"""Phase 8 (Pakistan COD suite) additions to :class:`packs.ecommerce.pack.EcommercePack`, kept here so the shared pack module only gains one line per member.""" from __future__ import annotations from typing import Any from core.packs.loader import AgentDeps, IntentInfo from core.tools.spec import RegisteredTool COD_INTENTS = [ IntentInfo( "ecommerce.cod_confirm", "Confirm ONE cash-on-delivery order: score its RTO risk, then auto-confirm and book a " "courier (low risk) or ask the customer on WhatsApp (medium/high risk), e.g. " "'confirm ORD-1021'.", ), IntentInfo( "ecommerce.cod_sweep", "Scheduled: COD confirmations past their deadline become no_answer and are escalated.", chat_enabled=False, ), IntentInfo( "ecommerce.courier_status", "Courier webhook: a shipment status changed (in transit, delivered, returned...).", chat_enabled=False, ), IntentInfo( "ecommerce.courier_poll", "Scheduled: poll couriers for active shipments' status.", chat_enabled=False, ), IntentInfo( "ecommerce.cod_reconcile", "Reconcile COD remittances from couriers against delivered orders and report " "mismatches and missing payments, e.g. 'reconcile COD payments'.", ), ] COD_EVENT_TYPES = [i.name for i in COD_INTENTS] COD_EVENT_ALIASES = { # Phase 5 generic signed webhook: {"type": "courier.status", "payload": {"courier", ...}} "courier.status": "ecommerce.courier_status", } def cod_tools() -> list[RegisteredTool]: from packs.ecommerce.tools.cod_tools import cod_tools as tools return tools() def cod_subgraphs(deps: AgentDeps) -> dict[str, Any]: from packs.ecommerce import graphs_cod return { "ecommerce.cod_confirm": graphs_cod.cod_confirm_graph(deps), "ecommerce.cod_sweep": graphs_cod.cod_sweep_graph(deps), "ecommerce.courier_status": graphs_cod.courier_status_graph(deps), "ecommerce.courier_poll": graphs_cod.courier_poll_graph(deps), "ecommerce.cod_reconcile": graphs_cod.cod_reconcile_graph(deps), } def order_created_graph(deps: AgentDeps) -> Any: """Replaces the Phase 6 ``ecommerce.order.created`` graph: same store-event step, then (if the tenant enabled it) the COD confirmation chain.""" from packs.ecommerce.graphs_cod import order_created_graph as build return build(deps) def cod_routers() -> list[Any]: from packs.ecommerce.api_cod import router return [router] def cod_seeders() -> dict[str, Any]: from packs.ecommerce.seed_cod import seed_cod_eval, seed_cod_recon_eval return {"ecommerce/cod": seed_cod_eval, "ecommerce/cod-recon": seed_cod_recon_eval}