@rubytech/create-realagent 1.0.832 → 1.0.834
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/dist/index.js +131 -9
- package/package.json +1 -1
- package/payload/platform/lib/admins-write/dist/index.d.ts +87 -0
- package/payload/platform/lib/admins-write/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/admins-write/dist/index.js +248 -0
- package/payload/platform/lib/admins-write/dist/index.js.map +1 -0
- package/payload/platform/lib/admins-write/src/index.ts +311 -0
- package/payload/platform/lib/admins-write/tsconfig.json +8 -0
- package/payload/platform/neo4j/migrations/009-conversation-archive-title.ts +197 -0
- package/payload/platform/neo4j/schema.cypher +1 -1
- package/payload/platform/package.json +2 -2
- package/payload/platform/plugins/admin/PLUGIN.md +1 -1
- package/payload/platform/plugins/admin/mcp/dist/index.js +37 -44
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/docs/references/internals.md +4 -3
- package/payload/platform/plugins/memory/bin/conversation-archive-ingest.mjs +215 -43
- package/payload/platform/plugins/memory/bin/conversation-archive-ingest.sh +7 -2
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/llm-classifier.test.js +75 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/llm-classifier.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.d.ts +16 -10
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.js +155 -100
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.d.ts +13 -5
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.js +53 -59
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest.test.js +9 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.d.ts +24 -7
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js +47 -11
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js.map +1 -1
- package/payload/platform/plugins/memory/skills/conversation-archive/SKILL.md +45 -8
- package/payload/platform/scripts/lib/resolve-account-dir.sh +3 -1
- package/payload/platform/scripts/migrate-import.sh +3 -1
- package/payload/platform/scripts/seed-neo4j.sh +13 -3
- package/payload/server/chunk-CRAIGEXY.js +654 -0
- package/payload/server/chunk-GK4WHM3H.js +9961 -0
- package/payload/server/chunk-I2NOLBQA.js +2123 -0
- package/payload/server/chunk-IVTESKFR.js +9961 -0
- package/payload/server/chunk-KD3XP4IK.js +1116 -0
- package/payload/server/chunk-KKGGT5RH.js +654 -0
- package/payload/server/chunk-MRJGG6CS.js +2124 -0
- package/payload/server/chunk-OJZPS4BL.js +367 -0
- package/payload/server/chunk-ZVW5XKPU.js +1116 -0
- package/payload/server/client-pool-FM3YJWV5.js +32 -0
- package/payload/server/client-pool-J5BCVVI2.js +32 -0
- package/payload/server/cloudflare-task-tracker-FSPEJOTH.js +19 -0
- package/payload/server/cloudflare-task-tracker-XCUO4N74.js +19 -0
- package/payload/server/maxy-edge.js +6 -5
- package/payload/server/neo4j-migrations-5AN2U3YO.js +664 -0
- package/payload/server/neo4j-migrations-XP7XDVPX.js +664 -0
- package/payload/server/public/assets/{Checkbox-CTGhpDKq.js → Checkbox-Bq6ORjz2.js} +1 -1
- package/payload/server/public/assets/admin-CstEkw-G.js +352 -0
- package/payload/server/public/assets/data-DwZZ7qbH.js +1 -0
- package/payload/server/public/assets/graph-DceEv42K.js +1 -0
- package/payload/server/public/assets/{jsx-runtime-D4WovFYk.css → jsx-runtime-DidQeNoZ.css} +1 -1
- package/payload/server/public/assets/page-Bpi_jPw6.js +50 -0
- package/payload/server/public/assets/{page-DkBfWy4C.js → page-CFWoVkgV.js} +1 -1
- package/payload/server/public/assets/{public-BdVIVpv8.js → public-BWMwq5Jj.js} +1 -1
- package/payload/server/public/assets/{useAdminFetch-DmHu0oCx.js → useAdminFetch-B93ig7ef.js} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-CSc_hxjV.js → useVoiceRecorder-Cb0nAtOo.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 +376 -167
- package/payload/platform/plugins/admin/mcp/dist/lib/review-tools.d.ts +0 -31
- package/payload/platform/plugins/admin/mcp/dist/lib/review-tools.d.ts.map +0 -1
- package/payload/platform/plugins/admin/mcp/dist/lib/review-tools.js +0 -666
- package/payload/platform/plugins/admin/mcp/dist/lib/review-tools.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.d.ts +0 -61
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.js +0 -266
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-pass.d.ts +0 -27
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-pass.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-pass.js +0 -477
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-pass.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-write.d.ts +0 -27
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-write.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-write.js +0 -160
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-write.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-parse.d.ts +0 -10
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-parse.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-parse.js +0 -29
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-parse.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-preview.d.ts +0 -28
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-preview.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-preview.js +0 -34
- package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-preview.js.map +0 -1
- package/payload/server/public/assets/admin-BNwPsMhJ.js +0 -352
- package/payload/server/public/assets/data-Y77FLKjs.js +0 -1
- package/payload/server/public/assets/graph-N_Bw-8oT.js +0 -1
- package/payload/server/public/assets/page-BKLGP-th.js +0 -50
- /package/payload/server/public/assets/{jsx-runtime-DkaAusaX.js → jsx-runtime-DH5S-MwB.js} +0 -0
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { getSession } from "../lib/neo4j.js";
|
|
3
|
-
import { callOauthLlm } from "../../../../../lib/oauth-llm/dist/index.js";
|
|
4
|
-
import { HAIKU_MODEL } from "../../../../../lib/models/dist/index.js";
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// whatsapp-export-insight-pass — Phase 2 chunked-Haiku insight extraction
|
|
7
|
-
// over an already-loaded WhatsApp Conversation (Task 871).
|
|
8
|
-
//
|
|
9
|
-
// Phase 1 (whatsapp-ingest.sh) is now LLM-free. The operator triggers this
|
|
10
|
-
// tool consciously via the `whatsapp-import-enrich` skill ("enrich the X
|
|
11
|
-
// chat"). Each chunk runs Haiku with a forced submit-tool call; the server
|
|
12
|
-
// applies a confidence>=0.8 gate per item before MERGE-keying it as an
|
|
13
|
-
// :Observation node in the graph. Re-running over the same conversation is
|
|
14
|
-
// idempotent — the MERGE key collapses identical items into one row.
|
|
15
|
-
//
|
|
16
|
-
// Doctrine alignment:
|
|
17
|
-
// - feedback_deterministic_means_remove_llm.md — Phase 1 has no LLM;
|
|
18
|
-
// this tool is the only sanctioned LLM entry for WhatsApp ingest.
|
|
19
|
-
// - feedback_compress_at_ingest_for_bulk_archives.md — small chunks
|
|
20
|
-
// (50 msgs, overlap 5) keep per-message attention, and the confidence
|
|
21
|
-
// gate compresses on write.
|
|
22
|
-
// - feedback_classifier_runs_off_oauth_not_api_key.md — admin-side
|
|
23
|
-
// classifier; OAuth, never the API key.
|
|
24
|
-
// - feedback_loud_failures.md — Haiku fallback / write failures log a
|
|
25
|
-
// structured line; the per-chunk loop continues on per-call errors so
|
|
26
|
-
// one chunk does not pollute the full pass.
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
const INSIGHT_CHUNK_SIZE = 50;
|
|
29
|
-
const INSIGHT_CHUNK_OVERLAP = 5;
|
|
30
|
-
const CONFIDENCE_THRESHOLD = 0.8;
|
|
31
|
-
// Task 887 §C — parallel insight pass. Pre-887 the chunked loop ran
|
|
32
|
-
// 38 sequential Haiku calls inside one tool_call (~10s/chunk = ~380s),
|
|
33
|
-
// blowing past `MAIN_STREAM_STALL_THRESHOLD = 180s` in stream-parser.ts
|
|
34
|
-
// and tripping the SSE kill timer while the backend kept writing. With
|
|
35
|
-
// cap=8 the wall-clock collapses to ceil(38/8) × ~10s ≈ 50s — well under
|
|
36
|
-
// the SSE guard. Cross-chunk MERGE-keyed idempotence holds because every
|
|
37
|
-
// observation row uses `sourceMessageRef='chunk-pass'`, so the natural
|
|
38
|
-
// key (conversationId, sourceMessageRef, kind, contentHash) collapses
|
|
39
|
-
// concurrent writers to one row regardless of chunk-arrival ordering.
|
|
40
|
-
const INSIGHT_CONCURRENCY = 8;
|
|
41
|
-
const INSIGHT_HEARTBEAT_MS = 30_000;
|
|
42
|
-
const INSIGHT_SYSTEM_PROMPT = `You extract structured insights from a chunk of a WhatsApp conversation.
|
|
43
|
-
|
|
44
|
-
Return STRICT JSON via the provided tool. No prose, no commentary. Only items with concrete, verbatim evidence in the chunk. Empty arrays are valid; prefer omission to invention.
|
|
45
|
-
|
|
46
|
-
Definitions:
|
|
47
|
-
- "mention": a person, organisation, place, or named topic referred to by name.
|
|
48
|
-
- "task": something a participant committed to do or asked another to do (imperative or future-tense).
|
|
49
|
-
- "preference": stated like, dislike, opinion, or rule of behaviour.
|
|
50
|
-
- "observedRelationship": an explicit relational claim (works at, is married to, manages, etc.).
|
|
51
|
-
|
|
52
|
-
Every item carries a "confidence" float in [0,1]. Confidence reflects how unambiguously the evidence in the chunk supports the claim — not your prior belief about the world. Conversational filler ("let me know"), throwaway names without context, or speculative language ("maybe Ben works at Acme") MUST score below 0.8. The server discards items below 0.8.
|
|
53
|
-
|
|
54
|
-
Snippets must be ≤80 characters of the original message body, no sender names, no timestamps.`;
|
|
55
|
-
const INSIGHT_TOOL = {
|
|
56
|
-
name: "submit_insights",
|
|
57
|
-
description: "Submit the structured insights extracted from the chunk.",
|
|
58
|
-
input_schema: {
|
|
59
|
-
type: "object",
|
|
60
|
-
properties: {
|
|
61
|
-
mentions: {
|
|
62
|
-
type: "array",
|
|
63
|
-
items: {
|
|
64
|
-
type: "object",
|
|
65
|
-
properties: {
|
|
66
|
-
name: { type: "string" },
|
|
67
|
-
snippet: { type: "string" },
|
|
68
|
-
confidence: { type: "number" },
|
|
69
|
-
},
|
|
70
|
-
required: ["name", "snippet", "confidence"],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
tasks: {
|
|
74
|
-
type: "array",
|
|
75
|
-
items: {
|
|
76
|
-
type: "object",
|
|
77
|
-
properties: {
|
|
78
|
-
task: { type: "string" },
|
|
79
|
-
snippet: { type: "string" },
|
|
80
|
-
confidence: { type: "number" },
|
|
81
|
-
},
|
|
82
|
-
required: ["task", "snippet", "confidence"],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
preferences: {
|
|
86
|
-
type: "array",
|
|
87
|
-
items: {
|
|
88
|
-
type: "object",
|
|
89
|
-
properties: {
|
|
90
|
-
subject: { type: "string" },
|
|
91
|
-
preference: { type: "string" },
|
|
92
|
-
confidence: { type: "number" },
|
|
93
|
-
},
|
|
94
|
-
required: ["subject", "preference", "confidence"],
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
observedRelationships: {
|
|
98
|
-
type: "array",
|
|
99
|
-
items: {
|
|
100
|
-
type: "object",
|
|
101
|
-
properties: {
|
|
102
|
-
from: { type: "string" },
|
|
103
|
-
to: { type: "string" },
|
|
104
|
-
relationship: { type: "string" },
|
|
105
|
-
confidence: { type: "number" },
|
|
106
|
-
},
|
|
107
|
-
required: ["from", "to", "relationship", "confidence"],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
required: ["mentions", "tasks", "preferences", "observedRelationships"],
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
// MERGE-keyed Observation write. The natural key is
|
|
115
|
-
// (conversationId, sourceMessageRef, kind, contentHash) — Task 870's
|
|
116
|
-
// idempotence contract. `sourceMessageRef` is `chunk:<idx>` for items the
|
|
117
|
-
// chunked pass cannot attribute to a single :Message; Phase 2 enrichment
|
|
118
|
-
// recovers a message-level ref by snippet match later.
|
|
119
|
-
const INSIGHT_WRITE_CYPHER = `
|
|
120
|
-
MATCH (c:Conversation:WhatsAppConversation {conversationId: $conversationId})
|
|
121
|
-
UNWIND $observations AS obs
|
|
122
|
-
MERGE (o:Observation {
|
|
123
|
-
conversationId: $conversationId,
|
|
124
|
-
sourceMessageRef: obs.sourceMessageRef,
|
|
125
|
-
kind: obs.kind,
|
|
126
|
-
contentHash: obs.contentHash
|
|
127
|
-
})
|
|
128
|
-
ON CREATE SET
|
|
129
|
-
o:WhatsAppObservation,
|
|
130
|
-
o.accountId = $accountId,
|
|
131
|
-
o.summary = obs.summary,
|
|
132
|
-
o.snippet = obs.snippet,
|
|
133
|
-
o.subject = obs.subject,
|
|
134
|
-
o.from = obs.from,
|
|
135
|
-
o.to = obs.to,
|
|
136
|
-
o.confidence = obs.confidence,
|
|
137
|
-
o.source = 'whatsapp',
|
|
138
|
-
o.createdByAgent = 'whatsapp-export-insight-pass',
|
|
139
|
-
o.createdBySource = 'whatsapp-export-insight-pass',
|
|
140
|
-
o.createdBySession = $sessionId,
|
|
141
|
-
o.createdAt = datetime(),
|
|
142
|
-
o.scope = 'admin',
|
|
143
|
-
o.insightPass = true,
|
|
144
|
-
o.observationStatus = 'auto-extracted'
|
|
145
|
-
ON MATCH SET
|
|
146
|
-
o.lastSeenAt = datetime(),
|
|
147
|
-
o.lastSeenBySession = $sessionId
|
|
148
|
-
MERGE (o)-[r:OBSERVED_IN]->(c)
|
|
149
|
-
ON CREATE SET r.source = 'whatsapp', r.createdAt = datetime()
|
|
150
|
-
RETURN count(o) AS touched
|
|
151
|
-
`;
|
|
152
|
-
export async function whatsappExportInsightPass(params) {
|
|
153
|
-
const { conversationId, accountId } = params;
|
|
154
|
-
const sessionId = params.sessionId ?? null;
|
|
155
|
-
const startedMs = Date.now();
|
|
156
|
-
const session = getSession();
|
|
157
|
-
let messages;
|
|
158
|
-
try {
|
|
159
|
-
const res = await session.run(`MATCH (m:Message)-[:PART_OF]->(c:Conversation:WhatsAppConversation {conversationId: $conversationId})
|
|
160
|
-
WHERE m.accountId = $accountId
|
|
161
|
-
WITH m ORDER BY m.dateSent ASC, m.sequenceIndex ASC, m.messageId ASC
|
|
162
|
-
RETURN m.messageId AS messageId, m.senderName AS senderName, m.body AS body, m.dateSent AS dateSent`, { conversationId, accountId });
|
|
163
|
-
messages = res.records.map((r) => ({
|
|
164
|
-
messageId: r.get("messageId"),
|
|
165
|
-
senderName: r.get("senderName"),
|
|
166
|
-
body: r.get("body"),
|
|
167
|
-
dateSent: String(r.get("dateSent")),
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
finally {
|
|
171
|
-
await session.close();
|
|
172
|
-
}
|
|
173
|
-
if (messages.length === 0) {
|
|
174
|
-
process.stderr.write(`[whatsapp-export-insight-pass] empty-conversation conversationId=${conversationId}\n`);
|
|
175
|
-
return emptyResult(conversationId, Date.now() - startedMs);
|
|
176
|
-
}
|
|
177
|
-
// Build chunks with overlap. Step = chunkSize - overlap so consecutive
|
|
178
|
-
// chunks share the last `overlap` messages — preserves cross-message
|
|
179
|
-
// claims that straddle a chunk boundary.
|
|
180
|
-
const step = INSIGHT_CHUNK_SIZE - INSIGHT_CHUNK_OVERLAP;
|
|
181
|
-
const chunks = [];
|
|
182
|
-
for (let start = 0; start < messages.length; start += step) {
|
|
183
|
-
chunks.push(messages.slice(start, start + INSIGHT_CHUNK_SIZE));
|
|
184
|
-
if (start + INSIGHT_CHUNK_SIZE >= messages.length)
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
const totals = {
|
|
188
|
-
mentions: 0,
|
|
189
|
-
tasks: 0,
|
|
190
|
-
preferences: 0,
|
|
191
|
-
observedRelationships: 0,
|
|
192
|
-
rejectedLowConfidence: 0,
|
|
193
|
-
written: 0,
|
|
194
|
-
chunksThrew: 0,
|
|
195
|
-
chunksFallback: 0,
|
|
196
|
-
chunksUnexpected: 0,
|
|
197
|
-
chunksWriteFailed: 0,
|
|
198
|
-
};
|
|
199
|
-
process.stderr.write(`[whatsapp-export-insight-pass] start chunkSize=${INSIGHT_CHUNK_SIZE} overlap=${INSIGHT_CHUNK_OVERLAP} confidenceThreshold=${CONFIDENCE_THRESHOLD} chunks=${chunks.length} concurrency=${INSIGHT_CONCURRENCY} conversationId=${conversationId}\n`);
|
|
200
|
-
// Per-chunk worker — pure async function. Returns nothing; mutates the
|
|
201
|
-
// shared `totals` accumulator at the end of each successful run. Errors
|
|
202
|
-
// are caught per-chunk and logged; a single bad chunk does not poison
|
|
203
|
-
// the pass (parity with pre-887 behaviour).
|
|
204
|
-
async function runChunk(idx) {
|
|
205
|
-
const chunk = chunks[idx];
|
|
206
|
-
const transcript = chunk
|
|
207
|
-
.map((m, j) => `[${j + 1}] ${m.senderName}: ${m.body}`)
|
|
208
|
-
.join("\n");
|
|
209
|
-
let llmResult;
|
|
210
|
-
try {
|
|
211
|
-
llmResult = await callOauthLlm({
|
|
212
|
-
model: HAIKU_MODEL,
|
|
213
|
-
system: INSIGHT_SYSTEM_PROMPT,
|
|
214
|
-
userMessage: transcript,
|
|
215
|
-
maxTokens: 8192,
|
|
216
|
-
timeoutMs: 180_000,
|
|
217
|
-
tools: [INSIGHT_TOOL],
|
|
218
|
-
toolChoiceName: INSIGHT_TOOL.name,
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
catch (err) {
|
|
222
|
-
totals.chunksThrew++;
|
|
223
|
-
process.stderr.write(`[whatsapp-export-insight-pass] chunk=${idx + 1}/${chunks.length} threw="${err instanceof Error ? err.message : String(err)}"\n`);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (llmResult.kind === "fallback") {
|
|
227
|
-
totals.chunksFallback++;
|
|
228
|
-
process.stderr.write(`[whatsapp-export-insight-pass] chunk=${idx + 1}/${chunks.length} fallback cause=${llmResult.cause} reason="${llmResult.reason}"\n`);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (llmResult.kind !== "ok-tool") {
|
|
232
|
-
totals.chunksUnexpected++;
|
|
233
|
-
process.stderr.write(`[whatsapp-export-insight-pass] chunk=${idx + 1}/${chunks.length} unexpected-result kind=${llmResult.kind}\n`);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const input = (llmResult.input ?? {});
|
|
237
|
-
let chunkMentions = 0;
|
|
238
|
-
let chunkTasks = 0;
|
|
239
|
-
let chunkPreferences = 0;
|
|
240
|
-
let chunkObserved = 0;
|
|
241
|
-
let chunkRejected = 0;
|
|
242
|
-
// sourceMessageRef is constant `chunk-pass` for chunked items: the
|
|
243
|
-
// chunked Haiku has no per-message provenance, AND the 5-message overlap
|
|
244
|
-
// window deliberately surfaces the same message in two chunks. If we
|
|
245
|
-
// keyed by `chunk:<idx>`, the same mention extracted from both halves
|
|
246
|
-
// would land as two rows (different MERGE key), defeating idempotence.
|
|
247
|
-
// A constant ref means identical `(kind, contentHash)` collapses to one
|
|
248
|
-
// row regardless of which chunk surfaced it; cross-run idempotence holds
|
|
249
|
-
// even when chunk indices shift after a Phase-1 delta re-import.
|
|
250
|
-
// Concurrent writers under §C parallelism use the same constant ref —
|
|
251
|
-
// Neo4j MERGE is atomic per-row, so two chunks racing on the same key
|
|
252
|
-
// collapse to one node, not two.
|
|
253
|
-
const sourceMessageRef = "chunk-pass";
|
|
254
|
-
const observations = [];
|
|
255
|
-
for (const m of asArray(input.mentions)) {
|
|
256
|
-
const conf = numericConfidence(m.confidence);
|
|
257
|
-
if (conf < CONFIDENCE_THRESHOLD) {
|
|
258
|
-
chunkRejected++;
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
const summary = strSlice(m.name, 200);
|
|
262
|
-
const snippet = strSlice(m.snippet, 200);
|
|
263
|
-
observations.push({
|
|
264
|
-
kind: "mention",
|
|
265
|
-
sourceMessageRef,
|
|
266
|
-
contentHash: contentHashFor("mention", { summary, snippet }),
|
|
267
|
-
summary,
|
|
268
|
-
snippet,
|
|
269
|
-
subject: null,
|
|
270
|
-
from: null,
|
|
271
|
-
to: null,
|
|
272
|
-
confidence: conf,
|
|
273
|
-
});
|
|
274
|
-
chunkMentions++;
|
|
275
|
-
}
|
|
276
|
-
for (const t of asArray(input.tasks)) {
|
|
277
|
-
const conf = numericConfidence(t.confidence);
|
|
278
|
-
if (conf < CONFIDENCE_THRESHOLD) {
|
|
279
|
-
chunkRejected++;
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
const summary = strSlice(t.task, 200);
|
|
283
|
-
const snippet = strSlice(t.snippet, 200);
|
|
284
|
-
observations.push({
|
|
285
|
-
kind: "task",
|
|
286
|
-
sourceMessageRef,
|
|
287
|
-
contentHash: contentHashFor("task", { summary, snippet }),
|
|
288
|
-
summary,
|
|
289
|
-
snippet,
|
|
290
|
-
subject: null,
|
|
291
|
-
from: null,
|
|
292
|
-
to: null,
|
|
293
|
-
confidence: conf,
|
|
294
|
-
});
|
|
295
|
-
chunkTasks++;
|
|
296
|
-
}
|
|
297
|
-
for (const p of asArray(input.preferences)) {
|
|
298
|
-
const conf = numericConfidence(p.confidence);
|
|
299
|
-
if (conf < CONFIDENCE_THRESHOLD) {
|
|
300
|
-
chunkRejected++;
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
const summary = strSlice(p.preference, 200);
|
|
304
|
-
const subject = strSlice(p.subject, 200);
|
|
305
|
-
observations.push({
|
|
306
|
-
kind: "preference",
|
|
307
|
-
sourceMessageRef,
|
|
308
|
-
contentHash: contentHashFor("preference", { summary, subject }),
|
|
309
|
-
summary,
|
|
310
|
-
snippet: null,
|
|
311
|
-
subject,
|
|
312
|
-
from: null,
|
|
313
|
-
to: null,
|
|
314
|
-
confidence: conf,
|
|
315
|
-
});
|
|
316
|
-
chunkPreferences++;
|
|
317
|
-
}
|
|
318
|
-
for (const r of asArray(input.observedRelationships)) {
|
|
319
|
-
const conf = numericConfidence(r.confidence);
|
|
320
|
-
if (conf < CONFIDENCE_THRESHOLD) {
|
|
321
|
-
chunkRejected++;
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
const summary = strSlice(r.relationship, 200);
|
|
325
|
-
const from = strSlice(r.from, 200);
|
|
326
|
-
const to = strSlice(r.to, 200);
|
|
327
|
-
observations.push({
|
|
328
|
-
kind: "observed-relationship",
|
|
329
|
-
sourceMessageRef,
|
|
330
|
-
contentHash: contentHashFor("observed-relationship", { summary, from, to }),
|
|
331
|
-
summary,
|
|
332
|
-
snippet: null,
|
|
333
|
-
subject: null,
|
|
334
|
-
from,
|
|
335
|
-
to,
|
|
336
|
-
confidence: conf,
|
|
337
|
-
});
|
|
338
|
-
chunkObserved++;
|
|
339
|
-
}
|
|
340
|
-
process.stderr.write(`[whatsapp-export-insight-pass] chunk=${idx + 1}/${chunks.length} mentions=${chunkMentions} tasks=${chunkTasks} preferences=${chunkPreferences} observed=${chunkObserved} rejected-low-confidence=${chunkRejected}\n`);
|
|
341
|
-
let written = 0;
|
|
342
|
-
if (observations.length > 0) {
|
|
343
|
-
const writeSession = getSession();
|
|
344
|
-
try {
|
|
345
|
-
written = await writeSession.executeWrite(async (tx) => {
|
|
346
|
-
const res = await tx.run(INSIGHT_WRITE_CYPHER, {
|
|
347
|
-
conversationId,
|
|
348
|
-
accountId,
|
|
349
|
-
sessionId,
|
|
350
|
-
observations,
|
|
351
|
-
});
|
|
352
|
-
const stats = res.summary.counters.updates();
|
|
353
|
-
return stats.nodesCreated;
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
catch (err) {
|
|
357
|
-
totals.chunksWriteFailed++;
|
|
358
|
-
process.stderr.write(`[whatsapp-export-insight-pass] chunk=${idx + 1}/${chunks.length} write-failed reason="${err instanceof Error ? err.message : String(err)}"\n`);
|
|
359
|
-
}
|
|
360
|
-
finally {
|
|
361
|
-
await writeSession.close().catch(() => { });
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
// Single accumulation point per chunk — no interleaved partial writes
|
|
365
|
-
// to `totals`, so the final summary is the sum of completed chunks.
|
|
366
|
-
totals.mentions += chunkMentions;
|
|
367
|
-
totals.tasks += chunkTasks;
|
|
368
|
-
totals.preferences += chunkPreferences;
|
|
369
|
-
totals.observedRelationships += chunkObserved;
|
|
370
|
-
totals.rejectedLowConfidence += chunkRejected;
|
|
371
|
-
totals.written += written;
|
|
372
|
-
}
|
|
373
|
-
// Worker queue — fixed-size async pool over the chunk index range.
|
|
374
|
-
// No external dep; explicit and matches the project's preference for
|
|
375
|
-
// small, transparent helpers over imported abstractions
|
|
376
|
-
// (feedback_deterministic_means_remove_llm.md taste).
|
|
377
|
-
let nextChunk = 0;
|
|
378
|
-
let inflight = 0;
|
|
379
|
-
const workerCount = Math.min(INSIGHT_CONCURRENCY, chunks.length);
|
|
380
|
-
// Heartbeat — emits an observability stderr line every 30s for the
|
|
381
|
-
// duration of the parallel pass. The stream-parser stall reset is
|
|
382
|
-
// event-driven (SDK-level), so this line does NOT itself reset
|
|
383
|
-
// `mainStreamHeartbeats`; its job is to give the operator a grep-able
|
|
384
|
-
// tail when a future hang lands. Cleared in finally so a failure
|
|
385
|
-
// doesn't leak the timer.
|
|
386
|
-
const passStartMs = Date.now();
|
|
387
|
-
// Skip the heartbeat for tiny passes (≤1 chunk, ~10s of work) — the
|
|
388
|
-
// first tick fires at 30s after Promise.all resolves, so the signal is
|
|
389
|
-
// already a no-op. Saves a stray timer for short archives.
|
|
390
|
-
const heartbeatTimer = chunks.length > 1
|
|
391
|
-
? setInterval(() => {
|
|
392
|
-
const elapsedSec = Math.round((Date.now() - passStartMs) / 1000);
|
|
393
|
-
process.stderr.write(`[whatsapp-export-insight-pass] parallel concurrency=${workerCount} inflight=${inflight} chunks-started=${nextChunk}/${chunks.length} elapsed=${elapsedSec}s\n`);
|
|
394
|
-
}, INSIGHT_HEARTBEAT_MS)
|
|
395
|
-
: null;
|
|
396
|
-
try {
|
|
397
|
-
const workers = Array.from({ length: workerCount }, async () => {
|
|
398
|
-
while (true) {
|
|
399
|
-
const idx = nextChunk++;
|
|
400
|
-
if (idx >= chunks.length)
|
|
401
|
-
return;
|
|
402
|
-
inflight++;
|
|
403
|
-
try {
|
|
404
|
-
await runChunk(idx);
|
|
405
|
-
}
|
|
406
|
-
finally {
|
|
407
|
-
inflight--;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
await Promise.all(workers);
|
|
412
|
-
}
|
|
413
|
-
finally {
|
|
414
|
-
if (heartbeatTimer)
|
|
415
|
-
clearInterval(heartbeatTimer);
|
|
416
|
-
}
|
|
417
|
-
const elapsedMs = Date.now() - startedMs;
|
|
418
|
-
process.stderr.write(`[whatsapp-export-insight-pass] done conversationId=${conversationId} chunks=${chunks.length} mentions=${totals.mentions} tasks=${totals.tasks} preferences=${totals.preferences} observed=${totals.observedRelationships} rejected-low-confidence=${totals.rejectedLowConfidence} written=${totals.written} chunks-threw=${totals.chunksThrew} chunks-fallback=${totals.chunksFallback} chunks-unexpected=${totals.chunksUnexpected} chunks-write-failed=${totals.chunksWriteFailed} ms=${elapsedMs}\n`);
|
|
419
|
-
return {
|
|
420
|
-
conversationId,
|
|
421
|
-
chunks: chunks.length,
|
|
422
|
-
chunkSize: INSIGHT_CHUNK_SIZE,
|
|
423
|
-
overlap: INSIGHT_CHUNK_OVERLAP,
|
|
424
|
-
confidenceThreshold: CONFIDENCE_THRESHOLD,
|
|
425
|
-
totals,
|
|
426
|
-
ms: elapsedMs,
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
function emptyResult(conversationId, ms) {
|
|
430
|
-
return {
|
|
431
|
-
conversationId,
|
|
432
|
-
chunks: 0,
|
|
433
|
-
chunkSize: INSIGHT_CHUNK_SIZE,
|
|
434
|
-
overlap: INSIGHT_CHUNK_OVERLAP,
|
|
435
|
-
confidenceThreshold: CONFIDENCE_THRESHOLD,
|
|
436
|
-
totals: {
|
|
437
|
-
mentions: 0,
|
|
438
|
-
tasks: 0,
|
|
439
|
-
preferences: 0,
|
|
440
|
-
observedRelationships: 0,
|
|
441
|
-
rejectedLowConfidence: 0,
|
|
442
|
-
written: 0,
|
|
443
|
-
chunksThrew: 0,
|
|
444
|
-
chunksFallback: 0,
|
|
445
|
-
chunksUnexpected: 0,
|
|
446
|
-
chunksWriteFailed: 0,
|
|
447
|
-
},
|
|
448
|
-
ms,
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
function asArray(v) {
|
|
452
|
-
return Array.isArray(v) ? v : [];
|
|
453
|
-
}
|
|
454
|
-
function numericConfidence(v) {
|
|
455
|
-
const n = typeof v === "number" ? v : Number(v);
|
|
456
|
-
if (!Number.isFinite(n))
|
|
457
|
-
return 0;
|
|
458
|
-
if (n < 0)
|
|
459
|
-
return 0;
|
|
460
|
-
if (n > 1)
|
|
461
|
-
return 1;
|
|
462
|
-
return n;
|
|
463
|
-
}
|
|
464
|
-
function strSlice(v, max) {
|
|
465
|
-
return String(v ?? "").slice(0, max);
|
|
466
|
-
}
|
|
467
|
-
function contentHashFor(kind, fields) {
|
|
468
|
-
// Stable normalisation: NFKC + trim + lowercase per Task 870's idempotence
|
|
469
|
-
// contract. The hash is the natural-key tail; identical (kind, fields)
|
|
470
|
-
// collapse to one MERGE row across re-runs.
|
|
471
|
-
const ordered = Object.keys(fields).sort();
|
|
472
|
-
const norm = ordered
|
|
473
|
-
.map((k) => `${k}=${(fields[k] ?? "").normalize("NFKC").trim().toLowerCase()}`)
|
|
474
|
-
.join("|");
|
|
475
|
-
return createHash("sha256").update(`${kind}|${norm}`).digest("hex");
|
|
476
|
-
}
|
|
477
|
-
//# sourceMappingURL=whatsapp-export-insight-pass.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp-export-insight-pass.js","sourceRoot":"","sources":["../../src/tools/whatsapp-export-insight-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAEtE,8EAA8E;AAC9E,0EAA0E;AAC1E,2DAA2D;AAC3D,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,2EAA2E;AAC3E,qEAAqE;AACrE,EAAE;AACF,sBAAsB;AACtB,uEAAuE;AACvE,sEAAsE;AACtE,sEAAs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,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,QAAQ,CAAC,CAAU,EAAE,GAAW;IACvC,OAAO,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,MAA8B;IAClE,2EAA2E;IAC3E,uEAAuE;IACvE,4CAA4C;IAC5C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,OAAO;SACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;SAC9E,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface WhatsappExportInsightWriteParams {
|
|
2
|
-
kind: "MENTIONS" | "RELATED_TO";
|
|
3
|
-
conversationId: string;
|
|
4
|
-
messageId?: string;
|
|
5
|
-
fromNodeId: string;
|
|
6
|
-
toNodeId: string;
|
|
7
|
-
name: string;
|
|
8
|
-
candidateElementIds: string[];
|
|
9
|
-
disambiguatorOk?: boolean;
|
|
10
|
-
operatorConfirmed?: boolean;
|
|
11
|
-
evidenceMessageIds?: string[];
|
|
12
|
-
reason?: string;
|
|
13
|
-
accountId: string;
|
|
14
|
-
sessionId?: string;
|
|
15
|
-
allowedScopes?: string[];
|
|
16
|
-
envAgentSlug?: string;
|
|
17
|
-
envKeywordSubscriptions?: string[];
|
|
18
|
-
}
|
|
19
|
-
export interface WhatsappExportInsightWriteResult {
|
|
20
|
-
status: "written" | "merged" | "rejected";
|
|
21
|
-
rejectionReason?: "first-name-only" | "candidate-mismatch" | "relationship-needs-confirm" | "endpoints-not-found" | "endpoints-cross-account" | "endpoints-wrong-labels" | "self-edge";
|
|
22
|
-
edgeKind: "MENTIONS" | "RELATED_TO";
|
|
23
|
-
edgeElementId?: string;
|
|
24
|
-
candidatesSeen: number;
|
|
25
|
-
}
|
|
26
|
-
export declare function whatsappExportInsightWrite(params: WhatsappExportInsightWriteParams): Promise<WhatsappExportInsightWriteResult>;
|
|
27
|
-
//# sourceMappingURL=whatsapp-export-insight-write.d.ts.map
|
package/payload/platform/plugins/memory/mcp/dist/tools/whatsapp-export-insight-write.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp-export-insight-write.d.ts","sourceRoot":"","sources":["../../src/tools/whatsapp-export-insight-write.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,gCAAgC;IAC/C,IAAI,EAAE,UAAU,GAAG,YAAY,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC1C,eAAe,CAAC,EACZ,iBAAiB,GACjB,oBAAoB,GACpB,4BAA4B,GAC5B,qBAAqB,GACrB,yBAAyB,GACzB,wBAAwB,GACxB,WAAW,CAAC;IAChB,QAAQ,EAAE,UAAU,GAAG,YAAY,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gCAAgC,GACvC,OAAO,CAAC,gCAAgC,CAAC,CA4L3C"}
|