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.
Files changed (91) hide show
  1. package/dist/agent/extract.d.ts +5 -5
  2. package/dist/agent/extract.d.ts.map +1 -1
  3. package/dist/agent/extract.js +77 -120
  4. package/dist/agent/extract.js.map +1 -1
  5. package/dist/agent/types.d.ts.map +1 -1
  6. package/dist/agent/types.js +21 -31
  7. package/dist/agent/types.js.map +1 -1
  8. package/dist/bot.js +17 -19
  9. package/dist/bot.js.map +1 -1
  10. package/dist/gif-state.js +1 -1
  11. package/dist/gif-state.js.map +1 -1
  12. package/dist/init.js +1 -1
  13. package/dist/init.js.map +1 -1
  14. package/package.json +5 -9
  15. package/dist/agent/auth.d.ts +0 -11
  16. package/dist/agent/auth.d.ts.map +0 -1
  17. package/dist/agent/auth.js +0 -54
  18. package/dist/agent/auth.js.map +0 -1
  19. package/dist/agent/clarify.d.ts +0 -44
  20. package/dist/agent/clarify.d.ts.map +0 -1
  21. package/dist/agent/clarify.js +0 -285
  22. package/dist/agent/clarify.js.map +0 -1
  23. package/dist/agent/dry-run.d.ts +0 -12
  24. package/dist/agent/dry-run.d.ts.map +0 -1
  25. package/dist/agent/dry-run.js +0 -236
  26. package/dist/agent/dry-run.js.map +0 -1
  27. package/dist/agent/filters.d.ts +0 -48
  28. package/dist/agent/filters.d.ts.map +0 -1
  29. package/dist/agent/filters.js +0 -124
  30. package/dist/agent/filters.js.map +0 -1
  31. package/dist/agent/gramjs-monitor.d.ts +0 -26
  32. package/dist/agent/gramjs-monitor.d.ts.map +0 -1
  33. package/dist/agent/gramjs-monitor.js +0 -325
  34. package/dist/agent/gramjs-monitor.js.map +0 -1
  35. package/dist/agent/graph.d.ts +0 -30
  36. package/dist/agent/graph.d.ts.map +0 -1
  37. package/dist/agent/graph.js +0 -240
  38. package/dist/agent/graph.js.map +0 -1
  39. package/dist/agent/helpers.d.ts +0 -6
  40. package/dist/agent/helpers.d.ts.map +0 -1
  41. package/dist/agent/helpers.js +0 -15
  42. package/dist/agent/helpers.js.map +0 -1
  43. package/dist/agent/message.d.ts +0 -69
  44. package/dist/agent/message.d.ts.map +0 -1
  45. package/dist/agent/message.js +0 -479
  46. package/dist/agent/message.js.map +0 -1
  47. package/dist/agent/queue.d.ts +0 -15
  48. package/dist/agent/queue.d.ts.map +0 -1
  49. package/dist/agent/queue.js +0 -41
  50. package/dist/agent/queue.js.map +0 -1
  51. package/dist/agent/redis.d.ts +0 -8
  52. package/dist/agent/redis.d.ts.map +0 -1
  53. package/dist/agent/redis.js +0 -33
  54. package/dist/agent/redis.js.map +0 -1
  55. package/dist/agent/store.d.ts +0 -93
  56. package/dist/agent/store.d.ts.map +0 -1
  57. package/dist/agent/store.js +0 -145
  58. package/dist/agent/store.js.map +0 -1
  59. package/dist/agent/tools.d.ts +0 -159
  60. package/dist/agent/tools.d.ts.map +0 -1
  61. package/dist/agent/tools.js +0 -439
  62. package/dist/agent/tools.js.map +0 -1
  63. package/dist/agent/types.d.ts +0 -218
  64. package/dist/agent/vote.d.ts +0 -13
  65. package/dist/agent/vote.d.ts.map +0 -1
  66. package/dist/agent/vote.js +0 -246
  67. package/dist/agent/vote.js.map +0 -1
  68. package/dist/agent/worker.d.ts +0 -14
  69. package/dist/agent/worker.d.ts.map +0 -1
  70. package/dist/agent/worker.js +0 -137
  71. package/dist/agent/worker.js.map +0 -1
  72. package/dist/bin.d.ts +0 -17
  73. package/dist/bot.d.ts +0 -16
  74. package/dist/config.d.ts +0 -129
  75. package/dist/config.d.ts.map +0 -1
  76. package/dist/config.js +0 -157
  77. package/dist/config.js.map +0 -1
  78. package/dist/gif-state.d.ts +0 -17
  79. package/dist/i18n.d.ts +0 -49
  80. package/dist/i18n.d.ts.map +0 -1
  81. package/dist/i18n.js +0 -229
  82. package/dist/i18n.js.map +0 -1
  83. package/dist/init.d.ts +0 -7
  84. package/dist/logger.d.ts +0 -14
  85. package/dist/logger.d.ts.map +0 -1
  86. package/dist/logger.js +0 -45
  87. package/dist/logger.js.map +0 -1
  88. package/dist/service.d.ts +0 -19
  89. package/dist/service.d.ts.map +0 -1
  90. package/dist/service.js +0 -165
  91. package/dist/service.js.map +0 -1
