// Code generated by protoc-gen-ts-server. DO NOT EDIT.
// source: worldmonitor/intelligence/v1/service.proto

export interface GetRiskScoresRequest {
  region: string;
}

export interface GetRiskScoresResponse {
  ciiScores: CiiScore[];
  strategicRisks: StrategicRisk[];
  degraded: boolean;
  stale: boolean;
}

export interface CiiScore {
  region: string;
  staticBaseline: number;
  dynamicScore: number;
  combinedScore: number;
  trend: TrendDirection;
  components?: CiiComponents;
  computedAt: number;
  methodologyVersion: string;
  eventMultiplier: number;
  advisoryLevel: string;
  advisoryProvenance: string;
}

export interface CiiComponents {
  newsActivity: number;
  ciiContribution: number;
  geoConvergence: number;
  militaryActivity: number;
}

export interface StrategicRisk {
  region: string;
  level: SeverityLevel;
  score: number;
  factors: string[];
  trend: TrendDirection;
}

export interface GetPizzintStatusRequest {
  includeGdelt: boolean;
}

export interface GetPizzintStatusResponse {
  pizzint?: PizzintStatus;
  tensionPairs: GdeltTensionPair[];
}

export interface PizzintStatus {
  defconLevel: number;
  defconLabel: string;
  aggregateActivity: number;
  activeSpikes: number;
  locationsMonitored: number;
  locationsOpen: number;
  updatedAt: number;
  dataFreshness: DataFreshness;
  locations: PizzintLocation[];
}

export interface PizzintLocation {
  placeId: string;
  name: string;
  address: string;
  currentPopularity: number;
  percentageOfUsual: number;
  isSpike: boolean;
  spikeMagnitude: number;
  dataSource: string;
  recordedAt: string;
  dataFreshness: DataFreshness;
  isClosedNow: boolean;
  lat: number;
  lng: number;
}

export interface GdeltTensionPair {
  id: string;
  countries: string[];
  label: string;
  score: number;
  trend: TrendDirection;
  changePercent: number;
  region: string;
}

export interface ClassifyEventRequest {
  title: string;
  description: string;
  source: string;
  country: string;
}

export interface ClassifyEventResponse {
  classification?: EventClassification;
}

export interface EventClassification {
  category: string;
  subcategory: string;
  severity: SeverityLevel;
  confidence: number;
  analysis: string;
  entities: string[];
}

export interface GetCountryRiskRequest {
  countryCode: string;
}

export interface GetCountryRiskResponse {
  countryCode: string;
  countryName: string;
  cii?: CiiScore;
  advisoryLevel: string;
  sanctionsActive: boolean;
  sanctionsCount: number;
  fetchedAt: number;
  upstreamUnavailable: boolean;
}

export interface GetCountryIntelBriefRequest {
  countryCode: string;
  framework: string;
}

export interface GetCountryIntelBriefResponse {
  countryCode: string;
  countryName: string;
  brief: string;
  model: string;
  generatedAt: number;
  sources: BriefSource[];
}

export interface BriefSource {
  title: string;
  source: string;
  url: string;
  publishedAt: string;
}

export interface SearchGdeltDocumentsRequest {
  query: string;
  maxRecords: number;
  timespan: string;
  toneFilter: string;
  sort: string;
}

export interface SearchGdeltDocumentsResponse {
  articles: GdeltArticle[];
  query: string;
  error: string;
}

export interface GdeltArticle {
  title: string;
  url: string;
  source: string;
  date: string;
  image: string;
  language: string;
  tone: number;
}

export interface DeductSituationRequest {
  query: string;
  geoContext: string;
  framework: string;
}

export interface DeductSituationResponse {
  analysis: string;
  model: string;
  provider: string;
}

export interface ListSatellitesRequest {
  country: string;
}

export interface ListSatellitesResponse {
  satellites: Satellite[];
}

export interface Satellite {
  id: string;
  name: string;
  country: string;
  type: string;
  alt: number;
  velocity: number;
  inclination: number;
  line1: string;
  line2: string;
}

export interface ListGpsInterferenceRequest {
  region: string;
}

export interface ListGpsInterferenceResponse {
  hexes: GpsJamHex[];
  stats?: GpsJamStats;
  source: string;
  fetchedAt: number;
}

export interface GpsJamHex {
  h3: string;
  lat: number;
  lon: number;
  level: InterferenceLevel;
  npAvg: number;
  sampleCount: number;
  aircraftCount: number;
}

