@gpt-platform/admin 0.1.3 → 0.1.5

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,18 @@ 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,
31
+ SDK_VERSION: () => SDK_VERSION,
37
32
  ServerError: () => ServerError,
38
- StorageStatsRequestSchema: () => StorageStatsRequestSchema,
39
33
  TimeoutError: () => TimeoutError,
40
34
  ValidationError: () => ValidationError,
41
- WebhookBulkDisableSchema: () => WebhookBulkDisableSchema,
42
- WebhookBulkEnableSchema: () => WebhookBulkEnableSchema,
43
- WebhookConfigCreateSchema: () => WebhookConfigCreateSchema,
44
- WebhookDeliveryBulkRetrySchema: () => WebhookDeliveryBulkRetrySchema,
45
35
  default: () => index_default,
46
36
  handleApiError: () => handleApiError
47
37
  });
@@ -867,8 +857,11 @@ var client = createClient(
867
857
  createConfig({ baseUrl: "http://localhost:33333" })
868
858
  );
869
859
 
860
+ // src/version.ts
861
+ var SDK_VERSION = "0.1.4";
862
+ var DEFAULT_API_VERSION = "2026-02-25";
863
+
870
864
  // src/base-client.ts
871
- var DEFAULT_API_VERSION = "2025-12-03";
872
865
  function isSecureUrl(url) {
873
866
  try {
874
867
  const parsed = new URL(url);
@@ -1469,11 +1462,6 @@ var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
1469
1462
  url: "/admin/extraction/documents",
1470
1463
  ...options
1471
1464
  });
1472
- var getAdminBucketsByIdObjects = (options) => (options.client ?? client).get({
1473
- security: [{ scheme: "bearer", type: "http" }],
1474
- url: "/admin/buckets/{id}/objects",
1475
- ...options
1476
- });
1477
1465
  var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post({
1478
1466
  security: [{ scheme: "bearer", type: "http" }],
1479
1467
  url: "/admin/documents/bulk-delete",
@@ -1553,58 +1541,12 @@ var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client
1553
1541
  }
1554
1542
  });
1555
1543
 
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
1544
  // src/namespaces/accounts.ts
