File size: 1,228 Bytes
1794757
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { getLiveSourcesForAgent } from "./registry";
import type { AgentId, DataSourceSpec, LiveSourcePlanItem } from "./types";

function defaultPollIntervalMs(source: DataSourceSpec): number {
  switch (source.kind) {
    case "telegram":
      return 15_000;
    case "structured":
    case "api":
      return 30_000;
    case "rss":
      return 60_000;
    case "scrape":
      return 120_000;
    case "video":
      return 180_000;
  }
}

function defaultMaxItemsPerPull(source: DataSourceSpec): number {
  switch (source.kind) {
    case "telegram":
      return 20;
    case "structured":
    case "api":
      return 10;
    case "rss":
      return 8;
    case "scrape":
      return 5;
    case "video":
      return 1;
  }
}

function isWarmStartSource(source: DataSourceSpec): boolean {
  return source.kind === "telegram" || source.kind === "structured" || source.tags.includes("official");
}

export function buildLiveSourcePlan(agentId: AgentId): LiveSourcePlanItem[] {
  return getLiveSourcesForAgent(agentId).map((source) => ({
    sourceId: source.id,
    pollIntervalMs: defaultPollIntervalMs(source),
    warmStart: isWarmStartSource(source),
    maxItemsPerPull: defaultMaxItemsPerPull(source),
  }));
}