{"_id":"@eleven-am/hu-sdk","_rev":"6-768473829103112d0f3c06da2064f1b5","name":"@eleven-am/hu-sdk","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.1":{"name":"@eleven-am/hu-sdk","version":"0.0.1","keywords":["voice","agent","websocket","streaming","llm","assistant"],"author":{"name":"eleven-am"},"license":"MIT","_id":"@eleven-am/hu-sdk@0.0.1","maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"dist":{"shasum":"4c2924b1f0ded51141ec315a082469b026f153c1","tarball":"https://registry.npmjs.org/@eleven-am/hu-sdk/-/hu-sdk-0.0.1.tgz","fileCount":8,"integrity":"sha512-rH/xXK99QySUzP7GY+TkTWxLPx10pCC5BL9jpDaSiD+dm8lBk7yv+dMGh4rzVd0yP6D20P3U5Gab82euBn2Kjw==","signatures":[{"sig":"MEUCIDiu+Q91DP26S/YPKgxN1I//Hk6AqpwfAkfxozZYBL8SAiEAo+81XX97aSgyxCQqepwtrubq5vdtNObGM7vmn7O1hLw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":202123},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"232bd7cd5b64e82dc5fdb13dd3c61b712f040ad6","scripts":{"dev":"tsup --watch","lint":"eslint src/","test":"vitest","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"eleven-am","email":"maixperiyon@gmail.com"},"_npmVersion":"11.4.2","description":"TypeScript SDK for building voice agents on the Voice Gateway","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ws":"^8.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^9.0.0","vitest":"^3.0.0","@types/ws":"^8.18.1","typescript":"^5.7.0","@types/node":"^22.0.0"},"peerDependencies":{"ws":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hu-sdk_0.0.1_1769467051344_0.9226776593764716","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@eleven-am/hu-sdk","version":"0.0.2","keywords":["voice","agent","websocket","streaming","llm","assistant"],"author":{"name":"eleven-am"},"license":"MIT","_id":"@eleven-am/hu-sdk@0.0.2","maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"dist":{"shasum":"b8c0be664eae51370cf5be5bea2e714352073afe","tarball":"https://registry.npmjs.org/@eleven-am/hu-sdk/-/hu-sdk-0.0.2.tgz","fileCount":8,"integrity":"sha512-0WHjnR623YLghTx7zdPZUs9ppmsJpkIabJ+r3VD15mdTdsMm17WSsrcZ5t2AbJRic5LZ16gU87iUTBs4HMuH+A==","signatures":[{"sig":"MEQCIF+MbuRiDXjlYCjg0QR3iv8wZPsUAxGViunLRFrUbx5ZAiA394koOC/0Is8KDjf7D9/6eSHysIQAzTOnluGZijzUYw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":243581},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"1e31fb3e93daf2d1e1eaa7dcf94b5fcc9ce9d7ce","scripts":{"dev":"tsup --watch","lint":"eslint src/","test":"vitest","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"eleven-am","email":"maixperiyon@gmail.com"},"_npmVersion":"11.4.2","description":"TypeScript SDK for building voice agents on the Voice Gateway","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ws":"^8.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^9.0.0","vitest":"^3.0.0","@types/ws":"^8.18.1","typescript":"^5.7.0","@types/node":"^22.0.0"},"peerDependencies":{"ws":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hu-sdk_0.0.2_1769515894053_0.18579439743803117","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@eleven-am/hu-sdk","version":"0.0.3","keywords":["voice","agent","websocket","streaming","llm","assistant"],"author":{"name":"eleven-am"},"license":"MIT","_id":"@eleven-am/hu-sdk@0.0.3","maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"dist":{"shasum":"89d0c2479b267e04acfbbe2466d2e651b4368740","tarball":"https://registry.npmjs.org/@eleven-am/hu-sdk/-/hu-sdk-0.0.3.tgz","fileCount":8,"integrity":"sha512-F3lLeZbOcsG1oVpTcX/URRGEWYusHDIniX5ZGCGGOblLoWOyQB11gSJ/o1bZ4G8pVdNuWindW5rx5oyS4JFYxg==","signatures":[{"sig":"MEUCIQDHaB5yoT8RiooFAgBMbCYe+3SQxjWjcdWCqYUukkAcdAIgVEURtXUF1+Ttq2cG8RBF7EuHBtpDmGiRyWhoqlS1VYk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":254479},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"1e31fb3e93daf2d1e1eaa7dcf94b5fcc9ce9d7ce","scripts":{"dev":"tsup --watch","lint":"eslint src/","test":"vitest","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"eleven-am","email":"maixperiyon@gmail.com"},"_npmVersion":"11.4.2","description":"TypeScript SDK for building voice agents on the Voice Gateway","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ws":"^8.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^9.0.0","vitest":"^3.0.0","@types/ws":"^8.18.1","typescript":"^5.7.0","@types/node":"^22.0.0"},"peerDependencies":{"ws":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hu-sdk_0.0.3_1769517405004_0.24677583981111084","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@eleven-am/hu-sdk","version":"0.0.4","keywords":["voice","agent","websocket","streaming","llm","assistant"],"author":{"name":"eleven-am"},"license":"MIT","_id":"@eleven-am/hu-sdk@0.0.4","maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"dist":{"shasum":"7a3628b1eb064e4f0ffc964234563f455ef41e8c","tarball":"https://registry.npmjs.org/@eleven-am/hu-sdk/-/hu-sdk-0.0.4.tgz","fileCount":8,"integrity":"sha512-SJ4yr7fjLnGBaoaQPgKlBA1rc26SokgpA4017wKVLOEeW6qQ64gd0p4Vk47gbg+nexanywevi9vxbdsBDCtK5w==","signatures":[{"sig":"MEUCIQCougWpqz0qVlWq3bzEDsx4F128eZXi/UMEy7zD+0v6NAIgH6IplhFOHUtoWKz9n78mcZYXHc1DY0+L5U0BqntgSCg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":257930},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"7507363b7dc26651b1ec9d0aa78f73100cafe9c2","scripts":{"dev":"tsup --watch","lint":"eslint src/","test":"vitest","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"eleven-am","email":"maixperiyon@gmail.com"},"_npmVersion":"11.4.2","description":"TypeScript SDK for building voice agents on the Voice Gateway","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ws":"^8.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^9.0.0","vitest":"^3.0.0","@types/ws":"^8.18.1","typescript":"^5.7.0","@types/node":"^22.0.0"},"peerDependencies":{"ws":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hu-sdk_0.0.4_1769519114732_0.41074772366172363","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@eleven-am/hu-sdk","version":"0.0.5","keywords":["voice","agent","websocket","streaming","llm","assistant"],"author":{"name":"eleven-am"},"license":"MIT","_id":"@eleven-am/hu-sdk@0.0.5","maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"dist":{"shasum":"9ea438e18817149a947d58dba8626f80dac169eb","tarball":"https://registry.npmjs.org/@eleven-am/hu-sdk/-/hu-sdk-0.0.5.tgz","fileCount":8,"integrity":"sha512-SGaszhUoedWZg5+WON7D6D4EZSpd4CWA1VxRponVVxTPN+XqUpJf7wxIjiS822XaRT4K2sOmjwr5MiOKbUberw==","signatures":[{"sig":"MEUCIDecdYHQwNJbW3pieFmBKAzb9N7PpBK6LdDJB6qx1jL0AiEA01W9/fd6sgQ4EdFdF0gSoZsP/PvKT9zFyJnQtq5fvmY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":266539},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"f5da0896b0ab3e05cac0afc08ce7df9b7d88eef9","scripts":{"dev":"tsup --watch","lint":"eslint src/","test":"vitest","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"eleven-am","email":"maixperiyon@gmail.com"},"_npmVersion":"11.4.2","description":"TypeScript SDK for building voice agents on the Voice Gateway","directories":{},"_nodeVersion":"22.17.0","dependencies":{"ws":"^8.0.0","jose":"^5.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","eslint":"^9.0.0","vitest":"^3.0.0","@types/ws":"^8.18.1","typescript":"^5.7.0","@types/node":"^22.0.0"},"peerDependencies":{"ws":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hu-sdk_0.0.5_1769537840510_0.5653919582024718","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@eleven-am/hu-sdk","version":"0.0.6","description":"TypeScript SDK for building voice agents on the Voice Gateway","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest","lint":"eslint src/","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["voice","agent","websocket","streaming","llm","assistant"],"author":{"name":"eleven-am"},"license":"MIT","devDependencies":{"@types/node":"^22.0.0","@types/ws":"^8.18.1","eslint":"^9.0.0","tsup":"^8.0.0","typescript":"^5.7.0","vitest":"^3.0.0"},"dependencies":{"jose":"^5.0.0","ws":"^8.0.0"},"peerDependencies":{"ws":"^8.0.0"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"_id":"@eleven-am/hu-sdk@0.0.6","gitHead":"7bf682aa95a500c4c9218c7aa284937c4416a2ba","_nodeVersion":"22.17.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-Q+xNjz6FqIBRuKzG6wrpgdpM2pp9KlPqLySjQPmMRJ3N/Zok+IIL4U2Bk9YV+SqSGF4op2HutV+To8OAJlnd5A==","shasum":"c3fdc128fe8f30531bb95a6eee1121d3a4f8c74d","tarball":"https://registry.npmjs.org/@eleven-am/hu-sdk/-/hu-sdk-0.0.6.tgz","fileCount":8,"unpackedSize":273311,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDmI13yMEQCb55wpPTUhiXii4kRMXBz2444k55SZ8gbgAiB2BavRCFG3WaDG7y6F5nZ4dQDq41zwQxSDwvOpOsaogw=="}]},"_npmUser":{"name":"eleven-am","email":"maixperiyon@gmail.com"},"directories":{},"maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hu-sdk_0.0.6_1770154674687_0.05215497533767954"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-26T22:37:31.236Z","modified":"2026-02-03T21:37:54.953Z","0.0.1":"2026-01-26T22:37:31.482Z","0.0.2":"2026-01-27T12:11:34.195Z","0.0.3":"2026-01-27T12:36:45.161Z","0.0.4":"2026-01-27T13:05:14.907Z","0.0.5":"2026-01-27T18:17:20.675Z","0.0.6":"2026-02-03T21:37:54.850Z"},"author":{"name":"eleven-am"},"license":"MIT","keywords":["voice","agent","websocket","streaming","llm","assistant"],"description":"TypeScript SDK for building voice agents on the Voice Gateway","maintainers":[{"name":"eleven-am","email":"maixperiyon@gmail.com"}],"readme":"# HU SDK (TypeScript)\n\nTypeScript SDK for building voice agents on the Voice Gateway.\n\n## Installation\n\n```bash\nnpm install @eleven-am/hu-sdk\n```\n\n## Quick Start\n\n```typescript\nimport { VoiceAgent, ConnectionModes } from '@eleven-am/hu-sdk';\n\nconst agent = new VoiceAgent({\n  apiKey: 'sk-voice-xxx',\n  gatewayUrl: 'wss://gateway.example.com',\n  mode: ConnectionModes.WebSocket,\n});\n\nagent\n  .onUtterance(async (ctx) => {\n    console.log(`User said: ${ctx.text}`);\n\n    // Stream response\n    ctx.sendDelta('Hello ');\n    ctx.sendDelta('World!');\n    ctx.done();\n  })\n  .onInterrupt((sessionId, reason) => {\n    console.log(`Interrupted: ${reason}`);\n  })\n  .onError((error) => {\n    console.error('Error:', error);\n  });\n\nawait agent.connect();\n```\n\n## Streaming with LLM\n\n```typescript\nimport { VoiceAgent } from '@eleven-am/hu-sdk';\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI();\n\nconst agent = new VoiceAgent({\n  apiKey: process.env.VOICE_API_KEY!,\n  gatewayUrl: process.env.GATEWAY_URL!,\n});\n\nagent.onUtterance(async (ctx) => {\n  const stream = await openai.chat.completions.create({\n    model: 'gpt-4',\n    messages: [{ role: 'user', content: ctx.text }],\n    stream: true,\n  });\n\n  for await (const chunk of stream) {\n    if (ctx.abortSignal.aborted) break;\n\n    const delta = chunk.choices[0]?.delta?.content;\n    if (delta) {\n      ctx.sendDelta(delta);\n    }\n  }\n\n  ctx.done();\n});\n\nawait agent.connect();\n```\n\n## Using Vision (Video Frames)\n\nAgents with `vision` scope can request video frames from the user's session:\n\n```typescript\nagent.onUtterance(async (ctx) => {\n  // Check if vision context is available\n  if (ctx.vision?.available) {\n    console.log('Auto-analyzed:', ctx.vision.description);\n  }\n\n  // Request raw frames for custom analysis\n  const frames = await ctx.requestFrames({\n    limit: 5,\n    rawBase64: true,\n  });\n\n  if (frames.frames) {\n    for (const frame of frames.frames) {\n      // frame.base64 contains the image data\n      // frame.timestamp is when it was captured\n    }\n  }\n\n  // Or get pre-analyzed descriptions\n  const analyzed = await ctx.requestFrames({ limit: 3 });\n  if (analyzed.descriptions) {\n    console.log('Frame descriptions:', analyzed.descriptions);\n  }\n\n  ctx.done('I can see what you\\'re showing me!');\n});\n```\n\n## Using Memory\n\nAgents with `memory` scope can query the user's stored facts:\n\n```typescript\nagent.onUtterance(async (ctx) => {\n  // Query relevant memories\n  const memories = await ctx.queryMemory({\n    query: ctx.text,\n    topK: 5,\n    threshold: 0.7,\n    types: ['preference', 'fact'],\n  });\n\n  if (memories.facts && memories.facts.length > 0) {\n    const context = memories.facts\n      .map(f => f.content)\n      .join('\\n');\n\n    // Use memories as context for LLM\n    const response = await generateWithContext(ctx.text, context);\n    ctx.done(response);\n  } else {\n    ctx.done('I don\\'t have any relevant memories about that.');\n  }\n});\n```\n\n## Routing Filters\n\nAgents can register filters to control which utterances are routed to them. Filters are evaluated server-side for efficient routing in multi-agent setups:\n\n```typescript\nawait agent.connect();\n\n// Register filters after connecting\nagent.registerFilters({\n  // Match utterances containing these entity types or values\n  entities: ['PERSON', 'John'],\n  // Match utterances about these topics\n  topics: ['weather', 'travel'],\n  // Match utterances containing these keywords\n  keywords: ['urgent', 'help'],\n  // Match specific speakers\n  speakers: ['user'],\n  // Number of previous utterances to include for context (used with \"filtered\" tier)\n  includeContext: 5,\n  // Data access tier - controls what data the agent receives:\n  // - \"full\": everything (whole conversation stream)\n  // - \"filtered\": matching messages + context window (default)\n  // - \"summary\": just {entities, topics} - no text\n  tier: 'filtered',\n});\n```\n\nFilters can be updated at any time while connected. The gateway will apply the new filters to subsequent utterances.\n\n## Handling Interrupts\n\nWhen the user starts speaking, the gateway sends an interrupt. Use the abort signal to stop processing:\n\n```typescript\nagent.onUtterance(async (ctx) => {\n  for await (const chunk of streamResponse(ctx.text)) {\n    // Check before each operation\n    if (ctx.abortSignal.aborted) {\n      console.log('User interrupted, stopping');\n      return;\n    }\n    ctx.sendDelta(chunk);\n  }\n  ctx.done();\n});\n\nagent.onInterrupt((sessionId, reason) => {\n  // reason: \"new_user_speech\" | \"lost_arbitration\" | \"supersede\"\n  console.log(`Session ${sessionId} interrupted: ${reason}`);\n});\n```\n\n## Configuration\n\n```typescript\ninterface VoiceAgentConfig {\n  apiKey: string;              // Your API key (sk-voice-xxx)\n  gatewayUrl: string;          // Gateway WebSocket/HTTP URL\n  mode?: ConnectionMode;       // 'websocket' (default) or 'sse'\n  reconnect?: boolean;         // Auto-reconnect on disconnect (default: true)\n  reconnectInterval?: number;  // Base reconnect delay in ms (default: 1000)\n  maxReconnectAttempts?: number; // Max reconnect attempts (default: unlimited)\n  logger?: Logger;             // Custom logger (default: console)\n}\n```\n\n## Context API\n\nThe `UtteranceContext` provides:\n\n| Property | Type | Description |\n|----------|------|-------------|\n| `text` | `string` | The user's utterance text |\n| `isFinal` | `boolean` | Whether this is a final transcript |\n| `user` | `UserInfo \\| undefined` | User info (if `profile`/`email`/`location` scope) |\n| `vision` | `VisionContext \\| undefined` | Vision context (if `vision` scope) |\n| `entities` | `EntityInfo[]` | Entities extracted from the utterance (NER) |\n| `topics` | `string[]` | Topics detected in the utterance |\n| `context` | `ContextUtterance[]` | Previous utterances (if `includeContext` filter set) |\n| `sessionId` | `string` | Current session ID |\n| `requestId` | `string` | Current request ID |\n| `userId` | `string \\| undefined` | User ID |\n| `timestamp` | `Date` | When the utterance was received |\n| `abortSignal` | `AbortSignal` | Signals when interrupted |\n\n| Method | Description |\n|--------|-------------|\n| `sendDelta(delta)` | Stream a text chunk to the user |\n| `done(finalText?)` | Complete the response |\n| `requestFrames(options?)` | Request video frames (async) |\n| `queryMemory(options)` | Query user memories (async) |\n\n## Connection Modes\n\n### WebSocket (recommended)\n\nFull-duplex communication, lower latency:\n\n```typescript\nconst agent = new VoiceAgent({\n  mode: ConnectionModes.WebSocket,\n  // ...\n});\n```\n\n### Server-Sent Events (SSE)\n\nOne-way server push with HTTP POST for sending. Works in browser environments:\n\n```typescript\nconst agent = new VoiceAgent({\n  mode: ConnectionModes.SSE,\n  // ...\n});\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}