Compare commits

..

2 Commits

Author SHA1 Message Date
Quan HL
7723a1ecb5 support bot delay action 2023-09-22 17:24:53 +07:00
Quan HL
b1469168f8 support bot delay action 2023-09-22 17:23:31 +07:00
6 changed files with 758 additions and 2956 deletions

View File

@@ -1,4 +1,4 @@
# verb-specifications
# verb-specificiations
Jambonz Verb Specification Utilities
#### Running the test suite

View File

@@ -4,27 +4,6 @@ const _specData = require('./specs');
const specs = new Map();
for (const key in _specData) { specs.set(key, _specData[key]); }
/* verb synonyms and shortcuts: maps alias verb names to their canonical form,
optionally injecting properties (e.g. vendor) into the verb data */
const verbTransforms = new Map([
['stream', {verb: 'listen'}],
['s2s', {verb: 'llm'}],
['openai_s2s', {verb: 'llm', properties: {vendor: 'openai'}}],
['microsoft_s2s', {verb: 'llm', properties: {vendor: 'microsoft'}}],
['google_s2s', {verb: 'llm', properties: {vendor: 'google'}}],
['elevenlabs_s2s', {verb: 'llm', properties: {vendor: 'elevenlabs'}}],
['deepgram_s2s', {verb: 'llm', properties: {vendor: 'deepgram'}}],
['voiceagent_s2s', {verb: 'llm', properties: {vendor: 'voiceagent'}}],
['ultravox_s2s', {verb: 'llm', properties: {vendor: 'ultravox'}}],
]);
function applyVerbTransform(name, data) {
const transform = verbTransforms.get(name);
if (!transform) return {name, data};
const newData = transform.properties ? {...transform.properties, ...data} : data;
return {name: transform.verb, data: newData};
}
function normalizeJambones(logger, obj) {
if (!Array.isArray(obj)) {
throw new Error('malformed jambonz payload: must be array');
@@ -34,22 +13,18 @@ function normalizeJambones(logger, obj) {
if (typeof tdata !== 'object') throw new Error('malformed jambonz payload: must be array of objects');
if ('verb' in tdata) {
// {verb: 'say', text: 'foo..bar'..}
const name = tdata.verb;
const o = {};
Object.keys(tdata)
.filter((k) => k !== 'verb')
.forEach((k) => o[k] = tdata[k]);
const {name, data} = applyVerbTransform(tdata.verb, o);
const o2 = {};
o2[name] = data;
o2[name] = o;
document.push(o2);
}
else if (Object.keys(tdata).length === 1) {
// {'say': {..}}
const key = Object.keys(tdata)[0];
const {name, data} = applyVerbTransform(key, tdata[key]);
const o2 = {};
o2[name] = data;
document.push(o2);
document.push(tdata);
}
else {
logger.info(tdata, 'malformed jambonz payload: missing verb property');
@@ -83,8 +58,7 @@ function validateVerb(name, data, logger) {
const dSpec = specData.properties[dKey];
debug(`Task:validate validating property ${dKey} with value ${JSON.stringify(dVal)}`);
if (typeof dVal === 'undefined') continue;
else if (typeof dSpec === 'string' && dSpec === 'array') {
if (typeof dSpec === 'string' && dSpec === 'array') {
if (!Array.isArray(dVal)) throw new Error(`${name}: property ${dKey} is not an array`);
}
else if (typeof dSpec === 'string' && dSpec.includes('|')) {

2592
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@jambonz/verb-specifications",
"version": "0.1.1",
"version": "0.0.35",
"description": "Jambonz Verb Specification Utilities",
"main": "index.js",
"scripts": {
@@ -20,7 +20,7 @@
"devDependencies": {
"eslint": "^7.32.0",
"eslint-plugin-promise": "^4.3.1",
"tape": "^5.7.5"
"tape": "^5.6.1"
},
"dependencies": {
"debug": "^4.3.4",

View File

@@ -1,20 +1,4 @@
{
"alert" : {
"properties": {
"id": "string",
"message": "string"
},
"required": [
"message"
]
},
"answer": {
"properties": {
"id": "string"
},
"required": [
]
},
"sip:decline": {
"properties": {
"id": "string",
@@ -43,7 +27,6 @@
"id": "string",
"referTo": "string",
"referredBy": "string",
"referredByDisplayName": "string",
"headers": "object",
"actionHook": "object|string",
"eventHook": "object|string"
@@ -58,40 +41,16 @@
"synthesizer": "#synthesizer",
"recognizer": "#recognizer",
"bargeIn": "#bargeIn",
"ttsStream": "#ttsStream",
"record": "#recordOptions",
"listen": "#listenOptions",
"stream": "#listenOptions",
"transcribe": "#transcribeOptions",
"amd": "#amd",
"fillerNoise": "#fillerNoise",
"notifyEvents": "boolean",
"notifySttLatency": "boolean",
"reset": "string|array",
"onHoldMusic": "string",
"actionHookDelayAction": "#actionHookDelayAction",
"sipRequestWithinDialogHook": "object|string",
"boostAudioSignal": "number|string",
"vad":"#vad",
"referHook": "object|string",
"earlyMedia": "boolean",
"autoStreamTts": "boolean",
"disableTtsCache": "boolean",
"noiseIsolation": "#noiseIsolation",
"turnTaking": "#turnTaking"
"actionHookDelayAction": "#actionHookDelayAction"
},
"required": []
},
"fillerNoise": {
"properties": {
"enable": "boolean",
"url": "string",
"startDelaySecs": "number"
},
"required": [
"enable"
]
},
"listenOptions": {
"properties": {
"enable": "boolean",
@@ -107,28 +66,17 @@
"passDtmf": "boolean",
"playBeep": "boolean",
"disableBidirectionalAudio": "boolean",
"bidirectionalAudio": "#bidirectionalAudio",
"timeout": "number"
},
"required": [
"enable"
]
},
"ttsStream": {
"properties": {
"enable": "boolean",
"synthesizer": "#synthesizer"
},
"required": [
"enable"
]
},
"bargeIn": {
"properties": {
"enable": "boolean",
"sticky": "boolean",
"actionHook": "object|string",
"partialResultHook": "object|string",
"input": "array",
"finishOnKey": "string",
"numDigits": "number",
@@ -142,34 +90,6 @@
"enable"
]
},
"transcribeOptions": {
"properties": {
"enable": "boolean",
"transcriptionHook": "string",
"recognizer": "#recognizer"
},
"required": [
"enable"
]
},
"dub": {
"properties": {
"id": "string",
"action": {
"type": "string",
"enum": ["addTrack", "removeTrack", "silenceTrack", "playOnTrack", "sayOnTrack"]
},
"track": "string",
"play": "string",
"say": "string|object",
"loop": "boolean",
"gain": "number|string"
},
"required": [
"action",
"track"
]
},
"dequeue": {
"properties": {
"id": "string",
@@ -227,15 +147,13 @@
"properties": {
"id": "string",
"text": "string|array",
"instructions": "string",
"stream": "boolean",
"loop": "number|string",
"synthesizer": "#synthesizer",
"earlyMedia": "boolean",
"disableTtsCache": "boolean",
"closeStreamOnEmpty": "boolean"
"disableTtsCache": "boolean"
},
"required": [
"text"
]
},
"gather": {
@@ -258,7 +176,6 @@
"recognizer": "#recognizer",
"play": "#play",
"say": "#say",
"fillerNoise": "#fillerNoise",
"actionHookDelayAction": "#actionHookDelayAction"
},
"required": [
@@ -269,8 +186,6 @@
"id": "string",
"name": "string",
"beep": "boolean",
"memberTag": "string",
"speakOnlyTo": "string",
"startConferenceOnEnter": "boolean",
"endConferenceOnExit": "boolean",
"endConferenceDuration": "number",
@@ -281,9 +196,7 @@
"statusEvents": "array",
"statusHook": "object|string",
"enterHook": "object|string",
"record": "#record",
"listen": "#listen",
"distributeDtmf": "boolean"
"record": "#record"
},
"required": [
"name"
@@ -304,19 +217,13 @@
"dtmfHook": "object|string",
"headers": "object",
"anchorMedia": "boolean",
"exitMediaPath": "boolean",
"boostAudioSignal": "number|string",
"listen": "#listen",
"stream": "#listen",
"target": ["#target"],
"timeLimit": "number",
"timeout": "number",
"proxy": "string",
"transcribe": "#transcribe",
"amd": "#amd",
"dub": ["#dub"],
"tag": "object",
"forwardPAI": "boolean"
"amd": "#amd"
},
"required": [
"target"
@@ -327,17 +234,15 @@
"id": "string",
"credentials": "object|string",
"project": "string",
"agent": "string",
"environment": "string",
"region": "string",
"model": {
"region": {
"type": "string",
"enum": ["es", "cx", "ces"]
"enum": ["europe-west1", "europe-west2", "australia-southeast1", "asia-northeast1"]
},
"lang": "string",
"actionHook": "object|string",
"eventHook": "object|string",
"events": "array",
"events": "[string]",
"welcomeEvent": "string",
"welcomeEventParams": "object",
"noInputTimeout": "number",
@@ -345,8 +250,7 @@
"passDtmfAsTextInput": "boolean",
"thinkingMusic": "string",
"tts": "#synthesizer",
"bargein": "boolean",
"queryInput": "#queryInput"
"bargein": "boolean"
},
"required": [
"project",
@@ -354,16 +258,6 @@
"lang"
]
},
"queryInput": {
"properties": {
"text": "string",
"intent": "string",
"event": "string",
"dtmf": "string"
},
"required": [
]
},
"dtmf": {
"properties": {
"id": "string",
@@ -414,43 +308,12 @@
"passDtmf": "boolean",
"playBeep": "boolean",
"disableBidirectionalAudio": "boolean",
"bidirectionalAudio": "#bidirectionalAudio",
"sampleRate": "number",
"timeout": "number",
"transcribe": "#transcribe",
"url": "string",
"wsAuth": "#auth",
"earlyMedia": "boolean",
"channel": "number"
},
"required": [
"url"
]
},
"llm": {
"properties": {
"id": "string",
"vendor": "string",
"model": "string",
"auth": "object",
"connectOptions": "object",
"mcpServers": ["#mcpServer"],
"actionHook": "object|string",
"eventHook": "object|string",
"toolHook": "object|string",
"events": "array",
"llmOptions": "object"
},
"required": [
"vendor",
"llmOptions"
]
},
"mcpServer": {
"properties": {
"url": "string",
"auth": "object",
"roots": ["#root"]
"earlyMedia": "boolean"
},
"required": [
"url"
@@ -510,11 +373,6 @@
"type": "string",
"enum": ["startCallRecording", "stopCallRecording", "pauseCallRecording", "resumeCallRecording"]
},
"type" : {
"type" : "string",
"enum" : ["cloud", "siprec"]
},
"recordingID": "string",
"siprecServerURL": "string|array",
"headers": "object"
@@ -526,8 +384,7 @@
"redirect": {
"properties": {
"id": "string",
"actionHook": "object|string",
"statusHook": "object|string"
"actionHook": "object|string"
},
"required": [
"actionHook"
@@ -553,10 +410,7 @@
"headers": "object",
"timeout": "number",
"amd": "#amd",
"dual_streams": "boolean",
"sipRequestWithinDialogHook": "string",
"referHook": "object|string",
"timeLimit": "number"
"dual_streams" : "boolean"
},
"required": [
"call_hook",
@@ -577,12 +431,11 @@
"properties": {
"id": "string",
"transcriptionHook": "string",
"translationHook": "string",
"recognizer": "#recognizer",
"earlyMedia": "boolean",
"channel": "number"
"earlyMedia": "boolean"
},
"required": [
"transcriptionHook"
]
},
"target": {
@@ -605,8 +458,7 @@
"vmail": "boolean",
"tenant": "string",
"trunk": "string",
"overrideTo": "string",
"proxy": "string"
"overrideTo": "string"
},
"required": [
"type"
@@ -635,14 +487,14 @@
"vendor": "string",
"label": "string",
"language": "string",
"voice": "string|object",
"voice": "string",
"fallbackVendor": "string",
"fallbackLabel": "string",
"fallbackLanguage": "string",
"fallbackVoice": "string|object",
"fallbackVoice": "string",
"engine": {
"type": "string",
"enum": ["standard", "neural", "generative", "long-form"]
"enum": ["standard", "neural"]
},
"gender": {
"type": "string",
@@ -725,24 +577,13 @@
"asrDtmfTerminationDigit": "string",
"asrTimeout": "number",
"fastRecognitionTimeout": "number",
"minConfidence": "number",
"nuanceOptions": "#nuanceOptions",
"deepgramOptions": "#deepgramOptions",
"ibmOptions": "#ibmOptions",
"nvidiaOptions": "#nvidiaOptions",
"sonioxOptions": "#sonioxOptions",
"cobaltOptions": "#cobaltOptions",
"awsOptions": "#awsOptions",
"azureOptions": "#azureOptions",
"assemblyAiOptions": "#assemblyAiOptions",
"googleOptions": "#googleOptions",
"customOptions": "#customOptions",
"verbioOptions": "#verbioOptions",
"speechmaticsOptions": "#speechmaticsOptions",
"openaiOptions": "#openaiOptions",
"houndifyOptions": "#houndifyOptions",
"gladiaOptions": "object",
"elevenlabsOptions": "#elevenlabsOptions"
"customOptions": "#customOptions"
},
"required": [
"vendor"
@@ -752,131 +593,11 @@
"properties": {
"authToken": "string",
"uri": "string",
"sampleRate": "number",
"options": "object"
},
"required": [
]
},
"awsOptions": {
"properties": {
"accessKey": "string",
"secretKey": "string",
"securityToken": "string",
"region": "string",
"vocabularyName": "string",
"vocabularyFilterName": "string",
"vocabularyFilterMethod": {
"type": "string",
"enum": [
"remove",
"mask",
"tag"
]
},
"languageModelName": "string",
"piiEntityTypes": "array",
"piiIdentifyEntities": "boolean"
},
"required": [
]
},
"azureOptions": {
"properties": {
"speechSegmentationSilenceTimeoutMs": "number",
"postProcessing" : "string",
"audioLogging" : "boolean",
"languageIdMode": {
"type": "string",
"enum": [
"AtStart",
"Continuous"
]
},
"speechRecognitionMode": {
"type": "string",
"enum": [
"CONVERSATION",
"DICTATION",
"INTERACTIVE"
]
}
},
"required": [
]
},
"googleOptions" : {
"properties": {
"serviceVersion": {
"type": "string",
"enum": [
"v1",
"v2"
]
},
"recognizerId": "string",
"speechStartTimeoutMs": "number",
"speechEndTimeoutMs": "number",
"enableVoiceActivityEvents": "boolean",
"transcriptNormalization": "array"
}
},
"houndifyOptions": {
"properties": {
"requestInfo": "object",
"sampleRate": "number",
"latitude": "number",
"longitude": "number",
"city": "string",
"state": "string",
"country": "string",
"timeZone": "string",
"domain": "string",
"audioEndpoint": "string",
"maxSilenceSeconds": "number",
"maxSilenceAfterFullQuerySeconds": "number",
"maxSilenceAfterPartialQuerySeconds": "number",
"vadSensitivity": "number",
"vadTimeout": "number",
"vadMode": "string",
"vadVoiceMs": "number",
"vadSilenceMs": "number",
"vadDebug": "boolean",
"audioFormat": "string",
"enableNoiseReduction": "boolean",
"enableProfanityFilter": "boolean",
"enablePunctuation": "boolean",
"enableCapitalization": "boolean",
"confidenceThreshold": "number",
"enableDisfluencyFilter": "boolean",
"maxResults": "number",
"enableWordTimestamps": "boolean",
"maxAlternatives": "number",
"partialTranscriptInterval": "number",
"sessionTimeout": "number",
"connectionTimeout": "number",
"customVocabulary": "array",
"languageModel": "string",
"audioQueryAbsoluteTimeout": "number"
}
},
"elevenlabsOptions": {
"properties": {
"includeTimestamps": "boolean",
"commitStrategy": {
"type": "string",
"enum": [
"manual",
"vad"
]
},
"vadSilenceThresholdSecs": "number",
"vadThreshold": "number",
"minSpeechDurationMs": "number",
"minSilenceDurationMs": "number",
"enableLogging": "boolean"
}
},
"cobaltOptions": {
"properties": {
"serverUri": "string",
@@ -921,16 +642,12 @@
},
"deepgramOptions": {
"properties": {
"deepgramSttUri": "string",
"deepgramSttUseTls": "boolean",
"apiKey": "string",
"tier": "string",
"model": "string",
"customModel": "string",
"version": "string",
"punctuate": "boolean",
"smartFormatting": "boolean",
"noDelay": "boolean",
"profanityFilter": "boolean",
"redact": {
"type": "string",
@@ -950,18 +667,9 @@
"search": "array",
"replace": "array",
"keywords": "array",
"keyterms": "array",
"endpointing": "boolean | number",
"utteranceEndMs": "number",
"shortUtterance": "boolean",
"vadTurnoff": "number",
"tag": "string",
"fillerWords" : "boolean",
"eotThreshold": "number",
"eotTimeoutMs": "number",
"mipOptOut": "boolean",
"entityPrompt": "string",
"eagerEotThreshold":"number"
"tag": "string"
}
},
"sonioxOptions": {
@@ -977,173 +685,6 @@
"required": [
]
},
"verbioOptions": {
"properties": {
"enable_formatting": "boolean",
"enable_diarization": "boolean",
"topic": "number",
"inline_grammar": "string",
"grammar_uri": "string",
"label": "string",
"recognition_timeout": "number",
"speech_complete_timeout": "number",
"speech_incomplete_timeout": "number"
},
"required": [
]
},
"openaiOptions": {
"properties": {
"apiKey": "string",
"model": "string",
"prompt": "string",
"promptTemplates": "#promptTemplates",
"language": "string",
"input_audio_noise_reduction": {
"type": "string",
"enum": [
"near_field",
"far_field"
]
},
"turn_detection": "#turnDetection"
},
"required": [
]
},
"promptTemplates": {
"properties": {
"hintsTemplate": "string",
"conversationHistoryTemplate": "string"
},
"required": [
]
},
"turnDetection": {
"properties": {
"type": {
"type": "string",
"enum": [
"none",
"server_vad",
"semantic_vad"
]
},
"eagerness": {
"type": "string",
"enum": [
"low",
"medium",
"high",
"auto"
]
},
"threshold": "number",
"prefix_padding_ms": "number",
"silence_duration_ms": "number"
},
"required": [
"type"
]
},
"speechmaticsOptions": {
"properties": {
"transcription_config": "#sm_transcriptionConfig",
"translation_config": "#sm_translationConfig",
"audio_events_config_config": "#sm_audioEventsConfig"
},
"required": [
]
},
"sm_transcriptionConfig": {
"properties": {
"language": "string",
"domain": "string",
"additional_vocab": "array",
"diarization": "string",
"speaker_diarization_config": "#sm_speakerDiarizationConfig",
"conversation_config": "#sm_conversationConfig",
"enable_partials": "boolean",
"max_delay": "number",
"max_delay_mode": {
"type": "string",
"enum": [
"fixed",
"flexible"
]
},
"output_locale": "string",
"punctuation_overrides": "#sm_puctuationOverrides",
"operating_point": "string",
"enable_entities": "boolean",
"audio_filtering_config": "#sm_audioFilteringConfig",
"transcript_filtering_config": "#sm_transcriptFilteringConfig"
},
"required": [
]
},
"sm_speakerDiarizationConfig": {
"properties": {
"speaker_sensitivity": "number",
"max_speakers": "number"
},
"required": [
]
},
"sm_conversationConfig": {
"properties": {
"end_of_utterance_silence_trigger": "number"
},
"required": [
]
},
"sm_puctuationOverrides": {
"properties": {
"permitted_marks": "array",
"sensitivity": "number"
},
"required": [
]
},
"sm_audioFilteringConfig": {
"properties": {
"volume_threshold": "number"
},
"required": [
"volume_threshold"
]
},
"sm_transcriptFilteringConfig": {
"properties": {
"remove_disfluencies": "boolean"
},
"required": [
"remove_disfluencies"
]
},
"sm_translationConfig": {
"properties": {
"target_languages": "array",
"enable_partials": "boolean"
},
"required": [
"target_languages"
]
},
"sm_audioEventsConfig": {
"properties": {
"types": {
"type": "array",
"enum": [
"applause",
"music",
"laughter"
]
}
},
"required": [
]
},
"sonioxStorage": {
"properties": {
"id": "string",
@@ -1201,29 +742,6 @@
"required": [
]
},
"assemblyAiOptions": {
"properties": {
"apiKey": "string",
"serviceVersion": {
"type": "string",
"enum": [
"v2",
"v3"
]
},
"speechModel": "string",
"formatTurns": "boolean",
"endOfTurnConfidenceThreshold": "number",
"minEndOfTurnSilenceWhenConfident": "number",
"maxTurnSilence": "number",
"minTurnSilence": "number",
"keyterms": "array",
"prompt": "string",
"languageDetection": "boolean",
"vadThreshold": "number",
"inactivityTimeout": "number"
}
},
"resource": {
"properties": {
"externalReference": "#resourceReference",
@@ -1300,27 +818,16 @@
"properties": {
"enable": "boolean",
"voiceMs": "number",
"silenceMs": "number",
"strategy": "string",
"mode": "number",
"vendor": {
"type": "string",
"enum": [
"webrtc",
"silero"
]
},
"threshold": "number",
"speechPadMs": "number"
"mode": "number"
},
"required": [
"enable"
]
},
"amd": {
"properties": {
"actionHook": "object|string",
"thresholdWordCount": "number",
"digitCount": "number",
"timers": "#amdTimers",
"recognizer": "#recognizer"
},
@@ -1342,63 +849,7 @@
"noResponseTimeout": "number",
"noResponseGiveUpTimeout": "number",
"retries": "number",
"actions": "array",
"giveUpActions": "array"
}
},
"bidirectionalAudio" : {
"properties": {
"enabled": "boolean",
"streaming": "boolean",
"sampleRate": "number"
}
},
"pipeline": {
"properties": {
"id": "string",
"stt": "#recognizer",
"tts": "#synthesizer",
"vad": "#vad",
"turnDetection": "#turnDetectionPipeline",
"llm": "#llm",
"preflightLlm": "boolean",
"actionHook": "object|string",
"eventHook": "object|string",
"toolHook": "object|string"
},
"required": [
"stt",
"llm",
"tts"
]
},
"turnDetectionPipeline": {
"properties": {
"vendor": {
"type": "string",
"enum": ["krisp"]
},
"threshold": "number",
"eagerEotThreshold": "number"
},
"required": [
"vendor"
]
},
"noiseIsolation" : {
"properties": {
"enable": "boolean",
"vendor": "string",
"level": "number",
"model": "string"
}
},
"turnTaking": {
"properties": {
"enable": "boolean",
"vendor": "string",
"threshold": "number",
"model": "string"
"actions": "array"
}
}
}
}

View File

@@ -1,6 +1,6 @@
const test = require('tape');
const logger = require('pino')({level: process.env.JAMBONES_LOGLEVEL || 'error'});
const { validate, normalizeJambones } = require('..');
const { validate } = require('..');
test("validate correct verbs", async (t) => {
@@ -37,14 +37,6 @@ test("validate correct verbs", async (t) => {
"input" : ["speech"],
"actionHook": "/userInput"
},
"transcribe": {
"enable": true,
"transcriptionHook": "http://server.com/hook",
"recognizer": {
"vendor": "google",
"language": "de-DE",
}
},
"onHoldMusic": "http://server.com/hold",
"actionHookDelayAction": {
"enabled": true,
@@ -70,44 +62,6 @@ test("validate correct verbs", async (t) => {
]
}
},
{
"verb": "config",
"notifySttLatency": true,
"recognizer": {
"vendor": "google",
"language": "de-DE",
"label": "label1",
"assemblyAiOptions": {
"apiKey": "apikey",
"serviceVersion": "v3",
"formatTurns": true,
"endOfTurnConfidenceThreshold": 0.5,
"minEndOfTurnSilenceWhenConfident": 500,
"maxTurnSilence": 2000
}
}
},
{
"verb": "config",
"referHook": "https://referhook.com"
},
{
"verb": "config",
"referHook": {
"url": "https://referhook.com"
}
},
{
"verb": "config",
"recognizer": {
"vendor": "google",
"language": "de-DE",
"label": "label1",
"azureOptions": {
"languageIdMode": "Continuous"
}
}
},
{
"verb": "config",
"record": {
@@ -119,10 +73,6 @@ test("validate correct verbs", async (t) => {
}
}
},
{
"verb": "config",
"sipRequestWithinDialogHook": "https://jambonz.or/sipIndialogActionHook"
},
{
"verb": "config",
"record": {
@@ -145,7 +95,6 @@ test("validate correct verbs", async (t) => {
"callerName": "Tom",
"answerOnBridge": true,
"dtmfCapture": ["*2", "*3"],
"timeLimit": 10,
"dtmfHook": {
"url": "/dtmf",
"method": "GET"
@@ -211,12 +160,7 @@ test("validate correct verbs", async (t) => {
"hintsBoost": 10,
"fastRecognitionTimeout": 2000,
"deepgramOptions": {
"endpointing": 500,
"noDelay": true,
"eotThreshold": 500,
"eotTimeoutMs": 5000,
"eagerEotThreshold": 200,
"mipOptOut": true
"endpointing": 500
}
},
"say": {
@@ -230,119 +174,8 @@ test("validate correct verbs", async (t) => {
"fallbackLabel": "label1",
"fallbackVoice": "voice"
}
},
"say": {
"text": "To speak to Sales press 1 or say Sales. To speak to customer support press 2 or say Support",
"instructions": "Voice: High-energy, upbeat, and encouraging, projecting enthusiasm and motivation."
},
"say": {
"text": "To speak to Sales press 1 or say Sales. To speak to customer support press 2 or say Support",
"synthesizer": {
"vendor": "google",
"language": "en-US",
"voice": {
"reportedUsage":"REALTIME",
"model":"path/to/model",
},
"fallbackVendor": "google",
"fallbackLanguage": "en-US",
"fallbackLabel": "label1",
"fallbackVoice": {
"reportedUsage":"REALTIME",
"model":"path/to/model",
}
}
}
},
{
"verb": "gather",
"actionHook": "http://example.com/collect",
"input": ["digits", "speech"],
"bargein": true,
"dtmfBargein": true,
"finishOnKey": "#",
"numDigits": 5,
"timeout": 8,
"recognizer": {
"vendor": "verbio",
"language": "en-US",
"verbioOptions": {
"enable_formatting": true,
"enable_diarization": true,
"topic": 0,
"inline_grammar": "this is inline grammar",
"grammar_uri": "https://grammar_uri.com",
"label": "label",
"recognition_timeout": 500,
"speech_complete_timeout": 500,
"speech_incomplete_timeout": 500,
}
},
},
{
"verb": "gather",
"actionHook": "http://example.com/collect",
"input": ["digits", "speech"],
"bargein": true,
"dtmfBargein": true,
"finishOnKey": "#",
"numDigits": 5,
"timeout": 8,
"recognizer": {
"vendor": "houndify",
"language": "en-US",
"houndifyOptions": {
"requestInfo": {
"Latitude": 30.6,
"Longitude": 30.6,
"City": "Huston"
},
"sampleRate": 16000,
"latitude": 30.6,
"longitude": 30.6,
"city": "Huston",
"state": "CA",
"country": "US",
"timeZone": "GMT",
"domain": "Voice",
"audioEndpoint": "https://api.houndify.com/v1/audio",
"maxSilenceSeconds": 5,
"maxSilenceAfterFullQuerySeconds": 3,
"maxSilenceAfterPartialQuerySeconds": 2,
"vadSensitivity": 0.5,
"vadTimeout": 1000,
"vadMode": "auto",
"vadVoiceMs": 250,
"vadSilenceMs": 500,
"vadDebug": true,
"audioFormat": "PCM16",
"enableNoiseReduction": true,
"enableProfanityFilter": false,
"enablePunctuation": true,
"enableCapitalization": true,
"confidenceThreshold": 0.7,
"enableDisfluencyFilter": true,
"maxResults": 5,
"enableWordTimestamps": true,
"maxAlternatives": 3,
"partialTranscriptInterval": 100,
"sessionTimeout": 30000,
"connectionTimeout": 5000,
"customVocabulary": ["jambonz", "telephony", "voip"],
"languageModel": "enhanced",
"audioQueryAbsoluteTimeout": 5
},
"gladiaOptions": {
"post_processing": {
"summarization": false,
"summarization_config": {
"type": "general"
},
"chapterization": false
},
}
},
},
{
"verb": "gather",
"actionHook": "http://example.com/collect",
@@ -429,64 +262,6 @@ test("validate correct verbs", async (t) => {
"url": "wss://myrecorder.example.com/calls",
"mixType" : "stereo"
},
{
"verb": "listen",
"url": "wss://myrecorder.example.com/calls",
"mixType" : "stereo",
"bidirectionalAudio": {
enabled: true,
streaming: true,
sampleRate: 8000
}
},
{
"verb": "config",
"listen": {
"enable": true,
"url": "wss://myrecorder.example.com/calls",
"mixType" : "stereo",
"bidirectionalAudio": {
enabled: true,
streaming: true,
sampleRate: 8000
}
}
},
{
"verb": "config",
"autoStreamTts": true
},
{
"verb": "config",
"vad": {
"enable": true,
"voiceMs": 250,
"silenceMs": 150,
"strategy": "one-shot",
"mode": 2,
"vendor": "webrtc",
"threshold": 0.5,
"speechPadMs": 1000
}
},
{
"verb": "config",
"noiseIsolation": {
"enable": true,
"vendor": "krisp",
"level": 3,
"model": "custom-model"
}
},
{
"verb": "config",
"turnTaking": {
"enable": true,
"vendor": "krisp",
"threshold": 0.5,
"model": "turn-taking-model"
}
},
{
"verb": "message",
"to": "15083084809",
@@ -545,12 +320,6 @@ test("validate correct verbs", async (t) => {
"referTo": "+15083084809",
"actionHook": "/action"
},
{
"verb": "sip:refer",
"referTo": "+15083084809",
"referredByDisplayName": "Alice",
"actionHook": "/action"
},
{
"verb": "tag",
"data": {
@@ -568,57 +337,6 @@ test("validate correct verbs", async (t) => {
"interim": true
}
},
{
"verb": "transcribe",
"transcriptionHook": "http://example.com/transcribe",
"recognizer": {
"vendor": "nvidia",
"language" : "en-US",
"interim": true,
"elevenlabsOptions": {
"includeTimestamps": true,
"commitStrategy": "vad",
"vadSilenceThresholdSecs": 0.8,
"vadThreshold": 0.5,
"minSpeechDurationMs": 300,
"minSilenceDurationMs": 500,
"enableLogging": false
}
}
},
{
"verb": "transcribe",
"transcriptionHook": "http://example.com/transcribe",
"recognizer": {
"vendor": "nvidia",
"language" : "en-US",
"customOptions": {
"sampleRate": 16000
}
}
},
{
"verb": "transcribe",
"transcriptionHook": "http://example.com/transcribe",
"recognizer": {
"vendor": "nvidia",
"language" : "en-US",
"interim": true,
"googleOptions": {
"serviceVersion": "v2",
"speechStartTimeoutMs": 500,
"speechEndTimeoutMs": 1000,
"enableVoiceActivityEvents": true,
"transcriptNormalization" : [
{
"search": "dog",
"replace": "cat",
"case_sensitive": true
}
]
}
}
},
{
"verb": "rest:dial",
"account_sid": "1291964182631236912836123912",
@@ -641,96 +359,7 @@ test("validate correct verbs", async (t) => {
"actionHook": "/answeringMachineDetection",
},
"dual_streams": true,
"timeLimit" : 10
},
{
"verb": "llm",
"vendor": 'ultravox',
"model": 'fixie-ai/ultravox',
"auth": {
"apiKey": "sk-1234567890abcdefg"
},
"llmOptions": {
"firstSpeaker": 'FIRST_SPEAKER_AGENT',
},
"mcpServers": [
{
"url": 'https://mcp.example.com',
"auth": {
"username": 'username',
"password": 'password'
}
}
]
},
{
"verb": "s2s",
"vendor": "openai",
"llmOptions": {
"model": "gpt-4o-realtime"
}
},
{
"verb": "openai_s2s",
"llmOptions": {
"model": "gpt-4o-realtime"
}
},
{
"verb": "google_s2s",
"llmOptions": {
"model": "gemini-2.0-flash"
}
},
{
"verb": "elevenlabs_s2s",
"llmOptions": {
"agentId": "agent-123"
}
},
{
"verb": "stream",
"url": "wss://myrecorder.example.com/calls",
"mixType": "stereo"
},
{
"verb": "pipeline",
"stt": {
"vendor": "google",
"language": "en-US"
},
"tts": {
"vendor": "google",
"language": "en-US"
},
"llm": {
"vendor": "openai",
"llmOptions": {
"model": "gpt-4o"
}
},
"actionHook": "/pipeline/action",
"eventHook": "/pipeline/event",
"toolHook": "/pipeline/tool"
},
{
"verb": "transcribe",
"transcriptionHook": "http://example.com/transcribe",
"recognizer": {
"vendor": "speechmatics",
"language": "en",
"speechmaticsOptions": {
"transcription_config": {
"language": "en",
"enable_partials": true,
"max_delay": 2,
"conversation_config": {
"end_of_utterance_silence_trigger": 0.5
}
}
}
}
"dual_streams": true
}
];
try {
@@ -758,110 +387,6 @@ test('invalid test', async (t) => {
} catch(err) {
t.ok(1 == 1,'successfully validate verbs');
}
t.end();
});
test('verb synonyms: stream is synonym for listen', async (t) => {
// "verb" format
const result1 = normalizeJambones(logger, [
{"verb": "stream", "url": "wss://example.com/calls", "mixType": "stereo"}
]);
t.equal(Object.keys(result1[0])[0], 'listen', 'stream verb is rewritten to listen');
t.equal(result1[0].listen.url, 'wss://example.com/calls', 'data is preserved');
// object-key format
const result2 = normalizeJambones(logger, [
{"stream": {"url": "wss://example.com/calls"}}
]);
t.equal(Object.keys(result2[0])[0], 'listen', 'stream key is rewritten to listen');
// validate passes
try {
validate(logger, [{"verb": "stream", "url": "wss://example.com/calls"}]);
t.pass('stream verb validates successfully');
} catch (err) {
t.fail('stream verb should validate: ' + err);
}
t.end();
});
test('verb synonyms: s2s is synonym for llm', async (t) => {
const result = normalizeJambones(logger, [
{"verb": "s2s", "vendor": "openai", "llmOptions": {"model": "gpt-4o"}}
]);
t.equal(Object.keys(result[0])[0], 'llm', 's2s verb is rewritten to llm');
t.equal(result[0].llm.vendor, 'openai', 'vendor is preserved');
t.equal(result[0].llm.llmOptions.model, 'gpt-4o', 'llmOptions preserved');
try {
validate(logger, [{"verb": "s2s", "vendor": "openai", "llmOptions": {"model": "gpt-4o"}}]);
t.pass('s2s verb validates successfully');
} catch (err) {
t.fail('s2s verb should validate: ' + err);
}
t.end();
});
test('vendor shortcuts: openai_s2s injects vendor', async (t) => {
const result = normalizeJambones(logger, [
{"verb": "openai_s2s", "llmOptions": {"model": "gpt-4o-realtime"}}
]);
t.equal(Object.keys(result[0])[0], 'llm', 'openai_s2s is rewritten to llm');
t.equal(result[0].llm.vendor, 'openai', 'vendor is injected');
t.equal(result[0].llm.llmOptions.model, 'gpt-4o-realtime', 'llmOptions preserved');
try {
validate(logger, [{"verb": "openai_s2s", "llmOptions": {"model": "gpt-4o-realtime"}}]);
t.pass('openai_s2s validates successfully');
} catch (err) {
t.fail('openai_s2s should validate: ' + err);
}
t.end();
});
test('vendor shortcuts: all vendors work', async (t) => {
const vendors = [
'openai', 'microsoft', 'google', 'elevenlabs', 'deepgram', 'voiceagent', 'ultravox'
];
for (const vendor of vendors) {
const verbName = `${vendor}_s2s`;
const result = normalizeJambones(logger, [
{"verb": verbName, "llmOptions": {}}
]);
t.equal(Object.keys(result[0])[0], 'llm', `${verbName} rewrites to llm`);
t.equal(result[0].llm.vendor, vendor, `${verbName} injects vendor=${vendor}`);
}
t.end();
});
test('vendor shortcuts: object-key format works', async (t) => {
const result = normalizeJambones(logger, [
{"google_s2s": {"llmOptions": {"model": "gemini-2.0-flash"}}}
]);
t.equal(Object.keys(result[0])[0], 'llm', 'google_s2s key is rewritten to llm');
t.equal(result[0].llm.vendor, 'google', 'vendor is injected');
t.equal(result[0].llm.llmOptions.model, 'gemini-2.0-flash', 'llmOptions preserved');
t.end();
});
test('vendor shortcuts: explicit vendor in data overrides injected vendor', async (t) => {
const result = normalizeJambones(logger, [
{"verb": "openai_s2s", "vendor": "custom", "llmOptions": {}}
]);
t.equal(result[0].llm.vendor, 'custom', 'explicit vendor takes precedence');
t.end();
});
test('non-synonym verbs are unchanged', async (t) => {
const result = normalizeJambones(logger, [
{"verb": "say", "text": "hello"}
]);
t.equal(Object.keys(result[0])[0], 'say', 'say verb is not transformed');
const result2 = normalizeJambones(logger, [
{"llm": {"vendor": "openai", "llmOptions": {}}}
]);
t.equal(Object.keys(result2[0])[0], 'llm', 'llm verb is not transformed');
t.end();
});
})