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