@dudousxd/nestjs-agent-store-drizzle 0.9.0 → 0.10.1

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.d.cts CHANGED
@@ -1,13 +1,14 @@
1
1
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
2
2
  import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
3
- import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, ToolKind, ToolCallStatus, UsagePurpose, AgentStore, ThreadTurnReader, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, RecordUsageInput, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, GovernancePageQuery, ToolCallWhere, GovernancePage, ThreadWhere, RunWhere, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, ModelPriceInput, CurrentModelPrice } from '@dudousxd/nestjs-agent-core';
3
+ import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, ToolKind, ToolCallStatus, UsagePurpose, AgentStore, ThreadTurnReader, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, RecordUsageInput, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, GovernancePageQuery, ToolCallWhere, GovernancePage, ThreadWhere, RunWhere, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice } from '@dudousxd/nestjs-agent-core';
4
4
  export { ThreadTurnPage, ThreadTurnQuery } from '@dudousxd/nestjs-agent-core';
5
- import { TablesRelationalConfig } from 'drizzle-orm';
6
- import { Type, DynamicModule } from '@nestjs/common';
5
+ import { TablesRelationalConfig, SQL } from 'drizzle-orm';
6
+ import { OnModuleInit, OnModuleDestroy, Type, DynamicModule } from '@nestjs/common';
7
7
 
