@dudousxd/nestjs-agent-store-drizzle 0.8.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,11 +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, MessageUsage, ToolKind, ToolCallStatus, UsagePurpose, AgentStore, CreateThreadInput, ThreadSummary, ThreadDetail, 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';
4
- import { Type, DynamicModule } from '@nestjs/common';
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
+ export { ThreadTurnPage, ThreadTurnQuery } from '@dudousxd/nestjs-agent-core';
5
+ import { TablesRelationalConfig, SQL } from 'drizzle-orm';
6
+ import { OnModuleInit, OnModuleDestroy, Type, DynamicModule } from '@nestjs/common';
5
7
 
6
8
  /**
7
9
  * Drizzle schema mirroring the MikroORM agent entities (same logical columns/relations):
8
- * 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
9
12
  * db-test runs on an in-memory better-sqlite3; timestamps are stored as integer epoch-ms columns
10
13
  * (`{ mode: 'timestamp_ms' }`) which Drizzle round-trips to/from JS `Date`, and the model-facing
11
14
  * message extras (tool calls/results, follow-ups, usage) live in JSON `text` columns.
@@ -131,6 +134,25 @@ declare const agentThread: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
131
134
  }, {}, {
132
135
  length: number | undefined;
133
136
  }>;
137
+ defaultAgent: drizzle_orm_sqlite_core.SQLiteColumn<{
138
+ name: "default_agent";
139
+ tableName: "agent_thread";
140
+ dataType: "string";
141
+ columnType: "SQLiteText";
142
+ data: string;
143
+ driverParam: string;
144
+ notNull: false;
145
+ hasDefault: false;
146
+ isPrimaryKey: false;
147
+ isAutoincrement: false;
148
+ hasRuntimeDefault: false;
149
+ enumValues: [string, ...string[]];
150
+ baseColumn: never;
151
+ identity: undefined;
152
+ generated: undefined;
153
+ }, {}, {
154
+ length: number | undefined;
155
+ }>;
134
156
  createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
135
157
  name: "created_at";
136
158
  tableName: "agent_thread";
@@ -309,6 +331,25 @@ declare const agentMessage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
309
331
  }, {}, {
310
332
  $type: ToolResult[];
311
333
  }>;
334
+ attachments: drizzle_orm_sqlite_core.SQLiteColumn<{
335
+ name: "attachments";
336
+ tableName: "agent_message";
337
+ dataType: "json";
338
+ columnType: "SQLiteTextJson";
339
+ data: MessageAttachment[];
340
+ driverParam: string;
341
+ notNull: false;
342
+ hasDefault: false;
343
+ isPrimaryKey: false;
344
+ isAutoincrement: false;
345
+ hasRuntimeDefault: false;
346
+ enumValues: undefined;
347
+ baseColumn: never;
348
+ identity: undefined;
349
+ generated: undefined;
350
+ }, {}, {
351
+ $type: MessageAttachment[];
352
+ }>;
312
353
  followUps: drizzle_orm_sqlite_core.SQLiteColumn<{
313
354
  name: "follow_ups";
314
355
  tableName: "agent_message";
@@ -366,6 +407,25 @@ declare const agentMessage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
366
407
  }, {}, {
367
408
  length: number | undefined;
368
409
  }>;
410
+ runId: drizzle_orm_sqlite_core.SQLiteColumn<{
411
+ name: "run_id";
412
+ tableName: "agent_message";
413
+ dataType: "string";
414
+ columnType: "SQLiteText";
415
+ data: string;
416
+ driverParam: string;
417
+ notNull: false;
418
+ hasDefault: false;
419
+ isPrimaryKey: false;
420
+ isAutoincrement: false;
421
+ hasRuntimeDefault: false;
422
+ enumValues: [string, ...string[]];
423
+ baseColumn: never;
424
+ identity: undefined;
425
+ generated: undefined;
426
+ }, {}, {
427
+ length: number | undefined;
428
+ }>;
369
429
  createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
370
430
  name: "created_at";
371
431
  tableName: "agent_message";
@@ -386,7 +446,13 @@ declare const agentMessage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
386
446
  };
387
447
  dialect: "sqlite";
388
448
  }>;
389
- /** A tool call requested during an assistant turn. The pk is the model-supplied `toolCallId`. */
449
+ /**
450
+ * A tool call requested during an assistant turn. The pk is the model-supplied `toolCallId`.
451
+ *
452
+ * `messageId` carries its own index rather than relying on the foreign key: MySQL indexes a foreign
453
+ * key column for you, Postgres does not — and every message-scoped read here filters on it (the
454
+ * thread reader's `IN (…)` over a turn's calls, and `truncateFrom`'s delete).
455
+ */
390
456
  declare const agentToolCall: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
391
457
  name: "agent_tool_call";
392
458
  schema: undefined;
@@ -1006,8 +1072,14 @@ declare const agentModelPricing: drizzle_orm_sqlite_core.SQLiteTableWithColumns<
1006
1072
  };
1007
1073
  dialect: "sqlite";
1008
1074
  }>;
