@signalhousellc/sdk 1.0.66 → 1.0.68
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/README.md +10 -0
- package/package.json +9 -2
- package/skills/signalhouse-10dlc/references/tcr-rejection-causes.md +4 -7
- package/src/SignalHouseSDK.js +27 -13
- package/src/domains/Agents.js +605 -0
- package/src/domains/Auth.js +30 -24
- package/src/domains/Billing.js +32 -26
- package/src/domains/Brands.js +45 -34
- package/src/domains/Campaigns.js +163 -62
- package/src/domains/Groups.js +53 -16
- package/src/domains/Landings.js +36 -30
- package/src/domains/Messages.js +126 -68
- package/src/domains/Notifications.js +12 -6
- package/src/domains/Numbers.js +85 -69
- package/src/domains/Onboarding.js +14 -8
- package/src/domains/Shortlinks.js +10 -4
- package/src/domains/Subgroups.js +16 -10
- package/src/domains/Subscriptions.js +22 -16
- package/src/domains/Tickets.js +18 -12
- package/src/domains/Users.js +26 -20
- package/src/domains/Webhooks.js +26 -11
- package/src/domains/voice/Analytics.js +8 -2
- package/src/domains/voice/CallLogs.js +14 -8
- package/src/domains/voice/Calls.js +14 -8
- package/src/domains/voice/GlobalVoiceSettings.js +10 -4
- package/src/domains/voice/ProgrammableVoiceProfiles.js +22 -16
- package/src/domains/voice/SipProfiles.js +24 -18
- package/src/domains/voice/SipTrunks.js +26 -20
- package/src/domains/voice/Tokens.js +10 -4
- package/src/domains/voice/browser/Call.js +2 -0
- package/src/domains/voice/browser/Device.js +23 -11
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} CreateAgentProfileData
|
|
9
|
+
* @property {string} groupId - The parent group id (at least 8 characters, starts with 'G').
|
|
10
|
+
* @property {string|null} [subgroupId] - Optional subgroup id (at least 8 characters, starts with 'S'); null/omitted = group-level agent.
|
|
11
|
+
* @property {string} name - The agent's name (required).
|
|
12
|
+
* @property {string} [status] - Lifecycle status: "active" or "inactive" (defaults to "active").
|
|
13
|
+
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
14
|
+
* @property {string} [greeting] - Opening line the agent leads with.
|
|
15
|
+
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} UpdateAgentProfileData
|
|
20
|
+
* @property {string} [name] - The agent's name.
|
|
21
|
+
* @property {string} [status] - Lifecycle status: "active" or "inactive".
|
|
22
|
+
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
23
|
+
* @property {string} [greeting] - Opening line the agent leads with.
|
|
24
|
+
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The per-channel settings for one agent. Model, voice and sampling settings live here rather
|
|
29
|
+
* than on the profile: each channel is served by a different runtime, and the model catalogues
|
|
30
|
+
* do not overlap — so a value that is valid on one channel may be invalid on another.
|
|
31
|
+
* @typedef {Object} AgentChannelSettingData
|
|
32
|
+
* @property {string[]} [allowedTools] - Tools enabled on this channel — built-in keys or custom agentTool ids.
|
|
33
|
+
* @property {boolean} [enabled] - Whether the agent answers on this channel.
|
|
34
|
+
* @property {string} [channelPrompt] - Channel-specific prompt text appended to the agent's system prompt.
|
|
35
|
+
* @property {string|null} [greeting] - Channel-specific greeting override; null = use the agent's greeting.
|
|
36
|
+
* @property {string} [llmProvider] - LLM backend for this channel: "bedrock", "openai", "anthropic", or "groq" (defaults to "bedrock").
|
|
37
|
+
* @property {string|null} [llmModel] - Concrete model id for the provider; null = provider default.
|
|
38
|
+
* @property {number} [temperature] - Sampling temperature (0-2).
|
|
39
|
+
* @property {string|null} [voiceId] - Voice identifier for spoken channels; ignored off the voice channel.
|
|
40
|
+
* @property {number|null} [speed] - Speaking rate multiplier (0.7-1.2); null = platform default.
|
|
41
|
+
* @property {number|null} [stability] - Voice consistency (0-1); lower is more expressive and more variable.
|
|
42
|
+
* @property {number|null} [similarityBoost] - How closely synthesis tracks the source voice (0-1).
|
|
43
|
+
* @property {string|null} [speechModel] - Speech synthesis model; separate from `llmModel`, which decides what is said rather than how it is voiced.
|
|
44
|
+
* @property {string|null} [turnEagerness] - How readily the agent decides the caller has finished: "patient", "normal", or "eager".
|
|
45
|
+
* @property {number|null} [turnTimeoutSeconds] - Silence before the agent takes its turn: 1-300, or -1 for no timeout.
|
|
46
|
+
* @property {number|null} [initialWaitSeconds] - Silence before the agent speaks first: 1-300, or -1 for no timeout.
|
|
47
|
+
* @property {number|null} [silenceEndCallSeconds] - Silence before the call is ended outright (10-7200).
|
|
48
|
+
* @property {number|null} [maxCallDurationSeconds] - Hard ceiling on one conversation (60-7200).
|
|
49
|
+
* @property {boolean} [allowGreetingInterruption] - Whether a caller may talk over the greeting.
|
|
50
|
+
* @property {string[]} [keyterms] - Words the transcriber is biased toward — names, jargon, unusual spellings.
|
|
51
|
+
* @property {Object|null} [backgroundSound] - Ambient audio bed as `{ preset, volume }`; null = silence.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
export class Agents {
|
|
55
|
+
constructor(client, enableAdmin) {
|
|
56
|
+
this.client = client;
|
|
57
|
+
this.enableAdmin = enableAdmin;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* List the voices an agent can be configured to speak with.
|
|
62
|
+
*
|
|
63
|
+
* The catalog is platform-wide, not per-account, so this takes no scope. `voiceId` is the
|
|
64
|
+
* value to set on a spoken channel's setting.
|
|
65
|
+
* @async
|
|
66
|
+
* @roles api, admin, developer, billing, user
|
|
67
|
+
* @param {Object} [params] - The parameters for the request.
|
|
68
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
69
|
+
* @returns {Promise<SdkResponse<any>>} - The available voices, each as `{ voiceId, name, description, previewUrl, gender, accent, age, useCase, language }`.
|
|
70
|
+
*/
|
|
71
|
+
async getAgentVoices({ options = {} } = {}) {
|
|
72
|
+
return this.client("/agent/voices", { method: "GET", ...options });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* List the agent profiles under a group.
|
|
77
|
+
* @async
|
|
78
|
+
* @roles api, admin, developer, billing, user
|
|
79
|
+
* @param {Object} params - The parameters for listing agent profiles.
|
|
80
|
+
* @param {string} params.groupId - The group whose profiles to list (required).
|
|
81
|
+
* @param {string} [params.subgroupId] - Narrow to the agents this subgroup can use — its own, plus the group-level agents shared with every subgroup.
|
|
82
|
+
* @param {number} [params.page] - The page number for pagination.
|
|
83
|
+
* @param {number} [params.limit] - The number of items per page for pagination.
|
|
84
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
85
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
86
|
+
* @returns {Promise<SdkResponse<any>>} - The list of agent profiles returned from the server.
|
|
87
|
+
*/
|
|
88
|
+
async getAgentProfiles({ groupId, subgroupId, page, limit, options = {} }) {
|
|
89
|
+
this.client._require({ groupId });
|
|
90
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, page, limit });
|
|
91
|
+
return this.client(`/agent/profiles${queryString}`, { method: "GET", ...options });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get a single agent profile by id.
|
|
96
|
+
* @async
|
|
97
|
+
* @roles api, admin, developer, billing, user
|
|
98
|
+
* @param {Object} params - The parameters for getting an agent profile.
|
|
99
|
+
* @param {string} params.agentProfileId - The id of the agent profile to fetch.
|
|
100
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
101
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
102
|
+
* @returns {Promise<SdkResponse<any>>} - The agent profile returned from the server.
|
|
103
|
+
*/
|
|
104
|
+
async getAgentProfile({ agentProfileId, options = {} }) {
|
|
105
|
+
this.client._require({ agentProfileId });
|
|
106
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
107
|
+
return this.client(`/agent/profiles/${safeId}`, { method: "GET", ...options });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Create a new agent profile.
|
|
112
|
+
* @async
|
|
113
|
+
* @roles api, admin, developer
|
|
114
|
+
* @param {Object} params - The parameters for creating an agent profile (see CreateAgentProfileData typedef).
|
|
115
|
+
* @param {CreateAgentProfileData} params.profileData - The data for the agent profile to create, including required fields groupId and name.
|
|
116
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
117
|
+
* @throws {Error} Throws an error if the profileData parameter is missing.
|
|
118
|
+
* @returns {Promise<SdkResponse<any>>} - The created agent profile returned from the server.
|
|
119
|
+
*/
|
|
120
|
+
async createAgentProfile({ profileData, options = {} }) {
|
|
121
|
+
this.client._require({ profileData });
|
|
122
|
+
return this.client(`/agent/profiles`, { method: "POST", body: profileData, ...options });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Update an existing agent profile.
|
|
127
|
+
* @async
|
|
128
|
+
* @roles api, admin, developer
|
|
129
|
+
* @param {Object} params - The parameters for updating an agent profile (see UpdateAgentProfileData typedef).
|
|
130
|
+
* @param {string} params.id - The id of the agent profile to update.
|
|
131
|
+
* @param {UpdateAgentProfileData} params.updateData - The data for the agent profile to update.
|
|
132
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
133
|
+
* @throws {Error} Throws an error if the id or updateData parameter is missing.
|
|
134
|
+
* @returns {Promise<SdkResponse<any>>} - The updated agent profile returned from the server.
|
|
135
|
+
*/
|
|
136
|
+
async updateAgentProfile({ id, updateData, options = {} }) {
|
|
137
|
+
this.client._require({ id, updateData });
|
|
138
|
+
const safeId = encodeURIComponent(id);
|
|
139
|
+
return this.client(`/agent/profiles/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Delete (inactivate) an agent profile by its id.
|
|
144
|
+
* @async
|
|
145
|
+
* @roles api, admin, developer
|
|
146
|
+
* @param {Object} params - The parameters for deleting an agent profile.
|
|
147
|
+
* @param {string} params.id - The id of the agent profile to delete.
|
|
148
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
149
|
+
* @throws {Error} Throws an error if the id parameter is missing.
|
|
150
|
+
* @returns {Promise<SdkResponse<any>>} - The inactivated agent profile returned from the server.
|
|
151
|
+
*/
|
|
152
|
+
async deleteAgentProfile({ id, options = {} }) {
|
|
153
|
+
this.client._require({ id });
|
|
154
|
+
const safeId = encodeURIComponent(id);
|
|
155
|
+
return this.client(`/agent/profiles/${safeId}`, { method: "DELETE", ...options });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Send a message to an agent and get its reply — the app-native conversation
|
|
160
|
+
* endpoint (webchat / SMS). Omit conversationId to start a new conversation, or
|
|
161
|
+
* pass one to continue an existing one. Runs the agent's LLM tool loop server-side
|
|
162
|
+
* and returns the assistant's reply along with any tools it invoked.
|
|
163
|
+
* @async
|
|
164
|
+
* @roles api, admin, developer, billing, user
|
|
165
|
+
* @param {Object} params - The parameters for sending a message.
|
|
166
|
+
* @param {string} params.agentProfileId - The agent to talk to (required).
|
|
167
|
+
* @param {string} params.channel - The channel: "webchat", "sms", or "voice" (required).
|
|
168
|
+
* @param {string} params.message - The user's message (required).
|
|
169
|
+
* @param {string} [params.conversationId] - Continue this conversation; omit to start a new one.
|
|
170
|
+
* @param {string} [params.contactIdentifier] - The far-end identifier (webchat visitor id, sender number).
|
|
171
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
172
|
+
* @throws {Error} Throws an error if agentProfileId, channel, or message is missing.
|
|
173
|
+
* @returns {Promise<SdkResponse<any>>} - `{ conversationId, conversationSessionId, reply, toolInvocations, ok }` from the server.
|
|
174
|
+
*/
|
|
175
|
+
async sendAgentMessage({ agentProfileId, channel, message, conversationId, contactIdentifier, options = {} }) {
|
|
176
|
+
this.client._require({ agentProfileId, channel, message });
|
|
177
|
+
const body = { agentProfileId, channel, message };
|
|
178
|
+
if (conversationId !== undefined && conversationId !== null) body.conversationId = conversationId;
|
|
179
|
+
if (contactIdentifier !== undefined && contactIdentifier !== null) body.contactIdentifier = contactIdentifier;
|
|
180
|
+
return this.client(`/agent/messages`, { method: "POST", body, ...options });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Start a conversation without sending a message.
|
|
185
|
+
*
|
|
186
|
+
* The counterpart to `sendAgentMessage` for callers that run the model themselves —
|
|
187
|
+
* a voice runtime, or your own LLM. Those record what was said; `sendAgentMessage`
|
|
188
|
+
* decides it. Both write the same conversation records.
|
|
189
|
+
* @async
|
|
190
|
+
* @roles api, admin, developer, billing, user
|
|
191
|
+
* @param {Object} params - The parameters for starting a conversation.
|
|
192
|
+
* @param {string} params.agentProfileId - The agent this conversation belongs to (required).
|
|
193
|
+
* @param {string} params.channel - The channel: "webchat", "sms", or "voice" (required).
|
|
194
|
+
* @param {string} [params.contactIdentifier] - The far-end identifier (visitor id, caller number).
|
|
195
|
+
* @param {string} [params.callId] - Telephony call id, for the voice channel.
|
|
196
|
+
* @param {Object} [params.metadata] - Arbitrary metadata stored with the conversation.
|
|
197
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request.
|
|
198
|
+
* @throws {Error} Throws an error if agentProfileId or channel is missing.
|
|
199
|
+
* @returns {Promise<Object>} - The created conversation, including `conversationId` and `conversationSessionId`.
|
|
200
|
+
*/
|
|
201
|
+
async startConversation({ agentProfileId, channel, contactIdentifier, callId, metadata, options = {} }) {
|
|
202
|
+
this.client._require({ agentProfileId, channel });
|
|
203
|
+
const body = { agentProfileId, channel };
|
|
204
|
+
if (contactIdentifier !== undefined && contactIdentifier !== null) body.contactIdentifier = contactIdentifier;
|
|
205
|
+
if (callId !== undefined && callId !== null) body.callId = callId;
|
|
206
|
+
if (metadata !== undefined && metadata !== null) body.metadata = metadata;
|
|
207
|
+
return this.client(`/agent/conversations`, { method: "POST", body, ...options });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Read one conversation with a page of its messages, in order.
|
|
212
|
+
*
|
|
213
|
+
* Paged rather than whole: a transcript has no natural ceiling. Omitting `limit` gives 100
|
|
214
|
+
* messages, not all of them.
|
|
215
|
+
* @async
|
|
216
|
+
* @roles api, admin, developer, billing, user
|
|
217
|
+
* @param {Object} params - The parameters for reading a conversation.
|
|
218
|
+
* @param {string} params.conversationId - The conversation to read (required).
|
|
219
|
+
* @param {number} [params.page] - Page number; defaults to 1.
|
|
220
|
+
* @param {number} [params.limit] - Messages per page; defaults to 100, capped at 500.
|
|
221
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request.
|
|
222
|
+
* @throws {Error} Throws an error if the conversationId parameter is missing.
|
|
223
|
+
* @returns {Promise<Object>} - A one-element array with the conversation and its `messages`.
|
|
224
|
+
*/
|
|
225
|
+
async getConversation({ conversationId, page, limit, options = {} }) {
|
|
226
|
+
this.client._require({ conversationId });
|
|
227
|
+
const safeId = encodeURIComponent(conversationId);
|
|
228
|
+
const queryString = this.client._getQueryString({ page, limit });
|
|
229
|
+
return this.client(`/agent/conversations/${safeId}${queryString}`, { method: "GET", ...options });
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Append one message to a conversation.
|
|
234
|
+
*
|
|
235
|
+
* Records a turn rather than generating one, so `role` is explicit — an assistant turn
|
|
236
|
+
* your own runtime produced is the normal case here. `content` is optional so a
|
|
237
|
+
* tool-only turn needs no prose.
|
|
238
|
+
* @async
|
|
239
|
+
* @roles api, admin, developer, billing, user
|
|
240
|
+
* @param {Object} params - The parameters for appending a message.
|
|
241
|
+
* @param {string} params.conversationId - The conversation to append to (required).
|
|
242
|
+
* @param {string} params.role - "user", "assistant", "system", or "tool" (required).
|
|
243
|
+
* @param {string} [params.content] - What was said.
|
|
244
|
+
* @param {Array<Object>} [params.toolCalls] - Tools invoked on this turn.
|
|
245
|
+
* @param {Array<Object>} [params.toolResults] - Their results.
|
|
246
|
+
* @param {number} [params.ttfbMs] - Time to first byte/audio, in milliseconds.
|
|
247
|
+
* @param {number} [params.latencyMs] - Total turn latency, in milliseconds.
|
|
248
|
+
* @param {boolean} [params.bargeInOccurred] - Whether the far end talked over this turn.
|
|
249
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request.
|
|
250
|
+
* @throws {Error} Throws an error if conversationId or role is missing.
|
|
251
|
+
* @returns {Promise<Object>} - The persisted message.
|
|
252
|
+
*/
|
|
253
|
+
async appendConversationMessage({ conversationId, role, content, toolCalls, toolResults, ttfbMs, latencyMs, bargeInOccurred, options = {} }) {
|
|
254
|
+
this.client._require({ conversationId, role });
|
|
255
|
+
const safeId = encodeURIComponent(conversationId);
|
|
256
|
+
const body = { role };
|
|
257
|
+
if (content !== undefined && content !== null) body.content = content;
|
|
258
|
+
if (toolCalls !== undefined && toolCalls !== null) body.toolCalls = toolCalls;
|
|
259
|
+
if (toolResults !== undefined && toolResults !== null) body.toolResults = toolResults;
|
|
260
|
+
if (ttfbMs !== undefined && ttfbMs !== null) body.ttfbMs = ttfbMs;
|
|
261
|
+
if (latencyMs !== undefined && latencyMs !== null) body.latencyMs = latencyMs;
|
|
262
|
+
if (bargeInOccurred !== undefined && bargeInOccurred !== null) body.bargeInOccurred = bargeInOccurred;
|
|
263
|
+
return this.client(`/agent/conversations/${safeId}/messages`, { method: "POST", body, ...options });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* End a conversation, closing its open session.
|
|
268
|
+
*
|
|
269
|
+
* `status` records HOW it ended and cannot be recovered afterwards, so pass the one that
|
|
270
|
+
* actually happened. Ending an already-ended conversation is a no-op, so a retry after a
|
|
271
|
+
* dropped connection cannot overwrite it.
|
|
272
|
+
* @async
|
|
273
|
+
* @roles api, admin, developer, billing, user
|
|
274
|
+
* @param {Object} params - The parameters for ending a conversation.
|
|
275
|
+
* @param {string} params.conversationId - The conversation to end (required).
|
|
276
|
+
* @param {string} [params.status] - "completed", "escalated", or "abandoned" (defaults to "completed").
|
|
277
|
+
* @param {Object} [params.metadata] - Metadata merged onto the conversation.
|
|
278
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request.
|
|
279
|
+
* @throws {Error} Throws an error if the conversationId parameter is missing.
|
|
280
|
+
* @returns {Promise<Object>} - The ended conversation.
|
|
281
|
+
*/
|
|
282
|
+
async endConversation({ conversationId, status, metadata, options = {} }) {
|
|
283
|
+
this.client._require({ conversationId });
|
|
284
|
+
const safeId = encodeURIComponent(conversationId);
|
|
285
|
+
const body = {};
|
|
286
|
+
if (status !== undefined && status !== null) body.status = status;
|
|
287
|
+
if (metadata !== undefined && metadata !== null) body.metadata = metadata;
|
|
288
|
+
return this.client(`/agent/conversations/${safeId}`, { method: "PUT", body, ...options });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* List an agent's per-channel settings (the tools enabled per channel, whether the
|
|
293
|
+
* channel is on, and any channel-specific prompt/greeting).
|
|
294
|
+
* @async
|
|
295
|
+
* @roles api, admin, developer, billing, user
|
|
296
|
+
* @param {Object} params - The parameters for listing channel settings.
|
|
297
|
+
* @param {string} params.agentProfileId - The agent whose channel settings to list.
|
|
298
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
299
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
300
|
+
* @returns {Promise<SdkResponse<any>>} - The agent's channel settings returned from the server.
|
|
301
|
+
*/
|
|
302
|
+
async getAgentChannelSettings({ agentProfileId, options = {} }) {
|
|
303
|
+
this.client._require({ agentProfileId });
|
|
304
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
305
|
+
return this.client(`/agent/profiles/${safeId}/channels`, { method: "GET", ...options });
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Get a single per-channel setting for an agent.
|
|
310
|
+
* @async
|
|
311
|
+
* @roles api, admin, developer, billing, user
|
|
312
|
+
* @param {Object} params - The parameters for getting a channel setting.
|
|
313
|
+
* @param {string} params.agentProfileId - The agent the setting belongs to.
|
|
314
|
+
* @param {string} params.channel - The channel: "webchat", "sms", or "voice".
|
|
315
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
316
|
+
* @throws {Error} Throws an error if agentProfileId or channel is missing.
|
|
317
|
+
* @returns {Promise<SdkResponse<any>>} - The channel setting returned from the server.
|
|
318
|
+
*/
|
|
319
|
+
async getAgentChannelSetting({ agentProfileId, channel, options = {} }) {
|
|
320
|
+
this.client._require({ agentProfileId, channel });
|
|
321
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
322
|
+
const safeChannel = encodeURIComponent(channel);
|
|
323
|
+
return this.client(`/agent/profiles/${safeId}/channels/${safeChannel}`, { method: "GET", ...options });
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Create or update (upsert) an agent's per-channel setting. One row per (agent, channel);
|
|
328
|
+
* the channel is taken from the path, the fields from settingData.
|
|
329
|
+
* @async
|
|
330
|
+
* @roles api, admin, developer
|
|
331
|
+
* @param {Object} params - The parameters for the upsert.
|
|
332
|
+
* @param {string} params.agentProfileId - The agent the setting belongs to.
|
|
333
|
+
* @param {string} params.channel - The channel: "webchat", "sms", or "voice".
|
|
334
|
+
* @param {AgentChannelSettingData} [params.settingData] - The fields to set.
|
|
335
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
336
|
+
* @throws {Error} Throws an error if agentProfileId or channel is missing.
|
|
337
|
+
* @returns {Promise<SdkResponse<any>>} - The created or updated channel setting returned from the server.
|
|
338
|
+
*/
|
|
339
|
+
async upsertAgentChannelSetting({ agentProfileId, channel, settingData = {}, options = {} }) {
|
|
340
|
+
this.client._require({ agentProfileId, channel });
|
|
341
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
342
|
+
const safeChannel = encodeURIComponent(channel);
|
|
343
|
+
return this.client(`/agent/profiles/${safeId}/channels/${safeChannel}`, { method: "PUT", body: settingData, ...options });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Delete an agent's per-channel setting.
|
|
348
|
+
* @async
|
|
349
|
+
* @roles api, admin, developer
|
|
350
|
+
* @param {Object} params - The parameters for the delete.
|
|
351
|
+
* @param {string} params.agentProfileId - The agent the setting belongs to.
|
|
352
|
+
* @param {string} params.channel - The channel: "webchat", "sms", or "voice".
|
|
353
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
354
|
+
* @throws {Error} Throws an error if agentProfileId or channel is missing.
|
|
355
|
+
* @returns {Promise<SdkResponse<any>>} - The delete confirmation returned from the server.
|
|
356
|
+
*/
|
|
357
|
+
async deleteAgentChannelSetting({ agentProfileId, channel, options = {} }) {
|
|
358
|
+
this.client._require({ agentProfileId, channel });
|
|
359
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
360
|
+
const safeChannel = encodeURIComponent(channel);
|
|
361
|
+
return this.client(`/agent/profiles/${safeId}/channels/${safeChannel}`, { method: "DELETE", ...options });
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Read the tenant AI settings for a scope (group, or a subgroup within it) — brand, tone,
|
|
366
|
+
* timezone, business hours, and after-hours message. Returns the scope's own row only (no
|
|
367
|
+
* group-level fallback).
|
|
368
|
+
* @async
|
|
369
|
+
* @roles api, admin, developer, billing, user
|
|
370
|
+
* @param {Object} params - The parameters for reading tenant settings.
|
|
371
|
+
* @param {string} params.groupId - The group (required).
|
|
372
|
+
* @param {string} [params.subgroupId] - The subgroup; omit for the group-level settings.
|
|
373
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
374
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
375
|
+
* @returns {Promise<SdkResponse<any>>} - The tenant settings returned from the server.
|
|
376
|
+
*/
|
|
377
|
+
async getTenantAiSettings({ groupId, subgroupId, options = {} }) {
|
|
378
|
+
this.client._require({ groupId });
|
|
379
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId });
|
|
380
|
+
return this.client(`/agent/tenant-settings${queryString}`, { method: "GET", ...options });
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Create or update (upsert) the tenant AI settings for a scope. The scope is identified by
|
|
385
|
+
* the query params; the body carries the settings fields.
|
|
386
|
+
* @async
|
|
387
|
+
* @roles api, admin, developer
|
|
388
|
+
* @param {Object} params - The parameters for the upsert.
|
|
389
|
+
* @param {string} params.groupId - The group (required).
|
|
390
|
+
* @param {string} [params.subgroupId] - The subgroup; omit for the group-level settings.
|
|
391
|
+
* @param {Object} [params.settingsData] - Fields to set: brandName (string), tone (string), timezone (IANA string), businessHours (array of {day, closed, open, close}), afterHoursMessage (string).
|
|
392
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
393
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
394
|
+
* @returns {Promise<SdkResponse<any>>} - The created or updated tenant settings returned from the server.
|
|
395
|
+
*/
|
|
396
|
+
async upsertTenantAiSettings({ groupId, subgroupId, settingsData = {}, options = {} }) {
|
|
397
|
+
this.client._require({ groupId });
|
|
398
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId });
|
|
399
|
+
return this.client(`/agent/tenant-settings${queryString}`, { method: "PUT", body: settingsData, ...options });
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Delete the tenant AI settings for a scope.
|
|
404
|
+
* @async
|
|
405
|
+
* @roles api, admin, developer
|
|
406
|
+
* @param {Object} params - The parameters for the delete.
|
|
407
|
+
* @param {string} params.groupId - The group (required).
|
|
408
|
+
* @param {string} [params.subgroupId] - The subgroup; omit for the group-level settings.
|
|
409
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
410
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
411
|
+
* @returns {Promise<SdkResponse<any>>} - The delete confirmation returned from the server.
|
|
412
|
+
*/
|
|
413
|
+
async deleteTenantAiSettings({ groupId, subgroupId, options = {} }) {
|
|
414
|
+
this.client._require({ groupId });
|
|
415
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId });
|
|
416
|
+
return this.client(`/agent/tenant-settings${queryString}`, { method: "DELETE", ...options });
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* List the knowledge-base items an agent can answer from (RAG), scoped to a group and
|
|
421
|
+
* optionally narrowed to a subgroup and/or a single agent.
|
|
422
|
+
* @async
|
|
423
|
+
* @roles api, admin, developer, billing, user
|
|
424
|
+
* @param {Object} params - The parameters for listing knowledge items.
|
|
425
|
+
* @param {string} params.groupId - The group whose knowledge to list (required).
|
|
426
|
+
* @param {string} [params.subgroupId] - Narrow to a subgroup.
|
|
427
|
+
* @param {string} [params.agentProfileId] - Narrow to one agent.
|
|
428
|
+
* @param {number} [params.page] - Page number (1-based) for pagination.
|
|
429
|
+
* @param {number} [params.limit] - Items per page (max 100; server default 25).
|
|
430
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
431
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
432
|
+
* @returns {Promise<SdkResponse<any>>} - The knowledge items returned from the server.
|
|
433
|
+
*/
|
|
434
|
+
async getKnowledgeItems({ groupId, subgroupId, agentProfileId, page, limit, options = {} }) {
|
|
435
|
+
this.client._require({ groupId });
|
|
436
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, agentProfileId, page, limit });
|
|
437
|
+
return this.client(`/agent/knowledge${queryString}`, { method: "GET", ...options });
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Get a single knowledge item by id.
|
|
442
|
+
* @async
|
|
443
|
+
* @roles api, admin, developer, billing, user
|
|
444
|
+
* @param {Object} params - The parameters for getting a knowledge item.
|
|
445
|
+
* @param {string} params.knowledgeItemId - The id of the knowledge item to fetch.
|
|
446
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
447
|
+
* @throws {Error} Throws an error if the knowledgeItemId parameter is missing.
|
|
448
|
+
* @returns {Promise<SdkResponse<any>>} - The knowledge item returned from the server.
|
|
449
|
+
*/
|
|
450
|
+
async getKnowledgeItem({ knowledgeItemId, options = {} }) {
|
|
451
|
+
this.client._require({ knowledgeItemId });
|
|
452
|
+
const safeId = encodeURIComponent(knowledgeItemId);
|
|
453
|
+
return this.client(`/agent/knowledge/${safeId}`, { method: "GET", ...options });
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Create a knowledge item. The raw `text` is stored and Atlas Vector Search owns the
|
|
458
|
+
* embedding — there is no embedding to supply.
|
|
459
|
+
* @async
|
|
460
|
+
* @roles api, admin, developer
|
|
461
|
+
* @param {Object} params - The parameters for creating a knowledge item.
|
|
462
|
+
* @param {Object} params.itemData - The knowledge fields. Required: groupId (starts with 'G'), text.
|
|
463
|
+
* Optional: subgroupId (starts with 'S', nullable), agentProfileId
|
|
464
|
+
* (nullable = shared across the tenant's agents), title, source
|
|
465
|
+
* ("manual" | "url" | "document" | "import"), enabled (boolean), metadata (object|null).
|
|
466
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
467
|
+
* @throws {Error} Throws an error if the itemData parameter is missing.
|
|
468
|
+
* @returns {Promise<SdkResponse<any>>} - The created knowledge item returned from the server.
|
|
469
|
+
*/
|
|
470
|
+
async createKnowledgeItem({ itemData, options = {} }) {
|
|
471
|
+
this.client._require({ itemData });
|
|
472
|
+
return this.client(`/agent/knowledge`, { method: "POST", body: itemData, ...options });
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Update a knowledge item. The item's scope (group/subgroup/agent) is immutable and
|
|
477
|
+
* cannot be changed.
|
|
478
|
+
* @async
|
|
479
|
+
* @roles api, admin, developer
|
|
480
|
+
* @param {Object} params - The parameters for updating a knowledge item.
|
|
481
|
+
* @param {string} params.id - The id of the knowledge item to update.
|
|
482
|
+
* @param {Object} params.updateData - The fields to update: title, text, source, enabled, metadata.
|
|
483
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
484
|
+
* @throws {Error} Throws an error if the id or updateData parameter is missing.
|
|
485
|
+
* @returns {Promise<SdkResponse<any>>} - The updated knowledge item returned from the server.
|
|
486
|
+
*/
|
|
487
|
+
async updateKnowledgeItem({ id, updateData, options = {} }) {
|
|
488
|
+
this.client._require({ id, updateData });
|
|
489
|
+
const safeId = encodeURIComponent(id);
|
|
490
|
+
return this.client(`/agent/knowledge/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Delete a knowledge item by its id.
|
|
495
|
+
* @async
|
|
496
|
+
* @roles api, admin, developer
|
|
497
|
+
* @param {Object} params - The parameters for deleting a knowledge item.
|
|
498
|
+
* @param {string} params.id - The id of the knowledge item to delete.
|
|
499
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
500
|
+
* @throws {Error} Throws an error if the id parameter is missing.
|
|
501
|
+
* @returns {Promise<SdkResponse<any>>} - The delete confirmation returned from the server.
|
|
502
|
+
*/
|
|
503
|
+
async deleteKnowledgeItem({ id, options = {} }) {
|
|
504
|
+
this.client._require({ id });
|
|
505
|
+
const safeId = encodeURIComponent(id);
|
|
506
|
+
return this.client(`/agent/knowledge/${safeId}`, { method: "DELETE", ...options });
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* List the tools defined under a group — custom webhook tools, configured built-ins, and
|
|
511
|
+
* (future) MCP. `webhookAuth` secrets are redacted in the response.
|
|
512
|
+
* @async
|
|
513
|
+
* @roles api, admin, developer, billing, user
|
|
514
|
+
* @param {Object} params - The parameters for listing tools.
|
|
515
|
+
* @param {string} params.groupId - The group whose tools to list (required).
|
|
516
|
+
* @param {string} [params.subgroupId] - Narrow to a subgroup.
|
|
517
|
+
* @param {string} [params.agentProfileId] - Narrow to one agent.
|
|
518
|
+
* @param {string} [params.type] - Narrow to a tool type: "builtin", "webhook", or "mcp".
|
|
519
|
+
* @param {number} [params.page] - Page number (1-based) for pagination.
|
|
520
|
+
* @param {number} [params.limit] - Items per page (max 100; server default 25).
|
|
521
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
522
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
523
|
+
* @returns {Promise<SdkResponse<any>>} - The tools returned from the server (secrets redacted).
|
|
524
|
+
*/
|
|
525
|
+
async getAgentTools({ groupId, subgroupId, agentProfileId, type, page, limit, options = {} }) {
|
|
526
|
+
this.client._require({ groupId });
|
|
527
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, agentProfileId, type, page, limit });
|
|
528
|
+
return this.client(`/agent/tools${queryString}`, { method: "GET", ...options });
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Get a single agent tool by id. `webhookAuth` secrets are redacted in the response.
|
|
533
|
+
* @async
|
|
534
|
+
* @roles api, admin, developer, billing, user
|
|
535
|
+
* @param {Object} params - The parameters for getting a tool.
|
|
536
|
+
* @param {string} params.agentToolId - The id of the tool to fetch.
|
|
537
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
538
|
+
* @throws {Error} Throws an error if the agentToolId parameter is missing.
|
|
539
|
+
* @returns {Promise<SdkResponse<any>>} - The tool returned from the server (secrets redacted).
|
|
540
|
+
*/
|
|
541
|
+
async getAgentTool({ agentToolId, options = {} }) {
|
|
542
|
+
this.client._require({ agentToolId });
|
|
543
|
+
const safeId = encodeURIComponent(agentToolId);
|
|
544
|
+
return this.client(`/agent/tools/${safeId}`, { method: "GET", ...options });
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Create an agent tool. For a webhook tool, `webhookUrl` must be an https URL that does not
|
|
549
|
+
* target a private/internal address (rejected otherwise). `webhookAuth` is stored and never
|
|
550
|
+
* echoed back.
|
|
551
|
+
* @async
|
|
552
|
+
* @roles api, admin, developer
|
|
553
|
+
* @param {Object} params - The parameters for creating a tool.
|
|
554
|
+
* @param {Object} params.toolData - The tool fields. Required: groupId (starts with 'G'), name, description.
|
|
555
|
+
* Type-specific: type ("builtin" | "webhook" | "mcp"); webhook → webhookUrl, builtin →
|
|
556
|
+
* builtinKey, mcp → mcpServerUrl. Optional: subgroupId, agentProfileId (nullable = shared),
|
|
557
|
+
* parametersSchema, config, channels (string[]), enabled (boolean), and webhookAuth —
|
|
558
|
+
* which MUST be `{ headers?: { [name]: value }, signingSecret?: string }` (any other shape,
|
|
559
|
+
* e.g. `{ header, value }`, is rejected with a 400). `headers` are sent verbatim on every
|
|
560
|
+
* call (reserved/framing and `x-signalhouse-*` names are rejected); `signingSecret` makes us
|
|
561
|
+
* send `X-SignalHouse-Signature: sha256=HMAC-SHA256(`${X-SignalHouse-Timestamp}.${rawBody}`)`
|
|
562
|
+
* so you can verify the call and reject replays. Stored, never returned.
|
|
563
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
564
|
+
* @throws {Error} Throws an error if the toolData parameter is missing.
|
|
565
|
+
* @returns {Promise<SdkResponse<any>>} - The created tool returned from the server (secrets redacted).
|
|
566
|
+
*/
|
|
567
|
+
async createAgentTool({ toolData, options = {} }) {
|
|
568
|
+
this.client._require({ toolData });
|
|
569
|
+
return this.client(`/agent/tools`, { method: "POST", body: toolData, ...options });
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Update an agent tool. The tool's scope (group/subgroup/agent) is immutable. A supplied
|
|
574
|
+
* `webhookUrl` is SSRF-checked.
|
|
575
|
+
* @async
|
|
576
|
+
* @roles api, admin, developer
|
|
577
|
+
* @param {Object} params - The parameters for updating a tool.
|
|
578
|
+
* @param {string} params.id - The id of the tool to update.
|
|
579
|
+
* @param {Object} params.updateData - The fields to update: name, description, type, builtinKey, parametersSchema, config, webhookUrl, webhookAuth, mcpServerUrl, channels, enabled.
|
|
580
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
581
|
+
* @throws {Error} Throws an error if the id or updateData parameter is missing.
|
|
582
|
+
* @returns {Promise<SdkResponse<any>>} - The updated tool returned from the server (secrets redacted).
|
|
583
|
+
*/
|
|
584
|
+
async updateAgentTool({ id, updateData, options = {} }) {
|
|
585
|
+
this.client._require({ id, updateData });
|
|
586
|
+
const safeId = encodeURIComponent(id);
|
|
587
|
+
return this.client(`/agent/tools/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Delete an agent tool by its id.
|
|
592
|
+
* @async
|
|
593
|
+
* @roles api, admin, developer
|
|
594
|
+
* @param {Object} params - The parameters for deleting a tool.
|
|
595
|
+
* @param {string} params.id - The id of the tool to delete.
|
|
596
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
597
|
+
* @throws {Error} Throws an error if the id parameter is missing.
|
|
598
|
+
* @returns {Promise<SdkResponse<any>>} - The delete confirmation returned from the server.
|
|
599
|
+
*/
|
|
600
|
+
async deleteAgentTool({ id, options = {} }) {
|
|
601
|
+
this.client._require({ id });
|
|
602
|
+
const safeId = encodeURIComponent(id);
|
|
603
|
+
return this.client(`/agent/tools/${safeId}`, { method: "DELETE", ...options });
|
|
604
|
+
}
|
|
605
|
+
}
|