1601
1545
  function createAccountsNamespace(rb) {
1602
1546
  return {
1603
- /** List all billing accounts */
1604
1547
  list: async (options) => {
1605
1548
  return rb.execute(getAdminAccounts, {}, options);
1606
1549
  },
1607
- /** Get a billing account by ID */
1608
1550
  get: async (id, options) => {
1609
1551
  return rb.execute(
1610
1552
  getAdminAccountsById,
@@ -1612,37 +1554,31 @@ function createAccountsNamespace(rb) {
1612
1554
  options
1613
1555
  );
1614
1556
  },
1615
- /** Credit an account */
1616
1557
  credit: async (id, amount, description, options) => {
1617
- const validated = AccountCreditSchema.parse({ amount, description });
1558
+ if (amount <= 0) {
1559
+ throw new Error("Credit amount must be positive");
1560
+ }
1618
1561
  return rb.execute(
1619
1562
  patchAdminAccountsByIdCredit,
1620
1563
  {
1621
1564
  path: { id },
1622
1565
  body: {
1623
- data: {
1624
- id,
1625
- type: "account",
1626
- attributes: validated
1627
- }
1566
+ data: { type: "account", attributes: { amount, description } }
1628
1567
  }
1629
1568
  },
1630
1569
  options
1631
1570
  );
1632
1571
  },
1633
- /** Debit an account */
1634
1572
  debit: async (id, amount, description, options) => {
1635
- const validated = AccountDebitSchema.parse({ amount, description });
1573
+ if (amount <= 0) {
1574
+ throw new Error("Debit amount must be positive");
1575
+ }
1636
1576
  return rb.execute(
1637
1577
  patchAdminAccountsByIdDebit,
1638
1578
  {
1639
1579
  path: { id },
1640
1580
  body: {
1641
- data: {
1642
- id,
1643
- type: "account",
1644
- attributes: validated
1645
- }
1581
+ data: { type: "account", attributes: { amount, description } }
1646
1582
  }
1647
1583
  },
1648
1584
  options
@@ -1654,47 +1590,35 @@ function createAccountsNamespace(rb) {
1654
1590
  // src/namespaces/apiKeys.ts
1655
1591
  function createApiKeysNamespace(rb) {
1656
1592
  return {
1657
- /** List all API keys */
1658
1593
  list: async (options) => {
1659
1594
  return rb.execute(getAdminApiKeys, {}, options);
1660
1595
  },
1661
- /** Get an API key by ID */
1662
1596
  get: async (id, options) => {
1663
1597
  return rb.execute(getAdminApiKeysById, { path: { id } }, options);
1664
1598
  },
1665
- /** Allocate credits to an API key */
1666
1599
  allocate: async (id, amount, description, options) => {
1667
1600
  return rb.execute(
1668
1601
  patchAdminApiKeysByIdAllocate,
1669
1602
  {
1670
1603
  path: { id },
1671
1604
  body: {
1672
- data: {
1673
- id,
1674
- type: "api_key",
1675
- attributes: {
1676
- amount,
1677
- description
1678
- }
1679
- }
1605
+ data: { type: "api_key", attributes: { amount, description } }
1680
1606
  }
1681
1607
  },
1682
1608
  options
1683
1609
  );
1684
1610
  },
1685
- /** Revoke an API key */
1686
1611
  revoke: async (id, options) => {
1687
1612
  return rb.execute(
1688
1613
  patchAdminApiKeysByIdRevoke,
1689
- { path: { id } },
1614
+ { path: { id }, body: {} },
1690
1615
  options
1691
1616
  );
1692
1617
  },
1693
- /** Rotate an API key */
1694
1618
  rotate: async (id, options) => {
1695
1619
  return rb.execute(
1696
1620
  patchAdminApiKeysByIdRotate,
1697
- { path: { id } },
1621
+ { path: { id }, body: {} },
1698
1622
  options
1699
1623
  );
1700
1624
  }
@@ -1704,7 +1628,6 @@ function createApiKeysNamespace(rb) {
1704
1628
  // src/namespaces/documents.ts
1705
1629
  function createDocumentsNamespace(rb) {
1706
1630
  return {
1707
- /** List extraction documents */
1708
1631
  list: async (options) => {
1709
1632
  return rb.execute(
1710
1633
  getAdminExtractionDocuments,
@@ -1712,7 +1635,6 @@ function createDocumentsNamespace(rb) {
1712
1635
  options
1713
1636
  );
1714
1637
  },
1715
- /** Get a document by ID */
1716
1638
  get: async (id, options) => {
1717
1639
  return rb.execute(
1718
1640
  getAdminExtractionDocumentsById,
@@ -1720,181 +1642,49 @@ function createDocumentsNamespace(rb) {
1720
1642
  options
1721
1643
  );
1722
1644
  },
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
- });
1645
+ bulkDelete: async (ids, options) => {
1646
+ if (ids.length === 0) {
1647
+ throw new Error("At least one document ID is required");
1648
+ }
1649
+ if (ids.length > 100) {
1650
+ throw new Error("Maximum 100 documents per bulk operation");
1651
+ }
1732
1652
  return rb.execute(
1733
1653
  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,
1828
- options
1829
- );
1830
- },
1831
- /** Approve a pending tool call */
1832
- approve: async (executionId, options) => {
1833
- return rb.rawPost(
1834
- `/isv/agent-executions/${executionId}/approve`,
1835
- void 0,
1654
+ { body: { data: { type: "bulk_delete", attributes: { ids } } } },
1836
1655
  options
1837
1656
  );
1838
1657
  },
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`,
1658
+ stats: async (options) => {
1659
+ return rb.execute(
1660
+ getAdminDocumentsStats,
1661
+ {},
1866
1662
  options
1867
1663
  );
1868
1664
  }
1869
1665
  };
1870
- addExecutionStreaming(
1871
- executions,
1872
- () => rb.getRequestHeaders()
1873
- );
1874
- return executions;
1666
+ }
1667
+
1668
+ // src/namespaces/executions.ts
1669
+ function createExecutionsNamespace(_rb) {
1670
+ return {};
1875
1671
  }
1876
1672
 
1877
1673
  // src/namespaces/storage.ts
1878
1674
  function createStorageNamespace(rb) {
1879
1675
  return {
1880
- /** Get storage statistics */
1881
1676
  stats: async (workspaceId, options) => {
1882
- const validated = StorageStatsRequestSchema.parse({
1883
- workspace_id: workspaceId
1884
- });
1677
+ const params = workspaceId ? { query: { "filter[workspace_id]": workspaceId } } : {};
1885
1678
  return rb.execute(
1886
1679
  getAdminStorageStats,
1887
- validated.workspace_id ? { query: { filter: { workspace_id: validated.workspace_id } } } : {},
1680
+ params,
1888
1681
  options
1889
1682
  );
1890
1683
  },
1891
- /** Bucket management */
1892
1684
  buckets: {
1893
- /** List all buckets */
1894
1685
  list: async (options) => {
1895
1686
  return rb.execute(getAdminBuckets, {}, options);
1896
1687
  },
1897
- /** Get a bucket by ID */
1898
1688
  get: async (id, options) => {
1899
1689
  return rb.execute(
1900
1690
  getAdminBucketsById,
@@ -1902,21 +1692,12 @@ function createStorageNamespace(rb) {
1902
1692
  options
1903
1693
  );
1904
1694
  },
1905
- /** Get bucket statistics */
1906
1695
  stats: async (id, options) => {
1907
1696
  return rb.execute(
1908
1697
  getAdminBucketsByIdStats,
1909
1698
  { path: { id } },
1910
1699
  options
1911
1700
  );
1912
- },
1913
- /** List objects in a bucket */
1914
- objects: async (id, options) => {
1915
- return rb.execute(
1916
- getAdminBucketsByIdObjects,
1917
- { path: { id } },
1918
- options
1919
- );
1920
1701
  }
1921
1702
  }
1922
1703
  };
@@ -1926,12 +1707,10 @@ function createStorageNamespace(rb) {
1926
1707
  function createWebhooksNamespace(rb) {
1927
1708
  return {
1928
1709
  configs: {
1929
- /** List all webhook configs */
1930
1710
  list: async (options) => {
1931
1711
  return rb.execute(getAdminWebhookConfigs, {}, options);
1932
1712
  },
1933
- /** Create a webhook config */
1934
- create: async (name, url, events, applicationId, secret, enabled = true, options) => {
1713
+ create: async (name, url, events, applicationId, secret, options) => {
1935
1714
  return rb.execute(
1936
1715
  postAdminWebhookConfigs,
1937
1716
  {
@@ -1943,8 +1722,7 @@ function createWebhooksNamespace(rb) {
1943
1722
  url,
1944
1723
  events,
1945
1724
  application_id: applicationId,
1946
- secret,
1947
- enabled
1725
+ secret
1948
1726
  }
1949
1727
  }
1950
1728
  }
@@ -1952,7 +1730,6 @@ function createWebhooksNamespace(rb) {
1952
1730
  options
1953
1731
  );
1954
1732
  },
1955
- /** Get a webhook config by ID */
1956
1733
  get: async (id, options) => {
1957
1734
  return rb.execute(
1958
1735
  getAdminWebhookConfigsById,
@@ -1960,24 +1737,16 @@ function createWebhooksNamespace(rb) {
1960
1737
  options
1961
1738
  );
1962
1739
  },
1963
- /** Update a webhook config */
1964
- update: async (id, updates, options) => {
1740
+ update: async (id, attributes, options) => {
1965
1741
  return rb.execute(
1966
1742
  patchAdminWebhookConfigsById,
1967
1743
  {
1968
1744
  path: { id },
1969
- body: {
1970
- data: {
1971
- id,
1972
- type: "webhook_config",
1973
- attributes: updates
1974
- }
1975
- }
1745
+ body: { data: { id, type: "webhook_config", attributes } }
1976
1746
  },
1977
1747
  options
1978
1748
  );
1979
1749
  },
1980
- /** Delete a webhook config */
1981
1750
  delete: async (id, options) => {
1982
1751
  return rb.executeDelete(
1983
1752
  deleteAdminWebhookConfigsById,
@@ -1985,17 +1754,15 @@ function createWebhooksNamespace(rb) {
1985
1754
  options
1986
1755
  );
1987
1756
  },
1988
- /** Test a webhook config */
1989
1757
  test: async (id, options) => {
1990
1758
  return rb.execute(
1991
1759
  postAdminWebhookConfigsByIdTest,
1992
- { path: { id } },
1760
+ { path: { id }, body: {} },
1993
1761
  options
1994
1762
  );
1995
1763
  }
1996
1764
  },
1997
1765
  deliveries: {
1998
- /** List webhook deliveries */
1999
1766
  list: async (options) => {
2000
1767
  return rb.execute(
2001
1768
  getAdminWebhookDeliveries,
@@ -2003,7 +1770,6 @@ function createWebhooksNamespace(rb) {
2003
1770
  options
2004
1771
  );
2005
1772
  },
2006
- /** Get a webhook delivery by ID */
2007
1773
  get: async (id, options) => {
2008
1774
  return rb.execute(
2009
1775
  getAdminWebhookDeliveriesById,
@@ -2011,11 +1777,10 @@ function createWebhooksNamespace(rb) {
2011
1777
  options
2012
1778
  );
2013
1779
  },
2014
- /** Retry a webhook delivery */
2015
1780
  retry: async (id, options) => {
2016
1781
  return rb.execute(
2017
1782
  postAdminWebhookDeliveriesByIdRetry,
2018
- { path: { id } },
1783
+ { path: { id }, body: {} },
2019
1784
  options
2020
1785
  );
2021
1786
  }
@@ -2046,28 +1811,18 @@ var GptAdmin = class extends BaseClient {
2046
1811
  var index_default = GptAdmin;
2047
1812
  // Annotate the CommonJS export names for ESM import in node:
2048
1813
  0 && (module.exports = {
2049
- AccountCreditSchema,
2050
- AccountDebitSchema,
2051
- AgentAdminCreateSchema,
2052
- ApiKeyAllocateSchema,
2053
1814
  AuthenticationError,
2054
1815
  AuthorizationError,
2055
1816
  DEFAULT_API_VERSION,
2056
- DocumentBulkDeleteSchema,
2057
- DocumentBulkReprocessSchema,
2058
1817
  GptAdmin,
2059
1818
  GptCoreError,
2060
1819
  NetworkError,
2061
1820
  NotFoundError,
2062
1821
  RateLimitError,
1822
+ SDK_VERSION,
2063
1823
  ServerError,
2064
- StorageStatsRequestSchema,
2065
1824
  TimeoutError,
2066
1825
  ValidationError,
2067
- WebhookBulkDisableSchema,
2068
- WebhookBulkEnableSchema,
2069
- WebhookConfigCreateSchema,
2070
- WebhookDeliveryBulkRetrySchema,
2071
1826
  handleApiError
2072
1827
  });
2073
1828
  //# sourceMappingURL=index.js.map