@squidcloud/twilio-client 1.0.493
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/connectors/twilio/common/src/twilio-types.d.ts +224 -0
- package/dist/connectors/twilio/twilio-client/src/index.d.ts +2 -0
- package/dist/connectors/twilio/twilio-client/src/twilio-client.d.ts +18 -0
- package/dist/index.js +1 -0
- package/dist/internal-common/src/ai/voice-languages.d.ts +22 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +1536 -0
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +298 -0
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +2144 -0
- package/dist/internal-common/src/public-types/ai-voice.public-types.d.ts +200 -0
- package/dist/internal-common/src/public-types/backend.public-types.d.ts +61 -0
- package/dist/internal-common/src/public-types/communication.public-types.d.ts +30 -0
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +405 -0
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +65 -0
- package/dist/internal-common/src/public-types/job.public-types.d.ts +87 -0
- package/dist/internal-common/src/public-types/metadata-filter.public-types.d.ts +106 -0
- package/dist/internal-common/src/public-types/secret.public-types.d.ts +82 -0
- package/package.json +25 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { AllAiAgentChatOptions } from './ai-agent.public-types';
|
|
2
|
+
import type { AiAgentId, IntegrationId } from './communication.public-types';
|
|
3
|
+
/**
|
|
4
|
+
* Providers that put a Squid agent on a phone call. `twilio` relays the call to Squid over a WebSocket
|
|
5
|
+
* Squid serves; `openai` is an OpenAI Realtime call Squid answers itself, see
|
|
6
|
+
* {@link AnswerOpenAiVoiceCallRequest}.
|
|
7
|
+
* @category AI
|
|
8
|
+
*/
|
|
9
|
+
export declare const AI_VOICE_RELAY_PROVIDERS: readonly ["twilio", "openai"];
|
|
10
|
+
/**
|
|
11
|
+
* A provider of {@link AI_VOICE_RELAY_PROVIDERS}.
|
|
12
|
+
* @category AI
|
|
13
|
+
*/
|
|
14
|
+
export type AiVoiceRelayProvider = (typeof AI_VOICE_RELAY_PROVIDERS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* How a call opens. `phrase` speaks the greeting as soon as the call is answered; `agent` has the agent
|
|
17
|
+
* compose its opening line on a first turn before the caller speaks, so it can look the caller up and greet a
|
|
18
|
+
* known caller by name, with the greeting as what it says when there is nothing to personalize.
|
|
19
|
+
* @category AI
|
|
20
|
+
*/
|
|
21
|
+
export declare const AI_VOICE_GREETING_MODES: readonly ["phrase", "agent"];
|
|
22
|
+
/**
|
|
23
|
+
* A mode of {@link AI_VOICE_GREETING_MODES}.
|
|
24
|
+
* @category AI
|
|
25
|
+
*/
|
|
26
|
+
export type AiVoiceGreetingMode = (typeof AI_VOICE_GREETING_MODES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* Request to open a voice session: a phone call the provider relays to a Squid agent in real time.
|
|
29
|
+
* The response carries the relay URL the provider must connect to.
|
|
30
|
+
* @category AI
|
|
31
|
+
*/
|
|
32
|
+
export interface CreateAiVoiceSessionRequest {
|
|
33
|
+
/** The agent that answers the call. */
|
|
34
|
+
agentId: AiAgentId;
|
|
35
|
+
/** The telephony provider that relays the call. */
|
|
36
|
+
provider: AiVoiceRelayProvider;
|
|
37
|
+
/** The provider's id of the call (a Twilio CallSid), when known before the provider connects. */
|
|
38
|
+
externalCallId?: string;
|
|
39
|
+
/** Chat options applied to every turn of the call: instructions, connected integrations, agent context. */
|
|
40
|
+
chatOptions?: AllAiAgentChatOptions;
|
|
41
|
+
/** Free-form data echoed on every session event, for the caller's own bookkeeping. */
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
/** `agent` has the agent open the call once the provider connects; otherwise the provider speaks its own greeting. */
|
|
44
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
45
|
+
/** What the agent says in `agent` mode when there is nothing to personalize. */
|
|
46
|
+
greeting?: string;
|
|
47
|
+
/** How long the relay token stays valid before the provider connects, in seconds. Defaults to 5 minutes. */
|
|
48
|
+
connectTimeoutSeconds?: number;
|
|
49
|
+
/** Public base URL of the application when it differs from the default, such as a tunnel in local development. */
|
|
50
|
+
relayBaseUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The opened voice session.
|
|
54
|
+
* @category AI
|
|
55
|
+
*/
|
|
56
|
+
export interface CreateAiVoiceSessionResponse {
|
|
57
|
+
/** Unique id of the session. */
|
|
58
|
+
sessionId: string;
|
|
59
|
+
/** One-time relay token; already embedded in `relayUrl`. */
|
|
60
|
+
token: string;
|
|
61
|
+
/** Absolute `wss://` URL the telephony provider connects to for this call. */
|
|
62
|
+
relayUrl: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Request to answer a phone call that reached an OpenAI project's SIP endpoint. Squid accepts the call with
|
|
66
|
+
* the given instructions, and for the call's life runs the agent whenever the realtime model asks it
|
|
67
|
+
* something and hangs up when the model ends the call. Requires the application API key.
|
|
68
|
+
* @category AI
|
|
69
|
+
*/
|
|
70
|
+
export interface AnswerOpenAiVoiceCallRequest {
|
|
71
|
+
/** The agent the realtime model asks for knowledge and actions. */
|
|
72
|
+
agentId: AiAgentId;
|
|
73
|
+
/** The call id from OpenAI's `realtime.call.incoming` webhook. */
|
|
74
|
+
callId: string;
|
|
75
|
+
/** The `openai_voice` integration whose API key answers the call. */
|
|
76
|
+
integrationId: IntegrationId;
|
|
77
|
+
/** Realtime model that talks on the call; defaults to the integration's default model. */
|
|
78
|
+
model?: string;
|
|
79
|
+
/** Voice of the realtime model; defaults to the integration's default voice. */
|
|
80
|
+
voice?: string;
|
|
81
|
+
/** Instructions of the realtime model. */
|
|
82
|
+
instructions: string;
|
|
83
|
+
/** Spoken as soon as the call is answered; without it the model waits for the caller to speak first. */
|
|
84
|
+
greeting?: string;
|
|
85
|
+
/** `agent` has the agent compose the opening line, with `greeting` as its fallback; `phrase` (the default) speaks `greeting` as is. */
|
|
86
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
87
|
+
/** The telephony provider's id of the call (a Twilio CallSid), echoed on every session event. */
|
|
88
|
+
externalCallId?: string;
|
|
89
|
+
/** Chat options applied to every turn the agent runs for the call: instructions, agent context. */
|
|
90
|
+
chatOptions?: AllAiAgentChatOptions;
|
|
91
|
+
/** Free-form data echoed on every session event, for the caller's own bookkeeping. */
|
|
92
|
+
metadata?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The answered OpenAI call.
|
|
96
|
+
* @category AI
|
|
97
|
+
*/
|
|
98
|
+
export interface AnswerOpenAiVoiceCallResponse {
|
|
99
|
+
/** Unique id of the voice session that runs the call. */
|
|
100
|
+
sessionId: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* How a voice call handles languages: `single` keeps the whole call in its language, `selected` lets the
|
|
104
|
+
* caller switch between it and the chosen ones, `any` follows the caller into any language.
|
|
105
|
+
* @category AI
|
|
106
|
+
*/
|
|
107
|
+
export type AiVoiceLanguageMode = 'single' | 'selected' | 'any';
|
|
108
|
+
/**
|
|
109
|
+
* Request to start a voice call with an agent from a browser. The browser produces a WebRTC offer, Squid
|
|
110
|
+
* creates the call on the OpenAI Realtime API and returns the answer; from then on the browser talks to
|
|
111
|
+
* OpenAI directly while Squid runs the agent behind the call. Every setting defaults to what the agent's
|
|
112
|
+
* phone line uses (its Twilio ability with the OpenAI engine), then to the application's OpenAI Voice
|
|
113
|
+
* integration. Open to application users under the agent's security rules, and to the API key.
|
|
114
|
+
* @category AI
|
|
115
|
+
*/
|
|
116
|
+
export interface StartOpenAiWebVoiceCallRequest {
|
|
117
|
+
/** The agent the realtime model asks for knowledge and actions. */
|
|
118
|
+
agentId: AiAgentId;
|
|
119
|
+
/** The browser's WebRTC offer, as SDP. */
|
|
120
|
+
sdp: string;
|
|
121
|
+
/** The `openai_voice` integration to use; needed only when the agent has no phone line and the app has several. */
|
|
122
|
+
integrationId?: IntegrationId;
|
|
123
|
+
/** Realtime model that talks on the call. */
|
|
124
|
+
model?: string;
|
|
125
|
+
/** Voice of the realtime model. */
|
|
126
|
+
voice?: string;
|
|
127
|
+
/** Language the call starts in, as an ISO code or BCP-47 tag. */
|
|
128
|
+
language?: string;
|
|
129
|
+
/** Whether the caller may switch language mid-call. */
|
|
130
|
+
languageMode?: AiVoiceLanguageMode;
|
|
131
|
+
/** The languages the caller may switch to in `selected` mode. */
|
|
132
|
+
additionalLanguages?: Array<string>;
|
|
133
|
+
/** Spoken as soon as the call starts; without any greeting the model waits for the caller. */
|
|
134
|
+
greeting?: string;
|
|
135
|
+
/** `agent` has the agent compose the opening line, with `greeting` as its fallback; defaults to the phone line's mode. */
|
|
136
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
137
|
+
/** What this call is for, added to the realtime model's instructions. */
|
|
138
|
+
instructions?: string;
|
|
139
|
+
/** Chat options applied to every turn the agent runs for the call: instructions, agent context. */
|
|
140
|
+
chatOptions?: AllAiAgentChatOptions;
|
|
141
|
+
/** Free-form data echoed on every session event, for the caller's own bookkeeping. */
|
|
142
|
+
metadata?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The started browser call.
|
|
146
|
+
* @category AI
|
|
147
|
+
*/
|
|
148
|
+
export interface StartOpenAiWebVoiceCallResponse {
|
|
149
|
+
/** Unique id of the voice session that runs the call. */
|
|
150
|
+
sessionId: string;
|
|
151
|
+
/** Id of the call at OpenAI. */
|
|
152
|
+
callId: string;
|
|
153
|
+
/** OpenAI's WebRTC answer, as SDP, for the browser's remote description. */
|
|
154
|
+
sdp: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Event type emitted on the application event bus for every voice session milestone. Subscribe with
|
|
158
|
+
* `@eventHandler(AI_VOICE_SESSION_EVENT_TYPE)`; the payload is an {@link AiVoiceSessionEvent}.
|
|
159
|
+
* @category AI
|
|
160
|
+
*/
|
|
161
|
+
export declare const AI_VOICE_SESSION_EVENT_TYPE = "ai-voice-session-event";
|
|
162
|
+
/**
|
|
163
|
+
* Milestones of a voice session.
|
|
164
|
+
* @category AI
|
|
165
|
+
*/
|
|
166
|
+
export type AiVoiceSessionEventKind = 'started' | 'turn' | 'ended';
|
|
167
|
+
/**
|
|
168
|
+
* One spoken turn of a voice session.
|
|
169
|
+
* @category AI
|
|
170
|
+
*/
|
|
171
|
+
export interface AiVoiceSessionTurn {
|
|
172
|
+
/** Who spoke. */
|
|
173
|
+
role: 'user' | 'agent';
|
|
174
|
+
/** What was said, as transcribed (user) or generated (agent). */
|
|
175
|
+
text: string;
|
|
176
|
+
/** When the turn completed, as an ISO timestamp. */
|
|
177
|
+
at: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Payload of an {@link AI_VOICE_SESSION_EVENT_TYPE} event.
|
|
181
|
+
* @category AI
|
|
182
|
+
*/
|
|
183
|
+
export interface AiVoiceSessionEvent {
|
|
184
|
+
/** Which milestone this event reports. */
|
|
185
|
+
kind: AiVoiceSessionEventKind;
|
|
186
|
+
/** The session the event belongs to. */
|
|
187
|
+
sessionId: string;
|
|
188
|
+
/** The provider of the call. */
|
|
189
|
+
provider: AiVoiceRelayProvider;
|
|
190
|
+
/** The agent answering the call. */
|
|
191
|
+
agentId: AiAgentId;
|
|
192
|
+
/** The provider's id of the call, when known. */
|
|
193
|
+
externalCallId?: string;
|
|
194
|
+
/** The metadata given when the session was created. */
|
|
195
|
+
metadata?: Record<string, unknown>;
|
|
196
|
+
/** The completed turn; set only for `turn` events. */
|
|
197
|
+
turn?: AiVoiceSessionTurn;
|
|
198
|
+
/** Why the session ended; set only for `ended` events. */
|
|
199
|
+
endReason?: string;
|
|
200
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Backend related public types that should be available on the client SDK */
|
|
2
|
+
/** A type alias for a string that represents an AI function ID. */
|
|
3
|
+
export type AiFunctionId = string;
|
|
4
|
+
/** A type alias for a string that represents an AI functions configurator ID. */
|
|
5
|
+
export type AiFunctionsConfiguratorId = string;
|
|
6
|
+
/**
|
|
7
|
+
* A type alias for a service identifier.
|
|
8
|
+
* @category Queue
|
|
9
|
+
*/
|
|
10
|
+
export type TopicName = string;
|
|
11
|
+
/** A type alias for a service class name. */
|
|
12
|
+
export type ServiceName = string;
|
|
13
|
+
/** A type alias for a function name within a service. */
|
|
14
|
+
export type FunctionName = string;
|
|
15
|
+
/**
|
|
16
|
+
* Function name with contextual data, where the data must be serializable as JSON.
|
|
17
|
+
*/
|
|
18
|
+
export interface AiFunctionIdWithContext {
|
|
19
|
+
/**
|
|
20
|
+
* The ID of the AI function as described in the `@aiFunction` decorator.
|
|
21
|
+
* Historically named as 'name' because AI function name is the default value for 'ID'.
|
|
22
|
+
*/
|
|
23
|
+
name: AiFunctionId;
|
|
24
|
+
/** A record of contextual data associated with the function call. */
|
|
25
|
+
context?: Record<string, unknown>;
|
|
26
|
+
/** A list of predefined parameter values for the AI function. These parameters are hidden from the AI. */
|
|
27
|
+
predefinedParameters?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A combined service and function name in the format 'ServiceName:FunctionName'.
|
|
31
|
+
* Uniquely identifies a function within a service.
|
|
32
|
+
*/
|
|
33
|
+
export type ServiceFunctionName = `${ServiceName}:${FunctionName}`;
|
|
34
|
+
/**
|
|
35
|
+
* LLM model name for use in API calls, eg. "gpt-4o-mini".
|
|
36
|
+
*/
|
|
37
|
+
export type UserAiChatModelName = string;
|
|
38
|
+
/**
|
|
39
|
+
* Stats about a given LLM model.
|
|
40
|
+
*/
|
|
41
|
+
export type LlmModelMetadata = {
|
|
42
|
+
/**
|
|
43
|
+
* A friendly name for the model, to display in UIs.
|
|
44
|
+
*/
|
|
45
|
+
displayName: string;
|
|
46
|
+
/** Maximum tokens the model can generate in a single response. */
|
|
47
|
+
maxOutputTokens: number;
|
|
48
|
+
/** Total context window size: input (aka prompt) + output (aka completion) tokens combined. */
|
|
49
|
+
contextWindowTokens: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Stats about a given embedding model.
|
|
53
|
+
*/
|
|
54
|
+
export type EmbeddingModelMetadata = {
|
|
55
|
+
/** A friendly name for the model, to display in UIs. */
|
|
56
|
+
displayName: string;
|
|
57
|
+
/** The number of dimensions produced by this embedding model. */
|
|
58
|
+
dimensions: number;
|
|
59
|
+
/** Maximum input tokens per request. */
|
|
60
|
+
maxTokens: number;
|
|
61
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** A type alias for an application id. */
|
|
2
|
+
export type AppId = string;
|
|
3
|
+
/** A tuple of environment identifiers like 'dev' or 'prod'. */
|
|
4
|
+
export declare const ENVIRONMENT_IDS: readonly ["dev", "prod"];
|
|
5
|
+
/** A type representing valid environment identifiers derived from ENVIRONMENT_IDS. */
|
|
6
|
+
export type EnvironmentId = (typeof ENVIRONMENT_IDS)[number];
|
|
7
|
+
/** A type alias for a squid developer identifier. */
|
|
8
|
+
export type SquidDeveloperId = string;
|
|
9
|
+
/** A type alias for an integration id. */
|
|
10
|
+
export type IntegrationId = string;
|
|
11
|
+
/** A type alias for a client identifier. */
|
|
12
|
+
export type ClientId = string;
|
|
13
|
+
/** A type alias for a squid document identifier. */
|
|
14
|
+
export type SquidDocId = string;
|
|
15
|
+
/** A type alias for a client request identifier. */
|
|
16
|
+
export type ClientRequestId = string;
|
|
17
|
+
/** ID of AI agent. Also known as AI profile id. */
|
|
18
|
+
export type AiAgentId = string;
|
|
19
|
+
/** App-level ID of AI Knowledge Base */
|
|
20
|
+
export type AiKnowledgeBaseId = string;
|
|
21
|
+
/**
|
|
22
|
+
* The built-in agent id. Cannot be customized.
|
|
23
|
+
* @category AI
|
|
24
|
+
*/
|
|
25
|
+
export declare const BUILT_IN_AGENT_ID = "built_in_agent";
|
|
26
|
+
/**
|
|
27
|
+
* A type alias for an AI context identifier.
|
|
28
|
+
* @category AI
|
|
29
|
+
*/
|
|
30
|
+
export type AiContextId = string;
|