@rubytech/create-maxy 1.0.815 → 1.0.816

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 (39) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/PLUGIN.md +4 -2
  3. package/payload/platform/plugins/cloudflare/PLUGIN.md +2 -2
  4. package/payload/platform/plugins/docs/references/cloudflare.md +5 -5
  5. package/payload/platform/plugins/docs/references/deployment.md +12 -12
  6. package/payload/platform/plugins/docs/references/internals.md +24 -24
  7. package/payload/platform/plugins/docs/references/memory-guide.md +1 -1
  8. package/payload/platform/plugins/docs/references/outlook-guide.md +1 -1
  9. package/payload/platform/plugins/docs/references/plugins-guide.md +8 -8
  10. package/payload/platform/plugins/docs/references/troubleshooting.md +38 -38
  11. package/payload/platform/plugins/memory/PLUGIN.md +4 -4
  12. package/payload/platform/plugins/whatsapp/PLUGIN.md +10 -4
  13. package/payload/platform/plugins/whatsapp/mcp/dist/index.js +80 -0
  14. package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
  15. package/payload/platform/plugins/whatsapp-import/PLUGIN.md +4 -4
  16. package/payload/platform/templates/agents/admin/IDENTITY.md +2 -0
  17. package/payload/platform/templates/specialists/agents/personal-assistant.md +2 -2
  18. package/payload/server/chunk-UYLZDEMC.js +1114 -0
  19. package/payload/server/chunk-Y3UQFQM7.js +10067 -0
  20. package/payload/server/client-pool-BMPFHXHB.js +31 -0
  21. package/payload/server/maxy-edge.js +2 -2
  22. package/payload/server/public/assets/{Checkbox-DZxF6s72.js → Checkbox-CTGhpDKq.js} +1 -1
  23. package/payload/server/public/assets/{admin-CTb65MiO.js → admin-Cxtmv0wo.js} +1 -1
  24. package/payload/server/public/assets/data-Y77FLKjs.js +1 -0
  25. package/payload/server/public/assets/graph-C4-jEPDE.js +1 -0
  26. package/payload/server/public/assets/{jsx-runtime-Cb4WEnIV.css → jsx-runtime-D4WovFYk.css} +1 -1
  27. package/payload/server/public/assets/{page-BLanFGXC.js → page-DkBfWy4C.js} +1 -1
  28. package/payload/server/public/assets/{page-DuwlF8N5.js → page-zuI00fuC.js} +1 -1
  29. package/payload/server/public/assets/{public-BqeUfasT.js → public-BdVIVpv8.js} +1 -1
  30. package/payload/server/public/assets/{useAdminFetch-DLGqK3Fs.js → useAdminFetch-DmHu0oCx.js} +1 -1
  31. package/payload/server/public/assets/{useVoiceRecorder-CHPkBGVV.js → useVoiceRecorder-CSc_hxjV.js} +1 -1
  32. package/payload/server/public/data.html +5 -5
  33. package/payload/server/public/graph.html +6 -6
  34. package/payload/server/public/index.html +8 -8
  35. package/payload/server/public/public.html +5 -5
  36. package/payload/server/server.js +168 -9
  37. package/payload/server/public/assets/data-BO12TydY.js +0 -1
  38. package/payload/server/public/assets/graph-XIePTyWQ.js +0 -1
  39. /package/payload/server/public/assets/{jsx-runtime-BZMOvG0f.js → jsx-runtime-DkaAusaX.js} +0 -0
@@ -5,13 +5,13 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/public-BqeUfasT.js"></script>
8
+ <script type="module" crossorigin src="/assets/public-BdVIVpv8.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BZMOvG0f.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DkaAusaX.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
12
- <link rel="modulepreload" crossorigin href="/assets/Checkbox-DZxF6s72.js">
13
- <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-CHPkBGVV.js">
14
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Cb4WEnIV.css">
12
+ <link rel="modulepreload" crossorigin href="/assets/Checkbox-CTGhpDKq.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-CSc_hxjV.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-D4WovFYk.css">
15
15
  <link rel="stylesheet" href="/brand-defaults.css">