export interface GpsJamStats {
  totalHexes: number;
  highCount: number;
  mediumCount: number;
}

export interface ListOrefAlertsRequest {
  mode: Mode;
}

export interface ListOrefAlertsResponse {
  configured: boolean;
  alerts: OrefAlert[];
  history: OrefWave[];
  historyCount24h: number;
  totalHistoryCount: number;
  timestampMs: number;
  error: string;
}

export interface OrefAlert {
  id: string;
  cat: string;
  title: string;
  data: string[];
  desc: string;
  timestampMs: number;
}

export interface OrefWave {
  alerts: OrefAlert[];
  timestampMs: number;
}

export interface ListTelegramFeedRequest {
  limit: number;
  topic: string;
  channel: string;
}

export interface ListTelegramFeedResponse {
  enabled: boolean;
  messages: TelegramMessage[];
  count: number;
  error: string;
}

export interface TelegramMessage {
  id: string;
  channelId: string;
  channelName: string;
  text: string;
  timestampMs: number;
  mediaUrls: string[];
  sourceUrl: string;
  topic: string;
}

export interface GetCompanyEnrichmentRequest {
  domain: string;
  name: string;
}

export interface GetCompanyEnrichmentResponse {
  company?: EnrichedCompany;
  github?: EnrichedGithub;
  techStack: TechStackItem[];
  secFilings?: SecFilings;
  hackerNewsMentions: HNMention[];
  enrichedAtMs: number;
  sources: string[];
}

export interface EnrichedCompany {
  name: string;
  domain: string;
  description: string;
  location: string;
  website: string;
  founded: number;
}

export interface EnrichedGithub {
  publicRepos: number;
  followers: number;
  avatarUrl: string;
}

export interface TechStackItem {
  name: string;
  category: string;
  confidence: number;
}

export interface SecFilings {
  totalFilings: number;
  recentFilings: SecFiling[];
}

export interface SecFiling {
  form: string;
  fileDate: string;
  description: string;
}

export interface HNMention {
  title: string;
  url: string;
  points: number;
  comments: number;
  createdAtMs: number;
}

export interface ListCompanySignalsRequest {
  company: string;
  domain: string;
}

export interface ListCompanySignalsResponse {
  company: string;
  domain: string;
  signals: CompanySignal[];
  summary?: SignalSummary;
  discoveredAtMs: number;
}

export interface CompanySignal {
  type: string;
  title: string;
  url: string;
  source: string;
  sourceTier: number;
  timestampMs: number;
  strength: string;
  engagement?: SignalEngagement;
}

export interface SignalEngagement {
  points: number;
  comments: number;
  stars: number;
  forks: number;
  mentions: number;
}

export interface SignalSummary {
  totalSignals: number;
  byType: Record<string, number>;
  strongestSignal?: CompanySignal;
  signalDiversity: number;
}

export interface GetCountryFactsRequest {
  countryCode: string;
}

export interface GetCountryFactsResponse {
  headOfState: string;
  headOfStateTitle: string;
  wikipediaSummary: string;
  wikipediaThumbnailUrl: string;
  population: number;
  capital: string;
  languages: string[];
  currencies: string[];
  areaSqKm: number;
  countryName: string;
}

export interface ListSecurityAdvisoriesRequest {
}

export interface ListSecurityAdvisoriesResponse {
  advisories: SecurityAdvisoryItem[];
  byCountry: Record<string, string>;
}

export interface SecurityAdvisoryItem {
  title: string;
  link: string;
  pubDate: string;
  source: string;
  sourceCountry: string;
  level: string;
  country: string;
}

export interface GetGdeltTopicTimelineRequest {
  topic: string;
}

export interface GetGdeltTopicTimelineResponse {
  topic: string;
  tone: GdeltTimelinePoint[];
  vol: GdeltTimelinePoint[];
  fetchedAt: string;
  error: string;
}

export interface GdeltTimelinePoint {
  date: string;
  value: number;
}

export interface ListCrossSourceSignalsRequest {
}

export interface ListCrossSourceSignalsResponse {
  signals: CrossSourceSignal[];
  evaluatedAt: number;
  compositeCount: number;
}