1009
- /** A run's lifecycle status. Not part of the core SPI (that surfaces `string`) — internal only. */
1010
- type AgentRunStatus = 'running' | 'completed' | 'failed';
1075
+ /**
1076
+ * A run's lifecycle status. Not part of the core SPI (that surfaces `string`) — internal only.
1077
+ *
1078
+ * `cancelled` is a third TERMINAL, not a flavour of `failed`: someone asked the run to stop and it
1079
+ * did. A reliability read that folded it into `failed` would page whoever is on call for model
1080
+ * failures every time a user pressed Stop.
1081
+ */
1082
+ type AgentRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
1011
1083
  /**
1012
1084
  * One recorded run (turn) outcome — the durable half of what `aviary:agent:*` diagnostics report
1013
1085
  * ephemerally. Written by {@link import('./drizzle-agent-store.js').DrizzleAgentStore.recordRunStart}/
@@ -1241,192 +1313,955 @@ declare const agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1241
1313
  }, {}, {
1242
1314
  length: number | undefined;
1243
1315
  }>;
1316
+ parentRunId: drizzle_orm_sqlite_core.SQLiteColumn<{
1317
+ name: "parent_run_id";
1318
+ tableName: "agent_run";
1319
+ dataType: "string";
1320
+ columnType: "SQLiteText";
1321
+ data: string;
1322
+ driverParam: string;
1323
+ notNull: false;
1324
+ hasDefault: false;
1325
+ isPrimaryKey: false;
1326
+ isAutoincrement: false;
1327
+ hasRuntimeDefault: false;
1328
+ enumValues: [string, ...string[]];
1329
+ baseColumn: never;
1330
+ identity: undefined;
1331
+ generated: undefined;
1332
+ }, {}, {
1333
+ length: number | undefined;
1334
+ }>;
1244
1335
  };
1245
1336
  dialect: "sqlite";
1246
1337
  }>;
1247
- /** The six agent tables as one schema object, ready for `drizzle(client, { schema })`. */
1248
- declare const agentSchema: {
1249
- agentThread: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1250
- name: "agent_thread";
1251
- schema: undefined;
1252
- columns: {
1253
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
1254
- name: "id";
1255
- tableName: "agent_thread";
1256
- dataType: "string";
1257
- columnType: "SQLiteText";
1258
- data: string;
1259
- driverParam: string;
1260
- notNull: true;
1261
- hasDefault: false;
1262
- isPrimaryKey: true;
1263
- isAutoincrement: false;
1264
- hasRuntimeDefault: false;
1265
- enumValues: [string, ...string[]];
1266
- baseColumn: never;
1267
- identity: undefined;
1268
- generated: undefined;
1269
- }, {}, {
1270
- length: number | undefined;
1271
- }>;
1272
- actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1273
- name: "actor_ref";
1274
- tableName: "agent_thread";
1275
- dataType: "string";
1276
- columnType: "SQLiteText";
1277
- data: string;
1278
- driverParam: string;
1279
- notNull: true;
1280
- hasDefault: false;
1281
- isPrimaryKey: false;
1282
- isAutoincrement: false;
1283
- hasRuntimeDefault: false;
1284
- enumValues: [string, ...string[]];
1285
- baseColumn: never;
1286
- identity: undefined;
1287
- generated: undefined;
1288
- }, {}, {
1289
- length: number | undefined;
1290
- }>;
1291
- tenantRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1292
- name: "tenant_ref";
1293
- tableName: "agent_thread";
1294
- dataType: "string";
1295
- columnType: "SQLiteText";
1296
- data: string;
1297
- driverParam: string;
1298
- notNull: false;
1299
- hasDefault: false;
1300
- isPrimaryKey: false;
1301
- isAutoincrement: false;
1302
- hasRuntimeDefault: false;
1303
- enumValues: [string, ...string[]];
1304
- baseColumn: never;
1305
- identity: undefined;
1306
- generated: undefined;
1307
- }, {}, {
1308
- length: number | undefined;
1309
- }>;
1310
- title: drizzle_orm_sqlite_core.SQLiteColumn<{
1311
- name: "title";
1312
- tableName: "agent_thread";
1313
- dataType: "string";
1314
- columnType: "SQLiteText";
1315
- data: string;
1316
- driverParam: string;
1317
- notNull: true;
1318
- hasDefault: false;
1319
- isPrimaryKey: false;
1320
- isAutoincrement: false;
1321
- hasRuntimeDefault: false;
1322
- enumValues: [string, ...string[]];
1323
- baseColumn: never;
1324
- identity: undefined;
1325
- generated: undefined;
1326
- }, {}, {
1327
- length: number | undefined;
1328
- }>;
1329
- transient: drizzle_orm_sqlite_core.SQLiteColumn<{
1330
- name: "transient";
1331
- tableName: "agent_thread";
1332
- dataType: "boolean";
1333
- columnType: "SQLiteBoolean";
1334
- data: boolean;
1335
- driverParam: number;
1336
- notNull: true;
1337
- hasDefault: true;
1338
- isPrimaryKey: false;
1339
- isAutoincrement: false;
1340
- hasRuntimeDefault: false;
1341
- enumValues: undefined;
1342
- baseColumn: never;
1343
- identity: undefined;
1344
- generated: undefined;
1345
- }, {}, {}>;
1346
- activeStreamId: drizzle_orm_sqlite_core.SQLiteColumn<{
1347
- name: "active_stream_id";
1348
- tableName: "agent_thread";
1349
- dataType: "string";
1350
- columnType: "SQLiteText";
1351
- data: string;
1352
- driverParam: string;
1353
- notNull: false;
1354
- hasDefault: false;
1355
- isPrimaryKey: false;
1356
- isAutoincrement: false;
1357
- hasRuntimeDefault: false;
1358
- enumValues: [string, ...string[]];
1359
- baseColumn: never;
1360
- identity: undefined;
1361
- generated: undefined;
1362
- }, {}, {
1363
- length: number | undefined;
1364
- }>;
1365
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1366
- name: "created_at";
1367
- tableName: "agent_thread";
1368
- dataType: "date";
1369
- columnType: "SQLiteTimestamp";
1370
- data: Date;
1371
- driverParam: number;
1372
- notNull: true;
1373
- hasDefault: false;
1374
- isPrimaryKey: false;
1375
- isAutoincrement: false;
1376
- hasRuntimeDefault: false;
1377
- enumValues: undefined;
1378
- baseColumn: never;
1379
- identity: undefined;
1380
- generated: undefined;
1381
- }, {}, {}>;
1382
- updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1383
- name: "updated_at";
1384
- tableName: "agent_thread";
1385
- dataType: "date";
1386
- columnType: "SQLiteTimestamp";
1387
- data: Date;
1388
- driverParam: number;
1389
- notNull: true;
1390
- hasDefault: false;
1391
- isPrimaryKey: false;
1392
- isAutoincrement: false;
1393
- hasRuntimeDefault: false;
1394
- enumValues: undefined;
1395
- baseColumn: never;
1396
- identity: undefined;
1397
- generated: undefined;
1398
- }, {}, {}>;
1399
- deletedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1400
- name: "deleted_at";
1401
- tableName: "agent_thread";
1402
- dataType: "date";
1403
- columnType: "SQLiteTimestamp";
1404
- data: Date;
1405
- driverParam: number;
1406
- notNull: false;
1407
- hasDefault: false;
1408
- isPrimaryKey: false;
1409
- isAutoincrement: false;
1410
- hasRuntimeDefault: false;
1411
- enumValues: undefined;
1412
- baseColumn: never;
1413
- identity: undefined;
1414
- generated: undefined;
1415
- }, {}, {}>;
1416
- };
1417
- dialect: "sqlite";
1418
- }>;
1419
- agentMessage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1420
- name: "agent_message";
1421
- schema: undefined;
1422
- columns: {
1423
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
1424
- name: "id";
1425
- tableName: "agent_message";
1426
- dataType: "string";
1427
- columnType: "SQLiteText";
1428
- data: string;
1429
- driverParam: string;
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 })`. */
1830
+ declare const agentSchema: {
1831
+ agentThread: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1832
+ name: "agent_thread";
1833
+ schema: undefined;
1834
+ columns: {
1835
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
1836
+ name: "id";
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";
2027
+ dataType: "string";
2028
+ columnType: "SQLiteText";
2029
+ data: string;
2030
+ driverParam: string;
2031
+ notNull: true;
2032
+ hasDefault: false;
2033
+ isPrimaryKey: true;
2034
+ isAutoincrement: false;
2035
+ hasRuntimeDefault: false;
2036
+ enumValues: [string, ...string[]];
2037
+ baseColumn: never;
2038
+ identity: undefined;
2039
+ generated: undefined;
2040
+ }, {}, {
2041
+ length: number | undefined;
2042
+ }>;
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";
2085
+ dataType: "string";
2086
+ columnType: "SQLiteText";
2087
+ data: string;
2088
+ driverParam: string;
2089
+ notNull: true;
2090
+ hasDefault: false;
2091
+ isPrimaryKey: false;
2092
+ isAutoincrement: false;
2093
+ hasRuntimeDefault: false;
2094
+ enumValues: [string, ...string[]];
2095
+ baseColumn: never;
2096
+ identity: undefined;
2097
+ generated: undefined;
2098
+ }, {}, {
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[];
2138
+ }>;
2139
+ attachments: drizzle_orm_sqlite_core.SQLiteColumn<{
2140
+ name: "attachments";
2141
+ tableName: "agent_message";
2142
+ dataType: "json";
2143
+ columnType: "SQLiteTextJson";
2144
+ data: MessageAttachment[];
2145
+ driverParam: string;
2146
+ notNull: false;
2147
+ hasDefault: false;
2148
+ isPrimaryKey: false;
2149
+ isAutoincrement: false;
2150
+ hasRuntimeDefault: false;
2151
+ enumValues: undefined;
2152
+ baseColumn: never;
2153
+ identity: undefined;
2154
+ generated: undefined;
2155
+ }, {}, {
2156
+ $type: MessageAttachment[];
2157
+ }>;
2158
+ followUps: drizzle_orm_sqlite_core.SQLiteColumn<{
2159
+ name: "follow_ups";
2160
+ tableName: "agent_message";
2161
+ dataType: "json";
2162
+ columnType: "SQLiteTextJson";
2163
+ data: string[];
2164
+ driverParam: string;
2165
+ notNull: false;
2166
+ hasDefault: false;
2167
+ isPrimaryKey: false;
2168
+ isAutoincrement: false;
2169
+ hasRuntimeDefault: false;
2170
+ enumValues: undefined;
2171
+ baseColumn: never;
2172
+ identity: undefined;
2173
+ generated: undefined;
2174
+ }, {}, {
2175
+ $type: string[];
2176
+ }>;
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;
2186
+ isPrimaryKey: false;
2187
+ isAutoincrement: false;
2188
+ hasRuntimeDefault: false;
2189
+ enumValues: undefined;
2190
+ baseColumn: never;
2191
+ identity: undefined;
2192
+ generated: undefined;
2193
+ }, {}, {
2194
+ $type: MessageUsage;
2195
+ }>;
2196
+ agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
2197
+ name: "agent_name";
2198
+ tableName: "agent_message";
2199
+ dataType: "string";
2200
+ columnType: "SQLiteText";
2201
+ data: string;
2202
+ driverParam: string;
2203
+ notNull: false;
2204
+ hasDefault: false;
2205
+ isPrimaryKey: false;
2206
+ isAutoincrement: false;
2207
+ hasRuntimeDefault: false;
2208
+ enumValues: [string, ...string[]];
2209
+ baseColumn: never;
2210
+ identity: undefined;
2211
+ generated: undefined;
2212
+ }, {}, {
2213
+ length: number | undefined;
2214
+ }>;
2215
+ runId: drizzle_orm_sqlite_core.SQLiteColumn<{
2216
+ name: "run_id";
2217
+ tableName: "agent_message";
2218
+ dataType: "string";
2219
+ columnType: "SQLiteText";
2220
+ data: string;
2221
+ driverParam: string;
2222
+ notNull: false;
2223
+ hasDefault: false;
2224
+ isPrimaryKey: false;
2225
+ isAutoincrement: false;
2226
+ hasRuntimeDefault: false;
2227
+ enumValues: [string, ...string[]];
2228
+ baseColumn: never;
2229
+ identity: undefined;
2230
+ generated: undefined;
2231
+ }, {}, {
2232
+ length: number | undefined;
2233
+ }>;
2234
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2235
+ name: "created_at";
2236
+ tableName: "agent_message";
2237
+ dataType: "date";
2238
+ columnType: "SQLiteTimestamp";
2239
+ data: Date;
2240
+ driverParam: number;
2241
+ notNull: true;
2242
+ hasDefault: false;
2243
+ isPrimaryKey: false;
2244
+ isAutoincrement: false;
2245
+ hasRuntimeDefault: false;
2246
+ enumValues: undefined;
2247
+ baseColumn: never;
2248
+ identity: undefined;
2249
+ generated: undefined;
2250
+ }, {}, {}>;
2251
+ };
2252
+ dialect: "sqlite";
2253
+ }>;
2254
+ agentToolCall: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2255
+ name: "agent_tool_call";
2256
+ schema: undefined;
2257
+ columns: {
2258
+ id: drizzle_orm_sqlite_core.SQLiteColumn<{
2259
+ name: "id";
2260
+ tableName: "agent_tool_call";
2261
+ dataType: "string";
2262
+ columnType: "SQLiteText";
2263
+ data: string;
2264
+ driverParam: string;
1430
2265
  notNull: true;
1431
2266
  hasDefault: false;
1432
2267
  isPrimaryKey: true;
@@ -1439,9 +2274,9 @@ declare const agentSchema: {
1439
2274
  }, {}, {
1440
2275
  length: number | undefined;
1441
2276
  }>;
1442
- threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
1443
- name: "thread_id";
1444
- tableName: "agent_message";
2277
+ messageId: drizzle_orm_sqlite_core.SQLiteColumn<{
2278
+ name: "message_id";
2279
+ tableName: "agent_tool_call";
1445
2280
  dataType: "string";
1446
2281
  columnType: "SQLiteText";
1447
2282
  data: string;
@@ -1458,12 +2293,12 @@ declare const agentSchema: {
1458
2293
  }, {}, {
1459
2294
  length: number | undefined;
1460
2295
  }>;
1461
- role: drizzle_orm_sqlite_core.SQLiteColumn<{
1462
- name: "role";
1463
- tableName: "agent_message";
2296
+ toolName: drizzle_orm_sqlite_core.SQLiteColumn<{
2297
+ name: "tool_name";
2298
+ tableName: "agent_tool_call";
1464
2299
  dataType: "string";
1465
2300
  columnType: "SQLiteText";
1466
- data: MessageRole;
2301
+ data: string;
1467
2302
  driverParam: string;
1468
2303
  notNull: true;
1469
2304
  hasDefault: false;
@@ -1476,14 +2311,13 @@ declare const agentSchema: {
1476
2311
  generated: undefined;
1477
2312
  }, {}, {
1478
2313
  length: number | undefined;
1479
- $type: MessageRole;
1480
2314
  }>;
1481
- content: drizzle_orm_sqlite_core.SQLiteColumn<{
1482
- name: "content";
1483
- tableName: "agent_message";
2315
+ toolType: drizzle_orm_sqlite_core.SQLiteColumn<{
2316
+ name: "tool_type";
2317
+ tableName: "agent_tool_call";
1484
2318
  dataType: "string";
1485
2319
  columnType: "SQLiteText";
1486
- data: string;
2320
+ data: ToolKind;
1487
2321
  driverParam: string;
1488
2322
  notNull: true;
1489
2323
  hasDefault: false;
@@ -1496,13 +2330,14 @@ declare const agentSchema: {
1496
2330
  generated: undefined;
1497
2331
  }, {}, {
1498
2332
  length: number | undefined;
2333
+ $type: ToolKind;
1499
2334
  }>;
1500
- toolCalls: drizzle_orm_sqlite_core.SQLiteColumn<{
1501
- name: "tool_calls";
1502
- tableName: "agent_message";
2335
+ input: drizzle_orm_sqlite_core.SQLiteColumn<{
2336
+ name: "input";
2337
+ tableName: "agent_tool_call";
1503
2338
  dataType: "json";
1504
2339
  columnType: "SQLiteTextJson";
1505
- data: ToolCallRequest[];
2340
+ data: unknown;
1506
2341
  driverParam: string;
1507
2342
  notNull: false;
1508
2343
  hasDefault: false;
@@ -1513,15 +2348,13 @@ declare const agentSchema: {
1513
2348
  baseColumn: never;
1514
2349
  identity: undefined;
1515
2350
  generated: undefined;
1516
- }, {}, {
1517
- $type: ToolCallRequest[];
1518
- }>;
1519
- toolResults: drizzle_orm_sqlite_core.SQLiteColumn<{
1520
- name: "tool_results";
1521
- tableName: "agent_message";
2351
+ }, {}, {}>;
2352
+ output: drizzle_orm_sqlite_core.SQLiteColumn<{
2353
+ name: "output";
2354
+ tableName: "agent_tool_call";
1522
2355
  dataType: "json";
1523
2356
  columnType: "SQLiteTextJson";
1524
- data: ToolResult[];
2357
+ data: unknown;
1525
2358
  driverParam: string;
1526
2359
  notNull: false;
1527
2360
  hasDefault: false;
@@ -1532,35 +2365,53 @@ declare const agentSchema: {
1532
2365
  baseColumn: never;
1533
2366
  identity: undefined;
1534
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;
1535
2385
  }, {}, {
1536
- $type: ToolResult[];
2386
+ length: number | undefined;
2387
+ $type: ToolCallStatus;
1537
2388
  }>;
1538
- followUps: drizzle_orm_sqlite_core.SQLiteColumn<{
1539
- name: "follow_ups";
1540
- tableName: "agent_message";
1541
- dataType: "json";
1542
- columnType: "SQLiteTextJson";
1543
- data: string[];
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;
1544
2395
  driverParam: string;
1545
2396
  notNull: false;
1546
2397
  hasDefault: false;
1547
2398
  isPrimaryKey: false;
1548
2399
  isAutoincrement: false;
1549
2400
  hasRuntimeDefault: false;
1550
- enumValues: undefined;
2401
+ enumValues: [string, ...string[]];
1551
2402
  baseColumn: never;
1552
2403
  identity: undefined;
1553
2404
  generated: undefined;
1554
2405
  }, {}, {
1555
- $type: string[];
2406
+ length: number | undefined;
1556
2407
  }>;
1557
- usage: drizzle_orm_sqlite_core.SQLiteColumn<{
1558
- name: "usage";
1559
- tableName: "agent_message";
1560
- dataType: "json";
1561
- columnType: "SQLiteTextJson";
1562
- data: MessageUsage;
1563
- 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;
1564
2415
  notNull: false;
1565
2416
  hasDefault: false;
1566
2417
  isPrimaryKey: false;
@@ -1570,12 +2421,63 @@ declare const agentSchema: {
1570
2421
  baseColumn: never;
1571
2422
  identity: undefined;
1572
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;
1573
2441
  }, {}, {
1574
- $type: MessageUsage;
2442
+ length: number | undefined;
1575
2443
  }>;
1576
- agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
1577
- name: "agent_name";
1578
- tableName: "agent_message";
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;
2468
+ notNull: false;
2469
+ hasDefault: false;
2470
+ isPrimaryKey: false;
2471
+ isAutoincrement: false;
2472
+ hasRuntimeDefault: false;
2473
+ enumValues: undefined;
2474
+ baseColumn: never;
2475
+ identity: undefined;
2476
+ generated: undefined;
2477
+ }, {}, {}>;
2478
+ runId: drizzle_orm_sqlite_core.SQLiteColumn<{
2479
+ name: "run_id";
2480
+ tableName: "agent_tool_call";
1579
2481
  dataType: "string";
1580
2482
  columnType: "SQLiteText";
1581
2483
  data: string;
@@ -1592,40 +2494,61 @@ declare const agentSchema: {
1592
2494
  }, {}, {
1593
2495
  length: number | undefined;
1594
2496
  }>;
1595
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1596
- name: "created_at";
1597
- tableName: "agent_message";
1598
- dataType: "date";
1599
- columnType: "SQLiteTimestamp";
1600
- data: Date;
1601
- driverParam: number;
1602
- notNull: true;
1603
- hasDefault: false;
1604
- isPrimaryKey: false;
1605
- isAutoincrement: false;
1606
- hasRuntimeDefault: false;
1607
- enumValues: undefined;
1608
- baseColumn: never;
1609
- identity: undefined;
1610
- generated: undefined;
1611
- }, {}, {}>;
1612
- };
1613
- dialect: "sqlite";
1614
- }>;
1615
- agentToolCall: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1616
- name: "agent_tool_call";
1617
- schema: undefined;
1618
- columns: {
1619
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
1620
- name: "id";
1621
- tableName: "agent_tool_call";
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";
2507
+ dataType: "string";
2508
+ columnType: "SQLiteText";
2509
+ data: string;
2510
+ driverParam: string;
2511
+ notNull: true;
2512
+ hasDefault: false;
2513
+ isPrimaryKey: true;
2514
+ isAutoincrement: false;
2515
+ hasRuntimeDefault: false;
2516
+ enumValues: [string, ...string[]];
2517
+ baseColumn: never;
2518
+ identity: undefined;
2519
+ generated: undefined;
2520
+ }, {}, {
2521
+ length: number | undefined;
2522
+ }>;
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;
2530
+ notNull: true;
2531
+ hasDefault: false;
2532
+ isPrimaryKey: false;
2533
+ isAutoincrement: false;
2534
+ hasRuntimeDefault: false;
2535
+ enumValues: [string, ...string[]];
2536
+ baseColumn: never;
2537
+ identity: undefined;
2538
+ generated: undefined;
2539
+ }, {}, {
2540
+ length: number | undefined;
2541
+ }>;
2542
+ actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
2543
+ name: "actor_ref";
2544
+ tableName: "agent_token_usage";
1622
2545
  dataType: "string";
1623
2546
  columnType: "SQLiteText";
1624
2547
  data: string;
1625
2548
  driverParam: string;
1626
2549
  notNull: true;
1627
2550
  hasDefault: false;
1628
- isPrimaryKey: true;
2551
+ isPrimaryKey: false;
1629
2552
  isAutoincrement: false;
1630
2553
  hasRuntimeDefault: false;
1631
2554
  enumValues: [string, ...string[]];
@@ -1637,12 +2560,12 @@ declare const agentSchema: {
1637
2560
  }>;
1638
2561
  messageId: drizzle_orm_sqlite_core.SQLiteColumn<{
1639
2562
  name: "message_id";
1640
- tableName: "agent_tool_call";
2563
+ tableName: "agent_token_usage";
1641
2564
  dataType: "string";
1642
2565
  columnType: "SQLiteText";
1643
2566
  data: string;
1644
2567
  driverParam: string;
1645
- notNull: true;
2568
+ notNull: false;
1646
2569
  hasDefault: false;
1647
2570
  isPrimaryKey: false;
1648
2571
  isAutoincrement: false;
@@ -1654,9 +2577,9 @@ declare const agentSchema: {
1654
2577
  }, {}, {
1655
2578
  length: number | undefined;
1656
2579
  }>;
1657
- toolName: drizzle_orm_sqlite_core.SQLiteColumn<{
1658
- name: "tool_name";
1659
- tableName: "agent_tool_call";
2580
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2581
+ name: "model_id";
2582
+ tableName: "agent_token_usage";
1660
2583
  dataType: "string";
1661
2584
  columnType: "SQLiteText";
1662
2585
  data: string;
@@ -1673,12 +2596,12 @@ declare const agentSchema: {
1673
2596
  }, {}, {
1674
2597
  length: number | undefined;
1675
2598
  }>;
1676
- toolType: drizzle_orm_sqlite_core.SQLiteColumn<{
1677
- name: "tool_type";
1678
- tableName: "agent_tool_call";
2599
+ purpose: drizzle_orm_sqlite_core.SQLiteColumn<{
2600
+ name: "purpose";
2601
+ tableName: "agent_token_usage";
1679
2602
  dataType: "string";
1680
2603
  columnType: "SQLiteText";
1681
- data: ToolKind;
2604
+ data: UsagePurpose;
1682
2605
  driverParam: string;
1683
2606
  notNull: true;
1684
2607
  hasDefault: false;
@@ -1691,15 +2614,49 @@ declare const agentSchema: {
1691
2614
  generated: undefined;
1692
2615
  }, {}, {
1693
2616
  length: number | undefined;
1694
- $type: ToolKind;
2617
+ $type: UsagePurpose;
1695
2618
  }>;
1696
- input: drizzle_orm_sqlite_core.SQLiteColumn<{
1697
- name: "input";
1698
- tableName: "agent_tool_call";
1699
- dataType: "json";
1700
- columnType: "SQLiteTextJson";
1701
- data: unknown;
1702
- 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;
1703
2660
  notNull: false;
1704
2661
  hasDefault: false;
1705
2662
  isPrimaryKey: false;
@@ -1710,13 +2667,13 @@ declare const agentSchema: {
1710
2667
  identity: undefined;
1711
2668
  generated: undefined;
1712
2669
  }, {}, {}>;
1713
- output: drizzle_orm_sqlite_core.SQLiteColumn<{
1714
- name: "output";
1715
- tableName: "agent_tool_call";
1716
- dataType: "json";
1717
- columnType: "SQLiteTextJson";
1718
- data: unknown;
1719
- 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;
1720
2677
  notNull: false;
1721
2678
  hasDefault: false;
1722
2679
  isPrimaryKey: false;
@@ -1727,16 +2684,57 @@ declare const agentSchema: {
1727
2684
  identity: undefined;
1728
2685
  generated: undefined;
1729
2686
  }, {}, {}>;
1730
- status: drizzle_orm_sqlite_core.SQLiteColumn<{
1731
- name: "status";
1732
- 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";
1733
2731
  dataType: "string";
1734
2732
  columnType: "SQLiteText";
1735
- data: ToolCallStatus;
2733
+ data: string;
1736
2734
  driverParam: string;
1737
2735
  notNull: true;
1738
2736
  hasDefault: false;
1739
- isPrimaryKey: false;
2737
+ isPrimaryKey: true;
1740
2738
  isAutoincrement: false;
1741
2739
  hasRuntimeDefault: false;
1742
2740
  enumValues: [string, ...string[]];
@@ -1745,16 +2743,15 @@ declare const agentSchema: {
1745
2743
  generated: undefined;
1746
2744
  }, {}, {
1747
2745
  length: number | undefined;
1748
- $type: ToolCallStatus;
1749
2746
  }>;
1750
- executedByRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1751
- name: "executed_by_ref";
1752
- tableName: "agent_tool_call";
2747
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2748
+ name: "model_id";
2749
+ tableName: "agent_model_pricing";
1753
2750
  dataType: "string";
1754
2751
  columnType: "SQLiteText";
1755
2752
  data: string;
1756
2753
  driverParam: string;
1757
- notNull: false;
2754
+ notNull: true;
1758
2755
  hasDefault: false;
1759
2756
  isPrimaryKey: false;
1760
2757
  isAutoincrement: false;
@@ -1766,11 +2763,45 @@ declare const agentSchema: {
1766
2763
  }, {}, {
1767
2764
  length: number | undefined;
1768
2765
  }>;
1769
- executionMs: drizzle_orm_sqlite_core.SQLiteColumn<{
1770
- name: "execution_ms";
1771
- tableName: "agent_tool_call";
2766
+ inputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2767
+ name: "input_price_per_1m";
2768
+ tableName: "agent_model_pricing";
1772
2769
  dataType: "number";
1773
- columnType: "SQLiteInteger";
2770
+ columnType: "SQLiteReal";
2771
+ data: number;
2772
+ driverParam: number;
2773
+ notNull: true;
2774
+ hasDefault: false;
2775
+ isPrimaryKey: false;
2776
+ isAutoincrement: false;
2777
+ hasRuntimeDefault: false;
2778
+ enumValues: undefined;
2779
+ baseColumn: never;
2780
+ identity: undefined;
2781
+ generated: undefined;
2782
+ }, {}, {}>;
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;
2791
+ hasDefault: false;
2792
+ isPrimaryKey: false;
2793
+ isAutoincrement: false;
2794
+ hasRuntimeDefault: false;
2795
+ enumValues: undefined;
2796
+ baseColumn: never;
2797
+ identity: undefined;
2798
+ generated: undefined;
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";
1774
2805
  data: number;
1775
2806
  driverParam: number;
1776
2807
  notNull: false;
@@ -1783,28 +2814,26 @@ declare const agentSchema: {
1783
2814
  identity: undefined;
1784
2815
  generated: undefined;
1785
2816
  }, {}, {}>;
1786
- error: drizzle_orm_sqlite_core.SQLiteColumn<{
1787
- name: "error";
1788
- tableName: "agent_tool_call";
1789
- dataType: "string";
1790
- columnType: "SQLiteText";
1791
- data: string;
1792
- driverParam: string;
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;
2823
+ driverParam: number;
1793
2824
  notNull: false;
1794
2825
  hasDefault: false;
1795
2826
  isPrimaryKey: false;
1796
2827
  isAutoincrement: false;
1797
2828
  hasRuntimeDefault: false;
1798
- enumValues: [string, ...string[]];
2829
+ enumValues: undefined;
1799
2830
  baseColumn: never;
1800
2831
  identity: undefined;
1801
2832
  generated: undefined;
1802
- }, {}, {
1803
- length: number | undefined;
1804
- }>;
1805
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1806
- name: "created_at";
1807
- tableName: "agent_tool_call";
2833
+ }, {}, {}>;
2834
+ effectiveFrom: drizzle_orm_sqlite_core.SQLiteColumn<{
2835
+ name: "effective_from";
2836
+ tableName: "agent_model_pricing";
1808
2837
  dataType: "date";
1809
2838
  columnType: "SQLiteTimestamp";
1810
2839
  data: Date;
@@ -1819,14 +2848,14 @@ declare const agentSchema: {
1819
2848
  identity: undefined;
1820
2849
  generated: undefined;
1821
2850
  }, {}, {}>;
1822
- executedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
1823
- name: "executed_at";
1824
- tableName: "agent_tool_call";
1825
- dataType: "date";
1826
- columnType: "SQLiteTimestamp";
1827
- data: Date;
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;
1828
2857
  driverParam: number;
1829
- notNull: false;
2858
+ notNull: true;
1830
2859
  hasDefault: false;
1831
2860
  isPrimaryKey: false;
1832
2861
  isAutoincrement: false;
@@ -1836,35 +2865,16 @@ declare const agentSchema: {
1836
2865
  identity: undefined;
1837
2866
  generated: undefined;
1838
2867
  }, {}, {}>;
1839
- runId: drizzle_orm_sqlite_core.SQLiteColumn<{
1840
- name: "run_id";
1841
- tableName: "agent_tool_call";
1842
- dataType: "string";
1843
- columnType: "SQLiteText";
1844
- data: string;
1845
- driverParam: string;
1846
- notNull: false;
1847
- hasDefault: false;
1848
- isPrimaryKey: false;
1849
- isAutoincrement: false;
1850
- hasRuntimeDefault: false;
1851
- enumValues: [string, ...string[]];
1852
- baseColumn: never;
1853
- identity: undefined;
1854
- generated: undefined;
1855
- }, {}, {
1856
- length: number | undefined;
1857
- }>;
1858
2868
  };
1859
2869
  dialect: "sqlite";
1860
2870
  }>;
1861
- agentTokenUsage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1862
- name: "agent_token_usage";
2871
+ agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2872
+ name: "agent_run";
1863
2873
  schema: undefined;
1864
2874
  columns: {
1865
2875
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
1866
2876
  name: "id";
1867
- tableName: "agent_token_usage";
2877
+ tableName: "agent_run";
1868
2878
  dataType: "string";
1869
2879
  columnType: "SQLiteText";
1870
2880
  data: string;
@@ -1883,7 +2893,7 @@ declare const agentSchema: {
1883
2893
  }>;
1884
2894
  threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
1885
2895
  name: "thread_id";
1886
- tableName: "agent_token_usage";
2896
+ tableName: "agent_run";
1887
2897
  dataType: "string";
1888
2898
  columnType: "SQLiteText";
1889
2899
  data: string;
@@ -1902,7 +2912,7 @@ declare const agentSchema: {
1902
2912
  }>;
1903
2913
  actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
1904
2914
  name: "actor_ref";
1905
- tableName: "agent_token_usage";
2915
+ tableName: "agent_run";
1906
2916
  dataType: "string";
1907
2917
  columnType: "SQLiteText";
1908
2918
  data: string;
@@ -1919,9 +2929,9 @@ declare const agentSchema: {
1919
2929
  }, {}, {
1920
2930
  length: number | undefined;
1921
2931
  }>;
1922
- messageId: drizzle_orm_sqlite_core.SQLiteColumn<{
1923
- name: "message_id";
1924
- tableName: "agent_token_usage";
2932
+ agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
2933
+ name: "agent_name";
2934
+ tableName: "agent_run";
1925
2935
  dataType: "string";
1926
2936
  columnType: "SQLiteText";
1927
2937
  data: string;
@@ -1938,12 +2948,12 @@ declare const agentSchema: {
1938
2948
  }, {}, {
1939
2949
  length: number | undefined;
1940
2950
  }>;
1941
- modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
1942
- name: "model_id";
1943
- tableName: "agent_token_usage";
2951
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
2952
+ name: "status";
2953
+ tableName: "agent_run";
1944
2954
  dataType: "string";
1945
2955
  columnType: "SQLiteText";
1946
- data: string;
2956
+ data: AgentRunStatus;
1947
2957
  driverParam: string;
1948
2958
  notNull: true;
1949
2959
  hasDefault: false;
@@ -1956,15 +2966,33 @@ declare const agentSchema: {
1956
2966
  generated: undefined;
1957
2967
  }, {}, {
1958
2968
  length: number | undefined;
2969
+ $type: AgentRunStatus;
1959
2970
  }>;
1960
- purpose: drizzle_orm_sqlite_core.SQLiteColumn<{
1961
- name: "purpose";
1962
- 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";
1963
2991
  dataType: "string";
1964
2992
  columnType: "SQLiteText";
1965
- data: UsagePurpose;
2993
+ data: string;
1966
2994
  driverParam: string;
1967
- notNull: true;
2995
+ notNull: false;
1968
2996
  hasDefault: false;
1969
2997
  isPrimaryKey: false;
1970
2998
  isAutoincrement: false;
@@ -1975,34 +3003,35 @@ declare const agentSchema: {
1975
3003
  generated: undefined;
1976
3004
  }, {}, {
1977
3005
  length: number | undefined;
1978
- $type: UsagePurpose;
1979
3006
  }>;
1980
- inputTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
1981
- name: "input_tokens";
1982
- tableName: "agent_token_usage";
1983
- dataType: "number";
1984
- columnType: "SQLiteInteger";
1985
- data: number;
1986
- driverParam: number;
1987
- 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;
1988
3015
  hasDefault: false;
1989
3016
  isPrimaryKey: false;
1990
3017
  isAutoincrement: false;
1991
3018
  hasRuntimeDefault: false;
1992
- enumValues: undefined;
3019
+ enumValues: [string, ...string[]];
1993
3020
  baseColumn: never;
1994
3021
  identity: undefined;
1995
3022
  generated: undefined;
1996
- }, {}, {}>;
1997
- outputTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
1998
- name: "output_tokens";
1999
- tableName: "agent_token_usage";
3023
+ }, {}, {
3024
+ length: number | undefined;
3025
+ }>;
3026
+ retries: drizzle_orm_sqlite_core.SQLiteColumn<{
3027
+ name: "retries";
3028
+ tableName: "agent_run";
2000
3029
  dataType: "number";
2001
3030
  columnType: "SQLiteInteger";
2002
3031
  data: number;
2003
3032
  driverParam: number;
2004
3033
  notNull: true;
2005
- hasDefault: false;
3034
+ hasDefault: true;
2006
3035
  isPrimaryKey: false;
2007
3036
  isAutoincrement: false;
2008
3037
  hasRuntimeDefault: false;
@@ -2011,14 +3040,14 @@ declare const agentSchema: {
2011
3040
  identity: undefined;
2012
3041
  generated: undefined;
2013
3042
  }, {}, {}>;
2014
- cacheWriteTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2015
- name: "cache_write_tokens";
2016
- tableName: "agent_token_usage";
2017
- dataType: "number";
2018
- columnType: "SQLiteInteger";
2019
- 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;
2020
3049
  driverParam: number;
2021
- notNull: false;
3050
+ notNull: true;
2022
3051
  hasDefault: false;
2023
3052
  isPrimaryKey: false;
2024
3053
  isAutoincrement: false;
@@ -2028,12 +3057,12 @@ declare const agentSchema: {
2028
3057
  identity: undefined;
2029
3058
  generated: undefined;
2030
3059
  }, {}, {}>;
2031
- cacheReadTokens: drizzle_orm_sqlite_core.SQLiteColumn<{
2032
- name: "cache_read_tokens";
2033
- tableName: "agent_token_usage";
2034
- dataType: "number";
2035
- columnType: "SQLiteInteger";
2036
- 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;
2037
3066
  driverParam: number;
2038
3067
  notNull: false;
2039
3068
  hasDefault: false;
@@ -2045,50 +3074,54 @@ declare const agentSchema: {
2045
3074
  identity: undefined;
2046
3075
  generated: undefined;
2047
3076
  }, {}, {}>;
2048
- costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
2049
- name: "cost_usd";
2050
- tableName: "agent_token_usage";
2051
- dataType: "number";
2052
- columnType: "SQLiteReal";
2053
- data: number;
2054
- 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;
2055
3084
  notNull: false;
2056
3085
  hasDefault: false;
2057
3086
  isPrimaryKey: false;
2058
3087
  isAutoincrement: false;
2059
3088
  hasRuntimeDefault: false;
2060
- enumValues: undefined;
3089
+ enumValues: [string, ...string[]];
2061
3090
  baseColumn: never;
2062
3091
  identity: undefined;
2063
3092
  generated: undefined;
2064
- }, {}, {}>;
2065
- createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2066
- name: "created_at";
2067
- tableName: "agent_token_usage";
2068
- dataType: "date";
2069
- columnType: "SQLiteTimestamp";
2070
- data: Date;
2071
- driverParam: number;
2072
- 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;
2073
3104
  hasDefault: false;
2074
3105
  isPrimaryKey: false;
2075
3106
  isAutoincrement: false;
2076
3107
  hasRuntimeDefault: false;
2077
- enumValues: undefined;
3108
+ enumValues: [string, ...string[]];
2078
3109
  baseColumn: never;
2079
3110
  identity: undefined;
2080
3111
  generated: undefined;
2081
- }, {}, {}>;
3112
+ }, {}, {
3113
+ length: number | undefined;
3114
+ }>;
2082
3115
  };
2083
3116
  dialect: "sqlite";
2084
3117
  }>;
2085
- agentModelPricing: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2086
- name: "agent_model_pricing";
3118
+ agentMemory: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3119
+ name: "agent_memory";
2087
3120
  schema: undefined;
2088
3121
  columns: {
2089
3122
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
2090
3123
  name: "id";
2091
- tableName: "agent_model_pricing";
3124
+ tableName: "agent_memory";
2092
3125
  dataType: "string";
2093
3126
  columnType: "SQLiteText";
2094
3127
  data: string;
@@ -2105,9 +3138,9 @@ declare const agentSchema: {
2105
3138
  }, {}, {
2106
3139
  length: number | undefined;
2107
3140
  }>;
2108
- modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2109
- name: "model_id";
2110
- tableName: "agent_model_pricing";
3141
+ scope: drizzle_orm_sqlite_core.SQLiteColumn<{
3142
+ name: "scope";
3143
+ tableName: "agent_memory";
2111
3144
  dataType: "string";
2112
3145
  columnType: "SQLiteText";
2113
3146
  data: string;
@@ -2124,66 +3157,130 @@ declare const agentSchema: {
2124
3157
  }, {}, {
2125
3158
  length: number | undefined;
2126
3159
  }>;
2127
- inputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2128
- name: "input_price_per_1m";
2129
- tableName: "agent_model_pricing";
2130
- dataType: "number";
2131
- columnType: "SQLiteReal";
2132
- data: number;
2133
- 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;
2134
3167
  notNull: true;
2135
3168
  hasDefault: false;
2136
3169
  isPrimaryKey: false;
2137
3170
  isAutoincrement: false;
2138
3171
  hasRuntimeDefault: false;
2139
- enumValues: undefined;
3172
+ enumValues: [string, ...string[]];
2140
3173
  baseColumn: never;
2141
3174
  identity: undefined;
2142
3175
  generated: undefined;
2143
- }, {}, {}>;
2144
- outputPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2145
- name: "output_price_per_1m";
2146
- tableName: "agent_model_pricing";
2147
- dataType: "number";
2148
- columnType: "SQLiteReal";
2149
- data: number;
2150
- 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;
2151
3186
  notNull: true;
2152
3187
  hasDefault: false;
2153
3188
  isPrimaryKey: false;
2154
3189
  isAutoincrement: false;
2155
3190
  hasRuntimeDefault: false;
2156
- enumValues: undefined;
3191
+ enumValues: [string, ...string[]];
2157
3192
  baseColumn: never;
2158
3193
  identity: undefined;
2159
3194
  generated: undefined;
2160
- }, {}, {}>;
2161
- cacheWritePricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2162
- name: "cache_write_price_per_1m";
2163
- tableName: "agent_model_pricing";
2164
- dataType: "number";
2165
- columnType: "SQLiteReal";
2166
- data: number;
2167
- driverParam: number;
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;
3205
+ notNull: true;
3206
+ hasDefault: false;
3207
+ isPrimaryKey: false;
3208
+ isAutoincrement: false;
3209
+ hasRuntimeDefault: false;
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[]];
3231
+ baseColumn: never;
3232
+ identity: undefined;
3233
+ generated: undefined;
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;
3244
+ notNull: false;
3245
+ hasDefault: false;
3246
+ isPrimaryKey: false;
3247
+ isAutoincrement: false;
3248
+ hasRuntimeDefault: false;
3249
+ enumValues: [string, ...string[]];
3250
+ baseColumn: never;
3251
+ identity: undefined;
3252
+ generated: undefined;
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;
2168
3263
  notNull: false;
2169
3264
  hasDefault: false;
2170
3265
  isPrimaryKey: false;
2171
3266
  isAutoincrement: false;
2172
3267
  hasRuntimeDefault: false;
2173
- enumValues: undefined;
3268
+ enumValues: [string, ...string[]];
2174
3269
  baseColumn: never;
2175
3270
  identity: undefined;
2176
3271
  generated: undefined;
2177
- }, {}, {}>;
2178
- cacheReadPricePer1m: drizzle_orm_sqlite_core.SQLiteColumn<{
2179
- name: "cache_read_price_per_1m";
2180
- tableName: "agent_model_pricing";
2181
- dataType: "number";
2182
- columnType: "SQLiteReal";
2183
- data: number;
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;
2184
3281
  driverParam: number;
2185
- notNull: false;
2186
- hasDefault: false;
3282
+ notNull: true;
3283
+ hasDefault: true;
2187
3284
  isPrimaryKey: false;
2188
3285
  isAutoincrement: false;
2189
3286
  hasRuntimeDefault: false;
@@ -2192,9 +3289,9 @@ declare const agentSchema: {
2192
3289
  identity: undefined;
2193
3290
  generated: undefined;
2194
3291
  }, {}, {}>;
2195
- effectiveFrom: drizzle_orm_sqlite_core.SQLiteColumn<{
2196
- name: "effective_from";
2197
- tableName: "agent_model_pricing";
3292
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
3293
+ name: "created_at";
3294
+ tableName: "agent_memory";
2198
3295
  dataType: "date";
2199
3296
  columnType: "SQLiteTimestamp";
2200
3297
  data: Date;
@@ -2209,12 +3306,12 @@ declare const agentSchema: {
2209
3306
  identity: undefined;
2210
3307
  generated: undefined;
2211
3308
  }, {}, {}>;
2212
- isCurrent: drizzle_orm_sqlite_core.SQLiteColumn<{
2213
- name: "is_current";
2214
- tableName: "agent_model_pricing";
2215
- dataType: "boolean";
2216
- columnType: "SQLiteBoolean";
2217
- 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;
2218
3315
  driverParam: number;
2219
3316
  notNull: true;
2220
3317
  hasDefault: false;
@@ -2229,13 +3326,13 @@ declare const agentSchema: {
2229
3326
  };
2230
3327
  dialect: "sqlite";
2231
3328
  }>;
2232
- agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2233
- name: "agent_run";
3329
+ ragIngestionLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3330
+ name: "rag_ingestion_log";
2234
3331
  schema: undefined;
2235
3332
  columns: {
2236
- id: drizzle_orm_sqlite_core.SQLiteColumn<{
2237
- name: "id";
2238
- tableName: "agent_run";
3333
+ documentId: drizzle_orm_sqlite_core.SQLiteColumn<{
3334
+ name: "document_id";
3335
+ tableName: "rag_ingestion_log";
2239
3336
  dataType: "string";
2240
3337
  columnType: "SQLiteText";
2241
3338
  data: string;
@@ -2252,12 +3349,12 @@ declare const agentSchema: {
2252
3349
  }, {}, {
2253
3350
  length: number | undefined;
2254
3351
  }>;
2255
- threadId: drizzle_orm_sqlite_core.SQLiteColumn<{
2256
- name: "thread_id";
2257
- tableName: "agent_run";
3352
+ status: drizzle_orm_sqlite_core.SQLiteColumn<{
3353
+ name: "status";
3354
+ tableName: "rag_ingestion_log";
2258
3355
  dataType: "string";
2259
3356
  columnType: "SQLiteText";
2260
- data: string;
3357
+ data: RagIngestionStatus;
2261
3358
  driverParam: string;
2262
3359
  notNull: true;
2263
3360
  hasDefault: false;
@@ -2270,15 +3367,16 @@ declare const agentSchema: {
2270
3367
  generated: undefined;
2271
3368
  }, {}, {
2272
3369
  length: number | undefined;
3370
+ $type: RagIngestionStatus;
2273
3371
  }>;
2274
- actorRef: drizzle_orm_sqlite_core.SQLiteColumn<{
2275
- name: "actor_ref";
2276
- tableName: "agent_run";
3372
+ collection: drizzle_orm_sqlite_core.SQLiteColumn<{
3373
+ name: "collection";
3374
+ tableName: "rag_ingestion_log";
2277
3375
  dataType: "string";
2278
3376
  columnType: "SQLiteText";
2279
3377
  data: string;
2280
3378
  driverParam: string;
2281
- notNull: true;
3379
+ notNull: false;
2282
3380
  hasDefault: false;
2283
3381
  isPrimaryKey: false;
2284
3382
  isAutoincrement: false;
@@ -2290,9 +3388,9 @@ declare const agentSchema: {
2290
3388
  }, {}, {
2291
3389
  length: number | undefined;
2292
3390
  }>;
2293
- agentName: drizzle_orm_sqlite_core.SQLiteColumn<{
2294
- name: "agent_name";
2295
- tableName: "agent_run";
3391
+ ownerType: drizzle_orm_sqlite_core.SQLiteColumn<{
3392
+ name: "owner_type";
3393
+ tableName: "rag_ingestion_log";
2296
3394
  dataType: "string";
2297
3395
  columnType: "SQLiteText";
2298
3396
  data: string;
@@ -2309,14 +3407,14 @@ declare const agentSchema: {
2309
3407
  }, {}, {
2310
3408
  length: number | undefined;
2311
3409
  }>;
2312
- status: drizzle_orm_sqlite_core.SQLiteColumn<{
2313
- name: "status";
2314
- tableName: "agent_run";
3410
+ ownerId: drizzle_orm_sqlite_core.SQLiteColumn<{
3411
+ name: "owner_id";
3412
+ tableName: "rag_ingestion_log";
2315
3413
  dataType: "string";
2316
3414
  columnType: "SQLiteText";
2317
- data: AgentRunStatus;
3415
+ data: string;
2318
3416
  driverParam: string;
2319
- notNull: true;
3417
+ notNull: false;
2320
3418
  hasDefault: false;
2321
3419
  isPrimaryKey: false;
2322
3420
  isAutoincrement: false;
@@ -2327,28 +3425,10 @@ declare const agentSchema: {
2327
3425
  generated: undefined;
2328
3426
  }, {}, {
2329
3427
  length: number | undefined;
2330
- $type: AgentRunStatus;
2331
3428
  }>;
2332
- durationMs: drizzle_orm_sqlite_core.SQLiteColumn<{
2333
- name: "duration_ms";
2334
- tableName: "agent_run";
2335
- dataType: "number";
2336
- columnType: "SQLiteInteger";
2337
- data: number;
2338
- driverParam: number;
2339
- notNull: false;
2340
- hasDefault: false;
2341
- isPrimaryKey: false;
2342
- isAutoincrement: false;
2343
- hasRuntimeDefault: false;
2344
- enumValues: undefined;
2345
- baseColumn: never;
2346
- identity: undefined;
2347
- generated: undefined;
2348
- }, {}, {}>;
2349
- errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
2350
- name: "error_code";
2351
- tableName: "agent_run";
3429
+ source: drizzle_orm_sqlite_core.SQLiteColumn<{
3430
+ name: "source";
3431
+ tableName: "rag_ingestion_log";
2352
3432
  dataType: "string";
2353
3433
  columnType: "SQLiteText";
2354
3434
  data: string;
@@ -2365,9 +3445,9 @@ declare const agentSchema: {
2365
3445
  }, {}, {
2366
3446
  length: number | undefined;
2367
3447
  }>;
2368
- errorMessage: drizzle_orm_sqlite_core.SQLiteColumn<{
2369
- name: "error_message";
2370
- tableName: "agent_run";
3448
+ mimeType: drizzle_orm_sqlite_core.SQLiteColumn<{
3449
+ name: "mime_type";
3450
+ tableName: "rag_ingestion_log";
2371
3451
  dataType: "string";
2372
3452
  columnType: "SQLiteText";
2373
3453
  data: string;
@@ -2384,15 +3464,15 @@ declare const agentSchema: {
2384
3464
  }, {}, {
2385
3465
  length: number | undefined;
2386
3466
  }>;
2387
- retries: drizzle_orm_sqlite_core.SQLiteColumn<{
2388
- name: "retries";
2389
- tableName: "agent_run";
3467
+ size: drizzle_orm_sqlite_core.SQLiteColumn<{
3468
+ name: "size";
3469
+ tableName: "rag_ingestion_log";
2390
3470
  dataType: "number";
2391
3471
  columnType: "SQLiteInteger";
2392
3472
  data: number;
2393
3473
  driverParam: number;
2394
- notNull: true;
2395
- hasDefault: true;
3474
+ notNull: false;
3475
+ hasDefault: false;
2396
3476
  isPrimaryKey: false;
2397
3477
  isAutoincrement: false;
2398
3478
  hasRuntimeDefault: false;
@@ -2401,14 +3481,14 @@ declare const agentSchema: {
2401
3481
  identity: undefined;
2402
3482
  generated: undefined;
2403
3483
  }, {}, {}>;
2404
- startedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2405
- name: "started_at";
2406
- tableName: "agent_run";
2407
- dataType: "date";
2408
- columnType: "SQLiteTimestamp";
2409
- 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;
2410
3490
  driverParam: number;
2411
- notNull: true;
3491
+ notNull: false;
2412
3492
  hasDefault: false;
2413
3493
  isPrimaryKey: false;
2414
3494
  isAutoincrement: false;
@@ -2418,26 +3498,28 @@ declare const agentSchema: {
2418
3498
  identity: undefined;
2419
3499
  generated: undefined;
2420
3500
  }, {}, {}>;
2421
- settledAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2422
- name: "settled_at";
2423
- tableName: "agent_run";
2424
- dataType: "date";
2425
- columnType: "SQLiteTimestamp";
2426
- data: Date;
2427
- driverParam: number;
3501
+ reason: drizzle_orm_sqlite_core.SQLiteColumn<{
3502
+ name: "reason";
3503
+ tableName: "rag_ingestion_log";
3504
+ dataType: "string";
3505
+ columnType: "SQLiteText";
3506
+ data: string;
3507
+ driverParam: string;
2428
3508
  notNull: false;
2429
3509
  hasDefault: false;
2430
3510
  isPrimaryKey: false;
2431
3511
  isAutoincrement: false;
2432
3512
  hasRuntimeDefault: false;
2433
- enumValues: undefined;
3513
+ enumValues: [string, ...string[]];
2434
3514
  baseColumn: never;
2435
3515
  identity: undefined;
2436
3516
  generated: undefined;
2437
- }, {}, {}>;
2438
- promptHash: drizzle_orm_sqlite_core.SQLiteColumn<{
2439
- name: "prompt_hash";
2440
- tableName: "agent_run";
3517
+ }, {}, {
3518
+ length: number | undefined;
3519
+ }>;
3520
+ error: drizzle_orm_sqlite_core.SQLiteColumn<{
3521
+ name: "error";
3522
+ tableName: "rag_ingestion_log";
2441
3523
  dataType: "string";
2442
3524
  columnType: "SQLiteText";
2443
3525
  data: string;
@@ -2454,6 +3536,40 @@ declare const agentSchema: {
2454
3536
  }, {}, {
2455
3537
  length: number | undefined;
2456
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
+ }, {}, {}>;
2457
3573
  };
2458
3574
  dialect: "sqlite";
2459
3575
  }>;
@@ -2463,15 +3579,22 @@ declare const agentSchema: {
2463
3579
  * driver (better-sqlite3, libsql, D1, …) in either sync or async result mode; the host app owns
2464
3580
  * the connection and passes the `drizzle(...)` instance in.
2465
3581
  */
2466
- type AgentDrizzleDb = BaseSQLiteDatabase<'sync' | 'async', unknown>;
3582
+ type AgentDrizzleDb = BaseSQLiteDatabase<'sync' | 'async', unknown, Record<string, unknown>, TablesRelationalConfig>;
2467
3583
  /** A persisted thread row as Drizzle selects it. */
2468
3584
  type AgentThreadRow = typeof agentThread.$inferSelect;
2469
3585
  /** A persisted message row as Drizzle selects it. */
2470
3586
  type AgentMessageRow = typeof agentMessage.$inferSelect;
2471
3587
  /** A persisted run row as Drizzle selects it. */
2472
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;
2473
3593
 
2474
- /** Runs the `CREATE TABLE IF NOT EXISTS` DDL above against the supplied Drizzle SQLite db. */
3594
+ /**
3595
+ * Runs the `CREATE TABLE IF NOT EXISTS` DDL above against the supplied Drizzle SQLite db, then adds
3596
+ * any column missing from a table that already existed.
3597
+ */
2475
3598
  declare function ensureAgentSchema(db: AgentDrizzleDb): Promise<void>;
2476
3599
 
2477
3600
  /**
@@ -2480,11 +3603,30 @@ declare function ensureAgentSchema(db: AgentDrizzleDb): Promise<void>;
2480
3603
  * owns the connection). Behaviour mirrors {@link import('@dudousxd/nestjs-agent-store-mikro-orm')}
2481
3604
  * exactly (fork/truncate/quota/active-stream/soft-delete semantics) so the two are interchangeable.
2482
3605
  */
2483
- declare class DrizzleAgentStore implements AgentStore {
3606
+ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader {
2484
3607
  private readonly db;
2485
3608
  constructor(db: AgentDrizzleDb);
2486
3609
  createThread(input: CreateThreadInput): Promise<ThreadSummary>;
2487
3610
  getThread(threadId: string): Promise<ThreadDetail | null>;
3611
+ /**
3612
+ * The window a turn reads off a thread: its newest `messageLimit` messages (oldest first), the
3613
+ * title, the default agent, and whether the thread has EVER been answered.
3614
+ *
3615
+ * {@link getThread} is the wrong read for a turn. It materializes the transcript — every message,
3616
+ * every attachment, every tool output the thread ever recorded — and the run then journals what it
3617
+ * loaded, so a long thread pays for its whole history on every turn and again on every replay.
3618
+ *
3619
+ * `hasAssistantMessage` is answered over the WHOLE thread, not the returned page: it answers "has
3620
+ * this conversation been answered before?", and a thread whose window happens to hold only the
3621
+ * user's last questions has still been answered. `null` when the thread is unknown or
3622
+ * soft-deleted, same as {@link getThread}.
3623
+ */
3624
+ loadThreadForTurn(query: ThreadTurnQuery): Promise<ThreadTurnPage | null>;
3625
+ /**
3626
+ * The newest `limit` messages of a thread, oldest first, projected to the columns a model turn
3627
+ * reads. Read newest-first so the LIMIT is the database's job, then reversed for the prompt.
3628
+ */
3629
+ private loadTurnWindow;
2488
3630
  listThreads(actorRef: string, limit?: number): Promise<ThreadSummary[]>;
2489
3631
  softDeleteThread(threadId: string): Promise<void>;
2490
3632
  forkThread(threadId: string, fromMessageId: string): Promise<ThreadSummary>;
@@ -2495,18 +3637,30 @@ declare class DrizzleAgentStore implements AgentStore {
2495
3637
  setTitle(threadId: string, title: string): Promise<void>;
2496
3638
  promoteThread(threadId: string): Promise<void>;
2497
3639
  setActiveStream(threadId: string, runId: string | null): Promise<void>;
2498
- /** Persist the start of a run (turn). Replay-safe: called under a durable localStep. */
2499
- recordRunStart(run: {
2500
- runId: string;
2501
- threadId: string;
2502
- actorRef: string;
2503
- agentName?: string;
2504
- promptHash?: string;
2505
- }): Promise<void>;
3640
+ /**
3641
+ * Patch a thread's `title` and/or `defaultAgent`. Each field is only touched when PRESENT in
3642
+ * `patch` — `defaultAgent: null` clears it (falls back to the app default), while an omitted
3643
+ * `defaultAgent` leaves whatever is stored untouched. A no-op (including `updatedAt`) when the
3644
+ * patch is empty or the thread doesn't exist.
3645
+ */
3646
+ updateThread(threadId: string, patch: UpdateThreadInput): Promise<void>;
3647
+ /**
3648
+ * The thread's default agent, projected — the caller wants one nullable scalar to decide which
3649
+ * agent answers the next turn, and {@link getThread} would materialize the whole transcript to
3650
+ * hand it over. `null` when the thread is unknown, soft-deleted, or has no default set.
3651
+ */
3652
+ defaultAgentForThread(threadId: string): Promise<string | null>;
3653
+ /**
3654
+ * Persist the start of a run (turn). Replay-safe: called under a durable localStep.
3655
+ *
3656
+ * Takes the SPI's own {@link RecordRunStartInput} rather than a hand-copied shape: a field added
3657
+ * to the input is otherwise accepted and dropped, silently, by every adapter that re-declares it.
3658
+ */
3659
+ recordRunStart(run: RecordRunStartInput): Promise<void>;
2506
3660
  /** Settle a run's outcome. A no-op when the run is unknown (mirrors `setTitle`/`updateThread`). */
2507
3661
  recordRunEnd(end: {
2508
3662
  runId: string;
2509
- status: 'completed' | 'failed';
3663
+ status: 'completed' | 'failed' | 'cancelled';
2510
3664
  durationMs?: number;
2511
3665
  errorCode?: string;
2512
3666
  errorMessage?: string;
@@ -2514,9 +3668,24 @@ declare class DrizzleAgentStore implements AgentStore {
2514
3668
  /** Bump the run's llm-step retry counter. Atomic `retries = retries + 1`, no read-modify-write. */
2515
3669
  bumpRunRetries(runId: string): Promise<void>;
2516
3670
  appendMessage(input: AppendMessageInput): Promise<StoredMessage>;
3671
+ setMessageToolResults(messageId: string, results: ToolResult[]): Promise<void>;
2517
3672
  truncateFrom(threadId: string, messageId: string): Promise<void>;
2518
3673
  recordToolCall(input: RecordToolCallInput): Promise<void>;
2519
3674
  updateToolCall(input: UpdateToolCallInput): Promise<void>;
3675
+ /**
3676
+ * Of `mediaIds`, the ones a surviving message in one of this actor's threads still carries.
3677
+ *
3678
+ * Reads the `attachments` JSON back out and matches in memory rather than pushing the match into
3679
+ * SQL: the column holds an array of objects, and every dialect this adapter's sibling targets
3680
+ * spells that query differently (`jsonb` containment, `json_table`, `json_each`), while none of
3681
+ * them can use an index for it anyway. The scan is bounded by ONE actor's attachment-bearing
3682
+ * messages, which is a small set — attachments are rare, and a message without one is excluded
3683
+ * by the `is not null` before any JSON is parsed.
3684
+ *
3685
+ * Soft-deleted threads are deliberately included: their message rows survive, so the bytes they
3686
+ * point at are still reachable from stored state and are not garbage.
3687
+ */
3688
+ referencedMediaIds(actorRef: string, mediaIds: readonly string[]): Promise<string[]>;
2520
3689
  recordUsage(input: RecordUsageInput): Promise<void>;
2521
3690
  quotaToday(actorRef: string, day: string): Promise<{
2522
3691
  usedTokens: number;
@@ -2626,6 +3795,72 @@ declare class DrizzleGovernanceQueries implements AgentGovernanceQueries {
2626
3795
  private toolCallCountsByMessage;
2627
3796
  }
2628
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
+
2629
3864
  /**
2630
3865
  * {@link AgentPricingStore} backed by Drizzle ORM — the write side of the pricing table
2631
3866
  * {@link import('./drizzle-governance-queries.js').DrizzleGovernanceQueries} joins against. A POJO
@@ -2639,6 +3874,190 @@ declare class DrizzlePricingStore implements AgentPricingStore {
2639
3874
  listCurrentPrices(): Promise<CurrentModelPrice[]>;
2640
3875
  }
2641
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
+
2642
4061
  /** Options for {@link DrizzleAgentStoreModule.forRoot}. The app owns and supplies the db handle. */
2643
4062
  interface DrizzleAgentStoreModuleOptions {
2644
4063
  /** A Drizzle SQLite database instance (`drizzle(client, { schema: agentSchema })`). */
@@ -2649,6 +4068,18 @@ interface DrizzleAgentStoreModuleOptions {
2649
4068
  * table the single source of cost truth without touching `agent_model_pricing`.
2650
4069
  */
2651
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;
2652
4083
  }
2653
4084
  /**
2654
4085
  * Binds {@link DrizzleAgentStore} to the {@link AGENT_STORE} token consumed by
@@ -2671,4 +4102,4 @@ declare class DrizzleAgentStoreModule {
2671
4102
  static forRoot(options: DrizzleAgentStoreModuleOptions): DynamicModule;
2672
4103
  }
2673
4104
 
2674
- 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 };