@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.mjs CHANGED
@@ -818,8 +818,11 @@ var client = createClient(
818
818
  createConfig({ baseUrl: "http://localhost:33333" })
819
819
  );
820
820
 
821
+ // src/version.ts
822
+ var SDK_VERSION = "0.1.4";
823
+ var DEFAULT_API_VERSION = "2026-02-25";
824
+
821
825
  // src/base-client.ts
822
- var DEFAULT_API_VERSION = "2025-12-03";
823
826
  function isSecureUrl(url) {
824
827
  try {
825
828
  const parsed = new URL(url);
@@ -1420,11 +1423,6 @@ var getAdminExtractionDocuments = (options) => (options.client ?? client).get({
1420
1423
  url: "/admin/extraction/documents",
1421
1424
  ...options
1422
1425
  });
1423
- var getAdminBucketsByIdObjects = (options) => (options.client ?? client).get({
1424
- security: [{ scheme: "bearer", type: "http" }],
1425
- url: "/admin/buckets/{id}/objects",
1426
- ...options
1427
- });
1428
1426
  var postAdminDocumentsBulkDelete = (options) => (options.client ?? client).post({
1429
1427
  security: [{ scheme: "bearer", type: "http" }],
1430
1428
  url: "/admin/documents/bulk-delete",
@@ -1504,58 +1502,12 @@ var postAdminWebhookDeliveriesByIdRetry = (options) => (options.client ?? client
1504
1502
  }
1505
1503
  });
1506
1504
 
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
1505
  // src/namespaces/accounts.ts
1552
1506
  function createAccountsNamespace(rb) {
1553
1507
  return {
1554
- /** List all billing accounts */
1555
1508
  list: async (options) => {
1556
1509
  return rb.execute(getAdminAccounts, {}, options);
1557
1510
  },
1558
- /** Get a billing account by ID */
1559
1511
  get: async (id, options) => {
1560
1512
  return rb.execute(
1561
1513
  getAdminAccountsById,
@@ -1563,37 +1515,31 @@ function createAccountsNamespace(rb) {
1563
1515
  options
1564
1516
  );
1565
1517
  },
1566
- /** Credit an account */
1567
1518
  credit: async (id, amount, description, options) => {
1568
- const validated = AccountCreditSchema.parse({ amount, description });
1519
+ if (amount <= 0) {
1520
+ throw new Error("Credit amount must be positive");
1521
+ }
1569
1522
  return rb.execute(
1570
1523
  patchAdminAccountsByIdCredit,
1571
1524
  {
1572
1525
  path: { id },
1573
1526
  body: {
1574
- data: {
1575
- id,
1576
- type: "account",
1577
- attributes: validated
1578
- }
1527
+ data: { type: "account", attributes: { amount, description } }
1579
1528
  }
1580
1529
  },
1581
1530
  options
1582
1531
  );
1583
1532
  },
1584
- /** Debit an account */
1585
1533
  debit: async (id, amount, description, options) => {
1586
- const validated = AccountDebitSchema.parse({ amount, description });
1534
+ if (amount <= 0) {
1535
+ throw new Error("Debit amount must be positive");
1536
+ }
1587
1537
  return rb.execute(
1588
1538
  patchAdminAccountsByIdDebit,
1589
1539
  {
1590
1540
  path: { id },
1591
1541
  body: {
1592
- data: {
1593
- id,
1594
- type: "account",
1595
- attributes: validated
1596
- }
1542
+ data: { type: "account", attributes: { amount, description } }
1597
1543
  }
1598
1544
  },
1599
1545
  options
@@ -1605,47 +1551,35 @@ function createAccountsNamespace(rb) {
1605
1551
  // src/namespaces/apiKeys.ts
1606
1552
  function createApiKeysNamespace(rb) {
1607
1553
  return {
1608
- /** List all API keys */
1609
1554
  list: async (options) => {
1610
1555
  return rb.execute(getAdminApiKeys, {}, options);
1611
1556
  },
1612
- /** Get an API key by ID */
1613
1557
  get: async (id, options) => {
1614
1558
  return rb.execute(getAdminApiKeysById, { path: { id } }, options);
1615
1559
  },
1616
- /** Allocate credits to an API key */
1617
1560
  allocate: async (id, amount, description, options) => {
1618
1561
  return rb.execute(
1619
1562
  patchAdminApiKeysByIdAllocate,
1620
1563
  {
1621
1564
  path: { id },
1622
1565
  body: {
1623
- data: {
1624
- id,
1625
- type: "api_key",
1626
- attributes: {
1627
- amount,
1628
- description
1629
- }
1630
- }
1566
+ data: { type: "api_key", attributes: { amount, description } }
1631
1567
  }
1632
1568
  },
1633
1569
  options
1634
1570
  );
1635
1571
  },
1636
- /** Revoke an API key */
1637
1572
  revoke: async (id, options) => {
1638
1573
  return rb.execute(
1639
1574
  patchAdminApiKeysByIdRevoke,
1640
- { path: { id } },
1575
+ { path: { id }, body: {} },
1641
1576
  options
1642
1577
  );
1643
1578
  },
1644
- /** Rotate an API key */
1645
1579
  rotate: async (id, options) => {
1646
1580
  return rb.execute(
1647
1581
  patchAdminApiKeysByIdRotate,
1648
- { path: { id } },
1582
+ { path: { id }, body: {} },
1649
1583
  options
1650
1584
  );
1651
1585
  }
@@ -1655,7 +1589,6 @@ function createApiKeysNamespace(rb) {
1655
1589
  // src/namespaces/documents.ts
1656
1590
  function createDocumentsNamespace(rb) {
1657
1591
  return {
1658
- /** List extraction documents */
1659
1592
  list: async (options) => {
1660
1593
  return rb.execute(
1661
1594
  getAdminExtractionDocuments,
@@ -1663,7 +1596,6 @@ function createDocumentsNamespace(rb) {
1663
1596
  options
1664
1597
  );
1665
1598
  },
1666
- /** Get a document by ID */
1667
1599
  get: async (id, options) => {
1668
1600
  return rb.execute(
1669
1601
  getAdminExtractionDocumentsById,
@@ -1671,181 +1603,49 @@ function createDocumentsNamespace(rb) {
1671
1603
  options
1672
1604
  );
1673
1605
  },
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
- });
1606
+ bulkDelete: async (ids, options) => {
1607
+ if (ids.length === 0) {
1608
+ throw new Error("At least one document ID is required");
1609
+ }
1610
+ if (ids.length > 100) {
1611
+ throw new Error("Maximum 100 documents per bulk operation");
1612
+ }
1683
1613
  return rb.execute(
1684
1614
  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,
1779
- options
1780
- );
1781
- },
1782
- /** Approve a pending tool call */
1783
- approve: async (executionId, options) => {
1784
- return rb.rawPost(
1785
- `/isv/agent-executions/${executionId}/approve`,
1786
- void 0,
1615
+ { body: { data: { type: "bulk_delete", attributes: { ids } } } },
1787
1616
  options
1788
1617
  );
1789
1618
  },
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`,
1619
+ stats: async (options) => {
1620
+ return rb.execute(
1621
+ getAdminDocumentsStats,
1622
+ {},
1817
1623
  options
1818
1624
  );
1819
1625
  }
1820
1626
  };
1821
- addExecutionStreaming(
1822
- executions,
1823
- () => rb.getRequestHeaders()
1824
- );
1825
- return executions;
1627
+ }
1628
+
1629
+ // src/namespaces/executions.ts
1630
+ function createExecutionsNamespace(_rb) {
1631
+ return {};
1826
1632
  }
1827
1633
 
1828
1634
  // src/namespaces/storage.ts
1829
1635
  function createStorageNamespace(rb) {
1830
1636
  return {
1831
- /** Get storage statistics */
1832
1637
  stats: async (workspaceId, options) => {
1833
- const validated = StorageStatsRequestSchema.parse({
1834
- workspace_id: workspaceId
1835
- });
1638
+ const params = workspaceId ? { query: { "filter[workspace_id]": workspaceId } } : {};
1836
1639
  return rb.execute(
1837
1640
  getAdminStorageStats,
1838
- validated.workspace_id ? { query: { filter: { workspace_id: validated.workspace_id } } } : {},
1641
+ params,
1839
1642
  options
1840
1643
  );
1841
1644
  },
1842
- /** Bucket management */
1843
1645
  buckets: {
1844
- /** List all buckets */
1845
1646
  list: async (options) => {
1846
1647
  return rb.execute(getAdminBuckets, {}, options);
1847
1648
  },
1848
- /** Get a bucket by ID */
1849
1649
  get: async (id, options) => {
1850
1650
  return rb.execute(
1851
1651
  getAdminBucketsById,
@@ -1853,21 +1653,12 @@ function createStorageNamespace(rb) {
1853
1653
  options
1854
1654
  );
1855
1655
  },
1856
- /** Get bucket statistics */
1857
1656
  stats: async (id, options) => {
1858
1657
  return rb.execute(
1859
1658
  getAdminBucketsByIdStats,
1860
1659
  { path: { id } },
1861
1660
  options
1862
1661
  );
1863
- },
1864
- /** List objects in a bucket */
1865
- objects: async (id, options) => {
1866
- return rb.execute(
1867
- getAdminBucketsByIdObjects,
1868
- { path: { id } },
1869
- options
1870
- );
1871
1662
  }
1872
1663
  }
1873
1664
  };
@@ -1877,12 +1668,10 @@ function createStorageNamespace(rb) {
1877
1668
  function createWebhooksNamespace(rb) {
1878
1669
  return {
1879
1670
  configs: {
1880
- /** List all webhook configs */
1881
1671
  list: async (options) => {
1882
1672
  return rb.execute(getAdminWebhookConfigs, {}, options);
1883
1673
  },
1884
- /** Create a webhook config */
1885
- create: async (name, url, events, applicationId, secret, enabled = true, options) => {
1674
+ create: async (name, url, events, applicationId, secret, options) => {
1886
1675
  return rb.execute(
1887
1676
  postAdminWebhookConfigs,
1888
1677
  {
@@ -1894,8 +1683,7 @@ function createWebhooksNamespace(rb) {
1894
1683
  url,
1895
1684
  events,
1896
1685
  application_id: applicationId,
1897
- secret,
1898
- enabled
1686
+ secret
1899
1687
  }
1900
1688
  }
1901
1689
  }
@@ -1903,7 +1691,6 @@ function createWebhooksNamespace(rb) {
1903
1691
  options
1904
1692
  );
1905
1693
  },
1906
- /** Get a webhook config by ID */
1907
1694
  get: async (id, options) => {
1908
1695
  return rb.execute(
1909
1696
  getAdminWebhookConfigsById,
@@ -1911,24 +1698,16 @@ function createWebhooksNamespace(rb) {
1911
1698
  options
1912
1699
  );
1913
1700
  },
1914
- /** Update a webhook config */
1915
- update: async (id, updates, options) => {
1701
+ update: async (id, attributes, options) => {
1916
1702
  return rb.execute(
1917
1703
  patchAdminWebhookConfigsById,
1918
1704
  {
1919
1705
  path: { id },
1920
- body: {
1921
- data: {
1922
- id,
1923
- type: "webhook_config",
1924
- attributes: updates
1925
- }
1926
- }
1706
+ body: { data: { id, type: "webhook_config", attributes } }
1927
1707
  },
1928
1708
  options
1929
1709
  );
1930
1710
  },
1931
- /** Delete a webhook config */
1932
1711
  delete: async (id, options) => {
1933
1712
  return rb.executeDelete(
1934
1713
  deleteAdminWebhookConfigsById,
@@ -1936,17 +1715,15 @@ function createWebhooksNamespace(rb) {
1936
1715
  options
1937
1716
  );
1938
1717
  },
1939
- /** Test a webhook config */
1940
1718
  test: async (id, options) => {
1941
1719
  return rb.execute(
1942
1720
  postAdminWebhookConfigsByIdTest,
1943
- { path: { id } },
1721
+ { path: { id }, body: {} },
1944
1722
  options
1945
1723
  );
1946
1724
  }
1947
1725
  },
1948
1726
  deliveries: {
1949
- /** List webhook deliveries */
1950
1727
  list: async (options) => {
1951
1728
  return rb.execute(
1952
1729
  getAdminWebhookDeliveries,
@@ -1954,7 +1731,6 @@ function createWebhooksNamespace(rb) {
1954
1731
  options
1955
1732
  );
1956
1733
  },
1957
- /** Get a webhook delivery by ID */
1958
1734
  get: async (id, options) => {
1959
1735
  return rb.execute(
1960
1736
  getAdminWebhookDeliveriesById,
@@ -1962,11 +1738,10 @@ function createWebhooksNamespace(rb) {
1962
1738
  options
1963
1739
  );
1964
1740
  },
1965
- /** Retry a webhook delivery */
1966
1741
  retry: async (id, options) => {
1967
1742
  return rb.execute(
1968
1743
  postAdminWebhookDeliveriesByIdRetry,
1969
- { path: { id } },
1744
+ { path: { id }, body: {} },
1970
1745
  options
1971
1746
  );
1972
1747
  }
@@ -1996,28 +1771,18 @@ var GptAdmin = class extends BaseClient {
1996
1771
  // src/index.ts
1997
1772
  var index_default = GptAdmin;
1998
1773
  export {
1999
- AccountCreditSchema,
2000
- AccountDebitSchema,
2001
- AgentAdminCreateSchema,
2002
- ApiKeyAllocateSchema,
2003
1774
  AuthenticationError,
2004
1775
  AuthorizationError,
2005
1776
  DEFAULT_API_VERSION,
2006
- DocumentBulkDeleteSchema,
2007
- DocumentBulkReprocessSchema,
2008
1777
  GptAdmin,
2009
1778
  GptCoreError,
2010
1779
  NetworkError,
2011
1780
  NotFoundError,
2012
1781
  RateLimitError,
1782
+ SDK_VERSION,
2013
1783
  ServerError,
2014
- StorageStatsRequestSchema,
2015
1784
  TimeoutError,
2016
1785
  ValidationError,
2017
- WebhookBulkDisableSchema,
2018
- WebhookBulkEnableSchema,
2019
- WebhookConfigCreateSchema,
2020
- WebhookDeliveryBulkRetrySchema,
2021
1786
  index_default as default,
2022
1787
  handleApiError
2023
1788
  };