@veroai/sdk 0.1.2 → 0.1.3
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/index.cjs +5 -290
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -194
- package/dist/index.d.ts +1 -194
- package/dist/index.js +6 -288
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1255,287 +1255,8 @@ var VoiceResource = class {
|
|
|
1255
1255
|
}
|
|
1256
1256
|
};
|
|
1257
1257
|
|
|
1258
|
-
// src/resources/chat.ts
|
|
1259
|
-
function transformUser(data) {
|
|
1260
|
-
return {
|
|
1261
|
-
id: data.id,
|
|
1262
|
-
email: data.email,
|
|
1263
|
-
firstName: data.first_name,
|
|
1264
|
-
lastName: data.last_name,
|
|
1265
|
-
isVirtual: data.is_virtual,
|
|
1266
|
-
agentConfigId: data.agent_config_id
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
function transformUserWithPresence(data) {
|
|
1270
|
-
return {
|
|
1271
|
-
...transformUser(data),
|
|
1272
|
-
status: data.status,
|
|
1273
|
-
statusMessage: data.status_message,
|
|
1274
|
-
lastSeen: data.last_seen,
|
|
1275
|
-
createdAt: data.created_at
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
function transformParticipant(data) {
|
|
1279
|
-
return {
|
|
1280
|
-
userId: data.user_id,
|
|
1281
|
-
role: data.role,
|
|
1282
|
-
isActive: data.is_active,
|
|
1283
|
-
joinedAt: data.joined_at,
|
|
1284
|
-
lastSeen: data.last_seen,
|
|
1285
|
-
user: data.user ? transformUser(data.user) : void 0
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
function transformMessage(data) {
|
|
1289
|
-
return {
|
|
1290
|
-
id: data.id,
|
|
1291
|
-
conversationId: data.conversation_id,
|
|
1292
|
-
content: data.content,
|
|
1293
|
-
messageType: data.message_type,
|
|
1294
|
-
senderId: data.sender_id,
|
|
1295
|
-
sender: data.sender ? transformUser(data.sender) : void 0,
|
|
1296
|
-
readBy: data.read_by?.map((r) => ({
|
|
1297
|
-
userId: r.user_id,
|
|
1298
|
-
readAt: r.read_at
|
|
1299
|
-
})),
|
|
1300
|
-
metadata: data.metadata,
|
|
1301
|
-
createdAt: data.created_at,
|
|
1302
|
-
editedAt: data.edited_at
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
function transformConversation(data) {
|
|
1306
|
-
return {
|
|
1307
|
-
id: data.id,
|
|
1308
|
-
name: data.name,
|
|
1309
|
-
type: data.type,
|
|
1310
|
-
isActive: data.is_active,
|
|
1311
|
-
lastMessageAt: data.last_message_at,
|
|
1312
|
-
agentEnabled: data.agent_enabled,
|
|
1313
|
-
agentConfigId: data.agent_config_id,
|
|
1314
|
-
participants: data.participants?.map(transformParticipant),
|
|
1315
|
-
unreadCount: data.unread_count,
|
|
1316
|
-
metadata: data.metadata,
|
|
1317
|
-
createdAt: data.created_at,
|
|
1318
|
-
updatedAt: data.updated_at
|
|
1319
|
-
};
|
|
1320
|
-
}
|
|
1321
|
-
function transformPresence(data) {
|
|
1322
|
-
return {
|
|
1323
|
-
userId: data.user_id,
|
|
1324
|
-
status: data.status,
|
|
1325
|
-
statusMessage: data.status_message,
|
|
1326
|
-
lastSeen: data.last_seen,
|
|
1327
|
-
metadata: data.metadata
|
|
1328
|
-
};
|
|
1329
|
-
}
|
|
1330
|
-
function transformAgent(data) {
|
|
1331
|
-
return {
|
|
1332
|
-
configId: data.config_id,
|
|
1333
|
-
name: data.name,
|
|
1334
|
-
userId: data.user_id,
|
|
1335
|
-
enabled: data.enabled
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
var ConversationsResource = class {
|
|
1339
|
-
constructor(http) {
|
|
1340
|
-
this.http = http;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* List all conversations for the current user
|
|
1344
|
-
*/
|
|
1345
|
-
async list() {
|
|
1346
|
-
const response = await this.http.get("/v1/chat/conversations");
|
|
1347
|
-
return {
|
|
1348
|
-
data: response.conversations.map(transformConversation),
|
|
1349
|
-
total: response.total,
|
|
1350
|
-
hasMore: false
|
|
1351
|
-
};
|
|
1352
|
-
}
|
|
1353
|
-
/**
|
|
1354
|
-
* Get a conversation by ID
|
|
1355
|
-
*/
|
|
1356
|
-
async get(conversationId) {
|
|
1357
|
-
const response = await this.http.get(
|
|
1358
|
-
`/v1/chat/conversations/${conversationId}`
|
|
1359
|
-
);
|
|
1360
|
-
return transformConversation(response.conversation);
|
|
1361
|
-
}
|
|
1362
|
-
/**
|
|
1363
|
-
* Create a new conversation
|
|
1364
|
-
*/
|
|
1365
|
-
async create(params) {
|
|
1366
|
-
const response = await this.http.post(
|
|
1367
|
-
"/v1/chat/conversations",
|
|
1368
|
-
{
|
|
1369
|
-
type: params.type || "direct",
|
|
1370
|
-
name: params.name,
|
|
1371
|
-
participant_ids: params.participantIds,
|
|
1372
|
-
agent_config_id: params.agentConfigId,
|
|
1373
|
-
metadata: params.metadata
|
|
1374
|
-
}
|
|
1375
|
-
);
|
|
1376
|
-
return transformConversation(response.conversation);
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Get messages for a conversation
|
|
1380
|
-
*/
|
|
1381
|
-
async getMessages(conversationId, params) {
|
|
1382
|
-
const query = {};
|
|
1383
|
-
if (params?.limit) query.limit = params.limit;
|
|
1384
|
-
if (params?.offset) query.offset = params.offset;
|
|
1385
|
-
if (params?.before) {
|
|
1386
|
-
query.before = params.before instanceof Date ? params.before.toISOString() : params.before;
|
|
1387
|
-
}
|
|
1388
|
-
const response = await this.http.get(`/v1/chat/conversations/${conversationId}/messages`, query);
|
|
1389
|
-
return {
|
|
1390
|
-
messages: response.messages.map(transformMessage),
|
|
1391
|
-
total: response.total,
|
|
1392
|
-
hasMore: response.has_more
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Send a message to a conversation
|
|
1397
|
-
*/
|
|
1398
|
-
async sendMessage(conversationId, params) {
|
|
1399
|
-
const response = await this.http.post(
|
|
1400
|
-
`/v1/chat/conversations/${conversationId}/messages`,
|
|
1401
|
-
{
|
|
1402
|
-
content: params.content,
|
|
1403
|
-
message_type: params.messageType || "text",
|
|
1404
|
-
metadata: params.metadata
|
|
1405
|
-
}
|
|
1406
|
-
);
|
|
1407
|
-
return transformMessage(response.message);
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Mark conversation as read
|
|
1411
|
-
*/
|
|
1412
|
-
async markRead(conversationId) {
|
|
1413
|
-
await this.http.post(`/v1/chat/conversations/${conversationId}/read`);
|
|
1414
|
-
}
|
|
1415
|
-
/**
|
|
1416
|
-
* Add participants to a conversation
|
|
1417
|
-
*/
|
|
1418
|
-
async addParticipants(conversationId, userIds) {
|
|
1419
|
-
const response = await this.http.post(`/v1/chat/conversations/${conversationId}/participants`, {
|
|
1420
|
-
user_ids: userIds
|
|
1421
|
-
});
|
|
1422
|
-
return response.participants.map(transformParticipant);
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
* Leave a conversation
|
|
1426
|
-
*/
|
|
1427
|
-
async leave(conversationId) {
|
|
1428
|
-
await this.http.delete(
|
|
1429
|
-
`/v1/chat/conversations/${conversationId}/participants/me`
|
|
1430
|
-
);
|
|
1431
|
-
}
|
|
1432
|
-
/**
|
|
1433
|
-
* Add an agent to a conversation
|
|
1434
|
-
*/
|
|
1435
|
-
async addAgent(conversationId, params) {
|
|
1436
|
-
const response = await this.http.post(
|
|
1437
|
-
`/v1/chat/conversations/${conversationId}/agent`,
|
|
1438
|
-
{
|
|
1439
|
-
agent_config_id: params.agentConfigId,
|
|
1440
|
-
add_as_participant: params.addAsParticipant ?? true
|
|
1441
|
-
}
|
|
1442
|
-
);
|
|
1443
|
-
return response.agent ? transformAgent(response.agent) : null;
|
|
1444
|
-
}
|
|
1445
|
-
/**
|
|
1446
|
-
* Remove agent from a conversation
|
|
1447
|
-
*/
|
|
1448
|
-
async removeAgent(conversationId) {
|
|
1449
|
-
await this.http.delete(`/v1/chat/conversations/${conversationId}/agent`);
|
|
1450
|
-
}
|
|
1451
|
-
/**
|
|
1452
|
-
* Toggle agent enabled/disabled
|
|
1453
|
-
*/
|
|
1454
|
-
async setAgentEnabled(conversationId, enabled) {
|
|
1455
|
-
await this.http.patch(`/v1/chat/conversations/${conversationId}/agent`, {
|
|
1456
|
-
enabled
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
var ChatUsersResource = class {
|
|
1461
|
-
constructor(http) {
|
|
1462
|
-
this.http = http;
|
|
1463
|
-
}
|
|
1464
|
-
/**
|
|
1465
|
-
* List all users in the tenant
|
|
1466
|
-
*/
|
|
1467
|
-
async list(params) {
|
|
1468
|
-
const query = {};
|
|
1469
|
-
if (params?.limit) query.limit = params.limit;
|
|
1470
|
-
if (params?.offset) query.offset = params.offset;
|
|
1471
|
-
if (params?.includeVirtual !== void 0) {
|
|
1472
|
-
query.include_virtual = params.includeVirtual;
|
|
1473
|
-
}
|
|
1474
|
-
const response = await this.http.get("/v1/chat/users", query);
|
|
1475
|
-
return {
|
|
1476
|
-
data: response.users.map(transformUserWithPresence),
|
|
1477
|
-
total: response.total,
|
|
1478
|
-
hasMore: false
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
|
-
/**
|
|
1482
|
-
* Get online users
|
|
1483
|
-
*/
|
|
1484
|
-
async online() {
|
|
1485
|
-
const response = await this.http.get("/v1/chat/users/online");
|
|
1486
|
-
return response.users.map(transformUserWithPresence);
|
|
1487
|
-
}
|
|
1488
|
-
/**
|
|
1489
|
-
* Get current user profile and presence
|
|
1490
|
-
*/
|
|
1491
|
-
async me() {
|
|
1492
|
-
const response = await this.http.get(
|
|
1493
|
-
"/v1/chat/users/me"
|
|
1494
|
-
);
|
|
1495
|
-
return transformUserWithPresence(response.user);
|
|
1496
|
-
}
|
|
1497
|
-
/**
|
|
1498
|
-
* Update current user's presence status
|
|
1499
|
-
*/
|
|
1500
|
-
async updateStatus(params) {
|
|
1501
|
-
await this.http.put("/v1/chat/users/me/status", {
|
|
1502
|
-
status: params.status,
|
|
1503
|
-
status_message: params.statusMessage,
|
|
1504
|
-
metadata: params.metadata
|
|
1505
|
-
});
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Get a user by ID
|
|
1509
|
-
*/
|
|
1510
|
-
async get(userId) {
|
|
1511
|
-
const response = await this.http.get(
|
|
1512
|
-
`/v1/chat/users/${userId}`
|
|
1513
|
-
);
|
|
1514
|
-
return transformUserWithPresence(response.user);
|
|
1515
|
-
}
|
|
1516
|
-
/**
|
|
1517
|
-
* Get presence for a specific user
|
|
1518
|
-
*/
|
|
1519
|
-
async getPresence(userId) {
|
|
1520
|
-
const response = await this.http.get(
|
|
1521
|
-
`/v1/chat/users/${userId}/presence`
|
|
1522
|
-
);
|
|
1523
|
-
return transformPresence(response.presence);
|
|
1524
|
-
}
|
|
1525
|
-
};
|
|
1526
|
-
var ChatResource = class {
|
|
1527
|
-
/** Conversation management */
|
|
1528
|
-
conversations;
|
|
1529
|
-
/** User listing and presence */
|
|
1530
|
-
users;
|
|
1531
|
-
constructor(http) {
|
|
1532
|
-
this.conversations = new ConversationsResource(http);
|
|
1533
|
-
this.users = new ChatUsersResource(http);
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1536
|
-
|
|
1537
1258
|
// src/resources/agents.ts
|
|
1538
|
-
function
|
|
1259
|
+
function transformAgent(agent) {
|
|
1539
1260
|
return {
|
|
1540
1261
|
id: agent.id,
|
|
1541
1262
|
name: agent.name,
|
|
@@ -1577,7 +1298,7 @@ var AgentsResource = class {
|
|
|
1577
1298
|
`/agents${query ? `?${query}` : ""}`
|
|
1578
1299
|
);
|
|
1579
1300
|
return {
|
|
1580
|
-
data: response.agents.map(
|
|
1301
|
+
data: response.agents.map(transformAgent),
|
|
1581
1302
|
total: response.total,
|
|
1582
1303
|
hasMore: response.offset + response.agents.length < response.total,
|
|
1583
1304
|
nextOffset: response.offset + response.agents.length < response.total ? response.offset + response.limit : void 0
|
|
@@ -1596,7 +1317,7 @@ var AgentsResource = class {
|
|
|
1596
1317
|
const response = await this.http.get(
|
|
1597
1318
|
`/agents/${encodeURIComponent(agentId)}`
|
|
1598
1319
|
);
|
|
1599
|
-
return
|
|
1320
|
+
return transformAgent(response.agent);
|
|
1600
1321
|
}
|
|
1601
1322
|
/**
|
|
1602
1323
|
* Create a new AI agent
|
|
@@ -1628,7 +1349,7 @@ var AgentsResource = class {
|
|
|
1628
1349
|
system_prompt: params.systemPrompt,
|
|
1629
1350
|
enabled: params.enabled ?? false
|
|
1630
1351
|
});
|
|
1631
|
-
return
|
|
1352
|
+
return transformAgent(response.agent);
|
|
1632
1353
|
}
|
|
1633
1354
|
/**
|
|
1634
1355
|
* Update an agent
|
|
@@ -1660,7 +1381,7 @@ var AgentsResource = class {
|
|
|
1660
1381
|
`/agents/${encodeURIComponent(agentId)}`,
|
|
1661
1382
|
body
|
|
1662
1383
|
);
|
|
1663
|
-
return
|
|
1384
|
+
return transformAgent(response.agent);
|
|
1664
1385
|
}
|
|
1665
1386
|
/**
|
|
1666
1387
|
* Delete an agent
|
|
@@ -2134,8 +1855,6 @@ var VeroAI = class _VeroAI {
|
|
|
2134
1855
|
voice;
|
|
2135
1856
|
/** AI agent configurations */
|
|
2136
1857
|
agents;
|
|
2137
|
-
/** Chat conversations and users */
|
|
2138
|
-
chat;
|
|
2139
1858
|
/** Real-time event subscriptions via WebSocket */
|
|
2140
1859
|
realtime;
|
|
2141
1860
|
/**
|
|
@@ -2172,7 +1891,6 @@ var VeroAI = class _VeroAI {
|
|
|
2172
1891
|
this.domains = new DomainsResource(this.http);
|
|
2173
1892
|
this.voice = new VoiceResource(this.http);
|
|
2174
1893
|
this.agents = new AgentsResource(this.http);
|
|
2175
|
-
this.chat = new ChatResource(this.http);
|
|
2176
1894
|
const tokenFetcher = async () => {
|
|
2177
1895
|
const response = await this.http.post("/v1/realtime/auth", {});
|
|
2178
1896
|
return response.token;
|
|
@@ -2203,6 +1921,6 @@ var VeroAI = class _VeroAI {
|
|
|
2203
1921
|
}
|
|
2204
1922
|
};
|
|
2205
1923
|
|
|
2206
|
-
export { APIError, AuthenticationError, AuthorizationError,
|
|
1924
|
+
export { APIError, AuthenticationError, AuthorizationError, NetworkError, NotFoundError, RateLimitError, RealtimeResource, ServerError, TimeoutError, ValidationError, VeroAI, VeroAIError, VoiceCallsResource, VoiceNumbersResource, VoiceResource, createRealtimeResource, VeroAI as default };
|
|
2207
1925
|
//# sourceMappingURL=index.js.map
|
|
2208
1926
|
//# sourceMappingURL=index.js.map
|