@dudousxd/nestjs-agent-store-drizzle 0.31.0 → 0.33.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,5 +1,5 @@
1
1
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
2
- import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, GenuiValidity, GenuiErrorCategory, CostSource, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, RecordGenuiCallInput, UsageTotals, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, 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, GenuiStats, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore, PoppyStore, PoppyConversationRecord, PoppyConversationPatch, PoppyEventBody, StoredPoppyEvent, PoppyMessageReceipt, PoppyMessageClaim, PoppyConnectionStore, PoppyConnectionRecord, PoppyPendingConnect } from '@dudousxd/nestjs-agent-core';
2
+ import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, GenuiValidity, GenuiErrorCategory, CostSource, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, AgentStore, ThreadTurnReader, ThreadSettingsReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, ThreadSettings, RecordRunStartInput, RecordRunEndInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, RecordGenuiCallInput, UsageTotals, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, 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, GenuiStats, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore, PoppyStore, PoppyConversationRecord, PoppyConversationPatch, PoppyEventBody, StoredPoppyEvent, PoppyMessageReceipt, PoppyMessageClaim, PoppyConnectionStore, PoppyConnectionRecord, PoppyPendingConnect } from '@dudousxd/nestjs-agent-core';
3
3
  export { ThreadTurnPage, ThreadTurnQuery } from '@dudousxd/nestjs-agent-core';
4
4
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
5
5
  import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
@@ -2290,6 +2290,59 @@ declare const agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2290
2290
  identity: undefined;
2291
2291
  generated: undefined;
2292
2292
  }, {}, {}>;
2293
+ ttftMs: drizzle_orm_sqlite_core.SQLiteColumn<{
2294
+ name: "ttft_ms";
2295
+ tableName: "agent_run";
2296
+ dataType: "number";
2297
+ columnType: "SQLiteInteger";
2298
+ data: number;
2299
+ driverParam: number;
2300
+ notNull: false;
2301
+ hasDefault: false;
2302
+ isPrimaryKey: false;
2303
+ isAutoincrement: false;
2304
+ hasRuntimeDefault: false;
2305
+ enumValues: undefined;
2306
+ baseColumn: never;
2307
+ identity: undefined;
2308
+ generated: undefined;
2309
+ }, {}, {}>;
2310
+ costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
2311
+ name: "cost_usd";
2312
+ tableName: "agent_run";
2313
+ dataType: "number";
2314
+ columnType: "SQLiteReal";
2315
+ data: number;
2316
+ driverParam: number;
2317
+ notNull: false;
2318
+ hasDefault: false;
2319
+ isPrimaryKey: false;
2320
+ isAutoincrement: false;
2321
+ hasRuntimeDefault: false;
2322
+ enumValues: undefined;
2323
+ baseColumn: never;
2324
+ identity: undefined;
2325
+ generated: undefined;
2326
+ }, {}, {}>;
2327
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2328
+ name: "model_id";
2329
+ tableName: "agent_run";
2330
+ dataType: "string";
2331
+ columnType: "SQLiteText";
2332
+ data: string;
2333
+ driverParam: string;
2334
+ notNull: false;
2335
+ hasDefault: false;
2336
+ isPrimaryKey: false;
2337
+ isAutoincrement: false;
2338
+ hasRuntimeDefault: false;
2339
+ enumValues: [string, ...string[]];
2340
+ baseColumn: never;
2341
+ identity: undefined;
2342
+ generated: undefined;
2343
+ }, {}, {
2344
+ length: number | undefined;
2345
+ }>;
2293
2346
  errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
2294
2347
  name: "error_code";
2295
2348
  tableName: "agent_run";
@@ -7105,6 +7158,59 @@ declare const agentSchema: {
7105
7158
  identity: undefined;
7106
7159
  generated: undefined;
7107
7160
  }, {}, {}>;