export interface CrossSourceSignal {
  id: string;
  type: CrossSourceSignalType;
  theater: string;
  summary: string;
  severity: CrossSourceSignalSeverity;
  severityScore: number;
  detectedAt: number;
  contributingTypes: string[];
  signalCount: number;
}

export interface ListMarketImplicationsRequest {
  frameworkId: string;
}

export interface ListMarketImplicationsResponse {
  cards: MarketImplicationCard[];
  degraded: boolean;
  emptyReason: string;
  generatedAt: string;
}

export interface MarketImplicationCard {
  ticker: string;
  name: string;
  direction: string;
  timeframe: string;
  confidence: string;
  title: string;
  narrative: string;
  riskCaveat: string;
  driver: string;
  transmissionChain: TransmissionNode[];
}

export interface TransmissionNode {
  node: string;
  impactType: string;
  logic: string;
}

export interface GetSocialVelocityRequest {
}

export interface GetSocialVelocityResponse {
  posts: SocialVelocityPost[];
  fetchedAt: number;
}

export interface SocialVelocityPost {
  id: string;
  title: string;
  subreddit: string;
  url: string;
  score: number;
  upvoteRatio: number;
  numComments: number;
  velocityScore: number;
  createdAt: number;
}

export interface GetCountryEnergyProfileRequest {
  countryCode: string;
}

export interface GetCountryEnergyProfileResponse {
  mixAvailable: boolean;
  mixYear: number;
  coalShare: number;
  gasShare: number;
  oilShare: number;
  nuclearShare: number;
  renewShare: number;
  windShare: number;
  solarShare: number;
  hydroShare: number;
  importShare: number;
  gasStorageAvailable: boolean;
  gasStorageFillPct: number;
  gasStorageChange1d: number;
  gasStorageTrend: string;
  gasStorageDate: string;
  electricityAvailable: boolean;
  electricityPriceMwh: number;
  electricitySource: string;
  electricityDate: string;
  jodiOilAvailable: boolean;
  jodiOilDataMonth: string;
  gasolineDemandKbd: number;
  gasolineImportsKbd: number;
  dieselDemandKbd: number;
  dieselImportsKbd: number;
  jetDemandKbd: number;
  jetImportsKbd: number;
  lpgDemandKbd: number;
  crudeImportsKbd: number;
  lpgImportsKbd: number;
  jodiGasAvailable: boolean;
  jodiGasDataMonth: string;
  gasTotalDemandTj: number;
  gasLngImportsTj: number;
  gasPipeImportsTj: number;
  gasLngShare: number;
  ieaStocksAvailable: boolean;
  ieaStocksDataMonth: string;
  ieaDaysOfCover: number;
  ieaNetExporter: boolean;
  ieaBelowObligation: boolean;
  emberFossilShare: number;
  emberRenewShare: number;
  emberNuclearShare: number;
  emberCoalShare: number;
  emberGasShare: number;
  emberDemandTwh: number;
  emberDataMonth: string;
  emberAvailable: boolean;
  sprRegime: string;
  sprCapacityMb: number;
  sprOperator: string;
  sprIeaMember: boolean;
  sprStockholdingModel: string;
  sprNote: string;
  sprSource: string;
  sprAsOf: string;
  sprAvailable: boolean;
}

export interface ComputeEnergyShockScenarioRequest {
  countryCode: string;
  chokepointId: string;
  disruptionPct: number;
  fuelMode: string;
}

export interface ComputeEnergyShockScenarioResponse {
  countryCode: string;
  chokepointId: string;
  disruptionPct: number;
  gulfCrudeShare: number;
  crudeLossKbd: number;
  products: ProductImpact[];
  effectiveCoverDays: number;
  assessment: string;
  dataAvailable: boolean;
  jodiOilCoverage: boolean;
  comtradeCoverage: boolean;
  ieaStocksCoverage: boolean;
  portwatchCoverage: boolean;
  coverageLevel: string;
  limitations: string[];
  degraded: boolean;
  chokepointConfidence: string;
  liveFlowRatio?: number;
  gasImpact?: GasImpact;
}

export interface ProductImpact {
  product: string;
  outputLossKbd: number;
  demandKbd: number;
  deficitPct: number;
}

export interface GasImpact {
  lngShareOfImports: number;
  lngImportsTj: number;
  lngDisruptionTj: number;
  totalDemandTj: number;
  deficitPct: number;
  dataAvailable: boolean;
  assessment: string;
  storage?: GasStorageBuffer;
  dataSource: string;
}

