@klex/agent-admin-api 0.8.2 → 0.10.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.
Files changed (3) hide show
  1. package/README.md +36 -0
  2. package/dist/index.d.ts +332 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -66,4 +66,40 @@ The Admin API contract includes the dedicated God Messages session:
66
66
  - `GET /v1/god-messages/messages` returns cursor-paginated session history.
67
67
  - `POST /v1/god-messages/reset` replaces a resettable session.
68
68
 
69
+ ## Session history
70
+
71
+ The agent persists the transcript of every chat session instance (default,
72
+ god, and child) to local storage. These routes expose it read-only:
73
+
74
+ - `GET /v1/sessions` lists instances, newest first. Filter with `kind`
75
+ (`default`, `god`, `child`), `live`, and `parentInstanceId`; page with
76
+ `limit` and the opaque `cursor` returned as `nextCursor`. To find the
77
+ current main session, call `GET /v1/sessions?kind=default&live=true&limit=1`.
78
+ A session is persisted only after its first message, so this list can be
79
+ empty right after a restart.
80
+ - `GET /v1/sessions/{instanceId}` returns one instance's metadata, including
81
+ `live`, `endReason`, `messageCount`, and `trimmedMessageCount`.
82
+ - `GET /v1/sessions/{instanceId}/messages` returns messages in chronological
83
+ order. Without a cursor it returns the newest `limit` messages. Pass the
84
+ numeric `nextCursor` as `cursor` to load the previous, older page.
85
+
86
+ Messages use the stored AI SDK `UIMessage` shape: `tool-${name}` parts carry
87
+ full `input`, `output`, and `errorText`, and `data-${name}` parts carry their
88
+ `data`. Unlike God Messages history, nothing is truncated. Provider metadata
89
+ (`providerMetadata`, `callProviderMetadata`, `resultProviderMetadata`, such
90
+ as encrypted reasoning) is omitted unless `includeProviderMetadata=true`.
91
+
92
+ Each `ChatSession` gets its own `instanceId`. The default session reuses
93
+ `sessionId = "default"` across replacements, so query by `instanceId`. The
94
+ local store has a size cap. When the cap is reached, the oldest ended sessions
95
+ are deleted first. After that, the oldest messages of live sessions are
96
+ trimmed, and `trimmedMessageCount` reports how many were removed. Inline
97
+ data is redacted everywhere, including inside tool outputs: the payload of
98
+ every `data:` URL in any encoding, also inside longer strings, the `data`
99
+ field of image, audio, and media blocks, and embedded resource `blob`s.
100
+ Objects nested deeper than 64 levels are replaced by a placeholder.
101
+
102
+ Unknown instances return `404` with code `session_not_found`. Malformed list
103
+ cursors return `400` with code `invalid_cursor`.
104
+
69
105
  Install `hono` and `@hono/zod-openapi` as peer dependencies.
