@unboundcx/sdk 2.8.7 → 2.8.10

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/index.js CHANGED
@@ -25,6 +25,8 @@ import { RecordTypesService } from './services/recordTypes.js';
25
25
  import { GenerateIdService } from './services/generateId.js';
26
26
  import { EngagementMetricsService } from './services/engagementMetrics.js';
27
27
  import { TaskRouterService } from './services/taskRouter.js';
28
+ import { KnowledgeBaseService } from './services/knowledgeBase.js';
29
+ import { FaxService } from './services/fax.js';
28
30
 
29
31
  class UnboundSDK extends BaseSDK {
30
32
  constructor(options = {}) {
@@ -91,6 +93,8 @@ class UnboundSDK extends BaseSDK {
91
93
  this.generateId = new GenerateIdService(this);
92
94
  this.engagementMetrics = new EngagementMetricsService(this);
93
95
  this.taskRouter = new TaskRouterService(this);
96
+ this.knowledgeBase = new KnowledgeBaseService(this);
97
+ this.fax = new FaxService(this);
94
98
 
95
99
  // Add additional services that might be missing
96
100
  this._initializeAdditionalServices();
@@ -268,4 +272,6 @@ export { GenerateIdService } from './services/generateId.js';
268
272
  export { EngagementMetricsService } from './services/engagementMetrics.js';
269
273
  export { TaskRouterService } from './services/taskRouter.js';
270
274
  export { WorkerService } from './services/taskRouter/WorkerService.js';
275
+ export { KnowledgeBaseService } from './services/knowledgeBase.js';
276
+ export { FaxService } from './services/fax.js';
271
277
  export { BaseSDK } from './base.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.8.7",
3
+ "version": "2.8.10",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -88,4 +88,4 @@
88
88
  "registry": "https://registry.npmjs.org/",
89
89
  "access": "public"
90
90
  }
91
- }
91
+ }
@@ -199,6 +199,8 @@ export class PlaybooksService {
199
199
  scoreType,
200
200
  weight,
201
201
  requiredForPass,
202
+ role,
203
+ signal,
202
204
  recordTypeId,
203
205
  }) {
204
206
  this.sdk.validateParams(
@@ -211,6 +213,8 @@ export class PlaybooksService {
211
213
  scoreType,
212
214
  weight,
213
215
  requiredForPass,
216
+ role,
217
+ signal,
214
218
  recordTypeId,
215
219
  },
216
220
  {
@@ -222,6 +226,8 @@ export class PlaybooksService {
222
226
  scoreType: { type: 'string', required: false },
223
227
  weight: { type: 'number', required: false },
224
228
  requiredForPass: { type: 'boolean', required: false },
229
+ role: { type: 'string', required: false },
230
+ signal: { type: 'string', required: false },
225
231
  recordTypeId: { type: 'string', required: false },
226
232
  },
227
233
  );
@@ -235,6 +241,8 @@ export class PlaybooksService {
235
241
  scoreType,
236
242
  weight,
237
243
  requiredForPass,
244
+ role,
245
+ signal,
238
246
  recordTypeId,
239
247
  },
240
248
  };
@@ -334,6 +342,8 @@ export class PlaybooksService {
334
342
  scoreType,
335
343
  weight,
336
344
  requiredForPass,
345
+ role,
346
+ signal,
337
347
  recordTypeId,
338
348
  }) {
339
349
  this.sdk.validateParams(
@@ -346,6 +356,8 @@ export class PlaybooksService {
346
356
  scoreType,
347
357
  weight,
348
358
  requiredForPass,
359
+ role,
360
+ signal,
349
361
  recordTypeId,
350
362
  },
351
363
  {
@@ -357,6 +369,8 @@ export class PlaybooksService {
357
369
  scoreType: { type: 'string', required: false },
358
370
  weight: { type: 'number', required: false },
359
371
  requiredForPass: { type: 'boolean', required: false },
372
+ role: { type: 'string', required: false },
373
+ signal: { type: 'string', required: false },
360
374
  recordTypeId: { type: 'string', required: false },
361
375
  },
362
376
  );
@@ -370,6 +384,8 @@ export class PlaybooksService {
370
384
  scoreType,
371
385
  weight,
372
386
  requiredForPass,
387
+ role,
388
+ signal,
373
389
  recordTypeId,
374
390
  },
375
391
  };
@@ -474,6 +490,8 @@ export class PlaybooksService {
474
490
  description,
475
491
  keywords,
476
492
  recommendedPhase,
493
+ role,
494
+ signal,
477
495
  recordTypeId,
478
496
  }) {
479
497
  this.sdk.validateParams(
@@ -483,12 +501,14 @@ export class PlaybooksService {
483
501
  description: { type: 'string', required: false },
484
502
  keywords: { type: 'array', required: false },
485
503
  recommendedPhase: { type: 'string', required: false },
504
+ role: { type: 'string', required: false },
505
+ signal: { type: 'string', required: false },
486
506
  recordTypeId: { type: 'string', required: false },
487
507
  },
488
508
  );
489
509
 
490
510
  const params = {
491
- body: { name, description, keywords, recommendedPhase, recordTypeId },
511
+ body: { name, description, keywords, recommendedPhase, role, signal, recordTypeId },
492
512
  };
493
513
 
494
514
  const result = await this.sdk._fetch(
@@ -587,6 +607,8 @@ export class PlaybooksService {
587
607
  description,
588
608
  keywords,
589
609
  recommendedPhase,
610
+ role,
611
+ signal,
590
612
  recordTypeId,
591
613
  }) {
592
614
  this.sdk.validateParams(
@@ -597,12 +619,14 @@ export class PlaybooksService {
597
619
  description: { type: 'string', required: false },
598
620
  keywords: { type: 'array', required: false },
599
621
  recommendedPhase: { type: 'string', required: false },
622
+ role: { type: 'string', required: false },
623
+ signal: { type: 'string', required: false },
600
624
  recordTypeId: { type: 'string', required: false },
601
625
  },
602
626
  );
603
627
 
604
628
  const params = {
605
- body: { name, description, keywords, recommendedPhase, recordTypeId },
629
+ body: { name, description, keywords, recommendedPhase, role, signal, recordTypeId },
606
630
  };
607
631
 
608
632
  const result = await this.sdk._fetch(
@@ -828,6 +852,9 @@ export class PlaybooksService {
828
852
  totalScore,
829
853
  achievedGoals,
830
854
  totalGoals,
855
+ customerTotalScore,
856
+ customerAchievedGoals,
857
+ customerTotalGoals,
831
858
  }) {
832
859
  this.sdk.validateParams(
833
860
  { sessionId },
@@ -837,6 +864,9 @@ export class PlaybooksService {
837
864
  totalScore: { type: 'number', required: false },
838
865
  achievedGoals: { type: 'number', required: false },
839
866
  totalGoals: { type: 'number', required: false },
867
+ customerTotalScore: { type: 'number', required: false },
868
+ customerAchievedGoals: { type: 'number', required: false },
869
+ customerTotalGoals: { type: 'number', required: false },
840
870
  },
841
871
  );
842
872
 
@@ -846,6 +876,9 @@ export class PlaybooksService {
846
876
  totalScore,
847
877
  achievedGoals,
848
878
  totalGoals,
879
+ customerTotalScore,
880
+ customerAchievedGoals,
881
+ customerTotalGoals,
849
882
  },
850
883
  };
851
884
 
@@ -923,6 +956,7 @@ export class PlaybooksService {
923
956
  reason,
924
957
  confidence,
925
958
  evidence,
959
+ role,
926
960
  }) {
927
961
  this.sdk.validateParams(
928
962
  { sessionId, goalId },
@@ -934,6 +968,7 @@ export class PlaybooksService {
934
968
  reason: { type: 'string', required: false },
935
969
  confidence: { type: 'number', required: false },
936
970
  evidence: { type: 'array', required: false },
971
+ role: { type: 'string', required: false },
937
972
  },
938
973
  );
939
974
 
@@ -945,6 +980,7 @@ export class PlaybooksService {
945
980
  reason,
946
981
  confidence,
947
982
  evidence,
983
+ role,
948
984
  },
949
985
  };
950
986
 
package/services/ai.js CHANGED
@@ -20,39 +20,81 @@ export class GenerativeService {
20
20
  prompt,
21
21
  messages,
22
22
  systemPrompt,
23
+ appendSystemPrompt,
23
24
  relatedId,
25
+ peopleId,
26
+ companyId,
24
27
  provider,
25
28
  model,
26
29
  temperature,
30
+ maxTokens,
27
31
  subscriptionId,
28
32
  stream,
29
33
  isPlayground = false,
30
34
  responseFormat,
35
+ sessionId,
36
+ scope,
37
+ manageSession,
38
+ tools,
39
+ toolConfig,
40
+ maxToolRounds,
41
+ recordTypeId,
42
+ meta,
43
+ qualityCheck,
44
+ isPublic,
31
45
  }) {
32
46
  this.sdk.validateParams(
33
47
  {
34
48
  stream,
35
49
  temperature,
50
+ maxTokens,
36
51
  subscriptionId,
37
52
  provider,
38
53
  model,
39
54
  prompt,
40
55
  messages,
41
56
  systemPrompt,
57
+ appendSystemPrompt,
42
58
  isPlayground,
43
59
  responseFormat,
60
+ sessionId,
61
+ scope,
62
+ manageSession,
63
+ tools,
64
+ toolConfig,
65
+ maxToolRounds,
66
+ recordTypeId,
67
+ peopleId,
68
+ companyId,
69
+ meta,
70
+ qualityCheck,
71
+ isPublic,
44
72
  },
45
73
  {
46
74
  prompt: { type: 'string', required: false },
47
75
  messages: { type: 'array', required: false },
48
76
  systemPrompt: { type: 'string', required: false },
77
+ appendSystemPrompt: { type: 'string', required: false },
49
78
  provider: { type: 'string', required: false },
50
79
  model: { type: 'string', required: false },
51
80
  temperature: { type: 'number', required: false },
81
+ maxTokens: { type: 'number', required: false },
52
82
  subscriptionId: { type: 'string', required: false },
53
83
  stream: { type: 'boolean', required: false },
54
84
  isPlayground: { type: 'boolean', required: false },
55
85
  responseFormat: { type: 'object', required: false },
86
+ sessionId: { type: 'string', required: false },
87
+ scope: { type: 'string', required: false },
88
+ manageSession: { type: 'boolean', required: false },
89
+ tools: { type: 'array', required: false },
90
+ toolConfig: { type: 'object', required: false },
91
+ maxToolRounds: { type: 'number', required: false },
92
+ recordTypeId: { type: 'string', required: false },
93
+ peopleId: { type: 'string', required: false },
94
+ companyId: { type: 'string', required: false },
95
+ meta: { type: 'object', required: false },
96
+ qualityCheck: { type: 'boolean', required: false },
97
+ isPublic: { type: 'boolean', required: false },
56
98
  },
57
99
  );
58
100
 
@@ -62,20 +104,44 @@ export class GenerativeService {
62
104
  prompt,
63
105
  messages,
64
106
  systemPrompt,
107
+ appendSystemPrompt,
65
108
  relatedId,
109
+ peopleId,
110
+ companyId,
66
111
  provider,
67
112
  model,
68
113
  temperature,
114
+ maxTokens,
69
115
  subscriptionId,
70
116
  stream,
71
117
  responseFormat,
118
+ sessionId,
119
+ scope,
120
+ manageSession,
121
+ tools,
122
+ toolConfig,
123
+ maxToolRounds,
124
+ recordTypeId,
125
+ meta,
126
+ qualityCheck,
127
+ isPublic,
72
128
  },
73
129
  // Return raw response for streaming to allow client-side stream handling
74
130
  returnRawResponse: stream === true,
75
131
  };
