easyoref 1.18.5 → 1.20.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.
- package/dist/agent/extract.d.ts +5 -5
- package/dist/agent/extract.d.ts.map +1 -1
- package/dist/agent/extract.js +77 -120
- package/dist/agent/extract.js.map +1 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +21 -31
- package/dist/agent/types.js.map +1 -1
- package/dist/bot.js +17 -19
- package/dist/bot.js.map +1 -1
- package/dist/gif-state.js +1 -1
- package/dist/gif-state.js.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/package.json +5 -9
- package/dist/agent/auth.d.ts +0 -11
- package/dist/agent/auth.d.ts.map +0 -1
- package/dist/agent/auth.js +0 -54
- package/dist/agent/auth.js.map +0 -1
- package/dist/agent/clarify.d.ts +0 -44
- package/dist/agent/clarify.d.ts.map +0 -1
- package/dist/agent/clarify.js +0 -285
- package/dist/agent/clarify.js.map +0 -1
- package/dist/agent/dry-run.d.ts +0 -12
- package/dist/agent/dry-run.d.ts.map +0 -1
- package/dist/agent/dry-run.js +0 -236
- package/dist/agent/dry-run.js.map +0 -1
- package/dist/agent/filters.d.ts +0 -48
- package/dist/agent/filters.d.ts.map +0 -1
- package/dist/agent/filters.js +0 -124
- package/dist/agent/filters.js.map +0 -1
- package/dist/agent/gramjs-monitor.d.ts +0 -26
- package/dist/agent/gramjs-monitor.d.ts.map +0 -1
- package/dist/agent/gramjs-monitor.js +0 -325
- package/dist/agent/gramjs-monitor.js.map +0 -1
- package/dist/agent/graph.d.ts +0 -30
- package/dist/agent/graph.d.ts.map +0 -1
- package/dist/agent/graph.js +0 -240
- package/dist/agent/graph.js.map +0 -1
- package/dist/agent/helpers.d.ts +0 -6
- package/dist/agent/helpers.d.ts.map +0 -1
- package/dist/agent/helpers.js +0 -15
- package/dist/agent/helpers.js.map +0 -1
- package/dist/agent/message.d.ts +0 -69
- package/dist/agent/message.d.ts.map +0 -1
- package/dist/agent/message.js +0 -479
- package/dist/agent/message.js.map +0 -1
- package/dist/agent/queue.d.ts +0 -15
- package/dist/agent/queue.d.ts.map +0 -1
- package/dist/agent/queue.js +0 -41
- package/dist/agent/queue.js.map +0 -1
- package/dist/agent/redis.d.ts +0 -8
- package/dist/agent/redis.d.ts.map +0 -1
- package/dist/agent/redis.js +0 -33
- package/dist/agent/redis.js.map +0 -1
- package/dist/agent/store.d.ts +0 -93
- package/dist/agent/store.d.ts.map +0 -1
- package/dist/agent/store.js +0 -145
- package/dist/agent/store.js.map +0 -1
- package/dist/agent/tools.d.ts +0 -159
- package/dist/agent/tools.d.ts.map +0 -1
- package/dist/agent/tools.js +0 -439
- package/dist/agent/tools.js.map +0 -1
- package/dist/agent/types.d.ts +0 -218
- package/dist/agent/vote.d.ts +0 -13
- package/dist/agent/vote.d.ts.map +0 -1
- package/dist/agent/vote.js +0 -246
- package/dist/agent/vote.js.map +0 -1
- package/dist/agent/worker.d.ts +0 -14
- package/dist/agent/worker.d.ts.map +0 -1
- package/dist/agent/worker.js +0 -137
- package/dist/agent/worker.js.map +0 -1
- package/dist/bin.d.ts +0 -17
- package/dist/bot.d.ts +0 -16
- package/dist/config.d.ts +0 -129
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -157
- package/dist/config.js.map +0 -1
- package/dist/gif-state.d.ts +0 -17
- package/dist/i18n.d.ts +0 -49
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js +0 -229
- package/dist/i18n.js.map +0 -1
- package/dist/init.d.ts +0 -7
- package/dist/logger.d.ts +0 -14
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -45
- package/dist/logger.js.map +0 -1
- package/dist/service.d.ts +0 -19
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -165
- package/dist/service.js.map +0 -1
package/dist/agent/clarify.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clarify Node — optional ReAct tool calling for low-confidence enrichment.
|
|
3
|
-
*
|
|
4
|
-
* When the voting pipeline produces a result below the confidence threshold,
|
|
5
|
-
* the clarify node gives the LLM access to 4 tools and lets it decide:
|
|
6
|
-
*
|
|
7
|
-
* - LLM sees the voted result, contradictions, and existing extractions
|
|
8
|
-
* - LLM MAY call tools if it thinks more data would help
|
|
9
|
-
* - LLM MAY respond immediately without tools if data is sufficient
|
|
10
|
-
* - Max 3 tool call iterations, then returns either way
|
|
11
|
-
*
|
|
12
|
-
* Tools:
|
|
13
|
-
* 1. read_telegram_sources — fetch N posts from a Telegram channel
|
|
14
|
-
* 2. alert_history — recent Oref alert history (was there really an alert?)
|
|
15
|
-
* 3. resolve_area — is a mentioned location relevant to user's areas?
|
|
16
|
-
* 4. betterstack_log — query recent EasyOref logs from Better Stack
|
|
17
|
-
*
|
|
18
|
-
* The LLM decides — not a deterministic threshold.
|
|
19
|
-
* Interview answer: "tools are available, agent is autonomous."
|
|
20
|
-
*/
|
|
21
|
-
import { AIMessage as AIMessageClass, HumanMessage, SystemMessage, ToolMessage, } from "@langchain/core/messages";
|
|
22
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
23
|
-
import { config } from "../config.js";
|
|
24
|
-
import * as logger from "../logger.js";
|
|
25
|
-
import { pushSessionPost } from "./store.js";
|
|
26
|
-
import { clarifyTools } from "./tools.js";
|
|
27
|
-
// ── Constants ──────────────────────────────────────────
|
|
28
|
-
const MAX_REACT_ITERATIONS = 3;
|
|
29
|
-
const CLARIFY_SYSTEM_PROMPT = `You are the clarification agent for EasyOref — an Israeli missile alert enrichment system.
|
|
30
|
-
|
|
31
|
-
The voting pipeline analyzed Telegram channel posts and produced a result with
|
|
32
|
-
low confidence or contradictions. You have access to 4 tools:
|
|
33
|
-
|
|
34
|
-
1. read_telegram_sources — fetch last N posts from a Telegram news channel
|
|
35
|
-
(IDF, N12, etc). Returns actual message texts.
|
|
36
|
-
2. alert_history — get recent alert history from Pikud HaOref.
|
|
37
|
-
Answers: "was there really an alert in area X in the last N minutes?"
|
|
38
|
-
3. resolve_area — check if a location mentioned in news is relevant to the
|
|
39
|
-
user's monitored areas. Uses defense-zone proximity mapping.
|
|
40
|
-
4. betterstack_log — query recent EasyOref logs from Better Stack.
|
|
41
|
-
See what the enrichment pipeline did recently (extractions, confidence, errors).
|
|
42
|
-
|
|
43
|
-
CRITICAL — TIME VALIDATION:
|
|
44
|
-
You receive the alert time (Israel timezone). Channel posts may be about PREVIOUS
|
|
45
|
-
attacks or ongoing military operations (not THIS specific alert). When in doubt:
|
|
46
|
-
- Use alert_history to verify if an alert really occurred at the claimed time/area.
|
|
47
|
-
- If a post discusses events from hours ago, it is STALE — ignore it.
|
|
48
|
-
- If the voted result has a country_origin that seems unlikely for the alert region
|
|
49
|
-
(e.g., "Lebanon" for central Israel) — verify with alert_history and fresh sources.
|
|
50
|
-
|
|
51
|
-
You decide whether tools would help:
|
|
52
|
-
- If contradictions can be resolved with existing data → respond immediately, no tools.
|
|
53
|
-
- If an authoritative source (IDF, N12) could settle a disagreement → fetch 1-4 posts.
|
|
54
|
-
- If you need to verify whether an alert occurred → check alert_history.
|
|
55
|
-
- If news mentions a city/region and you're unsure if it's relevant → use resolve_area.
|
|
56
|
-
- If the attack origin seems stale (about a previous event) → use alert_history to verify.
|
|
57
|
-
- You can call 0, 1, 2, or 3+ tools. Your choice.
|
|
58
|
-
|
|
59
|
-
When done (with or without tools), respond with ONLY valid JSON (no markdown):
|
|
60
|
-
{
|
|
61
|
-
"clarified": true/false,
|
|
62
|
-
"new_data": {
|
|
63
|
-
"country_origin": string|null,
|
|
64
|
-
"rocket_count": int|null,
|
|
65
|
-
"intercepted": int|null,
|
|
66
|
-
"hits_confirmed": int|null,
|
|
67
|
-
"casualties": int|null,
|
|
68
|
-
"injuries": int|null,
|
|
69
|
-
"is_cassette": bool|null
|
|
70
|
-
},
|
|
71
|
-
"confidence_boost": float, // 0-0.3 (0 if no new info)
|
|
72
|
-
"reasoning": "brief explanation of decision"
|
|
73
|
-
}`;
|
|
74
|
-
// ── LLM ───────────────────────────────────────────────
|
|
75
|
-
function getClarifyLLM() {
|
|
76
|
-
return new ChatOpenAI({
|
|
77
|
-
model: config.agent.filterModel,
|
|
78
|
-
configuration: {
|
|
79
|
-
baseURL: "https://openrouter.ai/api/v1",
|
|
80
|
-
defaultHeaders: {
|
|
81
|
-
"HTTP-Referer": "https://github.com/mikhailkogan17/EasyOref",
|
|
82
|
-
"X-Title": "EasyOref-Clarify",
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
apiKey: config.agent.apiKey,
|
|
86
|
-
temperature: 0,
|
|
87
|
-
maxTokens: 600,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
// ── Contradiction detection ───────────────────────────
|
|
91
|
-
function describeContradictions(extractions, voted) {
|
|
92
|
-
const issues = [];
|
|
93
|
-
// Country origin disagreement
|
|
94
|
-
if (voted.country_origins && voted.country_origins.length > 1) {
|
|
95
|
-
const names = voted.country_origins.map((c) => c.name).join(", ");
|
|
96
|
-
issues.push(`Multiple origin countries reported: ${names}`);
|
|
97
|
-
}
|
|
98
|
-
// Rocket count spread
|
|
99
|
-
if (voted.rocket_count_min !== null &&
|
|
100
|
-
voted.rocket_count_max !== null &&
|
|
101
|
-
voted.rocket_count_max - voted.rocket_count_min > 3) {
|
|
102
|
-
issues.push(`Wide rocket count range: ${voted.rocket_count_min}–${voted.rocket_count_max}`);
|
|
103
|
-
}
|
|
104
|
-
// Low sub-field confidence
|
|
105
|
-
if (voted.intercepted_confidence < 0.5 && voted.intercepted !== null) {
|
|
106
|
-
issues.push(`Intercepted count (${voted.intercepted}) has low confidence: ${voted.intercepted_confidence.toFixed(2)}`);
|
|
107
|
-
}
|
|
108
|
-
if (voted.hits_confidence < 0.5 && voted.hits_confirmed !== null) {
|
|
109
|
-
issues.push(`Hits confirmed (${voted.hits_confirmed}) has low confidence: ${voted.hits_confidence.toFixed(2)}`);
|
|
110
|
-
}
|
|
111
|
-
// Overall
|
|
112
|
-
issues.push(`Overall confidence: ${voted.confidence}`);
|
|
113
|
-
issues.push(`Sources count: ${voted.sources_count}`);
|
|
114
|
-
return issues.join("\n");
|
|
115
|
-
}
|
|
116
|
-
// ── ReAct loop ────────────────────────────────────────
|
|
117
|
-
export async function runClarify(input) {
|
|
118
|
-
const llm = getClarifyLLM();
|
|
119
|
-
const llmWithTools = llm.bindTools(clarifyTools);
|
|
120
|
-
const toolMap = new Map(clarifyTools.map((t) => [t.name, t]));
|
|
121
|
-
const contradictions = describeContradictions(input.extractions, input.votedResult);
|
|
122
|
-
const alertTimeIL = new Date(input.alertTs).toLocaleTimeString("he-IL", {
|
|
123
|
-
hour: "2-digit",
|
|
124
|
-
minute: "2-digit",
|
|
125
|
-
timeZone: "Asia/Jerusalem",
|
|
126
|
-
});
|
|
127
|
-
const userPrompt = `Alert region: ${input.alertAreas.join(", ")}\n` +
|
|
128
|
-
`Alert type: ${input.alertType}\n` +
|
|
129
|
-
`Alert time: ${alertTimeIL} (Israel)\n` +
|
|
130
|
-
`Message ID: ${input.messageId}\n\n` +
|
|
131
|
-
`Current voted result:\n` +
|
|
132
|
-
JSON.stringify(input.votedResult, null, 2) +
|
|
133
|
-
`\n\nContradictions & issues:\n${contradictions}\n\n` +
|
|
134
|
-
`Existing extractions (${input.extractions.filter((e) => e.valid).length} valid):\n` +
|
|
135
|
-
input.extractions
|
|
136
|
-
.filter((e) => e.valid)
|
|
137
|
-
.map((e) => ` [${e.channel}] country=${e.country_origin}, rockets=${e.rocket_count}, ` +
|
|
138
|
-
`intercepted=${e.intercepted}, hits=${e.hits_confirmed}, conf=${e.confidence}`)
|
|
139
|
-
.join("\n") +
|
|
140
|
-
`\n\nDecide: would fetching more data from authoritative channels or ` +
|
|
141
|
-
`the official API resolve these issues? If not, respond directly.`;
|
|
142
|
-
// Message history for the ReAct loop
|
|
143
|
-
const messages = [new SystemMessage(CLARIFY_SYSTEM_PROMPT), new HumanMessage(userPrompt)];
|
|
144
|
-
const newPosts = [];
|
|
145
|
-
let toolCallCount = 0;
|
|
146
|
-
for (let iter = 0; iter < MAX_REACT_ITERATIONS; iter++) {
|
|
147
|
-
const response = (await llmWithTools.invoke(messages));
|
|
148
|
-
messages.push(new AIMessageClass({
|
|
149
|
-
content: typeof response.content === "string"
|
|
150
|
-
? response.content
|
|
151
|
-
: JSON.stringify(response.content),
|
|
152
|
-
tool_calls: response.tool_calls,
|
|
153
|
-
}));
|
|
154
|
-
// No tool calls → LLM is done
|
|
155
|
-
if (!response.tool_calls || response.tool_calls.length === 0) {
|
|
156
|
-
logger.info("Clarify: LLM finished without tool calls", {
|
|
157
|
-
iteration: iter,
|
|
158
|
-
alertId: input.alertId,
|
|
159
|
-
});
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
// Execute each tool call
|
|
163
|
-
for (const tc of response.tool_calls) {
|
|
164
|
-
toolCallCount++;
|
|
165
|
-
const foundTool = toolMap.get(tc.name);
|
|
166
|
-
if (!foundTool) {
|
|
167
|
-
logger.warn("Clarify: unknown tool requested", { tool: tc.name });
|
|
168
|
-
messages.push(new ToolMessage({
|
|
169
|
-
content: JSON.stringify({ error: `Unknown tool: ${tc.name}` }),
|
|
170
|
-
tool_call_id: tc.id ?? `call_${toolCallCount}`,
|
|
171
|
-
}));
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
logger.info("Clarify: calling tool", {
|
|
176
|
-
tool: tc.name,
|
|
177
|
-
args: tc.args,
|
|
178
|
-
alertId: input.alertId,
|
|
179
|
-
});
|
|
180
|
-
const result = await foundTool.invoke(tc.args);
|
|
181
|
-
const resultStr = typeof result === "string" ? result : JSON.stringify(result);
|
|
182
|
-
messages.push(new ToolMessage({
|
|
183
|
-
content: resultStr,
|
|
184
|
-
tool_call_id: tc.id ?? `call_${toolCallCount}`,
|
|
185
|
-
}));
|
|
186
|
-
// If read_sources returned posts, store them for the session
|
|
187
|
-
if (tc.name === "read_telegram_sources" &&
|
|
188
|
-
resultStr.includes('"posts"')) {
|
|
189
|
-
try {
|
|
190
|
-
const parsed = JSON.parse(resultStr);
|
|
191
|
-
if (Array.isArray(parsed.posts)) {
|
|
192
|
-
for (const p of parsed.posts) {
|
|
193
|
-
const post = {
|
|
194
|
-
channel: parsed.channel ?? tc.args.channel,
|
|
195
|
-
text: p.text ?? "",
|
|
196
|
-
ts: p.ts ?? Date.now(),
|
|
197
|
-
messageUrl: p.messageUrl,
|
|
198
|
-
};
|
|
199
|
-
newPosts.push(post);
|
|
200
|
-
await pushSessionPost(post);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
// JSON parse failed — ignore
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
catch (err) {
|
|
210
|
-
logger.warn("Clarify: tool execution failed", {
|
|
211
|
-
tool: tc.name,
|
|
212
|
-
error: String(err),
|
|
213
|
-
});
|
|
214
|
-
messages.push(new ToolMessage({
|
|
215
|
-
content: JSON.stringify({
|
|
216
|
-
error: `Tool execution failed: ${String(err)}`,
|
|
217
|
-
retry: false,
|
|
218
|
-
}),
|
|
219
|
-
tool_call_id: tc.id ?? `call_${toolCallCount}`,
|
|
220
|
-
}));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
// Parse the final LLM response for structured findings
|
|
225
|
-
const lastMsg = messages[messages.length - 1];
|
|
226
|
-
const lastContent = lastMsg && "content" in lastMsg && typeof lastMsg.content === "string"
|
|
227
|
-
? lastMsg.content
|
|
228
|
-
: "";
|
|
229
|
-
let clarified = false;
|
|
230
|
-
let newExtractions = [];
|
|
231
|
-
try {
|
|
232
|
-
const cleaned = lastContent
|
|
233
|
-
.replace(/^```(?:json)?\s*\n?/i, "")
|
|
234
|
-
.replace(/\n?```\s*$/i, "");
|
|
235
|
-
const findings = JSON.parse(cleaned.trim());
|
|
236
|
-
clarified = findings.clarified === true;
|
|
237
|
-
// Convert new_data into a synthetic validated extraction
|
|
238
|
-
if (findings.new_data && clarified) {
|
|
239
|
-
const syntheticExtraction = {
|
|
240
|
-
channel: "mcp_clarify",
|
|
241
|
-
region_relevance: 1.0,
|
|
242
|
-
source_trust: 0.85,
|
|
243
|
-
tone: "calm",
|
|
244
|
-
time_relevance: 1.0,
|
|
245
|
-
country_origin: findings.new_data.country_origin ?? null,
|
|
246
|
-
rocket_count: findings.new_data.rocket_count ?? null,
|
|
247
|
-
is_cassette: findings.new_data.is_cassette ?? null,
|
|
248
|
-
intercepted: findings.new_data.intercepted ?? null,
|
|
249
|
-
intercepted_qual: null,
|
|
250
|
-
intercepted_qual_num: null,
|
|
251
|
-
sea_impact: null,
|
|
252
|
-
sea_impact_qual: null,
|
|
253
|
-
sea_impact_qual_num: null,
|
|
254
|
-
open_area_impact: null,
|
|
255
|
-
open_area_impact_qual: null,
|
|
256
|
-
open_area_impact_qual_num: null,
|
|
257
|
-
hits_confirmed: findings.new_data.hits_confirmed ?? null,
|
|
258
|
-
casualties: findings.new_data.casualties ?? null,
|
|
259
|
-
injuries: findings.new_data.injuries ?? null,
|
|
260
|
-
injuries_cause: null,
|
|
261
|
-
eta_refined_minutes: null,
|
|
262
|
-
rocket_detail: null,
|
|
263
|
-
confidence: Math.min(0.9, (input.votedResult.confidence ?? 0.5) +
|
|
264
|
-
(findings.confidence_boost ?? 0.15)),
|
|
265
|
-
valid: true,
|
|
266
|
-
messageUrl: undefined,
|
|
267
|
-
};
|
|
268
|
-
newExtractions = [syntheticExtraction];
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
catch {
|
|
272
|
-
logger.info("Clarify: could not parse final LLM response as JSON", {
|
|
273
|
-
alertId: input.alertId,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
logger.info("Clarify: completed", {
|
|
277
|
-
alertId: input.alertId,
|
|
278
|
-
toolCallCount,
|
|
279
|
-
clarified,
|
|
280
|
-
newPosts: newPosts.length,
|
|
281
|
-
newExtractions: newExtractions.length,
|
|
282
|
-
});
|
|
283
|
-
return { newPosts, newExtractions, toolCallCount, clarified };
|
|
284
|
-
}
|
|
285
|
-
//# sourceMappingURL=clarify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clarify.js","sourceRoot":"","sources":["../../src/agent/clarify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EACL,SAAS,IAAI,cAAc,EAC3B,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA2B1C,0DAA0D;AAE1D,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4C5B,CAAC;AAEH,yDAAyD;AAEzD,SAAS,aAAa;IACpB,OAAO,IAAI,UAAU,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW;QAC/B,aAAa,EAAE;YACb,OAAO,EAAE,8BAA8B;YACvC,cAAc,EAAE;gBACd,cAAc,EAAE,4CAA4C;gBAC5D,SAAS,EAAE,kBAAkB;aAC9B;SACF;QACD,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;QAC3B,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,GAAG;KACf,CAAC,CAAC;AACL,CAAC;AAED,yDAAyD;AAEzD,SAAS,sBAAsB,CAC7B,WAAkC,EAClC,KAAkB;IAElB,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,8BAA8B;IAC9B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AC/B,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;gBACxD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI;gBAChD,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI;gBAC5C,cAAc,EAAE,IAAI;gBACpB,mBAAmB,EAAE,IAAI;gBACzB,aAAa,EAAE,IAAI;gBACnB,UAAU,EAAE,IAAI,CAAC,GAAG,CAClB,GAAG,EACH,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,IAAI,GAAG,CAAC;oBACnC,CAAC,QAAQ,CAAC,gBAAgB,IAAI,IAAI,CAAC,CACtC;gBACD,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,SAAS;aACtB,CAAC;YACF,cAAc,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,IAAI,CAAC,qDAAqD,EAAE;YACjE,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,aAAa;QACb,SAAS;QACT,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,cAAc,EAAE,cAAc,CAAC,MAAM;KACtC,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;AAChE,CAAC"}
|
package/dist/agent/dry-run.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dry-run: test vote + buildEnrichedMessage without Redis / Telegram / LLM.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* npx tsx packages/bot/src/agent/dry-run.ts
|
|
6
|
-
*
|
|
7
|
-
* Prints the enriched message HTML to stdout.
|
|
8
|
-
* Strip HTML tags to preview plain text:
|
|
9
|
-
* npx tsx packages/bot/src/agent/dry-run.ts | sed 's/<[^>]*>//g'
|
|
10
|
-
*/
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=dry-run.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dry-run.d.ts","sourceRoot":"","sources":["../../src/agent/dry-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
package/dist/agent/dry-run.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dry-run: test vote + buildEnrichedMessage without Redis / Telegram / LLM.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* npx tsx packages/bot/src/agent/dry-run.ts
|
|
6
|
-
*
|
|
7
|
-
* Prints the enriched message HTML to stdout.
|
|
8
|
-
* Strip HTML tags to preview plain text:
|
|
9
|
-
* npx tsx packages/bot/src/agent/dry-run.ts | sed 's/<[^>]*>//g'
|
|
10
|
-
*/
|
|
11
|
-
// ── Mock base message (as formatMessage() would produce) ──────────────────────
|
|
12
|
-
const BASE_MESSAGE = [
|
|
13
|
-
"<b>🚀 Ракетная атака</b>",
|
|
14
|
-
"Ожидаются прилёты. Пройдите в укрытие.",
|
|
15
|
-
"",
|
|
16
|
-
"<b>Район:</b> Тель-Авив — Яффо",
|
|
17
|
-
"<b>Подлётное время:</b> ~5–12 мин",
|
|
18
|
-
"<b>Время оповещения:</b> 03:47",
|
|
19
|
-
].join("\n");
|
|
20
|
-
// ── Mock validated extractions (normally come from LLM) ───────────────────────
|
|
21
|
-
const NOW = Date.now();
|
|
22
|
-
const ALERT_TS = NOW - 90_000; // alert was 90s ago
|
|
23
|
-
const MOCK_EXTRACTIONS = [
|
|
24
|
-
{
|
|
25
|
-
channel: "@newsflashhhj",
|
|
26
|
-
messageUrl: "https://t.me/newsflashhhj/12340",
|
|
27
|
-
region_relevance: 0.9,
|
|
28
|
-
source_trust: 0.85,
|
|
29
|
-
tone: "calm",
|
|
30
|
-
country_origin: "Iran",
|
|
31
|
-
rocket_count: 6,
|
|
32
|
-
is_cassette: false,
|
|
33
|
-
hits_confirmed: null,
|
|
34
|
-
hit_detail: null,
|
|
35
|
-
eta_refined_minutes: 8,
|
|
36
|
-
confidence: 0.88,
|
|
37
|
-
valid: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
channel: "@israelsecurity",
|
|
41
|
-
messageUrl: "https://t.me/israelsecurity/5521",
|
|
42
|
-
region_relevance: 0.85,
|
|
43
|
-
source_trust: 0.78,
|
|
44
|
-
tone: "neutral",
|
|
45
|
-
country_origin: "Lebanon",
|
|
46
|
-
rocket_count: 7,
|
|
47
|
-
is_cassette: true,
|
|
48
|
-
hits_confirmed: null,
|
|
49
|
-
hit_detail: null,
|
|
50
|
-
eta_refined_minutes: 9,
|
|
51
|
-
confidence: 0.75,
|
|
52
|
-
valid: true,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
channel: "@N12LIVE",
|
|
56
|
-
messageUrl: "https://t.me/N12LIVE/8802",
|
|
57
|
-
region_relevance: 0.7,
|
|
58
|
-
source_trust: 0.9,
|
|
59
|
-
tone: "calm",
|
|
60
|
-
country_origin: "Iran",
|
|
61
|
-
rocket_count: 5,
|
|
62
|
-
is_cassette: null,
|
|
63
|
-
hits_confirmed: 2,
|
|
64
|
-
hit_detail: "на открытой местности",
|
|
65
|
-
eta_refined_minutes: null,
|
|
66
|
-
confidence: 0.82,
|
|
67
|
-
valid: true,
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
// ── Inline copy of vote() + buildEnrichedMessage() ────────────────────────────
|
|
71
|
-
// (avoids importing config / redis which require a real config.yaml)
|
|
72
|
-
const SUPERSCRIPTS = ["⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"];
|
|
73
|
-
function sup(indices) {
|
|
74
|
-
return indices
|
|
75
|
-
.map((n) => String(n)
|
|
76
|
-
.split("")
|
|
77
|
-
.map((d) => SUPERSCRIPTS[Number(d)])
|
|
78
|
-
.join(""))
|
|
79
|
-
.join("");
|
|
80
|
-
}
|
|
81
|
-
const COUNTRY_RU = {
|
|
82
|
-
Iran: "Иран",
|
|
83
|
-
Yemen: "Йемен",
|
|
84
|
-
Lebanon: "Ливан",
|
|
85
|
-
Gaza: "Газа",
|
|
86
|
-
Iraq: "Ирак",
|
|
87
|
-
Syria: "Сирия",
|
|
88
|
-
Hezbollah: "Хезболла",
|
|
89
|
-
};
|
|
90
|
-
function vote(extractions) {
|
|
91
|
-
const indexed = extractions.map((e, i) => ({ ...e, idx: i + 1 }));
|
|
92
|
-
const citedSources = indexed.map((e) => ({
|
|
93
|
-
index: e.idx,
|
|
94
|
-
channel: e.channel,
|
|
95
|
-
messageUrl: e.messageUrl ?? null,
|
|
96
|
-
}));
|
|
97
|
-
// ETA: highest-confidence source
|
|
98
|
-
const withEta = indexed
|
|
99
|
-
.filter((e) => e.eta_refined_minutes !== null)
|
|
100
|
-
.sort((a, b) => b.confidence - a.confidence);
|
|
101
|
-
const bestEta = withEta[0] ?? null;
|
|
102
|
-
// Countries: group, collect citations
|
|
103
|
-
const countryMap = new Map();
|
|
104
|
-
for (const e of indexed) {
|
|
105
|
-
if (e.country_origin) {
|
|
106
|
-
const list = countryMap.get(e.country_origin) ?? [];
|
|
107
|
-
list.push(e.idx);
|
|
108
|
-
countryMap.set(e.country_origin, list);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const country_origins = countryMap.size > 0
|
|
112
|
-
? Array.from(countryMap.entries()).map(([name, citations]) => ({
|
|
113
|
-
name,
|
|
114
|
-
citations,
|
|
115
|
-
}))
|
|
116
|
-
: null;
|
|
117
|
-
// Rocket range
|
|
118
|
-
const rocketSrcs = indexed.filter((e) => e.rocket_count !== null);
|
|
119
|
-
const rocketVals = rocketSrcs.map((e) => e.rocket_count);
|
|
120
|
-
const rocket_count_min = rocketVals.length > 0 ? Math.min(...rocketVals) : null;
|
|
121
|
-
const rocket_count_max = rocketVals.length > 0 ? Math.max(...rocketVals) : null;
|
|
122
|
-
const rocket_citations = rocketSrcs.map((e) => e.idx);
|
|
123
|
-
// Cassette: majority
|
|
124
|
-
const cassVals = indexed
|
|
125
|
-
.filter((e) => e.is_cassette !== null)
|
|
126
|
-
.map((e) => e.is_cassette);
|
|
127
|
-
const is_cassette = cassVals.length > 0
|
|
128
|
-
? cassVals.filter(Boolean).length > cassVals.length / 2
|
|
129
|
-
: null;
|
|
130
|
-
// Hits: median
|
|
131
|
-
const hitsVals = indexed
|
|
132
|
-
.filter((e) => e.hits_confirmed !== null)
|
|
133
|
-
.map((e) => e.hits_confirmed)
|
|
134
|
-
.sort((a, b) => a - b);
|
|
135
|
-
const hits_confirmed = hitsVals.length > 0 ? hitsVals[Math.floor(hitsVals.length / 2)] : null;
|
|
136
|
-
// Hits citations
|
|
137
|
-
const hitsSrcs = indexed.filter((e) => e.hits_confirmed !== null && e.hits_confirmed > 0);
|
|
138
|
-
const hits_citations = hitsSrcs.map((e) => e.idx);
|
|
139
|
-
// Weighted confidence
|
|
140
|
-
const totalWeight = indexed.reduce((s, e) => s + e.source_trust * e.confidence, 0);
|
|
141
|
-
return {
|
|
142
|
-
eta_refined_minutes: bestEta?.eta_refined_minutes ?? null,
|
|
143
|
-
eta_citations: bestEta ? [bestEta.idx] : [],
|
|
144
|
-
country_origins,
|
|
145
|
-
rocket_count_min,
|
|
146
|
-
rocket_count_max,
|
|
147
|
-
is_cassette,
|
|
148
|
-
rocket_citations,
|
|
149
|
-
hits_confirmed,
|
|
150
|
-
hits_citations,
|
|
151
|
-
confidence: Math.round((totalWeight / indexed.length) * 100) / 100,
|
|
152
|
-
sources_count: indexed.length,
|
|
153
|
-
citedSources,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function insertBeforeBlockEnd(text, line) {
|
|
157
|
-
const bqIdx = text.lastIndexOf("</blockquote>");
|
|
158
|
-
if (bqIdx !== -1) {
|
|
159
|
-
return text.slice(0, bqIdx) + line + "\n" + text.slice(bqIdx);
|
|
160
|
-
}
|
|
161
|
-
const timeLinePattern = /(<b>Время оповещения:<\/b>)/;
|
|
162
|
-
const match = text.match(timeLinePattern);
|
|
163
|
-
if (match?.index !== undefined) {
|
|
164
|
-
return text.slice(0, match.index) + line + "\n" + text.slice(match.index);
|
|
165
|
-
}
|
|
166
|
-
const lines = text.split("\n");
|
|
167
|
-
lines.splice(Math.max(lines.length - 1, 0), 0, line);
|
|
168
|
-
return lines.join("\n");
|
|
169
|
-
}
|
|
170
|
-
function refineEtaInPlace(text, minutes, alertTs, citations) {
|
|
171
|
-
const absTime = new Date(alertTs + minutes * 60_000).toLocaleTimeString("he-IL", { hour: "2-digit", minute: "2-digit", timeZone: "Asia/Jerusalem" });
|
|
172
|
-
const refined = `~${absTime}${sup(citations)}`;
|
|
173
|
-
const etaPatterns = [
|
|
174
|
-
/~\d+[–-]\d+\s*мин/,
|
|
175
|
-
/~\d+[–-]\d+\s*min/,
|
|
176
|
-
/~\d+[–-]\d+\s*דקות/,
|
|
177
|
-
/1\.5\s*мин/,
|
|
178
|
-
/1\.5\s*min/,
|
|
179
|
-
];
|
|
180
|
-
for (const pattern of etaPatterns) {
|
|
181
|
-
if (pattern.test(text))
|
|
182
|
-
return text.replace(pattern, refined);
|
|
183
|
-
}
|
|
184
|
-
return text;
|
|
185
|
-
}
|
|
186
|
-
function buildEnrichedMessage(currentText, alertTs, r) {
|
|
187
|
-
let text = currentText;
|
|
188
|
-
if (r.eta_refined_minutes !== null && r.eta_citations.length > 0) {
|
|
189
|
-
text = refineEtaInPlace(text, r.eta_refined_minutes, alertTs, r.eta_citations);
|
|
190
|
-
}
|
|
191
|
-
if (r.country_origins && r.country_origins.length > 0) {
|
|
192
|
-
const parts = r.country_origins.map((c) => {
|
|
193
|
-
const ru = COUNTRY_RU[c.name] ?? c.name;
|
|
194
|
-
return `${ru}${sup(c.citations)}`;
|
|
195
|
-
});
|
|
196
|
-
// Leading \n creates blank line between ETA and intel block
|
|
197
|
-
text = insertBeforeBlockEnd(text, `\n<b>Откуда:</b> ${parts.join(" + ")}`);
|
|
198
|
-
}
|
|
199
|
-
if (r.rocket_count_min !== null && r.rocket_count_max !== null) {
|
|
200
|
-
const countStr = r.rocket_count_min === r.rocket_count_max
|
|
201
|
-
? `${r.rocket_count_min}`
|
|
202
|
-
: `~${r.rocket_count_min}-${r.rocket_count_max}`;
|
|
203
|
-
const cassette = r.is_cassette ? " (кассет.)" : "";
|
|
204
|
-
text = insertBeforeBlockEnd(text, `<b>Ракет:</b> ${countStr}${cassette}`);
|
|
205
|
-
}
|
|
206
|
-
if (r.hits_confirmed !== null && r.hits_confirmed > 0) {
|
|
207
|
-
const hitsCite = r.hits_citations.length > 0 ? sup(r.hits_citations) : "";
|
|
208
|
-
text = insertBeforeBlockEnd(text, `<b>Попадания (Дан центр):</b> ${r.hits_confirmed}${hitsCite}`);
|
|
209
|
-
}
|
|
210
|
-
const sourcesWithUrl = r.citedSources.filter((s) => s.messageUrl);
|
|
211
|
-
if (sourcesWithUrl.length > 0) {
|
|
212
|
-
const links = sourcesWithUrl
|
|
213
|
-
.map((s) => `<a href="${s.messageUrl}">[${s.index}]</a>`)
|
|
214
|
-
.join(" ");
|
|
215
|
-
text += `\n—\n<i>Источники: ${links}</i>`;
|
|
216
|
-
}
|
|
217
|
-
return text;
|
|
218
|
-
}
|
|
219
|
-
// ── Run ───────────────────────────────────────────────────────────────────────
|
|
220
|
-
const voted = vote(MOCK_EXTRACTIONS);
|
|
221
|
-
console.log("\n=== VOTE RESULT ===");
|
|
222
|
-
console.log(JSON.stringify(voted, null, 2));
|
|
223
|
-
const enriched = buildEnrichedMessage(BASE_MESSAGE, ALERT_TS, voted);
|
|
224
|
-
console.log("\n=== ENRICHED MESSAGE (HTML) ===");
|
|
225
|
-
console.log(enriched);
|
|
226
|
-
console.log("\n=== PLAIN TEXT PREVIEW ===");
|
|
227
|
-
console.log(enriched
|
|
228
|
-
.replace(/<[^>]*>/g, "")
|
|
229
|
-
.replace(/</g, "<")
|
|
230
|
-
.replace(/>/g, ">"));
|
|
231
|
-
console.log(`\n=== STATS ===`);
|
|
232
|
-
console.log(`Confidence: ${voted.confidence}`);
|
|
233
|
-
console.log(`Sources: ${voted.sources_count}`);
|
|
234
|
-
console.log(`Chars: ${enriched.length} (TG caption limit: 1024)`);
|
|
235
|
-
export {};
|
|
236
|
-
//# sourceMappingURL=dry-run.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dry-run.js","sourceRoot":"","sources":["../../src/agent/dry-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iFAAiF;AAEjF,MAAM,YAAY,GAAG;IACnB,0BAA0B;IAC1B,wCAAwC;IACxC,EAAE;IACF,gCAAgC;IAChC,mCAAmC;IACnC,gCAAgC;CACjC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,iFAAiF;AAEjF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACvB,MAAM,QAAQ,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,oBAAoB;AAEnD,MAAM,gBAAgB,GAAG;IACvB;QACE,OAAO,EAAE,eAAe;QACxB,UAAU,EAAE,iCAAiC;QAC7C,gBAAgB,EAAE,GAAG;QACrB,YAAY,EAAE,IAAI;QAClB,IAAI,EAAE,MAAe;QACrB,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,KAAK;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;QAChB,mBAAmB,EAAE,CAAC;QACtB,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ;IACD;QACE,OAAO,EAAE,iBAAiB;QAC1B,UAAU,EAAE,kCAAkC;QAC9C,gBAAgB,EAAE,IAAI;QACtB,YAAY,EAAE,IAAI;QAClB,IAAI,EAAE,SAAkB;QACxB,cAAc,EAAE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comma count)
|
|
6
|
-
* - Summary/recap posts with timestamp patterns "(HH:MM)", "X минут"
|
|
7
|
-
* - IDF/Tsahal press releases (long official texts)
|
|
8
|
-
*
|
|
9
|
-
* Builds ChannelTracking structure for the LLM pipeline.
|
|
10
|
-
*/
|
|
11
|
-
import type { ChannelPost } from "./store.js";
|
|
12
|
-
import type { ChannelTracking, TrackedMessage } from "./types.js";
|
|
13
|
-
/**
|
|
14
|
-
* Pikud HaOref "простыня" — area list with many commas.
|
|
15
|
-
*/
|
|
16
|
-
declare function isAreaListNoise(text: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Summary/recap posts with timestamp patterns.
|
|
19
|
-
* Real-time intel doesn't contain multiple "(HH:MM)" timestamps
|
|
20
|
-
* or "X минут/минуты" duration references.
|
|
21
|
-
*/
|
|
22
|
-
declare function isSummaryPost(text: string): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* IDF/Tsahal press releases — long official texts (>400 chars from IDF channels).
|
|
25
|
-
*/
|
|
26
|
-
declare function isIdfPressRelease(channel: string, text: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Combined noise filter. Returns true if post should be filtered OUT.
|
|
29
|
-
*/
|
|
30
|
-
export declare function isNoise(post: ChannelPost): boolean;
|
|
31
|
-
declare function toTrackedMessage(post: ChannelPost): TrackedMessage;
|
|
32
|
-
/**
|
|
33
|
-
* Build ChannelTracking from session posts.
|
|
34
|
-
*
|
|
35
|
-
* Splits posts per channel into prev (already processed) and last (new).
|
|
36
|
-
* Applies deterministic noise filter on all posts.
|
|
37
|
-
* Only includes channels that have new (last) messages.
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildChannelTracking(posts: ChannelPost[], sessionStartTs: number, lastUpdateTs: number): ChannelTracking;
|
|
40
|
-
export declare const _test: {
|
|
41
|
-
readonly isAreaListNoise: typeof isAreaListNoise;
|
|
42
|
-
readonly isSummaryPost: typeof isSummaryPost;
|
|
43
|
-
readonly isIdfPressRelease: typeof isIdfPressRelease;
|
|
44
|
-
readonly isNoise: typeof isNoise;
|
|
45
|
-
readonly toTrackedMessage: typeof toTrackedMessage;
|
|
46
|
-
};
|
|
47
|
-
export {};
|
|
48
|
-
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/agent/filters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EACV,eAAe,EAEf,cAAc,EACf,MAAM,YAAY,CAAC;AAQpB;;GAEG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI9C;AAED;;;;GAIG;AACH,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO5C;AAED;;GAEG;AACH,iBAAS,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUlD;AAID,iBAAS,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAO3D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAAE,EACpB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB,eAAe,CAuCjB;AAID,eAAO,MAAM,KAAK;;;;;;CAMR,CAAC"}
|