package/dist/index.d.ts CHANGED
@@ -15,15 +15,6 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
15
15
  } & {
16
16
  "/v1/cloud/status": {
17
17
  $get: {
18
- output: {
19
- error: string;
20
- code: string;
21
- remediation?: string | undefined;
22
- };
23
- outputFormat: "json";
24
- status: 500;
25
- input: {};
26
- } | {
27
18
  output: {
28
19
  cloudEnabled: boolean;
29
20
  enrolled: boolean;
@@ -35,6 +26,15 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
35
26
  outputFormat: "json";
36
27
  status: 200;
37
28
  input: {};
29
+ } | {
30
+ output: {
31
+ error: string;
32
+ code: string;
33
+ remediation?: string | undefined;
34
+ };
35
+ outputFormat: "json";
36
+ status: 500;
37
+ input: {};
38
38
  };
39
39
  };
40
40
  } & {
@@ -1167,10 +1167,12 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1167
1167
  "/v1/god-messages": {
1168
1168
  $post: {
1169
1169
  output: {
1170
- sessionId: string;
1170
+ error: string;
1171
+ code: string;
1172
+ remediation?: string | undefined;
1171
1173
  };
1172
1174
  outputFormat: "json";
1173
- status: 202;
1175
+ status: 400;
1174
1176
  input: {
1175
1177
  json: {
1176
1178
  content: ({
@@ -1210,7 +1212,7 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1210
1212
  remediation?: string | undefined;
1211
1213
  };
1212
1214
  outputFormat: "json";
1213
- status: 400;
1215
+ status: 409;
1214
1216
  input: {
1215
1217
  json: {
1216
1218
  content: ({
@@ -1250,7 +1252,7 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1250
1252
  remediation?: string | undefined;
1251
1253
  };
1252
1254
  outputFormat: "json";
1253
- status: 409;
1255
+ status: 500;
1254
1256
  input: {
1255
1257
  json: {
1256
1258
  content: ({
@@ -1290,7 +1292,7 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1290
1292
  remediation?: string | undefined;
1291
1293
  };
1292
1294
  outputFormat: "json";
1293
- status: 500;
1295
+ status: 503;
1294
1296
  input: {
1295
1297
  json: {
1296
1298
  content: ({
@@ -1325,12 +1327,10 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1325
1327
  };
1326
1328
  } | {
1327
1329
  output: {
1328
- error: string;
1329
- code: string;
1330
- remediation?: string | undefined;
1330
+ sessionId: string;
1331
1331
  };
1332
1332
  outputFormat: "json";
1333
- status: 503;
1333
+ status: 202;
1334
1334
  input: {
1335
1335
  json: {
1336
1336
  content: ({
@@ -1523,6 +1523,221 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1523
1523
  input: {};
1524
1524
  };
1525
1525
  };
1526
+ } & {
1527
+ "/v1/sessions": {
1528
+ $get: {
1529
+ output: {
1530
+ error: string;
1531
+ code: string;
1532
+ remediation?: string | undefined;
1533
+ };
1534
+ outputFormat: "json";
1535
+ status: 400;
1536
+ input: {
1537
+ query: {
1538
+ kind?: "child" | "default" | "god" | undefined;
1539
+ parentInstanceId?: string | undefined;
1540
+ live?: "false" | "true" | undefined;
1541
+ limit?: unknown;
1542
+ cursor?: string | undefined;
1543
+ };
1544
+ };
1545
+ } | {
1546
+ output: {
1547
+ error: string;
1548
+ code: string;
1549
+ remediation?: string | undefined;
1550
+ };
1551
+ outputFormat: "json";
1552
+ status: 500;
1553
+ input: {
1554
+ query: {
1555
+ kind?: "child" | "default" | "god" | undefined;
1556
+ parentInstanceId?: string | undefined;
1557
+ live?: "false" | "true" | undefined;
1558
+ limit?: unknown;
1559
+ cursor?: string | undefined;
1560
+ };
1561
+ };
1562
+ } | {
1563
+ output: {
1564
+ sessions: {
1565
+ instanceId: string;
1566
+ sessionId: string;
1567
+ kind: "child" | "default" | "god";
1568
+ name: string;
1569
+ parentInstanceId: string | null;
1570
+ extensionIdentifier: string | null;
1571
+ createdAt: string;
1572
+ updatedAt: string;
1573
+ endedAt: string | null;
1574
+ endReason: string | null;
1575
+ live: boolean;
1576
+ messageCount: number;
1577
+ trimmedMessageCount: number;
1578
+ byteSize: number;
1579
+ }[];
1580
+ nextCursor: string | null;
1581
+ hasMore: boolean;
1582
+ };
1583
+ outputFormat: "json";
1584
+ status: 200;
1585
+ input: {
1586
+ query: {
1587
+ kind?: "child" | "default" | "god" | undefined;
1588
+ parentInstanceId?: string | undefined;
1589
+ live?: "false" | "true" | undefined;
1590
+ limit?: unknown;
1591
+ cursor?: string | undefined;
1592
+ };
1593
+ };
1594
+ };
1595
+ };
1596
+ } & {
1597
+ "/v1/sessions/:instanceId": {
1598
+ $get: {
1599
+ output: {
1600
+ error: string;
1601
+ code: string;
1602
+ remediation?: string | undefined;
1603
+ };
1604
+ outputFormat: "json";
1605
+ status: 404;
1606
+ input: {
1607
+ param: {
1608
+ instanceId: string;
1609
+ };
1610
+ };
1611
+ } | {
1612
+ output: {
1613
+ error: string;
1614
+ code: string;
1615
+ remediation?: string | undefined;
1616
+ };
1617
+ outputFormat: "json";
1618
+ status: 500;
1619
+ input: {
1620
+ param: {
1621
+ instanceId: string;
1622
+ };
1623
+ };
1624
+ } | {
1625
+ output: {
1626
+ instanceId: string;
1627
+ sessionId: string;
1628
+ kind: "child" | "default" | "god";
1629
+ name: string;
1630
+ parentInstanceId: string | null;
1631
+ extensionIdentifier: string | null;
1632
+ createdAt: string;
1633
+ updatedAt: string;
1634
+ endedAt: string | null;
1635
+ endReason: string | null;
1636
+ live: boolean;
1637
+ messageCount: number;
1638
+ trimmedMessageCount: number;
1639
+ byteSize: number;
1640
+ };
1641
+ outputFormat: "json";
1642
+ status: 200;
1643
+ input: {
1644
+ param: {
1645
+ instanceId: string;
1646
+ };
1647
+ };
1648
+ };
1649
+ };
1650
+ } & {
1651
+ "/v1/sessions/:instanceId/messages": {
1652
+ $get: {
1653
+ output: {
1654
+ error: string;
1655
+ code: string;
1656
+ remediation?: string | undefined;
1657
+ };
1658
+ outputFormat: "json";
1659
+ status: 400;
1660
+ input: {
1661
+ param: {
1662
+ instanceId: string;
1663
+ };
1664
+ } & {
1665
+ query: {
1666
+ limit?: unknown;
1667
+ cursor?: unknown;
1668
+ includeProviderMetadata?: "false" | "true" | undefined;
1669
+ };
1670
+ };
1671
+ } | {
1672
+ output: {
1673
+ error: string;
1674
+ code: string;
1675
+ remediation?: string | undefined;
1676
+ };
1677
+ outputFormat: "json";
1678
+ status: 404;
1679
+ input: {
1680
+ param: {
1681
+ instanceId: string;
1682
+ };
1683
+ } & {
1684
+ query: {
1685
+ limit?: unknown;
1686
+ cursor?: unknown;
1687
+ includeProviderMetadata?: "false" | "true" | undefined;
1688
+ };
1689
+ };
1690
+ } | {
1691
+ output: {
1692
+ error: string;
1693
+ code: string;
1694
+ remediation?: string | undefined;
1695
+ };
1696
+ outputFormat: "json";
1697
+ status: 500;
1698
+ input: {
1699
+ param: {
1700
+ instanceId: string;
1701
+ };
1702
+ } & {
1703
+ query: {
1704
+ limit?: unknown;
1705
+ cursor?: unknown;
1706
+ includeProviderMetadata?: "false" | "true" | undefined;
1707
+ };
1708
+ };
1709
+ } | {
1710
+ output: {
1711
+ messages: {
1712
+ id: string;
1713
+ role: "assistant" | "system" | "user";
1714
+ metadata?: import("hono/utils/types").JSONValue | undefined;
1715
+ parts: {
1716
+ [x: string]: import("hono/utils/types").JSONValue;
1717
+ type: string;
1718
+ }[];
1719
+ seq: number;
1720
+ persistedAt: string;
1721
+ }[];
1722
+ nextCursor: number | null;
1723
+ hasMore: boolean;
1724
+ trimmedMessageCount: number;
1725
+ };
1726
+ outputFormat: "json";
1727
+ status: 200;
1728
+ input: {
1729
+ param: {
1730
+ instanceId: string;
1731
+ };
1732
+ } & {
1733
+ query: {
1734
+ limit?: unknown;
1735
+ cursor?: unknown;
1736
+ includeProviderMetadata?: "false" | "true" | undefined;
1737
+ };
1738
+ };
1739
+ };
1740
+ };
1526
1741
  } & {
1527
1742
  "/v1/usage": {
1528
1743
  $get: {
@@ -1599,6 +1814,105 @@ export type AdminApi = import("hono/hono-base").HonoBase<any, {
1599
1814
  };
1600
1815
  };
1601
1816
  };
1817
+ } & {
1818
+ "/v1/skills": {
1819
+ $get: {
1820
+ output: {
1821
+ error: string;
1822
+ code: string;
1823
+ remediation?: string | undefined;
1824
+ };
1825
+ outputFormat: "json";
1826
+ status: 500;
1827
+ input: {};
1828
+ } | {
1829
+ output: {
1830
+ error: string;
1831
+ code: string;
1832
+ remediation?: string | undefined;
1833
+ };
1834
+ outputFormat: "json";
1835
+ status: 503;
1836
+ input: {};
1837
+ } | {
1838
+ output: {
1839
+ skills: {
1840
+ name: string;
1841
+ description: string;
1842
+ origin: "learned";
1843
+ createdAt?: string | undefined;
1844
+ updatedAt?: string | undefined;
1845
+ lastReadAt?: string | null | undefined;
1846
+ readCount?: number | undefined;
1847
+ }[];
1848
+ };
1849
+ outputFormat: "json";
1850
+ status: 200;
1851
+ input: {};
1852
+ };
1853
+ };
1854
+ } & {
1855
+ "/v1/skills/:name": {
1856
+ $get: {
1857
+ output: {
1858
+ error: string;
1859
+ code: string;
1860
+ remediation?: string | undefined;
1861
+ };
1862
+ outputFormat: "json";
1863
+ status: 404;
1864
+ input: {
1865
+ param: {
1866
+ name: string;
1867
+ };
1868
+ };
1869
+ } | {
1870
+ output: {
1871
+ error: string;
1872
+ code: string;
1873
+ remediation?: string | undefined;
1874
+ };
1875
+ outputFormat: "json";
1876
+ status: 500;
1877
+ input: {
1878
+ param: {
1879
+ name: string;
1880
+ };
1881
+ };
1882
+ } | {
1883
+ output: {
1884
+ error: string;
1885
+ code: string;
1886
+ remediation?: string | undefined;
1887
+ };
1888
+ outputFormat: "json";
1889
+ status: 503;
1890
+ input: {
1891
+ param: {
1892
+ name: string;
1893
+ };
1894
+ };
1895
+ } | {
1896
+ output: {
1897
+ name: string;
1898
+ description: string;
1899
+ origin: "learned";
1900
+ createdAt?: string | undefined;
1901
+ updatedAt?: string | undefined;
1902
+ lastReadAt?: string | null | undefined;
1903
+ readCount?: number | undefined;
1904
+ body: string;
1905
+ sourceEpisodes?: string[] | undefined;
1906
+ };
1907
+ outputFormat: "json";
1908
+ status: 200;
1909
+ input: {
1910
+ param: {
1911
+ name: string;
1912
+ };
1913
+ };
1914
+ };
1915
+ };
1602
1916
  } & {
1603
1917
  "/v1/provider-types": {
1604
1918
  $get: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klex/agent-admin-api",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Shared types for the Klex Bot Admin API",