{"_id":"@brijmcq/openclaw-billing-plugin","_rev":"5-645a8dabc2a2c0d9c4b1a92951cb8685","name":"@brijmcq/openclaw-billing-plugin","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.1":{"name":"@brijmcq/openclaw-billing-plugin","version":"1.0.1","keywords":["openclaw","plugin","billing","openrouter","subscription"],"author":{"name":"brijmcq"},"license":"MIT","_id":"@brijmcq/openclaw-billing-plugin@1.0.1","maintainers":[{"name":"brijmcq","email":"brijumaquio@gmail.com"}],"dist":{"shasum":"5fd4e3b94eb715961adb523b0f148b10538b442e","tarball":"https://registry.npmjs.org/@brijmcq/openclaw-billing-plugin/-/openclaw-billing-plugin-1.0.1.tgz","fileCount":6,"integrity":"sha512-rH9R7poaFYSrpk/FI8jUHQPzJ1aRmWIoCOTy9gaeJPkDDhL5CsvvF463xwGOeyZWBfNAA7S0XWlhIk+F/fpnmg==","signatures":[{"sig":"MEUCIQC9Zb6NdLPk9VR1kez774czQ2eVAP9njf3UCqw2rEhlogIgPT0L4L9WUMFEiEE3dqriNm7YKyLLT+Z+CF66cFPgqys=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11207},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsc --watch","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"brijmcq","email":"brijumaquio@gmail.com"},"openclaw":{"extensions":["./dist/index.js"]},"_npmVersion":"11.6.0","description":"Shows subscription message when OpenRouter quota is reached","directories":{},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.0","@types/node":"^20.11.0"},"peerDependencies":{"openclaw":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/openclaw-billing-plugin_1.0.1_1772717766847_0.4492598851563878","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@brijmcq/openclaw-billing-plugin","version":"1.0.2","keywords":["openclaw","plugin","billing","openrouter","subscription"],"author":{"name":"brijmcq"},"license":"MIT","_id":"@brijmcq/openclaw-billing-plugin@1.0.2","maintainers":[{"name":"brijmcq","email":"brijumaquio@gmail.com"}],"dist":{"shasum":"fd09e9cde3b78600bdbd44f04a7fb06aed8a4460","tarball":"https://registry.npmjs.org/@brijmcq/openclaw-billing-plugin/-/openclaw-billing-plugin-1.0.2.tgz","fileCount":6,"integrity":"sha512-xETh7+5oy8QLnuRS81DOMB9F5UieNKYc0zi03Crv2NWh+5hMdpXyxWT4MuMkPo4eFlD6WecfuFPodRAcPZzQiA==","signatures":[{"sig":"MEUCIQDb1aJvRYhTF+Pg1Wz5B3rw3AqVZhujt0gd/dtyAjkCKgIgDn4ySmhiBwynkh1n9SlZ4fR5kPvckX6fxlMJTzJLWKk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11207},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsc --watch","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"brijmcq","email":"brijumaquio@gmail.com"},"openclaw":{"extensions":["./dist/index.js"]},"_npmVersion":"11.6.0","description":"Shows subscription message when OpenRouter quota is reached","directories":{},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.0","@types/node":"^20.11.0"},"peerDependencies":{"openclaw":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/openclaw-billing-plugin_1.0.2_1772718306463_0.7497265493627168","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@brijmcq/openclaw-billing-plugin","version":"1.0.3","keywords":["openclaw","plugin","billing","openrouter","subscription"],"author":{"name":"brijmcq"},"license":"MIT","_id":"@brijmcq/openclaw-billing-plugin@1.0.3","maintainers":[{"name":"brijmcq","email":"brijumaquio@gmail.com"}],"dist":{"shasum":"e210c035d4ea667fe9264fcd8cd519647d108a42","tarball":"https://registry.npmjs.org/@brijmcq/openclaw-billing-plugin/-/openclaw-billing-plugin-1.0.3.tgz","fileCount":6,"integrity":"sha512-31qEvTHSzHrv2e6ehn8uzh/h4Lxhn0Q4P391a+vA2BdKMEzAI11bfWosdE0R1A3NKBV54XUxZpQIAxsUGvRy8A==","signatures":[{"sig":"MEUCIQDTyFHcJgNLQwIQLh4wxaMvl9pf94x/RBJub4JKRGihPwIgEU2UhSVMCm0h8XvXC8KoLIkmxJ5glmcCN3NhmUyYBQU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11300},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsc --watch","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"brijmcq","email":"brijumaquio@gmail.com"},"openclaw":{"extensions":["./dist/index.js"]},"_npmVersion":"11.6.0","description":"Shows subscription message when OpenRouter quota is reached","directories":{},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.0","@types/node":"^20.11.0"},"peerDependencies":{"openclaw":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/openclaw-billing-plugin_1.0.3_1772718639732_0.6862694896097508","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@brijmcq/openclaw-billing-plugin","version":"1.0.4","keywords":["openclaw","plugin","billing","openrouter","subscription"],"author":{"name":"brijmcq"},"license":"MIT","_id":"@brijmcq/openclaw-billing-plugin@1.0.4","maintainers":[{"name":"brijmcq","email":"brijumaquio@gmail.com"}],"dist":{"shasum":"46ec7fb373c64c339d1c7e6504d84fe8ec670ee4","tarball":"https://registry.npmjs.org/@brijmcq/openclaw-billing-plugin/-/openclaw-billing-plugin-1.0.4.tgz","fileCount":6,"integrity":"sha512-Z+Gu0tgXnEk610AZjmLgXEMcv50SqN8opIjaPR+jfkJynT4YvaegGhnMp31IFj5QFpfk09yIhyzOHu9IMTvrmw==","signatures":[{"sig":"MEUCIH9PVtQJJraq3iNuM1yoLxD7pKcSpi1zl6R33+wNaCcqAiEAgCmym/eJC7g1jTgVWao9VEI5Ams0v/MP3jin/QwIxTo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10523},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsc --watch","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"brijmcq","email":"brijumaquio@gmail.com"},"openclaw":{"extensions":["./dist/index.js"]},"_npmVersion":"11.6.0","description":"Shows subscription message when OpenRouter quota is reached","directories":{},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.0","@types/node":"^20.11.0"},"peerDependencies":{"openclaw":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/openclaw-billing-plugin_1.0.4_1772718809168_0.12606742730635467","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@brijmcq/openclaw-billing-plugin","version":"1.0.5","description":"Shows subscription message when OpenRouter quota is reached","main":"dist/index.js","types":"dist/index.d.ts","openclaw":{"extensions":["./dist/index.js"]},"scripts":{"build":"tsc","dev":"tsc --watch","prepublishOnly":"npm run build"},"keywords":["openclaw","plugin","billing","openrouter","subscription"],"author":{"name":"brijmcq"},"license":"MIT","devDependencies":{"@types/node":"^20.11.0","typescript":"^5.3.0"},"peerDependencies":{"openclaw":">=1.0.0"},"_id":"@brijmcq/openclaw-billing-plugin@1.0.5","_nodeVersion":"24.9.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-kohV3LtKQgUQ082JL+g6UF3O+aKrTE5anBtjhSJc6mv5/R9OO72v1yiR1WK6fVGv4YHmoGZsiHGzmMmqEWeWPw==","shasum":"312ef25c8428a0ef8f945653f8bac118d6561c2e","tarball":"https://registry.npmjs.org/@brijmcq/openclaw-billing-plugin/-/openclaw-billing-plugin-1.0.5.tgz","fileCount":6,"unpackedSize":10588,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD80rtTQ/uUJTAu/T8mPlNHbD391Y9pZgFscTWyFiRVXwIgfDdH3pQWm9fuYvueC3TTnlDVeHqe/RRGw4+6V/cKabU="}]},"_npmUser":{"name":"brijmcq","email":"brijumaquio@gmail.com"},"directories":{},"maintainers":[{"name":"brijmcq","email":"brijumaquio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/openclaw-billing-plugin_1.0.5_1772719132565_0.09559849946670718"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-05T13:36:06.698Z","modified":"2026-03-05T13:58:52.826Z","1.0.1":"2026-03-05T13:36:07.011Z","1.0.2":"2026-03-05T13:45:06.609Z","1.0.3":"2026-03-05T13:50:39.882Z","1.0.4":"2026-03-05T13:53:29.340Z","1.0.5":"2026-03-05T13:58:52.712Z"},"author":{"name":"brijmcq"},"license":"MIT","keywords":["openclaw","plugin","billing","openrouter","subscription"],"description":"Shows subscription message when OpenRouter quota is reached","maintainers":[{"name":"brijmcq","email":"brijumaquio@gmail.com"}],"readme":"# OpenClaw Billing Plugin\n\nShows a friendly subscription message when OpenRouter quota is reached.\n\n## Installation\n\n```bash\nnpm install -g @brijmcq/openclaw-billing-plugin\n```\n\n## Configuration\n\nAdd to your `openclaw.config.json`:\n\n```json\n{\n  \"plugins\": {\n    \"entries\": {\n      \"openclaw-billing-plugin\": {\n        \"enabled\": true,\n        \"config\": {\n          \"subscription_url\": \"https://billing.example.com/subscribe\"\n        }\n      }\n    }\n  }\n}\n```\n\n### Optional: Custom Message\n\nYou can provide a custom message instead of the default:\n\n```json\n{\n  \"plugins\": {\n    \"entries\": {\n      \"openclaw-billing-plugin\": {\n        \"enabled\": true,\n        \"config\": {\n          \"subscription_url\": \"https://billing.example.com/subscribe\",\n          \"custom_message\": \"Your credits are depleted! Subscribe here: https://billing.example.com/subscribe\"\n        }\n      }\n    }\n  }\n}\n```\n\n## What It Does\n\nWhen your OpenRouter API quota is reached, instead of showing a cryptic error, it shows a friendly message with a link to subscribe.\n\n**Before (without plugin):**\n```\nError: 429 Too Many Requests - Rate limit exceeded\n```\n\n**After (with plugin):**\n```\n⚠️ Monthly Credit Limit Reached\n\nYou've used your monthly OpenRouter allowance.\n\nOptions:\n• Subscribe for $99/month: https://billing.example.com/subscribe\n• Wait for next billing cycle reset\n\nQuestions? Contact support.\n```\n\n## How It Works\n\nThe plugin uses **two complementary approaches** to catch quota errors:\n\n### Approach 1: Provider Response Hook (Primary)\n- Intercepts API responses directly via `api.registerHook('provider_response')`\n- Checks HTTP status codes (402, 429)\n- Replaces error immediately at the source\n- Most direct and reliable method\n\n### Approach 2: Message Sending Hook (Fallback)\n- Intercepts outbound messages via `message_sending` hook\n- Checks message text for quota error keywords\n- Replaces error messages before delivery to user\n- Works if provider_response hook is unavailable\n\n**The plugin tries both approaches** for maximum compatibility across OpenClaw versions.\n\n**Note**: The plugin provides a seamless experience - users see a friendly subscription message instead of cryptic API errors.\n\n## Development\n\n### Build\n\n```bash\nnpm install\nnpm run build\n```\n\n### Test Locally\n\n```bash\n# Link the plugin locally\nnpm link\n\n# In your OpenClaw directory\nnpm link @brijmcq/openclaw-billing-plugin\n\n# Add configuration to openclaw.config.json\n# Restart OpenClaw gateway\n```\n\n## Publishing\n\n```bash\nnpm login\nnpm publish --access public\n```\n\n## Configuration Options\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `subscription_url` | string | Yes | URL where customers can subscribe or add credits |\n| `custom_message` | string | No | Custom message to show when quota is reached |\n\n## Error Detection\n\nThe plugin detects quota errors in outbound messages by checking for:\n\n- **Keywords**: \"rate limit\", \"quota\", \"insufficient\", \"limit exceeded\", \"too many requests\", \"usage limit\", \"429\", \"402\", \"credits\", \"billing\"\n- **Patterns**: Regular expressions matching common quota error formats\n- **OpenRouter mentions**: Confirms error is from OpenRouter (not other providers)\n\nThe detection is designed to be conservative - it only replaces messages that clearly indicate a quota/rate limit issue.\n\n## License\n\nMIT\n\n## Support\n\nFor issues or questions, please open an issue on GitHub.\n","readmeFilename":"README.md"}