export interface GasStorageBuffer {
  fillPct: number;
  gasTwh: number;
  bufferDays: number;
  trend: string;
  date: string;
  scope: string;
}

export interface GetCountryPortActivityRequest {
  countryCode: string;
}

export interface CountryPortActivityResponse {
  ports: PortActivityEntry[];
  fetchedAt: string;
  available: boolean;
}

export interface PortActivityEntry {
  portId: string;
  portName: string;
  lat: number;
  lon: number;
  tankerCalls30d: number;
  trendDeltaPct: number;
  importTankerDwt: number;
  exportTankerDwt: number;
  anomalySignal: boolean;
}

export interface GetRegionalSnapshotRequest {
  regionId: string;
}

export interface GetRegionalSnapshotResponse {
  snapshot?: RegionalSnapshot;
}

export interface RegionalSnapshot {
  regionId: string;
  generatedAt: number;
  meta?: SnapshotMeta;
  regime?: RegimeState;
  balance?: BalanceVector;
  actors: ActorState[];
  leverageEdges: LeverageEdge[];
  scenarioSets: ScenarioSet[];
  transmissionPaths: TransmissionPath[];
  triggers?: TriggerLadder;
  mobility?: MobilityState;
  evidence: EvidenceItem[];
  narrative?: RegionalNarrative;
}

export interface SnapshotMeta {
  snapshotId: string;
  modelVersion: string;
  scoringVersion: string;
  geographyVersion: string;
  snapshotConfidence: number;
  missingInputs: string[];
  staleInputs: string[];
  validUntil: number;
  triggerReason: string;
  narrativeProvider: string;
  narrativeModel: string;
}

export interface RegimeState {
  label: string;
  previousLabel: string;
  transitionedAt: number;
  transitionDriver: string;
}

export interface BalanceVector {
  coercivePressure: number;
  domesticFragility: number;
  capitalStress: number;
  energyVulnerability: number;
  allianceCohesion: number;
  maritimeAccess: number;
  energyLeverage: number;
  netBalance: number;
  pressures: BalanceDriver[];
  buffers: BalanceDriver[];
}

export interface BalanceDriver {
  axis: string;
  description: string;
  magnitude: number;
  evidenceIds: string[];
  orientation: string;
}

export interface ActorState {
  actorId: string;
  name: string;
  role: string;
  leverageDomains: string[];
  leverageScore: number;
  delta: number;
  evidenceIds: string[];
}

export interface LeverageEdge {
  fromActorId: string;
  toActorId: string;
  mechanism: string;
  strength: number;
  evidenceIds: string[];
}

export interface ScenarioSet {
  horizon: string;
  lanes: ScenarioLane[];
}

export interface ScenarioLane {
  name: string;
  probability: number;
  triggerIds: string[];
  consequences: string[];
  transmissions: TransmissionPath[];
}

export interface TransmissionPath {
  start: string;
  mechanism: string;
  end: string;
  severity: string;
  corridorId: string;
  confidence: number;
  latencyHours: number;
  impactedAssetClass: string;
  impactedRegions: string[];
  magnitudeLow: number;
  magnitudeHigh: number;
  magnitudeUnit: string;
  templateId: string;
  templateVersion: string;
}

export interface TriggerLadder {
  active: Trigger[];
  watching: Trigger[];
  dormant: Trigger[];
}

export interface Trigger {
  id: string;
  description: string;
  threshold?: TriggerThreshold;
  activated: boolean;
  activatedAt: number;
  scenarioLane: string;
  evidenceIds: string[];
}

export interface TriggerThreshold {
  metric: string;
  operator: string;
  value: number;
  windowMinutes: number;
  baseline: string;
}

export interface MobilityState {
  airspace: AirspaceStatus[];
  flightCorridors: FlightCorridorStress[];
  airports: AirportNodeStatus[];
  rerouteIntensity: number;
  notamClosures: string[];
}

export interface AirspaceStatus {
  airspaceId: string;
  status: string;
  reason: string;
}

export interface FlightCorridorStress {
  corridor: string;
  stressLevel: number;
  reroutedFlights24h: number;
}

export interface AirportNodeStatus {
  icao: string;
  name: string;
  status: string;
  disruptionReason: string;
}

export interface EvidenceItem {
  id: string;
  type: string;
  source: string;
  summary: string;
  confidence: number;
  observedAt: number;
  theater: string;
  corridor: string;
}