7161
+ ttftMs: drizzle_orm_sqlite_core.SQLiteColumn<{
7162
+ name: "ttft_ms";
7163
+ tableName: "agent_run";
7164
+ dataType: "number";
7165
+ columnType: "SQLiteInteger";
7166
+ data: number;
7167
+ driverParam: number;
7168
+ notNull: false;
7169
+ hasDefault: false;
7170
+ isPrimaryKey: false;
7171
+ isAutoincrement: false;
7172
+ hasRuntimeDefault: false;
7173
+ enumValues: undefined;
7174
+ baseColumn: never;
7175
+ identity: undefined;
7176
+ generated: undefined;
7177
+ }, {}, {}>;
7178
+ costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
7179
+ name: "cost_usd";
7180
+ tableName: "agent_run";
7181
+ dataType: "number";
7182
+ columnType: "SQLiteReal";
7183
+ data: number;
7184
+ driverParam: number;
7185
+ notNull: false;
7186
+ hasDefault: false;
7187
+ isPrimaryKey: false;
7188
+ isAutoincrement: false;
7189
+ hasRuntimeDefault: false;
7190
+ enumValues: undefined;
7191
+ baseColumn: never;
7192
+ identity: undefined;
7193
+ generated: undefined;
7194
+ }, {}, {}>;
7195
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
7196
+ name: "model_id";
7197
+ tableName: "agent_run";
7198
+ dataType: "string";
7199
+ columnType: "SQLiteText";
7200
+ data: string;
7201
+ driverParam: string;
7202
+ notNull: false;
7203
+ hasDefault: false;
7204
+ isPrimaryKey: false;
7205
+ isAutoincrement: false;
7206
+ hasRuntimeDefault: false;
7207
+ enumValues: [string, ...string[]];
7208
+ baseColumn: never;
7209
+ identity: undefined;
7210
+ generated: undefined;
7211
+ }, {}, {
7212
+ length: number | undefined;
7213
+ }>;
7108
7214
  errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
7109
7215
  name: "error_code";
7110
7216
  tableName: "agent_run";
@@ -9067,7 +9173,7 @@ declare function agentSchemaDdl(dialect: AgentDialect): string[];
9067
9173
  * MySQL (the host app owns the connection). Behaviour mirrors {@link import('@dudousxd/nestjs-agent-store-mikro-orm')}
9068
9174
  * exactly (fork/truncate/quota/active-stream/soft-delete semantics) so the two are interchangeable.
9069
9175
  */
