npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ar-agents/fecred

v0.2.0

Published

Agent toolkit for AFIP/ARCA WSFECred (Factura de Credito Electronica MiPyME): check if a counterparty is obligated to the FCE regime, list received FCEs, and accept or reject them. Pair with @ar-agents/identity for WSAA cert + signature handling.

Readme

@ar-agents/fecred

Agent toolkit for AFIP/ARCA WSFECred (Registro de Facturas de Credito Electronica MiPyME, RG 4367). Check if a counterparty is obligated to the FCE regime, list received FCEs, and accept or reject them within the legal window.

pnpm add @ar-agents/fecred

What this package does

  • HttpFecredAdapter: real adapter that POSTs SOAP to AFIP WSFECred (homo or prod). Caller supplies a WSAA access ticket for the wsfecred service; the adapter handles envelope construction, SOAPAction header, and response parsing.
  • InMemoryFecredAdapter: deterministic adapter for integration tests + demos. Seed received FCEs and obligated CUITs; accept/reject mutate the in-memory state with AFIP-realistic semantics.
  • UnconfiguredFecredAdapter: explicit throws-on-every-call default, so an agent without creds never silently lies.
  • Five Vercel AI SDK tools: fecred_check_obligation, fecred_list_received, fecred_accept_invoice, fecred_reject_invoice, fecred_health.

When to use this vs the sibling packages

| You want to... | Use | | --------------------------------------------------------------- | ------------------------- | | Issue a regular factura (A/B/C) and get a CAE | @ar-agents/facturacion | | Validate that a received factura's CAE is real | @ar-agents/wscdc | | Know if your invoice to a big buyer MUST be an FCE | this package | | Manage FCEs you received: list, accept, reject | this package |

The FCE regime applies when a MiPyME invoices a large company above a threshold amount (montoDesde). AFIP updates that threshold periodically (for example the April 2026 update to roughly ARS 5.5M); fecred_check_obligation returns the live value, so never hardcode it.

Quick start

import { HttpFecredAdapter, type AccessTicket } from "@ar-agents/fecred";

// Acquire a TA from your WSAA flow first, service id "wsfecred":
//   const ta = await acquireWsaaTicket("wsfecred", { certPem, keyPem });
const ticket: AccessTicket = /* ... */ undefined!;

const fecred = new HttpFecredAdapter({ env: "prod", ticket });

// 1. Before issuing: must this invoice be an FCE?
const oblig = await fecred.checkObligation({ cuitConsultada: "30-50000001-8" });
if (oblig.obligado && invoiceTotal >= (oblig.montoDesde ?? Infinity)) {
  // Issue FCE type 201/206/211 via @ar-agents/facturacion.
}

// 2. As receptor: what is pending acceptance?
const pending = await fecred.listComprobantes({
  rol: "Receptor",
  estadoCmp: "Recepcionado",
  fechaTipo: "Emision",
});

// 3. Accept one (IRREVERSIBLE legal act):
const r = await fecred.acceptInvoice({
  idFactura: { cuitEmisor: "20-41758101-5", codTipoCmp: 201, ptoVta: 3, nroCmp: 42 },
  saldoAceptado: 8_000_000,
  codMoneda: "PES",
  cotizacionMonedaUlt: 1,
});

Wired as agent tools:

import { Experimental_Agent as Agent } from "ai";
import { fecredTools, HttpFecredAdapter } from "@ar-agents/fecred";
import { anthropic } from "@ai-sdk/anthropic";

const agent = new Agent({
  model: anthropic("claude-sonnet-4-7"),
  tools: fecredTools({
    adapter: new HttpFecredAdapter({ env: "prod", ticket }),
  }),
  system: "Sos un agente que gestiona Facturas de Credito Electronica recibidas.",
});

The legal window

A received FCE that is not rejected within the legal acceptance window (15 corridos days from puesta a disposicion) is tacitly accepted and becomes a negotiable credit title. Run fecred_list_received regularly and surface anything close to fechaVenAcep.

In-memory testing

import { InMemoryFecredAdapter, fecredTools } from "@ar-agents/fecred";

const adapter = new InMemoryFecredAdapter({
  obligatedCuits: ["30-50000001-8"],
  montoDesde: 5_500_000, // configurable; the real value comes from AFIP
  comprobantes: [/* seeded FecredComprobante objects */],
});

const tools = fecredTools({ adapter });

Errors

import {
  FecredError,
  FecredValidationError,  // bad input, do NOT retry
  FecredProtocolError,    // network / HTTP / SOAP fault, may retry
  FecredUnconfiguredError,
} from "@ar-agents/fecred";

A resultado: "R" in an accept/reject response is NOT thrown: it means AFIP refused the operation (already accepted, out of window, etc.) and the errors[] array explains why.

Constraints

  • Dates are YYYY-MM-DD (xsd:date). This differs from WSFE/WSCDC's YYYYMMDD.
  • FCE comprobante type codes: 201 (FCE A), 206 (FCE B), 211 (FCE C), plus their nota de debito/credito variants.
  • WSAA service id is wsfecred and requires its own authorization in the AFIP portal, separate from wsfe and wscdc.
  • Rejection requires at least one motivo with codMotivo, descMotivo, and justificacion (max 250 chars each).

For LLM agents using these tools, see AGENTS.md.

License

MIT, Nazareno Clemente [email protected]