export interface RegionalNarrative {
  situation?: NarrativeSection;
  balanceAssessment?: NarrativeSection;
  outlook24h?: NarrativeSection;
  outlook7d?: NarrativeSection;
  outlook30d?: NarrativeSection;
  watchItems: NarrativeSection[];
}

export interface NarrativeSection {
  text: string;
  evidenceIds: string[];
}

export interface GetRegimeHistoryRequest {
  regionId: string;
  limit: number;
}

export interface GetRegimeHistoryResponse {
  transitions: RegimeTransition[];
}

export interface RegimeTransition {
  regionId: string;
  label: string;
  previousLabel: string;
  transitionedAt: number;
  transitionDriver: string;
  snapshotId: string;
}

export interface GetRegionalBriefRequest {
  regionId: string;
}

export interface GetRegionalBriefResponse {
  brief?: RegionalBrief;
}

export interface RegionalBrief {
  regionId: string;
  generatedAt: number;
  periodStart: number;
  periodEnd: number;
  situationRecap: string;
  regimeTrajectory: string;
  keyDevelopments: string[];
  riskOutlook: string;
  provider: string;
  model: string;
}

export type SeverityLevel = "SEVERITY_LEVEL_UNSPECIFIED" | "SEVERITY_LEVEL_LOW" | "SEVERITY_LEVEL_MEDIUM" | "SEVERITY_LEVEL_HIGH";

export type TrendDirection = "TREND_DIRECTION_UNSPECIFIED" | "TREND_DIRECTION_RISING" | "TREND_DIRECTION_STABLE" | "TREND_DIRECTION_FALLING";

export type CrossSourceSignalSeverity = "CROSS_SOURCE_SIGNAL_SEVERITY_UNSPECIFIED" | "CROSS_SOURCE_SIGNAL_SEVERITY_LOW" | "CROSS_SOURCE_SIGNAL_SEVERITY_MEDIUM" | "CROSS_SOURCE_SIGNAL_SEVERITY_HIGH" | "CROSS_SOURCE_SIGNAL_SEVERITY_CRITICAL";

export type CrossSourceSignalType = "CROSS_SOURCE_SIGNAL_TYPE_UNSPECIFIED" | "CROSS_SOURCE_SIGNAL_TYPE_COMPOSITE_ESCALATION" | "CROSS_SOURCE_SIGNAL_TYPE_THERMAL_SPIKE" | "CROSS_SOURCE_SIGNAL_TYPE_GPS_JAMMING" | "CROSS_SOURCE_SIGNAL_TYPE_MILITARY_FLIGHT_SURGE" | "CROSS_SOURCE_SIGNAL_TYPE_UNREST_SURGE" | "CROSS_SOURCE_SIGNAL_TYPE_OREF_ALERT_CLUSTER" | "CROSS_SOURCE_SIGNAL_TYPE_VIX_SPIKE" | "CROSS_SOURCE_SIGNAL_TYPE_COMMODITY_SHOCK" | "CROSS_SOURCE_SIGNAL_TYPE_CYBER_ESCALATION" | "CROSS_SOURCE_SIGNAL_TYPE_SHIPPING_DISRUPTION" | "CROSS_SOURCE_SIGNAL_TYPE_SANCTIONS_SURGE" | "CROSS_SOURCE_SIGNAL_TYPE_EARTHQUAKE_SIGNIFICANT" | "CROSS_SOURCE_SIGNAL_TYPE_RADIATION_ANOMALY" | "CROSS_SOURCE_SIGNAL_TYPE_INFRASTRUCTURE_OUTAGE" | "CROSS_SOURCE_SIGNAL_TYPE_WILDFIRE_ESCALATION" | "CROSS_SOURCE_SIGNAL_TYPE_DISPLACEMENT_SURGE" | "CROSS_SOURCE_SIGNAL_TYPE_FORECAST_DETERIORATION" | "CROSS_SOURCE_SIGNAL_TYPE_MARKET_STRESS" | "CROSS_SOURCE_SIGNAL_TYPE_WEATHER_EXTREME" | "CROSS_SOURCE_SIGNAL_TYPE_MEDIA_TONE_DETERIORATION" | "CROSS_SOURCE_SIGNAL_TYPE_RISK_SCORE_SPIKE";

