{"_id":"@aivorynet/monitor-agent-bun","_rev":"3-5f21df1f2c943250bc18c9c91c183d2c","name":"@aivorynet/monitor-agent-bun","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.1":{"name":"@aivorynet/monitor-agent-bun","version":"0.0.1","_id":"@aivorynet/monitor-agent-bun@0.0.1","maintainers":[{"name":"jenni_aivory","email":"jenni@aivory.net"},{"name":"madppiper","email":"paul@aivory.net"}],"dist":{"shasum":"f119595777a1d4a079048c216771f93629eba9d2","tarball":"https://registry.npmjs.org/@aivorynet/monitor-agent-bun/-/monitor-agent-bun-0.0.1.tgz","fileCount":1,"integrity":"sha512-gmPZDXwHOO9ZUGkABB4Rs+09Y4YU06mn2KOU18hr/NqtAR9v3HAPjr9X8Jb/D9TSFDUaMSgYiuMZy/cPVS0b9Q==","signatures":[{"sig":"MEUCIA2UNcEDJ3wCvBm5N/Ginf1ac7z63Gu/kGEu4ErJhIjzAiEAha1IjRxr02b5pzhvi1vDAupxvfGuBfY3Vu1uydY2cvU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":101},"_npmUser":{"name":"jenni_aivory","email":"jenni@aivory.net"},"_npmVersion":"11.10.0","description":"Placeholder for OIDC setup","directories":{},"_nodeVersion":"22.21.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/monitor-agent-bun_0.0.1_1771342364971_0.1639053141797795","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@aivorynet/monitor-agent-bun","version":"0.1.0","keywords":["aivory","monitor","debugging","bun","error-tracking"],"author":{"name":"AIVory"},"license":"MIT","_id":"@aivorynet/monitor-agent-bun@0.1.0","maintainers":[{"name":"jenni_aivory","email":"jenni@aivory.net"},{"name":"madppiper","email":"paul@aivory.net"}],"homepage":"https://aivory.net/monitor/","bugs":{"url":"https://github.com/aivorynet/agent-bun/issues"},"dist":{"shasum":"fd7abe0d25bcbe8b1fcbda4ac9bd1e32a8b1c607","tarball":"https://registry.npmjs.org/@aivorynet/monitor-agent-bun/-/monitor-agent-bun-0.1.0.tgz","fileCount":15,"integrity":"sha512-39KPuh2/9nzI2ZbjmJNVmwgJ5DH4zKmIQjClwtdY76ZeuTR52wFq/ZHuLT2Nyni5ijdmIiIoEF5azNAk49CSkQ==","signatures":[{"sig":"MEYCIQDkeTw7/Bpy3En59365CjZkM01NOJWmqNBAYKdrftzVYgIhALLfqutG/vRfGhuvQLUIMKXiT4B66I2OXAbLzHkkrADs","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aivorynet%2fmonitor-agent-bun@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":36059},"main":"src/index.ts","type":"module","types":"src/index.ts","gitHead":"52383e52131d91ccd19d33619bb32099e059145e","scripts":{"test":"bun test","typecheck":"bun x tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c7d32500-ce29-403a-b99b-fd9ebc819649"}},"repository":{"url":"git+https://github.com/aivorynet/agent-bun.git","type":"git"},"_npmVersion":"11.10.0","description":"AIVory Monitor agent for Bun runtime","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/monitor-agent-bun_0.1.0_1771412019956_0.05688786513599764","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aivorynet/monitor-agent-bun","version":"0.1.1","description":"AIVory Monitor agent for Bun runtime","type":"module","main":"src/index.ts","types":"src/index.ts","scripts":{"test":"bun test","typecheck":"bun x tsc --noEmit"},"keywords":["aivory","monitor","debugging","bun","error-tracking"],"author":{"name":"AIVory"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aivorynet/agent-bun.git"},"homepage":"https://aivory.net/monitor/","bugs":{"url":"https://github.com/aivorynet/agent-bun/issues"},"devDependencies":{"@types/bun":"latest","typescript":"^5.0.0"},"gitHead":"9a3fe901d9f580f57011026c51726ad591ebaabf","_id":"@aivorynet/monitor-agent-bun@0.1.1","_nodeVersion":"22.22.0","_npmVersion":"11.11.0","dist":{"integrity":"sha512-0NfwoE5nmOcvvg42pjAJMIPtXa7SPuU6Q3Il+2biLp3jK2V8JCINKbWlal9z6fZxtqdxZkcVYJo5HY3ezFmJ5Q==","shasum":"3b906263e1c57abb45ae1872cb98886c4bfb8d17","tarball":"https://registry.npmjs.org/@aivorynet/monitor-agent-bun/-/monitor-agent-bun-0.1.1.tgz","fileCount":15,"unpackedSize":36171,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aivorynet%2fmonitor-agent-bun@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFKMoEXByiWoiXh/V0CBr37Ahfg7S6x8pu+S5Td0P+enAiBVwVyDBlQ/aB/3aNIYMkgnCLsqP8bmjaxEdlxL0VlfRQ=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c7d32500-ce29-403a-b99b-fd9ebc819649"}},"directories":{},"maintainers":[{"name":"jenni_aivory","email":"jenni@aivory.net"},{"name":"madppiper","email":"paul@aivory.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/monitor-agent-bun_0.1.1_1772199404370_0.798952387629499"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-17T15:32:44.846Z","modified":"2026-02-27T13:36:44.910Z","0.0.1":"2026-02-17T15:32:45.108Z","0.1.0":"2026-02-18T10:53:40.099Z","0.1.1":"2026-02-27T13:36:44.515Z"},"bugs":{"url":"https://github.com/aivorynet/agent-bun/issues"},"author":{"name":"AIVory"},"license":"MIT","homepage":"https://aivory.net/monitor/","keywords":["aivory","monitor","debugging","bun","error-tracking"],"repository":{"type":"git","url":"git+https://github.com/aivorynet/agent-bun.git"},"description":"AIVory Monitor agent for Bun runtime","maintainers":[{"name":"jenni_aivory","email":"jenni@aivory.net"},{"name":"madppiper","email":"paul@aivory.net"}],"readme":"# AIVory Monitor Bun Agent\n\nRemote debugging with AI-powered fix generation for Bun runtime applications.\n\n## Requirements\n\n- Bun 1.0 or higher\n- AIVory Monitor account with API key\n\n## Installation\n\n```bash\nbun add @aivory/monitor-agent-bun\n```\n\n## Usage\n\n### Basic Initialization\n\n```typescript\nimport { init } from '@aivory/monitor-agent-bun';\n\ninit({\n  apiKey: 'your-api-key',\n  environment: 'production'\n});\n```\n\n### Manual Exception Capture\n\nBun lacks runtime variable inspection, so you must explicitly pass local variables:\n\n```typescript\nimport { captureException } from '@aivory/monitor-agent-bun';\n\ntry {\n  const userId = '123';\n  const data = fetchUserData(userId);\n  processData(data);\n} catch (error) {\n  // Explicitly pass local variables for debugging context\n  captureException(error, { userId: '123' }, { userId, data });\n}\n```\n\n### Preload for Automatic Capture\n\nUse Bun's preload to automatically capture unhandled exceptions:\n\n```bash\nbun --preload @aivory/monitor-agent-bun app.ts\n```\n\nSet configuration via environment variables when using preload:\n\n```bash\nAIVORY_API_KEY=xxx AIVORY_ENVIRONMENT=production bun --preload @aivory/monitor-agent-bun app.ts\n```\n\n### Set User Context\n\n```typescript\nimport { setUser } from '@aivory/monitor-agent-bun';\n\nsetUser({\n  id: 'user-123',\n  email: 'user@example.com',\n  username: 'john_doe'\n});\n```\n\n## Configuration\n\nConfiguration can be provided via init options or environment variables:\n\n| Environment Variable | Default | Description |\n|---------------------|---------|-------------|\n| `AIVORY_API_KEY` | Required | Your AIVory Monitor API key |\n| `AIVORY_BACKEND_URL` | `wss://api.aivory.net/ws/agent` | Backend WebSocket URL |\n| `AIVORY_ENVIRONMENT` | `production` | Environment name (dev, staging, production) |\n| `AIVORY_SAMPLING_RATE` | `1.0` | Exception sampling rate (0.0 - 1.0) |\n| `AIVORY_MAX_DEPTH` | `10` | Maximum depth for variable capture |\n| `AIVORY_MAX_STRING_LENGTH` | `1000` | Maximum string length to capture |\n| `AIVORY_MAX_COLLECTION_SIZE` | `100` | Maximum array/object size to capture |\n| `AIVORY_DEBUG` | `false` | Enable debug logging |\n\nExample with custom configuration:\n\n```typescript\nimport { init } from '@aivory/monitor-agent-bun';\n\ninit({\n  apiKey: process.env.AIVORY_API_KEY,\n  environment: 'staging',\n  samplingRate: 0.5,  // Sample 50% of exceptions\n  maxCaptureDepth: 5,\n  debug: true\n});\n```\n\n## How It Works\n\nThe Bun agent captures exceptions and streams debugging context to the AIVory Monitor backend:\n\n1. **Process Event Hooks**: Attaches to Bun's `uncaughtException` and `unhandledRejection` events\n2. **Native WebSocket**: Uses Bun's built-in WebSocket for efficient backend communication\n3. **TypeScript Native**: No compilation step required, runs directly on Bun's TypeScript runtime\n4. **Stack Trace Capture**: Automatically captures stack traces with file paths and line numbers\n5. **Variable Context**: Captures local variables when explicitly provided via `captureException`\n\nUnlike Node.js agents, Bun cannot inspect runtime variables automatically due to runtime limitations. Always pass local variables explicitly to `captureException` for full debugging context.\n\n## Troubleshooting\n\n### Agent Not Connecting\n\nCheck that your API key is valid and the backend URL is reachable:\n\n```typescript\ninit({\n  apiKey: 'your-key',\n  debug: true  // Enable debug logging\n});\n```\n\n### Missing Local Variables\n\nBun cannot automatically capture local variables. You must pass them explicitly:\n\n```typescript\n// Bad - no variable context\ncaptureException(error);\n\n// Good - full context\ncaptureException(error, { requestId }, { userId, data, config });\n```\n\n### Exceptions Not Captured\n\nVerify the agent is initialized before exceptions occur:\n\n```typescript\nimport { init, isInitialized } from '@aivory/monitor-agent-bun';\n\ninit({ apiKey: 'xxx' });\n\nif (isInitialized()) {\n  console.log('Agent ready');\n} else {\n  console.error('Agent failed to initialize');\n}\n```\n\n### High Memory Usage\n\nReduce capture depth and collection size:\n\n```typescript\ninit({\n  maxCaptureDepth: 3,\n  maxCollectionSize: 50,\n  maxStringLength: 500\n});\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}