agent402-tollbooth 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +4 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -763,7 +763,10 @@ export async function buildCliX402Middleware(env = process.env) {
763
763
 
764
764
  async function startCli() {
765
765
  const upstream = process.env.TOLLBOOTH_UPSTREAM;
766
- const port = Number(process.env.PORT) || 4021;
766
+ // PORT=0 asks the OS for a free port (the banner prints the bound one); only
767
+ // an unset or unreadable PORT falls back to 4021.
768
+ const rawPort = String(process.env.PORT ?? "").trim();
769
+ const port = rawPort !== "" && Number.isInteger(Number(rawPort)) && Number(rawPort) >= 0 ? Number(rawPort) : 4021;
767
770
  const _secret = process.env.TOLLBOOTH_SECRET;
768
771
  if (!_secret) {
769
772
  console.warn("⚠ TOLLBOOTH_SECRET not set — proof-of-work tokens use a random per-process secret: they won't survive a restart and will be rejected across multiple workers/instances. Set a stable TOLLBOOTH_SECRET in production.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent402-tollbooth",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "Agent402 tollbooth: open-source, self-hostable pay-per-crawl for x402 AND MPP (the sell side of Agentic Finance): charge AI bots per request (USDC via x402, or MPP - the Machine Payments Protocol - through the same settlement, or USDG on Robinhood Chain, or free proof-of-work) while humans browse free. Drop-in Express middleware or reverse proxy that settles both wires from env alone - no Cloudflare, no Stripe, no signup.",
5
5
  "type": "module",
6
6
  "main": "index.js",