{"_id":"@aigentic/router","_rev":"3-ef0636dc9373639356a90f7dcb82e76c","name":"@aigentic/router","dist-tags":{"latest":"0.1.31"},"versions":{"0.1.30":{"name":"@aigentic/router","version":"0.1.30","keywords":["semantic-router","intent-matching","ai-routing","agent-routing","vector-search","hnsw","similarity-search","embeddings","llm","native","napi","rust","simd","fast","performance","ruv","ruvector"],"author":{"url":"https://ruv.io","name":"ruv.io Team","email":"info@ruv.io"},"license":"MIT","_id":"@aigentic/router@0.1.30","maintainers":[{"name":"aigentic","email":"engineering@aigentic.net"}],"homepage":"https://ruv.io","bugs":{"url":"https://github.com/ruvnet/ruvector/issues"},"dist":{"shasum":"a79e8aa032fed01dbc3f410db545352c26257469","tarball":"https://registry.npmjs.org/@aigentic/router/-/router-0.1.30.tgz","fileCount":4,"integrity":"sha512-eRggcnd7Mp3I/iqYVVwd8UhyzGdiTpX9Kz29Ooa22gNCF6Z0x0lCKavupr31cGoiirDcVdgDNFXUDlbASWI+gA==","signatures":[{"sig":"MEUCIQC9IzJOkURhbMCZkqfggE56JQm1PzZIVroDhThAdqN+wQIgS3nltMg0h+4CQRw0lrIa3kPIWyOd1MIQv0a8Iy8jhDo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26308},"main":"index.js","types":"index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"06426cbc6e70f09762e996a98517b0b1fd1c7c4e","scripts":{"test":"node test.js","build:napi":"napi build --platform --release --cargo-cwd ../../../crates/ruvector-router-ffi","publish:platforms":"node scripts/publish-platforms.js"},"_npmUser":{"name":"aigentic","email":"engineering@aigentic.net"},"repository":{"url":"git+https://github.com/ruvnet/ruvector.git","type":"git","directory":"npm/packages/router"},"_npmVersion":"11.12.0","description":"Semantic router for AI agents - vector-based intent matching with HNSW indexing and SIMD acceleration","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@napi-rs/cli":"^2.18.0"},"optionalDependencies":{"@aigentic/router-darwin-x64":"0.1.30","@aigentic/router-darwin-arm64":"0.1.30","@aigentic/router-linux-x64-gnu":"0.1.30","@aigentic/router-win32-x64-msvc":"0.1.30","@aigentic/router-linux-arm64-gnu":"0.1.30"},"_npmOperationalInternal":{"tmp":"tmp/router_0.1.30_1779091166374_0.46806039815703393","host":"s3://npm-registry-packages-npm-production"}},"0.1.31":{"name":"@aigentic/router","version":"0.1.31","keywords":["semantic-router","intent-matching","ai-routing","agent-routing","vector-search","hnsw","similarity-search","embeddings","llm","native","napi","rust","simd","fast","performance","ruv","ruvector"],"author":{"url":"https://ruv.io","name":"ruv.io Team","email":"info@ruv.io"},"license":"MIT","_id":"@aigentic/router@0.1.31","maintainers":[{"name":"aigentic","email":"engineering@aigentic.net"}],"homepage":"https://ruv.io","bugs":{"url":"https://github.com/ruvnet/ruvector/issues"},"dist":{"shasum":"f0535b51399fc8616778283b6993ecc97b418e3c","tarball":"https://registry.npmjs.org/@aigentic/router/-/router-0.1.31.tgz","fileCount":4,"integrity":"sha512-Pmc6D2oFkakvhHCvrB/zUh5k6l1+cbTxFl832EhA2Q2wGDBQ9AmEKHucJ3E95iYqixCdXBycTcjb77EGc/T7tQ==","signatures":[{"sig":"MEUCIGmPkZo+BLao6fNeFIxlYC3uH2roKg7+7XH6byqPqjLEAiEAuoHpB3p+iWE/AQIloDg+gTpsnGw1p/GBE1RjOQ6XrAg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26309},"main":"index.js","types":"index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"06426cbc6e70f09762e996a98517b0b1fd1c7c4e","scripts":{"test":"node test.js","build:napi":"napi build --platform --release --cargo-cwd ../../../crates/ruvector-router-ffi","publish:platforms":"node scripts/publish-platforms.js"},"_npmUser":{"name":"aigentic","email":"engineering@aigentic.net"},"repository":{"url":"git+https://github.com/ruvnet/ruvector.git","type":"git","directory":"npm/packages/router"},"_npmVersion":"11.12.0","description":"Semantic router for AI agents - vector-based intent matching with HNSW indexing and SIMD acceleration","directories":{},"_nodeVersion":"22.22.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@napi-rs/cli":"^2.18.0"},"optionalDependencies":{"@aigentic/router-darwin-x64":"0.1.30","@aigentic/router-darwin-arm64":"0.1.30","@aigentic/router-linux-x64-gnu":"^0.1.31","@aigentic/router-win32-x64-msvc":"0.1.30","@aigentic/router-linux-arm64-gnu":"0.1.30"},"_npmOperationalInternal":{"tmp":"tmp/router_0.1.31_1779092974974_0.7752774265366782","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-05-18T07:59:26.287Z","modified":"2026-09-13T15:30:32.679Z","0.1.30":"2026-05-18T07:59:26.506Z","0.1.31":"2026-05-18T08:29:35.152Z"},"bugs":{"url":"https://github.com/ruvnet/ruvector/issues"},"author":{"url":"https://ruv.io","name":"ruv.io Team","email":"info@ruv.io"},"license":"MIT","homepage":"https://ruv.io","keywords":["semantic-router","intent-matching","ai-routing","agent-routing","vector-search","hnsw","similarity-search","embeddings","llm","native","napi","rust","simd","fast","performance","ruv","ruvector"],"repository":{"url":"git+https://github.com/ruvnet/ruvector.git","type":"git","directory":"npm/packages/router"},"description":"Semantic router for AI agents - vector-based intent matching with HNSW indexing and SIMD acceleration","maintainers":[{"email":"engineering@aigentic.net","name":"aiggy"}],"readme":"# @ruvector/router\n\nSemantic router for AI agents - vector-based intent matching with HNSW indexing and SIMD acceleration.\n\n## Features\n\n- **Semantic Intent Matching**: Route queries to intents based on meaning, not keywords\n- **HNSW Indexing**: Fast approximate nearest neighbor search\n- **SIMD Optimized**: Native Rust performance with vectorized operations\n- **Quantization**: Memory-efficient storage for large intent sets\n- **Multi-Platform**: Works on Linux, macOS, and Windows\n\n## Installation\n\n```bash\nnpm install @ruvector/router\n```\n\nThe package automatically installs the correct native binary for your platform.\n\n## Quick Start\n\n```typescript\nimport { SemanticRouter } from '@ruvector/router';\n\n// Create router\nconst router = new SemanticRouter({ dimension: 384 });\n\n// Add intents with example utterances\nrouter.addIntent({\n  name: 'weather',\n  utterances: [\n    'What is the weather today?',\n    'Will it rain tomorrow?',\n    'How hot will it be?'\n  ],\n  metadata: { handler: 'weather_agent' }\n});\n\nrouter.addIntent({\n  name: 'greeting',\n  utterances: [\n    'Hello',\n    'Hi there',\n    'Good morning',\n    'Hey'\n  ],\n  metadata: { handler: 'greeting_agent' }\n});\n\nrouter.addIntent({\n  name: 'help',\n  utterances: [\n    'I need help',\n    'Can you assist me?',\n    'What can you do?'\n  ],\n  metadata: { handler: 'help_agent' }\n});\n\n// Route a query\nconst results = await router.route('What will the weather be like this weekend?');\n\nconsole.log(results[0].intent);   // 'weather'\nconsole.log(results[0].score);    // 0.92\nconsole.log(results[0].metadata); // { handler: 'weather_agent' }\n```\n\n## API Reference\n\n### `SemanticRouter`\n\nMain class for semantic routing.\n\n#### Constructor\n\n```typescript\nnew SemanticRouter(config: RouterConfig)\n```\n\n**RouterConfig:**\n| Property | Type | Default | Description |\n|----------|------|---------|-------------|\n| `dimension` | number | required | Embedding dimension size |\n| `metric` | string | 'cosine' | Distance metric: 'cosine', 'euclidean', 'dot' |\n| `m` | number | 16 | HNSW M parameter |\n| `efConstruction` | number | 200 | HNSW ef_construction |\n| `quantization` | boolean | false | Enable memory-efficient quantization |\n\n#### Methods\n\n##### `addIntent(intent: Intent): void`\n\nAdd an intent to the router.\n\n```typescript\nrouter.addIntent({\n  name: 'booking',\n  utterances: ['Book a flight', 'Reserve a hotel'],\n  metadata: { department: 'travel' }\n});\n```\n\n##### `route(query: string | Float32Array, k?: number): Promise<RouteResult[]>`\n\nRoute a query to matching intents.\n\n```typescript\nconst results = await router.route('I want to book a vacation');\n// [{ intent: 'booking', score: 0.89, metadata: {...} }]\n```\n\n##### `routeWithEmbedding(embedding: Float32Array, k?: number): RouteResult[]`\n\nRoute with a pre-computed embedding (synchronous).\n\n```typescript\nconst embedding = await getEmbedding('query text');\nconst results = router.routeWithEmbedding(embedding, 3);\n```\n\n##### `removeIntent(name: string): boolean`\n\nRemove an intent from the router.\n\n##### `getIntents(): string[]`\n\nGet all registered intent names.\n\n##### `clear(): void`\n\nRemove all intents.\n\n##### `save(path: string): Promise<void>`\n\nPersist router state to disk.\n\n##### `load(path: string): Promise<void>`\n\nLoad router state from disk.\n\n### Types\n\n#### `Intent`\n\n```typescript\ninterface Intent {\n  name: string;                        // Unique intent identifier\n  utterances: string[];                // Example utterances\n  embedding?: Float32Array | number[]; // Pre-computed embedding\n  metadata?: Record<string, unknown>;  // Custom metadata\n}\n```\n\n#### `RouteResult`\n\n```typescript\ninterface RouteResult {\n  intent: string;                      // Matched intent name\n  score: number;                       // Similarity score (0-1)\n  metadata?: Record<string, unknown>;  // Intent metadata\n}\n```\n\n## Use Cases\n\n### Chatbot Intent Detection\n\n```typescript\nconst router = new SemanticRouter({ dimension: 384 });\n\n// Define intents\nconst intents = [\n  { name: 'faq', utterances: ['What are your hours?', 'How do I contact support?'] },\n  { name: 'order', utterances: ['Track my order', 'Where is my package?'] },\n  { name: 'return', utterances: ['I want to return this', 'How do I get a refund?'] }\n];\n\nintents.forEach(i => router.addIntent(i));\n\n// Handle user message\nasync function handleMessage(text: string) {\n  const [result] = await router.route(text);\n\n  switch(result.intent) {\n    case 'faq': return handleFAQ(text);\n    case 'order': return handleOrder(text);\n    case 'return': return handleReturn(text);\n    default: return handleUnknown(text);\n  }\n}\n```\n\n### Multi-Agent Orchestration\n\n```typescript\nconst agents = {\n  'code': new CodeAgent(),\n  'research': new ResearchAgent(),\n  'creative': new CreativeAgent()\n};\n\nconst router = new SemanticRouter({ dimension: 768 });\n\nrouter.addIntent({\n  name: 'code',\n  utterances: ['Write code', 'Debug this', 'Implement a function'],\n  metadata: { agent: 'code' }\n});\n\nrouter.addIntent({\n  name: 'research',\n  utterances: ['Find information', 'Search for', 'Look up'],\n  metadata: { agent: 'research' }\n});\n\n// Route task to best agent\nasync function routeTask(task: string) {\n  const [result] = await router.route(task);\n  const agent = agents[result.metadata.agent];\n  return agent.execute(task);\n}\n```\n\n## Platform Support\n\n| Platform | Architecture | Package |\n|----------|--------------|---------|\n| Linux | x64 | `@ruvector/router-linux-x64-gnu` |\n| Linux | ARM64 | `@ruvector/router-linux-arm64-gnu` |\n| macOS | x64 | `@ruvector/router-darwin-x64` |\n| macOS | ARM64 | `@ruvector/router-darwin-arm64` |\n| Windows | x64 | `@ruvector/router-win32-x64-msvc` |\n\n## Performance\n\n- **Routing**: < 1ms per query with HNSW\n- **Throughput**: 100,000+ routes/second\n- **Memory**: ~1KB per intent + embeddings\n\n## Related Packages\n\n- [`@ruvector/core`](https://www.npmjs.com/package/@ruvector/core) - Vector database\n- [`@ruvector/tiny-dancer`](https://www.npmjs.com/package/@ruvector/tiny-dancer) - Neural routing\n- [`@ruvector/gnn`](https://www.npmjs.com/package/@ruvector/gnn) - Graph Neural Networks\n\n## License\n\nMIT\n","readmeFilename":"README.md"}