@@ -1,439 +0,0 @@
1
- /**
2
- * LangChain tool definitions for agentic clarification.
3
- *
4
- * 4 tools the LLM can choose to call (or not):
5
- *
6
- * 1. read_telegram_sources
7
- * → Fetch last 1-4 posts from a Telegram news channel via MTProto.
8
- * Returns actual message texts — the LLM extracts data from them.
9
- * Rate-limited: max 4 posts/call, anti-flood jitter.
10
- *
11
- * 2. alert_history
12
- * → Get recent alert history from Pikud HaOref.
13
- * Answers: "was there really an alert in area X recently?"
14
- * More useful than active alerts (bot already has those).
15
- *
16
- * 3. resolve_area
17
- * → Determine if a mentioned location is relevant to user's
18
- * monitored areas. "попадание в Петах Тикве" → relevant for
19
- * Герцлия? (same defense zone / Gush Dan).
20
- *
21
- * 4. betterstack_log
22
- * → Query recent EasyOref logs from Better Stack.
23
- * Answers: "what happened in the enrichment pipeline recently?"
24
- * Uses existing Logtail token (observability.betterstack_token).
25
- *
26
- * Each tool returns a JSON string consumable by the LLM.
27
- * Error handling: tool failures return { error, retry } objects.
28
- */
29
- import { tool } from "@langchain/core/tools";
30
- import { z } from "zod";
31
- import { config } from "../config.js";
32
- import * as logger from "../logger.js";
33
- import { fetchRecentChannelPosts } from "./gramjs-monitor.js";
34
- // ── Area proximity data ────────────────────────────────
35
- /**
36
- * Defense-zone proximity groups.
37
- * Cities in the same group share Iron Dome coverage, similar ETA,
38
- * and are typically alerted together in large barrages.
39
- * Source: Pikud HaOref zone mapping.
40
- */
41
- const AREA_PROXIMITY_GROUPS = {
42
- "גוש דן": [
43
- "תל אביב",
44
- "רמת גן",
45
- "גבעתיים",
46
- "בני ברק",
47
- "חולון",
48
- "בת ים",
49
- "פתח תקווה",
50
- "גבעת שמואל",
51
- "אור יהודה",
52
- "יהוד",
53
- "קריית אונו",
54
- ],
55
- שרון: [
56
- "הרצליה",
57
- "רעננה",
58
- "כפר סבא",
59
- "הוד השרון",
60
- "נתניה",
61
- "רמת השרון",
62
- "כוכב יאיר",
63
- ],
64
- מרכז: [
65
- "ראשון לציון",
66
- "רחובות",
67
- "נס ציונה",
68
- "לוד",
69
- "רמלה",
70
- "מודיעין",
71
- "יבנה",
72
- "שוהם",
73
- ],
74
- ירושלים: ["ירושלים", "בית שמש", "מעלה אדומים", "מבשרת ציון"],
75
- חיפה: [
76
- "חיפה",
77
- "קריות",
78
- "קריית אתא",
79
- "קריית ביאליק",
80
- "קריית מוצקין",
81
- "טירת כרמל",
82
- "נשר",
83
- ],
84
- "דרום-מערב": ["אשקלון", "אשדוד", "גן יבנה", "קריית מלאכי"],
85
- "עוטף עזה": ["שדרות", "עוטף עזה", "נתיבות", "אופקים"],
86
- "באר שבע": ["באר שבע", "ערד", "דימונה"],
87
- "גליל עליון": ["קריית שמונה", "מטולה", "צפת", "ראש פינה"],
88
- };
89
- /**
90
- * Resolve whether a mentioned location is in the same defense zone
91
- * as any of the user's monitored areas.
92
- */
93
- function resolveAreaProximity(mentioned, monitoredAreas) {
94
- const mentionedLower = mentioned.trim();
95
- // 1. Direct match — mentioned location IS a monitored area
96
- for (const m of monitoredAreas) {
97
- if (m.includes(mentionedLower) ||
98
- mentionedLower.includes(m.split(" ")[0] ?? "")) {
99
- return {
100
- relevant: true,
101
- sameZone: null,
102
- monitoredMatch: [m],
103
- reasoning: `"${mentioned}" directly matches monitored area "${m}"`,
104
- };
105
- }
106
- }
107
- // 2. Zone-based proximity — find which zone the mentioned area belongs to
108
- for (const [zone, cities] of Object.entries(AREA_PROXIMITY_GROUPS)) {
109
- const mentionedInZone = cities.some((c) => mentionedLower.includes(c) || c.includes(mentionedLower));
110
- if (!mentionedInZone)
111
- continue;
112
- // Check if any monitored area is in the same zone
113
- const matchedMonitored = monitoredAreas.filter((m) => cities.some((c) => m.includes(c) || c.includes(m.split(" ")[0] ?? "")));
114
- if (matchedMonitored.length > 0) {
115
- return {
116
- relevant: true,
117
- sameZone: zone,
118
- monitoredMatch: matchedMonitored,
119
- reasoning: `"${mentioned}" is in zone "${zone}" together with monitored: ` +
120
- matchedMonitored.join(", "),
121
- };
122
- }
123
- return {
124
- relevant: false,
125
- sameZone: zone,
126
- monitoredMatch: [],
127
- reasoning: `"${mentioned}" is in zone "${zone}" but none of user's monitored ` +
128
- `areas (${monitoredAreas.join(", ")}) are in that zone`,
129
- };
130
- }
131
- // 3. Generic region keywords
132
- const regionKeywords = {
133
- מרכז: ["תל אביב", "רמת גן", "פתח תקווה", "ראשון לציון", "הרצליה", "חולון"],
134
- צפון: ["חיפה", "קריות", "צפת", "קריית שמונה", "נצרת", "עכו", "טבריה"],
135
- דרום: ["באר שבע", "אשדוד", "אשקלון", "שדרות", "אילת"],
136
- };
137
- for (const [region, cities] of Object.entries(regionKeywords)) {
138
- if (!mentionedLower.includes(region))
139
- continue;
140
- const matchedMonitored = monitoredAreas.filter((m) => cities.some((c) => m.includes(c) || c.includes(m.split(" ")[0] ?? "")));
141
- if (matchedMonitored.length > 0) {
142
- return {
143
- relevant: true,
144
- sameZone: region,
145
- monitoredMatch: matchedMonitored,
146
- reasoning: `"${mentioned}" refers to region "${region}" which includes ` +
147
- matchedMonitored.join(", "),
148
- };
149
- }
150
- }
151
- return {
152
- relevant: false,
153
- sameZone: null,
154
- monitoredMatch: [],
155
- reasoning: `"${mentioned}" could not be matched to any monitored area ` +
156
- `(${monitoredAreas.join(", ")})`,
157
- };
158
- }
159
- // ── Exported for testing ───────────────────────────────
160
- export { resolveAreaProximity as _resolveAreaProximity };
161
- // ── 1. Read Source Channels (MTProto) ──────────────────
162
- export const readSourcesTool = tool(async ({ channel, limit, }) => {
163
- try {
164
- const safeLimit = Math.min(limit, config.agent.clarifyFetchCount);
165
- const posts = await fetchRecentChannelPosts(channel, safeLimit);
166
- if (posts.length === 0) {
167
- return JSON.stringify({
168
- channel,
169
- posts: [],
170
- note: "No recent posts found or channel not accessible",
171
- });
172
- }
173
- const result = {
174
- channel,
175
- posts: posts.map((p) => ({
176
- text: p.text.slice(0, 800),
177
- ts: p.ts,
178
- messageUrl: p.messageUrl,
179
- })),
180
- count: posts.length,
181
- };
182
- logger.info("Tool: read_telegram_sources executed", {
183
- channel,
184
- limit: safeLimit,
185
- returned: posts.length,
186
- });
187
- return JSON.stringify(result);
188
- }
189
- catch (err) {
190
- const errStr = String(err);
191
- const isRateLimit = errStr.includes("FLOOD") || errStr.includes("rate limit");
192
- logger.warn("Tool: read_telegram_sources failed", {
193
- channel,
194
- error: errStr,
195
- });
196
- return JSON.stringify({
197
- error: `Failed to fetch from ${channel}: ${errStr}`,
198
- retry: !isRateLimit,
199
- });
200
- }
201
- }, {
202
- name: "read_telegram_sources",
203
- description: "Fetch last 1-4 posts from a Telegram news channel via MTProto. " +
204
- "Returns actual message texts you can extract data from. " +
205
- "Authoritative channels: @idf_telegram (IDF official), @N12LIVE (news), " +
206
- "@israelsecurity (security), @ynetalerts (Ynet). " +
207
- "Use when existing sources contradict each other or you need confirmation.",
208
- schema: z.object({
209
- channel: z
210
- .string()
211
- .describe("Channel username with @ prefix (e.g. @idf_telegram)"),
212
- limit: z
213
- .number()
214
- .min(1)
215
- .max(4)
216
- .default(3)
217
- .describe("Number of recent posts to fetch (1-4)"),
218
- }),
219
- });
220
- // ── 2. Pikud HaOref Alert History ──────────────────────
221
- export const alertHistoryTool = tool(async ({ area, last_minutes, }) => {
222
- try {
223
- const historyUrl = config.orefHistoryUrl ??
224
- "https://www.oref.org.il/Shared/Ajax/GetAlarmsHistory.aspx?lang=he&fromDate=" +
225
- formatOrefDate(new Date(Date.now() - last_minutes * 60_000)) +
226
- "&toDate=" +
227
- formatOrefDate(new Date());
228
- const res = await fetch(historyUrl, {
229
- headers: {
230
- "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
231
- "X-Requested-With": "XMLHttpRequest",
232
- Referer: "https://www.oref.org.il/",
233
- Accept: "application/json, text/plain, */*",
234
- },
235
- signal: AbortSignal.timeout(5000),
236
- });
237
- if (!res.ok) {
238
- return JSON.stringify({
239
- error: `Oref history API returned ${res.status}`,
240
- retry: true,
241
- });
242
- }
243
- const text = await res.text();
244
- if (!text.trim()) {
245
- return JSON.stringify({
246
- area,
247
- alerts: [],
248
- note: "No alert history returned for this period",
249
- });
250
- }
251
- const parsed = JSON.parse(text);
252
- const alerts = Array.isArray(parsed) ? parsed : [parsed];
253
- // Filter by area
254
- const relevant = alerts.filter((a) => {
255
- const data = a.data ?? "";
256
- return data.includes(area) || area.includes(data.split(" ")[0] ?? "");
257
- });
258
- const result = {
259
- area,
260
- last_minutes,
261
- alerts: relevant.slice(0, 20).map((a) => ({
262
- date: a.alertDate ?? a.date,
263
- title: a.title,
264
- data: a.data,
265
- category: a.category_desc ?? a.category,
266
- })),
267
- total_in_period: alerts.length,
268
- relevant_count: relevant.length,
269
- queried_at: new Date().toISOString(),
270
- };
271
- logger.info("Tool: alert_history executed", {
272
- area,
273
- last_minutes,
274
- total: alerts.length,
275
- relevant: relevant.length,
276
- });
277
- return JSON.stringify(result);
278
- }
279
- catch (err) {
280
- logger.warn("Tool: alert_history failed", { error: String(err) });
281
- return JSON.stringify({
282
- error: `Oref history API call failed: ${String(err)}`,
283
- retry: true,
284
- });
285
- }
286
- }, {
287
- name: "alert_history",
288
- description: "Get recent alert history from Pikud HaOref (Israel Home Front Command). " +
289
- "Answers: 'was there really an alert in area X in the last N minutes?' " +
290
- "More useful than active alerts (the bot already has the current alert). " +
291
- "Use to verify channel claims about attacks in specific areas.",
292
- schema: z.object({
293
- area: z
294
- .string()
295
- .describe("Hebrew area name to search for in history (e.g. תל אביב)"),
296
- last_minutes: z
297
- .number()
298
- .min(5)
299
- .max(120)
300
- .default(30)
301
- .describe("How many minutes of history to search (5-120)"),
302
- }),
303
- });
304
- // ── 3. Resolve Area Relevance ──────────────────────────
305
- export const resolveAreaTool = tool(async ({ location }) => {
306
- const monitoredAreas = config.areas;
307
- if (monitoredAreas.length === 0) {
308
- return JSON.stringify({
309
- error: "No monitored areas configured",
310
- hint: "User has not set up city monitoring",
311
- });
312
- }
313
- const result = resolveAreaProximity(location, monitoredAreas);
314
- logger.info("Tool: resolve_area executed", {
315
- location,
316
- relevant: result.relevant,
317
- zone: result.sameZone,
318
- });
319
- return JSON.stringify({
320
- location,
321
- monitored_areas: monitoredAreas,
322
- ...result,
323
- });
324
- }, {
325
- name: "resolve_area",
326
- description: "Determine if a location mentioned in news is relevant to the user's " +
327
- "monitored areas. Uses defense-zone proximity: cities in the same Iron Dome " +
328
- "coverage zone are considered relevant. " +
329
- 'Example: "попадание в Петах Тикве" → relevant for Herzliya user ' +
330
- "(both in Gush Dan / Sharon zone). " +
331
- 'Use when a news post mentions a city or region like "center" and you need ' +
332
- "to determine if it affects the user.",
333
- schema: z.object({
334
- location: z
335
- .string()
336
- .describe("City or region name in Hebrew as mentioned in news (e.g. פתח תקווה, מרכז)"),
337
- }),
338
- });
339
- // ── Helper ─────────────────────────────────────────────
340
- /** Format date as DD.MM.YYYY for Oref history API */
341
- function formatOrefDate(d) {
342
- const dd = String(d.getDate()).padStart(2, "0");
343
- const mm = String(d.getMonth() + 1).padStart(2, "0");
344
- const yyyy = d.getFullYear();
345
- return `${dd}.${mm}.${yyyy}`;
346
- }
347
- export { formatOrefDate as _formatOrefDate };
348
- // ── 4. Better Stack Log Query ──────────────────────────
349
- export const betterstackLogTool = tool(async ({ query, last_minutes, }) => {
350
- const token = config.logtailToken;
351
- if (!token) {
352
- return JSON.stringify({
353
- error: "Better Stack token not configured",
354
- hint: "Set observability.betterstack_token in config.yaml or LOGTAIL_TOKEN env",
355
- });
356
- }
357
- try {
358
- const now = new Date();
359
- const from = new Date(now.getTime() - last_minutes * 60_000);
360
- const params = new URLSearchParams({
361
- query,
362
- batch: "20",
363
- from: from.toISOString(),
364
- to: now.toISOString(),
365
- order: "newest_first",
366
- });
367
- const res = await fetch(`https://logs.betterstack.com/api/v1/query?${params}`, {
368
- headers: {
369
- Authorization: `Bearer ${token}`,
370
- Accept: "application/json",
371
- },
372
- signal: AbortSignal.timeout(8000),
373
- });
374
- if (!res.ok) {
375
- const body = await res.text().catch(() => "");
376
- return JSON.stringify({
377
- error: `Better Stack API returned ${res.status}`,
378
- body: body.slice(0, 200),
379
- retry: res.status >= 500,
380
- });
381
- }
382
- const json = (await res.json());
383
- const events = Array.isArray(json.data) ? json.data : [];
384
- const result = {
385
- query,
386
- last_minutes,
387
- events: events.slice(0, 20).map((e) => {
388
- const ev = e;
389
- return {
390
- dt: ev.dt ?? ev.timestamp,
391
- message: ev.message ?? ev.msg,
392
- level: ev.level ?? ev.severity,
393
- context: ev.context ?? ev.metadata,
394
- };
395
- }),
396
- total: events.length,
397
- queried_at: now.toISOString(),
398
- };
399
- logger.info("Tool: betterstack_log executed", {
400
- query,
401
- last_minutes,
402
- total: events.length,
403
- });
404
- return JSON.stringify(result);
405
- }
406
- catch (err) {
407
- logger.warn("Tool: betterstack_log failed", { error: String(err) });
408
- return JSON.stringify({
409
- error: `Better Stack query failed: ${String(err)}`,
410
- retry: true,
411
- });
412
- }
413
- }, {
414
- name: "betterstack_log",
415
- description: "Query recent EasyOref logs from Better Stack (Logtail). " +
416
- "Search for log entries matching a text query within a time window. " +
417
- "Use when you need to understand what the enrichment pipeline did recently — " +
418
- "e.g. which alerts were processed, what extractions were made, or why " +
419
- "confidence was low. Returns up to 20 most recent matching log entries.",
420
- schema: z.object({
421
- query: z
422
- .string()
423
- .describe("Text to search for in logs (e.g. 'alert_history', 'Clarify', 'enrichment')"),
424
- last_minutes: z
425
- .number()
426
- .min(1)
427
- .max(60)
428
- .default(15)
429
- .describe("How many minutes of logs to search (1-60)"),
430
- }),
431
- });
432
- // ── Exported tool array ────────────────────────────────
433
- export const clarifyTools = [
434
- readSourcesTool,
435
- alertHistoryTool,
436
- resolveAreaTool,
437
- betterstackLogTool,
438
- ];
439
- //# sourceMappingURL=tools.js.map
@@ -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E,CAAC;aACX,QAAQ,CAAC,2CAA2C,CAAC;KACzD,CAAC;CACH,CACF,CAAC;AAEF,0DAA0D;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,kBAAkB;CACnB,CAAC"}
@@ -1,218 +0,0 @@
1
- /** Shared types for the agent subsystem */
2
- export type AlertType = "early_warning" | "siren" | "resolved";
3
- export interface TrackedMessage {
4
- timestamp: number;
5
- text: string;
6
- url?: string;
7
- channel: string;
8
- }
9
- export interface ChannelWithUpdates {
10
- channel: string;
11
- /** Posts from session start to last enrichment job (already processed) */
12
- prev_tracked_messages: TrackedMessage[];
13
- /** Posts since last enrichment job (new, need processing) */
14
- last_tracked_messages: TrackedMessage[];
15
- }
16
- export interface ChannelTracking {
17
- track_start_timestamp: number;
18
- last_update_timestamp: number;
19
- channels_with_updates: ChannelWithUpdates[];
20
- }
21
- /**
22
- * Qualitative count descriptor — used when channels report without exact numbers.
23
- * "none" is only shown if confidence > 0.95 and explicitly stated in source.
24
- */
25
- export type QualCount = "all" | "most" | "many" | "few" | "exists" | "none" | "more_than" | "less_than";
26
- export interface RelevanceCheck {
27
- channel: string;
28
- text: string;
29
- ts: number;
30
- /** true if post passed keyword/region pre-filter */
31
- relevant: boolean;
32
- }
33
- export interface ExtractionResult {
34
- channel: string;
35
- /** V1: region relevance (0-1) — does post mention our alert region? */
36
- region_relevance: number;
37
- /** V2: source trust (0-1) — factual reporting vs rumors/panic? */
38
- source_trust: number;
39
- /** Extracted data */
40
- country_origin: string | null;
41
- rocket_count: number | null;
42
- is_cassette: boolean | null;
43
- /** Rocket breakdown: intercepted by Iron Dome */
44
- intercepted: number | null;
45
- /** Qualitative descriptor when no exact number is stated (null if exact number given) */
46
- intercepted_qual: QualCount | null;
47
- intercepted_qual_num: number | null;
48
- /** Rocket breakdown: fell in sea/empty area */
49
- sea_impact: number | null;
50
- sea_impact_qual: QualCount | null;
51
- sea_impact_qual_num: number | null;
52
- /** Rocket breakdown: hit open/populated ground */
53
- open_area_impact: number | null;
54
- open_area_impact_qual: QualCount | null;
55
- open_area_impact_qual_num: number | null;
56
- hits_confirmed: number | null;
57
- /** Region where impact occurred (in UI language) */
58
- hit_location?: string | null;
59
- /** Type of impact */
60
- hit_type?: "direct" | "shrapnel" | null;
61
- /** Impact detail: where/how (e.g. "open area", "building", "sea", "no damage"). In UI language. */
62
- hit_detail?: string | null;
63
- /** Casualties reported (injured/killed) — primarily resolved phase */
64
- casualties: number | null;
65
- injuries: number | null;
66
- /** Cause of injuries: rocket fragment/direct hit vs panic/rushing to shelter */
67
- injuries_cause: "rocket" | "rushing_to_shelter" | null;
68
- eta_refined_minutes: number | null;
69
- /** Verbatim per-region rocket breakdown (e.g. "2 center, 3 north") */
70
- rocket_detail: string | null;
71
- /** V3: tone — "calm"|"neutral"|"alarmist" */
72
- tone: "calm" | "neutral" | "alarmist";
73
- /** Overall extraction confidence (0-1) */
74
- confidence: number;
75
- /**
76
- * Time relevance (0-1) — does this post discuss the CURRENT attack?
77
- * LLM sets: 0 = clearly about a previous/different event, 1 = current event.
78
- * Post-filter rejects posts with time_relevance < 0.5.
79
- */
80
- time_relevance: number;
81
- }
82
- export interface ValidatedExtraction extends ExtractionResult {
83
- /** Passed all three validators? */
84
- valid: boolean;
85
- /** Reason if rejected */
86
- reject_reason?: string;
87
- /** Link to original Telegram post (from ChannelPost.messageUrl) */
88
- messageUrl?: string;
89
- }
90
- export interface CitedSource {
91
- /** 1-based citation index */
92
- index: number;
93
- channel: string;
94
- messageUrl: string | null;
95
- }
96
- export interface VotedResult {
97
- /** ETA in minutes (highest-confidence source) */
98
- eta_refined_minutes: number | null;
99
- /** Citation indices that provided ETA */
100
- eta_citations: number[];
101
- /** Unique origin countries with per-country citation indices */
102
- country_origins: Array<{
103
- name: string;
104
- citations: number[];
105
- }> | null;
106
- /** Rocket count range across sources (min == max → exact) */
107
- rocket_count_min: number | null;
108
- rocket_count_max: number | null;
109
- rocket_citations: number[];
110
- /** Avg weighted confidence of sources reporting rocket count (for uncertainty marker) */
111
- rocket_confidence: number;
112
- /** Verbatim per-region rocket breakdown if sources split by region */
113
- rocket_detail: string | null;
114
- is_cassette: boolean | null;
115
- /** Avg weighted confidence of sources confirming cassette munitions */
116
- is_cassette_confidence: number;
117
- /** Rocket breakdown (median values; null if no sources reported) */
118
- intercepted: number | null;
119
- intercepted_qual: QualCount | null;
120
- intercepted_qual_num: number | null;
121
- /** Avg weighted confidence of sources reporting intercepted count */
122
- intercepted_confidence: number;
123
- sea_impact: number | null;
124
- sea_impact_qual: QualCount | null;
125
- sea_impact_qual_num: number | null;
126
- sea_confidence: number;
127
- open_area_impact: number | null;
128
- open_area_impact_qual: QualCount | null;
129
- open_area_impact_qual_num: number | null;
130
- open_area_confidence: number;
131
- hits_confirmed: number | null;
132
- /** Citation indices that provided hits data */
133
- hits_citations: number[];
134
- /** Avg weighted confidence of sources reporting confirmed hits */
135
- hits_confidence: number;
136
- /** Region where impact occurred (in UI language, from highest-confidence source) */
137
- hit_location: string | null;
138
- /** Type of impact: direct or shrapnel/debris */
139
- hit_type: "direct" | "shrapnel" | null;
140
- /** Impact detail: where/how (e.g. "на открытой местности", "здание", "в море") */
141
- hit_detail: string | null;
142
- /** Sources explicitly confirm NO impacts ("прилетов нет") */
143
- no_impacts: boolean;
144
- no_impacts_citations: number[];
145
- /** Citation indices for intercepted data */
146
- intercepted_citations: number[];
147
- casualties: number | null;
148
- casualties_citations: number[];
149
- casualties_confidence: number;
150
- injuries: number | null;
151
- injuries_cause: "rocket" | "rushing_to_shelter" | null;
152
- injuries_citations: number[];
153
- injuries_confidence: number;
154
- confidence: number;
155
- sources_count: number;
156
- /** All valid sources, ordered by citation index */
157
- citedSources: CitedSource[];
158
- }
159
- /**
160
- * Cross-phase enrichment data persisted in Redis.
161
- * Each phase writes its findings; the next phase reads and carries forward.
162
- * This is the "single track" — results flow: early → siren → resolved.
163
- *
164
- * Inline citations are stored as arrays of {url, channel} for rendering
165
- * as [[1]](url), [[2]](url) inline after each data point.
166
- */
167
- export interface InlineCite {
168
- url: string;
169
- channel: string;
170
- }
171
- export interface EnrichmentData {
172
- /** Origin country (from early_warning or siren) */
173
- origin: string | null;
174
- originCites: InlineCite[];
175
- /** ETA absolute time string (e.g. "~17:42") */
176
- etaAbsolute: string | null;
177
- etaCites: InlineCite[];
178
- /** Rocket count display string (e.g. "~5–7") */
179
- rocketCount: string | null;
180
- rocketCites: InlineCite[];
181
- /** Is cassette munitions */
182
- isCassette: boolean | null;
183
- /** Interception data display string (e.g. "3", "большинство") */
184
- intercepted: string | null;
185
- interceptedCites: InlineCite[];
186
- /** Sea impact display string */
187
- seaImpact: string | null;
188
- /** Open area impact display string */
189
- openAreaImpact: string | null;
190
- /** Confirmed hits on structures */
191
- hitsConfirmed: string | null;
192
- hitsCites: InlineCite[];
193
- /** Region where impact occurred (in UI language) */
194
- hitLocation: string | null;
195
- /** Type of impact: "direct" | "shrapnel" */
196
- hitType: string | null;
197
- /** Impact detail: where/how (e.g. "на открытой местности", "здание") */
198
- hitDetail: string | null;
199
- /** Explicitly confirmed no impacts */
200
- noImpacts: boolean;
201
- noImpactsCites: InlineCite[];
202
- /** Verbatim per-region rocket breakdown */
203
- rocketDetail: string | null;
204
- /** Casualties / injuries (from resolved) */
205
- casualties: string | null;
206
- casualtiesCites: InlineCite[];
207
- injuries: string | null;
208
- /** Cause display string — set only if injuries came from rushing to shelter */
209
- injuriesCause: "rocket" | "rushing_to_shelter" | null;
210
- injuriesCites: InlineCite[];
211
- /** Time early_warning was received (for siren "Раннее: было в HH:MM") */
212
- earlyWarningTime: string | null;
213
- /** Hash of last enriched text to detect "message not modified" before sending */
214
- lastEditHash: string | null;
215
- }
216
- /** Empty enrichment data template */
217
- export declare function emptyEnrichmentData(): EnrichmentData;
218
- //# sourceMappingURL=types.d.ts.map