{"_id":"@aivorynet/monitor-agent-deno","_rev":"3-9757c7435744ad1f0771980afb2d4e8d","name":"@aivorynet/monitor-agent-deno","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.1":{"name":"@aivorynet/monitor-agent-deno","version":"0.0.1","_id":"@aivorynet/monitor-agent-deno@0.0.1","maintainers":[{"name":"jenni_aivory","email":"jenni@aivory.net"},{"name":"madppiper","email":"paul@aivory.net"}],"dist":{"shasum":"8608524de7a19f872439c982a6272d900ac21b0a","tarball":"https://registry.npmjs.org/@aivorynet/monitor-agent-deno/-/monitor-agent-deno-0.0.1.tgz","fileCount":1,"integrity":"sha512-8GOZlVg2BxksDx6sA1KGNyKbaejTw2kJXGLOALRJZD3efCAInCPH7/lQaZk9dszyPFrRPD08e5xy76gr+QkROg==","signatures":[{"sig":"MEQCIFcmXy9KQxLPo8KtXqVSuYX44LXON9a+RYMGYF9r98cNAiBsLdpaVocLNtwEDvmozkYufYRD8xPM88edL/iTUCHsNQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":102},"_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-deno_0.0.1_1771342391395_0.9548117655672208","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@aivorynet/monitor-agent-deno","version":"0.1.0","keywords":["aivory","monitor","debugging","deno"],"author":{"name":"AIVory"},"license":"MIT","_id":"@aivorynet/monitor-agent-deno@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-deno/issues"},"dist":{"shasum":"225498c07d38566d3c12bf88275cbc27cdb9cdea","tarball":"https://registry.npmjs.org/@aivorynet/monitor-agent-deno/-/monitor-agent-deno-0.1.0.tgz","fileCount":15,"integrity":"sha512-W1ccx9q/DmKA1Wu7htaFnTpWTze47kqLVGWzoSUVjThvg/wS/xObwMfLu//xjTcH6RatLghMNnoX6wXjMM/xqw==","signatures":[{"sig":"MEQCIFCu/azEil3xEFgEWXIr58TjC5a5TKyq87nJkZ8+aT51AiB3v/+WLLGBhiy2YKuHAvvX/yFqxGMd+G4cQF5OkGLc2Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aivorynet%2fmonitor-agent-deno@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":38099},"main":"src/mod.ts","type":"module","types":"src/mod.ts","gitHead":"b09118d657e4b878bb5ecb2a02e895adbb3fb17f","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:70c6ba9f-75ec-44f7-9d57-7d77866c25ea"}},"repository":{"url":"git+https://github.com/aivorynet/agent-deno.git","type":"git"},"_npmVersion":"11.10.0","description":"AIVory Monitor agent for Deno runtime","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/monitor-agent-deno_0.1.0_1771418647234_0.4730811984590988","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aivorynet/monitor-agent-deno","version":"0.1.1","description":"AIVory Monitor agent for Deno runtime","type":"module","main":"src/mod.ts","types":"src/mod.ts","keywords":["aivory","monitor","debugging","deno"],"author":{"name":"AIVory"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aivorynet/agent-deno.git"},"homepage":"https://aivory.net/monitor/","bugs":{"url":"https://github.com/aivorynet/agent-deno/issues"},"gitHead":"6ed81757c3caaf9d9f7c0a828d18c1970e92ce97","_id":"@aivorynet/monitor-agent-deno@0.1.1","_nodeVersion":"22.22.0","_npmVersion":"11.11.0","dist":{"integrity":"sha512-qucG+FZexsJqaM7dWEW6mNm2tc3CuTxXNKQ+j2zlW4LN5+LeNRhA00SmVazq5TVC/Q5nCKnY7TG4LcwiSJUrPA==","shasum":"9d6ca57a7d83148868b4c1b8853d676e70a56874","tarball":"https://registry.npmjs.org/@aivorynet/monitor-agent-deno/-/monitor-agent-deno-0.1.1.tgz","fileCount":15,"unpackedSize":38211,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aivorynet%2fmonitor-agent-deno@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFVEu1xeSA7E/nRk7n9b2pRe+xWB/xl6CvfZbrMeibqEAiEA9d7S7VIhdKiW2yh8crLq3WCnbjnFEX1jQ0BWjIy+C/8="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:70c6ba9f-75ec-44f7-9d57-7d77866c25ea"}},"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-deno_0.1.1_1772199402346_0.7176950891712597"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-17T15:33:11.296Z","modified":"2026-02-27T13:36:42.825Z","0.0.1":"2026-02-17T15:33:11.530Z","0.1.0":"2026-02-18T12:44:07.366Z","0.1.1":"2026-02-27T13:36:42.497Z"},"bugs":{"url":"https://github.com/aivorynet/agent-deno/issues"},"author":{"name":"AIVory"},"license":"MIT","homepage":"https://aivory.net/monitor/","keywords":["aivory","monitor","debugging","deno"],"repository":{"type":"git","url":"git+https://github.com/aivorynet/agent-deno.git"},"description":"AIVory Monitor agent for Deno runtime","maintainers":[{"name":"jenni_aivory","email":"jenni@aivory.net"},{"name":"madppiper","email":"paul@aivory.net"}],"readme":"# AIVory Monitor - Deno Agent\n\nRemote debugging with AI-powered fix generation for Deno runtime.\n\n## Requirements\n\n- Deno 1.30 or higher\n- AIVory API key (get one at [aivory.net](https://aivory.net))\n\n## Installation\n\nImport directly from URL:\n\n```typescript\nimport { init, captureException } from \"https://deno.land/x/aivory_monitor/mod.ts\";\n```\n\nOr use local import for development:\n\n```typescript\nimport { init, captureException } from \"./src/mod.ts\";\n```\n\n## Usage\n\n### Basic Initialization\n\n```typescript\nimport { init } from \"https://deno.land/x/aivory_monitor/mod.ts\";\n\ninit({\n  apiKey: 'your-api-key',\n  environment: 'production'\n});\n```\n\n### Required Permissions\n\nThe agent requires the following Deno permissions:\n\n```bash\ndeno run --allow-net --allow-env your-app.ts\n```\n\n- `--allow-net`: For WebSocket connection to AIVory backend\n- `--allow-env`: For reading configuration from environment variables\n\n### Automatic Exception Capture\n\nOnce initialized, the agent automatically captures:\n\n- Unhandled errors (`error` events)\n- Unhandled promise rejections (`unhandledrejection` events)\n\n```typescript\n// This will be automatically captured\nthrow new Error('Something went wrong');\n\n// This will also be captured\nPromise.reject(new Error('Async operation failed'));\n```\n\n### Manual Exception Capture\n\nCapture exceptions manually with additional context and local variables:\n\n```typescript\nimport { captureException } from \"https://deno.land/x/aivory_monitor/mod.ts\";\n\ntry {\n  const userId = '12345';\n  const result = riskyOperation(userId);\n} catch (error) {\n  // Capture with context and local variables\n  captureException(\n    error,\n    { userId: '12345', operation: 'riskyOperation' },\n    { userId, result }\n  );\n}\n```\n\n### User Context\n\nSet user information to be included with all captures:\n\n```typescript\nimport { setUser } from \"https://deno.land/x/aivory_monitor/mod.ts\";\n\nsetUser({\n  id: 'user-123',\n  email: 'user@example.com',\n  username: 'johndoe'\n});\n```\n\n### Custom Context\n\nAdd custom context that will be sent with all captures:\n\n```typescript\nimport { setContext } from \"https://deno.land/x/aivory_monitor/mod.ts\";\n\nsetContext({\n  version: '1.2.3',\n  environment: 'production',\n  server: 'us-east-1'\n});\n```\n\n## Configuration\n\nConfiguration can be provided via environment variables or initialization options:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `AIVORY_API_KEY` | AIVory API key (required) | None |\n| `AIVORY_BACKEND_URL` | Backend WebSocket URL | `wss://api.aivory.net/ws/agent` |\n| `AIVORY_ENVIRONMENT` | Environment name | `production` |\n| `AIVORY_SAMPLING_RATE` | Exception sampling rate (0.0-1.0) | `1.0` |\n| `AIVORY_MAX_DEPTH` | Maximum variable capture depth | `10` |\n| `AIVORY_MAX_STRING_LENGTH` | Maximum string length | `1000` |\n| `AIVORY_MAX_COLLECTION_SIZE` | Maximum array/object size | `100` |\n| `AIVORY_DEBUG` | Enable debug logging | `false` |\n\n### Example with Environment Variables\n\n```bash\nexport AIVORY_API_KEY=your-api-key\nexport AIVORY_ENVIRONMENT=staging\nexport AIVORY_SAMPLING_RATE=0.5\ndeno run --allow-net --allow-env your-app.ts\n```\n\n### Example with Options\n\n```typescript\ninit({\n  apiKey: 'your-api-key',\n  backendUrl: 'wss://api.aivory.net/ws/agent',\n  environment: 'staging',\n  samplingRate: 0.5,\n  maxCaptureDepth: 5,\n  debug: true\n});\n```\n\n## Permissions\n\nThe agent requires minimal permissions to function:\n\n- **--allow-net**: Required for WebSocket connection to the AIVory backend. The agent connects to `wss://api.aivory.net` by default.\n- **--allow-env**: Required to read configuration from environment variables (`AIVORY_API_KEY`, etc.).\n\nNo file system access, subprocess execution, or other elevated permissions are needed.\n\n## How It Works\n\n1. **Exception Handlers**: The agent registers global event listeners for `error` and `unhandledrejection` events using Deno's standard `addEventListener` API.\n\n2. **Variable Capture**: Local variables are captured using Deno's built-in `Deno.inspect()` for safe serialization. Circular references and large objects are handled automatically.\n\n3. **Stack Trace Parsing**: Error stack traces are parsed to extract file paths, line numbers, and function names for each frame.\n\n4. **Fingerprinting**: Exceptions are fingerprinted using a hash of the error type and top stack frames, enabling automatic grouping of similar errors.\n\n5. **WebSocket Transport**: Captured data is sent to the AIVory backend via native WebSocket connection with automatic reconnection handling.\n\n6. **Zero Dependencies**: The agent uses only Deno's built-in APIs - no external dependencies required.\n\n## Troubleshooting\n\n### Agent not capturing exceptions\n\n- Verify the API key is set correctly\n- Check that required permissions are granted (`--allow-net`, `--allow-env`)\n- Enable debug mode: `AIVORY_DEBUG=true` or `init({ debug: true })`\n- Check console output for initialization messages\n\n### WebSocket connection issues\n\n- Verify network connectivity to `api.aivory.net`\n- Check if a firewall or proxy is blocking WebSocket connections\n- Try accessing the backend URL directly: `https://api.aivory.net/health`\n- Enable debug mode to see connection logs\n\n### Sampling rate too low\n\nIf you're not seeing all exceptions:\n\n- Check the `AIVORY_SAMPLING_RATE` setting (default is `1.0` for 100%)\n- Set it explicitly: `init({ samplingRate: 1.0 })`\n\n### Performance impact\n\nThe agent is designed to have minimal performance impact:\n\n- Variable capture depth is limited (default: 10 levels)\n- String and collection sizes are capped\n- Sampling rate can be adjusted for high-traffic applications\n- WebSocket communication is asynchronous and non-blocking\n\n## Development\n\nRun tests:\n\n```bash\ndeno task test\n```\n\nType check:\n\n```bash\ndeno task check\n```\n\nRun test application:\n\n```bash\ndeno task run-test\n```\n\n## License\n\nPart of the AIVory Monitor project. See main repository for license details.\n","readmeFilename":"README.md"}