76
132
 
77
- // Force HTTP transport when streaming is enabled since NATS doesn't support streaming responses
78
- const forceFetch = stream === true;
133
+ // Force HTTP transport when streaming or when messages contain large content (too large for NATS)
134
+ const hasLargeContent = messages?.some(
135
+ (m) =>
136
+ Array.isArray(m.content) &&
137
+ m.content.some(
138
+ (c) =>
139
+ c.type === 'image' ||
140
+ c.type === 'image_url' ||
141
+ c.type === 'document',
142
+ ),
143
+ );
144
+ const forceFetch = stream === true || hasLargeContent;
79
145
  const result = await this.sdk._fetch(
80
146
  '/ai/generative/chat',
81
147
  'POST',
@@ -85,6 +151,180 @@ export class GenerativeService {
85
151
  return result;
86
152
  }
87
153
 
154
+ /**
155
+ * Clone an existing chat session into a new one, importing conversation context.
156
+ * Filters out system prompts and tool calls, keeps user/assistant turns.
157
+ * If the transcript exceeds ~50k tokens it is summarized automatically.
158
+ *
159
+ * @param {Object} options
160
+ * @param {string} options.sourceSessionId - Session to clone from (required)
161
+ * @param {string} [options.systemPrompt] - New system prompt (appended after conversation context)
162
+ * @param {string} [options.provider] - LLM provider (falls back to source session)
163
+ * @param {string} [options.model] - Model ID (falls back to source session)
164
+ * @param {Array} [options.tools] - Tool names (falls back to source session)
165
+ * @param {Object} [options.toolConfig] - Tool config (falls back to source session)
166
+ * @param {string} [options.scope] - 'user' or 'account'
167
+ * @param {string} [options.userId] - Owner user ID
168
+ * @param {string} [options.peopleId] - Linked people record
169
+ * @param {string} [options.companyId] - Linked company record
170
+ * @param {string} [options.relatedId] - Linked related record
171
+ * @returns {Promise<Object>} { id, sourceSessionId, wasSummarized }
172
+ */
173
+ async cloneSession({
174
+ sourceSessionId,
175
+ systemPrompt,
176
+ provider,
177
+ model,
178
+ tools,
179
+ toolConfig,
180
+ scope,
181
+ userId,
182
+ peopleId,
183
+ companyId,
184
+ relatedId,
185
+ }) {
186
+ this.sdk.validateParams(
187
+ { sourceSessionId },
188
+ {
189
+ sourceSessionId: { type: 'string', required: true },
190
+ systemPrompt: { type: 'string', required: false },
191
+ provider: { type: 'string', required: false },
192
+ model: { type: 'string', required: false },
193
+ tools: { type: 'array', required: false },
194
+ toolConfig: { type: 'object', required: false },
195
+ scope: { type: 'string', required: false },
196
+ userId: { type: 'string', required: false },
197
+ peopleId: { type: 'string', required: false },
198
+ companyId: { type: 'string', required: false },
199
+ relatedId: { type: 'string', required: false },
200
+ },
201
+ );
202
+
203
+ const params = {
204
+ body: {
205
+ sourceSessionId,
206
+ systemPrompt,
207
+ provider,
208
+ model,
209
+ tools,
210
+ toolConfig,
211
+ scope,
212
+ userId,
213
+ peopleId,
214
+ companyId,
215
+ relatedId,
216
+ },
217
+ };
218
+
219
+ const result = await this.sdk._fetch(
220
+ '/ai/generative/chat/clone',
221
+ 'POST',
222
+ params,
223
+ );
224
+ return result;
225
+ }
226
+
227
+ /**
228
+ * List available chat tools and their metadata
229
+ * @returns {Promise<Object>} { tools: Array<{ name, label, description, configRequirements }>, count: number }
230
+ */
231
+ async listTools() {
232
+ return await this.sdk._fetch('/ai/generative/tools', 'GET');
233
+ }
234
+
235
+ /**
236
+ * List chat sessions visible to the current user
237
+ * @param {Object} [options] - Filter options
238
+ * @param {string} [options.relatedId] - Filter by related object ID
239
+ * @param {string} [options.scope] - Filter by scope ('user' or 'account')
240
+ * @param {number} [options.limit=25] - Results limit
241
+ * @param {number} [options.offset=0] - Pagination offset
242
+ * @returns {Promise<Object>} { sessions: Array }
243
+ */
244
+ async listSessions({ relatedId, scope, limit, offset } = {}) {
245
+ this.sdk.validateParams(
246
+ { relatedId, scope, limit, offset },
247
+ {
248
+ relatedId: { type: 'string', required: false },
249
+ scope: { type: 'string', required: false },
250
+ limit: { type: 'number', required: false },
251
+ offset: { type: 'number', required: false },
252
+ },
253
+ );
254
+
255
+ const params = { query: { relatedId, scope, limit, offset } };
256
+ const result = await this.sdk._fetch(
257
+ '/ai/generative/sessions',
258
+ 'GET',
259
+ params,
260
+ );
261
+ return result;
262
+ }
263
+
264
+ /**
265
+ * Get a chat session with its message history
266
+ * @param {Object} options
267
+ * @param {string} options.sessionId - Session ID to retrieve
268
+ * @returns {Promise<Object>} { session: { id, name, scope, relatedId, provider, model, messages, messageCount, lastMessageAt, createdAt } }
269
+ */
270
+ async getSession({ sessionId }) {
271
+ this.sdk.validateParams(
272
+ { sessionId },
273
+ { sessionId: { type: 'string', required: true } },
274
+ );
275
+
276
+ const result = await this.sdk._fetch(
277
+ `/ai/generative/sessions/${sessionId}`,
278
+ 'GET',
279
+ );
280
+ return result;
281
+ }
282
+
283
+ /**
284
+ * Update a chat session (name, scope)
285
+ * @param {Object} options
286
+ * @param {string} options.sessionId - Session ID to update
287
+ * @param {string} [options.name] - New session name
288
+ * @param {string} [options.scope] - New scope ('user' or 'account')
289
+ * @returns {Promise<Object>} { success: true }
290
+ */
291
+ async updateSession({ sessionId, name, scope }) {
292
+ this.sdk.validateParams(
293
+ { sessionId, name, scope },
294
+ {
295
+ sessionId: { type: 'string', required: true },
296
+ name: { type: 'string', required: false },
297
+ scope: { type: 'string', required: false },
298
+ },
299
+ );
300
+
301
+ const result = await this.sdk._fetch(
302
+ `/ai/generative/sessions/${sessionId}`,
303
+ 'PUT',
304
+ { body: { name, scope } },
305
+ );
306
+ return result;
307
+ }
308
+
309
+ /**
310
+ * Delete a chat session
311
+ * @param {Object} options
312
+ * @param {string} options.sessionId - Session ID to delete
313
+ * @returns {Promise<Object>} { success: true }
314
+ */
315
+ async deleteSession({ sessionId }) {
316
+ this.sdk.validateParams(
317
+ { sessionId },
318
+ { sessionId: { type: 'string', required: true } },
319
+ );
320
+
321
+ const result = await this.sdk._fetch(
322
+ `/ai/generative/sessions/${sessionId}`,
323
+ 'DELETE',
324
+ );
325
+ return result;
326
+ }
327
+
88
328
  async playbook({
89
329
  prompt,
90
330
  messages,
@@ -122,4 +122,49 @@ export class ExternalOAuthService {
122
122
  const result = await this.sdk._fetch('/externalOAuth', 'GET');
123
123
  return result;
124
124
  }
125
+
126
+ async listUnified() {
127
+ const result = await this.sdk._fetch('/externalOAuth/unified', 'GET');
128
+ return result;
129
+ }
130
+
131
+ async providers() {
132
+ const result = await this.sdk._fetch('/externalOAuth/providers', 'GET');
133
+ return result;
134
+ }
135
+
136
+ async authorize({
137
+ name,
138
+ provider,
139
+ clientId,
140
+ clientSecret,
141
+ scopes,
142
+ authorizationUrl,
143
+ tokenUrl,
144
+ }) {
145
+ this.sdk.validateParams(
146
+ { name, provider },
147
+ {
148
+ name: { type: 'string', required: true },
149
+ provider: { type: 'string', required: true },
150
+ clientId: { type: 'string', required: false },
151
+ clientSecret: { type: 'string', required: false },
152
+ scopes: { type: 'array', required: false },
153
+ authorizationUrl: { type: 'string', required: false },
154
+ tokenUrl: { type: 'string', required: false },
155
+ },
156
+ );
157
+
158
+ const body = { name, provider };
159
+ if (clientId) body.clientId = clientId;
160
+ if (clientSecret) body.clientSecret = clientSecret;
161
+ if (scopes) body.scopes = scopes;
162
+ if (authorizationUrl) body.authorizationUrl = authorizationUrl;
163
+ if (tokenUrl) body.tokenUrl = tokenUrl;
164
+
165
+ const result = await this.sdk._fetch('/externalOAuth/authorize', 'POST', {
166
+ body,
167
+ });
168
+ return result;
169
+ }
125
170
  }