@gpt-platform/admin 0.1.3 → 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.js CHANGED
@@ -20,28 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- AccountCreditSchema: () => AccountCreditSchema,
24
- AccountDebitSchema: () => AccountDebitSchema,
25
- AgentAdminCreateSchema: () => AgentAdminCreateSchema,
26
- ApiKeyAllocateSchema: () => ApiKeyAllocateSchema,
27
23
  AuthenticationError: () => AuthenticationError,
28
24
  AuthorizationError: () => AuthorizationError,
29
25
  DEFAULT_API_VERSION: () => DEFAULT_API_VERSION,
30
- DocumentBulkDeleteSchema: () => DocumentBulkDeleteSchema,
31
- DocumentBulkReprocessSchema: () => DocumentBulkReprocessSchema,
32
26
  GptAdmin: () => GptAdmin,
33
27
  GptCoreError: () => GptCoreError,
34
28
  NetworkError: () => NetworkError,
35
29
  NotFoundError: () => NotFoundError,
36
30
  RateLimitError: () => RateLimitError,
37
31
  ServerError: () => ServerError,
38
- StorageStatsRequestSchema: () => StorageStatsRequestSchema,
39
32
  TimeoutError: () => TimeoutError,
40
33
  ValidationError: () => ValidationError,
41
- WebhookBulkDisableSchema: () => WebhookBulkDisableSchema,
42
- WebhookBulkEnableSchema: () => WebhookBulkEnableSchema,
43
- WebhookConfigCreateSchema: () => WebhookConfigCreateSchema,
44
- WebhookDeliveryBulkRetrySchema: () => WebhookDeliveryBulkRetrySchema,
45
34
  default: () => index_default,
46
35
  handleApiError: () => handleApiError
47
36
  });
@@ -1553,58 +1542,12 @@ var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client
1553
1542
  }
1554
1543
  });
1555
1544
 
1556
- // src/schemas/requests.ts
1557
- var import_zod = require("zod");
1558
- var StorageStatsRequestSchema = import_zod.z.object({
1559
- workspace_id: import_zod.z.string().optional()
1560
- });
1561
- var WebhookConfigCreateSchema = import_zod.z.object({
1562
- url: import_zod.z.string().url(),
1563
- events: import_zod.z.array(import_zod.z.string()).min(1),
1564
- secret: import_zod.z.string().optional(),
1565
- enabled: import_zod.z.boolean().default(true)
1566
- });
1567
- var WebhookBulkEnableSchema = import_zod.z.object({
1568
- config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
1569
- });
1570
- var WebhookBulkDisableSchema = import_zod.z.object({
1571
- config_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
1572
- });
1573
- var WebhookDeliveryBulkRetrySchema = import_zod.z.object({
1574
- delivery_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
1575
- });
1576
- var AgentAdminCreateSchema = import_zod.z.object({
1577
- name: import_zod.z.string().min(1).max(255),
1578
- prompt_template: import_zod.z.string().min(1),
1579
- system_wide: import_zod.z.boolean().default(false)
1580
- });
1581
- var AccountCreditSchema = import_zod.z.object({
1582
- amount: import_zod.z.number().positive(),
1583
- description: import_zod.z.string().optional()
1584
- });
1585
- var AccountDebitSchema = import_zod.z.object({
1586
- amount: import_zod.z.number().positive(),
1587
- description: import_zod.z.string().optional()
1588
- });
1589
- var ApiKeyAllocateSchema = import_zod.z.object({
1590
- rate_limit: import_zod.z.number().int().positive().optional(),
1591
- expires_at: import_zod.z.string().datetime().optional()
1592
- });
1593
- var DocumentBulkDeleteSchema = import_zod.z.object({
1594
- document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
1595
- });
1596
- var DocumentBulkReprocessSchema = import_zod.z.object({
1597
- document_ids: import_zod.z.array(import_zod.z.string()).min(1).max(100)
1598
- });
1599
-
1600
1545
  // src/namespaces/accounts.ts
