"""Auto-generated by delta-registry-website/lib/schema-generator — do not hand-edit.
Source: Apify actor 'sec-enforcement-litigation-delta-feed' (live Apify API), generated 2026-09-18.
Regenerate with: node generate-all.js

NOTE: this targets AG2 Classic (import autogen), the AutoGen-lineage conversational-agent API.
"AutoGen" itself is in Microsoft-maintenance mode as of 2026; AG2 (ag2ai/ag2) is the actively
developed continuation. AG2 also has a newer, separate v1.0 protocol-driven surface (shipped
2026-09-11) not covered here because its docs could not be verified at generation time.
"""
import os
from typing import Annotated, Optional

import requests
from autogen import ConversableAgent, register_function, LLMConfig

APIFY_ACTOR_ID = 'EDhT9Mvrdm2hzTECA'  # stefano_seggio/sec-enforcement-litigation-delta-feed
APIFY_RUN_SYNC_URL = f"https://api.apify.com/v2/acts/{APIFY_ACTOR_ID}/run-sync-get-dataset-items"


def run_sec_enforcement_litigation_delta_feed(
    userAgent: Annotated[str, 'SEC\'s own fair-access policy (sec.gov/os/webmaster-faq#developers) requires automated requests to sec.gov/data.sec.gov to declare a descriptive User-Agent identifying the requester, typically \'<Your Company Name> <your-contact-email>\'. Sent verbatim on every request.'],
    sources: Annotated[Optional[list[str]], 'Which of SEC.gov\'s own enforcement feeds to walk each run. \'Litigation Releases\' are HTML pages under sec.gov/enforcement-litigation/litigation-releases/lr-NNNNN (RSS at .../litigation-releases/rss, live-verified). \'Administrative Proceedings\' link directly to PDF orders under sec.gov/files/litigation/admin/YYYY/34-NNNNNN.pdf (RSS at .../administrative-proceedings/rss, live-verified) and require a separate PDF text-extraction pass.'] = ["litigation_releases","administrative_proceedings"],
    onlyNew: Annotated[Optional[bool], 'When true (default), only NEW_LISTING and content-changed (UPDATED) records are pushed as charged events. Set false to also push free, uncharged SNAPSHOT_NO_DIFF records for every release the walk touches.'] = true,
    maxItemsPerRun: Annotated[Optional[int], 'Caps the number of charged (result/result-summary) events this run will push, independent of your Apify spending limit. 0 means no Actor-side cap.'] = 0,
    enableCikLinking: Annotated[Optional[bool], 'When true (default), each parsed respondent name is looked up against SEC\'s own EDGAR company database (browse-edgar company search) to attach a linked_edgar_cik. A match scoring below cikMatchConfidenceThreshold is left null rather than guessed.'] = true,
    cikMatchConfidenceThreshold: Annotated[Optional[float], 'Minimum name-match confidence (0-1) required before linked_edgar_cik is populated. Default 0.80 is deliberately conservative - a real respondent, \'Invesco Alpha Inc.\', shares a name substring with the real, unrelated NYSE-listed Invesco Ltd, and a lower threshold would risk wrongly attaching a real public company\'s CIK to an unrelated enforcement action in your vendor-risk feed.'] = 0.8,
    watchlistNames: Annotated[Optional[list[str]], 'Entity or individual names (case-insensitive substring match against parsed respondents) you specifically want flagged. A match sets is_watchlist_match: true.'] = [],
    requestDelayMs: Annotated[Optional[int], 'A flat delay applied between every successful request to sec.gov/data.sec.gov, independent of retries - a deliberately conservative default since this Actor\'s endpoints were live-verified for shape and availability only, not load-tested against SEC\'s general fair-access ceiling.'] = 750,
    maxRetries: Annotated[Optional[int], 'Retry attempts for a 429/5xx response or a network-level failure before a request is treated as failed for this run. Exponential backoff (1000ms * 2^attempt, jittered, capped at 15s).'] = 4,
    requestTimeoutSecs: Annotated[Optional[int], 'AbortSignal timeout applied to every individual HTTP request (feed page, release page, PDF download, EDGAR lookup).'] = 30,
    deltaStateName: Annotated[Optional[str], 'Names the Key-Value Store this schedule\'s seen-release state is kept in. Run two schedules - e.g. one full-coverage, one watchlist-only - without them draining each other\'s baseline by giving each a distinct name here.'] = "default",
    resetState: Annotated[Optional[bool], 'When true, clears this schedule\'s stored seen-release state before walking, so the next run re-baselines from scratch. Use for testing or recovering a corrupted state store, not routine operation.'] = false,
) -> str:
    """Structures SEC.gov's own Litigation Releases and Administrative Proceedings feeds into delta events: respondent, statute/rule citations, monetary sanctions, and a best-effort linked EDGAR CIK. Outside the saturated 10-K/8-K/Form-4 filings-scraper niche. Pay-per-event: billed only for what changed."""
    token = os.environ["APIFY_TOKEN"]
    payload = {
        **({"sources": sources} if sources is not None else {}),
        **({"onlyNew": onlyNew} if onlyNew is not None else {}),
        **({"maxItemsPerRun": maxItemsPerRun} if maxItemsPerRun is not None else {}),
        **({"enableCikLinking": enableCikLinking} if enableCikLinking is not None else {}),
        **({"cikMatchConfidenceThreshold": cikMatchConfidenceThreshold} if cikMatchConfidenceThreshold is not None else {}),
        **({"watchlistNames": watchlistNames} if watchlistNames is not None else {}),
        "userAgent": userAgent,
        **({"requestDelayMs": requestDelayMs} if requestDelayMs is not None else {}),
        **({"maxRetries": maxRetries} if maxRetries is not None else {}),
        **({"requestTimeoutSecs": requestTimeoutSecs} if requestTimeoutSecs is not None else {}),
        **({"deltaStateName": deltaStateName} if deltaStateName is not None else {}),
        **({"resetState": resetState} if resetState is not None else {}),
    }
    resp = requests.post(
        APIFY_RUN_SYNC_URL,
        params={"token": token},
        json=payload,
        timeout=320,  # Apify's real run-sync-get-dataset-items cap is 300s
    )
    resp.raise_for_status()
    return resp.text


# Wire into your own agents, e.g.:
#
# with LLMConfig(api_type="openai", model="gpt-4o-mini"):
#     compliance_agent = ConversableAgent(name="compliance_agent", system_message="...")
# executor_agent = ConversableAgent(name="executor_agent", human_input_mode="NEVER")
#
# register_function(
#     run_sec_enforcement_litigation_delta_feed,
#     caller=compliance_agent,
#     executor=executor_agent,
#     description='Structures SEC.gov\'s own Litigation Releases and Administrative Proceedings feeds into delta events: respondent, statute/rule citations, monetary sanctions, and a best-effort linked EDGAR CIK. Outside the saturated 10-K/8-K/Form-4 filings-scraper niche. Pay-per-event: billed only for what changed.',
# )