export type DataFreshness = "DATA_FRESHNESS_UNSPECIFIED" | "DATA_FRESHNESS_FRESH" | "DATA_FRESHNESS_STALE";

export type InterferenceLevel = "INTERFERENCE_LEVEL_UNSPECIFIED" | "INTERFERENCE_LEVEL_LOW" | "INTERFERENCE_LEVEL_MEDIUM" | "INTERFERENCE_LEVEL_HIGH";

export type Mode = "MODE_UNSPECIFIED" | "MODE_HISTORY";

export interface FieldViolation {
  field: string;
  description: string;
}

export class ValidationError extends Error {
  violations: FieldViolation[];

  constructor(violations: FieldViolation[]) {
    super("Validation failed");
    this.name = "ValidationError";
    this.violations = violations;
  }
}

export class ApiError extends Error {
  statusCode: number;
  body: string;

  constructor(statusCode: number, message: string, body: string) {
    super(message);
    this.name = "ApiError";
    this.statusCode = statusCode;
    this.body = body;
  }
}

export interface ServerContext {
  request: Request;
  pathParams: Record<string, string>;
  headers: Record<string, string>;
}

export interface ServerOptions {
  onError?: (error: unknown, req: Request) => Response | Promise<Response>;
  validateRequest?: (methodName: string, body: unknown) => FieldViolation[] | undefined;
}

export interface RouteDescriptor {
  method: string;
  path: string;
  handler: (req: Request) => Promise<Response>;
}

export interface IntelligenceServiceHandler {
  getRiskScores(ctx: ServerContext, req: GetRiskScoresRequest): Promise<GetRiskScoresResponse>;
  getPizzintStatus(ctx: ServerContext, req: GetPizzintStatusRequest): Promise<GetPizzintStatusResponse>;
  classifyEvent(ctx: ServerContext, req: ClassifyEventRequest): Promise<ClassifyEventResponse>;
  getCountryRisk(ctx: ServerContext, req: GetCountryRiskRequest): Promise<GetCountryRiskResponse>;
  getCountryIntelBrief(ctx: ServerContext, req: GetCountryIntelBriefRequest): Promise<GetCountryIntelBriefResponse>;
  searchGdeltDocuments(ctx: ServerContext, req: SearchGdeltDocumentsRequest): Promise<SearchGdeltDocumentsResponse>;
  deductSituation(ctx: ServerContext, req: DeductSituationRequest): Promise<DeductSituationResponse>;
  listSatellites(ctx: ServerContext, req: ListSatellitesRequest): Promise<ListSatellitesResponse>;
  listGpsInterference(ctx: ServerContext, req: ListGpsInterferenceRequest): Promise<ListGpsInterferenceResponse>;
  listOrefAlerts(ctx: ServerContext, req: ListOrefAlertsRequest): Promise<ListOrefAlertsResponse>;
  listTelegramFeed(ctx: ServerContext, req: ListTelegramFeedRequest): Promise<ListTelegramFeedResponse>;
  getCompanyEnrichment(ctx: ServerContext, req: GetCompanyEnrichmentRequest): Promise<GetCompanyEnrichmentResponse>;
  listCompanySignals(ctx: ServerContext, req: ListCompanySignalsRequest): Promise<ListCompanySignalsResponse>;
  getCountryFacts(ctx: ServerContext, req: GetCountryFactsRequest): Promise<GetCountryFactsResponse>;
  listSecurityAdvisories(ctx: ServerContext, req: ListSecurityAdvisoriesRequest): Promise<ListSecurityAdvisoriesResponse>;
  getGdeltTopicTimeline(ctx: ServerContext, req: GetGdeltTopicTimelineRequest): Promise<GetGdeltTopicTimelineResponse>;
  listCrossSourceSignals(ctx: ServerContext, req: ListCrossSourceSignalsRequest): Promise<ListCrossSourceSignalsResponse>;
  listMarketImplications(ctx: ServerContext, req: ListMarketImplicationsRequest): Promise<ListMarketImplicationsResponse>;
  getSocialVelocity(ctx: ServerContext, req: GetSocialVelocityRequest): Promise<GetSocialVelocityResponse>;
  getCountryEnergyProfile(ctx: ServerContext, req: GetCountryEnergyProfileRequest): Promise<GetCountryEnergyProfileResponse>;
  computeEnergyShockScenario(ctx: ServerContext, req: ComputeEnergyShockScenarioRequest): Promise<ComputeEnergyShockScenarioResponse>;
  getCountryPortActivity(ctx: ServerContext, req: GetCountryPortActivityRequest): Promise<CountryPortActivityResponse>;
  getRegionalSnapshot(ctx: ServerContext, req: GetRegionalSnapshotRequest): Promise<GetRegionalSnapshotResponse>;
  getRegimeHistory(ctx: ServerContext, req: GetRegimeHistoryRequest): Promise<GetRegimeHistoryResponse>;
  getRegionalBrief(ctx: ServerContext, req: GetRegionalBriefRequest): Promise<GetRegionalBriefResponse>;
}