9070
- declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore {
9176
+ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ThreadSettingsReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore {
9071
9177
  private readonly db;
9072
9178
  private readonly dialect;
9073
9179
  private readonly t;
@@ -9127,6 +9233,12 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9127
9233
  */
9128
9234
  private loadTurnWindow;
9129
9235
  listThreads(actorRef: string, limit?: number): Promise<ThreadSummary[]>;
9236
+ /**
9237
+ * The content of each thread's newest message ({@link messageOrderNewestFirst}), in a fixed two
9238
+ * reads for any number of threads: each thread's highest `seq`, then the rows holding it. Only a
9239
+ * thread whose every message predates `seq` is read on its own, by `created_at`.
9240
+ */
9241
+ private lastMessageContents;
9130
9242
  softDeleteThread(threadId: string): Promise<void>;
9131
9243
  forkThread(threadId: string, fromMessageId: string): Promise<ThreadSummary>;
9132
9244
  ownerOfThread(threadId: string): Promise<string | null>;
@@ -9198,6 +9310,7 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9198
9310
  modelForThread(threadId: string): Promise<string | null>;
9199
9311
  /** The thread's pinned persona, projected like {@link defaultAgentForThread}. */
9200
9312
  personaForThread(threadId: string): Promise<string | null>;
9313
+ threadSettings(threadId: string): Promise<ThreadSettings | null>;
9201
9314
  defaultAgentForThread(threadId: string): Promise<string | null>;
9202
9315
  /**
9203
9316
  * Persist the start of a run (turn). Replay-safe: called under a durable localStep.
@@ -9207,13 +9320,7 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9207
9320
  */
9208
9321
  recordRunStart(run: RecordRunStartInput): Promise<void>;
9209
9322
  /** Settle a run's outcome. A no-op when the run is unknown (mirrors `setTitle`/`updateThread`). */
9210
- recordRunEnd(end: {
9211
- runId: string;
9212
- status: 'completed' | 'failed' | 'cancelled';
9213
- durationMs?: number;
9214
- errorCode?: string;
9215
- errorMessage?: string;
9216
- }): Promise<void>;
9323
+ recordRunEnd(end: RecordRunEndInput): Promise<void>;
9217
9324
  /** Bump the run's llm-step retry counter. Atomic `retries = retries + 1`, no read-modify-write. */
9218
9325
  bumpRunRetries(runId: string): Promise<void>;
9219
9326
  appendMessage(input: AppendMessageInput): Promise<StoredMessage>;
@@ -9249,6 +9356,15 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9249
9356
  recordGenuiCalls(rows: readonly RecordGenuiCallInput[]): Promise<void>;
9250
9357
  quotaToday(actorRef: string, day: string): Promise<UsageTotals>;
9251
9358
  usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<UsageTotals>;
9359
+ /**
9360
+ * Every range summed by the database in one statement, each as a conditional aggregate over the
9361
+ * rows of the smallest span covering them all — the actor's `(actor_ref, created_at)` index serves
9362
+ * it, and no usage row crosses the wire.
9363
+ */
9364
+ usageWindows(actorRef: string, ranges: readonly {
9365
+ fromDay: string;
9366
+ toDay: string;
9367
+ }[]): Promise<UsageTotals[]>;
9252
9368
  private toSummary;
9253
9369
  private toStoredMessage;
9254
9370
  }
@@ -9350,6 +9466,7 @@ declare class DrizzleGovernanceQueries implements AgentGovernanceQueries {
9350
9466
  /** Decorate an ordered thread list with its batched rollups, preserving the incoming order. */
9351
9467
  private toThreadActivityRows;
9352
9468
  recentThreads(limit: number): Promise<ThreadActivityRow[]>;
9469
+ /** The range's runs, with only the columns the rollups read. */
9353
9470
  private runsInRange;
9354
9471
  runMetrics(range: GovernanceRange): Promise<RunMetrics>;
9355
9472
  runsByAgent(range: GovernanceRange): Promise<RunAgentBreakdownRow[]>;
@@ -12264,6 +12381,57 @@ declare const pgAgentSchema: {
12264
12381
  identity: undefined;
12265
12382
  generated: undefined;
12266
12383
  }, {}, {}>;
12384
+ ttftMs: drizzle_orm_pg_core.PgColumn<{
12385
+ name: "ttft_ms";
12386
+ tableName: "agent_run";
12387
+ dataType: "number";
12388
+ columnType: "PgInteger";
12389
+ data: number;
12390
+ driverParam: string | number;
12391
+ notNull: false;
12392
+ hasDefault: false;
12393
+ isPrimaryKey: false;
12394
+ isAutoincrement: false;
12395
+ hasRuntimeDefault: false;
12396
+ enumValues: undefined;
12397
+ baseColumn: never;
12398
+ identity: undefined;
12399
+ generated: undefined;
12400
+ }, {}, {}>;
12401
+ costUsd: drizzle_orm_pg_core.PgColumn<{
12402
+ name: "cost_usd";
12403
+ tableName: "agent_run";
12404
+ dataType: "number";
12405
+ columnType: "PgDoublePrecision";
12406
+ data: number;
12407
+ driverParam: string | number;
12408
+ notNull: false;
12409
+ hasDefault: false;
12410
+ isPrimaryKey: false;
12411
+ isAutoincrement: false;
12412
+ hasRuntimeDefault: false;
12413
+ enumValues: undefined;
12414
+ baseColumn: never;
12415
+ identity: undefined;
12416
+ generated: undefined;
12417
+ }, {}, {}>;
12418
+ modelId: drizzle_orm_pg_core.PgColumn<{
12419
+ name: "model_id";
12420
+ tableName: "agent_run";
12421
+ dataType: "string";
12422
+ columnType: "PgText";
12423
+ data: string;
12424
+ driverParam: string;
12425
+ notNull: false;
12426
+ hasDefault: false;
12427
+ isPrimaryKey: false;
12428
+ isAutoincrement: false;
12429
+ hasRuntimeDefault: false;
12430
+ enumValues: [string, ...string[]];
12431
+ baseColumn: never;
12432
+ identity: undefined;
12433
+ generated: undefined;
12434
+ }, {}, {}>;
12267
12435
  errorCode: drizzle_orm_pg_core.PgColumn<{
12268
12436
  name: "error_code";
12269
12437
  tableName: "agent_run";
@@ -16420,6 +16588,57 @@ declare const mysqlAgentSchema: {
16420
16588
  identity: undefined;
16421
16589
  generated: undefined;
16422
16590
  }, {}, {}>;
16591
+ ttftMs: drizzle_orm_mysql_core.MySqlColumn<{
16592
+ name: "ttft_ms";
16593
+ tableName: "agent_run";
16594
+ dataType: "number";
16595
+ columnType: "MySqlInt";
16596
+ data: number;
16597
+ driverParam: string | number;
16598
+ notNull: false;
16599
+ hasDefault: false;
16600
+ isPrimaryKey: false;
16601
+ isAutoincrement: false;
16602
+ hasRuntimeDefault: false;
16603
+ enumValues: undefined;
16604
+ baseColumn: never;
16605
+ identity: undefined;
16606
+ generated: undefined;
16607
+ }, {}, {}>;
16608
+ costUsd: drizzle_orm_mysql_core.MySqlColumn<{
16609
+ name: "cost_usd";
16610
+ tableName: "agent_run";
16611
+ dataType: "number";
16612
+ columnType: "MySqlDouble";
16613
+ data: number;
16614
+ driverParam: string | number;
16615
+ notNull: false;
16616
+ hasDefault: false;
16617
+ isPrimaryKey: false;
16618
+ isAutoincrement: false;
16619
+ hasRuntimeDefault: false;
16620
+ enumValues: undefined;
16621
+ baseColumn: never;
16622
+ identity: undefined;
16623
+ generated: undefined;
16624
+ }, {}, {}>;
16625
+ modelId: drizzle_orm_mysql_core.MySqlColumn<{
16626
+ name: string;
16627
+ tableName: "agent_run";
16628
+ dataType: "string";
16629
+ columnType: "MySqlVarChar";
16630
+ data: string;
16631
+ driverParam: string | number;
16632
+ notNull: false;
16633
+ hasDefault: false;
16634
+ isPrimaryKey: false;
16635
+ isAutoincrement: false;
16636
+ hasRuntimeDefault: false;
16637
+ enumValues: [string, ...string[]];
16638
+ baseColumn: never;
16639
+ identity: undefined;
16640
+ generated: undefined;
16641
+ }, {}, {}>;
16423
16642
  errorCode: drizzle_orm_mysql_core.MySqlColumn<{
16424
16643
  name: string;
16425
16644
  tableName: "agent_run";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
2
- import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, GenuiValidity, GenuiErrorCategory, CostSource, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, RecordGenuiCallInput, UsageTotals, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, 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, GenuiStats, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore, PoppyStore, PoppyConversationRecord, PoppyConversationPatch, PoppyEventBody, StoredPoppyEvent, PoppyMessageReceipt, PoppyMessageClaim, PoppyConnectionStore, PoppyConnectionRecord, PoppyPendingConnect } from '@dudousxd/nestjs-agent-core';
2
+ import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, GenuiValidity, GenuiErrorCategory, CostSource, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, AgentStore, ThreadTurnReader, ThreadSettingsReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, ThreadSettings, RecordRunStartInput, RecordRunEndInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, RecordGenuiCallInput, UsageTotals, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, 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, GenuiStats, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore, PoppyStore, PoppyConversationRecord, PoppyConversationPatch, PoppyEventBody, StoredPoppyEvent, PoppyMessageReceipt, PoppyMessageClaim, PoppyConnectionStore, PoppyConnectionRecord, PoppyPendingConnect } from '@dudousxd/nestjs-agent-core';
3
3
  export { ThreadTurnPage, ThreadTurnQuery } from '@dudousxd/nestjs-agent-core';
4
4
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
5
5
  import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
@@ -2290,6 +2290,59 @@ declare const agentRun: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2290
2290
  identity: undefined;
2291
2291
  generated: undefined;
2292
2292
  }, {}, {}>;
2293
+ ttftMs: drizzle_orm_sqlite_core.SQLiteColumn<{
2294
+ name: "ttft_ms";
2295
+ tableName: "agent_run";
2296
+ dataType: "number";
2297
+ columnType: "SQLiteInteger";
2298
+ data: number;
2299
+ driverParam: number;
2300
+ notNull: false;
2301
+ hasDefault: false;
2302
+ isPrimaryKey: false;
2303
+ isAutoincrement: false;
2304
+ hasRuntimeDefault: false;
2305
+ enumValues: undefined;
2306
+ baseColumn: never;
2307
+ identity: undefined;
2308
+ generated: undefined;
2309
+ }, {}, {}>;
2310
+ costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
2311
+ name: "cost_usd";
2312
+ tableName: "agent_run";
2313
+ dataType: "number";
2314
+ columnType: "SQLiteReal";
2315
+ data: number;
2316
+ driverParam: number;
2317
+ notNull: false;
2318
+ hasDefault: false;
2319
+ isPrimaryKey: false;
2320
+ isAutoincrement: false;
2321
+ hasRuntimeDefault: false;
2322
+ enumValues: undefined;
2323
+ baseColumn: never;
2324
+ identity: undefined;
2325
+ generated: undefined;
2326
+ }, {}, {}>;
2327
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
2328
+ name: "model_id";
2329
+ tableName: "agent_run";
2330
+ dataType: "string";
2331
+ columnType: "SQLiteText";
2332
+ data: string;
2333
+ driverParam: string;
2334
+ notNull: false;
2335
+ hasDefault: false;
2336
+ isPrimaryKey: false;
2337
+ isAutoincrement: false;
2338
+ hasRuntimeDefault: false;
2339
+ enumValues: [string, ...string[]];
2340
+ baseColumn: never;
2341
+ identity: undefined;
2342
+ generated: undefined;
2343
+ }, {}, {
2344
+ length: number | undefined;
2345
+ }>;
2293
2346
  errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
