@jambonz/sdk 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +4 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4 -2
- package/dist/client/index.d.ts +4 -2
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -1
- package/dist/harness/index.cjs +843 -0
- package/dist/harness/index.cjs.map +1 -0
- package/dist/harness/index.d.cts +501 -0
- package/dist/harness/index.d.ts +501 -0
- package/dist/harness/index.js +832 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/{rest-jYM4NgyN.d.cts → rest-qwPYz71v.d.ts} +29 -2
- package/dist/{rest-nkM1OQLd.d.ts → rest-rSaRlKBZ.d.cts} +29 -2
- package/dist/types/index.d.cts +163 -3
- package/dist/types/index.d.ts +163 -3
- package/dist/{verb-builder-D1rpCZ6y.d.ts → verb-builder-58TZ7DKD.d.cts} +2 -1
- package/dist/{verb-builder-Cbw6aUdF.d.cts → verb-builder-D20D5_vU.d.ts} +2 -1
- package/dist/{verbs-D0TgdJYZ.d.cts → verbs-YtIbYtiR.d.cts} +22 -1
- package/dist/{verbs-D0TgdJYZ.d.ts → verbs-YtIbYtiR.d.ts} +22 -1
- package/dist/webhook/index.cjs +3 -0
- package/dist/webhook/index.cjs.map +1 -1
- package/dist/webhook/index.d.cts +2 -2
- package/dist/webhook/index.d.ts +2 -2
- package/dist/webhook/index.js +3 -0
- package/dist/webhook/index.js.map +1 -1
- package/dist/websocket/index.cjs +20 -0
- package/dist/websocket/index.cjs.map +1 -1
- package/dist/websocket/index.d.cts +12 -3
- package/dist/websocket/index.d.ts +12 -3
- package/dist/websocket/index.js +20 -0
- package/dist/websocket/index.js.map +1 -1
- package/examples/harness/README.md +70 -0
- package/examples/harness/harness.ts +99 -0
- package/examples/harness/package.json +21 -0
- package/examples/harness/tsconfig.json +12 -0
- package/package.json +13 -2
- package/dist/session-DKaSRkIo.d.cts +0 -160
- package/dist/session-DKaSRkIo.d.ts +0 -160
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal jambonz custom harness.
|
|
3
|
+
*
|
|
4
|
+
* Out of the box createHarness() is a pass-through: it sends the conversation to an OpenAI-compatible
|
|
5
|
+
* model and streams the reply back to jambonz. This example adds three small hooks:
|
|
6
|
+
* - beforeModel routes each turn by keyword to a procedure with its own prompt and tools
|
|
7
|
+
* - a tool of its own (lookup_outage), run in-process
|
|
8
|
+
* - checkSentence, which never lets a long digit string be read out
|
|
9
|
+
*/
|
|
10
|
+
import { createHarness } from '@jambonz/sdk/harness';
|
|
11
|
+
import { pino } from 'pino';
|
|
12
|
+
|
|
13
|
+
const logger = pino({ level: process.env.LOG_LEVEL ?? 'info' });
|
|
14
|
+
const port = Number(process.env.PORT ?? 8080);
|
|
15
|
+
|
|
16
|
+
// pretend outage data; a real harness would call its own systems here
|
|
17
|
+
const OUTAGES: Record<string, { area: string; until: string }> = {
|
|
18
|
+
'main street': { area: 'Main Street', until: '5 pm today' },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const PROCEDURES = {
|
|
22
|
+
outage: {
|
|
23
|
+
keywords: ['outage', 'power', 'electricity', 'lights'],
|
|
24
|
+
prompt:
|
|
25
|
+
'You help callers report and check power outages for Acme Energy. Ask for the street if you do not have it, ' +
|
|
26
|
+
'then use lookup_outage. Keep answers to one or two short sentences; they are spoken aloud.',
|
|
27
|
+
tools: ['lookup_outage'],
|
|
28
|
+
},
|
|
29
|
+
billing: {
|
|
30
|
+
keywords: ['bill', 'billing', 'payment', 'charge', 'invoice'],
|
|
31
|
+
prompt:
|
|
32
|
+
'You answer billing questions for Acme Energy. You cannot see account details; offer to transfer the caller ' +
|
|
33
|
+
'to billing if they need their account. Keep answers short; they are spoken aloud.',
|
|
34
|
+
tools: [] as string[],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function route(text: string): keyof typeof PROCEDURES | undefined {
|
|
39
|
+
const lower = text.toLowerCase();
|
|
40
|
+
return (Object.keys(PROCEDURES) as Array<keyof typeof PROCEDURES>).find((p) =>
|
|
41
|
+
PROCEDURES[p].keywords.some((k) => lower.includes(k)),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
createHarness({
|
|
46
|
+
logger,
|
|
47
|
+
apiKey: process.env.HARNESS_API_KEY, // the key in the jambonz Harness credential
|
|
48
|
+
model: process.env.MODEL ?? 'gpt-4.1-mini',
|
|
49
|
+
instructions:
|
|
50
|
+
'You answer phone calls for Acme Energy. Be warm and brief: one or two sentences, plain text, no lists or markdown.',
|
|
51
|
+
greeting: 'Thanks for calling Acme Energy. How can I help you today?',
|
|
52
|
+
|
|
53
|
+
onSessionStart(session, ctx) {
|
|
54
|
+
ctx.log.info({ from: session.from, metadata: session.metadata }, 'new call');
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// routing: once a procedure is chosen it stays in force for later turns
|
|
58
|
+
beforeModel(turn, ctx) {
|
|
59
|
+
const picked = route(turn.text) ?? (ctx.state.get('procedure') as keyof typeof PROCEDURES | undefined);
|
|
60
|
+
if (!picked) return { route: 'chat' };
|
|
61
|
+
ctx.state.set('procedure', picked);
|
|
62
|
+
const p = PROCEDURES[picked];
|
|
63
|
+
ctx.record('procedures', [picked]);
|
|
64
|
+
return { route: 'procedure', instructions: p.prompt, tools: p.tools };
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
tools: {
|
|
68
|
+
lookup_outage: {
|
|
69
|
+
description: 'Find a reported power outage on a street',
|
|
70
|
+
parameters: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: { street: { type: 'string', description: 'Street name, e.g. "Main Street"' } },
|
|
73
|
+
required: ['street'],
|
|
74
|
+
},
|
|
75
|
+
run: ({ street }) => {
|
|
76
|
+
const hit = OUTAGES[String(street).toLowerCase()];
|
|
77
|
+
return hit ? { outage: true, ...hit } : { outage: false };
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// never read out anything that looks like an account or card number
|
|
83
|
+
checkSentence: (sentence) => (/\d{6,}/.test(sentence) ? "I can't read that number out over the phone." : true),
|
|
84
|
+
|
|
85
|
+
onEvent: {
|
|
86
|
+
// the caller pressed 0: hand them to a person, if an operator number is configured
|
|
87
|
+
async dtmf(e, ctx) {
|
|
88
|
+
if (e.digits !== '0' || !process.env.OPERATOR_NUMBER) return;
|
|
89
|
+
ctx.say('Connecting you to a person now.');
|
|
90
|
+
const result = await ctx.command('transfer', { to: process.env.OPERATOR_NUMBER });
|
|
91
|
+
if (!result.ok) ctx.log.warn({ error: result.error }, 'transfer to operator failed');
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
.listen(port)
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
logger.error({ err }, 'could not start the harness');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jambonz-harness-example",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "A minimal jambonz custom harness built with @jambonz/sdk/harness",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "tsx harness.ts",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@jambonz/sdk": "^0.13.0",
|
|
14
|
+
"pino": "^9.14.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^22.0.0",
|
|
18
|
+
"tsx": "^4.19.0",
|
|
19
|
+
"typescript": "^5.6.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jambonz/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "jambonz SDK for building voice applications — optimized for AI agents",
|
|
5
5
|
"author": "Dave Horton",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,6 +74,16 @@
|
|
|
74
74
|
"types": "./dist/types/index.d.cts",
|
|
75
75
|
"default": "./dist/types/index.cjs"
|
|
76
76
|
}
|
|
77
|
+
},
|
|
78
|
+
"./harness": {
|
|
79
|
+
"import": {
|
|
80
|
+
"types": "./dist/harness/index.d.ts",
|
|
81
|
+
"default": "./dist/harness/index.js"
|
|
82
|
+
},
|
|
83
|
+
"require": {
|
|
84
|
+
"types": "./dist/harness/index.d.cts",
|
|
85
|
+
"default": "./dist/harness/index.cjs"
|
|
86
|
+
}
|
|
77
87
|
}
|
|
78
88
|
},
|
|
79
89
|
"files": [
|
|
@@ -95,8 +105,9 @@
|
|
|
95
105
|
"postpublish": "npm run clean-docs"
|
|
96
106
|
},
|
|
97
107
|
"dependencies": {
|
|
98
|
-
"@jambonz/schema": "^0.4.
|
|
108
|
+
"@jambonz/schema": "^0.4.36",
|
|
99
109
|
"ajv": "^8.17.1",
|
|
110
|
+
"pino": "^9.14.0",
|
|
100
111
|
"ws": "^8.18.0"
|
|
101
112
|
},
|
|
102
113
|
"devDependencies": {
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for call session data received from jambonz.
|
|
3
|
-
*/
|
|
4
|
-
/** Call session data provided in webhook requests and WebSocket session:new messages. */
|
|
5
|
-
interface CallSession {
|
|
6
|
-
/** Unique call identifier. */
|
|
7
|
-
call_sid: string;
|
|
8
|
-
/** Account identifier. */
|
|
9
|
-
account_sid: string;
|
|
10
|
-
/** Application identifier. */
|
|
11
|
-
application_sid: string;
|
|
12
|
-
/** Call direction. */
|
|
13
|
-
direction: 'inbound' | 'outbound';
|
|
14
|
-
/** Caller phone number or SIP URI. */
|
|
15
|
-
from: string;
|
|
16
|
-
/** Called phone number or SIP URI. */
|
|
17
|
-
to: string;
|
|
18
|
-
/** SIP Call-ID header. */
|
|
19
|
-
call_id: string;
|
|
20
|
-
/** SIP response status code. */
|
|
21
|
-
sip_status: number;
|
|
22
|
-
/** SIP reason phrase. */
|
|
23
|
-
sip_reason?: string;
|
|
24
|
-
/** Caller display name from the SIP From header. */
|
|
25
|
-
caller_name?: string;
|
|
26
|
-
/** Caller ID value (phone number or SIP user). */
|
|
27
|
-
caller_id?: string;
|
|
28
|
-
/** Call status. */
|
|
29
|
-
call_status?: string;
|
|
30
|
-
/** Name of the originating SIP trunk as configured in jambonz. */
|
|
31
|
-
originating_sip_trunk_name?: string;
|
|
32
|
-
/** IP address of the originating SIP trunk. */
|
|
33
|
-
originating_sip_ip?: string;
|
|
34
|
-
/** Service provider SID. */
|
|
35
|
-
service_provider_sid?: string;
|
|
36
|
-
/** Distributed tracing ID. */
|
|
37
|
-
trace_id?: string;
|
|
38
|
-
/** Call SID of the parent call (present for adulting / child call scenarios). */
|
|
39
|
-
parent_call_sid?: string;
|
|
40
|
-
/** jambonz REST API base URL for mid-call control. */
|
|
41
|
-
api_base_url?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Raw SIP INVITE message (drachtio SipRequest, serialized).
|
|
44
|
-
* Only present for WebSocket and HTTP POST transports.
|
|
45
|
-
* See https://drachtio.org/api#sip-request for the full API.
|
|
46
|
-
*/
|
|
47
|
-
sip?: {
|
|
48
|
-
/** SIP headers as key-value pairs. Custom X-* headers are included. */
|
|
49
|
-
headers: Record<string, string>;
|
|
50
|
-
/** SIP message body (typically SDP). */
|
|
51
|
-
body?: string;
|
|
52
|
-
/** SIP method (always 'INVITE' for session:new). */
|
|
53
|
-
method?: string;
|
|
54
|
-
/** Request-URI from the SIP INVITE. */
|
|
55
|
-
uri?: string;
|
|
56
|
-
/** Phone number extracted from the Request-URI. */
|
|
57
|
-
calledNumber?: string;
|
|
58
|
-
/** Calling phone number from P-Asserted-Identity or From header. */
|
|
59
|
-
callingNumber?: string;
|
|
60
|
-
/** Transport protocol (e.g. 'udp', 'tcp', 'tls'). */
|
|
61
|
-
protocol?: string;
|
|
62
|
-
/** IP address of the sender. */
|
|
63
|
-
source_address?: string;
|
|
64
|
-
/** Port of the sender. */
|
|
65
|
-
source_port?: string | number;
|
|
66
|
-
};
|
|
67
|
-
/** Application environment variables configured in the jambonz portal. */
|
|
68
|
-
env_vars?: Record<string, string>;
|
|
69
|
-
/** Default speech settings for the account. */
|
|
70
|
-
defaults?: {
|
|
71
|
-
synthesizer?: {
|
|
72
|
-
vendor?: string;
|
|
73
|
-
language?: string;
|
|
74
|
-
voice?: string;
|
|
75
|
-
};
|
|
76
|
-
recognizer?: {
|
|
77
|
-
vendor?: string;
|
|
78
|
-
language?: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
/** Custom data attached via the REST API when creating an outbound call. */
|
|
82
|
-
customerData?: Record<string, unknown>;
|
|
83
|
-
/** Additional properties. */
|
|
84
|
-
[key: string]: unknown;
|
|
85
|
-
}
|
|
86
|
-
/** TTS streaming event types sent by jambonz. */
|
|
87
|
-
type TtsStreamingEventType = 'stream_open' | 'stream_paused' | 'stream_resumed' | 'stream_closed' | 'user_interruption' | 'tts_spoken';
|
|
88
|
-
/** Payload for tts:streaming-event messages. */
|
|
89
|
-
interface TtsStreamingEvent {
|
|
90
|
-
event_type: TtsStreamingEventType;
|
|
91
|
-
/** The actual text spoken via TTS (present for tts_spoken events). */
|
|
92
|
-
text?: string;
|
|
93
|
-
/** Whether the user interrupted the TTS playout (present for tts_spoken events). */
|
|
94
|
-
bargein?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/** WebSocket message types received from jambonz. */
|
|
97
|
-
type WsMessageType = 'session:new' | 'session:adulting' | 'session:reconnect' | 'session:redirect' | 'verb:hook' | 'dial:confirm' | 'call:status' | 'verb:status' | 'llm:event' | 'llm:tool-call' | 'agent:event' | 'agent:tool-call' | 'tts:streaming-event' | 'tts:tokens-result' | 'jambonz:error';
|
|
98
|
-
/** Agent eventHook event types. */
|
|
99
|
-
type AgentEventType = 'turn_end' | 'user_transcript' | 'llm_response' | 'user_interruption';
|
|
100
|
-
/** Preflight (early generation) metrics. */
|
|
101
|
-
interface AgentPreflightMetrics {
|
|
102
|
-
result: 'hit' | 'miss' | 'pending';
|
|
103
|
-
tokens?: number;
|
|
104
|
-
}
|
|
105
|
-
/** Per-turn latency metrics (all values in milliseconds). */
|
|
106
|
-
interface AgentTurnLatency {
|
|
107
|
-
/** STT processing latency: stop talking to final transcript received. */
|
|
108
|
-
transcriber_latency?: number;
|
|
109
|
-
/** Additional wait after transcript for end-of-turn detection. */
|
|
110
|
-
turn_detection_latency?: number;
|
|
111
|
-
/** LLM latency: wait for first token after ready to prompt. Absent on preflight hit. */
|
|
112
|
-
model_latency?: number;
|
|
113
|
-
/** TTS engine latency: first text sent to TTS until first audio received. */
|
|
114
|
-
voice_latency?: number;
|
|
115
|
-
/** Early generation metrics. */
|
|
116
|
-
preflight?: AgentPreflightMetrics;
|
|
117
|
-
}
|
|
118
|
-
/** Payload for agent:event turn_end messages. */
|
|
119
|
-
interface AgentTurnEndEvent {
|
|
120
|
-
type: 'turn_end';
|
|
121
|
-
transcript: string;
|
|
122
|
-
response: string;
|
|
123
|
-
interrupted: boolean;
|
|
124
|
-
latency: AgentTurnLatency;
|
|
125
|
-
}
|
|
126
|
-
/** Payload for agent:event user_transcript messages. */
|
|
127
|
-
interface AgentUserTranscriptEvent {
|
|
128
|
-
type: 'user_transcript';
|
|
129
|
-
transcript: string;
|
|
130
|
-
}
|
|
131
|
-
/** Payload for agent:event llm_response messages. */
|
|
132
|
-
interface AgentLlmResponseEvent {
|
|
133
|
-
type: 'llm_response';
|
|
134
|
-
response: string;
|
|
135
|
-
}
|
|
136
|
-
/** Payload for agent:event user_interruption messages. */
|
|
137
|
-
interface AgentUserInterruptionEvent {
|
|
138
|
-
type: 'user_interruption';
|
|
139
|
-
}
|
|
140
|
-
/** Union of all agent eventHook payloads. */
|
|
141
|
-
type AgentEvent = AgentTurnEndEvent | AgentUserTranscriptEvent | AgentLlmResponseEvent | AgentUserInterruptionEvent;
|
|
142
|
-
/** Inbound WebSocket message from jambonz. */
|
|
143
|
-
interface WsMessage {
|
|
144
|
-
type: WsMessageType;
|
|
145
|
-
msgid: string;
|
|
146
|
-
call_sid?: string;
|
|
147
|
-
hook?: string;
|
|
148
|
-
data?: Record<string, unknown>;
|
|
149
|
-
b3?: string;
|
|
150
|
-
}
|
|
151
|
-
/** Outbound WebSocket message to jambonz. */
|
|
152
|
-
interface WsResponse {
|
|
153
|
-
type: 'ack' | 'command';
|
|
154
|
-
msgid?: string;
|
|
155
|
-
command?: string;
|
|
156
|
-
queueCommand?: boolean;
|
|
157
|
-
data?: unknown;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export type { AgentEvent as A, CallSession as C, TtsStreamingEvent as T, WsMessage as W, AgentEventType as a, AgentLlmResponseEvent as b, AgentPreflightMetrics as c, AgentTurnEndEvent as d, AgentTurnLatency as e, AgentUserInterruptionEvent as f, AgentUserTranscriptEvent as g, TtsStreamingEventType as h, WsMessageType as i, WsResponse as j };
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for call session data received from jambonz.
|
|
3
|
-
*/
|
|
4
|
-
/** Call session data provided in webhook requests and WebSocket session:new messages. */
|
|
5
|
-
interface CallSession {
|
|
6
|
-
/** Unique call identifier. */
|
|
7
|
-
call_sid: string;
|
|
8
|
-
/** Account identifier. */
|
|
9
|
-
account_sid: string;
|
|
10
|
-
/** Application identifier. */
|
|
11
|
-
application_sid: string;
|
|
12
|
-
/** Call direction. */
|
|
13
|
-
direction: 'inbound' | 'outbound';
|
|
14
|
-
/** Caller phone number or SIP URI. */
|
|
15
|
-
from: string;
|
|
16
|
-
/** Called phone number or SIP URI. */
|
|
17
|
-
to: string;
|
|
18
|
-
/** SIP Call-ID header. */
|
|
19
|
-
call_id: string;
|
|
20
|
-
/** SIP response status code. */
|
|
21
|
-
sip_status: number;
|
|
22
|
-
/** SIP reason phrase. */
|
|
23
|
-
sip_reason?: string;
|
|
24
|
-
/** Caller display name from the SIP From header. */
|
|
25
|
-
caller_name?: string;
|
|
26
|
-
/** Caller ID value (phone number or SIP user). */
|
|
27
|
-
caller_id?: string;
|
|
28
|
-
/** Call status. */
|
|
29
|
-
call_status?: string;
|
|
30
|
-
/** Name of the originating SIP trunk as configured in jambonz. */
|
|
31
|
-
originating_sip_trunk_name?: string;
|
|
32
|
-
/** IP address of the originating SIP trunk. */
|
|
33
|
-
originating_sip_ip?: string;
|
|
34
|
-
/** Service provider SID. */
|
|
35
|
-
service_provider_sid?: string;
|
|
36
|
-
/** Distributed tracing ID. */
|
|
37
|
-
trace_id?: string;
|
|
38
|
-
/** Call SID of the parent call (present for adulting / child call scenarios). */
|
|
39
|
-
parent_call_sid?: string;
|
|
40
|
-
/** jambonz REST API base URL for mid-call control. */
|
|
41
|
-
api_base_url?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Raw SIP INVITE message (drachtio SipRequest, serialized).
|
|
44
|
-
* Only present for WebSocket and HTTP POST transports.
|
|
45
|
-
* See https://drachtio.org/api#sip-request for the full API.
|
|
46
|
-
*/
|
|
47
|
-
sip?: {
|
|
48
|
-
/** SIP headers as key-value pairs. Custom X-* headers are included. */
|
|
49
|
-
headers: Record<string, string>;
|
|
50
|
-
/** SIP message body (typically SDP). */
|
|
51
|
-
body?: string;
|
|
52
|
-
/** SIP method (always 'INVITE' for session:new). */
|
|
53
|
-
method?: string;
|
|
54
|
-
/** Request-URI from the SIP INVITE. */
|
|
55
|
-
uri?: string;
|
|
56
|
-
/** Phone number extracted from the Request-URI. */
|
|
57
|
-
calledNumber?: string;
|
|
58
|
-
/** Calling phone number from P-Asserted-Identity or From header. */
|
|
59
|
-
callingNumber?: string;
|
|
60
|
-
/** Transport protocol (e.g. 'udp', 'tcp', 'tls'). */
|
|
61
|
-
protocol?: string;
|
|
62
|
-
/** IP address of the sender. */
|
|
63
|
-
source_address?: string;
|
|
64
|
-
/** Port of the sender. */
|
|
65
|
-
source_port?: string | number;
|
|
66
|
-
};
|
|
67
|
-
/** Application environment variables configured in the jambonz portal. */
|
|
68
|
-
env_vars?: Record<string, string>;
|
|
69
|
-
/** Default speech settings for the account. */
|
|
70
|
-
defaults?: {
|
|
71
|
-
synthesizer?: {
|
|
72
|
-
vendor?: string;
|
|
73
|
-
language?: string;
|
|
74
|
-
voice?: string;
|
|
75
|
-
};
|
|
76
|
-
recognizer?: {
|
|
77
|
-
vendor?: string;
|
|
78
|
-
language?: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
/** Custom data attached via the REST API when creating an outbound call. */
|
|
82
|
-
customerData?: Record<string, unknown>;
|
|
83
|
-
/** Additional properties. */
|
|
84
|
-
[key: string]: unknown;
|
|
85
|
-
}
|
|
86
|
-
/** TTS streaming event types sent by jambonz. */
|
|
87
|
-
type TtsStreamingEventType = 'stream_open' | 'stream_paused' | 'stream_resumed' | 'stream_closed' | 'user_interruption' | 'tts_spoken';
|
|
88
|
-
/** Payload for tts:streaming-event messages. */
|
|
89
|
-
interface TtsStreamingEvent {
|
|
90
|
-
event_type: TtsStreamingEventType;
|
|
91
|
-
/** The actual text spoken via TTS (present for tts_spoken events). */
|
|
92
|
-
text?: string;
|
|
93
|
-
/** Whether the user interrupted the TTS playout (present for tts_spoken events). */
|
|
94
|
-
bargein?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/** WebSocket message types received from jambonz. */
|
|
97
|
-
type WsMessageType = 'session:new' | 'session:adulting' | 'session:reconnect' | 'session:redirect' | 'verb:hook' | 'dial:confirm' | 'call:status' | 'verb:status' | 'llm:event' | 'llm:tool-call' | 'agent:event' | 'agent:tool-call' | 'tts:streaming-event' | 'tts:tokens-result' | 'jambonz:error';
|
|
98
|
-
/** Agent eventHook event types. */
|
|
99
|
-
type AgentEventType = 'turn_end' | 'user_transcript' | 'llm_response' | 'user_interruption';
|
|
100
|
-
/** Preflight (early generation) metrics. */
|
|
101
|
-
interface AgentPreflightMetrics {
|
|
102
|
-
result: 'hit' | 'miss' | 'pending';
|
|
103
|
-
tokens?: number;
|
|
104
|
-
}
|
|
105
|
-
/** Per-turn latency metrics (all values in milliseconds). */
|
|
106
|
-
interface AgentTurnLatency {
|
|
107
|
-
/** STT processing latency: stop talking to final transcript received. */
|
|
108
|
-
transcriber_latency?: number;
|
|
109
|
-
/** Additional wait after transcript for end-of-turn detection. */
|
|
110
|
-
turn_detection_latency?: number;
|
|
111
|
-
/** LLM latency: wait for first token after ready to prompt. Absent on preflight hit. */
|
|
112
|
-
model_latency?: number;
|
|
113
|
-
/** TTS engine latency: first text sent to TTS until first audio received. */
|
|
114
|
-
voice_latency?: number;
|
|
115
|
-
/** Early generation metrics. */
|
|
116
|
-
preflight?: AgentPreflightMetrics;
|
|
117
|
-
}
|
|
118
|
-
/** Payload for agent:event turn_end messages. */
|
|
119
|
-
interface AgentTurnEndEvent {
|
|
120
|
-
type: 'turn_end';
|
|
121
|
-
transcript: string;
|
|
122
|
-
response: string;
|
|
123
|
-
interrupted: boolean;
|
|
124
|
-
latency: AgentTurnLatency;
|
|
125
|
-
}
|
|
126
|
-
/** Payload for agent:event user_transcript messages. */
|
|
127
|
-
interface AgentUserTranscriptEvent {
|
|
128
|
-
type: 'user_transcript';
|
|
129
|
-
transcript: string;
|
|
130
|
-
}
|
|
131
|
-
/** Payload for agent:event llm_response messages. */
|
|
132
|
-
interface AgentLlmResponseEvent {
|
|
133
|
-
type: 'llm_response';
|
|
134
|
-
response: string;
|
|
135
|
-
}
|
|
136
|
-
/** Payload for agent:event user_interruption messages. */
|
|
137
|
-
interface AgentUserInterruptionEvent {
|
|
138
|
-
type: 'user_interruption';
|
|
139
|
-
}
|
|
140
|
-
/** Union of all agent eventHook payloads. */
|
|
141
|
-
type AgentEvent = AgentTurnEndEvent | AgentUserTranscriptEvent | AgentLlmResponseEvent | AgentUserInterruptionEvent;
|
|
142
|
-
/** Inbound WebSocket message from jambonz. */
|
|
143
|
-
interface WsMessage {
|
|
144
|
-
type: WsMessageType;
|
|
145
|
-
msgid: string;
|
|
146
|
-
call_sid?: string;
|
|
147
|
-
hook?: string;
|
|
148
|
-
data?: Record<string, unknown>;
|
|
149
|
-
b3?: string;
|
|
150
|
-
}
|
|
151
|
-
/** Outbound WebSocket message to jambonz. */
|
|
152
|
-
interface WsResponse {
|
|
153
|
-
type: 'ack' | 'command';
|
|
154
|
-
msgid?: string;
|
|
155
|
-
command?: string;
|
|
156
|
-
queueCommand?: boolean;
|
|
157
|
-
data?: unknown;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export type { AgentEvent as A, CallSession as C, TtsStreamingEvent as T, WsMessage as W, AgentEventType as a, AgentLlmResponseEvent as b, AgentPreflightMetrics as c, AgentTurnEndEvent as d, AgentTurnLatency as e, AgentUserInterruptionEvent as f, AgentUserTranscriptEvent as g, TtsStreamingEventType as h, WsMessageType as i, WsResponse as j };
|