1601
1546
  function createAccountsNamespace(rb) {
1602
1547
  return {
1603
- /** List all billing accounts */
1604
1548
  list: async (options) => {
1605
1549
  return rb.execute(getAdminAccounts, {}, options);
1606
1550
  },
1607
- /** Get a billing account by ID */
1608
1551
  get: async (id, options) => {
1609
1552
  return rb.execute(
1610
1553
  getAdminAccountsById,
@@ -1612,37 +1555,31 @@ function createAccountsNamespace(rb) {
1612
1555
  options
1613
1556
  );
1614
1557
  },
1615
- /** Credit an account */
1616
1558
  credit: async (id, amount, description, options) => {
1617
- const validated = AccountCreditSchema.parse({ amount, description });
1559
+ if (amount <= 0) {
1560
+ throw new Error("Credit amount must be positive");
1561
+ }
1618
1562
  return rb.execute(
1619
1563
  patchAdminAccountsByIdCredit,
1620
1564
  {
1621
1565
  path: { id },
1622
1566
  body: {
1623
- data: {
1624
- id,
1625
- type: "account",
1626
- attributes: validated
1627
- }
1567
+ data: { type: "account", attributes: { amount, description } }
1628
1568
  }
1629
1569
  },
1630
1570
  options
1631
1571
  );
1632
1572
  },
1633
- /** Debit an account */
1634
1573
  debit: async (id, amount, description, options) => {
1635
- const validated = AccountDebitSchema.parse({ amount, description });
1574
+ if (amount <= 0) {
1575
+ throw new Error("Debit amount must be positive");
1576
+ }
1636
1577
  return rb.execute(
1637
1578
  patchAdminAccountsByIdDebit,
1638
1579
  {
1639
1580
  path: { id },
1640
1581
  body: {
1641
- data: {
1642
- id,
1643
- type: "account",
1644
- attributes: validated
1645
- }
1582
+ data: { type: "account", attributes: { amount, description } }
1646
1583
  }
1647
1584
  },
1648
1585
  options
@@ -1654,47 +1591,35 @@ function createAccountsNamespace(rb) {
1654
1591
  // src/namespaces/apiKeys.ts
1655
1592
  function createApiKeysNamespace(rb) {
1656
1593
  return {
1657
- /** List all API keys */
1658
1594
  list: async (options) => {
1659
1595
  return rb.execute(getAdminApiKeys, {}, options);
1660
1596
  },
1661
- /** Get an API key by ID */
1662
1597
  get: async (id, options) => {
1663
1598
  return rb.execute(getAdminApiKeysById, { path: { id } }, options);
1664
1599
  },
1665
- /** Allocate credits to an API key */
1666
1600
  allocate: async (id, amount, description, options) => {
1667
1601
  return rb.execute(
1668
1602
  patchAdminApiKeysByIdAllocate,
1669
1603
  {
1670
1604
  path: { id },
1671
1605
  body: {
1672
- data: {
1673
- id,
1674
- type: "api_key",
1675
- attributes: {
1676
- amount,
1677
- description
1678
- }
1679
- }
1606
+ data: { type: "api_key", attributes: { amount, description } }
1680
1607
  }
1681
1608
  },
1682
1609
  options
1683
1610
  );
1684
1611
  },
1685
- /** Revoke an API key */
1686
1612
  revoke: async (id, options) => {
1687
1613
  return rb.execute(
1688
1614
  patchAdminApiKeysByIdRevoke,
1689
- { path: { id } },
1615
+ { path: { id }, body: {} },
1690
1616
  options
1691
1617
  );
1692
1618
  },
1693
- /** Rotate an API key */
1694
1619
  rotate: async (id, options) => {
1695
1620
  return rb.execute(
1696
1621
  patchAdminApiKeysByIdRotate,
1697
- { path: { id } },
1622
+ { path: { id }, body: {} },
1698
1623
  options
1699
1624
  );
1700
1625
  }
@@ -1704,7 +1629,6 @@ function createApiKeysNamespace(rb) {
1704
1629
  // src/namespaces/documents.ts
1705
1630
  function createDocumentsNamespace(rb) {
1706
1631
  return {
1707
- /** List extraction documents */
1708
1632
  list: async (options) => {
1709
1633
  return rb.execute(
1710
1634
  getAdminExtractionDocuments,
@@ -1712,7 +1636,6 @@ function createDocumentsNamespace(rb) {
1712
1636
  options
1713
1637
  );
1714
1638
  },
1715
- /** Get a document by ID */
1716
1639
  get: async (id, options) => {
1717
1640
  return rb.execute(
1718
1641
  getAdminExtractionDocumentsById,
@@ -1720,181 +1643,49 @@ function createDocumentsNamespace(rb) {
1720
1643
  options
1721
1644
  );
1722
1645
  },
1723
- /** Get document statistics */
1724
- stats: async (options) => {
1725
- return rb.execute(getAdminDocumentsStats, {}, options);
1726
- },
1727
- /** Bulk delete documents */
1728
- bulkDelete: async (documentIds, options) => {
1729
- const validated = DocumentBulkDeleteSchema.parse({
1730
- document_ids: documentIds
1731
- });
1646
+ bulkDelete: async (ids, options) => {
1647
+ if (ids.length === 0) {
1648
+ throw new Error("At least one document ID is required");
1649
+ }
1650
+ if (ids.length > 100) {
1651
+ throw new Error("Maximum 100 documents per bulk operation");
1652
+ }
1732
1653
  return rb.execute(
1733
1654
  postAdminDocumentsBulkDelete,
1734
- {
1735
- body: {
1736
- data: {
1737
- type: "operation_success",
1738
- attributes: {
1739
- ids: validated.document_ids
1740
- }
1741
- }
1742
- }
1743
- },
1744
- options
1745
- );
1746
- }
1747
- };
1748
- }
1749
-
1750
- // src/namespaces/_executions-streaming.ts
1751
- function addExecutionStreaming(executions, getHeaders) {
1752
- executions.stream = async (executionId, options) => {
1753
- const headers = {
1754
- ...getHeaders(),
1755
- Accept: "text/event-stream"
1756
- };
1757
- const result = await client.get({
1758
- url: `/isv/agent-executions/${executionId}/stream`,
1759
- headers,
1760
- parseAs: "stream",
1761
- ...options?.signal && { signal: options.signal }
1762
- });
1763
- const envelope = result;
1764
- const streamBody = envelope.data ?? result;
1765
- const response = envelope.response;
1766
- if (response && !response.ok) {
1767
- throw new ServerError(`Stream request failed: ${response.status}`, {
1768
- statusCode: response.status
1769
- });
1770
- }
1771
- if (streamBody instanceof ReadableStream) {
1772
- const syntheticResponse = new Response(streamBody, {
1773
- headers: { "Content-Type": "text/event-stream" }
1774
- });
1775
- return streamMessage(syntheticResponse, {
1776
- signal: options?.signal,
1777
- ...options
1778
- });
1779
- }
1780
- if (streamBody instanceof Response) {
1781
- if (!streamBody.ok) {
1782
- throw new ServerError(`Stream request failed: ${streamBody.status}`, {
1783
- statusCode: streamBody.status
1784
- });
1785
- }
1786
- return streamMessage(streamBody, {
1787
- signal: options?.signal,
1788
- ...options
1789
- });
1790
- }
1791
- throw new GptCoreError("Unexpected stream response format", {
1792
- code: "stream_error"
1793
- });
1794
- };
1795
- }
1796
-
1797
- // src/namespaces/executions.ts
1798
- function createExecutionsNamespace(rb) {
1799
- const executions = {
1800
- /** Start a new agent execution */
1801
- start: async (agentId, params, options) => {
1802
- return rb.rawPost(
1803
- `/isv/agents/${agentId}/execute`,
1804
- params,
1805
- options
1806
- );
1807
- },
1808
- /** Get execution status and details */
1809
- get: async (executionId, options) => {
1810
- return rb.rawGet(
1811
- `/isv/agent-executions/${executionId}`,
1812
- options
1813
- );
1814
- },
1815
- /** List executions for a workspace */
1816
- list: async (filters, options) => {
1817
- const query = filters?.status ? `?status=${filters.status}` : "";
1818
- return rb.rawGet(
1819
- `/isv/agent-executions${query}`,
1820
- options
1821
- );
1822
- },
1823
- /** Cancel a running execution */
1824
- cancel: async (executionId, options) => {
1825
- return rb.rawPost(
1826
- `/isv/agent-executions/${executionId}/cancel`,
1827
- void 0,
1655
+ { body: { data: { type: "bulk_delete", attributes: { ids } } } },
1828
1656
  options
1829
1657
  );
1830
1658
  },
1831
- /** Approve a pending tool call */
1832
- approve: async (executionId, options) => {
1833
- return rb.rawPost(
1834
- `/isv/agent-executions/${executionId}/approve`,
1835
- void 0,
1836
- options
1837
- );
1838
- },
1839
- /** Deny a pending tool call */
1840
- deny: async (executionId, reason, options) => {
1841
- return rb.rawPost(
1842
- `/isv/agent-executions/${executionId}/deny`,
1843
- reason ? { reason } : void 0,
1844
- options
1845
- );
1846
- },
1847
- /** Estimate cost for executing an agent */
1848
- estimate: async (agentId, params, options) => {
1849
- return rb.rawPost(
1850
- `/isv/agents/${agentId}/estimate`,
1851
- params,
1852
- options
1853
- );
1854
- },
1855
- /** Get child executions of a parent execution */
1856
- getChildren: async (executionId, options) => {
1857
- return rb.rawGet(
1858
- `/isv/agent-executions/${executionId}/children`,
1859
- options
1860
- );
1861
- },
1862
- /** Get the execution tree rooted at a given execution */
1863
- getTree: async (executionId, options) => {
1864
- return rb.rawGet(
1865
- `/isv/agent-executions/${executionId}/tree`,
1659
+ stats: async (options) => {
1660
+ return rb.execute(
1661
+ getAdminDocumentsStats,
1662
+ {},
1866
1663
  options
1867
1664
  );
1868
1665
  }
1869
1666
  };
1870
- addExecutionStreaming(
1871
- executions,
1872
- () => rb.getRequestHeaders()
1873
- );
1874
- return executions;
1667
+ }
1668
+
1669
+ // src/namespaces/executions.ts
1670
+ function createExecutionsNamespace(_rb) {
1671
+ return {};
1875
1672
  }
1876
1673
 
1877
1674
  // src/namespaces/storage.ts
1878
1675
  function createStorageNamespace(rb) {
1879
1676
  return {
1880
- /** Get storage statistics */
1881
1677
  stats: async (workspaceId, options) => {
1882
- const validated = StorageStatsRequestSchema.parse({
1883
- workspace_id: workspaceId
1884
- });
1678
+ const params = workspaceId ? { query: { "filter[workspace_id]": workspaceId } } : {};
1885
1679
  return rb.execute(
1886
1680
  getAdminStorageStats,
1887
- validated.workspace_id ? { query: { filter: { workspace_id: validated.workspace_id } } } : {},
1681
+ params,
1888
1682
  options
1889
1683
  );
1890
1684
  },
1891
- /** Bucket management */
1892
1685
  buckets: {
1893
- /** List all buckets */
1894
1686
  list: async (options) => {
1895
1687
  return rb.execute(getAdminBuckets, {}, options);
1896
1688
  },
1897
- /** Get a bucket by ID */
1898
1689
  get: async (id, options) => {
1899
1690
  return rb.execute(
1900
1691
  getAdminBucketsById,
@@ -1902,7 +1693,6 @@ function createStorageNamespace(rb) {
1902
1693
  options
1903
1694
  );
1904
1695
  },
1905
- /** Get bucket statistics */
1906
1696
  stats: async (id, options) => {
1907
1697
  return rb.execute(
1908
1698
  getAdminBucketsByIdStats,
@@ -1910,7 +1700,6 @@ function createStorageNamespace(rb) {
1910
1700
  options
1911
1701
  );
1912
1702
  },
1913
- /** List objects in a bucket */
1914
1703
  objects: async (id, options) => {
1915
1704
  return rb.execute(
1916
1705
  getAdminBucketsByIdObjects,
@@ -1926,12 +1715,10 @@ function createStorageNamespace(rb) {
1926
1715
  function createWebhooksNamespace(rb) {
1927
1716
  return {
1928
1717
  configs: {
1929
- /** List all webhook configs */
1930
1718
  list: async (options) => {
1931
1719
  return rb.execute(getAdminWebhookConfigs, {}, options);
1932
1720
  },
1933
- /** Create a webhook config */
1934
- create: async (name, url, events, applicationId, secret, enabled = true, options) => {
1721
+ create: async (name, url, events, applicationId, secret, options) => {
1935
1722
  return rb.execute(
1936
1723
  postAdminWebhookConfigs,
1937
1724
  {
@@ -1943,8 +1730,7 @@ function createWebhooksNamespace(rb) {
1943
1730
  url,
1944
1731
  events,
1945
1732
  application_id: applicationId,
1946
- secret,
1947
- enabled
1733
+ secret
1948
1734
  }
1949
1735
  }
1950
1736
  }
@@ -1952,7 +1738,6 @@ function createWebhooksNamespace(rb) {
1952
1738
  options
1953
1739
  );
1954
1740
  },
1955
- /** Get a webhook config by ID */
1956
1741
  get: async (id, options) => {
1957
1742
  return rb.execute(
1958
1743
  getAdminWebhookConfigsById,
@@ -1960,24 +1745,16 @@ function createWebhooksNamespace(rb) {
1960
1745
  options
1961
1746
  );
1962
1747
  },
1963
- /** Update a webhook config */
1964
- update: async (id, updates, options) => {
1748
+ update: async (id, attributes, options) => {
1965
1749
  return rb.execute(
1966
1750
  patchAdminWebhookConfigsById,
1967
1751
  {
1968
1752
  path: { id },
1969
- body: {
1970
- data: {
1971
- id,
1972
- type: "webhook_config",
1973
- attributes: updates
1974
- }
1975
- }
1753
+ body: { data: { id, type: "webhook_config", attributes } }
1976
1754
  },
1977
1755
  options
1978
1756
  );
1979
1757
  },
1980
- /** Delete a webhook config */
1981
1758
  delete: async (id, options) => {
1982
1759
  return rb.executeDelete(
1983
1760
  deleteAdminWebhookConfigsById,
@@ -1985,17 +1762,15 @@ function createWebhooksNamespace(rb) {
1985
1762
  options
1986
1763
  );
1987
1764
  },
1988
- /** Test a webhook config */
1989
1765
  test: async (id, options) => {
1990
1766
  return rb.execute(
1991
1767
  postAdminWebhookConfigsByIdTest,
1992
- { path: { id } },
1768
+ { path: { id }, body: {} },
1993
1769
  options
1994
1770
  );
1995
1771
  }
1996
1772
  },
1997
1773
  deliveries: {
1998
- /** List webhook deliveries */
1999
1774
  list: async (options) => {
2000
1775
  return rb.execute(
2001
1776
  getAdminWebhookDeliveries,
@@ -2003,7 +1778,6 @@ function createWebhooksNamespace(rb) {
2003
1778
  options
2004
1779
  );
2005
1780
  },
2006
- /** Get a webhook delivery by ID */
2007
1781
  get: async (id, options) => {
2008
1782
  return rb.execute(
2009
1783
  getAdminWebhookDeliveriesById,
@@ -2011,11 +1785,10 @@ function createWebhooksNamespace(rb) {
2011
1785
  options
2012
1786
  );
2013
1787
  },
2014
- /** Retry a webhook delivery */
2015
1788
  retry: async (id, options) => {
2016
1789
  return rb.execute(
2017
1790
  postAdminWebhookDeliveriesByIdRetry,
2018
- { path: { id } },
1791
+ { path: { id }, body: {} },
2019
1792
  options
2020
1793
  );
2021
1794
  }
@@ -2046,28 +1819,17 @@ var GptAdmin = class extends BaseClient {
2046
1819
  var index_default = GptAdmin;
2047
1820
  // Annotate the CommonJS export names for ESM import in node:
2048
1821
  0 && (module.exports = {
2049
- AccountCreditSchema,
2050
- AccountDebitSchema,
2051
- AgentAdminCreateSchema,
2052
- ApiKeyAllocateSchema,
2053
1822
  AuthenticationError,
2054
1823
  AuthorizationError,
2055
1824
  DEFAULT_API_VERSION,
2056
- DocumentBulkDeleteSchema,
2057
- DocumentBulkReprocessSchema,
2058
1825
  GptAdmin,
2059
1826
  GptCoreError,
2060
1827
  NetworkError,
2061
1828
  NotFoundError,
2062
1829
  RateLimitError,
2063
1830
  ServerError,
2064
- StorageStatsRequestSchema,
2065
1831
  TimeoutError,
2066
1832
  ValidationError,
2067
- WebhookBulkDisableSchema,
2068
- WebhookBulkEnableSchema,
2069
- WebhookConfigCreateSchema,
2070
- WebhookDeliveryBulkRetrySchema,
2071
1833
  handleApiError
2072
1834
  });
2073
1835
  //# sourceMappingURL=index.js.map