export function createIntelligenceServiceRoutes(
  handler: IntelligenceServiceHandler,
  options?: ServerOptions,
): RouteDescriptor[] {
  return [
    {
      method: "GET",
      path: "/api/intelligence/v1/get-risk-scores",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetRiskScoresRequest = {
            region: params.get("region") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getRiskScores", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getRiskScores(ctx, body);
          return new Response(JSON.stringify(result as GetRiskScoresResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-pizzint-status",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetPizzintStatusRequest = {
            includeGdelt: params.get("include_gdelt") === "true",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getPizzintStatus", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getPizzintStatus(ctx, body);
          return new Response(JSON.stringify(result as GetPizzintStatusResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/classify-event",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ClassifyEventRequest = {
            title: params.get("title") ?? "",
            description: params.get("description") ?? "",
            source: params.get("source") ?? "",
            country: params.get("country") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("classifyEvent", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.classifyEvent(ctx, body);
          return new Response(JSON.stringify(result as ClassifyEventResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-country-risk",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetCountryRiskRequest = {
            countryCode: params.get("country_code") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getCountryRisk", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getCountryRisk(ctx, body);
          return new Response(JSON.stringify(result as GetCountryRiskResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-country-intel-brief",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetCountryIntelBriefRequest = {
            countryCode: params.get("country_code") ?? "",
            framework: params.get("framework") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getCountryIntelBrief", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getCountryIntelBrief(ctx, body);
          return new Response(JSON.stringify(result as GetCountryIntelBriefResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/search-gdelt-documents",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: SearchGdeltDocumentsRequest = {
            query: params.get("query") ?? "",
            maxRecords: Number(params.get("max_records") ?? "0"),
            timespan: params.get("timespan") ?? "",
            toneFilter: params.get("tone_filter") ?? "",
            sort: params.get("sort") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("searchGdeltDocuments", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.searchGdeltDocuments(ctx, body);
          return new Response(JSON.stringify(result as SearchGdeltDocumentsResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "POST",
      path: "/api/intelligence/v1/deduct-situation",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const body = await req.json() as DeductSituationRequest;
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("deductSituation", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.deductSituation(ctx, body);
          return new Response(JSON.stringify(result as DeductSituationResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-satellites",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ListSatellitesRequest = {
            country: params.get("country") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("listSatellites", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listSatellites(ctx, body);
          return new Response(JSON.stringify(result as ListSatellitesResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-gps-interference",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ListGpsInterferenceRequest = {
            region: params.get("region") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("listGpsInterference", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listGpsInterference(ctx, body);
          return new Response(JSON.stringify(result as ListGpsInterferenceResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-oref-alerts",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ListOrefAlertsRequest = {
            mode: (params.get("mode") ?? "MODE_UNSPECIFIED") as Mode,
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("listOrefAlerts", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listOrefAlerts(ctx, body);
          return new Response(JSON.stringify(result as ListOrefAlertsResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-telegram-feed",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ListTelegramFeedRequest = {
            limit: Number(params.get("limit") ?? "0"),
            topic: params.get("topic") ?? "",
            channel: params.get("channel") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("listTelegramFeed", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listTelegramFeed(ctx, body);
          return new Response(JSON.stringify(result as ListTelegramFeedResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-company-enrichment",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetCompanyEnrichmentRequest = {
            domain: params.get("domain") ?? "",
            name: params.get("name") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getCompanyEnrichment", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getCompanyEnrichment(ctx, body);
          return new Response(JSON.stringify(result as GetCompanyEnrichmentResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-company-signals",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ListCompanySignalsRequest = {
            company: params.get("company") ?? "",
            domain: params.get("domain") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("listCompanySignals", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listCompanySignals(ctx, body);
          return new Response(JSON.stringify(result as ListCompanySignalsResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-country-facts",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetCountryFactsRequest = {
            countryCode: params.get("country_code") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getCountryFacts", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getCountryFacts(ctx, body);
          return new Response(JSON.stringify(result as GetCountryFactsResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-security-advisories",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const body = {} as ListSecurityAdvisoriesRequest;

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listSecurityAdvisories(ctx, body);
          return new Response(JSON.stringify(result as ListSecurityAdvisoriesResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-gdelt-topic-timeline",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetGdeltTopicTimelineRequest = {
            topic: params.get("topic") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getGdeltTopicTimeline", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getGdeltTopicTimeline(ctx, body);
          return new Response(JSON.stringify(result as GetGdeltTopicTimelineResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-cross-source-signals",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const body = {} as ListCrossSourceSignalsRequest;

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listCrossSourceSignals(ctx, body);
          return new Response(JSON.stringify(result as ListCrossSourceSignalsResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/list-market-implications",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ListMarketImplicationsRequest = {
            frameworkId: params.get("frameworkId") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("listMarketImplications", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.listMarketImplications(ctx, body);
          return new Response(JSON.stringify(result as ListMarketImplicationsResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-social-velocity",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const body = {} as GetSocialVelocityRequest;

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getSocialVelocity(ctx, body);
          return new Response(JSON.stringify(result as GetSocialVelocityResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-country-energy-profile",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetCountryEnergyProfileRequest = {
            countryCode: params.get("country_code") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getCountryEnergyProfile", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getCountryEnergyProfile(ctx, body);
          return new Response(JSON.stringify(result as GetCountryEnergyProfileResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/compute-energy-shock",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: ComputeEnergyShockScenarioRequest = {
            countryCode: params.get("country_code") ?? "",
            chokepointId: params.get("chokepoint_id") ?? "",
            disruptionPct: Number(params.get("disruption_pct") ?? "0"),
            fuelMode: params.get("fuel_mode") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("computeEnergyShockScenario", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.computeEnergyShockScenario(ctx, body);
          return new Response(JSON.stringify(result as ComputeEnergyShockScenarioResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-country-port-activity",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetCountryPortActivityRequest = {
            countryCode: params.get("country_code") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getCountryPortActivity", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getCountryPortActivity(ctx, body);
          return new Response(JSON.stringify(result as CountryPortActivityResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-regional-snapshot",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetRegionalSnapshotRequest = {
            regionId: params.get("region_id") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getRegionalSnapshot", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getRegionalSnapshot(ctx, body);
          return new Response(JSON.stringify(result as GetRegionalSnapshotResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-regime-history",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetRegimeHistoryRequest = {
            regionId: params.get("region_id") ?? "",
            limit: Number(params.get("limit") ?? "0"),
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getRegimeHistory", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getRegimeHistory(ctx, body);
          return new Response(JSON.stringify(result as GetRegimeHistoryResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
    {
      method: "GET",
      path: "/api/intelligence/v1/get-regional-brief",
      handler: async (req: Request): Promise<Response> => {
        try {
          const pathParams: Record<string, string> = {};
          const url = new URL(req.url, "http://localhost");
          const params = url.searchParams;
          const body: GetRegionalBriefRequest = {
            regionId: params.get("region_id") ?? "",
          };
          if (options?.validateRequest) {
            const bodyViolations = options.validateRequest("getRegionalBrief", body);
            if (bodyViolations) {
              throw new ValidationError(bodyViolations);
            }
          }

          const ctx: ServerContext = {
            request: req,
            pathParams,
            headers: Object.fromEntries(req.headers.entries()),
          };

          const result = await handler.getRegionalBrief(ctx, body);
          return new Response(JSON.stringify(result as GetRegionalBriefResponse), {
            status: 200,
            headers: { "Content-Type": "application/json" },
          });
        } catch (err: unknown) {
          if (err instanceof ValidationError) {
            return new Response(JSON.stringify({ violations: err.violations }), {
              status: 400,
              headers: { "Content-Type": "application/json" },
            });
          }
          if (options?.onError) {
            return options.onError(err, req);
          }
          const message = err instanceof Error ? err.message : String(err);
          return new Response(JSON.stringify({ message }), {
            status: 500,
            headers: { "Content-Type": "application/json" },
          });
        }
      },
    },
  ];
}

