{"_id":"@agenttax/ampersend","_rev":"2-175817d3e1ae5649966cdf38387bf462","name":"@agenttax/ampersend","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@agenttax/ampersend","version":"0.1.0","keywords":["agenttax","ampersend","x402","tax","sales-tax","ai-agent","compliance","machine-payments"],"license":"MIT","_id":"@agenttax/ampersend@0.1.0","maintainers":[{"name":"agenttaxdev","email":"Beardsley@Agenttax.io"}],"homepage":"https://agenttax.io/integrations/ampersend","bugs":{"url":"https://github.com/AgentTax/AgentTax/issues"},"dist":{"shasum":"a104cd25c4156fc172dfc3f7d7395c3fa23259f7","tarball":"https://registry.npmjs.org/@agenttax/ampersend/-/ampersend-0.1.0.tgz","fileCount":4,"integrity":"sha512-djvVWfw63tsOiBJdBwixhDxB2pa21eZfauxE9XbrJyVF2X+0s1sEn0KhaSk5CvJbETx1KgyrK31J6nxReySOqA==","signatures":[{"sig":"MEUCIGHZkIdv8pygvNLNnC9MjmIq0t/zjcl7ZyDBJfRyEnfUAiEAmchk35IjUBTmYgZIsLXctdLXRDcIlv08dK/L+gOIKFo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16735},"main":"index.js","type":"module","types":"index.d.ts","engines":{"node":">=18"},"gitHead":"1a998673835164dfa8b53b8451010405f0fbb803","_npmUser":{"name":"agenttaxdev","email":"Beardsley@Agenttax.io"},"repository":{"url":"git+https://github.com/AgentTax/AgentTax.git","type":"git","directory":"integrations/ampersend"},"_npmVersion":"11.6.2","description":"Tax compliance layer for Ampersend x402 agent payments — calculates sales tax on every transaction","directories":{},"_nodeVersion":"24.13.0","dependencies":{},"_hasShrinkwrap":false,"peerDependencies":{"ampersend-sdk":">=0.1.0"},"_npmOperationalInternal":{"tmp":"tmp/ampersend_0.1.0_1775501231579_0.4444511292252413","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@agenttax/ampersend","version":"0.1.1","description":"Tax compliance layer for Ampersend x402 agent payments — calculates sales tax on every transaction","type":"module","main":"index.js","types":"index.d.ts","license":"MIT","keywords":["agenttax","ampersend","x402","tax","sales-tax","ai-agent","compliance","machine-payments"],"repository":{"type":"git","url":"git+https://github.com/AgentTax/agenttax-ampersend.git"},"homepage":"https://agenttax.io/integrations/ampersend","peerDependencies":{"ampersend-sdk":">=0.1.0"},"dependencies":{},"engines":{"node":">=18"},"gitHead":"1a998673835164dfa8b53b8451010405f0fbb803","_id":"@agenttax/ampersend@0.1.1","bugs":{"url":"https://github.com/AgentTax/agenttax-ampersend/issues"},"_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-XoY9bfAGpyj4FmTlbL5/h5mNd/cTOG9UZSN5RhBG3bkKgvpX0RLyjnrxbrybzW2hXUIU3wQv0enr3DQfuzit+Q==","shasum":"f2b0372b0e9b76ca5ce37bb8f03e2835164ffd01","tarball":"https://registry.npmjs.org/@agenttax/ampersend/-/ampersend-0.1.1.tgz","fileCount":4,"unpackedSize":16984,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDjAH1nsVKHE7HGoYY/Vkyb+WQEkGynrWaOxt5KTCVuWgIhAL3N2jnxwJyyKFfxUfUg194C7He5EcPcX8MIEy4Ur35t"}]},"_npmUser":{"name":"agenttaxdev","email":"Beardsley@Agenttax.io"},"directories":{},"maintainers":[{"name":"agenttaxdev","email":"Beardsley@Agenttax.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ampersend_0.1.1_1775501607580_0.9512568296068495"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-06T18:47:11.444Z","modified":"2026-04-06T18:53:27.811Z","0.1.0":"2026-04-06T18:47:11.726Z","0.1.1":"2026-04-06T18:53:27.705Z"},"bugs":{"url":"https://github.com/AgentTax/agenttax-ampersend/issues"},"license":"MIT","homepage":"https://agenttax.io/integrations/ampersend","keywords":["agenttax","ampersend","x402","tax","sales-tax","ai-agent","compliance","machine-payments"],"repository":{"type":"git","url":"git+https://github.com/AgentTax/agenttax-ampersend.git"},"description":"Tax compliance layer for Ampersend x402 agent payments — calculates sales tax on every transaction","maintainers":[{"name":"agenttaxdev","email":"Beardsley@Agenttax.io"}],"readme":"# @agenttax/ampersend\n\nTax compliance layer for Ampersend x402 agent payments. Wraps any `X402Treasurer` to automatically calculate US sales tax on every settled transaction.\n\nZero dependencies beyond the Ampersend SDK you already have.\n\n## Install\n\n```bash\nnpm install @agenttax/ampersend\n```\n\nOr copy `index.js` directly — it's a single file with no dependencies.\n\n## Quick Start\n\n```javascript\nimport { createAmpersendTreasurer } from \"ampersend-sdk\";\nimport { withTaxCompliance } from \"@agenttax/ampersend\";\n\n// Your existing Ampersend setup\nconst treasurer = createAmpersendTreasurer({\n  wallet: myWallet,\n  apiKey: process.env.AMPERSEND_SESSION_KEY,\n});\n\n// Wrap it with tax compliance — one line\nconst taxTreasurer = withTaxCompliance(treasurer, {\n  apiKey: \"atx_live_...\",          // Free at agenttax.io — 100 calls/mo\n  defaultBuyerState: \"TX\",         // Buyer's US state\n  transactionType: \"compute\",      // compute, saas, api_access, consulting, etc.\n});\n\n// Use taxTreasurer exactly like your original treasurer.\n// Tax is calculated automatically on every accepted payment.\n```\n\n## What It Does\n\nEvery time an x402 payment settles through your Ampersend Treasurer:\n\n1. The payment goes through normally (your Treasurer logic is unchanged)\n2. On `status: \"accepted\"`, AgentTax calculates the applicable sales tax\n3. The tax result (amount, rate, jurisdiction, statute citation) is logged\n4. Your `onTaxCalculated` callback fires if provided\n\nTax calculation never blocks or delays payments — it runs async after settlement.\n\n## Get Tax Summary\n\n```javascript\n// After some transactions...\nconst summary = taxTreasurer.getTaxSummary();\n\nconsole.log(summary);\n// {\n//   transactions: 47,\n//   totalAmount: 125.50,\n//   totalTax: 6.28,\n//   effectiveRate: 0.05,\n//   byJurisdiction: { Texas: 4.50, California: 0, \"New York\": 1.78 }\n// }\n```\n\n## Per-Transaction Tax Details\n\n```javascript\nconst taxTreasurer = withTaxCompliance(treasurer, {\n  apiKey: \"atx_live_...\",\n  defaultBuyerState: \"TX\",\n  transactionType: \"compute\",\n  onTaxCalculated: (entry) => {\n    console.log(`Payment ${entry.authorizationId}: $${entry.amount}`);\n    console.log(`  Tax: $${entry.tax.total_tax} (${entry.tax.sales_tax?.jurisdiction})`);\n    console.log(`  Rate: ${(entry.tax.sales_tax?.rate * 100).toFixed(2)}%`);\n    console.log(`  Note: ${entry.tax.sales_tax?.note}`);\n    // → Payment abc123: $5.00\n    // →   Tax: $0.25 (Texas)\n    // →   Rate: 6.25%\n    // →   Note: TX Tax Code §151.351 — 20% statutory exemption\n  },\n});\n```\n\n## Dynamic State Resolution\n\nIf your agents transact across multiple states, provide a `resolveState` function:\n\n```javascript\nconst taxTreasurer = withTaxCompliance(treasurer, {\n  apiKey: \"atx_live_...\",\n  defaultBuyerState: \"CA\",           // Fallback\n  transactionType: \"saas\",\n  resolveState: (context, authorization) => {\n    // Determine state from payment context metadata\n    return context?.metadata?.buyerState || \"CA\";\n  },\n});\n```\n\n## Standalone Calculator\n\nDon't use Ampersend's Treasurer pattern? Use the standalone calculator:\n\n```javascript\nimport { createTaxCalculator } from \"@agenttax/ampersend\";\n\nconst tax = createTaxCalculator({\n  apiKey: \"atx_live_...\",\n  defaultBuyerState: \"NY\",\n  transactionType: \"api_access\",\n});\n\n// Calculate tax for any transaction\nconst result = await tax.calculate({ amount: 100.00 });\nconsole.log(result.total_tax);  // 4.00 (NY 4% state rate)\n\n// Batch calculation\nfor (const payment of ampersendPaymentHistory) {\n  await tax.calculate({\n    amount: payment.amountUsd,\n    buyerState: payment.buyerState,\n    counterpartyId: payment.sellerId,\n  });\n}\n\nconsole.log(tax.getTaxSummary());\n```\n\n## How Tax Works for x402 Payments\n\nWhen your agent pays for compute/API/storage via x402:\n\n- **45 states + DC** levy sales tax on digital services\n- Each state classifies AI agent transactions differently (\"data processing\" in TX, \"prewritten software\" in NY, \"digital automated service\" in WA)\n- Texas applies an 80% taxable rule (§151.351) — $1.00 payment = $0.05 tax, not $0.0625\n- Connecticut has a separate 1% rate for data processing vs 6.35% for info services\n- Iowa exempts B2B digital transactions entirely\n- The rate depends on **what** the agent does, **where** the buyer is, and **who** is buying\n\nAgentTax resolves all of this per-transaction. Every response includes the jurisdiction, statute citation, and confidence score.\n\n## API Key\n\nGet a free API key at [agenttax.io](https://agenttax.io) — 100 calls/month, no credit card.\n\nPaid plans: Starter $25/mo (10K calls), Growth $99/mo (100K), Pro $199/mo (1M).\n\nTry it without signing up: [agenttax.io/playground](https://agenttax.io/playground)\n\n## Links\n\n- [AgentTax](https://agenttax.io) — The tax engine for AI agent commerce\n- [AgentTax API Docs](https://agenttax.io/api-docs)\n- [Python SDK](https://pypi.org/project/agenttax/) — `pip install agenttax`\n- [Ampersend](https://ampersend.ai) — The control layer for the agent economy\n- [Ampersend SDK](https://github.com/edgeandnode/ampersend-sdk)\n- [x402 Protocol](https://x402.org)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}