import { B as BcraDeudaAdapter, a as BcraVarsAdapter } from './bcra-vars-BhphcVkm.js'; export { b as BCRA_VARIABLE_IDS, c as BcraDebtEntity, d as BcraDeudaData, e as BcraDeudaResult, f as BcraPublicApiAdapter, g as BcraPublicApiAdapterOptions, h as BcraSituation, i as BcraVariable, j as BcraVariableDatapoint, k as BcraVariableId, l as BcraVarsPublicApiAdapter, m as BcraVarsPublicApiAdapterOptions, n as BcraVarsResult, U as UnconfiguredBcraAdapter, o as UnconfiguredBcraVarsAdapter, p as describeSituation } from './bcra-vars-BhphcVkm.js'; import { ToolSet } from 'ai'; import { ArAgentsError } from '@ar-agents/core'; /** * BCRA-published list of Argentine banks and PSPs (Proveedores de Servicios * de Pago) keyed by their 3-digit entity code (the first 3 digits of a * CBU/CVU). * * # Maintenance * * BCRA periodically updates the list (new fintechs join, banks merge or * rebrand). When a code in the wild isn't in this map, `lookupBankByCode()` * returns `null` and `parseCbu()` reports `kind: "unknown"` — the CBU may * still be structurally valid (the check-digit algorithm is independent of * this table). Submit a PR to extend the table when you encounter gaps. * * # Sources * * - BCRA "Tabla de Entidades Financieras" (annex to its CBU normative) * - BCRA "Listado de Proveedores de Servicios de Pago — Cuentas de Pago" * - Manually verified against issued CBUs/CVUs from each entity */ type EntityKind = "cbu" | "cvu"; interface BankInfo { /** 3-digit BCRA-assigned code (first 3 digits of the CBU/CVU). */ code: string; /** Full Spanish entity name as published by BCRA. */ name: string; /** `cbu` for traditional banks, `cvu` for PSPs / virtual accounts. */ kind: EntityKind; /** * Optional brand/short name (e.g., "Mercado Pago" for the PSP whose legal * name is "Mercado Pago S.R.L."). Use this in user-facing surfaces; use * `name` for compliance / receipts. */ shortName?: string; } /** * Look up a bank/PSP by its 3-digit entity code (the first 3 digits of a * CBU). Returns `null` when the code isn't in the table. * * For CVUs (entity code 000), this returns null — use `lookupCvuByPrefix()` * with the 7-digit prefix (000 + 4-digit fintech subcode) instead. */ declare function lookupBankByCode(code: string): BankInfo | null; /** * Look up a CVU issuer (PSP/fintech) by the 7-digit prefix of the CVU, * which is `000` plus the 4-digit fintech subcode. Use this to identify * which PSP issued a CVU starting with `000`. * * Returns `null` when the prefix isn't in the table — the CVU may still be * structurally valid (BCRA's PSP list evolves quickly). * * @example * lookupCvuByPrefix("0000031") // → { name: "Mercado Pago...", kind: "cvu", ... } */ declare function lookupCvuByPrefix(prefix7: string): BankInfo | null; /** * Returns all known banks/entities. Useful for UIs that render a select * dropdown of banks. Sorted by code. */ declare function listBanks(): BankInfo[]; /** * Returns all known PSP issuers (keyed by 7-digit prefix). Useful for UIs * that render a select dropdown of fintech wallets. */ declare function listPsps(): BankInfo[]; /** * Pure-algorithm CBU/CVU validation and parsing for Argentine bank accounts. * * # Background (for agents picking this lib) * * **CBU** (Clave Bancaria Uniforme) is the standardized 22-digit identifier * for AR bank accounts (Banco Nación, Galicia, Santander, etc.). * **CVU** (Clave Virtual Uniforme) is the same format but issued by PSPs * (Mercado Pago, Ualá, Brubank, Naranja X, etc.) — non-bank financial * services regulated by the BCRA. * * Both share the same structure and the same check-digit algorithm — the * only difference is the bank/entity code prefix in the first 3 digits: * - **001-499**: traditional banks (BCRA-assigned, see `banks.ts`) * - **000 + 4-digit fintech code**: PSP/PSPCP virtual accounts * * # Format * * 22 digits split into two blocks: * - **Block 1 (8 digits)**: `BBB-SSSS-V₁` * - `BBB` = 3-digit entity code * - `SSSS` = 4-digit branch code (sucursal) * - `V₁` = block-1 check digit * - **Block 2 (14 digits)**: `-V₂` * - `account-13` = 13-digit account number * - `V₂` = block-2 check digit * * # Check digit algorithm (BCRA spec) * * **Block 1 check digit (V₁)**: * - Weights: `[7, 1, 3, 9, 7, 1, 3]` applied to digits 1-7 of block 1 * - sum = Σ(digit × weight) * - V₁ = `(10 - (sum mod 10)) mod 10` * * **Block 2 check digit (V₂)**: * - Weights: `[3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3]` applied to digits * 1-13 of block 2 * - sum = Σ(digit × weight) * - V₂ = `(10 - (sum mod 10)) mod 10` * * # When to use this module * * Use these functions when you need to detect typos in a CBU/CVU or extract * the bank/branch/account components WITHOUT contacting a bank or BCRA. * They're pure functions (no I/O, no environment dependencies, sub-millisecond) * and always safe to call. * * # Common pitfall * * Users paste CBUs in many shapes: `0070000-30000123456789`, with spaces, * with hyphens. Always pass the user's input directly to `parseCbu()` — it * normalizes by stripping non-digits before validating. */ /** * Whether this CBU/CVU is a traditional bank CBU (entity code 001-499) or * a PSP virtual CVU (entity code 000-prefix). * * - `cbu`: traditional bank — BBB code is the BCRA-assigned bank code. * - `cvu`: PSP virtual account — typically code 000 + 4-digit fintech code, * though some PSPs use codes in the 300+ range. Distinction is heuristic. * - `unknown`: bank code not in the lookup table (could be either). */ type CbuKind = "cbu" | "cvu" | "unknown"; /** * Structured result of parsing a CBU/CVU. The `valid` field is the bottom * line; the other fields exist to let callers explain WHY a CBU failed * (typo? wrong length? bad block-1 check? bad block-2 check?) instead of * just rejecting opaquely. */ interface CbuParseResult { /** * True iff the CBU passes ALL validations: 22 digits, block-1 check * digit matches, block-2 check digit matches. When false, see `error`. */ valid: boolean; /** Bare 22 digits with no separators. Always present even when invalid. */ normalized: string; /** Pretty-printed `BBBSSSSV-AAAAAAAAAAAAAV`. Null when length isn't 22. */ formatted: string | null; /** 3-digit entity (bank or PSP) code. Null when length isn't 22. */ entityCode: string | null; /** 4-digit branch code (sucursal). Null when length isn't 22. */ branchCode: string | null; /** 13-digit account number. Null when length isn't 22. */ accountNumber: string | null; /** Block-1 check digit (as written). Null when length isn't 22. */ block1CheckDigit: string | null; /** Block-2 check digit (as written). Null when length isn't 22. */ block2CheckDigit: string | null; /** * `cbu` if the entity code maps to a traditional bank, `cvu` if it maps * to a known PSP, `unknown` if the code is unrecognized (still possibly * valid — the BCRA list evolves). */ kind: CbuKind; /** * Bank/entity info from the lookup table, or `null` if the entity code * isn't in the table. Use `kind` together with this — `kind === "unknown"` * implies `bank === null`. */ bank: BankInfo | null; /** * Spanish error message when invalid. ALWAYS surface this verbatim to end * users — it's actionable (e.g., "Bloque 1 dígito verificador inválido. * Esperado: 0, recibido: 7. Probablemente hay un typo."). */ error: string | null; } /** * Strip every non-digit character. CBU/CVU inputs from end users come in * many shapes (`0070000-30000123456789`, `00700003 00001234567890`, etc.); * normalize before validating. * * @example * normalizeCbu("0070000-30000123456789") // → "00700003000012345678901" — wait, lengths */ declare function normalizeCbu(input: string): string; /** * Compute the BCRA mod-10 check digit for a block of digits with the given * weights. Returns `null` when input has unexpected length or non-digits. * * @internal exposed for testing — most callers should use `parseCbu()`. */ declare function computeBlockCheckDigit(digits: string, weights: readonly number[]): number | null; /** * Parse and validate a CBU/CVU. The PRIMARY entrypoint of this module. * * @param input The CBU/CVU in any format (with/without separators, spaces, hyphens). * @returns A `CbuParseResult` with `valid: true|false` plus structural details. * * @example * parseCbu("0070055530005571000018") * // { valid: true, normalized: "0070055530005571000018", * // entityCode: "007", branchCode: "0055", ..., kind: "cbu", * // bank: { code: "007", name: "Banco Santander Argentina" } } */ declare function parseCbu(input: string): CbuParseResult; /** * Convenience: returns just the boolean. Use `parseCbu()` when you need the * structured details (almost always — agents should explain WHY a CBU * failed to end users, not just reject it). */ declare function isValidCbu(input: string): boolean; /** * Optional configuration for `bankingTools()`. All fields are optional; * when omitted, sensible defaults apply that keep the tools always callable * (algorithm tools always work; BCRA lookup returns a clear "not configured" * message via `UnconfiguredBcraAdapter`). */ interface BankingToolsOptions { /** * BCRA Central de Deudores lookup backend. When omitted, a default adapter * is used that always returns `available: false` with setup instructions, * so the `lookup_credit_situation` tool stays safe to call without crashing. * * Pass `new BcraPublicApiAdapter()` for the production backend (no auth * required, hits BCRA's public REST endpoint). */ bcra?: BcraDeudaAdapter; /** * BCRA Principales Variables backend (tipo de cambio, CER, UVA, * reservas, etc.). When omitted, returns "not configured" via * `UnconfiguredBcraVarsAdapter`. Pass `new BcraVarsPublicApiAdapter()` * to enable, no auth required. */ bcraVars?: BcraVarsAdapter; /** * Override the agent-facing tool descriptions. Pass an object with keys * matching tool names; values replace the default description. Useful * when the agent's primary language isn't English/Spanish. */ descriptions?: Partial>; } type BankingToolName = "validate_cbu" | "lookup_bank_by_code" | "list_banks" | "list_psps" | "lookup_credit_situation" | "list_bcra_variables" | "get_bcra_variable" | "get_usd_oficial" | "get_uva" | "get_cer" | "get_reservas_bcra"; /** * Build the agent tool collection for `@ar-agents/banking`. Drop directly * into `Experimental_Agent`'s `tools` option, or merge with other tool sets * (e.g., from `@ar-agents/identity` and `@ar-agents/mercadopago`). * * @example Algorithm-only (default, BCRA lookup returns "not configured") * ```ts * import { Experimental_Agent as Agent, stepCountIs } from "ai"; * import { bankingTools } from "@ar-agents/banking"; * * const agent = new Agent({ * model: "anthropic/claude-sonnet-4-6", * tools: bankingTools(), * stopWhen: stepCountIs(6), * }); * ``` * * @example With a real BCRA adapter * ```ts * import { bankingTools, BcraPublicApiAdapter } from "@ar-agents/banking"; * * const agent = new Agent({ * model: "anthropic/claude-sonnet-4-6", * tools: bankingTools({ bcra: new BcraPublicApiAdapter() }), * stopWhen: stepCountIs(6), * }); * ``` */ declare function bankingTools(options?: BankingToolsOptions): ToolSet; /** * Errors emitted by `@ar-agents/banking` adapters and helpers. * * Extends `ArAgentsError` from `@ar-agents/core` so the family contract * (code / retryable / context) is uniform. */ type BankingErrorCode = "bcra_not_configured" | "bcra_cuit_not_found" | "bcra_service_unavailable" | "bcra_rate_limited" | "bcra_unknown_error" | "bcra_vars_not_configured" | "bcra_vars_unavailable"; declare class BankingError extends ArAgentsError { readonly code: BankingErrorCode; readonly details?: unknown; constructor(code: BankingErrorCode, message: string, details?: unknown); } /** * Thrown when BCRA Central de Deudores lookup is requested but no adapter * is configured. Surface the message verbatim — it explains how to enable. */ declare class BcraNotConfiguredError extends BankingError { constructor(); } /** * Thrown when BCRA Principales Variables lookup is requested but no * adapter is configured. Surface the message verbatim. */ declare class BcraVarsNotConfiguredError extends BankingError { constructor(); } export { type BankInfo, BankingError, type BankingErrorCode, type BankingToolName, type BankingToolsOptions, BcraDeudaAdapter, BcraNotConfiguredError, BcraVarsAdapter, BcraVarsNotConfiguredError, type CbuKind, type CbuParseResult, type EntityKind, bankingTools, computeBlockCheckDigit, isValidCbu, listBanks, listPsps, lookupBankByCode, lookupCvuByPrefix, normalizeCbu, parseCbu };