{"_id":"@dexel-confana/confana-dev","name":"@dexel-confana/confana-dev","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dexel-confana/confana-dev","version":"1.0.0","description":"Official Node.js SDK for the Confana AI platform — voice agents, TTS, ASR, LLM, and phone calls.","publishConfig":{"access":"public"},"type":"module","main":"./src/index.js","exports":{".":"./src/index.js"},"scripts":{"test":"node test.js"},"keywords":["confana","voice","agent","tts","asr","speech","llm","ai","voice-cloning","realtime","websocket","transcription","sdk"],"author":{"name":"Confana AI"},"license":"MIT","dependencies":{"ws":"^8.18.0"},"engines":{"node":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/confana-ai/confana-nodejs-library.git"},"homepage":"https://confana.ai","bugs":{"url":"https://github.com/confana-ai/confana-nodejs-library/issues"},"_id":"@dexel-confana/confana-dev@1.0.0","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-9iAz46JPFhHNlA7wK0e04/KsN0iJLP1bjLGRIZ5Kfq8q0uAyQt8At0YRPPKH0n0Ylc90iNoHMJxcHRqNXcXtnA==","shasum":"bf9f6b6e9a937f847aebadda4a78392572a8519d","tarball":"https://registry.npmjs.org/@dexel-confana/confana-dev/-/confana-dev-1.0.0.tgz","fileCount":11,"unpackedSize":43183,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG4CRxqrt1OOqmWTUvMQEvd7dQBEg1ACkcnziCWRjJeLAiEAw7FEOEQaN6XHBxbm+T2pn8FYGKgkizMf0VwX/dWiE6Y="}]},"_npmUser":{"name":"dexel-confana","email":"princeniiyarteyannan@gmail.com"},"directories":{},"maintainers":[{"name":"dexel-confana","email":"princeniiyarteyannan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/confana-dev_1.0.0_1782505449418_0.11628588976259913"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-26T20:24:09.211Z","1.0.0":"2026-06-26T20:24:09.580Z","modified":"2026-06-26T20:24:09.802Z"},"maintainers":[{"name":"dexel-confana","email":"princeniiyarteyannan@gmail.com"}],"description":"Official Node.js SDK for the Confana AI platform — voice agents, TTS, ASR, LLM, and phone calls.","homepage":"https://confana.ai","keywords":["confana","voice","agent","tts","asr","speech","llm","ai","voice-cloning","realtime","websocket","transcription","sdk"],"repository":{"type":"git","url":"git+https://github.com/confana-ai/confana-nodejs-library.git"},"author":{"name":"Confana AI"},"bugs":{"url":"https://github.com/confana-ai/confana-nodejs-library/issues"},"license":"MIT","readme":"# confana-dev\n\n[![npm version](https://img.shields.io/npm/v/confana-dev.svg)](https://www.npmjs.com/package/confana-dev)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Node.js ≥18](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)\n\nThe official Node.js SDK for the [Confana AI platform](https://confana.ai).  \nBuild AI-powered voice agents, transcribe audio, synthesise speech, stream real-time conversations, and trigger phone calls — in minutes.\n\n---\n\n## Installation\n\n```bash\nnpm install confana-dev\n```\n\n---\n\n## Quick Start\n\n```js\nimport { ConfanaClient } from \"confana-dev\";\n\nconst client = new ConfanaClient({\n  api_key:    \"YOUR_API_KEY\",           // from Dashboard → Settings\n  base_url:   \"https://api.confana.ai\", // your Confana backend (or self-hosted)\n  engine_url: \"https://engine.confana.ai\",\n});\n```\n\n---\n\n## Text-to-Speech (TTS)\n\n```js\n// Synthesise text → WAV Buffer\nconst audio = await client.tts.speak(\"Hello! How can I help you today?\");\nimport fs from \"fs/promises\";\nawait fs.writeFile(\"hello.wav\", audio);\n\n// Different language\nconst audioFr = await client.tts.speak(\"Bonjour, comment puis-je vous aider?\", { language: \"fr\" });\n\n// Built-in speaker voice\nconst audioBob = await client.tts.speak(\"Good morning!\", { speaker: \"Bob\" });\n\n// One-liner to file\nawait client.tts.speakToFile(\"Goodbye!\", \"bye.wav\");\n\n// Fine-tune quality\nconst hq = await client.tts.speak(\"This sounds amazing!\", {\n  num_step: 32,       // Diffusion steps 4–50 (higher = better quality)\n  temperature: 0.9,   // Expressiveness 0.0–1.5\n});\n\n// Zero-shot voice cloning\nimport fs from \"fs/promises\";\nconst refAudio = await fs.readFile(\"my_voice.wav\");\nconst cloned = await client.tts.speak(\"Hello in my voice!\", {\n  voice_clone_audio:    refAudio,\n  voice_clone_ref_text: \"Hello in my voice!\",\n});\n```\n\n### Real-time TTS streaming (WebSocket)\n\n```js\nimport Speaker from \"speaker\";\nconst spk = new Speaker({ channels: 1, bitDepth: 16, sampleRate: 24000 });\n\nfor await (const chunk_b64 of client.tts.stream(\"Tell me a long story...\", { num_step: 32 })) {\n  spk.write(Buffer.from(chunk_b64, \"base64\"));\n}\nspk.end();\n```\n\n### TTS Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `language` | `string` | `\"en\"` | BCP-47 language code |\n| `speaker` | `string\\|number` | `null` | Built-in speaker: `\"Bob\"`, `\"Tasha\"`, `\"Kofi\"`, `\"Adwoa\"`, or index 0–3 |\n| `num_step` | `number` | `32` | Diffusion steps (4–50). Higher = better quality, slower. |\n| `temperature` | `number` | `0.8` | Expressiveness (0.0–1.5). Higher = more varied. |\n| `voice_clone_audio` | `Buffer` | `null` | Raw audio bytes for voice cloning |\n| `voice_clone_url` | `string` | `null` | URL of a reference audio file |\n| `voice_clone_ref_text` | `string` | `null` | Transcript of the reference recording |\n\n---\n\n## Automatic Speech Recognition (ASR)\n\n```js\n// Transcribe a file\nconst text = await client.asr.transcribe(\"interview.wav\");\nconsole.log(text);\n\n// Auto-detect language\nconst text2 = await client.asr.transcribe(\"audio.mp3\", { language: \"auto\" });\n\n// Transcribe raw bytes\nconst bytes = await fs.readFile(\"speech.wav\");\nconst text3 = await client.asr.transcribeBytes(bytes, { beam_size: 5 });\n```\n\n### Real-time microphone streaming\n\n> Requires [SoX](https://sourceforge.net/projects/sox/) installed on the system.\n\n```js\nfor await (const utterance of client.asr.streamMicrophone({ language: \"en\" })) {\n  console.log(\"You said:\", utterance);\n  if (utterance.toLowerCase().includes(\"stop\")) break;\n}\n```\n\n### ASR Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `language` | `string` | `\"auto\"` | BCP-47 code or `\"auto\"` for language detection |\n| `beam_size` | `number` | `5` | Beam search width (1–10). Higher = more accurate, slower. |\n| `temperature` | `number` | `0.0` | Decoding temperature (0.0 = greedy / deterministic) |\n\n---\n\n## LLM Chat\n\n```js\n// Single-turn Q&A\nconst reply = await client.llm.chat(\"What is a workflow node?\");\n\n// Multi-turn conversation (history updated automatically)\nconst history = [];\nawait client.llm.chat(\"Hi! My name is Alice.\", { history });\nconst name = await client.llm.chat(\"What is my name?\", { history });\n// → \"Your name is Alice.\"\n\n// Streaming\nfor await (const token of client.llm.stream(\"Write a haiku about JavaScript.\")) {\n  process.stdout.write(token);\n}\n```\n\n---\n\n## Agent Sessions\n\n```js\n// Load a published agent by ID\nconst session = await client.agent.session(\"YOUR_AGENT_ID\");\n\n// Text chat\nconst reply = await session.chat(\"Book a table for two on Friday.\");\nconsole.log(reply);\n\n// Streaming reply\nfor await (const token of session.stream(\"What are your hours?\")) {\n  process.stdout.write(token);\n}\n\n// Conversation history\nconst hist = await session.history();\n\n// Reset memory (keeps session alive)\nawait session.reset();\n\n// Debug engine state (current graph node, mode, etc.)\nconsole.log(await session.state());\n\n// End and clean up\nawait session.end();\n```\n\n### Voice WebSocket\n\n```js\nconst ws = session.voice_ws();\nawait ws.connect();\n\n// Send PCM audio in real time\nws.send_audio(pcmBuffer);        // 16-bit 16 kHz mono PCM\nws.signal_end_of_speech();\n\n// Receive events\nfor await (const event of ws.events()) {\n  if (event.type === \"audio_chunk\") { /* TTS audio */ }\n  if (event.type === \"transcript\")  { /* STT text  */ }\n}\n\nws.disconnect();\n```\n\n---\n\n## Phone Calls\n\n```js\n// Outbound call\nconst call = await client.phone.call(\"AGENT_ID\", \"+12025550178\");\nconsole.log(\"Call SID:\", call.call_sid);\n\n// Check status\nconst status = await client.phone.callStatus(call.call_sid);\n\n// Hang up\nawait client.phone.hangup(call.call_sid);\n\n// Inbound webhook URL (configure in Twilio console)\nconst url = client.phone.inboundWebhookUrl(\"AGENT_ID\");\n```\n\n---\n\n## Error Handling\n\n```js\nimport { ConfanaError, TTSError, ASRError, SessionError } from \"confana-dev\";\n\ntry {\n  const audio = await client.tts.speak(\"Hello!\");\n} catch (err) {\n  if (err instanceof TTSError)     console.error(\"TTS failed:\", err.message);\n  if (err instanceof ASRError)     console.error(\"ASR failed:\", err.message);\n  if (err instanceof SessionError) console.error(\"Session error:\", err.message);\n  else throw err;\n}\n```\n\n---\n\n## Supported Languages\n\n| Code | Language   | Code | Language   |\n|------|------------|------|------------|\n| `en` | English    | `zh` | Chinese    |\n| `fr` | French     | `ja` | Japanese   |\n| `es` | Spanish    | `ko` | Korean     |\n| `de` | German     | `ar` | Arabic     |\n| `pt` | Portuguese | `hi` | Hindi      |\n| `it` | Italian    | `ru` | Russian    |\n| `ak` | Akan (Twi) |      |            |\n\n---\n\n## License\n\nMIT © Confana AI\n","readmeFilename":"README.md","_rev":"1-571dcd3b2728c8dca30cbc16a9bf7048"}