@gpt-platform/admin 0.1.2 → 0.1.4

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
@@ -1504,58 +1504,12 @@ var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client
1504
1504
  }
1505
1505
  });
1506
1506
 
1507
- // src/schemas/requests.ts
1508
- import { z } from "zod";
1509
- var StorageStatsRequestSchema = z.object({
1510
- workspace_id: z.string().optional()
1511
- });
1512
- var WebhookConfigCreateSchema = z.object({
1513
- url: z.string().url(),
1514
- events: z.array(z.string()).min(1),
1515
- secret: z.string().optional(),
1516
- enabled: z.boolean().default(true)
1517
- });
1518
- var WebhookBulkEnableSchema = z.object({
1519
- config_ids: z.array(z.string()).min(1).max(100)
1520
- });
1521
- var WebhookBulkDisableSchema = z.object({
1522
- config_ids: z.array(z.string()).min(1).max(100)
1523
- });
1524
- var WebhookDeliveryBulkRetrySchema = z.object({
1525
- delivery_ids: z.array(z.string()).min(1).max(100)
1526
- });
1527
- var AgentAdminCreateSchema = z.object({
1528
- name: z.string().min(1).max(255),
1529
- prompt_template: z.string().min(1),
1530
- system_wide: z.boolean().default(false)
1531
- });
1532
- var AccountCreditSchema = z.object({
1533
- amount: z.number().positive(),
1534
- description: z.string().optional()
1535
- });
1536
- var AccountDebitSchema = z.object({
1537
- amount: z.number().positive(),
1538
- description: z.string().optional()
1539
- });
1540
- var ApiKeyAllocateSchema = z.object({
1541
- rate_limit: z.number().int().positive().optional(),
1542
- expires_at: z.string().datetime().optional()
1543
- });
1544
- var DocumentBulkDeleteSchema = z.object({
1545
- document_ids: z.array(z.string()).min(1).max(100)
1546
- });
1547
- var DocumentBulkReprocessSchema = z.object({
1548
- document_ids: z.array(z.string()).min(1).max(100)
1549
- });
1550
-
1551
1507
  // src/namespaces/accounts.ts
