openpondai/agents/news-intelligence-roundup

OpenTool app

1Branch0Tags
OP
OpenPond Syncsync: merge local template master into production
typescript
import type { ToolProfile } from "opentool"; import { store } from "opentool/store"; import { NEWS_INTELLIGENCE_ROUNDUP_TEMPLATE_CONFIG, requestOverrideSchema, resolveRuntimeConfig, } from "../src/config"; import { runNewsIntelligenceRoundup } from "../src/news-intelligence-roundup"; export const schema = requestOverrideSchema; export const profile: ToolProfile = { description: "Topic-based roundup over the gateway news-intelligence corpus.", category: "tracker", templatePreview: { subtitle: "Query recent news windows and return a structured roundup.", description: `Runs a query against the news-intelligence pipeline for one or more lookback windows. Builds a structured summary with per-window coverage and top matched articles. Returns machine-readable JSON suitable for cron ingestion and landing-page feeds.`, }, templateConfig: NEWS_INTELLIGENCE_ROUNDUP_TEMPLATE_CONFIG, }; export async function POST(req: Request) { const payload = await req.json().catch(() => null); const parsed = requestOverrideSchema.safeParse(payload ?? {}); if (!parsed.success) { return new Response( JSON.stringify({ ok: false, error: parsed.error.issues[0]?.message ?? "invalid request payload", }), { status: 400, headers: { "content-type": "application/json" }, }, ); } try { const config = resolveRuntimeConfig(parsed.data); const result = await runNewsIntelligenceRoundup(config); await store({ source: "news-intelligence-roundup", ref: `news-intelligence-roundup-${Date.now()}`, status: "info", action: "roundup", metadata: result, }); return Response.json(result); } catch (error) { const message = error instanceof Error ? error.message : "unknown"; await store({ source: "news-intelligence-roundup", ref: `news-intelligence-roundup-${Date.now()}`, status: "failed", action: "roundup", metadata: { ok: false, error: message }, }); return new Response(JSON.stringify({ ok: false, error: message }), { status: 400, headers: { "content-type": "application/json" }, }); } }