@rubytech/create-realagent 1.0.814 → 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.
- package/package.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +4 -2
- package/payload/platform/plugins/admin/skills/onboarding/SKILL.md +2 -0
- package/payload/platform/plugins/cloudflare/PLUGIN.md +2 -2
- package/payload/platform/plugins/docs/references/cloudflare.md +5 -3
- package/payload/platform/plugins/docs/references/deployment.md +12 -12
- package/payload/platform/plugins/docs/references/internals.md +24 -24
- package/payload/platform/plugins/docs/references/memory-guide.md +1 -1
- package/payload/platform/plugins/docs/references/outlook-guide.md +1 -1
- package/payload/platform/plugins/docs/references/plugins-guide.md +8 -8
- package/payload/platform/plugins/docs/references/troubleshooting.md +38 -38
- package/payload/platform/plugins/memory/PLUGIN.md +4 -4
- package/payload/platform/plugins/whatsapp/PLUGIN.md +10 -4
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +80 -0
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/whatsapp-import/PLUGIN.md +4 -4
- package/payload/platform/templates/agents/admin/IDENTITY.md +2 -0
- package/payload/platform/templates/specialists/agents/personal-assistant.md +2 -2
- package/payload/server/chunk-42BMMSRN.js +10066 -0
- package/payload/server/chunk-52LIWKMM.js +1032 -0
- package/payload/server/chunk-UYLZDEMC.js +1114 -0
- package/payload/server/chunk-Y3UQFQM7.js +10067 -0
- package/payload/server/client-pool-AIYWSJBR.js +31 -0
- package/payload/server/client-pool-BMPFHXHB.js +31 -0
- package/payload/server/maxy-edge.js +2 -2
- package/payload/server/public/assets/{Checkbox-DZxF6s72.js → Checkbox-CTGhpDKq.js} +1 -1
- package/payload/server/public/assets/{admin-DfuHw_TQ.js → admin-Cxtmv0wo.js} +60 -60
- package/payload/server/public/assets/data-Y77FLKjs.js +1 -0
- package/payload/server/public/assets/graph-C4-jEPDE.js +1 -0
- package/payload/server/public/assets/{jsx-runtime-Cb4WEnIV.css → jsx-runtime-D4WovFYk.css} +1 -1
- package/payload/server/public/assets/{page-BLanFGXC.js → page-DkBfWy4C.js} +1 -1
- package/payload/server/public/assets/{page-DuwlF8N5.js → page-zuI00fuC.js} +1 -1
- package/payload/server/public/assets/{public-BqeUfasT.js → public-BdVIVpv8.js} +1 -1
- package/payload/server/public/assets/{useAdminFetch-DLGqK3Fs.js → useAdminFetch-DmHu0oCx.js} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-CHPkBGVV.js → useVoiceRecorder-CSc_hxjV.js} +1 -1
- package/payload/server/public/data.html +5 -5
- package/payload/server/public/graph.html +6 -6
- package/payload/server/public/index.html +8 -8
- package/payload/server/public/public.html +5 -5
- package/payload/server/server.js +225 -9
- package/payload/server/public/assets/data-BO12TydY.js +0 -1
- package/payload/server/public/assets/graph-XIePTyWQ.js +0 -1
- /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>Real Agent</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/public-
|
|
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-
|
|
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-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-
|
|
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>
|
package/payload/server/server.js
CHANGED
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
vncLog,
|
|
54
54
|
waitForExit,
|
|
55
55
|
writeChromiumWrapper
|
|
56
|
-
} from "./chunk-
|
|
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-
|
|
84
|
+
} from "./chunk-UYLZDEMC.js";
|
|
85
85
|
import {
|
|
86
86
|
ACCOUNTS_DIR,
|
|
87
87
|
GREETING_DIRECTIVE,
|
|
@@ -829,6 +829,30 @@ function defaultRules() {
|
|
|
829
829
|
thresholdWindowMinutes: 0,
|
|
830
830
|
suggestedAction: "[Task 867] cloudflare-setup completed but the post-action relay never reached the chat history. Check `[action-relay-queue] phase=enqueued` (queue write), `[action-completion-relay] phase=consumed` (boot-drain ran), and `[persist] role=user \u2026 Cloudflare setup completed` (graph write). One of those is missing; the matching grep recipe is in the Task 867 brief Observability section."
|
|
831
831
|
},
|
|
832
|
+
{
|
|
833
|
+
// Task 879 §C — onboarding turn-completion contract: any assistant
|
|
834
|
+
// turn that narrates a step transition with a non-question-terminated
|
|
835
|
+
// phrase ("Moving to step 9 — operator persona...", "Step 8 done.")
|
|
836
|
+
// must be followed within 30s by either a `render-component` call
|
|
837
|
+
// (the next step's UI surfaces) or `onboarding-complete-step`
|
|
838
|
+
// (deterministic step advance). The trigger pattern matches the
|
|
839
|
+
// `[onboarding-step-narration]` line written by stream-parser at the
|
|
840
|
+
// assistant text block emit site (only for non-question phrases).
|
|
841
|
+
// Operator's symptom in Task 879's evidence: "Moving to step 9..."
|
|
842
|
+
// followed by 4 minutes of silence until the operator nudged with
|
|
843
|
+
// "yeah, so?" — exact failure shape this rule catches.
|
|
844
|
+
id: "assistant-step-advance-deadend",
|
|
845
|
+
name: "Onboarding step-advance narration without follow-up tool call",
|
|
846
|
+
type: "absent-followup",
|
|
847
|
+
logSource: "session",
|
|
848
|
+
pattern: "\\[onboarding-step-narration\\]",
|
|
849
|
+
followupPattern: "\\[render-component\\]|\\[tool-use\\][^\\n]*name=mcp__admin__onboarding-complete-step",
|
|
850
|
+
followupWindowMs: 3e4,
|
|
851
|
+
thresholdCount: 0,
|
|
852
|
+
thresholdWindowMinutes: 0,
|
|
853
|
+
scope: "session",
|
|
854
|
+
suggestedAction: '[Task 879 \xA7C] An onboarding turn narrated a step transition (e.g. "Moving to step N", "Step N done.") but did not render a component or call `onboarding-complete-step` within 30s. The operator is left with a dead-end paragraph and no actionable surface. Check the `platform/plugins/admin/skills/onboarding/SKILL.md` Turn-completion contract section \u2014 the agent must end any step-advance turn with `render-component` or a `?`-terminated question, never bare prose.'
|
|
855
|
+
},
|
|
832
856
|
{
|
|
833
857
|
// Task 538: fires when a [spawn] line appears in a conversation's stream
|
|
834
858
|
// log but no subprocess-lifecycle marker follows within 10s. The three
|
|
@@ -2725,19 +2749,25 @@ function maybeRestoreCredsFromBackup(authDir) {
|
|
|
2725
2749
|
function readSelfId(authDir) {
|
|
2726
2750
|
try {
|
|
2727
2751
|
const credsPath = resolveCredsPath(authDir);
|
|
2728
|
-
if (!fsSync.existsSync(credsPath)) return { e164: null, jid: null };
|
|
2752
|
+
if (!fsSync.existsSync(credsPath)) return { e164: null, jid: null, lid: null };
|
|
2729
2753
|
const raw = fsSync.readFileSync(credsPath, "utf-8");
|
|
2730
2754
|
const parsed = JSON.parse(raw);
|
|
2731
2755
|
const jid = parsed?.me?.id ?? null;
|
|
2756
|
+
const lidRaw = parsed?.me?.lid ?? null;
|
|
2732
2757
|
let e164 = null;
|
|
2733
2758
|
if (jid) {
|
|
2734
2759
|
const match = jid.match(/^(\d+)(?::\d+)?@s\.whatsapp\.net$/i);
|
|
2735
2760
|
if (match) e164 = match[1];
|
|
2736
2761
|
}
|
|
2737
|
-
|
|
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 };
|
|
2738
2768
|
} catch (err) {
|
|
2739
2769
|
console.warn(`${TAG2} readSelfId failed authDir=${authDir}: ${String(err)}`);
|
|
2740
|
-
return { e164: null, jid: null };
|
|
2770
|
+
return { e164: null, jid: null, lid: null };
|
|
2741
2771
|
}
|
|
2742
2772
|
}
|
|
2743
2773
|
async function clearAuth(authDir) {
|
|
@@ -3222,6 +3252,20 @@ function phonesMatch(a, b) {
|
|
|
3222
3252
|
function isLidJid(jid) {
|
|
3223
3253
|
return WHATSAPP_LID_RE.test(jid);
|
|
3224
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
|
+
}
|
|
3225
3269
|
async function resolveJidToE164(jid, lidMapping) {
|
|
3226
3270
|
if (!jid) return null;
|
|
3227
3271
|
const userMatch = jid.match(WHATSAPP_USER_JID_RE);
|
|
@@ -4343,6 +4387,7 @@ async function startConnection(accountId) {
|
|
|
4343
4387
|
connected: false,
|
|
4344
4388
|
selfPhone: null,
|
|
4345
4389
|
selfJid: null,
|
|
4390
|
+
selfLid: null,
|
|
4346
4391
|
reconnectAttempts: 0,
|
|
4347
4392
|
abortController: new AbortController(),
|
|
4348
4393
|
debouncer: null,
|
|
@@ -4406,7 +4451,13 @@ async function registerLoginSocket(accountId, sock, authDir) {
|
|
|
4406
4451
|
}
|
|
4407
4452
|
await stopConnection(accountId);
|
|
4408
4453
|
const selfId = readSelfId(authDir);
|
|
4409
|
-
const
|
|
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
|
+
}
|
|
4410
4461
|
const conn = {
|
|
4411
4462
|
accountId,
|
|
4412
4463
|
platformAccountId,
|
|
@@ -4416,6 +4467,7 @@ async function registerLoginSocket(accountId, sock, authDir) {
|
|
|
4416
4467
|
connected: true,
|
|
4417
4468
|
selfPhone: selfId.e164,
|
|
4418
4469
|
selfJid: selfId.jid,
|
|
4470
|
+
selfLid: selfId.lid,
|
|
4419
4471
|
reconnectAttempts: 0,
|
|
4420
4472
|
lastConnectedAt: Date.now(),
|
|
4421
4473
|
abortController: new AbortController(),
|
|
@@ -4439,8 +4491,36 @@ async function registerLoginSocket(accountId, sock, authDir) {
|
|
|
4439
4491
|
});
|
|
4440
4492
|
monitorInbound(conn);
|
|
4441
4493
|
watchForDisconnect(conn);
|
|
4494
|
+
attachSelfIdRefreshOnCredsUpdate(conn);
|
|
4442
4495
|
console.error(`${TAG13} registered login socket for account=${accountId} phone=${selfId.e164 ?? "unknown"}`);
|
|
4443
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
|
+
}
|
|
4444
4524
|
function reloadConfig(accountConfig) {
|
|
4445
4525
|
loadConfig(accountConfig);
|
|
4446
4526
|
}
|
|
@@ -4504,9 +4584,16 @@ async function connectWithReconnect(conn) {
|
|
|
4504
4584
|
conn.connected = true;
|
|
4505
4585
|
conn.selfPhone = selfId.e164;
|
|
4506
4586
|
conn.selfJid = selfId.jid;
|
|
4587
|
+
conn.selfLid = selfId.lid;
|
|
4507
4588
|
conn.lastConnectedAt = connectedAt;
|
|
4508
4589
|
conn.lastError = void 0;
|
|
4509
|
-
|
|
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
|
+
}
|
|
4510
4597
|
console.error(`${TAG13} connected account=${conn.accountId} phone=${selfId.e164 ?? "unknown"}`);
|
|
4511
4598
|
try {
|
|
4512
4599
|
await sock.sendPresenceUpdate("available");
|
|
@@ -4526,6 +4613,7 @@ async function connectWithReconnect(conn) {
|
|
|
4526
4613
|
conn.debouncer = null;
|
|
4527
4614
|
}
|
|
4528
4615
|
monitorInbound(conn);
|
|
4616
|
+
attachSelfIdRefreshOnCredsUpdate(conn);
|
|
4529
4617
|
await waitForDisconnectEvent(conn);
|
|
4530
4618
|
uptimeMs = Date.now() - connectedAt;
|
|
4531
4619
|
conn.connected = false;
|
|
@@ -4876,8 +4964,16 @@ async function handleInboundMessage(conn, msg) {
|
|
|
4876
4964
|
senderPhone,
|
|
4877
4965
|
selfPhone,
|
|
4878
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.
|
|
4879
4975
|
isMentioned: extracted.mentionedJids.some(
|
|
4880
|
-
(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
|
|
4881
4977
|
),
|
|
4882
4978
|
config: whatsAppConfig,
|
|
4883
4979
|
accountConfig: whatsAppConfig.accounts?.[conn.accountId]
|
|
@@ -7777,6 +7873,93 @@ app7.get("/messages", (c) => {
|
|
|
7777
7873
|
return c.json({ error: String(err) }, 500);
|
|
7778
7874
|
}
|
|
7779
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
|
+
});
|
|
7780
7963
|
app7.get("/group-info", async (c) => {
|
|
7781
7964
|
const accountId = validateAccountId(c.req.query("accountId") ?? null);
|
|
7782
7965
|
const jid = c.req.query("jid");
|
|
@@ -8414,6 +8597,39 @@ app10.post("/", async (c) => {
|
|
|
8414
8597
|
const payload = await createAdminSession(selected.accountId, selected.config.thinkingView, userId, userName, selected.role, avatar);
|
|
8415
8598
|
return c.json(payload);
|
|
8416
8599
|
});
|
|
8600
|
+
app10.post("/rebind", async (c) => {
|
|
8601
|
+
let body;
|
|
8602
|
+
try {
|
|
8603
|
+
body = await c.req.json();
|
|
8604
|
+
} catch {
|
|
8605
|
+
return c.json({ ok: false, error: "invalid_json" }, 400);
|
|
8606
|
+
}
|
|
8607
|
+
const sessionKey = typeof body.session_key === "string" ? body.session_key : "";
|
|
8608
|
+
const conversationId = typeof body.lastKnownConversationId === "string" ? body.lastKnownConversationId : "";
|
|
8609
|
+
if (!sessionKey || !conversationId) {
|
|
8610
|
+
return c.json({ ok: false, error: "session_key and lastKnownConversationId required" }, 400);
|
|
8611
|
+
}
|
|
8612
|
+
const sk8 = sessionKey.slice(0, 8);
|
|
8613
|
+
const cid8 = conversationId.slice(0, 8);
|
|
8614
|
+
const bridge = await tryCookieBridgeForConversation(c, sessionKey, conversationId);
|
|
8615
|
+
if (!bridge.ok) {
|
|
8616
|
+
console.log(`[admin/session/rebind] sessionKey=${sk8}\u2026 result=bridge-rejected reason=${bridge.reason} conversationId=${cid8}\u2026`);
|
|
8617
|
+
const status = bridge.reason === "conversation-not-found" ? 404 : bridge.reason === "account-mismatch" ? 403 : 401;
|
|
8618
|
+
return c.json({ ok: false, error: bridge.reason }, status);
|
|
8619
|
+
}
|
|
8620
|
+
const existing = getConversationIdForSession(sessionKey);
|
|
8621
|
+
if (existing && existing !== conversationId) {
|
|
8622
|
+
console.log(`[admin/session/rebind] sessionKey=${sk8}\u2026 result=conflict conversationId=${existing.slice(0, 8)}\u2026 requested=${cid8}\u2026`);
|
|
8623
|
+
return c.json({ ok: false, error: "conflict", conversationId: existing }, 409);
|
|
8624
|
+
}
|
|
8625
|
+
const bound = setConversationIdForSession(sessionKey, conversationId);
|
|
8626
|
+
if (!bound) {
|
|
8627
|
+
console.error(`[admin/session/rebind] sessionKey=${sk8}\u2026 result=bind-failed conversationId=${cid8}\u2026 (post-bridge session-store missing \u2014 programmer error)`);
|
|
8628
|
+
return c.json({ ok: false, error: "bind_failed" }, 500);
|
|
8629
|
+
}
|
|
8630
|
+
console.log(`[admin/session/rebind] sessionKey=${sk8}\u2026 result=ok conversationId=${cid8}\u2026`);
|
|
8631
|
+
return c.json({ ok: true, conversationId });
|
|
8632
|
+
});
|
|
8417
8633
|
var session_default2 = app10;
|
|
8418
8634
|
|
|
8419
8635
|
// server/routes/admin/chat.ts
|
|
@@ -8708,7 +8924,7 @@ var app11 = new Hono();
|
|
|
8708
8924
|
app11.post("/cancel", requireAdminSession, async (c) => {
|
|
8709
8925
|
const session_key = c.var.sessionKey;
|
|
8710
8926
|
try {
|
|
8711
|
-
const { interruptClient: interruptClient2 } = await import("./client-pool-
|
|
8927
|
+
const { interruptClient: interruptClient2 } = await import("./client-pool-BMPFHXHB.js");
|
|
8712
8928
|
await interruptClient2(session_key);
|
|
8713
8929
|
return c.json({ ok: true });
|
|
8714
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,{}));
|
|
File without changes
|