2294
2347
  name: "error_code";
2295
2348
  tableName: "agent_run";
@@ -7105,6 +7158,59 @@ declare const agentSchema: {
7105
7158
  identity: undefined;
7106
7159
  generated: undefined;
7107
7160
  }, {}, {}>;
7161
+ ttftMs: drizzle_orm_sqlite_core.SQLiteColumn<{
7162
+ name: "ttft_ms";
7163
+ tableName: "agent_run";
7164
+ dataType: "number";
7165
+ columnType: "SQLiteInteger";
7166
+ data: number;
7167
+ driverParam: number;
7168
+ notNull: false;
7169
+ hasDefault: false;
7170
+ isPrimaryKey: false;
7171
+ isAutoincrement: false;
7172
+ hasRuntimeDefault: false;
7173
+ enumValues: undefined;
7174
+ baseColumn: never;
7175
+ identity: undefined;
7176
+ generated: undefined;
7177
+ }, {}, {}>;
7178
+ costUsd: drizzle_orm_sqlite_core.SQLiteColumn<{
7179
+ name: "cost_usd";
7180
+ tableName: "agent_run";
7181
+ dataType: "number";
7182
+ columnType: "SQLiteReal";
7183
+ data: number;
7184
+ driverParam: number;
7185
+ notNull: false;
7186
+ hasDefault: false;
7187
+ isPrimaryKey: false;
7188
+ isAutoincrement: false;
7189
+ hasRuntimeDefault: false;
7190
+ enumValues: undefined;
7191
+ baseColumn: never;
7192
+ identity: undefined;
7193
+ generated: undefined;
7194
+ }, {}, {}>;
7195
+ modelId: drizzle_orm_sqlite_core.SQLiteColumn<{
7196
+ name: "model_id";
7197
+ tableName: "agent_run";
7198
+ dataType: "string";
7199
+ columnType: "SQLiteText";
7200
+ data: string;
7201
+ driverParam: string;
7202
+ notNull: false;
7203
+ hasDefault: false;
7204
+ isPrimaryKey: false;
7205
+ isAutoincrement: false;
7206
+ hasRuntimeDefault: false;
7207
+ enumValues: [string, ...string[]];
7208
+ baseColumn: never;
7209
+ identity: undefined;
7210
+ generated: undefined;
7211
+ }, {}, {
7212
+ length: number | undefined;
7213
+ }>;
7108
7214
  errorCode: drizzle_orm_sqlite_core.SQLiteColumn<{
7109
7215
  name: "error_code";
7110
7216
  tableName: "agent_run";
@@ -9067,7 +9173,7 @@ declare function agentSchemaDdl(dialect: AgentDialect): string[];
9067
9173
  * MySQL (the host app owns the connection). Behaviour mirrors {@link import('@dudousxd/nestjs-agent-store-mikro-orm')}
9068
9174
  * exactly (fork/truncate/quota/active-stream/soft-delete semantics) so the two are interchangeable.
9069
9175
  */
9070
- declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore {
9176
+ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ThreadSettingsReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore {
9071
9177
  private readonly db;
9072
9178
  private readonly dialect;
9073
9179
  private readonly t;
@@ -9127,6 +9233,12 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9127
9233
  */
9128
9234
  private loadTurnWindow;
9129
9235
  listThreads(actorRef: string, limit?: number): Promise<ThreadSummary[]>;
9236
+ /**
9237
+ * The content of each thread's newest message ({@link messageOrderNewestFirst}), in a fixed two
9238
+ * reads for any number of threads: each thread's highest `seq`, then the rows holding it. Only a
9239
+ * thread whose every message predates `seq` is read on its own, by `created_at`.
9240
+ */
9241
+ private lastMessageContents;
9130
9242
  softDeleteThread(threadId: string): Promise<void>;
9131
9243
  forkThread(threadId: string, fromMessageId: string): Promise<ThreadSummary>;
9132
9244
  ownerOfThread(threadId: string): Promise<string | null>;
@@ -9198,6 +9310,7 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9198
9310
  modelForThread(threadId: string): Promise<string | null>;
9199
9311
  /** The thread's pinned persona, projected like {@link defaultAgentForThread}. */
9200
9312
  personaForThread(threadId: string): Promise<string | null>;
9313
+ threadSettings(threadId: string): Promise<ThreadSettings | null>;
9201
9314
  defaultAgentForThread(threadId: string): Promise<string | null>;
9202
9315
  /**
9203
9316
  * Persist the start of a run (turn). Replay-safe: called under a durable localStep.
@@ -9207,13 +9320,7 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9207
9320
  */
9208
9321
  recordRunStart(run: RecordRunStartInput): Promise<void>;
9209
9322
  /** Settle a run's outcome. A no-op when the run is unknown (mirrors `setTitle`/`updateThread`). */
9210
- recordRunEnd(end: {
9211
- runId: string;
9212
- status: 'completed' | 'failed' | 'cancelled';
9213
- durationMs?: number;
9214
- errorCode?: string;
9215
- errorMessage?: string;
9216
- }): Promise<void>;
9323
+ recordRunEnd(end: RecordRunEndInput): Promise<void>;
9217
9324
  /** Bump the run's llm-step retry counter. Atomic `retries = retries + 1`, no read-modify-write. */
9218
9325
  bumpRunRetries(runId: string): Promise<void>;
9219
9326
  appendMessage(input: AppendMessageInput): Promise<StoredMessage>;
@@ -9249,6 +9356,15 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
9249
9356
  recordGenuiCalls(rows: readonly RecordGenuiCallInput[]): Promise<void>;
9250
9357
  quotaToday(actorRef: string, day: string): Promise<UsageTotals>;
9251
9358
  usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<UsageTotals>;
9359
+ /**
9360
+ * Every range summed by the database in one statement, each as a conditional aggregate over the
9361
+ * rows of the smallest span covering them all — the actor's `(actor_ref, created_at)` index serves
9362
+ * it, and no usage row crosses the wire.
9363
+ */
9364
+ usageWindows(actorRef: string, ranges: readonly {
9365
+ fromDay: string;
9366
+ toDay: string;
9367
+ }[]): Promise<UsageTotals[]>;
9252
9368
  private toSummary;
9253
9369
  private toStoredMessage;
9254
9370
  }
@@ -9350,6 +9466,7 @@ declare class DrizzleGovernanceQueries implements AgentGovernanceQueries {
9350
9466
  /** Decorate an ordered thread list with its batched rollups, preserving the incoming order. */
9351
9467
  private toThreadActivityRows;
9352
9468
  recentThreads(limit: number): Promise<ThreadActivityRow[]>;
9469
+ /** The range's runs, with only the columns the rollups read. */
9353
9470
  private runsInRange;
9354
9471
  runMetrics(range: GovernanceRange): Promise<RunMetrics>;
9355
9472
  runsByAgent(range: GovernanceRange): Promise<RunAgentBreakdownRow[]>;
@@ -12264,6 +12381,57 @@ declare const pgAgentSchema: {
12264
12381
  identity: undefined;
12265
12382
  generated: undefined;
12266
12383
  }, {}, {}>;
12384
+ ttftMs: drizzle_orm_pg_core.PgColumn<{
12385
+ name: "ttft_ms";
12386
+ tableName: "agent_run";
12387
+ dataType: "number";
12388
+ columnType: "PgInteger";
12389
+ data: number;
12390
+ driverParam: string | number;
12391
+ notNull: false;
12392
+ hasDefault: false;
12393
+ isPrimaryKey: false;
12394
+ isAutoincrement: false;
12395
+ hasRuntimeDefault: false;
12396
+ enumValues: undefined;
12397
+ baseColumn: never;
12398
+ identity: undefined;
12399
+ generated: undefined;
12400
+ }, {}, {}>;
12401
+ costUsd: drizzle_orm_pg_core.PgColumn<{
12402
+ name: "cost_usd";
12403
+ tableName: "agent_run";
12404
+ dataType: "number";
12405
+ columnType: "PgDoublePrecision";
12406
+ data: number;
12407
+ driverParam: string | number;
12408
+ notNull: false;
12409
+ hasDefault: false;
12410
+ isPrimaryKey: false;
12411
+ isAutoincrement: false;
12412
+ hasRuntimeDefault: false;
12413
+ enumValues: undefined;
12414
+ baseColumn: never;
12415
+ identity: undefined;
12416
+ generated: undefined;
12417
+ }, {}, {}>;
12418
+ modelId: drizzle_orm_pg_core.PgColumn<{
12419
+ name: "model_id";
12420
+ tableName: "agent_run";
12421
+ dataType: "string";
12422
+ columnType: "PgText";
12423
+ data: string;
12424
+ driverParam: string;
12425
+ notNull: false;
12426
+ hasDefault: false;
12427
+ isPrimaryKey: false;
12428
+ isAutoincrement: false;
12429
+ hasRuntimeDefault: false;
12430
+ enumValues: [string, ...string[]];
12431
+ baseColumn: never;
12432
+ identity: undefined;
12433
+ generated: undefined;
12434
+ }, {}, {}>;
12267
12435
  errorCode: drizzle_orm_pg_core.PgColumn<{
12268
12436
  name: "error_code";
12269
12437
  tableName: "agent_run";
@@ -16420,6 +16588,57 @@ declare const mysqlAgentSchema: {
16420
16588
  identity: undefined;
16421
16589
  generated: undefined;
16422
16590
  }, {}, {}>;
16591
+ ttftMs: drizzle_orm_mysql_core.MySqlColumn<{
16592
+ name: "ttft_ms";
16593
+ tableName: "agent_run";
16594
+ dataType: "number";
16595
+ columnType: "MySqlInt";
16596
+ data: number;
16597
+ driverParam: string | number;
16598
+ notNull: false;
16599
+ hasDefault: false;
16600
+ isPrimaryKey: false;
16601
+ isAutoincrement: false;
16602
+ hasRuntimeDefault: false;
16603
+ enumValues: undefined;
16604
+ baseColumn: never;
16605
+ identity: undefined;
16606
+ generated: undefined;
16607
+ }, {}, {}>;
16608
+ costUsd: drizzle_orm_mysql_core.MySqlColumn<{
16609
+ name: "cost_usd";
16610
+ tableName: "agent_run";
16611
+ dataType: "number";
16612
+ columnType: "MySqlDouble";
16613
+ data: number;
16614
+ driverParam: string | number;
16615
+ notNull: false;
16616
+ hasDefault: false;
16617
+ isPrimaryKey: false;
16618
+ isAutoincrement: false;
16619
+ hasRuntimeDefault: false;
16620
+ enumValues: undefined;
16621
+ baseColumn: never;
16622
+ identity: undefined;
16623
+ generated: undefined;
16624
+ }, {}, {}>;
16625
+ modelId: drizzle_orm_mysql_core.MySqlColumn<{
16626
+ name: string;
16627
+ tableName: "agent_run";
16628
+ dataType: "string";
16629
+ columnType: "MySqlVarChar";
16630
+ data: string;
16631
+ driverParam: string | number;
16632
+ notNull: false;
16633
+ hasDefault: false;
16634
+ isPrimaryKey: false;
16635
+ isAutoincrement: false;
16636
+ hasRuntimeDefault: false;
16637
+ enumValues: [string, ...string[]];
16638
+ baseColumn: never;
16639
+ identity: undefined;
16640
+ generated: undefined;
16641
+ }, {}, {}>;
16423
16642
  errorCode: drizzle_orm_mysql_core.MySqlColumn<{
16424
16643
  name: string;
16425
16644
  tableName: "agent_run";