1552
1508
  function createAccountsNamespace(rb) {
1553
1509
  return {
1554
- /** List all billing accounts */
1555
1510
  list: async (options) => {
1556
1511
  return rb.execute(getAdminAccounts, {}, options);
1557
1512
  },
1558
- /** Get a billing account by ID */
1559
1513
  get: async (id, options) => {
1560
1514
  return rb.execute(
1561
1515
  getAdminAccountsById,
@@ -1563,37 +1517,31 @@ function createAccountsNamespace(rb) {
1563
1517
  options
1564
1518
  );
1565
1519
  },
1566
- /** Credit an account */
1567
1520
  credit: async (id, amount, description, options) => {
1568
- const validated = AccountCreditSchema.parse({ amount, description });
1521
+ if (amount <= 0) {
1522
+ throw new Error("Credit amount must be positive");
1523
+ }
1569
1524
  return rb.execute(
1570
1525
  patchAdminAccountsByIdCredit,
1571
1526
  {
1572
1527
  path: { id },
1573
1528
  body: {
1574
- data: {
1575
- id,
1576
- type: "account",
1577
- attributes: validated
1578
- }
1529
+ data: { type: "account", attributes: { amount, description } }
1579
1530
  }
1580
1531
  },
1581
1532
  options
1582
1533
  );
1583
1534
  },
1584
- /** Debit an account */
1585
1535
  debit: async (id, amount, description, options) => {
1586
- const validated = AccountDebitSchema.parse({ amount, description });
1536
+ if (amount <= 0) {
1537
+ throw new Error("Debit amount must be positive");
1538
+ }
1587
1539
  return rb.execute(
1588
1540
  patchAdminAccountsByIdDebit,
1589
1541
  {
1590
1542
  path: { id },
1591
1543
  body: {
1592
- data: {
1593
- id,
1594
- type: "account",
1595
- attributes: validated
1596
- }
1544
+ data: { type: "account", attributes: { amount, description } }
1597
1545
  }
1598
1546
  },
1599
1547
  options
@@ -1605,47 +1553,35 @@ function createAccountsNamespace(rb) {
1605
1553
  // src/namespaces/apiKeys.ts
1606
1554
  function createApiKeysNamespace(rb) {
1607
1555
  return {
1608
- /** List all API keys */
1609
1556
  list: async (options) => {
1610
1557
  return rb.execute(getAdminApiKeys, {}, options);
1611
1558
  },
1612
- /** Get an API key by ID */
1613
1559
  get: async (id, options) => {
1614
1560
  return rb.execute(getAdminApiKeysById, { path: { id } }, options);
1615
1561
  },
1616
- /** Allocate credits to an API key */
1617
1562
  allocate: async (id, amount, description, options) => {
1618
1563
  return rb.execute(
1619
1564
  patchAdminApiKeysByIdAllocate,
1620
1565
  {
1621
1566
  path: { id },
1622
1567
  body: {
1623
- data: {
1624
- id,
1625
- type: "api_key",
1626
- attributes: {
1627
- amount,
1628
- description
1629
- }
1630
- }
1568
+ data: { type: "api_key", attributes: { amount, description } }
1631
1569
  }
1632
1570
  },
1633
1571
  options
1634
1572
  );
1635
1573
  },
1636
- /** Revoke an API key */
1637
1574
  revoke: async (id, options) => {
1638
1575
  return rb.execute(
1639
1576
  patchAdminApiKeysByIdRevoke,
1640
- { path: { id } },
1577
+ { path: { id }, body: {} },
1641
1578
  options
1642
1579
  );
1643
1580
  },
1644
- /** Rotate an API key */
1645
1581
  rotate: async (id, options) => {
1646
1582
  return rb.execute(
1647
1583
  patchAdminApiKeysByIdRotate,
1648
- { path: { id } },
1584
+ { path: { id }, body: {} },
1649
1585
  options
1650
1586
  );
1651
1587
  }
@@ -1655,7 +1591,6 @@ function createApiKeysNamespace(rb) {
1655
1591
  // src/namespaces/documents.ts
1656
1592
  function createDocumentsNamespace(rb) {
1657
1593
  return {
1658
- /** List extraction documents */
1659
1594
  list: async (options) => {
1660
1595
  return rb.execute(
1661
1596
  getAdminExtractionDocuments,
@@ -1663,7 +1598,6 @@ function createDocumentsNamespace(rb) {
1663
1598
  options
1664
1599
  );
1665
1600
  },
1666
- /** Get a document by ID */
1667
1601
  get: async (id, options) => {
1668
1602
  return rb.execute(
1669
1603
  getAdminExtractionDocumentsById,
@@ -1671,181 +1605,49 @@ function createDocumentsNamespace(rb) {
1671
1605
  options
1672
1606
  );
1673
1607
  },
1674
- /** Get document statistics */
1675
- stats: async (options) => {
1676
- return rb.execute(getAdminDocumentsStats, {}, options);
1677
- },
1678
- /** Bulk delete documents */
1679
- bulkDelete: async (documentIds, options) => {
1680
- const validated = DocumentBulkDeleteSchema.parse({
1681
- document_ids: documentIds
1682
- });
1608
+ bulkDelete: async (ids, options) => {
1609
+ if (ids.length === 0) {
1610
+ throw new Error("At least one document ID is required");
1611
+ }
1612
+ if (ids.length > 100) {
1613
+ throw new Error("Maximum 100 documents per bulk operation");
1614
+ }
1683
1615
  return rb.execute(
1684
1616
  postAdminDocumentsBulkDelete,
1685
- {
1686
- body: {
1687
- data: {
1688
- type: "operation_success",
1689
- attributes: {
1690
- ids: validated.document_ids
1691
- }
1692
- }
1693
- }
1694
- },
1695
- options
1696
- );
1697
- }
1698
- };
1699
- }
1700
-
1701
- // src/namespaces/_executions-streaming.ts
1702
- function addExecutionStreaming(executions, getHeaders) {
1703
- executions.stream = async (executionId, options) => {
1704
- const headers = {
1705
- ...getHeaders(),
1706
- Accept: "text/event-stream"
1707
- };
1708
- const result = await client.get({
1709
- url: `/isv/agent-executions/${executionId}/stream`,
1710
- headers,
1711
- parseAs: "stream",
1712
- ...options?.signal && { signal: options.signal }
1713
- });
1714
- const envelope = result;
1715
- const streamBody = envelope.data ?? result;
1716
- const response = envelope.response;
1717
- if (response && !response.ok) {
1718
- throw new ServerError(`Stream request failed: ${response.status}`, {
1719
- statusCode: response.status
1720
- });
1721
- }
1722
- if (streamBody instanceof ReadableStream) {
1723
- const syntheticResponse = new Response(streamBody, {
1724
- headers: { "Content-Type": "text/event-stream" }
1725
- });
1726
- return streamMessage(syntheticResponse, {
1727
- signal: options?.signal,
1728
- ...options
1729
- });
1730
- }
1731
- if (streamBody instanceof Response) {
1732
- if (!streamBody.ok) {
1733
- throw new ServerError(`Stream request failed: ${streamBody.status}`, {
1734
- statusCode: streamBody.status
1735
- });
1736
- }
1737
- return streamMessage(streamBody, {
1738
- signal: options?.signal,
1739
- ...options
1740
- });
1741
- }
1742
- throw new GptCoreError("Unexpected stream response format", {
1743
- code: "stream_error"
1744
- });
1745
- };
1746
- }
1747
-
1748
- // src/namespaces/executions.ts
1749
- function createExecutionsNamespace(rb) {
1750
- const executions = {
1751
- /** Start a new agent execution */
1752
- start: async (agentId, params, options) => {
1753
- return rb.rawPost(
1754
- `/isv/agents/${agentId}/execute`,
1755
- params,
1756
- options
1757
- );
1758
- },
1759
- /** Get execution status and details */
1760
- get: async (executionId, options) => {
1761
- return rb.rawGet(
1762
- `/isv/agent-executions/${executionId}`,
1763
- options
1764
- );
1765
- },
1766
- /** List executions for a workspace */
1767
- list: async (filters, options) => {
1768
- const query = filters?.status ? `?status=${filters.status}` : "";
1769
- return rb.rawGet(
1770
- `/isv/agent-executions${query}`,
1771
- options
1772
- );
1773
- },
1774
- /** Cancel a running execution */
1775
- cancel: async (executionId, options) => {
1776
- return rb.rawPost(
1777
- `/isv/agent-executions/${executionId}/cancel`,
1778
- void 0,
1617
+ { body: { data: { type: "bulk_delete", attributes: { ids } } } },
1779
1618
  options
1780
1619
  );
1781
1620
  },
1782
- /** Approve a pending tool call */
1783
- approve: async (executionId, options) => {
1784
- return rb.rawPost(
1785
- `/isv/agent-executions/${executionId}/approve`,
1786
- void 0,
1787
- options
1788
- );
1789
- },
1790
- /** Deny a pending tool call */
1791
- deny: async (executionId, reason, options) => {
1792
- return rb.rawPost(
1793
- `/isv/agent-executions/${executionId}/deny`,
1794
- reason ? { reason } : void 0,
1795
- options
1796
- );
1797
- },
1798
- /** Estimate cost for executing an agent */
1799
- estimate: async (agentId, params, options) => {
1800
- return rb.rawPost(
1801
- `/isv/agents/${agentId}/estimate`,
1802
- params,
1803
- options
1804
- );
1805
- },
1806
- /** Get child executions of a parent execution */
1807
- getChildren: async (executionId, options) => {
1808
- return rb.rawGet(
1809
- `/isv/agent-executions/${executionId}/children`,
1810
- options
1811
- );
1812
- },
1813
- /** Get the execution tree rooted at a given execution */
1814
- getTree: async (executionId, options) => {
1815
- return rb.rawGet(
1816
- `/isv/agent-executions/${executionId}/tree`,
1621
+ stats: async (options) => {
1622
+ return rb.execute(
1623
+ getAdminDocumentsStats,
1624
+ {},
1817
1625
  options
1818
1626
  );
1819
1627
  }
1820
1628
  };
1821
- addExecutionStreaming(
1822
- executions,
1823
- () => rb.getRequestHeaders()
1824
- );
1825
- return executions;
1629
+ }
1630
+
1631
+ // src/namespaces/executions.ts
1632
+ function createExecutionsNamespace(_rb) {
1633
+ return {};
1826
1634
  }
1827
1635
 
1828
1636
  // src/namespaces/storage.ts
1829
1637
  function createStorageNamespace(rb) {
1830
1638
  return {
1831
- /** Get storage statistics */
1832
1639
  stats: async (workspaceId, options) => {
1833
- const validated = StorageStatsRequestSchema.parse({
1834
- workspace_id: workspaceId
1835
- });
1640
+ const params = workspaceId ? { query: { "filter[workspace_id]": workspaceId } } : {};
1836
1641
  return rb.execute(
1837
1642
  getAdminStorageStats,
1838
- validated.workspace_id ? { query: { filter: { workspace_id: validated.workspace_id } } } : {},
1643
+ params,
1839
1644
  options
1840
1645
  );
1841
1646
  },
1842
- /** Bucket management */
1843
1647
  buckets: {
1844
- /** List all buckets */
1845
1648
  list: async (options) => {
1846
1649
  return rb.execute(getAdminBuckets, {}, options);
1847
1650
  },
1848
- /** Get a bucket by ID */
1849
1651
  get: async (id, options) => {
1850
1652
  return rb.execute(
1851
1653
  getAdminBucketsById,
@@ -1853,7 +1655,6 @@ function createStorageNamespace(rb) {
1853
1655
  options
1854
1656
  );
1855
1657
  },
1856
- /** Get bucket statistics */
1857
1658
  stats: async (id, options) => {
1858
1659
  return rb.execute(
1859
1660
  getAdminBucketsByIdStats,
@@ -1861,7 +1662,6 @@ function createStorageNamespace(rb) {
1861
1662
  options
1862
1663
  );
1863
1664
  },
1864
- /** List objects in a bucket */
1865
1665
  objects: async (id, options) => {
1866
1666
  return rb.execute(
1867
1667
  getAdminBucketsByIdObjects,
@@ -1877,12 +1677,10 @@ function createStorageNamespace(rb) {
1877
1677
  function createWebhooksNamespace(rb) {
1878
1678
  return {
1879
1679
  configs: {
1880
- /** List all webhook configs */
1881
1680
  list: async (options) => {
1882
1681
  return rb.execute(getAdminWebhookConfigs, {}, options);
1883
1682
  },
1884
- /** Create a webhook config */
1885
- create: async (name, url, events, applicationId, secret, enabled = true, options) => {
1683
+ create: async (name, url, events, applicationId, secret, options) => {
1886
1684
  return rb.execute(
1887
1685
  postAdminWebhookConfigs,
1888
1686
  {
@@ -1894,8 +1692,7 @@ function createWebhooksNamespace(rb) {
1894
1692
  url,
1895
1693
  events,
1896
1694
  application_id: applicationId,
1897
- secret,
1898
- enabled
1695
+ secret
1899
1696
  }
1900
1697
  }
1901
1698
  }
@@ -1903,7 +1700,6 @@ function createWebhooksNamespace(rb) {
1903
1700
  options
1904
1701
  );
1905
1702
  },
1906
- /** Get a webhook config by ID */
1907
1703
  get: async (id, options) => {
1908
1704
  return rb.execute(
1909
1705
  getAdminWebhookConfigsById,
@@ -1911,24 +1707,16 @@ function createWebhooksNamespace(rb) {
1911
1707
  options
1912
1708
  );
1913
1709
  },
1914
- /** Update a webhook config */
1915
- update: async (id, updates, options) => {
1710
+ update: async (id, attributes, options) => {
1916
1711
  return rb.execute(
1917
1712
  patchAdminWebhookConfigsById,
1918
1713
  {
1919
1714
  path: { id },
1920
- body: {
1921
- data: {
1922
- id,
1923
- type: "webhook_config",
1924
- attributes: updates
1925
- }
1926
- }
1715
+ body: { data: { id, type: "webhook_config", attributes } }
1927
1716
  },
1928
1717
  options
1929
1718
  );
1930
1719
  },
1931
- /** Delete a webhook config */
1932
1720
  delete: async (id, options) => {
1933
1721
  return rb.executeDelete(
1934
1722
  deleteAdminWebhookConfigsById,
@@ -1936,17 +1724,15 @@ function createWebhooksNamespace(rb) {
1936
1724
  options
1937
1725
  );
1938
1726
  },
1939
- /** Test a webhook config */
1940
1727
  test: async (id, options) => {
1941
1728
  return rb.execute(
1942
1729
  postAdminWebhookConfigsByIdTest,
1943
- { path: { id } },
1730
+ { path: { id }, body: {} },
1944
1731
  options
1945
1732
  );
1946
1733
  }
1947
1734
  },
1948
1735
  deliveries: {
1949
- /** List webhook deliveries */
1950
1736
  list: async (options) => {
1951
1737
  return rb.execute(
1952
1738
  getAdminWebhookDeliveries,
@@ -1954,7 +1740,6 @@ function createWebhooksNamespace(rb) {
1954
1740
  options
1955
1741
  );
1956
1742
  },
1957
- /** Get a webhook delivery by ID */
1958
1743
  get: async (id, options) => {
1959
1744
  return rb.execute(
1960
1745
  getAdminWebhookDeliveriesById,
@@ -1962,11 +1747,10 @@ function createWebhooksNamespace(rb) {
1962
1747
  options
1963
1748
  );
1964
1749
  },
1965
- /** Retry a webhook delivery */
1966
1750
  retry: async (id, options) => {
1967
1751
  return rb.execute(
1968
1752
  postAdminWebhookDeliveriesByIdRetry,
1969
- { path: { id } },
1753
+ { path: { id }, body: {} },
1970
1754
  options
1971
1755
  );
1972
1756
  }
@@ -1996,28 +1780,17 @@ var GptAdmin = class extends BaseClient {
1996
1780
  // src/index.ts
1997
1781
  var index_default = GptAdmin;
1998
1782
  export {
1999
- AccountCreditSchema,
2000
- AccountDebitSchema,
2001
- AgentAdminCreateSchema,
2002
- ApiKeyAllocateSchema,
2003
1783
  AuthenticationError,
2004
1784
  AuthorizationError,
2005
1785
  DEFAULT_API_VERSION,
2006
- DocumentBulkDeleteSchema,
2007
- DocumentBulkReprocessSchema,
2008
1786
  GptAdmin,
2009
1787
  GptCoreError,
2010
1788
  NetworkError,
2011
1789
  NotFoundError,
2012
1790
  RateLimitError,
2013
1791
  ServerError,
2014
- StorageStatsRequestSchema,
2015
1792
  TimeoutError,
2016
1793
  ValidationError,
2017
- WebhookBulkDisableSchema,
2018
- WebhookBulkEnableSchema,
2019
- WebhookConfigCreateSchema,
2020
- WebhookDeliveryBulkRetrySchema,
2021
1794
  index_default as default,
2022
1795
  handleApiError
2023
1796
  };