@veroai/sdk 0.1.1 → 0.1.2
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 +290 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -1
- package/dist/index.d.ts +194 -1
- package/dist/index.js +288 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1255,8 +1255,287 @@ 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
|
+
|
|
1258
1537
|
// src/resources/agents.ts
|
|
1259
|
-
function
|
|
1538
|
+
function transformAgent2(agent) {
|
|
1260
1539
|
return {
|
|
1261
1540
|
id: agent.id,
|
|
1262
1541
|
name: agent.name,
|
|
@@ -1298,7 +1577,7 @@ var AgentsResource = class {
|
|
|
1298
1577
|
`/agents${query ? `?${query}` : ""}`
|
|
1299
1578
|
);
|
|
1300
1579
|
return {
|
|
1301
|
-
data: response.agents.map(
|
|
1580
|
+
data: response.agents.map(transformAgent2),
|
|
1302
1581
|
total: response.total,
|
|
1303
1582
|
hasMore: response.offset + response.agents.length < response.total,
|
|
1304
1583
|
nextOffset: response.offset + response.agents.length < response.total ? response.offset + response.limit : void 0
|
|
@@ -1317,7 +1596,7 @@ var AgentsResource = class {
|
|
|
1317
1596
|
const response = await this.http.get(
|
|
1318
1597
|
`/agents/${encodeURIComponent(agentId)}`
|
|
1319
1598
|
);
|
|
1320
|
-
return
|
|
1599
|
+
return transformAgent2(response.agent);
|
|
1321
1600
|
}
|
|
1322
1601
|
/**
|
|
1323
1602
|
* Create a new AI agent
|
|
@@ -1349,7 +1628,7 @@ var AgentsResource = class {
|
|
|
1349
1628
|
system_prompt: params.systemPrompt,
|
|
1350
1629
|
enabled: params.enabled ?? false
|
|
1351
1630
|
});
|
|
1352
|
-
return
|
|
1631
|
+
return transformAgent2(response.agent);
|
|
1353
1632
|
}
|
|
1354
1633
|
/**
|
|
1355
1634
|
* Update an agent
|
|
@@ -1381,7 +1660,7 @@ var AgentsResource = class {
|
|
|
1381
1660
|
`/agents/${encodeURIComponent(agentId)}`,
|
|
1382
1661
|
body
|
|
1383
1662
|
);
|
|
1384
|
-
return
|
|
1663
|
+
return transformAgent2(response.agent);
|
|
1385
1664
|
}
|
|
1386
1665
|
/**
|
|
1387
1666
|
* Delete an agent
|
|
@@ -1855,6 +2134,8 @@ var VeroAI = class _VeroAI {
|
|
|
1855
2134
|
voice;
|
|
1856
2135
|
/** AI agent configurations */
|
|
1857
2136
|
agents;
|
|
2137
|
+
/** Chat conversations and users */
|
|
2138
|
+
chat;
|
|
1858
2139
|
/** Real-time event subscriptions via WebSocket */
|
|
1859
2140
|
realtime;
|
|
1860
2141
|
/**
|
|
@@ -1891,6 +2172,7 @@ var VeroAI = class _VeroAI {
|
|
|
1891
2172
|
this.domains = new DomainsResource(this.http);
|
|
1892
2173
|
this.voice = new VoiceResource(this.http);
|
|
1893
2174
|
this.agents = new AgentsResource(this.http);
|
|
2175
|
+
this.chat = new ChatResource(this.http);
|
|
1894
2176
|
const tokenFetcher = async () => {
|
|
1895
2177
|
const response = await this.http.post("/v1/realtime/auth", {});
|
|
1896
2178
|
return response.token;
|
|
@@ -1921,6 +2203,6 @@ var VeroAI = class _VeroAI {
|
|
|
1921
2203
|
}
|
|
1922
2204
|
};
|
|
1923
2205
|
|
|
1924
|
-
export { APIError, AuthenticationError, AuthorizationError, NetworkError, NotFoundError, RateLimitError, RealtimeResource, ServerError, TimeoutError, ValidationError, VeroAI, VeroAIError, VoiceCallsResource, VoiceNumbersResource, VoiceResource, createRealtimeResource, VeroAI as default };
|
|
2206
|
+
export { APIError, AuthenticationError, AuthorizationError, ChatResource, ChatUsersResource, ConversationsResource, NetworkError, NotFoundError, RateLimitError, RealtimeResource, ServerError, TimeoutError, ValidationError, VeroAI, VeroAIError, VoiceCallsResource, VoiceNumbersResource, VoiceResource, createRealtimeResource, VeroAI as default };
|
|
1925
2207
|
//# sourceMappingURL=index.js.map
|
|
1926
2208
|
//# sourceMappingURL=index.js.map
|