16
16
  </head>
17
17
  <body>
@@ -53,7 +53,7 @@ import {
53
53
  vncLog,
54
54
  waitForExit,
55
55
  writeChromiumWrapper
56
- } from "./chunk-42BMMSRN.js";
56
+ } from "./chunk-Y3UQFQM7.js";
57
57
  import {
58
58
  agentLogStream,
59
59
  clearSessionHistory,
@@ -81,7 +81,7 @@ import {
81
81
  sigtermFlushStreamLogs,
82
82
  unregisterSession,
83
83
  validateSession
84
- } from "./chunk-52LIWKMM.js";
84
+ } from "./chunk-UYLZDEMC.js";
85
85
  import {
86
86
  ACCOUNTS_DIR,
87
87
  GREETING_DIRECTIVE,
@@ -2749,19 +2749,25 @@ function maybeRestoreCredsFromBackup(authDir) {
2749
2749
  function readSelfId(authDir) {
2750
2750
  try {
2751
2751
  const credsPath = resolveCredsPath(authDir);
2752
- if (!fsSync.existsSync(credsPath)) return { e164: null, jid: null };
2752
+ if (!fsSync.existsSync(credsPath)) return { e164: null, jid: null, lid: null };
2753
2753
  const raw = fsSync.readFileSync(credsPath, "utf-8");
2754
2754
  const parsed = JSON.parse(raw);
2755
2755
  const jid = parsed?.me?.id ?? null;
2756
+ const lidRaw = parsed?.me?.lid ?? null;
2756
2757
  let e164 = null;
2757
2758
  if (jid) {
2758
2759
  const match = jid.match(/^(\d+)(?::\d+)?@s\.whatsapp\.net$/i);
2759
2760
  if (match) e164 = match[1];
2760
2761
  }
2761
- return { e164, jid };
2762
+ let lid = null;
2763
+ if (lidRaw) {
2764
+ const lidMatch = lidRaw.match(/^(\d+)(?::\d+)?@lid$/i);
2765
+ if (lidMatch) lid = `${lidMatch[1]}@lid`;
2766
+ }
2767
+ return { e164, jid, lid };
2762
2768
  } catch (err) {
2763
2769
  console.warn(`${TAG2} readSelfId failed authDir=${authDir}: ${String(err)}`);
2764
- return { e164: null, jid: null };
2770
+ return { e164: null, jid: null, lid: null };
2765
2771
  }
2766
2772
  }
2767
2773
  async function clearAuth(authDir) {
@@ -3246,6 +3252,20 @@ function phonesMatch(a, b) {
3246
3252
  function isLidJid(jid) {
3247
3253
  return WHATSAPP_LID_RE.test(jid);
3248
3254
  }
3255
+ function withSelfLidShortcut(base, selfLid, selfJid) {
3256
+ if (!selfLid || !selfJid) return base;
3257
+ return {
3258
+ getPNForLID: async (lid) => {
3259
+ if (lid === selfLid) return selfJid;
3260
+ try {
3261
+ return await base?.getPNForLID(lid);
3262
+ } catch (err) {
3263
+ console.error(`[whatsapp:normalize] base lidMapping.getPNForLID threw lid=${lid}: ${String(err)}`);
3264
+ return void 0;
3265
+ }
3266
+ }
3267
+ };
3268
+ }
3249
3269
  async function resolveJidToE164(jid, lidMapping) {
3250
3270
  if (!jid) return null;
3251
3271
  const userMatch = jid.match(WHATSAPP_USER_JID_RE);
@@ -4367,6 +4387,7 @@ async function startConnection(accountId) {
4367
4387
  connected: false,
4368
4388
  selfPhone: null,
4369
4389
  selfJid: null,
4390
+ selfLid: null,
4370
4391
  reconnectAttempts: 0,
4371
4392
  abortController: new AbortController(),
4372
4393
  debouncer: null,
@@ -4430,7 +4451,13 @@ async function registerLoginSocket(accountId, sock, authDir) {
4430
4451
  }
4431
4452
  await stopConnection(accountId);
4432
4453
  const selfId = readSelfId(authDir);
4433
- const lidMapping = sock.signalRepository?.lidMapping ?? null;
4454
+ const rawLidMapping = sock.signalRepository?.lidMapping ?? null;
4455
+ const lidMapping = withSelfLidShortcut(rawLidMapping, selfId.lid, selfId.jid);
4456
+ if (selfId.lid) {
4457
+ console.error(`[whatsapp:lid] resolved self-lid accountId=${accountId} selfLid=${selfId.lid} source=creds`);
4458
+ } else {
4459
+ console.error(`[whatsapp:lid] FAIL self-lid-resolution accountId=${accountId} reason=creds-missing-lid`);
4460
+ }
4434
4461
  const conn = {
4435
4462
  accountId,
4436
4463
  platformAccountId,
@@ -4440,6 +4467,7 @@ async function registerLoginSocket(accountId, sock, authDir) {
4440
4467
  connected: true,
4441
4468
  selfPhone: selfId.e164,
4442
4469
  selfJid: selfId.jid,
4470
+ selfLid: selfId.lid,
4443
4471
  reconnectAttempts: 0,
4444
4472
  lastConnectedAt: Date.now(),
4445
4473
  abortController: new AbortController(),
@@ -4463,8 +4491,36 @@ async function registerLoginSocket(accountId, sock, authDir) {
4463
4491
  });
4464
4492
  monitorInbound(conn);
4465
4493
  watchForDisconnect(conn);
4494
+ attachSelfIdRefreshOnCredsUpdate(conn);
4466
4495
  console.error(`${TAG13} registered login socket for account=${accountId} phone=${selfId.e164 ?? "unknown"}`);
4467
4496
  }
4497
+ function attachSelfIdRefreshOnCredsUpdate(conn) {
4498
+ if (!conn.sock) return;
4499
+ const sock = conn.sock;
4500
+ const handler = () => {
4501
+ setTimeout(() => {
4502
+ try {
4503
+ const fresh = readSelfId(conn.authDir);
4504
+ const lidChanged = fresh.lid !== conn.selfLid;
4505
+ conn.selfPhone = fresh.e164;
4506
+ conn.selfJid = fresh.jid;
4507
+ conn.selfLid = fresh.lid;
4508
+ const rawLidMapping = sock?.signalRepository?.lidMapping ?? null;
4509
+ conn.lidMapping = withSelfLidShortcut(rawLidMapping, fresh.lid, fresh.jid);
4510
+ if (lidChanged) {
4511
+ if (fresh.lid) {
4512
+ console.error(`[whatsapp:lid] resolved self-lid accountId=${conn.accountId} selfLid=${fresh.lid} source=creds-update`);
4513
+ } else {
4514
+ console.error(`[whatsapp:lid] FAIL self-lid-resolution accountId=${conn.accountId} reason=creds-update-cleared-lid`);
4515
+ }
4516
+ }
4517
+ } catch (err) {
4518
+ console.error(`[whatsapp:lid] FAIL self-lid-refresh accountId=${conn.accountId} reason=${String(err).slice(0, 80)}`);
4519
+ }
4520
+ }, 1e3).unref?.();
4521
+ };
4522
+ sock.ev.on("creds.update", handler);
4523
+ }
4468
4524
  function reloadConfig(accountConfig) {
4469
4525
  loadConfig(accountConfig);
4470
4526
  }
@@ -4528,9 +4584,16 @@ async function connectWithReconnect(conn) {
4528
4584
  conn.connected = true;
4529
4585
  conn.selfPhone = selfId.e164;
4530
4586
  conn.selfJid = selfId.jid;
4587
+ conn.selfLid = selfId.lid;
4531
4588
  conn.lastConnectedAt = connectedAt;
4532
4589
  conn.lastError = void 0;
4533
- conn.lidMapping = sock.signalRepository?.lidMapping ?? null;
4590
+ const rawLidMapping = sock.signalRepository?.lidMapping ?? null;
4591
+ conn.lidMapping = withSelfLidShortcut(rawLidMapping, selfId.lid, selfId.jid);
4592
+ if (selfId.lid) {
4593
+ console.error(`[whatsapp:lid] resolved self-lid accountId=${conn.accountId} selfLid=${selfId.lid} source=creds`);
4594
+ } else {
4595
+ console.error(`[whatsapp:lid] FAIL self-lid-resolution accountId=${conn.accountId} reason=creds-missing-lid`);
4596
+ }
4534
4597
  console.error(`${TAG13} connected account=${conn.accountId} phone=${selfId.e164 ?? "unknown"}`);
4535
4598
  try {
4536
4599
  await sock.sendPresenceUpdate("available");
@@ -4550,6 +4613,7 @@ async function connectWithReconnect(conn) {
4550
4613
  conn.debouncer = null;
4551
4614
  }
4552
4615
  monitorInbound(conn);
4616
+ attachSelfIdRefreshOnCredsUpdate(conn);
4553
4617
  await waitForDisconnectEvent(conn);
4554
4618
  uptimeMs = Date.now() - connectedAt;
4555
4619
  conn.connected = false;
@@ -4900,8 +4964,16 @@ async function handleInboundMessage(conn, msg) {
4900
4964
  senderPhone,
4901
4965
  selfPhone,
4902
4966
  groupJid: remoteJid,
4967
+ // Three-way mention recognition (Sub-fix 4): legacy phone-JID equality,
4968
+ // legacy E.164-via-jidToE164 equality, plus the new self-LID equality so
4969
+ // mentions in LID-addressed groups (deliver as `<self-lid>@lid`) match.
4970
+ // Pre-LID groups continue matching the first two — additive, never blocks.
4971
+ // Each clause guards against null on its right operand; a creds-parse
4972
+ // failure leaves all three of selfJid/selfLid/selfPhone null and
4973
+ // jidToE164 of a malformed mention also returns null — without the
4974
+ // guards, `null === null` would spuriously match every nullified field.
4903
4975
  isMentioned: extracted.mentionedJids.some(
4904
- (jid) => jid === conn.selfJid || jidToE164(jid) === conn.selfPhone
4976
+ (jid) => conn.selfJid !== null && jid === conn.selfJid || conn.selfLid !== null && jid === conn.selfLid || conn.selfPhone !== null && jidToE164(jid) === conn.selfPhone
4905
4977
  ),
4906
4978
  config: whatsAppConfig,
4907
4979
  accountConfig: whatsAppConfig.accounts?.[conn.accountId]
@@ -7801,6 +7873,93 @@ app7.get("/messages", (c) => {
7801
7873
  return c.json({ error: String(err) }, 500);
7802
7874
  }
7803
7875
  });
7876
+ app7.get("/conversation-graph-state", async (c) => {
7877
+ try {
7878
+ const directSessionKey = c.req.query("sessionKey");
7879
+ const jid = c.req.query("jid");
7880
+ const accountIdQuery = c.req.query("accountId");
7881
+ let sessionKey;
7882
+ if (directSessionKey) {
7883
+ sessionKey = directSessionKey;
7884
+ } else {
7885
+ if (!jid) {
7886
+ return c.json({ error: "Provide either sessionKey or jid (with optional accountId)." }, 400);
7887
+ }
7888
+ const accountId = validateAccountId(accountIdQuery ?? null);
7889
+ if (isGroupJid(jid)) {
7890
+ sessionKey = deriveSessionKey({
7891
+ agentType: "public",
7892
+ accountId,
7893
+ senderPhone: "",
7894
+ isGroup: true,
7895
+ groupJid: jid
7896
+ });
7897
+ } else {
7898
+ const e164 = jid.replace(/^(\d+)(?::\d+)?@s\.whatsapp\.net$/i, "$1");
7899
+ if (!/^\d+$/.test(e164)) {
7900
+ return c.json({ error: `Cannot derive sessionKey from jid=${jid} \u2014 not a recognised user JID. Pass sessionKey explicitly.` }, 400);
7901
+ }
7902
+ sessionKey = deriveSessionKey({
7903
+ agentType: "public",
7904
+ accountId,
7905
+ senderPhone: e164,
7906
+ isGroup: false
7907
+ });
7908
+ }
7909
+ }
7910
+ const cypher = `
7911
+ MATCH (c:Conversation {sessionKey: $sessionKey})
7912
+ OPTIONAL MATCH (m:Message:WhatsAppMessage)-[:PART_OF]->(c)
7913
+ RETURN
7914
+ c.conversationId AS conversationId,
7915
+ m.messageId AS messageId,
7916
+ m.dateSent AS dateSent,
7917
+ m.fromMe AS fromMe,
7918
+ m.senderTelephone AS senderTelephone,
7919
+ m.body AS body
7920
+ ORDER BY dateSent ASC
7921
+ `;
7922
+ let session = null;
7923
+ const t0 = Date.now();
7924
+ let conversationId = null;
7925
+ const rows = [];
7926
+ try {
7927
+ session = getSession();
7928
+ const result = await session.run(cypher, { sessionKey });
7929
+ for (const rec of result.records) {
7930
+ if (conversationId === null) {
7931
+ conversationId = rec.get("conversationId") ?? null;
7932
+ }
7933
+ const messageId = rec.get("messageId");
7934
+ if (!messageId) continue;
7935
+ const dateSentRaw = rec.get("dateSent");
7936
+ rows.push({
7937
+ messageId,
7938
+ dateSent: dateSentRaw ? String(dateSentRaw) : null,
7939
+ fromMe: rec.get("fromMe") === true,
7940
+ senderTelephone: rec.get("senderTelephone") ?? null,
7941
+ body: rec.get("body") ?? null
7942
+ });
7943
+ }
7944
+ } catch (err) {
7945
+ const msg = err instanceof Error ? err.message : String(err);
7946
+ console.error(`${TAG18} conversation-graph-state ERR sessionKey=${sessionKey} reason=${msg}`);
7947
+ return c.json({ error: `Graph query failed: ${msg}`, sessionKey, cypher: cypher.trim() }, 500);
7948
+ }
7949
+ const ms = Date.now() - t0;
7950
+ console.error(`[mcp:whatsapp] tool=whatsapp-conversation-graph-state sessionKey=${sessionKey} graphRows=${rows.length} conversationId=${conversationId ?? "null"} ms=${ms}`);
7951
+ return c.json({
7952
+ sessionKey,
7953
+ conversationId,
7954
+ graphRows: rows,
7955
+ cypher: cypher.trim(),
7956
+ ms
7957
+ });
7958
+ } catch (err) {
7959
+ console.error(`${TAG18} conversation-graph-state error: ${String(err)}`);
7960
+ return c.json({ error: String(err) }, 500);
7961
+ }
7962
+ });
7804
7963
  app7.get("/group-info", async (c) => {
7805
7964
  const accountId = validateAccountId(c.req.query("accountId") ?? null);
7806
7965
  const jid = c.req.query("jid");
@@ -8765,7 +8924,7 @@ var app11 = new Hono();
8765
8924
  app11.post("/cancel", requireAdminSession, async (c) => {
8766
8925
  const session_key = c.var.sessionKey;
8767
8926
  try {
8768
- const { interruptClient: interruptClient2 } = await import("./client-pool-AIYWSJBR.js");
8927
+ const { interruptClient: interruptClient2 } = await import("./client-pool-BMPFHXHB.js");
8769
8928
  await interruptClient2(session_key);
8770
8929
  return c.json({ ok: true });
8771
8930
  } catch (err) {
@@ -1 +0,0 @@
1
- import{i as e,t}from"./jsx-runtime-BZMOvG0f.js";import{t as n}from"./page-BLanFGXC.js";import"./useAdminFetch-DLGqK3Fs.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{i as e,t}from"./jsx-runtime-BZMOvG0f.js";import{n}from"./page-DuwlF8N5.js";import"./useAdminFetch-DLGqK3Fs.js";import"./Checkbox-DZxF6s72.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));