8
8
  /**
9
9
  * Drizzle schema mirroring the MikroORM agent entities (same logical columns/relations):
10
- * threads, messages, tool calls, token usage, model pricing and run outcomes. Targets the SQLite core so the
10
+ * threads, messages, tool calls, token usage, model pricing, run outcomes and the RAG ingestion
11
+ * ledger. Targets the SQLite core so the
11
12
  * db-test runs on an in-memory better-sqlite3; timestamps are stored as integer epoch-ms columns
12
13
  * (`{ mode: 'timestamp_ms' }`) which Drizzle round-trips to/from JS `Date`, and the model-facing
13
14
  * message extras (tool calls/results, follow-ups, usage) live in JSON `text` columns.
@@ -1334,7 +1335,498 @@ declare const agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1334
1335
  };
1335
1336
  dialect: "sqlite";
1336
1337
  }>;
1337
- /** The six agent tables as one schema object, ready for `drizzle(client, { schema })`. */
1338
+ /**
1339
+ * One thing the assistant believes, held at one scope — the row behind a core `MemoryRecord`.
1340
+ *
1341
+ * `scope` is an OPAQUE token the host mints (`actor:…`, `tenant:…`, whatever axis a deployment scopes
1342
+ * by), which is what lets this package own the table at all: there is nothing here for a host to
1343
+ * relate its own entities to, so owning the rows takes nothing away from it.
1344
+ *
1345
+ * The origin is flattened into columns rather than stored as JSON so a host's console can filter and
1346
+ * sweep on it. `originThreadId` is deliberately NOT a foreign key — unlike every other table here,
1347
+ * which cascades off `agent_thread`: a memory outlives the conversation it came from, and a cascade
1348
+ * would delete beliefs when a transcript aged out.
1349
+ *
1350
+ * One unique index, on (`scope`, `key`) — what `write` upserts against, and what makes a duplicate
1351
+ * answer to one question impossible rather than merely unlikely. It doubles as the index every read
1352
+ * uses: `list` filters `scope in (…)`, which is that index's leading column, so a second index on
1353
+ * `scope` alone would be maintained on every write and read by nothing.
1354
+ */
1355
+ declare const agentMemory: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1356
+ name: "agent_memory";
1357
+ schema: undefined;
1358
+ columns: {
1359
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
1360
+ name: "id";
1361
+ tableName: "agent_memory";
1362
+ dataType: "string";
1363
+ columnType: "SQLiteText";
1364
+ data: string;
1365
+ driverParam: string;
1366
+ notNull: true;
1367
+ hasDefault: false;
1368
+ isPrimaryKey: true;
1369
+ isAutoincrement: false;
1370
+ hasRuntimeDefault: false;
1371
+ enumValues: [string, ...string[]];
1372
+ baseColumn: never;
1373
+ identity: undefined;
1374
+ generated: undefined;
1375
+ }, {}, {
1376
+ length: number | undefined;
1377
+ }>;
1378
+ scope: drizzle_orm_sqlite_core.SQLiteColumn<{
1379
+ name: "scope";
1380
+ tableName: "agent_memory";
1381
+ dataType: "string";
1382
+ columnType: "SQLiteText";
1383
+ data: string;
1384
+ driverParam: string;
1385
+ notNull: true;
1386
+ hasDefault: false;
1387
+ isPrimaryKey: false;
1388
+ isAutoincrement: false;
1389
+ hasRuntimeDefault: false;
1390
+ enumValues: [string, ...string[]];
1391
+ baseColumn: never;
1392
+ identity: undefined;
1393
+ generated: undefined;
1394
+ }, {}, {
1395
+ length: number | undefined;
1396
+ }>;
1397
+ key: drizzle_orm_sqlite_core.SQLiteColumn<{
1398
+ name: "key";
1399
+ tableName: "agent_memory";
1400
+ dataType: "string";
1401
+ columnType: "SQLiteText";
1402
+ data: string;
1403
+ driverParam: string;
1404
+ notNull: true;
1405
+ hasDefault: false;
1406
+ isPrimaryKey: false;
1407
+ isAutoincrement: false;
1408
+ hasRuntimeDefault: false;
1409
+ enumValues: [string, ...string[]];
1410
+ baseColumn: never;
1411
+ identity: undefined;
1412
+ generated: undefined;
1413
+ }, {}, {
1414
+ length: number | undefined;
1415
+ }>;
1416
+ text: drizzle_orm_sqlite_core.SQLiteColumn<{
1417
+ name: "text";
1418
+ tableName: "agent_memory";
1419
+ dataType: "string";
1420
+ columnType: "SQLiteText";
1421
+ data: string;
1422
+ driverParam: string;
1423
+ notNull: true;
1424
+ hasDefault: false;
1425
+ isPrimaryKey: false;
1426
+ isAutoincrement: false;
1427
+ hasRuntimeDefault: false;
1428
+ enumValues: [string, ...string[]];
1429
+ baseColumn: never;
1430
+ identity: undefined;
1431
+ generated: undefined;
1432
+ }, {}, {
1433
+ length: number | undefined;
1434
+ }>;
1435
+ originAuthor: drizzle_orm_sqlite_core.SQLiteColumn<{
1436
+ name: "origin_author";
1437
+ tableName: "agent_memory";
1438
+ dataType: "string";
1439
+ columnType: "SQLiteText";
1440
+ data: "agent" | "human";
1441
+ driverParam: string;
1442
+ notNull: true;
1443
+ hasDefault: false;
1444
+ isPrimaryKey: false;
1445
+ isAutoincrement: false;
1446
+ hasRuntimeDefault: false;
1447
+ enumValues: [string, ...string[]];
1448
+ baseColumn: never;
1449
+ identity: undefined;
1450
+ generated: undefined;
1451
+ }, {}, {
1452
+ length: number | undefined;
1453
+ $type: "agent" | "human";
1454
+ }>;
1455
+ originThreadId: drizzle_orm_sqlite_core.SQLiteColumn<{
1456
+ name: "origin_thread_id";
1457
+ tableName: "agent_memory";
1458
+ dataType: "string";
1459
+ columnType: "SQLiteText";
1460
+ data: string;
1461
+ driverParam: string;
1462
+ notNull: false;
1463
+ hasDefault: false;
1464
+ isPrimaryKey: false;
1465
+ isAutoincrement: false;
1466
+ hasRuntimeDefault: false;
1467
+ enumValues: [string, ...string[]];
1468
+ baseColumn: never;
1469
+ identity: undefined;
1470
+ generated: undefined;
1471
+ }, {}, {
1472
+ length: number | undefined;
1473
+ }>;
1474
+ originRunId: drizzle_orm_sqlite_core.SQLiteColumn<{
1475
+ name: "origin_run_id";
1476
+ tableName: "agent_memory";
1477
+ dataType: "string";
1478
+ columnType: "SQLiteText";
1479
+ data: string;
1480
+ driverParam: string;
1481
+ notNull: false;
1482
+ hasDefault: false;
1483
+ isPrimaryKey: false;
1484
+ isAutoincrement: false;
1485
+ hasRuntimeDefault: false;
1486
+ enumValues: [string, ...string[]];
1487
+ baseColumn: never;
1488
+ identity: undefined;
1489
+ generated: undefined;
1490
+ }, {}, {
1491
+ length: number | undefined;
1492
+ }>;
1493
+ originActorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1494
+ name: "origin_actor_ref";
1495
+ tableName: "agent_memory";
1496
+ dataType: "string";
1497
+ columnType: "SQLiteText";
1498
+ data: string;
1499
+ driverParam: string;
1500
+ notNull: false;
1501
+ hasDefault: false;
1502
+ isPrimaryKey: false;
1503
+ isAutoincrement: false;
1504
+ hasRuntimeDefault: false;
1505
+ enumValues: [string, ...string[]];
1506
+ baseColumn: never;
1507
+ identity: undefined;
1508
+ generated: undefined;
1509
+ }, {}, {
1510
+ length: number | undefined;
1511
+ }>;
1512
+ pinned: drizzle_orm_sqlite_core.SQLiteColumn<{
1513
+ name: "pinned";
1514
+ tableName: "agent_memory";
1515
+ dataType: "boolean";
1516
+ columnType: "SQLiteBoolean";
1517
+ data: boolean;
1518
+ driverParam: number;
1519
+ notNull: true;
1520
+ hasDefault: true;
1521
+ isPrimaryKey: false;
1522
+ isAutoincrement: false;
1523
+ hasRuntimeDefault: false;
1524
+ enumValues: undefined;
1525
+ baseColumn: never;
1526
+ identity: undefined;
1527
+ generated: undefined;
1528
+ }, {}, {}>;
1529
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1530
+ name: "created_at";
1531
+ tableName: "agent_memory";
1532
+ dataType: "date";
1533
+ columnType: "SQLiteTimestamp";
1534
+ data: Date;
1535
+ driverParam: number;
1536
+ notNull: true;
1537
+ hasDefault: false;
1538
+ isPrimaryKey: false;
1539
+ isAutoincrement: false;
1540
+ hasRuntimeDefault: false;
1541
+ enumValues: undefined;
1542
+ baseColumn: never;
1543
+ identity: undefined;
1544
+ generated: undefined;
1545
+ }, {}, {}>;
1546
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1547
+ name: "updated_at";
1548
+ tableName: "agent_memory";
1549
+ dataType: "date";
1550
+ columnType: "SQLiteTimestamp";
1551
+ data: Date;
1552
+ driverParam: number;
1553
+ notNull: true;
1554
+ hasDefault: false;
1555
+ isPrimaryKey: false;
1556
+ isAutoincrement: false;
1557
+ hasRuntimeDefault: false;
1558
+ enumValues: undefined;
1559
+ baseColumn: never;
1560
+ identity: undefined;
1561
+ generated: undefined;
1562
+ }, {}, {}>;
1563
+ };
1564
+ dialect: "sqlite";
1565
+ }>;
1566
+ /** The terminal states an ingestion attempt can land in. Mirrors `MediaIngestOutcome`. */
1567
+ type RagIngestionStatus = 'ingested' | 'skipped' | 'failed' | 'removed';
1568
+ /**
1569
+ * The latest ingestion outcome for one RAG document — one row per document id, overwritten on
1570
+ * re-ingest by {@link import('./drizzle-rag-ingestion-log.js').DrizzleRagIngestionLog}.
1571
+ *
1572
+ * This exists because the vector store can only enumerate what it *has*: a document whose extraction
1573
+ * produced no text, whose mime type had no extractor, or whose embedding call blew up has zero chunks
1574
+ * and is therefore invisible to `VectorStore.listDocuments()`. Without this table, a scanned PDF that
1575
+ * silently failed to index is indistinguishable from one that was never uploaded.
1576
+ *
1577
+ * `collection` / `ownerType` / `ownerId` are opaque strings copied off the diagnostics payload — this
1578
+ * package never interprets them, and deliberately has no foreign key to a host's own collection
1579
+ * table, which it cannot know about. The index on (`collection`, `updated_at`) is what the
1580
+ * per-collection listing reads.
1581
+ */
1582
+ declare const ragIngestionLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1583
+ name: "rag_ingestion_log";
1584
+ schema: undefined;
1585
+ columns: {
1586
+ documentId: drizzle_orm_sqlite_core.SQLiteColumn<{
1587
+ name: "document_id";
1588
+ tableName: "rag_ingestion_log";
1589
+ dataType: "string";
1590
+ columnType: "SQLiteText";
1591
+ data: string;
1592
+ driverParam: string;
1593
+ notNull: true;
1594
+ hasDefault: false;
1595
+ isPrimaryKey: true;
1596
+ isAutoincrement: false;
1597
+ hasRuntimeDefault: false;
1598
+ enumValues: [string, ...string[]];
1599
+ baseColumn: never;
1600
+ identity: undefined;
1601
+ generated: undefined;
1602
+ }, {}, {
1603
+ length: number | undefined;
1604
+ }>;
1605
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
1606
+ name: "status";
1607
+ tableName: "rag_ingestion_log";
1608
+ dataType: "string";
1609
+ columnType: "SQLiteText";
1610
+ data: RagIngestionStatus;
1611
+ driverParam: string;
1612
+ notNull: true;
1613
+ hasDefault: false;
1614
+ isPrimaryKey: false;
1615
+ isAutoincrement: false;
1616
+ hasRuntimeDefault: false;
1617
+ enumValues: [string, ...string[]];
1618
+ baseColumn: never;
1619
+ identity: undefined;
1620
+ generated: undefined;
1621
+ }, {}, {
1622
+ length: number | undefined;
1623
+ $type: RagIngestionStatus;
1624
+ }>;
1625
+ collection: drizzle_orm_sqlite_core.SQLiteColumn<{
1626
+ name: "collection";
1627
+ tableName: "rag_ingestion_log";
1628
+ dataType: "string";
1629
+ columnType: "SQLiteText";
1630
+ data: string;
1631
+ driverParam: string;
1632
+ notNull: false;
1633
+ hasDefault: false;
1634
+ isPrimaryKey: false;
1635
+ isAutoincrement: false;
1636
+ hasRuntimeDefault: false;
1637
+ enumValues: [string, ...string[]];
1638
+ baseColumn: never;
1639
+ identity: undefined;
1640
+ generated: undefined;
1641
+ }, {}, {
1642
+ length: number | undefined;
1643
+ }>;
1644
+ ownerType: drizzle_orm_sqlite_core.SQLiteColumn<{
1645
+ name: "owner_type";
1646
+ tableName: "rag_ingestion_log";
1647
+ dataType: "string";
1648
+ columnType: "SQLiteText";
1649
+ data: string;
1650
+ driverParam: string;
1651
+ notNull: false;
1652
+ hasDefault: false;
1653
+ isPrimaryKey: false;
1654
+ isAutoincrement: false;
1655
+ hasRuntimeDefault: false;
1656
+ enumValues: [string, ...string[]];
1657
+ baseColumn: never;
1658
+ identity: undefined;
1659
+ generated: undefined;
1660
+ }, {}, {
1661
+ length: number | undefined;
1662
+ }>;
1663
+ ownerId: drizzle_orm_sqlite_core.SQLiteColumn<{
1664
+ name: "owner_id";
1665
+ tableName: "rag_ingestion_log";
1666
+ dataType: "string";
1667
+ columnType: "SQLiteText";
1668
+ data: string;
1669
+ driverParam: string;
1670
+ notNull: false;
1671
+ hasDefault: false;
1672
+ isPrimaryKey: false;
1673
+ isAutoincrement: false;
1674
+ hasRuntimeDefault: false;
1675
+ enumValues: [string, ...string[]];
1676
+ baseColumn: never;
1677
+ identity: undefined;
1678
+ generated: undefined;
1679
+ }, {}, {
1680
+ length: number | undefined;
1681
+ }>;
1682
+ source: drizzle_orm_sqlite_core.SQLiteColumn<{
1683
+ name: "source";
1684
+ tableName: "rag_ingestion_log";
1685
+ dataType: "string";
1686
+ columnType: "SQLiteText";
1687
+ data: string;
1688
+ driverParam: string;
1689
+ notNull: false;
1690
+ hasDefault: false;
1691
+ isPrimaryKey: false;
1692
+ isAutoincrement: false;
1693
+ hasRuntimeDefault: false;
1694
+ enumValues: [string, ...string[]];
1695
+ baseColumn: never;
1696
+ identity: undefined;
1697
+ generated: undefined;
1698
+ }, {}, {
1699
+ length: number | undefined;
1700
+ }>;
1701
+ mimeType: drizzle_orm_sqlite_core.SQLiteColumn<{
1702
+ name: "mime_type";
1703
+ tableName: "rag_ingestion_log";
1704
+ dataType: "string";
1705
+ columnType: "SQLiteText";
1706
+ data: string;
1707
+ driverParam: string;
1708
+ notNull: false;
1709
+ hasDefault: false;
1710
+ isPrimaryKey: false;
1711
+ isAutoincrement: false;
1712
+ hasRuntimeDefault: false;
1713
+ enumValues: [string, ...string[]];
1714
+ baseColumn: never;
1715
+ identity: undefined;
1716
+ generated: undefined;
1717
+ }, {}, {
1718
+ length: number | undefined;
1719
+ }>;
1720
+ size: drizzle_orm_sqlite_core.SQLiteColumn<{
1721
+ name: "size";
1722
+ tableName: "rag_ingestion_log";
1723
+ dataType: "number";
1724
+ columnType: "SQLiteInteger";
1725
+ data: number;
1726
+ driverParam: number;
1727
+ notNull: false;
1728
+ hasDefault: false;
1729
+ isPrimaryKey: false;
1730
+ isAutoincrement: false;
1731
+ hasRuntimeDefault: false;
1732
+ enumValues: undefined;
1733
+ baseColumn: never;
1734
+ identity: undefined;
1735
+ generated: undefined;
1736
+ }, {}, {}>;
1737
+ chunks: drizzle_orm_sqlite_core.SQLiteColumn<{
1738
+ name: "chunks";
1739
+ tableName: "rag_ingestion_log";
1740
+ dataType: "number";
1741
+ columnType: "SQLiteInteger";
1742
+ data: number;
1743
+ driverParam: number;
1744
+ notNull: false;
1745
+ hasDefault: false;
1746
+ isPrimaryKey: false;
1747
+ isAutoincrement: false;
1748
+ hasRuntimeDefault: false;
1749
+ enumValues: undefined;
1750
+ baseColumn: never;
1751
+ identity: undefined;
1752
+ generated: undefined;
1753
+ }, {}, {}>;
1754
+ reason: drizzle_orm_sqlite_core.SQLiteColumn<{
1755
+ name: "reason";
1756
+ tableName: "rag_ingestion_log";
1757
+ dataType: "string";
1758
+ columnType: "SQLiteText";
1759
+ data: string;
1760
+ driverParam: string;
1761
+ notNull: false;
1762
+ hasDefault: false;
1763
+ isPrimaryKey: false;
1764
+ isAutoincrement: false;
1765
+ hasRuntimeDefault: false;
1766
+ enumValues: [string, ...string[]];
1767
+ baseColumn: never;
1768
+ identity: undefined;
1769
+ generated: undefined;
1770
+ }, {}, {
1771
+ length: number | undefined;
1772
+ }>;
1773
+ error: drizzle_orm_sqlite_core.SQLiteColumn<{
1774
+ name: "error";
1775
+ tableName: "rag_ingestion_log";
1776
+ dataType: "string";
1777
+ columnType: "SQLiteText";
1778
+ data: string;
1779
+ driverParam: string;
1780
+ notNull: false;
1781
+ hasDefault: false;
1782
+ isPrimaryKey: false;
1783
+ isAutoincrement: false;
1784
+ hasRuntimeDefault: false;
1785
+ enumValues: [string, ...string[]];
1786
+ baseColumn: never;
1787
+ identity: undefined;
1788
+ generated: undefined;
1789
+ }, {}, {
1790
+ length: number | undefined;
1791
+ }>;
1792
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1793
+ name: "created_at";
1794
+ tableName: "rag_ingestion_log";
1795
+ dataType: "date";
1796
+ columnType: "SQLiteTimestamp";
1797
+ data: Date;
1798
+ driverParam: number;
1799
+ notNull: true;
1800
+ hasDefault: false;
1801
+ isPrimaryKey: false;
1802
+ isAutoincrement: false;
1803
+ hasRuntimeDefault: false;
1804
+ enumValues: undefined;
1805
+ baseColumn: never;
1806
+ identity: undefined;
1807
+ generated: undefined;
1808
+ }, {}, {}>;
1809
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1810
+ name: "updated_at";
1811
+ tableName: "rag_ingestion_log";
1812
+ dataType: "date";
1813
+ columnType: "SQLiteTimestamp";
1814
+ data: Date;
1815
+ driverParam: number;
1816
+ notNull: true;
1817
+ hasDefault: false;
1818
+ isPrimaryKey: false;
1819
+ isAutoincrement: false;
1820
+ hasRuntimeDefault: false;
1821
+ enumValues: undefined;
1822
+ baseColumn: never;
1823
+ identity: undefined;
1824
+ generated: undefined;
1825
+ }, {}, {}>;
1826
+ };
1827
+ dialect: "sqlite";
1828
+ }>;
1829
+ /** The tables this store owns, as one schema object, ready for `drizzle(client, { schema })`. */
1338
1830
  declare const agentSchema: {
1339
1831
  agentThread: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1340
1832
  name: "agent_thread";
@@ -1342,7 +1834,196 @@ declare const agentSchema: {
1342
1834
  columns: {
1343
1835
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
1344
1836
  name: "id";
1345
- tableName: "agent_thread";
1837
+ tableName: "agent_thread";
1838
+ dataType: "string";
1839
+ columnType: "SQLiteText";
1840
+ data: string;
1841
+ driverParam: string;
1842
+ notNull: true;
1843
+ hasDefault: false;
1844
+ isPrimaryKey: true;
1845
+ isAutoincrement: false;
1846
+ hasRuntimeDefault: false;
1847
+ enumValues: [string, ...string[]];
1848
+ baseColumn: never;
1849
+ identity: undefined;
1850
+ generated: undefined;
1851
+ }, {}, {
1852
+ length: number | undefined;
1853
+ }>;
1854
+ actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1855
+ name: "actor_ref";
1856
+ tableName: "agent_thread";
1857
+ dataType: "string";
1858
+ columnType: "SQLiteText";
1859
+ data: string;
1860
+ driverParam: string;
1861
+ notNull: true;
1862
+ hasDefault: false;
1863
+ isPrimaryKey: false;
1864
+ isAutoincrement: false;
1865
+ hasRuntimeDefault: false;
1866
+ enumValues: [string, ...string[]];
1867
+ baseColumn: never;
1868
+ identity: undefined;
1869
+ generated: undefined;
1870
+ }, {}, {
1871
+ length: number | undefined;
1872
+ }>;
1873
+ tenantRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1874
+ name: "tenant_ref";
1875
+ tableName: "agent_thread";
1876
+ dataType: "string";
1877
+ columnType: "SQLiteText";
1878
+ data: string;
1879
+ driverParam: string;
1880
+ notNull: false;
1881
+ hasDefault: false;
1882
+ isPrimaryKey: false;
1883
+ isAutoincrement: false;
1884
+ hasRuntimeDefault: false;
1885
+ enumValues: [string, ...string[]];
1886
+ baseColumn: never;
1887
+ identity: undefined;
1888
+ generated: undefined;
1889
+ }, {}, {
1890
+ length: number | undefined;
1891
+ }>;
1892
+ title: drizzle_orm_sqlite_core.SQLiteColumn<{
1893
+ name: "title";
1894
+ tableName: "agent_thread";
1895
+ dataType: "string";
1896
+ columnType: "SQLiteText";
1897
+ data: string;
1898
+ driverParam: string;
1899
+ notNull: true;
1900
+ hasDefault: false;
1901
+ isPrimaryKey: false;
1902
+ isAutoincrement: false;
1903
+ hasRuntimeDefault: false;
1904
+ enumValues: [string, ...string[]];
1905
+ baseColumn: never;
1906
+ identity: undefined;
1907
+ generated: undefined;
1908
+ }, {}, {
1909
+ length: number | undefined;
1910
+ }>;
1911
+ transient: drizzle_orm_sqlite_core.SQLiteColumn<{
1912
+ name: "transient";
1913
+ tableName: "agent_thread";
1914
+ dataType: "boolean";
1915
+ columnType: "SQLiteBoolean";
1916
+ data: boolean;
1917
+ driverParam: number;
1918
+ notNull: true;
1919
+ hasDefault: true;
1920
+ isPrimaryKey: false;
1921
+ isAutoincrement: false;
1922
+ hasRuntimeDefault: false;
1923
+ enumValues: undefined;
1924
+ baseColumn: never;
1925
+ identity: undefined;
1926
+ generated: undefined;
1927
+ }, {}, {}>;
1928
+ activeStreamId: drizzle_orm_sqlite_core.SQLiteColumn<{
1929
+ name: "active_stream_id";
1930
+ tableName: "agent_thread";
1931
+ dataType: "string";
1932
+ columnType: "SQLiteText";
1933
+ data: string;
1934
+ driverParam: string;
1935
+ notNull: false;
1936
+ hasDefault: false;
1937
+ isPrimaryKey: false;
1938
+ isAutoincrement: false;
1939
+ hasRuntimeDefault: false;
1940
+ enumValues: [string, ...string[]];
1941
+ baseColumn: never;
1942
+ identity: undefined;
1943
+ generated: undefined;
1944
+ }, {}, {
1945
+ length: number | undefined;
1946
+ }>;
1947
+ defaultAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
1948
+ name: "default_agent";
1949
+ tableName: "agent_thread";
1950
+ dataType: "string";
1951
+ columnType: "SQLiteText";
1952
+ data: string;
1953
+ driverParam: string;
1954
+ notNull: false;
1955
+ hasDefault: false;
1956
+ isPrimaryKey: false;
1957
+ isAutoincrement: false;
1958
+ hasRuntimeDefault: false;
1959
+ enumValues: [string, ...string[]];
1960
+ baseColumn: never;
1961
+ identity: undefined;
1962
+ generated: undefined;
1963
+ }, {}, {
1964
+ length: number | undefined;
1965
+ }>;
1966
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1967
+ name: "created_at";
1968
+ tableName: "agent_thread";
1969
+ dataType: "date";
1970
+ columnType: "SQLiteTimestamp";
1971
+ data: Date;
1972
+ driverParam: number;
1973
+ notNull: true;
1974
+ hasDefault: false;
1975
+ isPrimaryKey: false;
1976
+ isAutoincrement: false;
1977
+ hasRuntimeDefault: false;
1978
+ enumValues: undefined;
1979
+ baseColumn: never;
1980
+ identity: undefined;
1981
+ generated: undefined;
1982
+ }, {}, {}>;
1983
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1984
+ name: "updated_at";
1985
+ tableName: "agent_thread";
1986
+ dataType: "date";
1987
+ columnType: "SQLiteTimestamp";
1988
+ data: Date;
1989
+ driverParam: number;
1990
+ notNull: true;
1991
+ hasDefault: false;
1992
+ isPrimaryKey: false;
1993
+ isAutoincrement: false;
1994
+ hasRuntimeDefault: false;
1995
+ enumValues: undefined;
1996
+ baseColumn: never;
1997
+ identity: undefined;
1998
+ generated: undefined;
1999
+ }, {}, {}>;
2000
+ deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2001
+ name: "deleted_at";
2002
+ tableName: "agent_thread";
2003
+ dataType: "date";
2004
+ columnType: "SQLiteTimestamp";
2005
+ data: Date;
2006
+ driverParam: number;
2007
+ notNull: false;
2008
+ hasDefault: false;
2009
+ isPrimaryKey: false;
2010
+ isAutoincrement: false;
2011
+ hasRuntimeDefault: false;
2012
+ enumValues: undefined;
2013
+ baseColumn: never;
2014
+ identity: undefined;
2015
+ generated: undefined;
2016
+ }, {}, {}>;
2017
+ };
2018
+ dialect: "sqlite";
2019
+ }>;
2020
+ agentMessage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2021
+ name: "agent_message";
2022
+ schema: undefined;
2023
+ columns: {
2024
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
2025
+ name: "id";
2026
+ tableName: "agent_message";
1346
2027
  dataType: "string";
1347
2028
  columnType: "SQLiteText";
1348
2029
  data: string;
@@ -1359,9 +2040,48 @@ declare const agentSchema: {
1359
2040
  }, {}, {
1360
2041
  length: number | undefined;
1361
2042
  }>;
1362
- actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1363
- name: "actor_ref";
1364
- tableName: "agent_thread";
2043
+ threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
2044
+ name: "thread_id";
2045
+ tableName: "agent_message";
2046
+ dataType: "string";
2047
+ columnType: "SQLiteText";
2048
+ data: string;
2049
+ driverParam: string;
2050
+ notNull: true;
2051
+ hasDefault: false;
2052
+ isPrimaryKey: false;
2053
+ isAutoincrement: false;
2054
+ hasRuntimeDefault: false;
2055
+ enumValues: [string, ...string[]];
2056
+ baseColumn: never;
2057
+ identity: undefined;
2058
+ generated: undefined;
2059
+ }, {}, {
2060
+ length: number | undefined;
2061
+ }>;
2062
+ role: drizzle_orm_sqlite_core.SQLiteColumn<{
2063
+ name: "role";
2064
+ tableName: "agent_message";
2065
+ dataType: "string";
2066
+ columnType: "SQLiteText";
2067
+ data: MessageRole;
2068
+ driverParam: string;
2069
+ notNull: true;
2070
+ hasDefault: false;
2071
+ isPrimaryKey: false;
2072
+ isAutoincrement: false;
2073
+ hasRuntimeDefault: false;
2074
+ enumValues: [string, ...string[]];
2075
+ baseColumn: never;
2076
+ identity: undefined;
2077
+ generated: undefined;
2078
+ }, {}, {
2079
+ length: number | undefined;
2080
+ $type: MessageRole;
2081
+ }>;
2082
+ content: drizzle_orm_sqlite_core.SQLiteColumn<{
2083
+ name: "content";
2084
+ tableName: "agent_message";
1365
2085
  dataType: "string";
1366
2086
  columnType: "SQLiteText";
1367
2087
  data: string;
@@ -1376,55 +2096,93 @@ declare const agentSchema: {
1376
2096
  identity: undefined;
1377
2097
  generated: undefined;
1378
2098
  }, {}, {
1379
- length: number | undefined;
2099
+ length: number | undefined;
2100
+ }>;
2101
+ toolCalls: drizzle_orm_sqlite_core.SQLiteColumn<{
2102
+ name: "tool_calls";
2103
+ tableName: "agent_message";
2104
+ dataType: "json";
2105
+ columnType: "SQLiteTextJson";
2106
+ data: ToolCallRequest[];
2107
+ driverParam: string;
2108
+ notNull: false;
2109
+ hasDefault: false;
2110
+ isPrimaryKey: false;
2111
+ isAutoincrement: false;
2112
+ hasRuntimeDefault: false;
2113
+ enumValues: undefined;
2114
+ baseColumn: never;
2115
+ identity: undefined;
2116
+ generated: undefined;
2117
+ }, {}, {
2118
+ $type: ToolCallRequest[];
2119
+ }>;
2120
+ toolResults: drizzle_orm_sqlite_core.SQLiteColumn<{
2121
+ name: "tool_results";
2122
+ tableName: "agent_message";
2123
+ dataType: "json";
2124
+ columnType: "SQLiteTextJson";
2125
+ data: ToolResult[];
2126
+ driverParam: string;
2127
+ notNull: false;
2128
+ hasDefault: false;
2129
+ isPrimaryKey: false;
2130
+ isAutoincrement: false;
2131
+ hasRuntimeDefault: false;
2132
+ enumValues: undefined;
2133
+ baseColumn: never;
2134
+ identity: undefined;
2135
+ generated: undefined;
2136
+ }, {}, {
2137
+ $type: ToolResult[];
1380
2138
  }>;
1381
- tenantRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1382
- name: "tenant_ref";
1383
- tableName: "agent_thread";
1384
- dataType: "string";
1385
- columnType: "SQLiteText";
1386
- data: string;
2139
+ attachments: drizzle_orm_sqlite_core.SQLiteColumn<{
2140
+ name: "attachments";
2141
+ tableName: "agent_message";
2142
+ dataType: "json";
2143
+ columnType: "SQLiteTextJson";
2144
+ data: MessageAttachment[];
1387
2145
  driverParam: string;
1388
2146
  notNull: false;
1389
2147
  hasDefault: false;
1390
2148
  isPrimaryKey: false;
1391
2149
  isAutoincrement: false;
1392
2150
  hasRuntimeDefault: false;
1393
- enumValues: [string, ...string[]];
2151
+ enumValues: undefined;
1394
2152
  baseColumn: never;
1395
2153
  identity: undefined;
1396
2154
  generated: undefined;
1397
2155
  }, {}, {
1398
- length: number | undefined;
2156
+ $type: MessageAttachment[];
1399
2157
  }>;
1400
- title: drizzle_orm_sqlite_core.SQLiteColumn<{
1401
- name: "title";
1402
- tableName: "agent_thread";
1403
- dataType: "string";
1404
- columnType: "SQLiteText";
1405
- data: string;
2158
+ followUps: drizzle_orm_sqlite_core.SQLiteColumn<{
2159
+ name: "follow_ups";
2160
+ tableName: "agent_message";
2161
+ dataType: "json";
2162
+ columnType: "SQLiteTextJson";
2163
+ data: string[];
1406
2164
  driverParam: string;
1407
- notNull: true;
2165
+ notNull: false;
1408
2166
  hasDefault: false;
1409
2167
  isPrimaryKey: false;
1410
2168
  isAutoincrement: false;
1411
2169
  hasRuntimeDefault: false;
1412
- enumValues: [string, ...string[]];
2170
+ enumValues: undefined;
1413
2171
  baseColumn: never;
1414
2172
  identity: undefined;
1415
2173
  generated: undefined;
1416
2174
  }, {}, {
1417
- length: number | undefined;
2175
+ $type: string[];
1418
2176
  }>;
1419
- transient: drizzle_orm_sqlite_core.SQLiteColumn<{
1420
- name: "transient";
1421
- tableName: "agent_thread";
1422
- dataType: "boolean";
1423
- columnType: "SQLiteBoolean";
1424
- data: boolean;
1425
- driverParam: number;
1426
- notNull: true;
1427
- hasDefault: true;
2177
+ usage: drizzle_orm_sqlite_core.SQLiteColumn<{
2178
+ name: "usage";
2179
+ tableName: "agent_message";
2180
+ dataType: "json";
2181
+ columnType: "SQLiteTextJson";
2182
+ data: MessageUsage;
2183
+ driverParam: string;
2184
+ notNull: false;
2185
+ hasDefault: false;
1428
2186
  isPrimaryKey: false;
1429
2187
  isAutoincrement: false;
1430
2188
  hasRuntimeDefault: false;
@@ -1432,10 +2190,12 @@ declare const agentSchema: {
1432
2190
  baseColumn: never;
1433
2191
  identity: undefined;
1434
2192
  generated: undefined;
1435
- }, {}, {}>;
1436
- activeStreamId: drizzle_orm_sqlite_core.SQLiteColumn<{
1437
- name: "active_stream_id";
1438
- tableName: "agent_thread";
2193
+ }, {}, {
2194
+ $type: MessageUsage;
2195
+ }>;
2196
+ agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
2197
+ name: "agent_name";
2198
+ tableName: "agent_message";
1439
2199
  dataType: "string";
1440
2200
  columnType: "SQLiteText";
1441
2201
  data: string;
@@ -1452,9 +2212,9 @@ declare const agentSchema: {
1452
2212
  }, {}, {
1453
2213
  length: number | undefined;
1454
2214
  }>;
1455
- defaultAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
1456
- name: "default_agent";
1457
- tableName: "agent_thread";
2215
+ runId: drizzle_orm_sqlite_core.SQLiteColumn<{
2216
+ name: "run_id";
2217
+ tableName: "agent_message";
1458
2218
  dataType: "string";
1459
2219
  columnType: "SQLiteText";
1460
2220
  data: string;
@@ -1473,24 +2233,7 @@ declare const agentSchema: {
1473
2233
  }>;
1474
2234
  createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1475
2235
  name: "created_at";
1476
- tableName: "agent_thread";
1477
- dataType: "date";
1478
- columnType: "SQLiteTimestamp";
1479
- data: Date;
1480
- driverParam: number;
1481
- notNull: true;
1482
- hasDefault: false;
1483
- isPrimaryKey: false;
1484
- isAutoincrement: false;
1485
- hasRuntimeDefault: false;
1486
- enumValues: undefined;
1487
- baseColumn: never;
1488
- identity: undefined;
1489
- generated: undefined;
1490
- }, {}, {}>;
1491
- updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1492
- name: "updated_at";
1493
- tableName: "agent_thread";
2236
+ tableName: "agent_message";
1494
2237
  dataType: "date";
1495
2238
  columnType: "SQLiteTimestamp";
1496
2239
  data: Date;
@@ -1505,33 +2248,16 @@ declare const agentSchema: {
1505
2248
  identity: undefined;
1506
2249
  generated: undefined;
1507
2250
  }, {}, {}>;
1508
- deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1509
- name: "deleted_at";
1510
- tableName: "agent_thread";
1511
- dataType: "date";
1512
- columnType: "SQLiteTimestamp";
1513
- data: Date;
1514
- driverParam: number;
1515
- notNull: false;
1516
- hasDefault: false;
1517
- isPrimaryKey: false;
1518
- isAutoincrement: false;
1519
- hasRuntimeDefault: false;
1520
- enumValues: undefined;
1521
- baseColumn: never;
1522
- identity: undefined;
1523
- generated: undefined;
1524
- }, {}, {}>;
1525
2251
  };
1526
2252
  dialect: "sqlite";
1527
2253
  }>;
1528
- agentMessage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1529
- name: "agent_message";
2254
+ agentToolCall: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2255
+ name: "agent_tool_call";
1530
2256
  schema: undefined;
1531
2257
  columns: {
1532
2258
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
1533
2259
  name: "id";
1534
- tableName: "agent_message";
2260
+ tableName: "agent_tool_call";
1535
2261
  dataType: "string";
1536
2262
  columnType: "SQLiteText";
1537
2263
  data: string;
@@ -1548,9 +2274,9 @@ declare const agentSchema: {
1548
2274
  }, {}, {
1549
2275
  length: number | undefined;
1550
2276
  }>;
1551
- threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
1552
- name: "thread_id";
1553
- tableName: "agent_message";
2277
+ messageId: drizzle_orm_sqlite_core.SQLiteColumn<{
2278
+ name: "message_id";
2279
+ tableName: "agent_tool_call";
1554
2280
  dataType: "string";
1555
2281
  columnType: "SQLiteText";
1556
2282
  data: string;
@@ -1567,12 +2293,12 @@ declare const agentSchema: {
1567
2293
  }, {}, {
1568
2294
  length: number | undefined;
1569
2295
  }>;
1570
- role: drizzle_orm_sqlite_core.SQLiteColumn<{
1571
- name: "role";
1572
- tableName: "agent_message";
2296
+ toolName: drizzle_orm_sqlite_core.SQLiteColumn<{
2297
+ name: "tool_name";
2298
+ tableName: "agent_tool_call";
1573
2299
  dataType: "string";
1574
2300
  columnType: "SQLiteText";
1575
- data: MessageRole;
2301
+ data: string;
1576
2302
  driverParam: string;
1577
2303
  notNull: true;
1578
2304
  hasDefault: false;
@@ -1585,14 +2311,13 @@ declare const agentSchema: {
1585
2311
  generated: undefined;
1586
2312
  }, {}, {
1587
2313
  length: number | undefined;
1588
- $type: MessageRole;
1589
2314
  }>;
1590
- content: drizzle_orm_sqlite_core.SQLiteColumn<{
1591
- name: "content";
1592
- tableName: "agent_message";
2315
+ toolType: drizzle_orm_sqlite_core.SQLiteColumn<{
2316
+ name: "tool_type";
2317
+ tableName: "agent_tool_call";
1593
2318
  dataType: "string";
1594
2319
  columnType: "SQLiteText";
1595
- data: string;
2320
+ data: ToolKind;
1596
2321
  driverParam: string;
1597
2322
  notNull: true;
1598
2323
  hasDefault: false;
@@ -1605,13 +2330,14 @@ declare const agentSchema: {
1605
2330
  generated: undefined;
1606
2331
  }, {}, {
1607
2332
  length: number | undefined;
2333
+ $type: ToolKind;
1608
2334
  }>;
1609
- toolCalls: drizzle_orm_sqlite_core.SQLiteColumn<{
1610
- name: "tool_calls";
1611
- tableName: "agent_message";
2335
+ input: drizzle_orm_sqlite_core.SQLiteColumn<{
2336
+ name: "input";
2337
+ tableName: "agent_tool_call";
1612
2338
  dataType: "json";
1613
2339
  columnType: "SQLiteTextJson";
1614
- data: ToolCallRequest[];
2340
+ data: unknown;
1615
2341
  driverParam: string;
1616
2342
  notNull: false;
1617
2343
  hasDefault: false;
@@ -1622,15 +2348,13 @@ declare const agentSchema: {
1622
2348
  baseColumn: never;
1623
2349
  identity: undefined;
1624
2350
  generated: undefined;
1625
- }, {}, {
1626
- $type: ToolCallRequest[];
1627
- }>;
1628
- toolResults: drizzle_orm_sqlite_core.SQLiteColumn<{
1629
- name: "tool_results";
1630
- tableName: "agent_message";
2351
+ }, {}, {}>;
2352
+ output: drizzle_orm_sqlite_core.SQLiteColumn<{
2353
+ name: "output";
2354
+ tableName: "agent_tool_call";
1631
2355
  dataType: "json";
1632
2356
  columnType: "SQLiteTextJson";
1633
- data: ToolResult[];
2357
+ data: unknown;
1634
2358
  driverParam: string;
1635
2359
  notNull: false;
1636
2360
  hasDefault: false;
@@ -1641,35 +2365,53 @@ declare const agentSchema: {
1641
2365
  baseColumn: never;
1642
2366
  identity: undefined;
1643
2367
  generated: undefined;
2368
+ }, {}, {}>;
2369
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
2370
+ name: "status";
2371
+ tableName: "agent_tool_call";
2372
+ dataType: "string";
2373
+ columnType: "SQLiteText";
2374
+ data: ToolCallStatus;
2375
+ driverParam: string;
2376
+ notNull: true;
2377
+ hasDefault: false;
2378
+ isPrimaryKey: false;
2379
+ isAutoincrement: false;
2380
+ hasRuntimeDefault: false;
2381
+ enumValues: [string, ...string[]];
2382
+ baseColumn: never;
2383
+ identity: undefined;
2384
+ generated: undefined;
1644
2385
  }, {}, {
1645
- $type: ToolResult[];
2386
+ length: number | undefined;
2387
+ $type: ToolCallStatus;
1646
2388
  }>;
1647
- attachments: drizzle_orm_sqlite_core.SQLiteColumn<{
1648
- name: "attachments";
1649
- tableName: "agent_message";
1650
- dataType: "json";
1651
- columnType: "SQLiteTextJson";
1652
- data: MessageAttachment[];
2389
+ executedByRef: drizzle_orm_sqlite_core.SQLiteColumn<{
2390
+ name: "executed_by_ref";
2391
+ tableName: "agent_tool_call";
2392
+ dataType: "string";
2393
+ columnType: "SQLiteText";
2394
+ data: string;
1653
2395
  driverParam: string;
1654
2396
  notNull: false;
1655
2397
  hasDefault: false;
1656
2398
  isPrimaryKey: false;
1657
2399
  isAutoincrement: false;
1658
2400
  hasRuntimeDefault: false;
1659
- enumValues: undefined;
2401
+ enumValues: [string, ...string[]];
1660
2402
  baseColumn: never;
1661
2403
  identity: undefined;
1662
2404
  generated: undefined;
1663
2405
  }, {}, {
1664
- $type: MessageAttachment[];
2406
+ length: number | undefined;
1665
2407
  }>;
1666
- followUps: drizzle_orm_sqlite_core.SQLiteColumn<{
1667
- name: "follow_ups";
1668
- tableName: "agent_message";
1669
- dataType: "json";
1670
- columnType: "SQLiteTextJson";
1671
- data: string[];
1672
- driverParam: string;
2408
+ executionMs: drizzle_orm_sqlite_core.SQLiteColumn<{
2409
+ name: "execution_ms";
2410
+ tableName: "agent_tool_call";
2411
+ dataType: "number";
2412
+ columnType: "SQLiteInteger";
2413
+ data: number;
2414
+ driverParam: number;
1673
2415
  notNull: false;
1674
2416
  hasDefault: false;
1675
2417
  isPrimaryKey: false;
@@ -1679,16 +2421,50 @@ declare const agentSchema: {
1679
2421
  baseColumn: never;
1680
2422
  identity: undefined;
1681
2423
  generated: undefined;
2424
+ }, {}, {}>;
2425
+ error: drizzle_orm_sqlite_core.SQLiteColumn<{
2426
+ name: "error";
2427
+ tableName: "agent_tool_call";
2428
+ dataType: "string";
2429
+ columnType: "SQLiteText";
2430
+ data: string;
2431
+ driverParam: string;
2432
+ notNull: false;
2433
+ hasDefault: false;
2434
+ isPrimaryKey: false;
2435
+ isAutoincrement: false;
2436
+ hasRuntimeDefault: false;
2437
+ enumValues: [string, ...string[]];
2438
+ baseColumn: never;
2439
+ identity: undefined;
2440
+ generated: undefined;
1682
2441
  }, {}, {
1683
- $type: string[];
2442
+ length: number | undefined;
1684
2443
  }>;
1685
- usage: drizzle_orm_sqlite_core.SQLiteColumn<{
1686
- name: "usage";
1687
- tableName: "agent_message";
1688
- dataType: "json";
1689
- columnType: "SQLiteTextJson";
1690
- data: MessageUsage;
1691
- driverParam: string;
2444
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2445
+ name: "created_at";
2446
+ tableName: "agent_tool_call";
2447
+ dataType: "date";
2448
+ columnType: "SQLiteTimestamp";
2449
+ data: Date;
2450
+ driverParam: number;
2451
+ notNull: true;
2452
+ hasDefault: false;
2453
+ isPrimaryKey: false;
2454
+ isAutoincrement: false;
2455
+ hasRuntimeDefault: false;
2456
+ enumValues: undefined;
2457
+ baseColumn: never;
2458
+ identity: undefined;
2459
+ generated: undefined;
2460
+ }, {}, {}>;
2461
+ executedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2462
+ name: "executed_at";
2463
+ tableName: "agent_tool_call";
2464
+ dataType: "date";
2465
+ columnType: "SQLiteTimestamp";
2466
+ data: Date;
2467
+ driverParam: number;
1692
2468
  notNull: false;
1693
2469
  hasDefault: false;
1694
2470
  isPrimaryKey: false;
@@ -1698,12 +2474,10 @@ declare const agentSchema: {
1698
2474
  baseColumn: never;
1699
2475
  identity: undefined;
1700
2476
  generated: undefined;
1701
- }, {}, {
1702
- $type: MessageUsage;
1703
- }>;
1704
- agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
1705
- name: "agent_name";
1706
- tableName: "agent_message";
2477
+ }, {}, {}>;
2478
+ runId: drizzle_orm_sqlite_core.SQLiteColumn<{
2479
+ name: "run_id";
2480
+ tableName: "agent_tool_call";
1707
2481
  dataType: "string";
1708
2482
  columnType: "SQLiteText";
1709
2483
  data: string;
@@ -1720,16 +2494,23 @@ declare const agentSchema: {
1720
2494
  }, {}, {
1721
2495
  length: number | undefined;
1722
2496
  }>;
1723
- runId: drizzle_orm_sqlite_core.SQLiteColumn<{
1724
- name: "run_id";
1725
- tableName: "agent_message";
2497
+ };
2498
+ dialect: "sqlite";
2499
+ }>;
2500
+ agentTokenUsage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2501
+ name: "agent_token_usage";
2502
+ schema: undefined;
2503
+ columns: {
2504
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
2505
+ name: "id";
2506
+ tableName: "agent_token_usage";
1726
2507
  dataType: "string";
1727
2508
  columnType: "SQLiteText";
1728
2509
  data: string;
1729
2510
  driverParam: string;
1730
- notNull: false;
2511
+ notNull: true;
1731
2512
  hasDefault: false;
1732
- isPrimaryKey: false;
2513
+ isPrimaryKey: true;
1733
2514
  isAutoincrement: false;
1734
2515
  hasRuntimeDefault: false;
1735
2516
  enumValues: [string, ...string[]];
@@ -1739,40 +2520,35 @@ declare const agentSchema: {
1739
2520
  }, {}, {
1740
2521
  length: number | undefined;
1741
2522
  }>;
1742
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1743
- name: "created_at";
1744
- tableName: "agent_message";
1745
- dataType: "date";
1746
- columnType: "SQLiteTimestamp";
1747
- data: Date;
1748
- driverParam: number;
2523
+ threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
2524
+ name: "thread_id";
2525
+ tableName: "agent_token_usage";
2526
+ dataType: "string";
2527
+ columnType: "SQLiteText";
2528
+ data: string;
2529
+ driverParam: string;
1749
2530
  notNull: true;
1750
2531
  hasDefault: false;
1751
2532
  isPrimaryKey: false;
1752
2533
  isAutoincrement: false;
1753
2534
  hasRuntimeDefault: false;
1754
- enumValues: undefined;
2535
+ enumValues: [string, ...string[]];
1755
2536
  baseColumn: never;
1756
2537
  identity: undefined;
1757
2538
  generated: undefined;
1758
- }, {}, {}>;
1759
- };
1760
- dialect: "sqlite";
1761
- }>;
1762
- agentToolCall: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1763
- name: "agent_tool_call";
1764
- schema: undefined;
1765
- columns: {
1766
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
1767
- name: "id";
1768
- tableName: "agent_tool_call";
2539
+ }, {}, {
2540
+ length: number | undefined;
2541
+ }>;
2542
+ actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
2543
+ name: "actor_ref";
2544
+ tableName: "agent_token_usage";
1769
2545
  dataType: "string";
1770
2546
  columnType: "SQLiteText";
1771
2547
  data: string;
1772
2548
  driverParam: string;
1773
2549
  notNull: true;
1774
2550
  hasDefault: false;
1775
- isPrimaryKey: true;
2551
+ isPrimaryKey: false;
1776
2552
  isAutoincrement: false;
1777
2553
  hasRuntimeDefault: false;
1778
2554
  enumValues: [string, ...string[]];
@@ -1784,12 +2560,12 @@ declare const agentSchema: {
1784
2560
  }>;
1785
2561
  messageId: drizzle_orm_sqlite_core.SQLiteColumn<{
1786
2562
  name: "message_id";
1787
- tableName: "agent_tool_call";
2563
+ tableName: "agent_token_usage";
1788
2564
  dataType: "string";
1789
2565
  columnType: "SQLiteText";
1790
2566
  data: string;
1791
2567
  driverParam: string;
1792
- notNull: true;
2568
+ notNull: false;
1793
2569
  hasDefault: false;
1794
2570
  isPrimaryKey: false;
1795
2571
  isAutoincrement: false;
@@ -1801,9 +2577,9 @@ declare const agentSchema: {
1801
2577
  }, {}, {
1802
2578
  length: number | undefined;
1803
2579
  }>;
1804
- toolName: drizzle_orm_sqlite_core.SQLiteColumn<{
1805
- name: "tool_name";
1806
- tableName: "agent_tool_call";
2580
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2581
+ name: "model_id";
2582
+ tableName: "agent_token_usage";
1807
2583
  dataType: "string";
1808
2584
  columnType: "SQLiteText";
1809
2585
  data: string;
@@ -1820,12 +2596,12 @@ declare const agentSchema: {
1820
2596
  }, {}, {
1821
2597
  length: number | undefined;
1822
2598
  }>;
1823
- toolType: drizzle_orm_sqlite_core.SQLiteColumn<{
1824
- name: "tool_type";
1825
- tableName: "agent_tool_call";
2599
+ purpose: drizzle_orm_sqlite_core.SQLiteColumn<{
2600
+ name: "purpose";
2601
+ tableName: "agent_token_usage";
1826
2602
  dataType: "string";
1827
2603
  columnType: "SQLiteText";
1828
- data: ToolKind;
2604
+ data: UsagePurpose;
1829
2605
  driverParam: string;
1830
2606
  notNull: true;
1831
2607
  hasDefault: false;
@@ -1838,15 +2614,49 @@ declare const agentSchema: {
1838
2614
  generated: undefined;
1839
2615
  }, {}, {
1840
2616
  length: number | undefined;
1841
- $type: ToolKind;
2617
+ $type: UsagePurpose;
1842
2618
  }>;
1843
- input: drizzle_orm_sqlite_core.SQLiteColumn<{
1844
- name: "input";
1845
- tableName: "agent_tool_call";
1846
- dataType: "json";
1847
- columnType: "SQLiteTextJson";
1848
- data: unknown;
1849
- driverParam: string;
2619
+ inputTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2620
+ name: "input_tokens";
2621
+ tableName: "agent_token_usage";
2622
+ dataType: "number";
2623
+ columnType: "SQLiteInteger";
2624
+ data: number;
2625
+ driverParam: number;
2626
+ notNull: true;
2627
+ hasDefault: false;
2628
+ isPrimaryKey: false;
2629
+ isAutoincrement: false;
2630
+ hasRuntimeDefault: false;
2631
+ enumValues: undefined;
2632
+ baseColumn: never;
2633
+ identity: undefined;
2634
+ generated: undefined;
2635
+ }, {}, {}>;
2636
+ outputTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2637
+ name: "output_tokens";
2638
+ tableName: "agent_token_usage";
2639
+ dataType: "number";
2640
+ columnType: "SQLiteInteger";
2641
+ data: number;
2642
+ driverParam: number;
2643
+ notNull: true;
2644
+ hasDefault: false;
2645
+ isPrimaryKey: false;
2646
+ isAutoincrement: false;
2647
+ hasRuntimeDefault: false;
2648
+ enumValues: undefined;
2649
+ baseColumn: never;
2650
+ identity: undefined;
2651
+ generated: undefined;
2652
+ }, {}, {}>;
2653
+ cacheWriteTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2654
+ name: "cache_write_tokens";
2655
+ tableName: "agent_token_usage";
2656
+ dataType: "number";
2657
+ columnType: "SQLiteInteger";
2658
+ data: number;
2659
+ driverParam: number;
1850
2660
  notNull: false;
1851
2661
  hasDefault: false;
1852
2662
  isPrimaryKey: false;
@@ -1857,13 +2667,13 @@ declare const agentSchema: {
1857
2667
  identity: undefined;
1858
2668
  generated: undefined;
1859
2669
  }, {}, {}>;
1860
- output: drizzle_orm_sqlite_core.SQLiteColumn<{
1861
- name: "output";
1862
- tableName: "agent_tool_call";
1863
- dataType: "json";
1864
- columnType: "SQLiteTextJson";
1865
- data: unknown;
1866
- driverParam: string;
2670
+ cacheReadTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2671
+ name: "cache_read_tokens";
2672
+ tableName: "agent_token_usage";
2673
+ dataType: "number";
2674
+ columnType: "SQLiteInteger";
2675
+ data: number;
2676
+ driverParam: number;
1867
2677
  notNull: false;
1868
2678
  hasDefault: false;
1869
2679
  isPrimaryKey: false;
@@ -1874,16 +2684,57 @@ declare const agentSchema: {
1874
2684
  identity: undefined;
1875
2685
  generated: undefined;
1876
2686
  }, {}, {}>;
1877
- status: drizzle_orm_sqlite_core.SQLiteColumn<{
1878
- name: "status";
1879
- tableName: "agent_tool_call";
2687
+ costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
2688
+ name: "cost_usd";
2689
+ tableName: "agent_token_usage";
2690
+ dataType: "number";
2691
+ columnType: "SQLiteReal";
2692
+ data: number;
2693
+ driverParam: number;
2694
+ notNull: false;
2695
+ hasDefault: false;
2696
+ isPrimaryKey: false;
2697
+ isAutoincrement: false;
2698
+ hasRuntimeDefault: false;
2699
+ enumValues: undefined;
2700
+ baseColumn: never;
2701
+ identity: undefined;
2702
+ generated: undefined;
2703
+ }, {}, {}>;
2704
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2705
+ name: "created_at";
2706
+ tableName: "agent_token_usage";
2707
+ dataType: "date";
2708
+ columnType: "SQLiteTimestamp";
2709
+ data: Date;
2710
+ driverParam: number;
2711
+ notNull: true;
2712
+ hasDefault: false;
2713
+ isPrimaryKey: false;
2714
+ isAutoincrement: false;
2715
+ hasRuntimeDefault: false;
2716
+ enumValues: undefined;
2717
+ baseColumn: never;
2718
+ identity: undefined;
2719
+ generated: undefined;
2720
+ }, {}, {}>;
2721
+ };
2722
+ dialect: "sqlite";
2723
+ }>;
2724
+ agentModelPricing: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2725
+ name: "agent_model_pricing";
2726
+ schema: undefined;
2727
+ columns: {
2728
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
2729
+ name: "id";
2730
+ tableName: "agent_model_pricing";
1880
2731
  dataType: "string";
1881
2732
  columnType: "SQLiteText";
1882
- data: ToolCallStatus;
2733
+ data: string;
1883
2734
  driverParam: string;
1884
2735
  notNull: true;
1885
2736
  hasDefault: false;
1886
- isPrimaryKey: false;
2737
+ isPrimaryKey: true;
1887
2738
  isAutoincrement: false;
1888
2739
  hasRuntimeDefault: false;
1889
2740
  enumValues: [string, ...string[]];
@@ -1892,16 +2743,15 @@ declare const agentSchema: {
1892
2743
  generated: undefined;
1893
2744
  }, {}, {
1894
2745
  length: number | undefined;
1895
- $type: ToolCallStatus;
1896
2746
  }>;
1897
- executedByRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1898
- name: "executed_by_ref";
1899
- tableName: "agent_tool_call";
2747
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2748
+ name: "model_id";
2749
+ tableName: "agent_model_pricing";
1900
2750
  dataType: "string";
1901
2751
  columnType: "SQLiteText";
1902
2752
  data: string;
1903
2753
  driverParam: string;
1904
- notNull: false;
2754
+ notNull: true;
1905
2755
  hasDefault: false;
1906
2756
  isPrimaryKey: false;
1907
2757
  isAutoincrement: false;
@@ -1913,14 +2763,14 @@ declare const agentSchema: {
1913
2763
  }, {}, {
1914
2764
  length: number | undefined;
1915
2765
  }>;
1916
- executionMs: drizzle_orm_sqlite_core.SQLiteColumn<{
1917
- name: "execution_ms";
1918
- tableName: "agent_tool_call";
2766
+ inputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2767
+ name: "input_price_per_1m";
2768
+ tableName: "agent_model_pricing";
1919
2769
  dataType: "number";
1920
- columnType: "SQLiteInteger";
2770
+ columnType: "SQLiteReal";
1921
2771
  data: number;
1922
2772
  driverParam: number;
1923
- notNull: false;
2773
+ notNull: true;
1924
2774
  hasDefault: false;
1925
2775
  isPrimaryKey: false;
1926
2776
  isAutoincrement: false;
@@ -1930,33 +2780,48 @@ declare const agentSchema: {
1930
2780
  identity: undefined;
1931
2781
  generated: undefined;
1932
2782
  }, {}, {}>;
1933
- error: drizzle_orm_sqlite_core.SQLiteColumn<{
1934
- name: "error";
1935
- tableName: "agent_tool_call";
1936
- dataType: "string";
1937
- columnType: "SQLiteText";
1938
- data: string;
1939
- driverParam: string;
1940
- notNull: false;
2783
+ outputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2784
+ name: "output_price_per_1m";
2785
+ tableName: "agent_model_pricing";
2786
+ dataType: "number";
2787
+ columnType: "SQLiteReal";
2788
+ data: number;
2789
+ driverParam: number;
2790
+ notNull: true;
1941
2791
  hasDefault: false;
1942
2792
  isPrimaryKey: false;
1943
2793
  isAutoincrement: false;
1944
2794
  hasRuntimeDefault: false;
1945
- enumValues: [string, ...string[]];
2795
+ enumValues: undefined;
1946
2796
  baseColumn: never;
1947
2797
  identity: undefined;
1948
2798
  generated: undefined;
1949
- }, {}, {
1950
- length: number | undefined;
1951
- }>;
1952
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1953
- name: "created_at";
1954
- tableName: "agent_tool_call";
1955
- dataType: "date";
1956
- columnType: "SQLiteTimestamp";
1957
- data: Date;
2799
+ }, {}, {}>;
2800
+ cacheWritePricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2801
+ name: "cache_write_price_per_1m";
2802
+ tableName: "agent_model_pricing";
2803
+ dataType: "number";
2804
+ columnType: "SQLiteReal";
2805
+ data: number;
2806
+ driverParam: number;
2807
+ notNull: false;
2808
+ hasDefault: false;
2809
+ isPrimaryKey: false;
2810
+ isAutoincrement: false;
2811
+ hasRuntimeDefault: false;
2812
+ enumValues: undefined;
2813
+ baseColumn: never;
2814
+ identity: undefined;
2815
+ generated: undefined;
2816
+ }, {}, {}>;
2817
+ cacheReadPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2818
+ name: "cache_read_price_per_1m";
2819
+ tableName: "agent_model_pricing";
2820
+ dataType: "number";
2821
+ columnType: "SQLiteReal";
2822
+ data: number;
1958
2823
  driverParam: number;
1959
- notNull: true;
2824
+ notNull: false;
1960
2825
  hasDefault: false;
1961
2826
  isPrimaryKey: false;
1962
2827
  isAutoincrement: false;
@@ -1966,14 +2831,14 @@ declare const agentSchema: {
1966
2831
  identity: undefined;
1967
2832
  generated: undefined;
1968
2833
  }, {}, {}>;
1969
- executedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1970
- name: "executed_at";
1971
- tableName: "agent_tool_call";
2834
+ effectiveFrom: drizzle_orm_sqlite_core.SQLiteColumn<{
2835
+ name: "effective_from";
2836
+ tableName: "agent_model_pricing";
1972
2837
  dataType: "date";
1973
2838
  columnType: "SQLiteTimestamp";
1974
2839
  data: Date;
1975
2840
  driverParam: number;
1976
- notNull: false;
2841
+ notNull: true;
1977
2842
  hasDefault: false;
1978
2843
  isPrimaryKey: false;
1979
2844
  isAutoincrement: false;
@@ -1983,35 +2848,33 @@ declare const agentSchema: {
1983
2848
  identity: undefined;
1984
2849
  generated: undefined;
1985
2850
  }, {}, {}>;
1986
- runId: drizzle_orm_sqlite_core.SQLiteColumn<{
1987
- name: "run_id";
1988
- tableName: "agent_tool_call";
1989
- dataType: "string";
1990
- columnType: "SQLiteText";
1991
- data: string;
1992
- driverParam: string;
1993
- notNull: false;
2851
+ isCurrent: drizzle_orm_sqlite_core.SQLiteColumn<{
2852
+ name: "is_current";
2853
+ tableName: "agent_model_pricing";
2854
+ dataType: "boolean";
2855
+ columnType: "SQLiteBoolean";
2856
+ data: boolean;
2857
+ driverParam: number;
2858
+ notNull: true;
1994
2859
  hasDefault: false;
1995
2860
  isPrimaryKey: false;
1996
2861
  isAutoincrement: false;
1997
2862
  hasRuntimeDefault: false;
1998
- enumValues: [string, ...string[]];
2863
+ enumValues: undefined;
1999
2864
  baseColumn: never;
2000
2865
  identity: undefined;
2001
2866
  generated: undefined;
2002
- }, {}, {
2003
- length: number | undefined;
2004
- }>;
2867
+ }, {}, {}>;
2005
2868
  };
2006
2869
  dialect: "sqlite";
2007
2870
  }>;
2008
- agentTokenUsage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2009
- name: "agent_token_usage";
2871
+ agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2872
+ name: "agent_run";
2010
2873
  schema: undefined;
2011
2874
  columns: {
2012
2875
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
2013
2876
  name: "id";
2014
- tableName: "agent_token_usage";
2877
+ tableName: "agent_run";
2015
2878
  dataType: "string";
2016
2879
  columnType: "SQLiteText";
2017
2880
  data: string;
@@ -2030,7 +2893,7 @@ declare const agentSchema: {
2030
2893
  }>;
2031
2894
  threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
2032
2895
  name: "thread_id";
2033
- tableName: "agent_token_usage";
2896
+ tableName: "agent_run";
2034
2897
  dataType: "string";
2035
2898
  columnType: "SQLiteText";
2036
2899
  data: string;
@@ -2049,7 +2912,7 @@ declare const agentSchema: {
2049
2912
  }>;
2050
2913
  actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
2051
2914
  name: "actor_ref";
2052
- tableName: "agent_token_usage";
2915
+ tableName: "agent_run";
2053
2916
  dataType: "string";
2054
2917
  columnType: "SQLiteText";
2055
2918
  data: string;
@@ -2066,9 +2929,9 @@ declare const agentSchema: {
2066
2929
  }, {}, {
2067
2930
  length: number | undefined;
2068
2931
  }>;
2069
- messageId: drizzle_orm_sqlite_core.SQLiteColumn<{
2070
- name: "message_id";
2071
- tableName: "agent_token_usage";
2932
+ agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
2933
+ name: "agent_name";
2934
+ tableName: "agent_run";
2072
2935
  dataType: "string";
2073
2936
  columnType: "SQLiteText";
2074
2937
  data: string;
@@ -2085,12 +2948,12 @@ declare const agentSchema: {
2085
2948
  }, {}, {
2086
2949
  length: number | undefined;
2087
2950
  }>;
2088
- modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2089
- name: "model_id";
2090
- tableName: "agent_token_usage";
2951
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
2952
+ name: "status";
2953
+ tableName: "agent_run";
2091
2954
  dataType: "string";
2092
2955
  columnType: "SQLiteText";
2093
- data: string;
2956
+ data: AgentRunStatus;
2094
2957
  driverParam: string;
2095
2958
  notNull: true;
2096
2959
  hasDefault: false;
@@ -2103,15 +2966,33 @@ declare const agentSchema: {
2103
2966
  generated: undefined;
2104
2967
  }, {}, {
2105
2968
  length: number | undefined;
2969
+ $type: AgentRunStatus;
2106
2970
  }>;
2107
- purpose: drizzle_orm_sqlite_core.SQLiteColumn<{
2108
- name: "purpose";
2109
- tableName: "agent_token_usage";
2971
+ durationMs: drizzle_orm_sqlite_core.SQLiteColumn<{
2972
+ name: "duration_ms";
2973
+ tableName: "agent_run";
2974
+ dataType: "number";
2975
+ columnType: "SQLiteInteger";
2976
+ data: number;
2977
+ driverParam: number;
2978
+ notNull: false;
2979
+ hasDefault: false;
2980
+ isPrimaryKey: false;
2981
+ isAutoincrement: false;
2982
+ hasRuntimeDefault: false;
2983
+ enumValues: undefined;
2984
+ baseColumn: never;
2985
+ identity: undefined;
2986
+ generated: undefined;
2987
+ }, {}, {}>;
2988
+ errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
2989
+ name: "error_code";
2990
+ tableName: "agent_run";
2110
2991
  dataType: "string";
2111
2992
  columnType: "SQLiteText";
2112
- data: UsagePurpose;
2993
+ data: string;
2113
2994
  driverParam: string;
2114
- notNull: true;
2995
+ notNull: false;
2115
2996
  hasDefault: false;
2116
2997
  isPrimaryKey: false;
2117
2998
  isAutoincrement: false;
@@ -2122,34 +3003,35 @@ declare const agentSchema: {
2122
3003
  generated: undefined;
2123
3004
  }, {}, {
2124
3005
  length: number | undefined;
2125
- $type: UsagePurpose;
2126
3006
  }>;
2127
- inputTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2128
- name: "input_tokens";
2129
- tableName: "agent_token_usage";
2130
- dataType: "number";
2131
- columnType: "SQLiteInteger";
2132
- data: number;
2133
- driverParam: number;
2134
- notNull: true;
3007
+ errorMessage: drizzle_orm_sqlite_core.SQLiteColumn<{
3008
+ name: "error_message";
3009
+ tableName: "agent_run";
3010
+ dataType: "string";
3011
+ columnType: "SQLiteText";
3012
+ data: string;
3013
+ driverParam: string;
3014
+ notNull: false;
2135
3015
  hasDefault: false;
2136
3016
  isPrimaryKey: false;
2137
3017
  isAutoincrement: false;
2138
3018
  hasRuntimeDefault: false;
2139
- enumValues: undefined;
3019
+ enumValues: [string, ...string[]];
2140
3020
  baseColumn: never;
2141
3021
  identity: undefined;
2142
3022
  generated: undefined;
2143
- }, {}, {}>;
2144
- outputTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2145
- name: "output_tokens";
2146
- tableName: "agent_token_usage";
3023
+ }, {}, {
3024
+ length: number | undefined;
3025
+ }>;
3026
+ retries: drizzle_orm_sqlite_core.SQLiteColumn<{
3027
+ name: "retries";
3028
+ tableName: "agent_run";
2147
3029
  dataType: "number";
2148
3030
  columnType: "SQLiteInteger";
2149
3031
  data: number;
2150
3032
  driverParam: number;
2151
3033
  notNull: true;
2152
- hasDefault: false;
3034
+ hasDefault: true;
2153
3035
  isPrimaryKey: false;
2154
3036
  isAutoincrement: false;
2155
3037
  hasRuntimeDefault: false;
@@ -2158,14 +3040,14 @@ declare const agentSchema: {
2158
3040
  identity: undefined;
2159
3041
  generated: undefined;
2160
3042
  }, {}, {}>;
2161
- cacheWriteTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2162
- name: "cache_write_tokens";
2163
- tableName: "agent_token_usage";
2164
- dataType: "number";
2165
- columnType: "SQLiteInteger";
2166
- data: number;
3043
+ startedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3044
+ name: "started_at";
3045
+ tableName: "agent_run";
3046
+ dataType: "date";
3047
+ columnType: "SQLiteTimestamp";
3048
+ data: Date;
2167
3049
  driverParam: number;
2168
- notNull: false;
3050
+ notNull: true;
2169
3051
  hasDefault: false;
2170
3052
  isPrimaryKey: false;
2171
3053
  isAutoincrement: false;
@@ -2175,12 +3057,12 @@ declare const agentSchema: {
2175
3057
  identity: undefined;
2176
3058
  generated: undefined;
2177
3059
  }, {}, {}>;
2178
- cacheReadTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2179
- name: "cache_read_tokens";
2180
- tableName: "agent_token_usage";
2181
- dataType: "number";
2182
- columnType: "SQLiteInteger";
2183
- data: number;
3060
+ settledAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3061
+ name: "settled_at";
3062
+ tableName: "agent_run";
3063
+ dataType: "date";
3064
+ columnType: "SQLiteTimestamp";
3065
+ data: Date;
2184
3066
  driverParam: number;
2185
3067
  notNull: false;
2186
3068
  hasDefault: false;
@@ -2192,50 +3074,54 @@ declare const agentSchema: {
2192
3074
  identity: undefined;
2193
3075
  generated: undefined;
2194
3076
  }, {}, {}>;
2195
- costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
2196
- name: "cost_usd";
2197
- tableName: "agent_token_usage";
2198
- dataType: "number";
2199
- columnType: "SQLiteReal";
2200
- data: number;
2201
- driverParam: number;
3077
+ promptHash: drizzle_orm_sqlite_core.SQLiteColumn<{
3078
+ name: "prompt_hash";
3079
+ tableName: "agent_run";
3080
+ dataType: "string";
3081
+ columnType: "SQLiteText";
3082
+ data: string;
3083
+ driverParam: string;
2202
3084
  notNull: false;
2203
3085
  hasDefault: false;
2204
3086
  isPrimaryKey: false;
2205
3087
  isAutoincrement: false;
2206
3088
  hasRuntimeDefault: false;
2207
- enumValues: undefined;
3089
+ enumValues: [string, ...string[]];
2208
3090
  baseColumn: never;
2209
3091
  identity: undefined;
2210
3092
  generated: undefined;
2211
- }, {}, {}>;
2212
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2213
- name: "created_at";
2214
- tableName: "agent_token_usage";
2215
- dataType: "date";
2216
- columnType: "SQLiteTimestamp";
2217
- data: Date;
2218
- driverParam: number;
2219
- notNull: true;
3093
+ }, {}, {
3094
+ length: number | undefined;
3095
+ }>;
3096
+ parentRunId: drizzle_orm_sqlite_core.SQLiteColumn<{
3097
+ name: "parent_run_id";
3098
+ tableName: "agent_run";
3099
+ dataType: "string";
3100
+ columnType: "SQLiteText";
3101
+ data: string;
3102
+ driverParam: string;
3103
+ notNull: false;
2220
3104
  hasDefault: false;
2221
3105
  isPrimaryKey: false;
2222
3106
  isAutoincrement: false;
2223
3107
  hasRuntimeDefault: false;
2224
- enumValues: undefined;
3108
+ enumValues: [string, ...string[]];
2225
3109
  baseColumn: never;
2226
3110
  identity: undefined;
2227
3111
  generated: undefined;
2228
- }, {}, {}>;
3112
+ }, {}, {
3113
+ length: number | undefined;
3114
+ }>;
2229
3115
  };
2230
3116
  dialect: "sqlite";
2231
3117
  }>;
2232
- agentModelPricing: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2233
- name: "agent_model_pricing";
3118
+ agentMemory: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3119
+ name: "agent_memory";
2234
3120
  schema: undefined;
2235
3121
  columns: {
2236
3122
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
2237
3123
  name: "id";
2238
- tableName: "agent_model_pricing";
3124
+ tableName: "agent_memory";
2239
3125
  dataType: "string";
2240
3126
  columnType: "SQLiteText";
2241
3127
  data: string;
@@ -2252,9 +3138,9 @@ declare const agentSchema: {
2252
3138
  }, {}, {
2253
3139
  length: number | undefined;
2254
3140
  }>;
2255
- modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2256
- name: "model_id";
2257
- tableName: "agent_model_pricing";
3141
+ scope: drizzle_orm_sqlite_core.SQLiteColumn<{
3142
+ name: "scope";
3143
+ tableName: "agent_memory";
2258
3144
  dataType: "string";
2259
3145
  columnType: "SQLiteText";
2260
3146
  data: string;
@@ -2271,77 +3157,141 @@ declare const agentSchema: {
2271
3157
  }, {}, {
2272
3158
  length: number | undefined;
2273
3159
  }>;
2274
- inputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2275
- name: "input_price_per_1m";
2276
- tableName: "agent_model_pricing";
2277
- dataType: "number";
2278
- columnType: "SQLiteReal";
2279
- data: number;
2280
- driverParam: number;
3160
+ key: drizzle_orm_sqlite_core.SQLiteColumn<{
3161
+ name: "key";
3162
+ tableName: "agent_memory";
3163
+ dataType: "string";
3164
+ columnType: "SQLiteText";
3165
+ data: string;
3166
+ driverParam: string;
2281
3167
  notNull: true;
2282
3168
  hasDefault: false;
2283
3169
  isPrimaryKey: false;
2284
3170
  isAutoincrement: false;
2285
3171
  hasRuntimeDefault: false;
2286
- enumValues: undefined;
3172
+ enumValues: [string, ...string[]];
2287
3173
  baseColumn: never;
2288
3174
  identity: undefined;
2289
3175
  generated: undefined;
2290
- }, {}, {}>;
2291
- outputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2292
- name: "output_price_per_1m";
2293
- tableName: "agent_model_pricing";
2294
- dataType: "number";
2295
- columnType: "SQLiteReal";
2296
- data: number;
2297
- driverParam: number;
3176
+ }, {}, {
3177
+ length: number | undefined;
3178
+ }>;
3179
+ text: drizzle_orm_sqlite_core.SQLiteColumn<{
3180
+ name: "text";
3181
+ tableName: "agent_memory";
3182
+ dataType: "string";
3183
+ columnType: "SQLiteText";
3184
+ data: string;
3185
+ driverParam: string;
3186
+ notNull: true;
3187
+ hasDefault: false;
3188
+ isPrimaryKey: false;
3189
+ isAutoincrement: false;
3190
+ hasRuntimeDefault: false;
3191
+ enumValues: [string, ...string[]];
3192
+ baseColumn: never;
3193
+ identity: undefined;
3194
+ generated: undefined;
3195
+ }, {}, {
3196
+ length: number | undefined;
3197
+ }>;
3198
+ originAuthor: drizzle_orm_sqlite_core.SQLiteColumn<{
3199
+ name: "origin_author";
3200
+ tableName: "agent_memory";
3201
+ dataType: "string";
3202
+ columnType: "SQLiteText";
3203
+ data: "agent" | "human";
3204
+ driverParam: string;
2298
3205
  notNull: true;
2299
3206
  hasDefault: false;
2300
3207
  isPrimaryKey: false;
2301
3208
  isAutoincrement: false;
2302
3209
  hasRuntimeDefault: false;
2303
- enumValues: undefined;
3210
+ enumValues: [string, ...string[]];
3211
+ baseColumn: never;
3212
+ identity: undefined;
3213
+ generated: undefined;
3214
+ }, {}, {
3215
+ length: number | undefined;
3216
+ $type: "agent" | "human";
3217
+ }>;
3218
+ originThreadId: drizzle_orm_sqlite_core.SQLiteColumn<{
3219
+ name: "origin_thread_id";
3220
+ tableName: "agent_memory";
3221
+ dataType: "string";
3222
+ columnType: "SQLiteText";
3223
+ data: string;
3224
+ driverParam: string;
3225
+ notNull: false;
3226
+ hasDefault: false;
3227
+ isPrimaryKey: false;
3228
+ isAutoincrement: false;
3229
+ hasRuntimeDefault: false;
3230
+ enumValues: [string, ...string[]];
2304
3231
  baseColumn: never;
2305
3232
  identity: undefined;
2306
3233
  generated: undefined;
2307
- }, {}, {}>;
2308
- cacheWritePricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2309
- name: "cache_write_price_per_1m";
2310
- tableName: "agent_model_pricing";
2311
- dataType: "number";
2312
- columnType: "SQLiteReal";
2313
- data: number;
2314
- driverParam: number;
3234
+ }, {}, {
3235
+ length: number | undefined;
3236
+ }>;
3237
+ originRunId: drizzle_orm_sqlite_core.SQLiteColumn<{
3238
+ name: "origin_run_id";
3239
+ tableName: "agent_memory";
3240
+ dataType: "string";
3241
+ columnType: "SQLiteText";
3242
+ data: string;
3243
+ driverParam: string;
2315
3244
  notNull: false;
2316
3245
  hasDefault: false;
2317
3246
  isPrimaryKey: false;
2318
3247
  isAutoincrement: false;
2319
3248
  hasRuntimeDefault: false;
2320
- enumValues: undefined;
3249
+ enumValues: [string, ...string[]];
2321
3250
  baseColumn: never;
2322
3251
  identity: undefined;
2323
3252
  generated: undefined;
2324
- }, {}, {}>;
2325
- cacheReadPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2326
- name: "cache_read_price_per_1m";
2327
- tableName: "agent_model_pricing";
2328
- dataType: "number";
2329
- columnType: "SQLiteReal";
2330
- data: number;
2331
- driverParam: number;
3253
+ }, {}, {
3254
+ length: number | undefined;
3255
+ }>;
3256
+ originActorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
3257
+ name: "origin_actor_ref";
3258
+ tableName: "agent_memory";
3259
+ dataType: "string";
3260
+ columnType: "SQLiteText";
3261
+ data: string;
3262
+ driverParam: string;
2332
3263
  notNull: false;
2333
3264
  hasDefault: false;
2334
3265
  isPrimaryKey: false;
2335
3266
  isAutoincrement: false;
2336
3267
  hasRuntimeDefault: false;
3268
+ enumValues: [string, ...string[]];
3269
+ baseColumn: never;
3270
+ identity: undefined;
3271
+ generated: undefined;
3272
+ }, {}, {
3273
+ length: number | undefined;
3274
+ }>;
3275
+ pinned: drizzle_orm_sqlite_core.SQLiteColumn<{
3276
+ name: "pinned";
3277
+ tableName: "agent_memory";
3278
+ dataType: "boolean";
3279
+ columnType: "SQLiteBoolean";
3280
+ data: boolean;
3281
+ driverParam: number;
3282
+ notNull: true;
3283
+ hasDefault: true;
3284
+ isPrimaryKey: false;
3285
+ isAutoincrement: false;
3286
+ hasRuntimeDefault: false;
2337
3287
  enumValues: undefined;
2338
3288
  baseColumn: never;
2339
3289
  identity: undefined;
2340
3290
  generated: undefined;
2341
3291
  }, {}, {}>;
2342
- effectiveFrom: drizzle_orm_sqlite_core.SQLiteColumn<{
2343
- name: "effective_from";
2344
- tableName: "agent_model_pricing";
3292
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3293
+ name: "created_at";
3294
+ tableName: "agent_memory";
2345
3295
  dataType: "date";
2346
3296
  columnType: "SQLiteTimestamp";
2347
3297
  data: Date;
@@ -2356,12 +3306,12 @@ declare const agentSchema: {
2356
3306
  identity: undefined;
2357
3307
  generated: undefined;
2358
3308
  }, {}, {}>;
2359
- isCurrent: drizzle_orm_sqlite_core.SQLiteColumn<{
2360
- name: "is_current";
2361
- tableName: "agent_model_pricing";
2362
- dataType: "boolean";
2363
- columnType: "SQLiteBoolean";
2364
- data: boolean;
3309
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3310
+ name: "updated_at";
3311
+ tableName: "agent_memory";
3312
+ dataType: "date";
3313
+ columnType: "SQLiteTimestamp";
3314
+ data: Date;
2365
3315
  driverParam: number;
2366
3316
  notNull: true;
2367
3317
  hasDefault: false;
@@ -2376,13 +3326,13 @@ declare const agentSchema: {
2376
3326
  };
2377
3327
  dialect: "sqlite";
2378
3328
  }>;
2379
- agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2380
- name: "agent_run";
3329
+ ragIngestionLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3330
+ name: "rag_ingestion_log";
2381
3331
  schema: undefined;
2382
3332
  columns: {
2383
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
2384
- name: "id";
2385
- tableName: "agent_run";
3333
+ documentId: drizzle_orm_sqlite_core.SQLiteColumn<{
3334
+ name: "document_id";
3335
+ tableName: "rag_ingestion_log";
2386
3336
  dataType: "string";
2387
3337
  columnType: "SQLiteText";
2388
3338
  data: string;
@@ -2399,12 +3349,12 @@ declare const agentSchema: {
2399
3349
  }, {}, {
2400
3350
  length: number | undefined;
2401
3351
  }>;
2402
- threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
2403
- name: "thread_id";
2404
- tableName: "agent_run";
3352
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
3353
+ name: "status";
3354
+ tableName: "rag_ingestion_log";
2405
3355
  dataType: "string";
2406
3356
  columnType: "SQLiteText";
2407
- data: string;
3357
+ data: RagIngestionStatus;
2408
3358
  driverParam: string;
2409
3359
  notNull: true;
2410
3360
  hasDefault: false;
@@ -2417,15 +3367,16 @@ declare const agentSchema: {
2417
3367
  generated: undefined;
2418
3368
  }, {}, {
2419
3369
  length: number | undefined;
3370
+ $type: RagIngestionStatus;
2420
3371
  }>;
2421
- actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
2422
- name: "actor_ref";
2423
- tableName: "agent_run";
3372
+ collection: drizzle_orm_sqlite_core.SQLiteColumn<{
3373
+ name: "collection";
3374
+ tableName: "rag_ingestion_log";
2424
3375
  dataType: "string";
2425
3376
  columnType: "SQLiteText";
2426
3377
  data: string;
2427
3378
  driverParam: string;
2428
- notNull: true;
3379
+ notNull: false;
2429
3380
  hasDefault: false;
2430
3381
  isPrimaryKey: false;
2431
3382
  isAutoincrement: false;
@@ -2437,9 +3388,9 @@ declare const agentSchema: {
2437
3388
  }, {}, {
2438
3389
  length: number | undefined;
2439
3390
  }>;
2440
- agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
2441
- name: "agent_name";
2442
- tableName: "agent_run";
3391
+ ownerType: drizzle_orm_sqlite_core.SQLiteColumn<{
3392
+ name: "owner_type";
3393
+ tableName: "rag_ingestion_log";
2443
3394
  dataType: "string";
2444
3395
  columnType: "SQLiteText";
2445
3396
  data: string;
@@ -2456,14 +3407,14 @@ declare const agentSchema: {
2456
3407
  }, {}, {
2457
3408
  length: number | undefined;
2458
3409
  }>;
2459
- status: drizzle_orm_sqlite_core.SQLiteColumn<{
2460
- name: "status";
2461
- tableName: "agent_run";
3410
+ ownerId: drizzle_orm_sqlite_core.SQLiteColumn<{
3411
+ name: "owner_id";
3412
+ tableName: "rag_ingestion_log";
2462
3413
  dataType: "string";
2463
3414
  columnType: "SQLiteText";
2464
- data: AgentRunStatus;
3415
+ data: string;
2465
3416
  driverParam: string;
2466
- notNull: true;
3417
+ notNull: false;
2467
3418
  hasDefault: false;
2468
3419
  isPrimaryKey: false;
2469
3420
  isAutoincrement: false;
@@ -2474,28 +3425,10 @@ declare const agentSchema: {
2474
3425
  generated: undefined;
2475
3426
  }, {}, {
2476
3427
  length: number | undefined;
2477
- $type: AgentRunStatus;
2478
3428
  }>;
2479
- durationMs: drizzle_orm_sqlite_core.SQLiteColumn<{
2480
- name: "duration_ms";
2481
- tableName: "agent_run";
2482
- dataType: "number";
2483
- columnType: "SQLiteInteger";
2484
- data: number;
2485
- driverParam: number;
2486
- notNull: false;
2487
- hasDefault: false;
2488
- isPrimaryKey: false;
2489
- isAutoincrement: false;
2490
- hasRuntimeDefault: false;
2491
- enumValues: undefined;
2492
- baseColumn: never;
2493
- identity: undefined;
2494
- generated: undefined;
2495
- }, {}, {}>;
2496
- errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
2497
- name: "error_code";
2498
- tableName: "agent_run";
3429
+ source: drizzle_orm_sqlite_core.SQLiteColumn<{
3430
+ name: "source";
3431
+ tableName: "rag_ingestion_log";
2499
3432
  dataType: "string";
2500
3433
  columnType: "SQLiteText";
2501
3434
  data: string;
@@ -2512,9 +3445,9 @@ declare const agentSchema: {
2512
3445
  }, {}, {
2513
3446
  length: number | undefined;
2514
3447
  }>;
2515
- errorMessage: drizzle_orm_sqlite_core.SQLiteColumn<{
2516
- name: "error_message";
2517
- tableName: "agent_run";
3448
+ mimeType: drizzle_orm_sqlite_core.SQLiteColumn<{
3449
+ name: "mime_type";
3450
+ tableName: "rag_ingestion_log";
2518
3451
  dataType: "string";
2519
3452
  columnType: "SQLiteText";
2520
3453
  data: string;
@@ -2531,31 +3464,14 @@ declare const agentSchema: {
2531
3464
  }, {}, {
2532
3465
  length: number | undefined;
2533
3466
  }>;
2534
- retries: drizzle_orm_sqlite_core.SQLiteColumn<{
2535
- name: "retries";
2536
- tableName: "agent_run";
3467
+ size: drizzle_orm_sqlite_core.SQLiteColumn<{
3468
+ name: "size";
3469
+ tableName: "rag_ingestion_log";
2537
3470
  dataType: "number";
2538
3471
  columnType: "SQLiteInteger";
2539
3472
  data: number;
2540
3473
  driverParam: number;
2541
- notNull: true;
2542
- hasDefault: true;
2543
- isPrimaryKey: false;
2544
- isAutoincrement: false;
2545
- hasRuntimeDefault: false;
2546
- enumValues: undefined;
2547
- baseColumn: never;
2548
- identity: undefined;
2549
- generated: undefined;
2550
- }, {}, {}>;
2551
- startedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2552
- name: "started_at";
2553
- tableName: "agent_run";
2554
- dataType: "date";
2555
- columnType: "SQLiteTimestamp";
2556
- data: Date;
2557
- driverParam: number;
2558
- notNull: true;
3474
+ notNull: false;
2559
3475
  hasDefault: false;
2560
3476
  isPrimaryKey: false;
2561
3477
  isAutoincrement: false;
@@ -2565,12 +3481,12 @@ declare const agentSchema: {
2565
3481
  identity: undefined;
2566
3482
  generated: undefined;
2567
3483
  }, {}, {}>;
2568
- settledAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2569
- name: "settled_at";
2570
- tableName: "agent_run";
2571
- dataType: "date";
2572
- columnType: "SQLiteTimestamp";
2573
- data: Date;
3484
+ chunks: drizzle_orm_sqlite_core.SQLiteColumn<{
3485
+ name: "chunks";
3486
+ tableName: "rag_ingestion_log";
3487
+ dataType: "number";
3488
+ columnType: "SQLiteInteger";
3489
+ data: number;
2574
3490
  driverParam: number;
2575
3491
  notNull: false;
2576
3492
  hasDefault: false;
@@ -2582,9 +3498,9 @@ declare const agentSchema: {
2582
3498
  identity: undefined;
2583
3499
  generated: undefined;
2584
3500
  }, {}, {}>;
2585
- promptHash: drizzle_orm_sqlite_core.SQLiteColumn<{
2586
- name: "prompt_hash";
2587
- tableName: "agent_run";
3501
+ reason: drizzle_orm_sqlite_core.SQLiteColumn<{
3502
+ name: "reason";
3503
+ tableName: "rag_ingestion_log";
2588
3504
  dataType: "string";
2589
3505
  columnType: "SQLiteText";
2590
3506
  data: string;
@@ -2601,9 +3517,9 @@ declare const agentSchema: {
2601
3517
  }, {}, {
2602
3518
  length: number | undefined;
2603
3519
  }>;
2604
- parentRunId: drizzle_orm_sqlite_core.SQLiteColumn<{
2605
- name: "parent_run_id";
2606
- tableName: "agent_run";
3520
+ error: drizzle_orm_sqlite_core.SQLiteColumn<{
3521
+ name: "error";
3522
+ tableName: "rag_ingestion_log";
2607
3523
  dataType: "string";
2608
3524
  columnType: "SQLiteText";
2609
3525
  data: string;
@@ -2620,6 +3536,40 @@ declare const agentSchema: {
2620
3536
  }, {}, {
2621
3537
  length: number | undefined;
2622
3538
  }>;
3539
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3540
+ name: "created_at";
3541
+ tableName: "rag_ingestion_log";
3542
+ dataType: "date";
3543
+ columnType: "SQLiteTimestamp";
3544
+ data: Date;
3545
+ driverParam: number;
3546
+ notNull: true;
3547
+ hasDefault: false;
3548
+ isPrimaryKey: false;
3549
+ isAutoincrement: false;
3550
+ hasRuntimeDefault: false;
3551
+ enumValues: undefined;
3552
+ baseColumn: never;
3553
+ identity: undefined;
3554
+ generated: undefined;
3555
+ }, {}, {}>;
3556
+ updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3557
+ name: "updated_at";
3558
+ tableName: "rag_ingestion_log";
3559
+ dataType: "date";
3560
+ columnType: "SQLiteTimestamp";
3561
+ data: Date;
3562
+ driverParam: number;
3563
+ notNull: true;
3564
+ hasDefault: false;
3565
+ isPrimaryKey: false;
3566
+ isAutoincrement: false;
3567
+ hasRuntimeDefault: false;
3568
+ enumValues: undefined;
3569
+ baseColumn: never;
3570
+ identity: undefined;
3571
+ generated: undefined;
3572
+ }, {}, {}>;
2623
3573
  };
2624
3574
  dialect: "sqlite";
2625
3575
  }>;
@@ -2636,6 +3586,10 @@ type AgentThreadRow = typeof agentThread.$inferSelect;
2636
3586
  type AgentMessageRow = typeof agentMessage.$inferSelect;
2637
3587
  /** A persisted run row as Drizzle selects it. */
2638
3588
  type AgentRunRow = typeof agentRun.$inferSelect;
3589
+ /** A persisted memory row as Drizzle selects it. */
3590
+ type AgentMemoryRow = typeof agentMemory.$inferSelect;
3591
+ /** A persisted RAG ingestion outcome as Drizzle selects it. */
3592
+ type RagIngestionLogRow = typeof ragIngestionLog.$inferSelect;
2639
3593
 
2640
3594
  /**
2641
3595
  * Runs the `CREATE TABLE IF NOT EXISTS` DDL above against the supplied Drizzle SQLite db, then adds
@@ -2841,6 +3795,72 @@ declare class DrizzleGovernanceQueries implements AgentGovernanceQueries {
2841
3795
  private toolCallCountsByMessage;
2842
3796
  }
2843
3797
 
3798
+ /**
3799
+ * {@link MemoryProvider} backed by Drizzle, over the `agent_memory` table this package's
3800
+ * `ensureAgentSchema` creates. The host app owns and supplies the db handle.
3801
+ *
3802
+ * `search` IS NOT IMPLEMENTED, and that is a decision rather than an omission. It is optional on the
3803
+ * SPI, and what it buys is a block filled by relevance once the applicable set outgrows
3804
+ * `maxMemories` — which needs an index over the memories themselves, and an index is the half a
3805
+ * general-purpose table cannot supply: the shape depends entirely on what a deployment already runs
3806
+ * (pgvector, a full-text index, a hybrid service), and picking one here would make this adapter
3807
+ * require infrastructure most hosts do not have for a ceiling most of them never reach. Without
3808
+ * `search`, `list` reads the applicable scopes whole and the ceiling never bites.
3809
+ *
3810
+ * The signal that it is worth building is `MemoryDigest.omitted` going non-zero — and
3811
+ * `pinnedOmitted` especially, which means a standing policy stopped reaching any prompt. Both are on
3812
+ * the `aviary:agent:memory.resolved` diagnostic. A host that gets there implements `search` against
3813
+ * its own index and passes it as the provider, or wraps this one.
3814
+ */
3815
+ declare class DrizzleMemoryProvider implements MemoryProvider {
3816
+ private readonly db;
3817
+ constructor(db: AgentDrizzleDb);
3818
+ /**
3819
+ * Every memory visible at `scopes` — asked on EVERY turn, so it is one indexed `scope in (…)`
3820
+ * against the leading column of the (`scope`, `key`) unique index.
3821
+ *
3822
+ * The scope filter is in the QUERY. The library drops out-of-scope records it is handed, but that
3823
+ * is a backstop: a memory held for another actor or another tenant is never selected here, so it
3824
+ * is unreachable rather than outranked.
3825
+ */
3826
+ list({ scopes }: ListMemoriesInput): Promise<MemoryRecord[]>;
3827
+ /**
3828
+ * Delete one, and only from the actor's OWN scope.
3829
+ *
3830
+ * `memoryForgetVerdict` already holds the library's endpoint to that rule; the `where` repeats it
3831
+ * because `forget` takes an id and nothing else, so a caller reaching this provider by any other
3832
+ * path would otherwise delete a tenant's or the deployment's memory by knowing one id.
3833
+ *
3834
+ * `false` where nothing matched — which covers "no such id" and "not yours" identically, so the
3835
+ * answer cannot be used to find out which memories exist about other people.
3836
+ */
3837
+ forget({ id, ctx }: ForgetMemoryInput): Promise<boolean>;
3838
+ /**
3839
+ * Upsert on (`scope`, `key`) — one statement, against the unique index, rather than a read
3840
+ * followed by a write: two turns concluding the same key at once would otherwise race to a
3841
+ * duplicate-key insert and one of them would fail the `remember` tool.
3842
+ *
3843
+ * The conflict `set` names exactly what a rewrite may change, so `pinned`, `createdAt` and `id`
3844
+ * are left alone by construction rather than by an exclusion anyone could forget to extend.
3845
+ * Dropping `pinned` would silently unpin a row the next time the agent restated the fact;
3846
+ * rewriting `createdAt` would lose when the belief was first formed; reassigning `id` would
3847
+ * invalidate the delete handle a person was already shown.
3848
+ */
3849
+ write({ key, text, scope, origin, ctx }: StoreMemoryInput): Promise<MemoryRecord>;
3850
+ /**
3851
+ * Make one memory always-on, or stop it being one. The operator act the SPI has no method for, on
3852
+ * purpose: a pin grants a fact a permanent place in every future prompt, so nothing an agent can
3853
+ * reach may set it. Authorize it in your own console — this takes no `ScopeContext` because it is
3854
+ * not an actor's act on their own memory.
3855
+ *
3856
+ * `false` where there is no such id.
3857
+ */
3858
+ pin({ id, pinned }: {
3859
+ id: string;
3860
+ pinned: boolean;
3861
+ }): Promise<boolean>;
3862
+ }
3863
+
2844
3864
  /**
2845
3865
  * {@link AgentPricingStore} backed by Drizzle ORM — the write side of the pricing table
2846
3866
  * {@link import('./drizzle-governance-queries.js').DrizzleGovernanceQueries} joins against. A POJO
@@ -2854,6 +3874,190 @@ declare class DrizzlePricingStore implements AgentPricingStore {
2854
3874
  listCurrentPrices(): Promise<CurrentModelPrice[]>;
2855
3875
  }
2856
3876
 
3877
+ /**
3878
+ * The paging order: newest first, tiebroken on the primary key.
3879
+ *
3880
+ * `updatedAt` alone is not a total order — a bulk upload stamps every document of the batch with the
3881
+ * same second — and a database is free to return tied rows in a different sequence for each
3882
+ * LIMIT/OFFSET query. A tie straddling a page boundary then hands a caller sweeping the table a row
3883
+ * in *neither* page (or the same row twice), which is how an orphan-sweep leaves an S3 object behind
3884
+ * with its log row already gone, and how a reconcile re-embeds documents it already has.
3885
+ * `documentId` is the table's primary key, so appending it makes the order total and the pages
3886
+ * disjoint.
3887
+ *
3888
+ * Exported because it is a contract, not an implementation detail: a caller that polls page 1 for a
3889
+ * document it just rewrote depends on `updated_at desc`, and a caller that pages depends on the
3890
+ * tiebreaker. Spread it into a query of your own (`.orderBy(...RAG_INGESTION_LOG_PAGE_ORDER)`) to
3891
+ * read this table the way {@link DrizzleRagIngestionLog} does — and to keep `iterate`'s keyset
3892
+ * arithmetic, which is derived from exactly this order, in view.
3893
+ */
3894
+ declare const RAG_INGESTION_LOG_PAGE_ORDER: SQL[];
3895
+ /** The coordinates half of a log query: which rows, with nothing said about paging. */
3896
+ interface RagIngestionLogWhere {
3897
+ collection?: string;
3898
+ status?: RagIngestionStatus;
3899
+ }
3900
+ interface RagIngestionLogQuery extends RagIngestionLogWhere {
3901
+ limit?: number;
3902
+ offset?: number;
3903
+ }
3904
+ /**
3905
+ * Where a sweep left off: the ordering column plus the primary key, i.e. one point in
3906
+ * {@link RAG_INGESTION_LOG_PAGE_ORDER}. Not an opaque token — it is two column values, so a caller
3907
+ * may persist it across processes and resume from it.
3908
+ */
3909
+ interface RagIngestionLogCursor {
3910
+ updatedAt: Date;
3911
+ documentId: string;
3912
+ }
3913
+ interface RagIngestionLogIterateOptions {
3914
+ /**
3915
+ * Rows fetched per round-trip. Defaults to 200; anything under 1 or non-finite falls back to
3916
+ * that default rather than being honoured — a batch of 0 would fetch nothing and never advance.
3917
+ */
3918
+ batchSize?: number;
3919
+ /** Resume strictly after this point in the order, e.g. a cursor persisted by an earlier sweep. */
3920
+ after?: RagIngestionLogCursor;
3921
+ }
3922
+ /**
3923
+ * Records the outcome of every RAG ingestion into `rag_ingestion_log`, by subscribing to the
3924
+ * `aviary:rag:*` diagnostics channels `@dudousxd/nestjs-agent-rag-media` publishes — the Drizzle
3925
+ * counterpart of `MikroOrmRagIngestionLog`, with the same columns, ordering and write semantics, so
3926
+ * a console built on one adapter reads the other.
3927
+ *
3928
+ * It answers the question a vector store structurally cannot: *which documents failed to index, and
3929
+ * why*. A skipped or failed document produces no chunks, so it is invisible to
3930
+ * `VectorStore.listDocuments()` — the index only knows about successes. Pair the two for a complete
3931
+ * picture: the store is the truth about what is retrievable, this table is the truth about what was
3932
+ * attempted.
3933
+ *
3934
+ * Writes are best-effort and never throw: this runs detached from any request, on a diagnostics
3935
+ * channel, so a failed write must not take down the ingestion that triggered it. A lost row costs
3936
+ * observability, not data — the vector store remains the system of record.
3937
+ */
3938
+ declare class DrizzleRagIngestionLog implements OnModuleInit, OnModuleDestroy {
3939
+ private readonly db;
3940
+ private readonly logger;
3941
+ private teardowns;
3942
+ private readonly inFlight;
3943
+ constructor(db: AgentDrizzleDb);
3944
+ onModuleInit(): void;
3945
+ onModuleDestroy(): Promise<void>;
3946
+ /** Await every in-flight write — for graceful shutdown and deterministic tests. */
3947
+ settle(): Promise<void>;
3948
+ /** The latest recorded outcome per document, newest first. */
3949
+ list(query?: RagIngestionLogQuery): Promise<RagIngestionLogRow[]>;
3950
+ /**
3951
+ * The same page plus the unpaginated total, so a caller can tell "these are all of them" from
3952
+ * "these are the first N". A list that silently truncates reads as complete when it isn't.
3953
+ *
3954
+ * Offset paging is only sound over a table nobody is deleting from underneath you: a row removed
3955
+ * behind the cursor shifts everything after it back by one, so the next page starts one row late
3956
+ * and that row is never seen. Use {@link iterate} for any sweep that deletes.
3957
+ */
3958
+ listPage(query?: RagIngestionLogQuery): Promise<{
3959
+ rows: RagIngestionLogRow[];
3960
+ total: number;
3961
+ }>;
3962
+ /**
3963
+ * Every matching row, newest first, streamed in batches — the sweep-safe way to walk this table.
3964
+ *
3965
+ * Paging is *keyset*, not offset: each batch asks for the rows that sort strictly after the last
3966
+ * row yielded, using `(updatedAt, documentId)` — one point in
3967
+ * {@link RAG_INGESTION_LOG_PAGE_ORDER}, which is total because it ends in the primary key. A
3968
+ * cursor made of column values does not move when rows leave the table, which is what makes this
3969
+ * delete-safe *by construction* rather than by the caller carefully advancing an offset by only
3970
+ * the rows it kept.
3971
+ *
3972
+ * **The guarantee, stated once:** a row is yielded exactly when — at the moment the batch that
3973
+ * would contain it is fetched — the row exists, matches `where`, and sorts strictly after the
3974
+ * last row already yielded. Everything below is a consequence of that one sentence.
3975
+ *
3976
+ * What you can rely on:
3977
+ * - **Deleting rows while iterating is safe.** Delete any row you like — the one just yielded, the
3978
+ * whole batch, rows you have not reached yet — and every row that is still there when the sweep
3979
+ * reaches its position is visited exactly once. Nothing is skipped and nothing is repeated,
3980
+ * because deleting a row moves no *other* row's `(updatedAt, documentId)`. (Rows you delete
3981
+ * *ahead* of the cursor are simply never visited, which is the point of deleting them.)
3982
+ * - **Ties are safe.** A bulk upload stamps a whole batch with the same `updatedAt`; the
3983
+ * `documentId` tiebreaker keeps consecutive batches disjoint even when every row ties.
3984
+ * - **Each row is yielded at most once**, for as long as `updatedAt` only ever moves forward —
3985
+ * which is what `record()` does, since it always stamps `now`.
3986
+ *
3987
+ * What this is **not**: a snapshot, or a repeatable read. The sweep observes the table as it is
3988
+ * when each batch is fetched, so:
3989
+ * - A row **inserted** mid-sweep by `record()` is stamped `now`. The order is newest-first, so it
3990
+ * sorts ahead of a cursor the sweep has already moved past, and is not visited. A sweep
3991
+ * therefore never sees documents ingested after it started — the behaviour an orphan sweep
3992
+ * wants, since a document that arrived while you were sweeping is not an orphan. (A *direct*
3993
+ * insert with a backdated `updatedAt` lands ahead of the cursor and **is** visited; nothing in
3994
+ * this class writes one.)
3995
+ * - A row **re-ingested** mid-sweep has its `updatedAt` bumped to `now`, moving it ahead of the
3996
+ * cursor for the same reason. If the sweep had already passed it, it is not visited twice; if it
3997
+ * had not, it is **missed for this pass**. That is the honest limit: against a concurrent
3998
+ * writer `iterate` guarantees "at most once", not "at least once". Sweeps that must not miss a
3999
+ * concurrently-rewritten row should be idempotent and run again.
4000
+ * - Only a row whose `updatedAt` moves *backwards* — which needs a direct write — can be yielded
4001
+ * twice.
4002
+ * - `collection` / `status` are re-evaluated per batch, so a row that stops matching mid-sweep
4003
+ * stops being visited.
4004
+ *
4005
+ * There is no `limit`/`offset` here on purpose: `where` says *which* rows, `options` says how the
4006
+ * sweep is run. A sweep that stops early stops by `break`ing out of the `for await`.
4007
+ */
4008
+ iterate(where?: RagIngestionLogWhere, options?: RagIngestionLogIterateOptions): AsyncGenerator<RagIngestionLogRow, void, undefined>;
4009
+ /**
4010
+ * Just the document ids of the matching rows, in {@link RAG_INGESTION_LOG_PAGE_ORDER}.
4011
+ *
4012
+ * Returns **all** of them — no 200-row cap, unlike `list` — by sweeping on {@link iterate}'s
4013
+ * keyset internally, so it is correct against concurrent deletes for the same reason `iterate`
4014
+ * is. What the cap protects against is hydrating an unbounded number of wide rows (`error` is a
4015
+ * TEXT column); this selects two columns — the id, plus the `updatedAt` the cursor needs — and
4016
+ * keeps only the ids, so the peak footprint is one batch of two-column rows plus a list of
4017
+ * strings whose size *is* the answer the caller asked for.
4018
+ *
4019
+ * For callers that need the id set of a collection and nothing else: an orphan sweep unioning the
4020
+ * log against the vector store's own document list.
4021
+ */
4022
+ listDocumentIds(where?: RagIngestionLogWhere, options?: {
4023
+ batchSize?: number;
4024
+ }): Promise<string[]>;
4025
+ /** The latest recorded outcome for one document, or null if it was never attempted. */
4026
+ get(documentId: string): Promise<RagIngestionLogRow | null>;
4027
+ /** Forget one document's record. Returns whether a row was actually removed. */
4028
+ remove(documentId: string): Promise<boolean>;
4029
+ /** Forget every record for a collection — for when the collection itself is deleted. */
4030
+ removeByCollection(collection: string): Promise<number>;
4031
+ /**
4032
+ * The keyset sweep both {@link iterate} and {@link listDocumentIds} are made of. `page` decides
4033
+ * how wide a row is — whole rows for `iterate`, two columns for `listDocumentIds` — and the
4034
+ * `R extends RagIngestionLogCursor` bound says the only thing the sweep needs back: a row it can
4035
+ * read the next cursor off.
4036
+ *
4037
+ * The cursor advances **per yielded row**, not per batch, so a consumer that `break`s mid-batch
4038
+ * leaves it on the last row it actually saw. It is two column values read off that row, so a row
4039
+ * leaving the table cannot move it — the whole reason this is delete-safe by construction.
4040
+ */
4041
+ private sweep;
4042
+ private where;
4043
+ /**
4044
+ * The coordinates filter AND'd with "strictly after `cursor` in
4045
+ * {@link RAG_INGESTION_LOG_PAGE_ORDER}".
4046
+ *
4047
+ * The order is `updatedAt desc, documentId asc`, so "after" means an older timestamp, or the same
4048
+ * timestamp and a larger id. Both halves are needed: the `<` alone would re-yield every row tied
4049
+ * with the cursor, and dropping the tie branch would skip them instead.
4050
+ */
4051
+ private keyset;
4052
+ /**
4053
+ * Upsert one outcome. Keyed by document id so the row always reflects the *current* state — a
4054
+ * retry that succeeds overwrites the failure it replaces, rather than leaving a stale error next
4055
+ * to a working document.
4056
+ */
4057
+ private record;
4058
+ private track;
4059
+ }
4060
+
2857
4061
  /** Options for {@link DrizzleAgentStoreModule.forRoot}. The app owns and supplies the db handle. */
2858
4062
  interface DrizzleAgentStoreModuleOptions {
2859
4063
  /** A Drizzle SQLite database instance (`drizzle(client, { schema: agentSchema })`). */
@@ -2864,6 +4068,18 @@ interface DrizzleAgentStoreModuleOptions {
2864
4068
  * table the single source of cost truth without touching `agent_model_pricing`.
2865
4069
  */
2866
4070
  pricingStore?: Type<AgentPricingStore>;
4071
+ /**
4072
+ * Record every RAG ingestion outcome into `rag_ingestion_log` by subscribing to the `aviary:rag:*`
4073
+ * diagnostics channels (default `true`, matching the MikroORM adapter). This is the only place a
4074
+ * *failed* or *skipped* document is visible — one that produced no chunks doesn't exist as far as
4075
+ * `VectorStore.listDocuments()` is concerned. Set `false` if you don't ingest media into RAG, or
4076
+ * record outcomes yourself.
4077
+ *
4078
+ * The table has to exist: `ensureAgentSchema` creates it, or write the `CREATE TABLE` into
4079
+ * your own migrations. Writes are best-effort, so a missing table costs a warning per ingestion
4080
+ * rather than a failed ingestion.
4081
+ */
4082
+ ragIngestionLog?: boolean;
2867
4083
  }
2868
4084
  /**
2869
4085
  * Binds {@link DrizzleAgentStore} to the {@link AGENT_STORE} token consumed by
@@ -2886,4 +4102,4 @@ declare class DrizzleAgentStoreModule {
2886
4102
  static forRoot(options: DrizzleAgentStoreModuleOptions): DynamicModule;
2887
4103
  }
2888
4104
 
2889
- export { type AgentDrizzleDb, type AgentMessageRow, type AgentRunRow, type AgentRunStatus, type AgentThreadRow, DrizzleAgentStore, DrizzleAgentStoreModule, type DrizzleAgentStoreModuleOptions, DrizzleGovernanceQueries, DrizzlePricingStore, agentMessage, agentModelPricing, agentRun, agentSchema, agentThread, agentTokenUsage, agentToolCall, ensureAgentSchema };
4105
+ export { type AgentDrizzleDb, type AgentMemoryRow, type AgentMessageRow, type AgentRunRow, type AgentRunStatus, type AgentThreadRow, DrizzleAgentStore, DrizzleAgentStoreModule, type DrizzleAgentStoreModuleOptions, DrizzleGovernanceQueries, DrizzleMemoryProvider, DrizzlePricingStore, DrizzleRagIngestionLog, RAG_INGESTION_LOG_PAGE_ORDER, type RagIngestionLogCursor, type RagIngestionLogIterateOptions, type RagIngestionLogQuery, type RagIngestionLogRow, type RagIngestionLogWhere, type RagIngestionStatus, agentMemory, agentMessage, agentModelPricing, agentRun, agentSchema, agentThread, agentTokenUsage, agentToolCall, ensureAgentSchema, ragIngestionLog };