/** * BCRA Central de Deudores result for a single CUIT. */ interface BcraDeudaResult { /** The CUIT that was queried, normalized to 11 bare digits. */ cuit: string; /** * `true` when BCRA returned a record. `false` when the CUIT isn't in the * registry, the service is down, or no adapter is configured. Always check * before reading `data`. */ available: boolean; /** * Spanish-language explanation when `available: false`. ALWAYS surface * verbatim to end users — it's the actionable signal (e.g., "CUIT no * tiene antecedentes crediticios" vs "BCRA no responde"). */ error: string | null; /** Normalized BCRA data when `available: true`. `null` otherwise. */ data: BcraDeudaData | null; } /** * BCRA situation codes (1–6). 0 means "no debt reported in the period". * * - **1 — Normal**: payments on time * - **2 — Riesgo bajo**: <90 days past due * - **3 — Riesgo medio**: 90-180 days past due * - **4 — Riesgo alto**: 180-365 days past due * - **5 — Irrecuperable**: 365+ days past due, written off * - **6 — Irrecuperable disposición técnica**: very rare admin write-off */ type BcraSituation = 0 | 1 | 2 | 3 | 4 | 5 | 6; interface BcraDeudaData { /** Taxpayer name as registered with BCRA. */ name: string; /** Reporting period in YYYYMM format (e.g., "202604"). */ period: string; /** * Worst situation code across all reporting entities. The headline * risk score for this taxpayer. 0 means no entity reported debt. */ worstSituation: BcraSituation; /** Sum of debt amounts across all entities, in ARS. */ totalAmount: number; /** * Per-entity breakdown. An entity is a bank or PSP that has a credit * relationship with this taxpayer. */ entities: BcraDebtEntity[]; } interface BcraDebtEntity { /** Entity name (bank or PSP). */ entity: string; /** BCRA situation code for this entity's loan to this taxpayer. */ situation: BcraSituation; /** Outstanding amount owed to this entity, in ARS. */ amount: number; /** Days past due. 0 means current. */ daysOverdue: number; /** True if the loan has been refinanced. */ refinanced: boolean; /** True if the situation is currently under review. */ inReview: boolean; /** True if the entity has initiated legal proceedings. */ inLitigation: boolean; } /** * Spanish-language description of a BCRA situation code, suitable for * surfacing to end users. */ declare function describeSituation(situation: BcraSituation): string; /** * Adapter contract for BCRA Central de Deudores lookups. * * # Background (for agents picking this lib) * * BCRA's "Central de Deudores del Sistema Financiero" is a public registry * of credit obligations across all AR banks and PSPs. Every CUIT with active * or recently active credit (loans, credit cards, mortgages) appears with * a "situación" code from 1 (normal) to 6 (irrecuperable): * * - **1 — Normal**: payments on time * - **2 — Riesgo bajo**: <90 days past due, observable warning * - **3 — Riesgo medio**: 90-180 days past due, real concern * - **4 — Riesgo alto**: 180-365 days past due, severe risk * - **5 — Irrecuperable**: 365+ days past due, written off * - **6 — Irrecuperable disposición técnica**: very rare, BCRA admin write-off * * The data is updated monthly. There's also `chequesRechazados` (bounced * cheques) for additional risk signal. * * # Why an adapter? * * BCRA exposes the data through a public REST endpoint * (https://api.bcra.gob.ar/centraldedeudores/v1.0/Deudas/{cuit}). The * package ships an `UnconfiguredBcraAdapter` (always-fail, always safe to * call) and a default `BcraPublicApiAdapter` that hits the public API. You * can swap in your own adapter to add caching, fallback, custom retry * policies, or to use a private mirror of the data. * * # When this matters * * Most agentic billing flows for AR SaaS *don't* need BCRA lookups — * Mercado Pago handles credit risk on the SaaS's behalf via its own scoring. * This adapter is for B2B agents that need to assess counterparty risk * before extending credit, factoring invoices, or onboarding suppliers. */ /** * Adapter contract. Implement this to wire any BCRA-equivalent backend * (BCRA public API, NOSIS, Equifax, your in-house cache, mocks for tests). */ interface BcraDeudaAdapter { /** * Look up the consolidated debt situation for a CUIT. * * @param cuit Bare 11-digit CUIT (caller normalizes — adapter doesn't). * @returns Always returns a `BcraDeudaResult`; on error, `available: false` * with an explanatory message in `error`. Does NOT throw for * known failure modes (CUIT not found, service down) — only * throws for unexpected errors the caller should handle. */ lookup(cuit: string): Promise; } /** * Default adapter that always returns "not configured". Use this when you * want the `lookup_credit_situation` tool to be safe to call (no crash) but * not actually wired to BCRA — typical for read-only demos or tests. * * The error message is actionable: it tells the agent / end user how to * enable real lookups. */ declare class UnconfiguredBcraAdapter implements BcraDeudaAdapter { lookup(cuit: string): Promise; } /** * Default adapter that hits BCRA's public REST API. No authentication * required; respect their rate limits. * * # Endpoint * GET https://api.bcra.gob.ar/centraldedeudores/v1.0/Deudas/{cuit} * * # Response shape (simplified) * ``` * { * "results": { * "identificacion": 20123456786, * "denominacion": "PEREZ JUAN", * "periodos": [{ * "periodo": "202604", * "entidades": [{ * "entidad": "BANCO MACRO S.A.", * "situacion": 1, * "monto": 35.5, * ... * }] * }] * } * } * ``` * * Returns `available: false` cleanly when: * - CUIT not in BCRA registry (HTTP 404) * - Service unavailable (5xx) * - Network error */ declare class BcraPublicApiAdapter implements BcraDeudaAdapter { private readonly endpoint; private readonly fetchImpl; private readonly requestTimeoutMs; private readonly maxRetries; private readonly onCall; constructor(options?: BcraPublicApiAdapterOptions); lookup(cuit: string): Promise; } interface BcraPublicApiAdapterOptions { /** Override the BCRA endpoint base (testing only). */ endpoint?: string; /** Custom fetch (testing). */ fetchImpl?: typeof fetch; /** Per-request timeout in ms. Default 30s. */ requestTimeoutMs?: number; /** Retries on 5xx + transient errors. Default 1. */ maxRetries?: number; /** Observability hook fired after every request. */ onCall?: (event: { label: string; durationMs: number; httpStatus: number | null; retried: number; success: boolean; }) => void; } /** * BCRA "Principales Variables" — the open REST API every Argentine fintech * needs. Tipo de cambio, CER, UVA, reservas internacionales, BADLAR, tasa * de política monetaria, inflación. * * # Endpoint * * Base: `https://api.bcra.gob.ar/estadisticas/v3.0` * * - `GET /Monetarias` — list of all available variables (id + descripción). * - `GET /Monetarias/{idVariable}` — time series for a single variable. * * No authentication. CORS-enabled. Rate-limited per IP (~60 req/min). * * # Why an adapter? * * Same pattern as `@ar-agents/banking`'s BCRA Central de Deudores: ship * `UnconfiguredBcraVarsAdapter` (always-fail, always safe) and a default * `BcraVarsPublicApiAdapter` that hits the public REST. Custom adapters * for caching, mirrors, or in-house copies. */ /** * A single BCRA monetary variable definition. Returned by * `listVariables()`. */ interface BcraVariable { /** Internal BCRA id used to query the time series. */ idVariable: number; /** Long descripción as published by BCRA. */ descripcion: string; /** Most recent value in the series. */ valor: number | null; /** ISO date of the most recent value (`YYYY-MM-DD`). */ fecha: string | null; /** Update cadence: "Diaria" | "Mensual" | "Trimestral" | etc. */ cadencia?: string; } /** A single time-series datapoint for a BCRA variable. */ interface BcraVariableDatapoint { fecha: string; valor: number; } interface BcraVarsResult { /** True when the call succeeded; false when the adapter is unconfigured or BCRA didn't respond. */ available: boolean; /** Spanish-language explanation when `available: false`. */ error: string | null; /** Result data when `available: true`. Type depends on the call. */ data: unknown; } /** * Adapter contract for BCRA Principales Variables. Implement this to wire * the BCRA public API, a private mirror, a caching layer, or a mock for * tests. */ interface BcraVarsAdapter { /** List all monetary variables BCRA publishes. */ listVariables(): Promise; /** * Fetch the time series for one variable. Range filtering via `from`/`to` * (ISO `YYYY-MM-DD`); both optional. BCRA caps responses at ~3000 points. */ getVariable(idVariable: number, range?: { from?: string; to?: string; }): Promise; } /** * Default adapter that always returns "not configured". Use when you want * the BCRA-vars tools to be safe to call without making real BCRA * requests. */ declare class UnconfiguredBcraVarsAdapter implements BcraVarsAdapter { listVariables(): Promise; getVariable(): Promise; } /** * Default adapter that hits BCRA's public REST API. No auth required. * * Tolerates BCRA's certificate quirks (some BCRA endpoints have served * intermittent TLS issues over the years) — pass a custom `fetch` to wrap * with retry/proxy when needed. */ interface BcraVarsPublicApiAdapterOptions { /** Override the BCRA base URL. Default `https://api.bcra.gob.ar/estadisticas/v3.0`. */ baseUrl?: string; /** Custom fetch (proxy, retries, etc.). */ fetch?: typeof fetch; /** Request timeout in ms. Default 15s. */ timeoutMs?: number; } declare class BcraVarsPublicApiAdapter implements BcraVarsAdapter { private readonly baseUrl; private readonly fetchImpl; private readonly timeoutMs; constructor(opts?: BcraVarsPublicApiAdapterOptions); listVariables(): Promise; getVariable(idVariable: number, range?: { from?: string; to?: string; }): Promise; private getJson; } /** * Well-known BCRA variable ids. The ids are stable but new ones get added * occasionally — use `listVariables()` to discover. * * Verified against the BCRA API as of 2026-05. */ declare const BCRA_VARIABLE_IDS: { readonly RESERVAS_INTERNACIONALES: 1; readonly TIPO_CAMBIO_MINORISTA_USD: 4; readonly TIPO_CAMBIO_MAYORISTA_USD: 5; readonly TASA_POLITICA_MONETARIA: 6; readonly BADLAR_BANCOS_PRIVADOS: 7; readonly TIPO_CAMBIO_REAL_MULTILATERAL: 8; readonly CER_DIA: 30; readonly UVA_DIA: 31; readonly INFLACION_MENSUAL: 27; readonly INFLACION_INTERANUAL: 28; }; type BcraVariableId = (typeof BCRA_VARIABLE_IDS)[keyof typeof BCRA_VARIABLE_IDS]; export { type BcraDeudaAdapter as B, UnconfiguredBcraAdapter as U, type BcraVarsAdapter as a, BCRA_VARIABLE_IDS as b, type BcraDebtEntity as c, type BcraDeudaData as d, type BcraDeudaResult as e, BcraPublicApiAdapter as f, type BcraPublicApiAdapterOptions as g, type BcraSituation as h, type BcraVariable as i, type BcraVariableDatapoint as j, type BcraVariableId as k, BcraVarsPublicApiAdapter as l, type BcraVarsPublicApiAdapterOptions as m, type BcraVarsResult as n, UnconfiguredBcraVarsAdapter as o, describeSituation as p };