@gpt-platform/admin 0.3.3 → 0.4.0

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.mjs CHANGED
@@ -814,8 +814,8 @@ var createClient = (config = {}) => {
814
814
  };
815
815
 
816
816
  // src/version.ts
817
- var SDK_VERSION = "0.3.3";
818
- var DEFAULT_API_VERSION = "2026-02-25";
817
+ var SDK_VERSION = "0.4.0";
818
+ var DEFAULT_API_VERSION = "2026-02-27";
819
819
 
820
820
  // src/base-client.ts
821
821
  function isSecureUrl(url) {
@@ -1133,6 +1133,7 @@ var RequestBuilder = class {
1133
1133
  const { data } = await this.requestWithRetry(
1134
1134
  () => fn({
1135
1135
  client: this.clientInstance,
1136
+ throwOnError: true,
1136
1137
  headers,
1137
1138
  ...params,
1138
1139
  ...options?.signal && { signal: options.signal }
@@ -1152,6 +1153,7 @@ var RequestBuilder = class {
1152
1153
  await this.requestWithRetry(
1153
1154
  () => fn({
1154
1155
  client: this.clientInstance,
1156
+ throwOnError: true,
1155
1157
  headers,
1156
1158
  ...params,
1157
1159
  ...options?.signal && { signal: options.signal }
@@ -1329,6 +1331,35 @@ var client = createClient(
1329
1331
  );
1330
1332
 
1331
1333
  // src/_internal/sdk.gen.ts
1334
+ var getAdminFieldTemplates = (options) => (options.client ?? client).get({
1335
+ security: [{ scheme: "bearer", type: "http" }],
1336
+ url: "/admin/field-templates",
1337
+ ...options
1338
+ });
1339
+ var postAdminFieldTemplates = (options) => (options.client ?? client).post({
1340
+ security: [{ scheme: "bearer", type: "http" }],
1341
+ url: "/admin/field-templates",
1342
+ ...options,
1343
+ headers: {
1344
+ "Content-Type": "application/vnd.api+json",
1345
+ ...options.headers
1346
+ }
1347
+ });
1348
+ var getAdminAgents = (options) => (options.client ?? client).get({
1349
+ security: [{ scheme: "bearer", type: "http" }],
1350
+ url: "/admin/agents",
1351
+ ...options
1352
+ });
1353
+ var deleteAdminAgentVersionsById = (options) => (options.client ?? client).delete({
1354
+ security: [{ scheme: "bearer", type: "http" }],
1355
+ url: "/admin/agent-versions/{id}",
1356
+ ...options
1357
+ });
1358
+ var getAdminAgentVersionsById = (options) => (options.client ?? client).get({
1359
+ security: [{ scheme: "bearer", type: "http" }],
1360
+ url: "/admin/agent-versions/{id}",
1361
+ ...options
1362
+ });
1332
1363
  var patchAdminAccountsByIdCredit = (options) => (options.client ?? client).patch({
1333
1364
  security: [{ scheme: "bearer", type: "http" }],
1334
1365
  url: "/admin/accounts/{id}/credit",
@@ -1338,16 +1369,206 @@ var patchAdminAccountsByIdCredit = (options) => (options.client ?? client).patch
1338
1369
  ...options.headers
1339
1370
  }
1340
1371
  });
1372
+ var getAdminTrainingSessionsAgentsByAgentIdSessions = (options) => (options.client ?? client).get({
1373
+ security: [{ scheme: "bearer", type: "http" }],
1374
+ url: "/admin/training-sessions/agents/{agent_id}/sessions",
1375
+ ...options
1376
+ });
1377
+ var patchAdminApiKeysByIdSetBudget = (options) => (options.client ?? client).patch({
1378
+ security: [{ scheme: "bearer", type: "http" }],
1379
+ url: "/admin/api-keys/{id}/set-budget",
1380
+ ...options,
1381
+ headers: {
1382
+ "Content-Type": "application/vnd.api+json",
1383
+ ...options.headers
1384
+ }
1385
+ });
1386
+ var getAdminAgentVersionsByIdRevisions = (options) => (options.client ?? client).get({
1387
+ security: [{ scheme: "bearer", type: "http" }],
1388
+ url: "/admin/agent-versions/{id}/revisions",
1389
+ ...options
1390
+ });
1391
+ var postAdminAgentsCloneForWorkspace = (options) => (options.client ?? client).post({
1392
+ security: [{ scheme: "bearer", type: "http" }],
1393
+ url: "/admin/agents/clone-for-workspace",
1394
+ ...options,
1395
+ headers: {
1396
+ "Content-Type": "application/vnd.api+json",
1397
+ ...options.headers
1398
+ }
1399
+ });
1400
+ var getAdminAgentsById = (options) => (options.client ?? client).get({
1401
+ security: [{ scheme: "bearer", type: "http" }],
1402
+ url: "/admin/agents/{id}",
1403
+ ...options
1404
+ });
1405
+ var postAdminAgentsByIdExport = (options) => (options.client ?? client).post({
1406
+ security: [{ scheme: "bearer", type: "http" }],
1407
+ url: "/admin/agents/{id}/export",
1408
+ ...options
1409
+ });
1410
+ var postAdminAgentsByIdRestoreVersion = (options) => (options.client ?? client).post({
1411
+ security: [{ scheme: "bearer", type: "http" }],
1412
+ url: "/admin/agents/{id}/restore-version",
1413
+ ...options,
1414
+ headers: {
1415
+ "Content-Type": "application/vnd.api+json",
1416
+ ...options.headers
1417
+ }
1418
+ });
1419
+ var getAdminAgentsByIdTrainingExamples = (options) => (options.client ?? client).get({
1420
+ security: [{ scheme: "bearer", type: "http" }],
1421
+ url: "/admin/agents/{id}/training-examples",
1422
+ ...options
1423
+ });
1424
+ var deleteAdminEmailMarketingCampaignsById = (options) => (options.client ?? client).delete({
1425
+ security: [{ scheme: "bearer", type: "http" }],
1426
+ url: "/admin/email-marketing/campaigns/{id}",
1427
+ ...options
1428
+ });
1429
+ var getAdminEmailMarketingCampaignsById = (options) => (options.client ?? client).get({
1430
+ security: [{ scheme: "bearer", type: "http" }],
1431
+ url: "/admin/email-marketing/campaigns/{id}",
1432
+ ...options
1433
+ });
1341
1434
  var getAdminWebhookDeliveriesById = (options) => (options.client ?? client).get({
1342
1435
  security: [{ scheme: "bearer", type: "http" }],
1343
1436
  url: "/admin/webhook-deliveries/{id}",
1344
1437
  ...options
1345
1438
  });
1439
+ var postAdminAgentsByIdSchemaVersionsByVersionIdActivate = (options) => (options.client ?? client).post({
1440
+ security: [{ scheme: "bearer", type: "http" }],
1441
+ url: "/admin/agents/{id}/schema-versions/{version_id}/activate",
1442
+ ...options
1443
+ });
1444
+ var postAdminAgentsPredict = (options) => (options.client ?? client).post({
1445
+ security: [{ scheme: "bearer", type: "http" }],
1446
+ url: "/admin/agents/predict",
1447
+ ...options,
1448
+ headers: {
1449
+ "Content-Type": "application/vnd.api+json",
1450
+ ...options.headers
1451
+ }
1452
+ });
1453
+ var deleteAdminApiKeysById = (options) => (options.client ?? client).delete({
1454
+ security: [{ scheme: "bearer", type: "http" }],
1455
+ url: "/admin/api-keys/{id}",
1456
+ ...options
1457
+ });
1346
1458
  var getAdminApiKeysById = (options) => (options.client ?? client).get({
1347
1459
  security: [{ scheme: "bearer", type: "http" }],
1348
1460
  url: "/admin/api-keys/{id}",
1349
1461
  ...options
1350
1462
  });
1463
+ var patchAdminApiKeysById = (options) => (options.client ?? client).patch({
1464
+ security: [{ scheme: "bearer", type: "http" }],
1465
+ url: "/admin/api-keys/{id}",
1466
+ ...options,
1467
+ headers: {
1468
+ "Content-Type": "application/vnd.api+json",
1469
+ ...options.headers
1470
+ }
1471
+ });
1472
+ var getAdminVoiceRecordingsSessionBySessionId = (options) => (options.client ?? client).get({
1473
+ security: [{ scheme: "bearer", type: "http" }],
1474
+ url: "/admin/voice/recordings/session/{session_id}",
1475
+ ...options
1476
+ });
1477
+ var getAdminEmailTrackingEventsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1478
+ security: [{ scheme: "bearer", type: "http" }],
1479
+ url: "/admin/email/tracking-events/workspace/{workspace_id}",
1480
+ ...options
1481
+ });
1482
+ var deleteAdminTrainingExamplesById = (options) => (options.client ?? client).delete({
1483
+ security: [{ scheme: "bearer", type: "http" }],
1484
+ url: "/admin/training-examples/{id}",
1485
+ ...options
1486
+ });
1487
+ var getAdminTrainingExamplesById = (options) => (options.client ?? client).get({
1488
+ security: [{ scheme: "bearer", type: "http" }],
1489
+ url: "/admin/training-examples/{id}",
1490
+ ...options
1491
+ });
1492
+ var patchAdminTrainingExamplesById = (options) => (options.client ?? client).patch({
1493
+ security: [{ scheme: "bearer", type: "http" }],
1494
+ url: "/admin/training-examples/{id}",
1495
+ ...options,
1496
+ headers: {
1497
+ "Content-Type": "application/vnd.api+json",
1498
+ ...options.headers
1499
+ }
1500
+ });
1501
+ var postAdminTrainingExamplesBulkDelete = (options) => (options.client ?? client).post({
1502
+ security: [{ scheme: "bearer", type: "http" }],
1503
+ url: "/admin/training-examples/bulk-delete",
1504
+ ...options,
1505
+ headers: {
1506
+ "Content-Type": "application/vnd.api+json",
1507
+ ...options.headers
1508
+ }
1509
+ });
1510
+ var getAdminVoiceSessions = (options) => (options.client ?? client).get({
1511
+ security: [{ scheme: "bearer", type: "http" }],
1512
+ url: "/admin/voice/sessions",
1513
+ ...options
1514
+ });
1515
+ var getAdminVoiceTranscriptionResultsSessionBySessionId = (options) => (options.client ?? client).get({
1516
+ security: [{ scheme: "bearer", type: "http" }],
1517
+ url: "/admin/voice/transcription-results/session/{session_id}",
1518
+ ...options
1519
+ });
1520
+ var getAdminUsers = (options) => (options.client ?? client).get({
1521
+ security: [{ scheme: "bearer", type: "http" }],
1522
+ url: "/admin/users",
1523
+ ...options
1524
+ });
1525
+ var getAdminAgentVersionsByIdMetrics = (options) => (options.client ?? client).get({
1526
+ security: [{ scheme: "bearer", type: "http" }],
1527
+ url: "/admin/agent-versions/{id}/metrics",
1528
+ ...options
1529
+ });
1530
+ var postAdminAgentVersionsByIdSetSystemFields = (options) => (options.client ?? client).post({
1531
+ security: [{ scheme: "bearer", type: "http" }],
1532
+ url: "/admin/agent-versions/{id}/set-system-fields",
1533
+ ...options,
1534
+ headers: {
1535
+ "Content-Type": "application/vnd.api+json",
1536
+ ...options.headers
1537
+ }
1538
+ });
1539
+ var postAdminEmailMarketingCampaigns = (options) => (options.client ?? client).post({
1540
+ security: [{ scheme: "bearer", type: "http" }],
1541
+ url: "/admin/email-marketing/campaigns",
1542
+ ...options,
1543
+ headers: {
1544
+ "Content-Type": "application/vnd.api+json",
1545
+ ...options.headers
1546
+ }
1547
+ });
1548
+ var postAdminAgentVersionsByIdAddSystemField = (options) => (options.client ?? client).post({
1549
+ security: [{ scheme: "bearer", type: "http" }],
1550
+ url: "/admin/agent-versions/{id}/add-system-field",
1551
+ ...options,
1552
+ headers: {
1553
+ "Content-Type": "application/vnd.api+json",
1554
+ ...options.headers
1555
+ }
1556
+ });
1557
+ var deleteAdminFieldTemplatesById = (options) => (options.client ?? client).delete({
1558
+ security: [{ scheme: "bearer", type: "http" }],
1559
+ url: "/admin/field-templates/{id}",
1560
+ ...options
1561
+ });
1562
+ var getAdminFieldTemplatesById = (options) => (options.client ?? client).get({
1563
+ security: [{ scheme: "bearer", type: "http" }],
1564
+ url: "/admin/field-templates/{id}",
1565
+ ...options
1566
+ });
1567
+ var getAdminVoiceSessionsById = (options) => (options.client ?? client).get({
1568
+ security: [{ scheme: "bearer", type: "http" }],
1569
+ url: "/admin/voice/sessions/{id}",
1570
+ ...options
1571
+ });
1351
1572
  var deleteAdminWebhookConfigsById = (options) => (options.client ?? client).delete({
1352
1573
  security: [{ scheme: "bearer", type: "http" }],
1353
1574
  url: "/admin/webhook-configs/{id}",
@@ -1367,6 +1588,24 @@ var patchAdminWebhookConfigsById = (options) => (options.client ?? client).patch
1367
1588
  ...options.headers
1368
1589
  }
1369
1590
  });
1591
+ var patchAdminUsersByIdAdminEmail = (options) => (options.client ?? client).patch({
1592
+ security: [{ scheme: "bearer", type: "http" }],
1593
+ url: "/admin/users/{id}/admin/email",
1594
+ ...options,
1595
+ headers: {
1596
+ "Content-Type": "application/vnd.api+json",
1597
+ ...options.headers
1598
+ }
1599
+ });
1600
+ var postAdminTrainingExamplesSearch = (options) => (options.client ?? client).post({
1601
+ security: [{ scheme: "bearer", type: "http" }],
1602
+ url: "/admin/training-examples/search",
1603
+ ...options,
1604
+ headers: {
1605
+ "Content-Type": "application/vnd.api+json",
1606
+ ...options.headers
1607
+ }
1608
+ });
1370
1609
  var patchAdminAccountsByIdDebit = (options) => (options.client ?? client).patch({
1371
1610
  security: [{ scheme: "bearer", type: "http" }],
1372
1611
  url: "/admin/accounts/{id}/debit",
@@ -1376,11 +1615,25 @@ var patchAdminAccountsByIdDebit = (options) => (options.client ?? client).patch(
1376
1615
  ...options.headers
1377
1616
  }
1378
1617
  });
1618
+ var getAdminVoiceTranscriptionResultsById = (options) => (options.client ?? client).get({
1619
+ security: [{ scheme: "bearer", type: "http" }],
1620
+ url: "/admin/voice/transcription-results/{id}",
1621
+ ...options
1622
+ });
1379
1623
  var getAdminApiKeys = (options) => (options.client ?? client).get({
1380
1624
  security: [{ scheme: "bearer", type: "http" }],
1381
1625
  url: "/admin/api-keys",
1382
1626
  ...options
1383
1627
  });
1628
+ var postAdminApiKeys = (options) => (options.client ?? client).post({
1629
+ security: [{ scheme: "bearer", type: "http" }],
1630
+ url: "/admin/api-keys",
1631
+ ...options,
1632
+ headers: {
1633
+ "Content-Type": "application/vnd.api+json",
1634
+ ...options.headers
1635
+ }
1636
+ });
1384
1637
  var getAdminExtractionDocumentsById = (options) => (options.client ?? client).get({
1385
1638
  security: [{ scheme: "bearer", type: "http" }],
1386
1639
  url: "/admin/extraction/documents/{id}",
@@ -1396,124 +1649,1442 @@ var getAdminStorageStats = (options) => (options.client ?? client).get({
1396
1649
  url: "/admin/storage/stats",
1397
1650
  ...options
1398
1651
  });
1652
+ var getAdminAgentsByIdStats = (options) => (options.client ?? client).get({
1653
+ security: [{ scheme: "bearer", type: "http" }],
1654
+ url: "/admin/agents/{id}/stats",
1655
+ ...options
1656
+ });
1657
+ var patchAdminUsersByIdConfirmEmail = (options) => (options.client ?? client).patch({
1658
+ security: [{ scheme: "bearer", type: "http" }],
1659
+ url: "/admin/users/{id}/confirm-email",
1660
+ ...options,
1661
+ headers: {
1662
+ "Content-Type": "application/vnd.api+json",
1663
+ ...options.headers
1664
+ }
1665
+ });
1666
+ var getAdminEmailMarketingSenderProfilesWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1667
+ security: [{ scheme: "bearer", type: "http" }],
1668
+ url: "/admin/email-marketing/sender-profiles/workspace/{workspace_id}",
1669
+ ...options
1670
+ });
1671
+ var getAdminEmailMarketingCampaignsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1672
+ security: [{ scheme: "bearer", type: "http" }],
1673
+ url: "/admin/email-marketing/campaigns/workspace/{workspace_id}",
1674
+ ...options
1675
+ });
1399
1676
  var getAdminAccountsById = (options) => (options.client ?? client).get({
1400
1677
  security: [{ scheme: "bearer", type: "http" }],
1401
1678
  url: "/admin/accounts/{id}",
1402
1679
  ...options
1403
1680
  });
1404
- var getAdminBucketsByIdStats = (options) => (options.client ?? client).get({
1681
+ var deleteAdminUsersById = (options) => (options.client ?? client).delete({
1405
1682
  security: [{ scheme: "bearer", type: "http" }],
1406
- url: "/admin/buckets/{id}/stats",
1683
+ url: "/admin/users/{id}",
1407
1684
  ...options
1408
1685
  });
1409
- var getAdminDocumentsStats = (options) => (options.client ?? client).get({
1686
+ var getAdminUsersById = (options) => (options.client ?? client).get({
1410
1687
  security: [{ scheme: "bearer", type: "http" }],
1411
- url: "/admin/documents/stats",
1688
+ url: "/admin/users/{id}",
1412
1689
  ...options
1413
1690
  });
1414
- var getAdminWebhookDeliveries = (options) => (options.client ?? client).get({
1691
+ var getAdminAgentsByIdUsage = (options) => (options.client ?? client).get({
1415
1692
  security: [{ scheme: "bearer", type: "http" }],
1416
- url: "/admin/webhook-deliveries",
1693
+ url: "/admin/agents/{id}/usage",
1417
1694
  ...options
1418
1695
  });
1419
- var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
1696
+ var getAdminEmailTrackingEventsById = (options) => (options.client ?? client).get({
1420
1697
  security: [{ scheme: "bearer", type: "http" }],
1421
- url: "/admin/extraction/documents",
1698
+ url: "/admin/email/tracking-events/{id}",
1422
1699
  ...options
1423
1700
  });
1424
- var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post({
1701
+ var deleteAdminEmailMarketingSenderProfilesById = (options) => (options.client ?? client).delete({
1425
1702
  security: [{ scheme: "bearer", type: "http" }],
1426
- url: "/admin/documents/bulk-delete",
1427
- ...options,
1428
- headers: {
1429
- "Content-Type": "application/vnd.api+json",
1430
- ...options.headers
1431
- }
1703
+ url: "/admin/email-marketing/sender-profiles/{id}",
1704
+ ...options
1432
1705
  });
1433
- var getAdminWebhookConfigs = (options) => (options.client ?? client).get({
1706
+ var getAdminEmailMarketingSenderProfilesById = (options) => (options.client ?? client).get({
1434
1707
  security: [{ scheme: "bearer", type: "http" }],
1435
- url: "/admin/webhook-configs",
1708
+ url: "/admin/email-marketing/sender-profiles/{id}",
1436
1709
  ...options
1437
1710
  });
1438
- var postAdminWebhookConfigs = (options) => (options.client ?? client).post({
1711
+ var patchAdminEmailMarketingSenderProfilesById = (options) => (options.client ?? client).patch({
1439
1712
  security: [{ scheme: "bearer", type: "http" }],
1440
- url: "/admin/webhook-configs",
1713
+ url: "/admin/email-marketing/sender-profiles/{id}",
1441
1714
  ...options,
1442
1715
  headers: {
1443
1716
  "Content-Type": "application/vnd.api+json",
1444
1717
  ...options.headers
1445
1718
  }
1446
1719
  });
1447
- var patchAdminApiKeysByIdAllocate = (options) => (options.client ?? client).patch({
1720
+ var getAdminAgentVersions = (options) => (options.client ?? client).get({
1448
1721
  security: [{ scheme: "bearer", type: "http" }],
1449
- url: "/admin/api-keys/{id}/allocate",
1450
- ...options,
1451
- headers: {
1452
- "Content-Type": "application/vnd.api+json",
1453
- ...options.headers
1454
- }
1722
+ url: "/admin/agent-versions",
1723
+ ...options
1455
1724
  });
1456
- var patchAdminApiKeysByIdRevoke = (options) => (options.client ?? client).patch({
1725
+ var postAdminAgentVersions = (options) => (options.client ?? client).post({
1457
1726
  security: [{ scheme: "bearer", type: "http" }],
1458
- url: "/admin/api-keys/{id}/revoke",
1727
+ url: "/admin/agent-versions",
1459
1728
  ...options,
1460
1729
  headers: {
1461
1730
  "Content-Type": "application/vnd.api+json",
1462
1731
  ...options.headers
1463
1732
  }
1464
1733
  });
1465
- var getAdminBuckets = (options) => (options.client ?? client).get({
1734
+ var getAdminVoiceSessionsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1466
1735
  security: [{ scheme: "bearer", type: "http" }],
1467
- url: "/admin/buckets",
1736
+ url: "/admin/voice/sessions/workspace/{workspace_id}",
1468
1737
  ...options
1469
1738
  });
1470
- var patchAdminApiKeysByIdRotate = (options) => (options.client ?? client).patch({
1739
+ var postAdminEmailOutboundEmails = (options) => (options.client ?? client).post({
1471
1740
  security: [{ scheme: "bearer", type: "http" }],
1472
- url: "/admin/api-keys/{id}/rotate",
1741
+ url: "/admin/email/outbound-emails",
1473
1742
  ...options,
1474
1743
  headers: {
1475
1744
  "Content-Type": "application/vnd.api+json",
1476
1745
  ...options.headers
1477
1746
  }
1478
1747
  });
1479
- var getAdminBucketsById = (options) => (options.client ?? client).get({
1748
+ var getAdminEmailOutboundEmailsWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1480
1749
  security: [{ scheme: "bearer", type: "http" }],
1481
- url: "/admin/buckets/{id}",
1750
+ url: "/admin/email/outbound-emails/workspace/{workspace_id}",
1482
1751
  ...options
1483
1752
  });
1484
- var postAdminWebhookConfigsByIdTest = (options) => (options.client ?? client).post({
1753
+ var getAdminBucketsByIdStats = (options) => (options.client ?? client).get({
1485
1754
  security: [{ scheme: "bearer", type: "http" }],
1486
- url: "/admin/webhook-configs/{id}/test",
1755
+ url: "/admin/buckets/{id}/stats",
1756
+ ...options
1757
+ });
1758
+ var getAdminUsersByEmail = (options) => (options.client ?? client).get({
1759
+ security: [{ scheme: "bearer", type: "http" }],
1760
+ url: "/admin/users/by-email",
1761
+ ...options
1762
+ });
1763
+ var deleteAdminAgentsByIdTrainingExamplesByExampleId = (options) => (options.client ?? client).delete({
1764
+ security: [{ scheme: "bearer", type: "http" }],
1765
+ url: "/admin/agents/{id}/training-examples/{example_id}",
1766
+ ...options
1767
+ });
1768
+ var postAdminAgentsImport = (options) => (options.client ?? client).post({
1769
+ security: [{ scheme: "bearer", type: "http" }],
1770
+ url: "/admin/agents/import",
1487
1771
  ...options,
1488
1772
  headers: {
1489
1773
  "Content-Type": "application/vnd.api+json",
1490
1774
  ...options.headers
1491
1775
  }
1492
1776
  });
1493
- var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client).post({
1777
+ var postAdminAgentsByIdPublishVersion = (options) => (options.client ?? client).post({
1494
1778
  security: [{ scheme: "bearer", type: "http" }],
1495
- url: "/admin/webhook-deliveries/{id}/retry",
1779
+ url: "/admin/agents/{id}/publish-version",
1496
1780
  ...options,
1497
1781
  headers: {
1498
1782
  "Content-Type": "application/vnd.api+json",
1499
1783
  ...options.headers
1500
1784
  }
1501
1785
  });
1502
-
1503
- // src/namespaces/accounts.ts
1504
- function createAccountsNamespace(rb) {
1505
- return {
1506
- list: async (options) => {
1507
- return rb.execute(getAdminAccounts, {}, options);
1508
- },
1509
- get: async (id, options) => {
1510
- return rb.execute(
1511
- getAdminAccountsById,
1512
- { path: { id } },
1513
- options
1514
- );
1515
- },
1516
- credit: async (id, amount, description, options) => {
1786
+ var getAdminDocumentsStats = (options) => (options.client ?? client).get({
1787
+ security: [{ scheme: "bearer", type: "http" }],
1788
+ url: "/admin/documents/stats",
1789
+ ...options
1790
+ });
1791
+ var getAdminWebhookDeliveries = (options) => (options.client ?? client).get({
1792
+ security: [{ scheme: "bearer", type: "http" }],
1793
+ url: "/admin/webhook-deliveries",
1794
+ ...options
1795
+ });
1796
+ var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
1797
+ security: [{ scheme: "bearer", type: "http" }],
1798
+ url: "/admin/extraction/documents",
1799
+ ...options
1800
+ });
1801
+ var getAdminAgentVersionRevisionsById = (options) => (options.client ?? client).get({
1802
+ security: [{ scheme: "bearer", type: "http" }],
1803
+ url: "/admin/agent-version-revisions/{id}",
1804
+ ...options
1805
+ });
1806
+ var getAdminAgentVersionRevisions = (options) => (options.client ?? client).get({
1807
+ security: [{ scheme: "bearer", type: "http" }],
1808
+ url: "/admin/agent-version-revisions",
1809
+ ...options
1810
+ });
1811
+ var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post({
1812
+ security: [{ scheme: "bearer", type: "http" }],
1813
+ url: "/admin/documents/bulk-delete",
1814
+ ...options,
1815
+ headers: {
1816
+ "Content-Type": "application/vnd.api+json",
1817
+ ...options.headers
1818
+ }
1819
+ });
1820
+ var getAdminWebhookConfigs = (options) => (options.client ?? client).get({
1821
+ security: [{ scheme: "bearer", type: "http" }],
1822
+ url: "/admin/webhook-configs",
1823
+ ...options
1824
+ });
1825
+ var postAdminWebhookConfigs = (options) => (options.client ?? client).post({
1826
+ security: [{ scheme: "bearer", type: "http" }],
1827
+ url: "/admin/webhook-configs",
1828
+ ...options,
1829
+ headers: {
1830
+ "Content-Type": "application/vnd.api+json",
1831
+ ...options.headers
1832
+ }
1833
+ });
1834
+ var deleteAdminTrainingSessionsById = (options) => (options.client ?? client).delete({
1835
+ security: [{ scheme: "bearer", type: "http" }],
1836
+ url: "/admin/training-sessions/{id}",
1837
+ ...options
1838
+ });
1839
+ var getAdminTrainingSessionsById = (options) => (options.client ?? client).get({
1840
+ security: [{ scheme: "bearer", type: "http" }],
1841
+ url: "/admin/training-sessions/{id}",
1842
+ ...options
1843
+ });
1844
+ var patchAdminUsersByIdAdmin = (options) => (options.client ?? client).patch({
1845
+ security: [{ scheme: "bearer", type: "http" }],
1846
+ url: "/admin/users/{id}/admin",
1847
+ ...options,
1848
+ headers: {
1849
+ "Content-Type": "application/vnd.api+json",
1850
+ ...options.headers
1851
+ }
1852
+ });
1853
+ var getAdminAgentsByIdTrainingStats = (options) => (options.client ?? client).get({
1854
+ security: [{ scheme: "bearer", type: "http" }],
1855
+ url: "/admin/agents/{id}/training-stats",
1856
+ ...options
1857
+ });
1858
+ var postAdminAgentsByIdTest = (options) => (options.client ?? client).post({
1859
+ security: [{ scheme: "bearer", type: "http" }],
1860
+ url: "/admin/agents/{id}/test",
1861
+ ...options,
1862
+ headers: {
1863
+ "Content-Type": "application/vnd.api+json",
1864
+ ...options.headers
1865
+ }
1866
+ });
1867
+ var patchAdminApiKeysByIdResetPeriod = (options) => (options.client ?? client).patch({
1868
+ security: [{ scheme: "bearer", type: "http" }],
1869
+ url: "/admin/api-keys/{id}/reset-period",
1870
+ ...options,
1871
+ headers: {
1872
+ "Content-Type": "application/vnd.api+json",
1873
+ ...options.headers
1874
+ }
1875
+ });
1876
+ var getAdminVoiceTranscriptionResults = (options) => (options.client ?? client).get({
1877
+ security: [{ scheme: "bearer", type: "http" }],
1878
+ url: "/admin/voice/transcription-results",
1879
+ ...options
1880
+ });
1881
+ var postAdminAgentVersionsByIdRemoveSystemField = (options) => (options.client ?? client).post({
1882
+ security: [{ scheme: "bearer", type: "http" }],
1883
+ url: "/admin/agent-versions/{id}/remove-system-field",
1884
+ ...options,
1885
+ headers: {
1886
+ "Content-Type": "application/vnd.api+json",
1887
+ ...options.headers
1888
+ }
1889
+ });
1890
+ var getAdminApiKeysStats = (options) => (options.client ?? client).get({
1891
+ security: [{ scheme: "bearer", type: "http" }],
1892
+ url: "/admin/api-keys/stats",
1893
+ ...options
1894
+ });
1895
+ var postAdminAgentsByIdTeach = (options) => (options.client ?? client).post({
1896
+ security: [{ scheme: "bearer", type: "http" }],
1897
+ url: "/admin/agents/{id}/teach",
1898
+ ...options,
1899
+ headers: {
1900
+ "Content-Type": "application/vnd.api+json",
1901
+ ...options.headers
1902
+ }
1903
+ });
1904
+ var patchAdminAgentsByIdSchemaVersionsByVersionId = (options) => (options.client ?? client).patch({
1905
+ security: [{ scheme: "bearer", type: "http" }],
1906
+ url: "/admin/agents/{id}/schema-versions/{version_id}",
1907
+ ...options,
1908
+ headers: {
1909
+ "Content-Type": "application/vnd.api+json",
1910
+ ...options.headers
1911
+ }
1912
+ });
1913
+ var getAdminVoiceRecordingsById = (options) => (options.client ?? client).get({
1914
+ security: [{ scheme: "bearer", type: "http" }],
1915
+ url: "/admin/voice/recordings/{id}",
1916
+ ...options
1917
+ });
1918
+ var patchAdminApiKeysByIdRevoke = (options) => (options.client ?? client).patch({
1919
+ security: [{ scheme: "bearer", type: "http" }],
1920
+ url: "/admin/api-keys/{id}/revoke",
1921
+ ...options,
1922
+ headers: {
1923
+ "Content-Type": "application/vnd.api+json",
1924
+ ...options.headers
1925
+ }
1926
+ });
1927
+ var getAdminBuckets = (options) => (options.client ?? client).get({
1928
+ security: [{ scheme: "bearer", type: "http" }],
1929
+ url: "/admin/buckets",
1930
+ ...options
1931
+ });
1932
+ var getAdminAgentsByIdSchemaVersions = (options) => (options.client ?? client).get({
1933
+ security: [{ scheme: "bearer", type: "http" }],
1934
+ url: "/admin/agents/{id}/schema-versions",
1935
+ ...options
1936
+ });
1937
+ var postAdminAgentsByIdSchemaVersions = (options) => (options.client ?? client).post({
1938
+ security: [{ scheme: "bearer", type: "http" }],
1939
+ url: "/admin/agents/{id}/schema-versions",
1940
+ ...options,
1941
+ headers: {
1942
+ "Content-Type": "application/vnd.api+json",
1943
+ ...options.headers
1944
+ }
1945
+ });
1946
+ var patchAdminApiKeysByIdRotate = (options) => (options.client ?? client).patch({
1947
+ security: [{ scheme: "bearer", type: "http" }],
1948
+ url: "/admin/api-keys/{id}/rotate",
1949
+ ...options,
1950
+ headers: {
1951
+ "Content-Type": "application/vnd.api+json",
1952
+ ...options.headers
1953
+ }
1954
+ });
1955
+ var getAdminBucketsById = (options) => (options.client ?? client).get({
1956
+ security: [{ scheme: "bearer", type: "http" }],
1957
+ url: "/admin/buckets/{id}",
1958
+ ...options
1959
+ });
1960
+ var patchAdminUsersByIdResetPassword = (options) => (options.client ?? client).patch({
1961
+ security: [{ scheme: "bearer", type: "http" }],
1962
+ url: "/admin/users/{id}/reset-password",
1963
+ ...options,
1964
+ headers: {
1965
+ "Content-Type": "application/vnd.api+json",
1966
+ ...options.headers
1967
+ }
1968
+ });
1969
+ var deleteAdminEmailOutboundEmailsById = (options) => (options.client ?? client).delete({
1970
+ security: [{ scheme: "bearer", type: "http" }],
1971
+ url: "/admin/email/outbound-emails/{id}",
1972
+ ...options
1973
+ });
1974
+ var getAdminEmailOutboundEmailsById = (options) => (options.client ?? client).get({
1975
+ security: [{ scheme: "bearer", type: "http" }],
1976
+ url: "/admin/email/outbound-emails/{id}",
1977
+ ...options
1978
+ });
1979
+ var getAdminTrainingExamples = (options) => (options.client ?? client).get({
1980
+ security: [{ scheme: "bearer", type: "http" }],
1981
+ url: "/admin/training-examples",
1982
+ ...options
1983
+ });
1984
+ var postAdminTrainingExamples = (options) => (options.client ?? client).post({
1985
+ security: [{ scheme: "bearer", type: "http" }],
1986
+ url: "/admin/training-examples",
1987
+ ...options,
1988
+ headers: {
1989
+ "Content-Type": "application/vnd.api+json",
1990
+ ...options.headers
1991
+ }
1992
+ });
1993
+ var getAdminApiKeysActive = (options) => (options.client ?? client).get({
1994
+ security: [{ scheme: "bearer", type: "http" }],
1995
+ url: "/admin/api-keys/active",
1996
+ ...options
1997
+ });
1998
+ var postAdminAgentsByIdAnalyzeTraining = (options) => (options.client ?? client).post({
1999
+ security: [{ scheme: "bearer", type: "http" }],
2000
+ url: "/admin/agents/{id}/analyze-training",
2001
+ ...options
2002
+ });
2003
+ var postAdminTrainingExamplesBulk = (options) => (options.client ?? client).post({
2004
+ security: [{ scheme: "bearer", type: "http" }],
2005
+ url: "/admin/training-examples/bulk",
2006
+ ...options,
2007
+ headers: {
2008
+ "Content-Type": "application/vnd.api+json",
2009
+ ...options.headers
2010
+ }
2011
+ });
2012
+ var postAdminAgentsByIdClone = (options) => (options.client ?? client).post({
2013
+ security: [{ scheme: "bearer", type: "http" }],
2014
+ url: "/admin/agents/{id}/clone",
2015
+ ...options,
2016
+ headers: {
2017
+ "Content-Type": "application/vnd.api+json",
2018
+ ...options.headers
2019
+ }
2020
+ });
2021
+ var postAdminWebhookConfigsByIdTest = (options) => (options.client ?? client).post({
2022
+ security: [{ scheme: "bearer", type: "http" }],
2023
+ url: "/admin/webhook-configs/{id}/test",
2024
+ ...options,
2025
+ headers: {
2026
+ "Content-Type": "application/vnd.api+json",
2027
+ ...options.headers
2028
+ }
2029
+ });
2030
+ var postAdminAgentVersionComparisons = (options) => (options.client ?? client).post({
2031
+ security: [{ scheme: "bearer", type: "http" }],
2032
+ url: "/admin/agent-version-comparisons",
2033
+ ...options,
2034
+ headers: {
2035
+ "Content-Type": "application/vnd.api+json",
2036
+ ...options.headers
2037
+ }
2038
+ });
2039
+ var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client).post({
2040
+ security: [{ scheme: "bearer", type: "http" }],
2041
+ url: "/admin/webhook-deliveries/{id}/retry",
2042
+ ...options,
2043
+ headers: {
2044
+ "Content-Type": "application/vnd.api+json",
2045
+ ...options.headers
2046
+ }
2047
+ });
2048
+ var patchAdminEmailMarketingSenderProfilesByIdValidateDns = (options) => (options.client ?? client).patch({
2049
+ security: [{ scheme: "bearer", type: "http" }],
2050
+ url: "/admin/email-marketing/sender-profiles/{id}/validate-dns",
2051
+ ...options,
2052
+ headers: {
2053
+ "Content-Type": "application/vnd.api+json",
2054
+ ...options.headers
2055
+ }
2056
+ });
2057
+ var getAdminAgentsUsage = (options) => (options.client ?? client).get({
2058
+ security: [{ scheme: "bearer", type: "http" }],
2059
+ url: "/admin/agents/usage",
2060
+ ...options
2061
+ });
2062
+ var postAdminAgentsByIdValidate = (options) => (options.client ?? client).post({
2063
+ security: [{ scheme: "bearer", type: "http" }],
2064
+ url: "/admin/agents/{id}/validate",
2065
+ ...options,
2066
+ headers: {
2067
+ "Content-Type": "application/vnd.api+json",
2068
+ ...options.headers
2069
+ }
2070
+ });
2071
+ var postAdminEmailMarketingCampaignsByIdSend = (options) => (options.client ?? client).post({
2072
+ security: [{ scheme: "bearer", type: "http" }],
2073
+ url: "/admin/email-marketing/campaigns/{id}/send",
2074
+ ...options,
2075
+ headers: {
2076
+ "Content-Type": "application/vnd.api+json",
2077
+ ...options.headers
2078
+ }
2079
+ });
2080
+ var postAdminEmailMarketingSenderProfiles = (options) => (options.client ?? client).post({
2081
+ security: [{ scheme: "bearer", type: "http" }],
2082
+ url: "/admin/email-marketing/sender-profiles",
2083
+ ...options,
2084
+ headers: {
2085
+ "Content-Type": "application/vnd.api+json",
2086
+ ...options.headers
2087
+ }
2088
+ });
2089
+ var getAdminVoiceRecordings = (options) => (options.client ?? client).get({
2090
+ security: [{ scheme: "bearer", type: "http" }],
2091
+ url: "/admin/voice/recordings",
2092
+ ...options
2093
+ });
2094
+
2095
+ // src/namespaces/agents.ts
2096
+ function createAgentsNamespace(rb) {
2097
+ return {
2098
+ /**
2099
+ * Lists all agents (platform-wide, no workspace filter).
2100
+ *
2101
+ * @param options - Optional request options.
2102
+ * @returns Array of Agent objects.
2103
+ *
2104
+ * @example
2105
+ * const agents = await admin.agents.list();
2106
+ */
2107
+ list: async (options) => {
2108
+ return rb.execute(getAdminAgents, {}, options);
2109
+ },
2110
+ /**
2111
+ * Fetches a single agent by ID.
2112
+ *
2113
+ * @param id - The UUID of the agent.
2114
+ * @param options - Optional request options.
2115
+ * @returns The Agent record.
2116
+ *
2117
+ * @example
2118
+ * const agent = await admin.agents.get('agt_01...');
2119
+ */
2120
+ get: async (id, options) => {
2121
+ return rb.execute(getAdminAgentsById, { path: { id } }, options);
2122
+ },
2123
+ /**
2124
+ * Clones an agent within the same workspace.
2125
+ *
2126
+ * @param id - The UUID of the agent to clone.
2127
+ * @param attributes - Optional attributes for the clone (name, description).
2128
+ * @param options - Optional request options.
2129
+ * @returns The cloned Agent.
2130
+ *
2131
+ * @example
2132
+ * const clone = await admin.agents.clone('agt_01...', { name: 'Clone of Bot' });
2133
+ */
2134
+ clone: async (id, attributes = {}, options) => {
2135
+ return rb.execute(
2136
+ postAdminAgentsByIdClone,
2137
+ { path: { id }, body: { data: { type: "agent", attributes } } },
2138
+ options
2139
+ );
2140
+ },
2141
+ /**
2142
+ * Clones an agent into a different workspace.
2143
+ *
2144
+ * @param agentId - The UUID of the agent to clone.
2145
+ * @param targetWorkspaceId - The UUID of the destination workspace.
2146
+ * @param options - Optional request options.
2147
+ * @returns The cloned Agent in the target workspace.
2148
+ *
2149
+ * @example
2150
+ * const cloned = await admin.agents.cloneForWorkspace('agt_01...', 'ws_02...');
2151
+ */
2152
+ cloneForWorkspace: async (agentId, targetWorkspaceId, options) => {
2153
+ return rb.execute(
2154
+ postAdminAgentsCloneForWorkspace,
2155
+ {
2156
+ body: {
2157
+ data: {
2158
+ type: "agent",
2159
+ attributes: {
2160
+ agent_id: agentId,
2161
+ target_workspace_id: targetWorkspaceId
2162
+ }
2163
+ }
2164
+ }
2165
+ },
2166
+ options
2167
+ );
2168
+ },
2169
+ /**
2170
+ * Exports an agent to a portable JSON bundle.
2171
+ *
2172
+ * @param id - The UUID of the agent to export.
2173
+ * @param options - Optional request options.
2174
+ * @returns The export bundle payload.
2175
+ *
2176
+ * @example
2177
+ * const bundle = await admin.agents.export('agt_01...');
2178
+ */
2179
+ export: async (id, options) => {
2180
+ return rb.execute(
2181
+ postAdminAgentsByIdExport,
2182
+ { path: { id }, body: {} },
2183
+ options
2184
+ );
2185
+ },
2186
+ /**
2187
+ * Imports an agent from a portable export bundle.
2188
+ *
2189
+ * @param data - The export bundle object.
2190
+ * @param options - Optional request options.
2191
+ * @returns The newly created Agent.
2192
+ *
2193
+ * @example
2194
+ * const imported = await admin.agents.import(exportBundle);
2195
+ */
2196
+ import: async (data, options) => {
2197
+ return rb.execute(
2198
+ postAdminAgentsImport,
2199
+ { body: { data: { type: "agent", attributes: { data } } } },
2200
+ options
2201
+ );
2202
+ },
2203
+ /**
2204
+ * Runs prediction/inference on an agent.
2205
+ *
2206
+ * @param agentId - The UUID of the agent.
2207
+ * @param input - Input data for prediction.
2208
+ * @param options - Optional request options.
2209
+ * @returns Prediction result.
2210
+ *
2211
+ * @example
2212
+ * const result = await admin.agents.predict('agt_01...', { text: 'Classify this' });
2213
+ */
2214
+ predict: async (agentId, input, options) => {
2215
+ return rb.execute(
2216
+ postAdminAgentsPredict,
2217
+ {
2218
+ body: {
2219
+ data: {
2220
+ type: "agent",
2221
+ attributes: { agent_id: agentId, ...input }
2222
+ }
2223
+ }
2224
+ },
2225
+ options
2226
+ );
2227
+ },
2228
+ /**
2229
+ * Runs an agent against a test input and returns the result.
2230
+ *
2231
+ * @param id - The UUID of the agent.
2232
+ * @param attributes - Test attributes (input, expected_output, etc.).
2233
+ * @param options - Optional request options.
2234
+ * @returns Test result payload.
2235
+ *
2236
+ * @example
2237
+ * const result = await admin.agents.test('agt_01...', { input: { text: '...' } });
2238
+ */
2239
+ test: async (id, attributes, options) => {
2240
+ return rb.execute(
2241
+ postAdminAgentsByIdTest,
2242
+ { path: { id }, body: { data: { type: "agent", attributes } } },
2243
+ options
2244
+ );
2245
+ },
2246
+ /**
2247
+ * Validates an agent's configuration without publishing.
2248
+ *
2249
+ * @param id - The UUID of the agent.
2250
+ * @param options - Optional request options.
2251
+ * @returns Validation result with any errors or warnings.
2252
+ *
2253
+ * @example
2254
+ * const result = await admin.agents.validate('agt_01...');
2255
+ */
2256
+ validate: async (id, options) => {
2257
+ return rb.execute(
2258
+ postAdminAgentsByIdValidate,
2259
+ { path: { id }, body: {} },
2260
+ options
2261
+ );
2262
+ },
2263
+ /**
2264
+ * Runs a training job (fine-tuning) on the agent using its examples.
2265
+ *
2266
+ * @param id - The UUID of the agent.
2267
+ * @param attributes - Training configuration attributes.
2268
+ * @param options - Optional request options.
2269
+ * @returns Training job status payload.
2270
+ *
2271
+ * @example
2272
+ * await admin.agents.teach('agt_01...', { epochs: 3 });
2273
+ */
2274
+ teach: async (id, attributes = {}, options) => {
2275
+ return rb.execute(
2276
+ postAdminAgentsByIdTeach,
2277
+ { path: { id }, body: { data: { type: "agent", attributes } } },
2278
+ options
2279
+ );
2280
+ },
2281
+ /**
2282
+ * Publishes a new immutable version from the agent's current state.
2283
+ *
2284
+ * @param id - The UUID of the agent.
2285
+ * @param options - Optional request options.
2286
+ * @returns The newly created AgentVersion.
2287
+ *
2288
+ * @example
2289
+ * const version = await admin.agents.publishVersion('agt_01...');
2290
+ */
2291
+ publishVersion: async (id, options) => {
2292
+ return rb.execute(
2293
+ postAdminAgentsByIdPublishVersion,
2294
+ { path: { id }, body: {} },
2295
+ options
2296
+ );
2297
+ },
2298
+ /**
2299
+ * Restores a previously published version as the active version.
2300
+ *
2301
+ * @param id - The UUID of the agent.
2302
+ * @param attributes - Must include `version_id` of the version to restore.
2303
+ * @param options - Optional request options.
2304
+ * @returns The restored AgentVersion.
2305
+ *
2306
+ * @example
2307
+ * const version = await admin.agents.restoreVersion('agt_01...', { version_id: 'ver_01...' });
2308
+ */
2309
+ restoreVersion: async (id, attributes, options) => {
2310
+ return rb.execute(
2311
+ postAdminAgentsByIdRestoreVersion,
2312
+ { path: { id }, body: { data: { type: "agent", attributes } } },
2313
+ options
2314
+ );
2315
+ },
2316
+ /**
2317
+ * Analyzes training examples and returns insights.
2318
+ *
2319
+ * @param id - The UUID of the agent.
2320
+ * @param options - Optional request options.
2321
+ * @returns Training analysis result.
2322
+ *
2323
+ * @example
2324
+ * const analysis = await admin.agents.analyzeTraining('agt_01...');
2325
+ */
2326
+ analyzeTraining: async (id, options) => {
2327
+ return rb.execute(
2328
+ postAdminAgentsByIdAnalyzeTraining,
2329
+ { path: { id }, body: {} },
2330
+ options
2331
+ );
2332
+ },
2333
+ /**
2334
+ * Retrieves usage statistics for a single agent.
2335
+ *
2336
+ * @param id - The UUID of the agent.
2337
+ * @param options - Optional request options.
2338
+ * @returns Usage data for the agent.
2339
+ *
2340
+ * @example
2341
+ * const usage = await admin.agents.usage('agt_01...');
2342
+ */
2343
+ usage: async (id, options) => {
2344
+ return rb.execute(
2345
+ getAdminAgentsByIdUsage,
2346
+ { path: { id } },
2347
+ options
2348
+ );
2349
+ },
2350
+ /**
2351
+ * Retrieves usage information for all agents.
2352
+ *
2353
+ * @param options - Optional request options.
2354
+ * @returns Array of usage data for all agents.
2355
+ *
2356
+ * @example
2357
+ * const allUsage = await admin.agents.usageAll();
2358
+ */
2359
+ usageAll: async (options) => {
2360
+ return rb.execute(
2361
+ getAdminAgentsUsage,
2362
+ {},
2363
+ options
2364
+ );
2365
+ },
2366
+ /**
2367
+ * Retrieves execution and performance statistics for an agent.
2368
+ *
2369
+ * @param id - The UUID of the agent.
2370
+ * @param options - Optional request options.
2371
+ * @returns Statistics payload.
2372
+ *
2373
+ * @example
2374
+ * const stats = await admin.agents.stats('agt_01...');
2375
+ */
2376
+ stats: async (id, options) => {
2377
+ return rb.execute(
2378
+ getAdminAgentsByIdStats,
2379
+ { path: { id } },
2380
+ options
2381
+ );
2382
+ },
2383
+ /**
2384
+ * Retrieves training statistics for a single agent.
2385
+ *
2386
+ * @param id - The UUID of the agent.
2387
+ * @param options - Optional request options.
2388
+ * @returns Training statistics data.
2389
+ *
2390
+ * @example
2391
+ * const stats = await admin.agents.trainingStats('agt_01...');
2392
+ */
2393
+ trainingStats: async (id, options) => {
2394
+ return rb.execute(
2395
+ getAdminAgentsByIdTrainingStats,
2396
+ { path: { id } },
2397
+ options
2398
+ );
2399
+ },
2400
+ /**
2401
+ * Sub-namespace for managing immutable agent versions.
2402
+ */
2403
+ versions: {
2404
+ /**
2405
+ * Lists all agent versions.
2406
+ *
2407
+ * @param options - Optional request options.
2408
+ * @returns Array of AgentVersion objects.
2409
+ *
2410
+ * @example
2411
+ * const versions = await admin.agents.versions.list();
2412
+ */
2413
+ list: async (options) => {
2414
+ return rb.execute(getAdminAgentVersions, {}, options);
2415
+ },
2416
+ /**
2417
+ * Fetches a single agent version by ID.
2418
+ *
2419
+ * @param id - The UUID of the agent version.
2420
+ * @param options - Optional request options.
2421
+ * @returns The AgentVersion record.
2422
+ *
2423
+ * @example
2424
+ * const version = await admin.agents.versions.get('ver_01...');
2425
+ */
2426
+ get: async (id, options) => {
2427
+ return rb.execute(
2428
+ getAdminAgentVersionsById,
2429
+ { path: { id } },
2430
+ options
2431
+ );
2432
+ },
2433
+ /**
2434
+ * Permanently deletes an agent version.
2435
+ *
2436
+ * @param id - The UUID of the version to delete.
2437
+ * @param options - Optional request options.
2438
+ * @returns True on successful deletion.
2439
+ *
2440
+ * @example
2441
+ * await admin.agents.versions.delete('ver_01...');
2442
+ */
2443
+ delete: async (id, options) => {
2444
+ return rb.executeDelete(
2445
+ deleteAdminAgentVersionsById,
2446
+ { path: { id } },
2447
+ options
2448
+ );
2449
+ },
2450
+ /**
2451
+ * Creates a new agent version snapshot.
2452
+ *
2453
+ * @param attributes - Version attributes (agent_id, prompt_template, fields, etc.).
2454
+ * @param options - Optional request options.
2455
+ * @returns The newly created AgentVersion.
2456
+ *
2457
+ * @example
2458
+ * const version = await admin.agents.versions.create({ agent_id: 'agt_01...', ... });
2459
+ */
2460
+ create: async (attributes, options) => {
2461
+ return rb.execute(
2462
+ postAdminAgentVersions,
2463
+ { body: { data: { type: "agent_version", attributes } } },
2464
+ options
2465
+ );
2466
+ },
2467
+ /**
2468
+ * Marks a system field as selected for this version.
2469
+ *
2470
+ * @param id - The UUID of the agent version.
2471
+ * @param fieldName - The name of the system field to add (e.g. `_filename`).
2472
+ * @param options - Optional request options.
2473
+ * @returns The updated AgentVersion.
2474
+ *
2475
+ * @example
2476
+ * await admin.agents.versions.addSystemField('ver_01...', '_filename');
2477
+ */
2478
+ addSystemField: async (id, fieldName, options) => {
2479
+ return rb.execute(
2480
+ postAdminAgentVersionsByIdAddSystemField,
2481
+ {
2482
+ path: { id },
2483
+ body: {
2484
+ data: {
2485
+ type: "agent_version",
2486
+ attributes: { system_field_name: fieldName }
2487
+ }
2488
+ }
2489
+ },
2490
+ options
2491
+ );
2492
+ },
2493
+ /**
2494
+ * Removes a system field from the selected set for this version.
2495
+ *
2496
+ * @param id - The UUID of the agent version.
2497
+ * @param fieldName - The name of the system field to remove (e.g. `_filename`).
2498
+ * @param options - Optional request options.
2499
+ * @returns The updated AgentVersion.
2500
+ *
2501
+ * @example
2502
+ * await admin.agents.versions.removeSystemField('ver_01...', '_filename');
2503
+ */
2504
+ removeSystemField: async (id, fieldName, options) => {
2505
+ return rb.execute(
2506
+ postAdminAgentVersionsByIdRemoveSystemField,
2507
+ {
2508
+ path: { id },
2509
+ body: {
2510
+ data: {
2511
+ type: "agent_version",
2512
+ attributes: { system_field_name: fieldName }
2513
+ }
2514
+ }
2515
+ },
2516
+ options
2517
+ );
2518
+ },
2519
+ /**
2520
+ * Sets the full list of selected system fields for this version.
2521
+ *
2522
+ * @param id - The UUID of the agent version.
2523
+ * @param fieldNames - Array of system field names to set (e.g. `['_filename', '_pages']`).
2524
+ * @param options - Optional request options.
2525
+ * @returns The updated AgentVersion.
2526
+ *
2527
+ * @example
2528
+ * await admin.agents.versions.setSystemFields('ver_01...', ['_filename', '_pages']);
2529
+ */
2530
+ setSystemFields: async (id, fieldNames, options) => {
2531
+ return rb.execute(
2532
+ postAdminAgentVersionsByIdSetSystemFields,
2533
+ {
2534
+ path: { id },
2535
+ body: {
2536
+ data: {
2537
+ type: "agent_version",
2538
+ attributes: { system_field_names: fieldNames }
2539
+ }
2540
+ }
2541
+ },
2542
+ options
2543
+ );
2544
+ },
2545
+ /**
2546
+ * Retrieves performance metrics for an agent version.
2547
+ *
2548
+ * @param id - The UUID of the agent version.
2549
+ * @param options - Optional request options.
2550
+ * @returns Metrics data for the version.
2551
+ *
2552
+ * @example
2553
+ * const metrics = await admin.agents.versions.metrics('ver_01...');
2554
+ */
2555
+ metrics: async (id, options) => {
2556
+ return rb.execute(
2557
+ getAdminAgentVersionsByIdMetrics,
2558
+ { path: { id } },
2559
+ options
2560
+ );
2561
+ },
2562
+ /**
2563
+ * Lists revision history for an agent version.
2564
+ *
2565
+ * @param id - The UUID of the agent version.
2566
+ * @param options - Optional request options.
2567
+ * @returns Array of revision records.
2568
+ *
2569
+ * @example
2570
+ * const revisions = await admin.agents.versions.revisions('ver_01...');
2571
+ */
2572
+ revisions: async (id, options) => {
2573
+ return rb.execute(
2574
+ getAdminAgentVersionsByIdRevisions,
2575
+ { path: { id } },
2576
+ options
2577
+ );
2578
+ },
2579
+ /**
2580
+ * Fetches a single revision record by ID.
2581
+ *
2582
+ * @param id - The UUID of the revision.
2583
+ * @param options - Optional request options.
2584
+ * @returns The revision record.
2585
+ *
2586
+ * @example
2587
+ * const revision = await admin.agents.versions.getRevision('rev_01...');
2588
+ */
2589
+ getRevision: async (id, options) => {
2590
+ return rb.execute(
2591
+ getAdminAgentVersionRevisionsById,
2592
+ { path: { id } },
2593
+ options
2594
+ );
2595
+ },
2596
+ /**
2597
+ * Lists all revisions across all agent versions.
2598
+ *
2599
+ * @param options - Optional request options.
2600
+ * @returns Array of revision records.
2601
+ *
2602
+ * @example
2603
+ * const revisions = await admin.agents.versions.listAllRevisions();
2604
+ */
2605
+ listAllRevisions: async (options) => {
2606
+ return rb.execute(
2607
+ getAdminAgentVersionRevisions,
2608
+ {},
2609
+ options
2610
+ );
2611
+ },
2612
+ /**
2613
+ * Compares two agent versions side-by-side.
2614
+ *
2615
+ * @param versionAId - UUID of the first version.
2616
+ * @param versionBId - UUID of the second version.
2617
+ * @param options - Optional request options.
2618
+ * @returns Comparison result with schema_diff and prompt_diff.
2619
+ *
2620
+ * @example
2621
+ * const diff = await admin.agents.versions.compare('ver_A...', 'ver_B...');
2622
+ */
2623
+ compare: async (versionAId, versionBId, options) => {
2624
+ return rb.execute(
2625
+ postAdminAgentVersionComparisons,
2626
+ {
2627
+ body: {
2628
+ data: {
2629
+ type: "agent_version_comparison",
2630
+ attributes: {
2631
+ version_a_id: versionAId,
2632
+ version_b_id: versionBId
2633
+ }
2634
+ }
2635
+ }
2636
+ },
2637
+ options
2638
+ );
2639
+ },
2640
+ /**
2641
+ * Sub-namespace for managing schema versions within an agent.
2642
+ */
2643
+ schemaVersions: {
2644
+ /**
2645
+ * Lists all schema versions for an agent.
2646
+ *
2647
+ * @param agentId - The UUID of the agent.
2648
+ * @param options - Optional request options.
2649
+ * @returns Array of schema version records.
2650
+ *
2651
+ * @example
2652
+ * const versions = await admin.agents.versions.schemaVersions.list('agt_01...');
2653
+ */
2654
+ list: async (agentId, options) => {
2655
+ return rb.execute(
2656
+ getAdminAgentsByIdSchemaVersions,
2657
+ { path: { id: agentId } },
2658
+ options
2659
+ );
2660
+ },
2661
+ /**
2662
+ * Creates a new schema version for an agent.
2663
+ *
2664
+ * @param agentId - The UUID of the agent.
2665
+ * @param attributes - Schema version attributes.
2666
+ * @param options - Optional request options.
2667
+ * @returns The newly created schema version.
2668
+ *
2669
+ * @example
2670
+ * const sv = await admin.agents.versions.schemaVersions.create('agt_01...', { fields: [...] });
2671
+ */
2672
+ create: async (agentId, attributes, options) => {
2673
+ return rb.execute(
2674
+ postAdminAgentsByIdSchemaVersions,
2675
+ {
2676
+ path: { id: agentId },
2677
+ body: { data: { type: "agent_version", attributes } }
2678
+ },
2679
+ options
2680
+ );
2681
+ },
2682
+ /**
2683
+ * Activates a schema version, making it the live version.
2684
+ *
2685
+ * @param agentId - The UUID of the agent.
2686
+ * @param versionId - The UUID of the schema version to activate.
2687
+ * @param options - Optional request options.
2688
+ * @returns The activated schema version.
2689
+ *
2690
+ * @example
2691
+ * await admin.agents.versions.schemaVersions.activate('agt_01...', 'ver_01...');
2692
+ */
2693
+ activate: async (agentId, versionId, options) => {
2694
+ return rb.execute(
2695
+ postAdminAgentsByIdSchemaVersionsByVersionIdActivate,
2696
+ { path: { id: agentId, version_id: versionId }, body: {} },
2697
+ options
2698
+ );
2699
+ },
2700
+ /**
2701
+ * Updates an existing schema version.
2702
+ *
2703
+ * @param agentId - The UUID of the agent.
2704
+ * @param versionId - The UUID of the schema version to update.
2705
+ * @param attributes - Attributes to update.
2706
+ * @param options - Optional request options.
2707
+ * @returns The updated schema version.
2708
+ *
2709
+ * @example
2710
+ * await admin.agents.versions.schemaVersions.update('agt_01...', 'ver_01...', { fields: [...] });
2711
+ */
2712
+ update: async (agentId, versionId, attributes, options) => {
2713
+ return rb.execute(
2714
+ patchAdminAgentsByIdSchemaVersionsByVersionId,
2715
+ {
2716
+ path: { id: agentId, version_id: versionId },
2717
+ body: { data: { type: "agent_version", attributes } }
2718
+ },
2719
+ options
2720
+ );
2721
+ }
2722
+ }
2723
+ },
2724
+ /**
2725
+ * Sub-namespace for managing training examples attached to agents.
2726
+ */
2727
+ training: {
2728
+ /**
2729
+ * Lists all training examples.
2730
+ *
2731
+ * @param options - Optional request options.
2732
+ * @returns Array of TrainingExample objects.
2733
+ *
2734
+ * @example
2735
+ * const examples = await admin.agents.training.list();
2736
+ */
2737
+ list: async (options) => {
2738
+ return rb.execute(
2739
+ getAdminTrainingExamples,
2740
+ {},
2741
+ options
2742
+ );
2743
+ },
2744
+ /**
2745
+ * Fetches a single training example by ID.
2746
+ *
2747
+ * @param id - The UUID of the training example.
2748
+ * @param options - Optional request options.
2749
+ * @returns The TrainingExample record.
2750
+ *
2751
+ * @example
2752
+ * const example = await admin.agents.training.get('tex_01...');
2753
+ */
2754
+ get: async (id, options) => {
2755
+ return rb.execute(
2756
+ getAdminTrainingExamplesById,
2757
+ { path: { id } },
2758
+ options
2759
+ );
2760
+ },
2761
+ /**
2762
+ * Creates a new training example.
2763
+ *
2764
+ * @param attributes - Training example attributes (agent_id, input_text, output_json, etc.).
2765
+ * @param options - Optional request options.
2766
+ * @returns The created TrainingExample.
2767
+ *
2768
+ * @example
2769
+ * const example = await admin.agents.training.create({ agent_id: 'agt_01...', input_text: '...', output_json: {} });
2770
+ */
2771
+ create: async (attributes, options) => {
2772
+ return rb.execute(
2773
+ postAdminTrainingExamples,
2774
+ { body: { data: { type: "training_example", attributes } } },
2775
+ options
2776
+ );
2777
+ },
2778
+ /**
2779
+ * Updates a training example's attributes.
2780
+ *
2781
+ * @param id - The UUID of the training example.
2782
+ * @param attributes - Attributes to update.
2783
+ * @param options - Optional request options.
2784
+ * @returns The updated TrainingExample.
2785
+ *
2786
+ * @example
2787
+ * const updated = await admin.agents.training.update('tex_01...', { label: 'reviewed' });
2788
+ */
2789
+ update: async (id, attributes, options) => {
2790
+ return rb.execute(
2791
+ patchAdminTrainingExamplesById,
2792
+ {
2793
+ path: { id },
2794
+ body: { data: { id, type: "training_example", attributes } }
2795
+ },
2796
+ options
2797
+ );
2798
+ },
2799
+ /**
2800
+ * Deletes a training example.
2801
+ *
2802
+ * @param id - The UUID of the training example to delete.
2803
+ * @param options - Optional request options.
2804
+ * @returns True on successful deletion.
2805
+ *
2806
+ * @example
2807
+ * await admin.agents.training.delete('tex_01...');
2808
+ */
2809
+ delete: async (id, options) => {
2810
+ return rb.executeDelete(
2811
+ deleteAdminTrainingExamplesById,
2812
+ { path: { id } },
2813
+ options
2814
+ );
2815
+ },
2816
+ /**
2817
+ * Creates multiple training examples in a single batch operation.
2818
+ *
2819
+ * @param examples - Array of training example attribute objects.
2820
+ * @param options - Optional request options.
2821
+ * @returns Array of created TrainingExample objects.
2822
+ *
2823
+ * @example
2824
+ * const created = await admin.agents.training.bulkCreate([
2825
+ * { agent_id: 'agt_01...', input_text: '...', output_json: {} },
2826
+ * ]);
2827
+ */
2828
+ bulkCreate: async (examples, options) => {
2829
+ return rb.execute(
2830
+ postAdminTrainingExamplesBulk,
2831
+ {
2832
+ body: {
2833
+ data: examples.map((attrs) => ({
2834
+ type: "training_example",
2835
+ attributes: attrs
2836
+ }))
2837
+ }
2838
+ },
2839
+ options
2840
+ );
2841
+ },
2842
+ /**
2843
+ * Deletes multiple training examples in a single batch operation.
2844
+ *
2845
+ * @param ids - Array of training example UUIDs to delete.
2846
+ * @param options - Optional request options.
2847
+ * @returns Deletion result payload.
2848
+ *
2849
+ * @example
2850
+ * await admin.agents.training.bulkDelete(['tex_01...', 'tex_02...']);
2851
+ */
2852
+ bulkDelete: async (ids, options) => {
2853
+ return rb.execute(
2854
+ postAdminTrainingExamplesBulkDelete,
2855
+ {
2856
+ body: { data: ids.map((id) => ({ type: "training_example", id })) }
2857
+ },
2858
+ options
2859
+ );
2860
+ },
2861
+ /**
2862
+ * Searches training examples by semantic similarity.
2863
+ *
2864
+ * @param query - The search query text.
2865
+ * @param options - Optional request options.
2866
+ * @returns Array of matching TrainingExample objects.
2867
+ *
2868
+ * @example
2869
+ * const results = await admin.agents.training.search('invoice total');
2870
+ */
2871
+ search: async (query, options) => {
2872
+ return rb.execute(
2873
+ postAdminTrainingExamplesSearch,
2874
+ {
2875
+ body: {
2876
+ data: { type: "training_example", attributes: { query } }
2877
+ }
2878
+ },
2879
+ options
2880
+ );
2881
+ },
2882
+ /**
2883
+ * Lists training examples for a specific agent.
2884
+ *
2885
+ * @param agentId - The UUID of the agent.
2886
+ * @param options - Optional request options.
2887
+ * @returns Array of training examples for the agent.
2888
+ *
2889
+ * @example
2890
+ * const examples = await admin.agents.training.listForAgent('agt_01...');
2891
+ */
2892
+ listForAgent: async (agentId, options) => {
2893
+ return rb.execute(
2894
+ getAdminAgentsByIdTrainingExamples,
2895
+ { path: { id: agentId } },
2896
+ options
2897
+ );
2898
+ },
2899
+ /**
2900
+ * Deletes a training example for a specific agent.
2901
+ *
2902
+ * @param agentId - The UUID of the agent.
2903
+ * @param exampleId - The UUID of the training example.
2904
+ * @param options - Optional request options.
2905
+ * @returns True on successful deletion.
2906
+ *
2907
+ * @example
2908
+ * await admin.agents.training.deleteForAgent('agt_01...', 'tex_01...');
2909
+ */
2910
+ deleteForAgent: async (agentId, exampleId, options) => {
2911
+ return rb.executeDelete(
2912
+ deleteAdminAgentsByIdTrainingExamplesByExampleId,
2913
+ { path: { id: agentId, example_id: exampleId } },
2914
+ options
2915
+ );
2916
+ },
2917
+ /**
2918
+ * Sub-namespace for managing training sessions.
2919
+ */
2920
+ sessions: {
2921
+ /**
2922
+ * Lists training sessions for a specific agent.
2923
+ *
2924
+ * @param agentId - The UUID of the agent.
2925
+ * @param options - Optional request options.
2926
+ * @returns Array of training session records.
2927
+ *
2928
+ * @example
2929
+ * const sessions = await admin.agents.training.sessions.list('agt_01...');
2930
+ */
2931
+ list: async (agentId, options) => {
2932
+ return rb.execute(
2933
+ getAdminTrainingSessionsAgentsByAgentIdSessions,
2934
+ { path: { agent_id: agentId } },
2935
+ options
2936
+ );
2937
+ },
2938
+ /**
2939
+ * Fetches a single training session by ID.
2940
+ *
2941
+ * @param id - The UUID of the training session.
2942
+ * @param options - Optional request options.
2943
+ * @returns The training session record.
2944
+ *
2945
+ * @example
2946
+ * const session = await admin.agents.training.sessions.get('ts_01...');
2947
+ */
2948
+ get: async (id, options) => {
2949
+ return rb.execute(
2950
+ getAdminTrainingSessionsById,
2951
+ { path: { id } },
2952
+ options
2953
+ );
2954
+ },
2955
+ /**
2956
+ * Deletes a training session.
2957
+ *
2958
+ * @param id - The UUID of the training session.
2959
+ * @param options - Optional request options.
2960
+ * @returns True on successful deletion.
2961
+ *
2962
+ * @example
2963
+ * await admin.agents.training.sessions.delete('ts_01...');
2964
+ */
2965
+ delete: async (id, options) => {
2966
+ return rb.executeDelete(
2967
+ deleteAdminTrainingSessionsById,
2968
+ { path: { id } },
2969
+ options
2970
+ );
2971
+ }
2972
+ }
2973
+ },
2974
+ /**
2975
+ * Sub-namespace for field templates — reusable field definitions.
2976
+ */
2977
+ fieldTemplates: {
2978
+ /**
2979
+ * Lists all available field templates.
2980
+ *
2981
+ * @param options - Optional request options.
2982
+ * @returns Array of field template objects.
2983
+ *
2984
+ * @example
2985
+ * const templates = await admin.agents.fieldTemplates.list();
2986
+ */
2987
+ list: async (options) => {
2988
+ return rb.execute(
2989
+ getAdminFieldTemplates,
2990
+ {},
2991
+ options
2992
+ );
2993
+ },
2994
+ /**
2995
+ * Fetches a single field template by ID.
2996
+ *
2997
+ * @param id - The UUID of the field template.
2998
+ * @param options - Optional request options.
2999
+ * @returns The field template object.
3000
+ *
3001
+ * @example
3002
+ * const template = await admin.agents.fieldTemplates.get('ftpl_01...');
3003
+ */
3004
+ get: async (id, options) => {
3005
+ return rb.execute(
3006
+ getAdminFieldTemplatesById,
3007
+ { path: { id } },
3008
+ options
3009
+ );
3010
+ },
3011
+ /**
3012
+ * Creates a new field template.
3013
+ *
3014
+ * @param attributes - Field template attributes (name, category, field_type, etc.).
3015
+ * @param options - Optional request options.
3016
+ * @returns The created field template object.
3017
+ *
3018
+ * @example
3019
+ * const template = await admin.agents.fieldTemplates.create({ name: 'Invoice Total', category: 'finance', field_type: 'currency' });
3020
+ */
3021
+ create: async (attributes, options) => {
3022
+ return rb.execute(
3023
+ postAdminFieldTemplates,
3024
+ { body: { data: { type: "field_template", attributes } } },
3025
+ options
3026
+ );
3027
+ },
3028
+ /**
3029
+ * Permanently deletes a field template by ID.
3030
+ *
3031
+ * @param id - The UUID of the field template to delete.
3032
+ * @param options - Optional request options.
3033
+ * @returns True on successful deletion.
3034
+ *
3035
+ * @example
3036
+ * await admin.agents.fieldTemplates.delete('ftpl_01...');
3037
+ */
3038
+ delete: async (id, options) => {
3039
+ return rb.executeDelete(
3040
+ deleteAdminFieldTemplatesById,
3041
+ { path: { id } },
3042
+ options
3043
+ );
3044
+ }
3045
+ }
3046
+ };
3047
+ }
3048
+
3049
+ // src/namespaces/accounts.ts
3050
+ function createAccountsNamespace(rb) {
3051
+ return {
3052
+ /**
3053
+ * Lists all billing accounts across the platform.
3054
+ *
3055
+ * @param options - Optional request options (headers, abort signal).
3056
+ * @returns Array of Account objects with current balances.
3057
+ */
3058
+ list: async (options) => {
3059
+ return rb.execute(getAdminAccounts, {}, options);
3060
+ },
3061
+ /**
3062
+ * Fetches a single billing account by ID.
3063
+ *
3064
+ * @param id - Account ID.
3065
+ * @param options - Optional request options.
3066
+ * @returns The Account record.
3067
+ */
3068
+ get: async (id, options) => {
3069
+ return rb.execute(
3070
+ getAdminAccountsById,
3071
+ { path: { id } },
3072
+ options
3073
+ );
3074
+ },
3075
+ /**
3076
+ * Adds credits to an account balance.
3077
+ *
3078
+ * Use for manual top-ups, promotional credits, or correction adjustments.
3079
+ * The amount must be a positive number greater than zero.
3080
+ *
3081
+ * @param id - Account ID.
3082
+ * @param amount - Number of credits to add (must be > 0).
3083
+ * @param description - Optional human-readable reason for the credit.
3084
+ * @param options - Optional request options.
3085
+ * @returns Updated Account with the new balance.
3086
+ */
3087
+ credit: async (id, amount, description, options) => {
1517
3088
  if (amount <= 0) {
1518
3089
  throw new Error("Credit amount must be positive");
1519
3090
  }
@@ -1528,6 +3099,18 @@ function createAccountsNamespace(rb) {
1528
3099
  options
1529
3100
  );
1530
3101
  },
3102
+ /**
3103
+ * Deducts credits from an account balance.
3104
+ *
3105
+ * Use for charge-backs, manual usage adjustments, or corrections.
3106
+ * The amount must be a positive number greater than zero.
3107
+ *
3108
+ * @param id - Account ID.
3109
+ * @param amount - Number of credits to deduct (must be > 0).
3110
+ * @param description - Optional human-readable reason for the debit.
3111
+ * @param options - Optional request options.
3112
+ * @returns Updated Account with the new balance.
3113
+ */
1531
3114
  debit: async (id, amount, description, options) => {
1532
3115
  if (amount <= 0) {
1533
3116
  throw new Error("Debit amount must be positive");
@@ -1546,129 +3129,1142 @@ function createAccountsNamespace(rb) {
1546
3129
  };
1547
3130
  }
1548
3131
 
1549
- // src/namespaces/apiKeys.ts
1550
- function createApiKeysNamespace(rb) {
3132
+ // src/namespaces/capabilities.ts
3133
+ function createCapabilitiesNamespace(rb) {
3134
+ return {
3135
+ /**
3136
+ * List the full capability catalog (platform admin view — no app annotations).
3137
+ *
3138
+ * Returns all capabilities with their tier, dependency, and metadata
3139
+ * information. No per-application annotations (`enabled`, `can_enable`,
3140
+ * etc.) — this view shows the raw platform catalog.
3141
+ *
3142
+ * Requires a platform admin key (`sk_sys_`).
3143
+ *
3144
+ * @param options - Optional request options (signal for cancellation, etc.).
3145
+ * @returns Array of `AdminCapabilityEntry` objects.
3146
+ *
3147
+ * @example
3148
+ * ```typescript
3149
+ * const admin = new GptAdmin({ apiKey: 'sk_sys_...' });
3150
+ * const catalog = await admin.capabilities.list();
3151
+ * const premium = catalog.filter(c => c.tier === "premium");
3152
+ * ```
3153
+ */
3154
+ list: async (options) => {
3155
+ return rb.rawGet("/sys/capabilities", options);
3156
+ },
3157
+ /**
3158
+ * List the capability catalog annotated for the authenticated application
3159
+ * (ISV view).
3160
+ *
3161
+ * Returns the full catalog with per-application state:
3162
+ * - `enabled` — whether the app currently has this capability active
3163
+ * - `can_enable` — whether the plan tier allows enabling it
3164
+ * - `missing_requires` — required capabilities not yet enabled
3165
+ * - `missing_requires_any` — `requires_any` alternatives not yet enabled
3166
+ *
3167
+ * Requires an ISV application key (`sk_app_`, `sk_srv_`). Use this method
3168
+ * to build plan upgrade flows and capability management UIs.
3169
+ *
3170
+ * @param options - Optional request options (signal for cancellation, etc.).
3171
+ * @returns Array of `AnnotatedCapabilityEntry` objects.
3172
+ *
3173
+ * @example
3174
+ * ```typescript
3175
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
3176
+ * const catalog = await admin.capabilities.listForApplication();
3177
+ * const upgradeable = catalog.filter(c => !c.enabled && c.can_enable);
3178
+ * ```
3179
+ */
3180
+ listForApplication: async (options) => {
3181
+ return rb.rawGet(
3182
+ "/isv/capabilities",
3183
+ options
3184
+ );
3185
+ },
3186
+ /**
3187
+ * Get a single capability by key from the platform admin catalog.
3188
+ *
3189
+ * Convenience method that fetches the full catalog and returns the entry
3190
+ * matching `key`, or `null` if not found.
3191
+ *
3192
+ * Requires a platform admin key (`sk_sys_`).
3193
+ *
3194
+ * @param key - The capability atom key as a string (e.g., `"salesforce_bulk"`).
3195
+ * @param options - Optional request options.
3196
+ * @returns The matching `AdminCapabilityEntry`, or `null`.
3197
+ *
3198
+ * @example
3199
+ * ```typescript
3200
+ * const entry = await admin.capabilities.get("salesforce_bulk");
3201
+ * if (entry) console.log(entry.tier); // "premium"
3202
+ * ```
3203
+ */
3204
+ get: async (key, options) => {
3205
+ const all = await rb.rawGet(
3206
+ "/sys/capabilities",
3207
+ options
3208
+ );
3209
+ return all.find((c) => c.key === key) ?? null;
3210
+ }
3211
+ };
3212
+ }
3213
+
3214
+ // src/namespaces/apiKeys.ts
3215
+ function createApiKeysNamespace(rb) {
3216
+ return {
3217
+ /**
3218
+ * Lists API keys. Supports keyset and offset pagination.
3219
+ *
3220
+ * Returns keys scoped to the actor — users see only their own keys,
3221
+ * ISV owners see keys for their application.
3222
+ *
3223
+ * @param options - Optional request options.
3224
+ * @returns Array of ApiKey objects.
3225
+ */
3226
+ list: async (options) => {
3227
+ return rb.execute(getAdminApiKeys, {}, options);
3228
+ },
3229
+ /**
3230
+ * Fetches a single API key by ID.
3231
+ *
3232
+ * @param id - API key ID.
3233
+ * @param options - Optional request options.
3234
+ * @returns The ApiKey record.
3235
+ */
3236
+ get: async (id, options) => {
3237
+ return rb.execute(getAdminApiKeysById, { path: { id } }, options);
3238
+ },
3239
+ /**
3240
+ * Revokes an API key, setting its status to `revoked` and recording the
3241
+ * revocation timestamp.
3242
+ *
3243
+ * Triggers smart credit reclaim: any unspent credits allocated to this key
3244
+ * are returned to the App Treasury or Tenant Wallet. Prefer this over
3245
+ * hard deletion to preserve the audit trail.
3246
+ *
3247
+ * @param id - API key ID.
3248
+ * @param options - Optional request options.
3249
+ * @returns Updated ApiKey with status `revoked`.
3250
+ */
3251
+ revoke: async (id, options) => {
3252
+ return rb.execute(
3253
+ patchAdminApiKeysByIdRevoke,
3254
+ { path: { id }, body: {} },
3255
+ options
3256
+ );
3257
+ },
3258
+ /**
3259
+ * Rotates an API key by generating a new token while preserving the key's
3260
+ * ID, metadata, and configuration.
3261
+ *
3262
+ * The new raw token is returned once in the `generated_api_key` field and
3263
+ * cannot be retrieved again. All active sessions using the old token are
3264
+ * immediately invalidated.
3265
+ *
3266
+ * @param id - API key ID.
3267
+ * @param options - Optional request options.
3268
+ * @returns Updated ApiKey with the new token in `generated_api_key`.
3269
+ */
3270
+ rotate: async (id, options) => {
3271
+ return rb.execute(
3272
+ patchAdminApiKeysByIdRotate,
3273
+ { path: { id }, body: {} },
3274
+ options
3275
+ );
3276
+ },
3277
+ /**
3278
+ * Create a new API key.
3279
+ * @param attributes - Key attributes (name, key_type, scopes, etc.)
3280
+ * @returns Created API key with generated token
3281
+ */
3282
+ create: async (attributes, options) => {
3283
+ return rb.execute(
3284
+ postAdminApiKeys,
3285
+ { body: { data: { type: "api_key", attributes } } },
3286
+ options
3287
+ );
3288
+ },
3289
+ /**
3290
+ * Update an API key's configuration.
3291
+ * @param id - API key ID
3292
+ * @param attributes - Attributes to update (name, scopes, rate limits)
3293
+ * @returns Updated API key
3294
+ */
3295
+ update: async (id, attributes, options) => {
3296
+ return rb.execute(
3297
+ patchAdminApiKeysById,
3298
+ { path: { id }, body: { data: { id, type: "api_key", attributes } } },
3299
+ options
3300
+ );
3301
+ },
3302
+ /**
3303
+ * Delete an API key permanently.
3304
+ * @param id - API key ID
3305
+ */
3306
+ delete: async (id, options) => {
3307
+ return rb.executeDelete(
3308
+ deleteAdminApiKeysById,
3309
+ { path: { id } },
3310
+ options
3311
+ );
3312
+ },
3313
+ /**
3314
+ * Set or remove a credit budget for an API key.
3315
+ * @param id - API key ID
3316
+ * @param creditLimit - Max credits per period (null to remove)
3317
+ * @param creditLimitPeriod - Budget period (null to remove)
3318
+ * @returns Updated API key
3319
+ */
3320
+ setBudget: async (id, creditLimit, creditLimitPeriod, options) => {
3321
+ return rb.execute(
3322
+ patchAdminApiKeysByIdSetBudget,
3323
+ {
3324
+ path: { id },
3325
+ body: {
3326
+ data: {
3327
+ id,
3328
+ type: "api_key",
3329
+ attributes: {
3330
+ credit_limit: creditLimit,
3331
+ credit_limit_period: creditLimitPeriod
3332
+ }
3333
+ }
3334
+ }
3335
+ },
3336
+ options
3337
+ );
3338
+ },
3339
+ /**
3340
+ * Get API key usage statistics grouped by key type.
3341
+ * @returns Array of usage stat records
3342
+ */
3343
+ usageStats: async (options) => {
3344
+ return rb.execute(
3345
+ getAdminApiKeysStats,
3346
+ {},
3347
+ options
3348
+ );
3349
+ },
3350
+ /**
3351
+ * List only active (non-revoked) API keys.
3352
+ * @returns Array of active API keys
3353
+ */
3354
+ active: async (options) => {
3355
+ return rb.execute(getAdminApiKeysActive, {}, options);
3356
+ },
3357
+ /**
3358
+ * Reset the budget period for an API key (resets period_credits_used to 0).
3359
+ * @param id - API key ID
3360
+ * @returns Updated API key
3361
+ */
3362
+ resetBudgetPeriod: async (id, options) => {
3363
+ return rb.execute(
3364
+ patchAdminApiKeysByIdResetPeriod,
3365
+ {
3366
+ path: { id },
3367
+ body: { data: { id, type: "api_key", attributes: {} } }
3368
+ },
3369
+ options
3370
+ );
3371
+ }
3372
+ };
3373
+ }
3374
+
3375
+ // src/namespaces/documents.ts
3376
+ function createDocumentsNamespace(rb) {
3377
+ return {
3378
+ /**
3379
+ * Lists active (non-deleted) documents across the platform.
3380
+ *
3381
+ * Excludes soft-deleted documents. To list deleted documents, call the
3382
+ * API directly with the `read_trashed` action.
3383
+ *
3384
+ * @param options - Optional request options.
3385
+ * @returns Array of ExtractionDocument objects.
3386
+ */
3387
+ list: async (options) => {
3388
+ return rb.execute(
3389
+ getAdminExtractionDocuments,
3390
+ {},
3391
+ options
3392
+ );
3393
+ },
3394
+ /**
3395
+ * Fetches a single active document by ID.
3396
+ *
3397
+ * Returns a 404 error for soft-deleted documents.
3398
+ *
3399
+ * @param id - Document ID.
3400
+ * @param options - Optional request options.
3401
+ * @returns The ExtractionDocument.
3402
+ */
3403
+ get: async (id, options) => {
3404
+ return rb.execute(
3405
+ getAdminExtractionDocumentsById,
3406
+ { path: { id } },
3407
+ options
3408
+ );
3409
+ },
3410
+ /**
3411
+ * Soft-deletes up to 100 documents in a single operation.
3412
+ *
3413
+ * Sets `deleted_at` on each document without removing the database rows,
3414
+ * preserving the audit trail. Throws synchronously if the array is empty
3415
+ * or exceeds 100 items.
3416
+ *
3417
+ * @param ids - Array of document IDs to delete (1–100 items).
3418
+ * @param options - Optional request options.
3419
+ * @returns Result metadata for the bulk operation.
3420
+ */
3421
+ bulkDelete: async (ids, options) => {
3422
+ if (ids.length === 0) {
3423
+ throw new Error("At least one document ID is required");
3424
+ }
3425
+ if (ids.length > 100) {
3426
+ throw new Error("Maximum 100 documents per bulk operation");
3427
+ }
3428
+ return rb.execute(
3429
+ postAdminDocumentsBulkDelete,
3430
+ { body: { data: { type: "bulk_delete", attributes: { ids } } } },
3431
+ options
3432
+ );
3433
+ },
3434
+ /**
3435
+ * Returns platform-wide document statistics.
3436
+ *
3437
+ * Includes total counts by status (uploaded, processing, complete, failed)
3438
+ * and aggregate storage usage.
3439
+ *
3440
+ * @param options - Optional request options.
3441
+ * @returns Statistics record.
3442
+ */
3443
+ stats: async (options) => {
3444
+ return rb.execute(
3445
+ getAdminDocumentsStats,
3446
+ {},
3447
+ options
3448
+ );
3449
+ }
3450
+ };
3451
+ }
3452
+
3453
+ // src/namespaces/executions.ts
3454
+ function createExecutionsNamespace(rb) {
3455
+ return {
3456
+ /**
3457
+ * Start a new agent execution.
3458
+ *
3459
+ * @param agentId - The UUID of the agent to execute.
3460
+ * @param input - Input data for the agent (task description, documents, etc.).
3461
+ * @param options - Optional request options. Use `idempotencyKey` to prevent duplicate executions.
3462
+ * @returns The created execution record with status `pending`.
3463
+ *
3464
+ * @example
3465
+ * const exec = await admin.executions.start('agt_01...', {
3466
+ * task: 'Process invoice batch',
3467
+ * });
3468
+ * console.log(`Execution ${exec.id} started, status: ${exec.status}`);
3469
+ */
3470
+ async start(agentId, input, options) {
3471
+ return rb.rawPost(
3472
+ `/isv/agents/${agentId}/execute`,
3473
+ { input },
3474
+ options
3475
+ );
3476
+ },
3477
+ /**
3478
+ * Estimate credits required for an execution without running it.
3479
+ *
3480
+ * @param agentId - The UUID of the agent.
3481
+ * @param input - The input the agent would process.
3482
+ * @param options - Optional request options.
3483
+ * @returns Cost estimate with min/max credit ranges.
3484
+ *
3485
+ * @example
3486
+ * const estimate = await admin.executions.estimate('agt_01...', {
3487
+ * task: 'Process batch',
3488
+ * });
3489
+ * console.log(`Estimated: ${estimate.min_credits} - ${estimate.max_credits}`);
3490
+ */
3491
+ async estimate(agentId, input, options) {
3492
+ return rb.rawPost(
3493
+ `/isv/agents/${agentId}/estimate`,
3494
+ { input },
3495
+ options
3496
+ );
3497
+ },
3498
+ /**
3499
+ * List agent executions.
3500
+ *
3501
+ * @param options - Optional request options.
3502
+ * @returns Array of execution records.
3503
+ *
3504
+ * @example
3505
+ * const executions = await admin.executions.list();
3506
+ */
3507
+ async list(options) {
3508
+ return rb.rawGet("/isv/agent-executions", options);
3509
+ },
3510
+ /**
3511
+ * Get a single execution by ID.
3512
+ *
3513
+ * @param id - Execution UUID.
3514
+ * @param options - Optional request options.
3515
+ * @returns The execution record.
3516
+ *
3517
+ * @example
3518
+ * const exec = await admin.executions.get('exec_01...');
3519
+ * console.log(exec.status, exec.total_tokens);
3520
+ */
3521
+ async get(id, options) {
3522
+ return rb.rawGet(`/isv/agent-executions/${id}`, options);
3523
+ },
3524
+ /**
3525
+ * Stream execution events via Server-Sent Events.
3526
+ * Returns an async iterator of typed execution events.
3527
+ *
3528
+ * @param id - Execution UUID to stream.
3529
+ * @param options - Optional request and stream options.
3530
+ * @returns Async iterator of ExecutionEvent objects.
3531
+ *
3532
+ * @example
3533
+ * const stream = await admin.executions.stream(exec.id);
3534
+ * for await (const event of stream) {
3535
+ * if (event.type === 'token_delta') process.stdout.write(event.data.content);
3536
+ * if (event.type === 'done') console.log('Complete');
3537
+ * }
3538
+ */
3539
+ async stream(id, options) {
3540
+ return rb.streamGetRequest(
3541
+ `/isv/agent-executions/${id}/stream`,
3542
+ options
3543
+ );
3544
+ },
3545
+ /**
3546
+ * Approve a pending human-in-the-loop tool call.
3547
+ *
3548
+ * @param id - Execution UUID awaiting approval.
3549
+ * @param options - Optional request options.
3550
+ * @returns The updated execution record.
3551
+ *
3552
+ * @example
3553
+ * await admin.executions.approve('exec_01...');
3554
+ */
3555
+ async approve(id, options) {
3556
+ return rb.rawPost(
3557
+ `/isv/agent-executions/${id}/approve`,
3558
+ void 0,
3559
+ options
3560
+ );
3561
+ },
3562
+ /**
3563
+ * Deny a pending human-in-the-loop tool call.
3564
+ *
3565
+ * @param id - Execution UUID awaiting approval.
3566
+ * @param reason - Human-readable reason for rejection.
3567
+ * @param options - Optional request options.
3568
+ * @returns The updated execution record.
3569
+ *
3570
+ * @example
3571
+ * await admin.executions.deny('exec_01...', 'Not authorized to send emails');
3572
+ */
3573
+ async deny(id, reason, options) {
3574
+ return rb.rawPost(
3575
+ `/isv/agent-executions/${id}/deny`,
3576
+ { reason },
3577
+ options
3578
+ );
3579
+ },
3580
+ /**
3581
+ * Cancel an in-progress execution.
3582
+ *
3583
+ * @param id - Execution UUID to cancel.
3584
+ * @param options - Optional request options.
3585
+ * @returns The updated execution record with `cancelled` status.
3586
+ *
3587
+ * @example
3588
+ * await admin.executions.cancel('exec_01...');
3589
+ */
3590
+ async cancel(id, options) {
3591
+ return rb.rawPost(
3592
+ `/isv/agent-executions/${id}/cancel`,
3593
+ void 0,
3594
+ options
3595
+ );
3596
+ },
3597
+ /**
3598
+ * List child executions spawned by a parent execution (multi-agent delegation).
3599
+ *
3600
+ * @param id - Parent execution UUID.
3601
+ * @param options - Optional request options.
3602
+ * @returns Array of child execution records.
3603
+ *
3604
+ * @example
3605
+ * const children = await admin.executions.children('exec_01...');
3606
+ */
3607
+ async children(id, options) {
3608
+ return rb.rawGet(
3609
+ `/isv/agent-executions/${id}/children`,
3610
+ options
3611
+ );
3612
+ },
3613
+ /**
3614
+ * Get the full execution tree for a root execution.
3615
+ * Includes all nested child executions and their statuses.
3616
+ *
3617
+ * @param id - Root execution UUID.
3618
+ * @param options - Optional request options.
3619
+ * @returns Hierarchical execution tree structure.
3620
+ *
3621
+ * @example
3622
+ * const tree = await admin.executions.tree('exec_01...');
3623
+ */
3624
+ async tree(id, options) {
3625
+ return rb.rawGet(
3626
+ `/isv/agent-executions/${id}/tree`,
3627
+ options
3628
+ );
3629
+ }
3630
+ };
3631
+ }
3632
+
3633
+ // src/namespaces/storage.ts
3634
+ function createStorageNamespace(rb) {
3635
+ return {
3636
+ /**
3637
+ * Retrieves platform-wide storage statistics.
3638
+ *
3639
+ * Pass a `workspaceId` to scope results to a single workspace.
3640
+ *
3641
+ * @param workspaceId - Optional workspace ID to filter statistics.
3642
+ * @param options - Optional request options.
3643
+ * @returns Storage statistics record with byte counts and file totals.
3644
+ */
3645
+ stats: async (workspaceId, options) => {
3646
+ const params = workspaceId ? { query: { "filter[workspace_id]": workspaceId } } : {};
3647
+ return rb.execute(
3648
+ getAdminStorageStats,
3649
+ params,
3650
+ options
3651
+ );
3652
+ },
3653
+ buckets: {
3654
+ /**
3655
+ * Lists all storage buckets, excluding processing-type buckets by default.
3656
+ *
3657
+ * @param options - Optional request options.
3658
+ * @returns Array of Bucket objects.
3659
+ */
3660
+ list: async (options) => {
3661
+ return rb.execute(getAdminBuckets, {}, options);
3662
+ },
3663
+ /**
3664
+ * Fetches a single bucket by ID.
3665
+ *
3666
+ * @param id - Bucket ID.
3667
+ * @param options - Optional request options.
3668
+ * @returns The Bucket record.
3669
+ */
3670
+ get: async (id, options) => {
3671
+ return rb.execute(
3672
+ getAdminBucketsById,
3673
+ { path: { id } },
3674
+ options
3675
+ );
3676
+ },
3677
+ /**
3678
+ * Fetches a bucket with the `storage_used` calculation.
3679
+ *
3680
+ * Returns total bytes across all workspace files stored in this bucket.
3681
+ *
3682
+ * @param id - Bucket ID.
3683
+ * @param options - Optional request options.
3684
+ * @returns Bucket record including computed `storage_used` field.
3685
+ */
3686
+ stats: async (id, options) => {
3687
+ return rb.execute(
3688
+ getAdminBucketsByIdStats,
3689
+ { path: { id } },
3690
+ options
3691
+ );
3692
+ }
3693
+ }
3694
+ };
3695
+ }
3696
+
3697
+ // src/pagination.ts
3698
+ var DEFAULT_MAX_PAGES = 500;
3699
+ async function* paginateAll(fetcher, options = {}) {
3700
+ const pageSize = options.pageSize || 20;
3701
+ const limit = options.limit;
3702
+ const maxPages = options.maxPages ?? DEFAULT_MAX_PAGES;
3703
+ const logger = options.logger ?? (typeof console !== "undefined" ? console : void 0);
3704
+ let page = 1;
3705
+ let totalYielded = 0;
3706
+ while (true) {
3707
+ if (page > maxPages) {
3708
+ logger?.warn(
3709
+ `[GPT Core SDK] Pagination stopped: reached maximum page limit (${maxPages}). Use options.maxPages to increase or options.limit to cap total items.`
3710
+ );
3711
+ return;
3712
+ }
3713
+ const response = await fetcher(page, pageSize);
3714
+ for (const item of response.data) {
3715
+ yield item;
3716
+ totalYielded++;
3717
+ if (limit && totalYielded >= limit) {
3718
+ return;
3719
+ }
3720
+ }
3721
+ if (!response.links?.next || response.data.length === 0) {
3722
+ break;
3723
+ }
3724
+ page++;
3725
+ }
3726
+ }
3727
+ var DEFAULT_LIMIT = 1e4;
3728
+ async function paginateToArray(fetcher, options = {}) {
3729
+ const safeOptions = {
3730
+ pageSize: options.pageSize || 20,
3731
+ // Security: Apply default limit to prevent unbounded memory usage
3732
+ limit: options.limit ?? DEFAULT_LIMIT,
3733
+ logger: options.logger
3734
+ };
3735
+ const results = [];
3736
+ for await (const item of paginateAll(fetcher, safeOptions)) {
3737
+ results.push(item);
3738
+ }
3739
+ return results;
3740
+ }
3741
+
3742
+ // src/namespace-types.ts
3743
+ function buildPageQuery(page, pageSize) {
3744
+ return {
3745
+ query: {
3746
+ page: {
3747
+ ...page && { number: page },
3748
+ ...pageSize && { size: pageSize }
3749
+ }
3750
+ }
3751
+ };
3752
+ }
3753
+
3754
+ // src/namespaces/users.ts
3755
+ function createUsersNamespace(rb) {
1551
3756
  return {
3757
+ /**
3758
+ * List all users (paginated).
3759
+ * @param options - Optional page and pageSize along with request options
3760
+ * @returns Array of users
3761
+ */
1552
3762
  list: async (options) => {
1553
- return rb.execute(getAdminApiKeys, {}, options);
1554
- },
1555
- get: async (id, options) => {
1556
- return rb.execute(getAdminApiKeysById, { path: { id } }, options);
1557
- },
1558
- allocate: async (id, amount, description, options) => {
1559
3763
  return rb.execute(
1560
- patchAdminApiKeysByIdAllocate,
1561
- {
1562
- path: { id },
1563
- body: {
1564
- data: { type: "api_key", attributes: { amount, description } }
1565
- }
1566
- },
3764
+ getAdminUsers,
3765
+ buildPageQuery(options?.page, options?.pageSize),
1567
3766
  options
1568
3767
  );
1569
3768
  },
1570
- revoke: async (id, options) => {
1571
- return rb.execute(
1572
- patchAdminApiKeysByIdRevoke,
1573
- { path: { id }, body: {} },
1574
- options
3769
+ /**
3770
+ * List all users (fetches all pages automatically).
3771
+ * @returns Complete array of all users
3772
+ */
3773
+ listAll: async (options) => {
3774
+ return paginateToArray(
3775
+ rb.createPaginatedFetcher(
3776
+ getAdminUsers,
3777
+ (page, pageSize) => ({
3778
+ query: { page: { number: page, size: pageSize } }
3779
+ }),
3780
+ options
3781
+ )
1575
3782
  );
1576
3783
  },
1577
- rotate: async (id, options) => {
3784
+ /**
3785
+ * Get a user by ID.
3786
+ * @param id - User ID
3787
+ * @returns User object
3788
+ */
3789
+ get: async (id, options) => {
3790
+ return rb.execute(getAdminUsersById, { path: { id } }, options);
3791
+ },
3792
+ /**
3793
+ * Look up a user by email address.
3794
+ * @param email - Email address to search
3795
+ * @returns User object
3796
+ */
3797
+ getByEmail: async (email, options) => {
1578
3798
  return rb.execute(
1579
- patchAdminApiKeysByIdRotate,
1580
- { path: { id }, body: {} },
3799
+ getAdminUsersByEmail,
3800
+ { query: { email } },
1581
3801
  options
1582
3802
  );
1583
- }
1584
- };
1585
- }
1586
-
1587
- // src/namespaces/documents.ts
1588
- function createDocumentsNamespace(rb) {
1589
- return {
1590
- list: async (options) => {
3803
+ },
3804
+ /**
3805
+ * Update a user's admin-level attributes (is_platform_admin, is_app_admin).
3806
+ * @param id - User ID
3807
+ * @param attributes - Admin attributes to update
3808
+ * @returns Updated user
3809
+ */
3810
+ adminUpdate: async (id, attributes, options) => {
1591
3811
  return rb.execute(
1592
- getAdminExtractionDocuments,
1593
- {},
3812
+ patchAdminUsersByIdAdmin,
3813
+ { path: { id }, body: { data: { id, type: "user", attributes } } },
1594
3814
  options
1595
3815
  );
1596
3816
  },
1597
- get: async (id, options) => {
3817
+ /**
3818
+ * Change a user's email address (admin action).
3819
+ * @param id - User ID
3820
+ * @param email - New email address
3821
+ * @returns Updated user
3822
+ */
3823
+ adminUpdateEmail: async (id, email, options) => {
1598
3824
  return rb.execute(
1599
- getAdminExtractionDocumentsById,
1600
- { path: { id } },
3825
+ patchAdminUsersByIdAdminEmail,
3826
+ {
3827
+ path: { id },
3828
+ body: { data: { id, type: "user", attributes: { email } } }
3829
+ },
1601
3830
  options
1602
3831
  );
1603
3832
  },
1604
- bulkDelete: async (ids, options) => {
1605
- if (ids.length === 0) {
1606
- throw new Error("At least one document ID is required");
1607
- }
1608
- if (ids.length > 100) {
1609
- throw new Error("Maximum 100 documents per bulk operation");
1610
- }
3833
+ /**
3834
+ * Confirm a user's email address (admin bypass).
3835
+ * @param id - User ID
3836
+ * @returns Updated user
3837
+ */
3838
+ confirmEmail: async (id, options) => {
1611
3839
  return rb.execute(
1612
- postAdminDocumentsBulkDelete,
1613
- { body: { data: { type: "bulk_delete", attributes: { ids } } } },
3840
+ patchAdminUsersByIdConfirmEmail,
3841
+ { path: { id }, body: { data: { id, type: "user", attributes: {} } } },
1614
3842
  options
1615
3843
  );
1616
3844
  },
1617
- stats: async (options) => {
3845
+ /**
3846
+ * Trigger a password reset email for a user (admin action).
3847
+ * @param id - User ID
3848
+ * @returns Updated user
3849
+ */
3850
+ triggerPasswordReset: async (id, options) => {
1618
3851
  return rb.execute(
1619
- getAdminDocumentsStats,
1620
- {},
3852
+ patchAdminUsersByIdResetPassword,
3853
+ { path: { id }, body: { data: { id, type: "user", attributes: {} } } },
1621
3854
  options
1622
3855
  );
3856
+ },
3857
+ /**
3858
+ * Delete a user and all associated data.
3859
+ * @param id - User ID
3860
+ */
3861
+ delete: async (id, options) => {
3862
+ return rb.executeDelete(deleteAdminUsersById, { path: { id } }, options);
1623
3863
  }
1624
3864
  };
1625
3865
  }
1626
3866
 
1627
- // src/namespaces/executions.ts
1628
- function createExecutionsNamespace(_rb) {
1629
- return {};
1630
- }
1631
-
1632
- // src/namespaces/storage.ts
1633
- function createStorageNamespace(rb) {
3867
+ // src/namespaces/voice.ts
3868
+ function createVoiceNamespace(rb) {
1634
3869
  return {
1635
- stats: async (workspaceId, options) => {
1636
- const params = workspaceId ? { query: { "filter[workspace_id]": workspaceId } } : {};
1637
- return rb.execute(
1638
- getAdminStorageStats,
1639
- params,
1640
- options
1641
- );
3870
+ /**
3871
+ * Voice session management admin view across all workspaces.
3872
+ */
3873
+ sessions: {
3874
+ /**
3875
+ * List voice sessions across all workspaces.
3876
+ *
3877
+ * @param options - Optional pagination, filter, and request options.
3878
+ * @returns Array of VoiceSession objects.
3879
+ *
3880
+ * @example
3881
+ * ```typescript
3882
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
3883
+ * // List all active sessions
3884
+ * const activeSessions = await admin.voice.sessions.list({ status: "active" });
3885
+ * // List sessions from the last 24 hours
3886
+ * const recentSessions = await admin.voice.sessions.list({
3887
+ * insertedAfter: new Date(Date.now() - 86400000).toISOString()
3888
+ * });
3889
+ * ```
3890
+ */
3891
+ list: async (options) => {
3892
+ const filters = {};
3893
+ if (options?.status) filters["filter[status]"] = options.status;
3894
+ if (options?.insertedAfter)
3895
+ filters["filter[inserted_after]"] = options.insertedAfter;
3896
+ if (options?.insertedBefore)
3897
+ filters["filter[inserted_before]"] = options.insertedBefore;
3898
+ return rb.execute(
3899
+ getAdminVoiceSessions,
3900
+ {
3901
+ ...buildPageQuery(options?.page, options?.pageSize),
3902
+ query: filters
3903
+ },
3904
+ options
3905
+ );
3906
+ },
3907
+ /**
3908
+ * Retrieve a single voice session by ID.
3909
+ *
3910
+ * @param id - The UUID of the voice session.
3911
+ * @param options - Optional request options.
3912
+ * @returns The VoiceSession.
3913
+ *
3914
+ * @example
3915
+ * ```typescript
3916
+ * const session = await admin.voice.sessions.get('session-uuid');
3917
+ * ```
3918
+ */
3919
+ get: async (id, options) => {
3920
+ return rb.execute(
3921
+ getAdminVoiceSessionsById,
3922
+ { path: { id } },
3923
+ options
3924
+ );
3925
+ },
3926
+ /**
3927
+ * List voice sessions in a specific workspace.
3928
+ *
3929
+ * @param workspaceId - The UUID of the workspace.
3930
+ * @param options - Optional pagination and request options.
3931
+ * @returns Array of VoiceSession objects in the workspace.
3932
+ *
3933
+ * @example
3934
+ * ```typescript
3935
+ * const sessions = await admin.voice.sessions.listByWorkspace('ws-uuid');
3936
+ * ```
3937
+ */
3938
+ listByWorkspace: async (workspaceId, options) => {
3939
+ return rb.execute(
3940
+ getAdminVoiceSessionsWorkspaceByWorkspaceId,
3941
+ {
3942
+ path: { workspace_id: workspaceId },
3943
+ ...buildPageQuery(options?.page, options?.pageSize)
3944
+ },
3945
+ options
3946
+ );
3947
+ }
1642
3948
  },
1643
- buckets: {
3949
+ /**
3950
+ * Voice recording management — admin view.
3951
+ */
3952
+ recordings: {
3953
+ /**
3954
+ * List voice recordings.
3955
+ *
3956
+ * @param options - Optional pagination and request options.
3957
+ * @returns Array of VoiceRecording objects.
3958
+ *
3959
+ * @example
3960
+ * ```typescript
3961
+ * const recordings = await admin.voice.recordings.list();
3962
+ * ```
3963
+ */
1644
3964
  list: async (options) => {
1645
- return rb.execute(getAdminBuckets, {}, options);
3965
+ return rb.execute(
3966
+ getAdminVoiceRecordings,
3967
+ buildPageQuery(options?.page, options?.pageSize),
3968
+ options
3969
+ );
1646
3970
  },
3971
+ /**
3972
+ * Retrieve a single recording by ID.
3973
+ *
3974
+ * @param id - The UUID of the recording.
3975
+ * @param options - Optional request options.
3976
+ * @returns The VoiceRecording.
3977
+ *
3978
+ * @example
3979
+ * ```typescript
3980
+ * const recording = await admin.voice.recordings.get('recording-uuid');
3981
+ * ```
3982
+ */
1647
3983
  get: async (id, options) => {
1648
3984
  return rb.execute(
1649
- getAdminBucketsById,
3985
+ getAdminVoiceRecordingsById,
1650
3986
  { path: { id } },
1651
3987
  options
1652
3988
  );
1653
3989
  },
1654
- stats: async (id, options) => {
3990
+ /**
3991
+ * List all recordings for a specific voice session.
3992
+ *
3993
+ * @param sessionId - The UUID of the voice session.
3994
+ * @param options - Optional request options.
3995
+ * @returns Array of VoiceRecording objects for the session.
3996
+ *
3997
+ * @example
3998
+ * ```typescript
3999
+ * const recordings = await admin.voice.recordings.bySession('session-uuid');
4000
+ * ```
4001
+ */
4002
+ bySession: async (sessionId, options) => {
1655
4003
  return rb.execute(
1656
- getAdminBucketsByIdStats,
4004
+ getAdminVoiceRecordingsSessionBySessionId,
4005
+ { path: { session_id: sessionId } },
4006
+ options
4007
+ );
4008
+ }
4009
+ },
4010
+ /**
4011
+ * Transcription result management — admin view.
4012
+ */
4013
+ transcriptionResults: {
4014
+ /**
4015
+ * List transcription results.
4016
+ *
4017
+ * @param options - Optional pagination and request options.
4018
+ * @returns Array of VoiceTranscriptionResult objects.
4019
+ *
4020
+ * @example
4021
+ * ```typescript
4022
+ * const results = await admin.voice.transcriptionResults.list();
4023
+ * ```
4024
+ */
4025
+ list: async (options) => {
4026
+ return rb.execute(
4027
+ getAdminVoiceTranscriptionResults,
4028
+ buildPageQuery(options?.page, options?.pageSize),
4029
+ options
4030
+ );
4031
+ },
4032
+ /**
4033
+ * Retrieve a single transcription result by ID.
4034
+ *
4035
+ * @param id - The UUID of the transcription result.
4036
+ * @param options - Optional request options.
4037
+ * @returns The VoiceTranscriptionResult.
4038
+ *
4039
+ * @example
4040
+ * ```typescript
4041
+ * const result = await admin.voice.transcriptionResults.get('result-uuid');
4042
+ * ```
4043
+ */
4044
+ get: async (id, options) => {
4045
+ return rb.execute(
4046
+ getAdminVoiceTranscriptionResultsById,
1657
4047
  { path: { id } },
1658
4048
  options
1659
4049
  );
4050
+ },
4051
+ /**
4052
+ * List transcription results for a specific voice session.
4053
+ *
4054
+ * @param sessionId - The UUID of the voice session.
4055
+ * @param options - Optional pagination and request options.
4056
+ * @returns Array of VoiceTranscriptionResult objects for the session.
4057
+ *
4058
+ * @example
4059
+ * ```typescript
4060
+ * const results = await admin.voice.transcriptionResults.bySession('session-uuid');
4061
+ * ```
4062
+ */
4063
+ bySession: async (sessionId, options) => {
4064
+ return rb.execute(
4065
+ getAdminVoiceTranscriptionResultsSessionBySessionId,
4066
+ {
4067
+ path: { session_id: sessionId },
4068
+ ...buildPageQuery(options?.page, options?.pageSize)
4069
+ },
4070
+ options
4071
+ );
1660
4072
  }
1661
4073
  }
1662
4074
  };
1663
4075
  }
1664
4076
 
4077
+ // src/namespaces/audit.ts
4078
+ function createAuditNamespace(rb) {
4079
+ return {
4080
+ /**
4081
+ * List audit log entries with keyset or offset pagination.
4082
+ *
4083
+ * Returns up to `limit` (default 50) entries sorted by `inserted_at` descending.
4084
+ * The `actor_display_name` calculation is included automatically.
4085
+ *
4086
+ * @param params - Optional pagination and sort parameters.
4087
+ * @param options - Optional request options.
4088
+ * @returns Array of AuditLog entries.
4089
+ *
4090
+ * @example
4091
+ * ```typescript
4092
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4093
+ *
4094
+ * // First page (default limit 50)
4095
+ * const page1 = await admin.audit.list();
4096
+ *
4097
+ * // Next page using keyset cursor
4098
+ * const page2 = await admin.audit.list({ after: page1.at(-1)?.id, limit: 25 });
4099
+ * ```
4100
+ */
4101
+ async list(params = {}, options) {
4102
+ const parts = [];
4103
+ if (params.limit !== void 0) parts.push(`page[limit]=${params.limit}`);
4104
+ if (params.offset !== void 0)
4105
+ parts.push(`page[offset]=${params.offset}`);
4106
+ if (params.after)
4107
+ parts.push(`page[after]=${encodeURIComponent(params.after)}`);
4108
+ if (params.before)
4109
+ parts.push(`page[before]=${encodeURIComponent(params.before)}`);
4110
+ if (params.sort) parts.push(`sort=${encodeURIComponent(params.sort)}`);
4111
+ const qs = parts.length ? `?${parts.join("&")}` : "";
4112
+ return rb.rawGet(`/admin/audit-logs${qs}`, options);
4113
+ },
4114
+ /**
4115
+ * Fetch a paginated, time-sorted activity feed scoped to a tenant.
4116
+ *
4117
+ * Optionally filter by workspace, action type, actor, or date range.
4118
+ * Results are sorted by `inserted_at` descending (most recent first).
4119
+ *
4120
+ * @param params - Feed parameters. `tenantId` is required.
4121
+ * @param options - Optional request options.
4122
+ * @returns Array of AuditLog entries matching the filters.
4123
+ *
4124
+ * @example
4125
+ * ```typescript
4126
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4127
+ *
4128
+ * // All activity for a tenant in the last 24h
4129
+ * const feed = await admin.audit.activityFeed({
4130
+ * tenantId: 'tenant-uuid',
4131
+ * fromDate: new Date(Date.now() - 86400000).toISOString(),
4132
+ * });
4133
+ *
4134
+ * // Narrow to a specific workspace and actor
4135
+ * const focused = await admin.audit.activityFeed({
4136
+ * tenantId: 'tenant-uuid',
4137
+ * workspaceId: 'ws-uuid',
4138
+ * actorId: 'user-uuid',
4139
+ * limit: 20,
4140
+ * });
4141
+ * ```
4142
+ */
4143
+ async activityFeed(params, options) {
4144
+ if (!params.tenantId) throw new Error("tenantId is required");
4145
+ const parts = [
4146
+ `tenant_id=${encodeURIComponent(params.tenantId)}`
4147
+ ];
4148
+ if (params.workspaceId)
4149
+ parts.push(`workspace_id=${encodeURIComponent(params.workspaceId)}`);
4150
+ if (params.activityType)
4151
+ parts.push(`activity_type=${encodeURIComponent(params.activityType)}`);
4152
+ if (params.actorId)
4153
+ parts.push(`actor_id=${encodeURIComponent(params.actorId)}`);
4154
+ if (params.fromDate)
4155
+ parts.push(`from_date=${encodeURIComponent(params.fromDate)}`);
4156
+ if (params.toDate)
4157
+ parts.push(`to_date=${encodeURIComponent(params.toDate)}`);
4158
+ if (params.limit !== void 0) parts.push(`limit=${params.limit}`);
4159
+ if (params.offset !== void 0) parts.push(`offset=${params.offset}`);
4160
+ return rb.rawGet(
4161
+ `/admin/audit-logs/activity?${parts.join("&")}`,
4162
+ options
4163
+ );
4164
+ },
4165
+ /**
4166
+ * Return per-action counts for a tenant, sorted by frequency descending.
4167
+ *
4168
+ * Useful for anomaly dashboards and compliance reporting.
4169
+ *
4170
+ * @param params - `tenantId` is required. `workspaceId` narrows to one workspace.
4171
+ * @param options - Optional request options.
4172
+ * @returns Array of `{ action, count }` objects sorted by count descending.
4173
+ *
4174
+ * @example
4175
+ * ```typescript
4176
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4177
+ *
4178
+ * const counts = await admin.audit.countByAction({ tenantId: 'tenant-uuid' });
4179
+ * // [{ action: "document.analyzed", count: 1240 }, { action: "user.login", count: 98 }, ...]
4180
+ * ```
4181
+ */
4182
+ async countByAction(params, options) {
4183
+ if (!params.tenantId) throw new Error("tenantId is required");
4184
+ const parts = [
4185
+ `tenant_id=${encodeURIComponent(params.tenantId)}`
4186
+ ];
4187
+ if (params.workspaceId)
4188
+ parts.push(`workspace_id=${encodeURIComponent(params.workspaceId)}`);
4189
+ return rb.rawGet(
4190
+ `/admin/audit-logs/count-by-action?${parts.join("&")}`,
4191
+ options
4192
+ );
4193
+ },
4194
+ /**
4195
+ * Enqueue a bulk compliance export of audit logs for a tenant.
4196
+ *
4197
+ * The export is processed asynchronously by the `ExportAuditLogsWorker` Oban job.
4198
+ * The caller receives a job ID and status immediately; the file URL is published
4199
+ * to `audit:export:{tenant_id}` via PubSub when ready (see `AuditExportCompleted`).
4200
+ *
4201
+ * @param params - Export parameters. `tenantId` and `format` are required.
4202
+ * @param options - Optional request options.
4203
+ * @returns `{ jobId, status }` — the Oban job ID and initial status (`"enqueued"`).
4204
+ *
4205
+ * @example
4206
+ * ```typescript
4207
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4208
+ *
4209
+ * // Request a CSV export of the last 30 days
4210
+ * const thirty = new Date();
4211
+ * thirty.setDate(thirty.getDate() - 30);
4212
+ * const result = await admin.audit.requestExport({
4213
+ * format: 'csv',
4214
+ * tenantId: 'tenant-uuid',
4215
+ * fromDate: thirty.toISOString(),
4216
+ * });
4217
+ * console.log(`Export job ${result.jobId} enqueued`);
4218
+ * ```
4219
+ */
4220
+ async requestExport(params, options) {
4221
+ if (!params.tenantId) throw new Error("tenantId is required");
4222
+ return rb.rawPost(
4223
+ `/admin/audit-logs/export`,
4224
+ {
4225
+ data: {
4226
+ type: "audit_log",
4227
+ attributes: {
4228
+ format: params.format,
4229
+ tenant_id: params.tenantId,
4230
+ ...params.fromDate && { from_date: params.fromDate },
4231
+ ...params.toDate && { to_date: params.toDate }
4232
+ }
4233
+ }
4234
+ },
4235
+ options
4236
+ );
4237
+ }
4238
+ };
4239
+ }
4240
+
1665
4241
  // src/namespaces/webhooks-ns.ts
1666
4242
  function createWebhooksNamespace(rb) {
1667
4243
  return {
1668
4244
  configs: {
4245
+ /**
4246
+ * Lists all webhook configurations.
4247
+ *
4248
+ * @param options - Optional request options.
4249
+ * @returns Array of WebhookConfig objects.
4250
+ */
1669
4251
  list: async (options) => {
1670
4252
  return rb.execute(getAdminWebhookConfigs, {}, options);
1671
4253
  },
4254
+ /**
4255
+ * Registers a new webhook endpoint to receive platform events.
4256
+ *
4257
+ * The `application_id` is inferred from the API key used to make the
4258
+ * request. Supply it explicitly to scope the webhook to a specific application.
4259
+ *
4260
+ * @param name - Display name for the webhook configuration.
4261
+ * @param url - HTTPS URL that will receive event POST requests.
4262
+ * @param events - Event types to subscribe to (e.g. `"document.analyzed"`).
4263
+ * @param applicationId - Optional application ID to scope this webhook.
4264
+ * @param secret - Optional HMAC signing secret for payload verification.
4265
+ * @param options - Optional request options.
4266
+ * @returns The created WebhookConfig.
4267
+ */
1672
4268
  create: async (name, url, events, applicationId, secret, options) => {
1673
4269
  return rb.execute(
1674
4270
  postAdminWebhookConfigs,
@@ -1689,6 +4285,13 @@ function createWebhooksNamespace(rb) {
1689
4285
  options
1690
4286
  );
1691
4287
  },
4288
+ /**
4289
+ * Fetches a single webhook configuration by ID.
4290
+ *
4291
+ * @param id - WebhookConfig ID.
4292
+ * @param options - Optional request options.
4293
+ * @returns The WebhookConfig.
4294
+ */
1692
4295
  get: async (id, options) => {
1693
4296
  return rb.execute(
1694
4297
  getAdminWebhookConfigsById,
@@ -1696,6 +4299,18 @@ function createWebhooksNamespace(rb) {
1696
4299
  options
1697
4300
  );
1698
4301
  },
4302
+ /**
4303
+ * Updates webhook endpoint settings.
4304
+ *
4305
+ * Updates URL, subscribed event types, enabled state, and other mutable
4306
+ * fields. To change the HMAC signing secret, use the `rotate_secret`
4307
+ * action via the API directly instead.
4308
+ *
4309
+ * @param id - WebhookConfig ID.
4310
+ * @param attributes - Partial attributes to update.
4311
+ * @param options - Optional request options.
4312
+ * @returns Updated WebhookConfig.
4313
+ */
1699
4314
  update: async (id, attributes, options) => {
1700
4315
  return rb.execute(
1701
4316
  patchAdminWebhookConfigsById,
@@ -1706,6 +4321,15 @@ function createWebhooksNamespace(rb) {
1706
4321
  options
1707
4322
  );
1708
4323
  },
4324
+ /**
4325
+ * Permanently deletes a webhook configuration.
4326
+ *
4327
+ * This action cannot be undone. Associated delivery records are preserved.
4328
+ *
4329
+ * @param id - WebhookConfig ID.
4330
+ * @param options - Optional request options.
4331
+ * @returns `true` on success.
4332
+ */
1709
4333
  delete: async (id, options) => {
1710
4334
  return rb.executeDelete(
1711
4335
  deleteAdminWebhookConfigsById,
@@ -1713,6 +4337,18 @@ function createWebhooksNamespace(rb) {
1713
4337
  options
1714
4338
  );
1715
4339
  },
4340
+ /**
4341
+ * Sends a realistic sample payload to the webhook URL.
4342
+ *
4343
+ * Verifies connectivity and signature verification by enqueuing a
4344
+ * WebhookSender Oban job tagged with `test: true`. Use this to confirm
4345
+ * the endpoint is reachable and parsing HMAC signatures correctly before
4346
+ * subscribing to live events.
4347
+ *
4348
+ * @param id - WebhookConfig ID.
4349
+ * @param options - Optional request options.
4350
+ * @returns The WebhookConfig on success.
4351
+ */
1716
4352
  test: async (id, options) => {
1717
4353
  return rb.execute(
1718
4354
  postAdminWebhookConfigsByIdTest,
@@ -1722,6 +4358,15 @@ function createWebhooksNamespace(rb) {
1722
4358
  }
1723
4359
  },
1724
4360
  deliveries: {
4361
+ /**
4362
+ * Lists all webhook delivery records across all configurations.
4363
+ *
4364
+ * Each delivery record tracks the attempt count, status, payload, and
4365
+ * response for a single event dispatch.
4366
+ *
4367
+ * @param options - Optional request options.
4368
+ * @returns Array of WebhookDelivery objects.
4369
+ */
1725
4370
  list: async (options) => {
1726
4371
  return rb.execute(
1727
4372
  getAdminWebhookDeliveries,
@@ -1729,6 +4374,13 @@ function createWebhooksNamespace(rb) {
1729
4374
  options
1730
4375
  );
1731
4376
  },
4377
+ /**
4378
+ * Fetches a single delivery record by ID.
4379
+ *
4380
+ * @param id - WebhookDelivery ID.
4381
+ * @param options - Optional request options.
4382
+ * @returns The WebhookDelivery.
4383
+ */
1732
4384
  get: async (id, options) => {
1733
4385
  return rb.execute(
1734
4386
  getAdminWebhookDeliveriesById,
@@ -1736,6 +4388,17 @@ function createWebhooksNamespace(rb) {
1736
4388
  options
1737
4389
  );
1738
4390
  },
4391
+ /**
4392
+ * Re-enqueues a failed or pending delivery for immediate re-dispatch.
4393
+ *
4394
+ * Sets the delivery status to `retrying` and inserts a new WebhookSender
4395
+ * Oban job. Use this to recover from transient endpoint failures without
4396
+ * waiting for the automatic retry schedule.
4397
+ *
4398
+ * @param id - WebhookDelivery ID.
4399
+ * @param options - Optional request options.
4400
+ * @returns Updated WebhookDelivery with status `retrying`.
4401
+ */
1739
4402
  retry: async (id, options) => {
1740
4403
  return rb.execute(
1741
4404
  postAdminWebhookDeliveriesByIdRetry,
@@ -1747,6 +4410,405 @@ function createWebhooksNamespace(rb) {
1747
4410
  };
1748
4411
  }
1749
4412
 
4413
+ // src/namespaces/campaigns.ts
4414
+ function createCampaignsNamespace(rb) {
4415
+ return {
4416
+ /**
4417
+ * Get a campaign by ID.
4418
+ *
4419
+ * @param id - The unique identifier of the campaign.
4420
+ * @param options - Optional request-level overrides.
4421
+ * @returns A promise resolving to the {@link Campaign}.
4422
+ *
4423
+ * @example
4424
+ * ```typescript
4425
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4426
+ * const campaign = await admin.campaigns.get('camp_abc123');
4427
+ * ```
4428
+ */
4429
+ get: async (id, options) => {
4430
+ return rb.execute(
4431
+ getAdminEmailMarketingCampaignsById,
4432
+ { path: { id } },
4433
+ options
4434
+ );
4435
+ },
4436
+ /**
4437
+ * List all campaigns for a workspace.
4438
+ *
4439
+ * @param workspaceId - The ID of the workspace to query.
4440
+ * @param options - Optional pagination and request options.
4441
+ * @returns A promise resolving to an array of {@link Campaign} records.
4442
+ *
4443
+ * @example
4444
+ * ```typescript
4445
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4446
+ * const campaigns = await admin.campaigns.listByWorkspace('ws_abc123');
4447
+ * ```
4448
+ */
4449
+ listByWorkspace: async (workspaceId, options) => {
4450
+ return rb.execute(
4451
+ getAdminEmailMarketingCampaignsWorkspaceByWorkspaceId,
4452
+ {
4453
+ path: { workspace_id: workspaceId },
4454
+ ...buildPageQuery(options?.page, options?.pageSize)
4455
+ },
4456
+ options
4457
+ );
4458
+ },
4459
+ /**
4460
+ * Create a new campaign.
4461
+ *
4462
+ * @param attributes - Campaign attributes including `workspace_id`, `name`, `template_id`.
4463
+ * @param options - Optional request-level overrides.
4464
+ * @returns A promise resolving to the newly created {@link Campaign}.
4465
+ *
4466
+ * @example
4467
+ * ```typescript
4468
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4469
+ * const campaign = await admin.campaigns.create({
4470
+ * workspace_id: 'ws_abc123',
4471
+ * name: 'Q1 Outreach',
4472
+ * template_id: 'tmpl_xyz',
4473
+ * });
4474
+ * ```
4475
+ */
4476
+ create: async (attributes, options) => {
4477
+ return rb.execute(
4478
+ postAdminEmailMarketingCampaigns,
4479
+ { body: { data: { type: "campaign", attributes } } },
4480
+ options
4481
+ );
4482
+ },
4483
+ /**
4484
+ * Trigger sending for an approved campaign.
4485
+ *
4486
+ * @param id - The ID of the campaign to send.
4487
+ * @param options - Optional request-level overrides.
4488
+ * @returns A promise resolving to the updated {@link Campaign}.
4489
+ *
4490
+ * @example
4491
+ * ```typescript
4492
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4493
+ * await admin.campaigns.send('camp_abc123');
4494
+ * ```
4495
+ */
4496
+ send: async (id, options) => {
4497
+ return rb.execute(
4498
+ postAdminEmailMarketingCampaignsByIdSend,
4499
+ { path: { id }, body: {} },
4500
+ options
4501
+ );
4502
+ },
4503
+ /**
4504
+ * Delete a campaign.
4505
+ *
4506
+ * @param id - The unique identifier of the campaign to delete.
4507
+ * @param options - Optional request-level overrides.
4508
+ * @returns A promise that resolves to `true` on successful deletion.
4509
+ *
4510
+ * @example
4511
+ * ```typescript
4512
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4513
+ * await admin.campaigns.delete('camp_abc123');
4514
+ * ```
4515
+ */
4516
+ delete: async (id, options) => {
4517
+ return rb.executeDelete(
4518
+ deleteAdminEmailMarketingCampaignsById,
4519
+ { path: { id } },
4520
+ options
4521
+ );
4522
+ }
4523
+ };
4524
+ }
4525
+
4526
+ // src/namespaces/email.ts
4527
+ function createEmailNamespace(rb) {
4528
+ return {
4529
+ /**
4530
+ * Outbound email management — admin view across all workspaces.
4531
+ */
4532
+ outboundEmails: {
4533
+ /**
4534
+ * Get an outbound email by ID.
4535
+ *
4536
+ * @param id - The unique identifier of the outbound email.
4537
+ * @param options - Optional request-level overrides.
4538
+ * @returns A promise resolving to the {@link EmailOutboundEmail}.
4539
+ *
4540
+ * @example
4541
+ * ```typescript
4542
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4543
+ * const email = await admin.email.outboundEmails.get('oe_abc123');
4544
+ * ```
4545
+ */
4546
+ get: async (id, options) => {
4547
+ return rb.execute(
4548
+ getAdminEmailOutboundEmailsById,
4549
+ { path: { id } },
4550
+ options
4551
+ );
4552
+ },
4553
+ /**
4554
+ * List outbound emails for a workspace.
4555
+ *
4556
+ * @param workspaceId - The ID of the workspace to query.
4557
+ * @param options - Optional pagination and request options.
4558
+ * @returns A promise resolving to an array of {@link EmailOutboundEmail}.
4559
+ *
4560
+ * @example
4561
+ * ```typescript
4562
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4563
+ * const emails = await admin.email.outboundEmails.listByWorkspace('ws_abc123');
4564
+ * ```
4565
+ */
4566
+ listByWorkspace: async (workspaceId, options) => {
4567
+ return rb.execute(
4568
+ getAdminEmailOutboundEmailsWorkspaceByWorkspaceId,
4569
+ {
4570
+ path: { workspace_id: workspaceId },
4571
+ ...buildPageQuery(options?.page, options?.pageSize)
4572
+ },
4573
+ options
4574
+ );
4575
+ },
4576
+ /**
4577
+ * Create an outbound email draft.
4578
+ *
4579
+ * @param attributes - Email attributes including `workspace_id`, `subject`, `body_html`, `sender_profile_id`.
4580
+ * @param options - Optional request-level overrides.
4581
+ * @returns A promise resolving to the created {@link EmailOutboundEmail}.
4582
+ *
4583
+ * @example
4584
+ * ```typescript
4585
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4586
+ * const email = await admin.email.outboundEmails.create({
4587
+ * workspace_id: 'ws_abc123',
4588
+ * subject: 'Admin notification',
4589
+ * body_html: '<p>Hello</p>',
4590
+ * sender_profile_id: 'sp_noreply',
4591
+ * });
4592
+ * ```
4593
+ */
4594
+ create: async (attributes, options) => {
4595
+ return rb.execute(
4596
+ postAdminEmailOutboundEmails,
4597
+ { body: { data: { type: "email_outbound_email", attributes } } },
4598
+ options
4599
+ );
4600
+ },
4601
+ /**
4602
+ * Delete an outbound email draft.
4603
+ *
4604
+ * @param id - The unique identifier of the outbound email to delete.
4605
+ * @param options - Optional request-level overrides.
4606
+ * @returns A promise that resolves to `true` on successful deletion.
4607
+ *
4608
+ * @example
4609
+ * ```typescript
4610
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4611
+ * await admin.email.outboundEmails.delete('oe_abc123');
4612
+ * ```
4613
+ */
4614
+ delete: async (id, options) => {
4615
+ return rb.executeDelete(
4616
+ deleteAdminEmailOutboundEmailsById,
4617
+ { path: { id } },
4618
+ options
4619
+ );
4620
+ }
4621
+ },
4622
+ /**
4623
+ * Sender profile management — admin view across all workspaces.
4624
+ */
4625
+ senderProfiles: {
4626
+ /**
4627
+ * Get a sender profile by ID.
4628
+ *
4629
+ * @param id - The unique identifier of the sender profile.
4630
+ * @param options - Optional request-level overrides.
4631
+ * @returns A promise resolving to the {@link EmailMarketingSenderProfile}.
4632
+ *
4633
+ * @example
4634
+ * ```typescript
4635
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4636
+ * const profile = await admin.email.senderProfiles.get('sp_abc123');
4637
+ * ```
4638
+ */
4639
+ get: async (id, options) => {
4640
+ return rb.execute(
4641
+ getAdminEmailMarketingSenderProfilesById,
4642
+ { path: { id } },
4643
+ options
4644
+ );
4645
+ },
4646
+ /**
4647
+ * List sender profiles for a workspace.
4648
+ *
4649
+ * @param workspaceId - The ID of the workspace to query.
4650
+ * @param options - Optional pagination and request options.
4651
+ * @returns A promise resolving to an array of {@link EmailMarketingSenderProfile}.
4652
+ *
4653
+ * @example
4654
+ * ```typescript
4655
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4656
+ * const profiles = await admin.email.senderProfiles.listByWorkspace('ws_abc123');
4657
+ * ```
4658
+ */
4659
+ listByWorkspace: async (workspaceId, options) => {
4660
+ return rb.execute(
4661
+ getAdminEmailMarketingSenderProfilesWorkspaceByWorkspaceId,
4662
+ {
4663
+ path: { workspace_id: workspaceId },
4664
+ ...buildPageQuery(options?.page, options?.pageSize)
4665
+ },
4666
+ options
4667
+ );
4668
+ },
4669
+ /**
4670
+ * Create a new sender profile.
4671
+ *
4672
+ * @param attributes - Profile attributes including `workspace_id`, `from_email`, `from_name`.
4673
+ * @param options - Optional request-level overrides.
4674
+ * @returns A promise resolving to the created {@link EmailMarketingSenderProfile}.
4675
+ *
4676
+ * @example
4677
+ * ```typescript
4678
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4679
+ * const profile = await admin.email.senderProfiles.create({
4680
+ * workspace_id: 'ws_abc123',
4681
+ * from_email: 'noreply@acme.com',
4682
+ * from_name: 'Acme Team',
4683
+ * });
4684
+ * ```
4685
+ */
4686
+ create: async (attributes, options) => {
4687
+ return rb.execute(
4688
+ postAdminEmailMarketingSenderProfiles,
4689
+ { body: { data: { type: "email_sender_profile", attributes } } },
4690
+ options
4691
+ );
4692
+ },
4693
+ /**
4694
+ * Update a sender profile.
4695
+ *
4696
+ * @param id - The unique identifier of the sender profile to update.
4697
+ * @param attributes - Attributes to update.
4698
+ * @param options - Optional request-level overrides.
4699
+ * @returns A promise resolving to the updated {@link EmailMarketingSenderProfile}.
4700
+ *
4701
+ * @example
4702
+ * ```typescript
4703
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4704
+ * const profile = await admin.email.senderProfiles.update('sp_abc123', {
4705
+ * from_name: 'Acme Support',
4706
+ * });
4707
+ * ```
4708
+ */
4709
+ update: async (id, attributes, options) => {
4710
+ return rb.execute(
4711
+ patchAdminEmailMarketingSenderProfilesById,
4712
+ {
4713
+ path: { id },
4714
+ body: { data: { id, type: "email_sender_profile", attributes } }
4715
+ },
4716
+ options
4717
+ );
4718
+ },
4719
+ /**
4720
+ * Delete a sender profile.
4721
+ *
4722
+ * @param id - The unique identifier of the sender profile to delete.
4723
+ * @param options - Optional request-level overrides.
4724
+ * @returns A promise that resolves to `true` on successful deletion.
4725
+ *
4726
+ * @example
4727
+ * ```typescript
4728
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4729
+ * await admin.email.senderProfiles.delete('sp_abc123');
4730
+ * ```
4731
+ */
4732
+ delete: async (id, options) => {
4733
+ return rb.executeDelete(
4734
+ deleteAdminEmailMarketingSenderProfilesById,
4735
+ { path: { id } },
4736
+ options
4737
+ );
4738
+ },
4739
+ /**
4740
+ * Trigger DNS validation for a sender profile (verifies SPF/DKIM/DMARC).
4741
+ *
4742
+ * @param id - The unique identifier of the sender profile.
4743
+ * @param options - Optional request-level overrides.
4744
+ * @returns A promise resolving to the updated {@link EmailMarketingSenderProfile} with DNS status.
4745
+ *
4746
+ * @example
4747
+ * ```typescript
4748
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4749
+ * const result = await admin.email.senderProfiles.validateDns('sp_abc123');
4750
+ * console.log(result.attributes.spf_valid, result.attributes.dkim_valid);
4751
+ * ```
4752
+ */
4753
+ validateDns: async (id, options) => {
4754
+ return rb.execute(
4755
+ patchAdminEmailMarketingSenderProfilesByIdValidateDns,
4756
+ { path: { id }, body: {} },
4757
+ options
4758
+ );
4759
+ }
4760
+ },
4761
+ /**
4762
+ * Tracking event management — admin view across all workspaces.
4763
+ */
4764
+ trackingEvents: {
4765
+ /**
4766
+ * Get a tracking event by ID.
4767
+ *
4768
+ * @param id - The unique identifier of the tracking event.
4769
+ * @param options - Optional request-level overrides.
4770
+ * @returns A promise resolving to the tracking event record.
4771
+ *
4772
+ * @example
4773
+ * ```typescript
4774
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4775
+ * const event = await admin.email.trackingEvents.get('te_abc123');
4776
+ * ```
4777
+ */
4778
+ get: async (id, options) => {
4779
+ return rb.execute(
4780
+ getAdminEmailTrackingEventsById,
4781
+ { path: { id } },
4782
+ options
4783
+ );
4784
+ },
4785
+ /**
4786
+ * List tracking events for a workspace.
4787
+ *
4788
+ * @param workspaceId - The ID of the workspace to query.
4789
+ * @param options - Optional pagination and request options.
4790
+ * @returns A promise resolving to an array of {@link EmailTrackingEvent} records.
4791
+ *
4792
+ * @example
4793
+ * ```typescript
4794
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
4795
+ * const events = await admin.email.trackingEvents.listByWorkspace('ws_abc123');
4796
+ * ```
4797
+ */
4798
+ listByWorkspace: async (workspaceId, options) => {
4799
+ return rb.execute(
4800
+ getAdminEmailTrackingEventsWorkspaceByWorkspaceId,
4801
+ {
4802
+ path: { workspace_id: workspaceId },
4803
+ ...buildPageQuery(options?.page, options?.pageSize)
4804
+ },
4805
+ options
4806
+ );
4807
+ }
4808
+ }
4809
+ };
4810
+ }
4811
+
1750
4812
  // src/gpt-admin.ts
1751
4813
  var GptAdmin = class extends BaseClient {
1752
4814
  constructor(config) {
@@ -1757,12 +4819,19 @@ var GptAdmin = class extends BaseClient {
1757
4819
  (d) => this.unwrap(d),
1758
4820
  (fn) => this.requestWithRetry(fn)
1759
4821
  );
4822
+ this.agents = createAgentsNamespace(rb);
1760
4823
  this.accounts = createAccountsNamespace(rb);
4824
+ this.capabilities = createCapabilitiesNamespace(rb);
1761
4825
  this.apiKeys = createApiKeysNamespace(rb);
1762
4826
  this.documents = createDocumentsNamespace(rb);
1763
4827
  this.executions = createExecutionsNamespace(rb);
1764
4828
  this.storage = createStorageNamespace(rb);
4829
+ this.users = createUsersNamespace(rb);
4830
+ this.voice = createVoiceNamespace(rb);
4831
+ this.audit = createAuditNamespace(rb);
1765
4832
  this.webhooks = createWebhooksNamespace(rb);
4833
+ this.campaigns = createCampaignsNamespace(rb);
4834
+ this.email = createEmailNamespace(rb);
1766
4835
  }
1767
4836
  };
1768
4837