@dudousxd/nestjs-agent-store-drizzle 0.27.1 → 0.28.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, 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, 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, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim } from '@dudousxd/nestjs-agent-core';
2
+ import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, 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, 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, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore } 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';
@@ -2436,6 +2436,92 @@ declare const ragIngestionLog: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2436
2436
  };
2437
2437
  dialect: "sqlite";
2438
2438
  }>;
2439
+ /**
2440
+ * Text channels' short-lived state (`@dudousxd/nestjs-agent-channels`), one row per key: the provider
2441
+ * message ids already answered, a question waiting for the person's answer, an outcome already
2442
+ * relayed. The primary key is the lock a claim takes; `expires_at` is epoch-ms, and past it the row
2443
+ * is free again and dead weight for `DrizzleChannelStore.purgeExpired`. Keys longer than 255
2444
+ * characters are stored by their SHA-256.
2445
+ */
2446
+ declare const agentChannelState: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2447
+ name: "agent_channel_state";
2448
+ schema: undefined;
2449
+ columns: {
2450
+ key: drizzle_orm_sqlite_core.SQLiteColumn<{
2451
+ name: "key";
2452
+ tableName: "agent_channel_state";
2453
+ dataType: "string";
2454
+ columnType: "SQLiteText";
2455
+ data: string;
2456
+ driverParam: string;
2457
+ notNull: true;
2458
+ hasDefault: false;
2459
+ isPrimaryKey: true;
2460
+ isAutoincrement: false;
2461
+ hasRuntimeDefault: false;
2462
+ enumValues: [string, ...string[]];
2463
+ baseColumn: never;
2464
+ identity: undefined;
2465
+ generated: undefined;
2466
+ }, {}, {
2467
+ length: number | undefined;
2468
+ }>;
2469
+ value: drizzle_orm_sqlite_core.SQLiteColumn<{
2470
+ name: "value";
2471
+ tableName: "agent_channel_state";
2472
+ dataType: "string";
2473
+ columnType: "SQLiteText";
2474
+ data: string;
2475
+ driverParam: string;
2476
+ notNull: false;
2477
+ hasDefault: false;
2478
+ isPrimaryKey: false;
2479
+ isAutoincrement: false;
2480
+ hasRuntimeDefault: false;
2481
+ enumValues: [string, ...string[]];
2482
+ baseColumn: never;
2483
+ identity: undefined;
2484
+ generated: undefined;
2485
+ }, {}, {
2486
+ length: number | undefined;
2487
+ }>;
2488
+ expiresAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2489
+ name: "expires_at";
2490
+ tableName: "agent_channel_state";
2491
+ dataType: "number";
2492
+ columnType: "SQLiteInteger";
2493
+ data: number;
2494
+ driverParam: number;
2495
+ notNull: true;
2496
+ hasDefault: false;
2497
+ isPrimaryKey: false;
2498
+ isAutoincrement: false;
2499
+ hasRuntimeDefault: false;
2500
+ enumValues: undefined;
2501
+ baseColumn: never;
2502
+ identity: undefined;
2503
+ generated: undefined;
2504
+ }, {}, {}>;
2505
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
2506
+ name: "created_at";
2507
+ tableName: "agent_channel_state";
2508
+ dataType: "number";
2509
+ columnType: "SQLiteInteger";
2510
+ data: number;
2511
+ driverParam: number;
2512
+ notNull: true;
2513
+ hasDefault: false;
2514
+ isPrimaryKey: false;
2515
+ isAutoincrement: false;
2516
+ hasRuntimeDefault: false;
2517
+ enumValues: undefined;
2518
+ baseColumn: never;
2519
+ identity: undefined;
2520
+ generated: undefined;
2521
+ }, {}, {}>;
2522
+ };
2523
+ dialect: "sqlite";
2524
+ }>;
2439
2525
  /**
2440
2526
  * Spent confirm tokens (`defineConfirmedTool`), one row per token, keyed by its SHA-256 — the
2441
2527
  * primary key is the lock that makes a confirmation single use across replicas. Only the hash, the
@@ -5671,6 +5757,85 @@ declare const agentSchema: {
5671
5757
  };
5672
5758
  dialect: "sqlite";
5673
5759
  }>;
5760
+ agentChannelState: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
5761
+ name: "agent_channel_state";
5762
+ schema: undefined;
5763
+ columns: {
5764
+ key: drizzle_orm_sqlite_core.SQLiteColumn<{
5765
+ name: "key";
5766
+ tableName: "agent_channel_state";
5767
+ dataType: "string";
5768
+ columnType: "SQLiteText";
5769
+ data: string;
5770
+ driverParam: string;
5771
+ notNull: true;
5772
+ hasDefault: false;
5773
+ isPrimaryKey: true;
5774
+ isAutoincrement: false;
5775
+ hasRuntimeDefault: false;
5776
+ enumValues: [string, ...string[]];
5777
+ baseColumn: never;
5778
+ identity: undefined;
5779
+ generated: undefined;
5780
+ }, {}, {
5781
+ length: number | undefined;
5782
+ }>;
5783
+ value: drizzle_orm_sqlite_core.SQLiteColumn<{
5784
+ name: "value";
5785
+ tableName: "agent_channel_state";
5786
+ dataType: "string";
5787
+ columnType: "SQLiteText";
5788
+ data: string;
5789
+ driverParam: string;
5790
+ notNull: false;
5791
+ hasDefault: false;
5792
+ isPrimaryKey: false;
5793
+ isAutoincrement: false;
5794
+ hasRuntimeDefault: false;
5795
+ enumValues: [string, ...string[]];
5796
+ baseColumn: never;
5797
+ identity: undefined;
5798
+ generated: undefined;
5799
+ }, {}, {
5800
+ length: number | undefined;
5801
+ }>;
5802
+ expiresAt: drizzle_orm_sqlite_core.SQLiteColumn<{
5803
+ name: "expires_at";
5804
+ tableName: "agent_channel_state";
5805
+ dataType: "number";
5806
+ columnType: "SQLiteInteger";
5807
+ data: number;
5808
+ driverParam: number;
5809
+ notNull: true;
5810
+ hasDefault: false;
5811
+ isPrimaryKey: false;
5812
+ isAutoincrement: false;
5813
+ hasRuntimeDefault: false;
5814
+ enumValues: undefined;
5815
+ baseColumn: never;
5816
+ identity: undefined;
5817
+ generated: undefined;
5818
+ }, {}, {}>;
5819
+ createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
5820
+ name: "created_at";
5821
+ tableName: "agent_channel_state";
5822
+ dataType: "number";
5823
+ columnType: "SQLiteInteger";
5824
+ data: number;
5825
+ driverParam: number;
5826
+ notNull: true;
5827
+ hasDefault: false;
5828
+ isPrimaryKey: false;
5829
+ isAutoincrement: false;
5830
+ hasRuntimeDefault: false;
5831
+ enumValues: undefined;
5832
+ baseColumn: never;
5833
+ identity: undefined;
5834
+ generated: undefined;
5835
+ }, {}, {}>;
5836
+ };
5837
+ dialect: "sqlite";
5838
+ }>;
5674
5839
  agentStreamFrame: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
5675
5840
  name: "agent_stream_frame";
5676
5841
  schema: undefined;
@@ -6291,6 +6456,34 @@ declare class DrizzleConfirmTokenStore implements ConfirmTokenStore {
6291
6456
  purgeExpired(now?: number): Promise<number>;
6292
6457
  }
6293
6458
 
6459
+ interface DrizzleChannelStoreOptions {
6460
+ /** How often a claim also deletes expired rows. Default 10 minutes; `0` → never (purge yourself). */
6461
+ purgeEveryMs?: number;
6462
+ }
6463
+ /**
6464
+ * A `ChannelStore` (text channels, `@dudousxd/nestjs-agent-channels`) over the `agent_channel_state`
6465
+ * table — shared by every replica, no Redis needed.
6466
+ *
6467
+ * A claim deletes the key's row when it expired, then inserts it skipping a duplicate key —
6468
+ * `ON CONFLICT DO NOTHING` on SQLite and Postgres, `INSERT IGNORE` on MySQL — so the primary key is
6469
+ * the lock: of two concurrent claims one inserts and the other touches no row. Expired rows are
6470
+ * deleted as claims arrive (`purgeEveryMs`), or by {@link purgeExpired} from a job. The table comes
6471
+ * from `ensureAgentSchema` (or your own migration).
6472
+ */
6473
+ declare class DrizzleChannelStore implements ChannelStore {
6474
+ private readonly db;
6475
+ private readonly dialect;
6476
+ private readonly t;
6477
+ private readonly purgeEveryMs;
6478
+ private lastPurge;
6479
+ constructor(db: AgentDrizzleDb, options?: DrizzleChannelStoreOptions);
6480
+ claim(key: string, ttlMs: number): Promise<boolean>;
6481
+ get(key: string): Promise<string | null>;
6482
+ set(key: string, value: string, ttlMs: number): Promise<void>;
6483
+ delete(key: string): Promise<void>;
6484
+ purgeExpired(now?: number): Promise<number>;
6485
+ }
6486
+
6294
6487
  /**
6295
6488
  * The paging order: newest first, tiebroken on the primary key.
6296
6489
  *
@@ -6508,7 +6701,8 @@ interface DrizzleAgentStoreModuleOptions {
6508
6701
  * `@dudousxd/nestjs-agent`, plus {@link DrizzleGovernanceQueries} to
6509
6702
  * {@link AGENT_GOVERNANCE_QUERIES} (the read-model the dashboard/telescope surfaces consume) and
6510
6703
  * {@link DrizzlePricingStore} to {@link AGENT_PRICING_STORE} (the write side of that pricing table),
6511
- * and {@link DrizzleConfirmTokenStore} to {@link AGENT_CONFIRM_TOKEN_STORE} (confirmed writes).
6704
+ * {@link DrizzleConfirmTokenStore} to {@link AGENT_CONFIRM_TOKEN_STORE} (confirmed writes), and
6705
+ * {@link DrizzleChannelStore} to {@link AGENT_CHANNEL_STORE} (text channels' state).
6512
6706
  * The host app supplies an already-opened Drizzle db — this module never opens a connection itself.
6513
6707
  *
6514
6708
  * The returned module is global, so {@link AGENT_STORE}, {@link AGENT_GOVERNANCE_QUERIES} and
@@ -9100,6 +9294,81 @@ declare const pgAgentSchema: {
9100
9294
  };
9101
9295
  dialect: "pg";
9102
9296
  }>;
9297
+ agentChannelState: drizzle_orm_pg_core.PgTableWithColumns<{
9298
+ name: "agent_channel_state";
9299
+ schema: undefined;
9300
+ columns: {
9301
+ key: drizzle_orm_pg_core.PgColumn<{
9302
+ name: "key";
9303
+ tableName: "agent_channel_state";
9304
+ dataType: "string";
9305
+ columnType: "PgText";
9306
+ data: string;
9307
+ driverParam: string;
9308
+ notNull: true;
9309
+ hasDefault: false;
9310
+ isPrimaryKey: true;
9311
+ isAutoincrement: false;
9312
+ hasRuntimeDefault: false;
9313
+ enumValues: [string, ...string[]];
9314
+ baseColumn: never;
9315
+ identity: undefined;
9316
+ generated: undefined;
9317
+ }, {}, {}>;
9318
+ value: drizzle_orm_pg_core.PgColumn<{
9319
+ name: "value";
9320
+ tableName: "agent_channel_state";
9321
+ dataType: "string";
9322
+ columnType: "PgText";
9323
+ data: string;
9324
+ driverParam: string;
9325
+ notNull: false;
9326
+ hasDefault: false;
9327
+ isPrimaryKey: false;
9328
+ isAutoincrement: false;
9329
+ hasRuntimeDefault: false;
9330
+ enumValues: [string, ...string[]];
9331
+ baseColumn: never;
9332
+ identity: undefined;
9333
+ generated: undefined;
9334
+ }, {}, {}>;
9335
+ expiresAt: drizzle_orm_pg_core.PgColumn<{
9336
+ name: "expires_at";
9337
+ tableName: "agent_channel_state";
9338
+ dataType: "number";
9339
+ columnType: "PgBigInt53";
9340
+ data: number;
9341
+ driverParam: string | number;
9342
+ notNull: true;
9343
+ hasDefault: false;
9344
+ isPrimaryKey: false;
9345
+ isAutoincrement: false;
9346
+ hasRuntimeDefault: false;
9347
+ enumValues: undefined;
9348
+ baseColumn: never;
9349
+ identity: undefined;
9350
+ generated: undefined;
9351
+ }, {}, {}>;
9352
+ createdAt: drizzle_orm_pg_core.PgColumn<{
9353
+ name: "created_at";
9354
+ tableName: "agent_channel_state";
9355
+ dataType: "number";
9356
+ columnType: "PgBigInt53";
9357
+ data: number;
9358
+ driverParam: string | number;
9359
+ notNull: true;
9360
+ hasDefault: false;
9361
+ isPrimaryKey: false;
9362
+ isAutoincrement: false;
9363
+ hasRuntimeDefault: false;
9364
+ enumValues: undefined;
9365
+ baseColumn: never;
9366
+ identity: undefined;
9367
+ generated: undefined;
9368
+ }, {}, {}>;
9369
+ };
9370
+ dialect: "pg";
9371
+ }>;
9103
9372
  agentStreamFrame: drizzle_orm_pg_core.PgTableWithColumns<{
9104
9373
  name: "agent_stream_frame";
9105
9374
  schema: undefined;
@@ -11767,6 +12036,81 @@ declare const mysqlAgentSchema: {
11767
12036
  };
11768
12037
  dialect: "mysql";
11769
12038
  }>;
12039
+ agentChannelState: drizzle_orm_mysql_core.MySqlTableWithColumns<{
12040
+ name: "agent_channel_state";
12041
+ schema: undefined;
12042
+ columns: {
12043
+ key: drizzle_orm_mysql_core.MySqlColumn<{
12044
+ name: string;
12045
+ tableName: "agent_channel_state";
12046
+ dataType: "string";
12047
+ columnType: "MySqlVarChar";
12048
+ data: string;
12049
+ driverParam: string | number;
12050
+ notNull: true;
12051
+ hasDefault: false;
12052
+ isPrimaryKey: true;
12053
+ isAutoincrement: false;
12054
+ hasRuntimeDefault: false;
12055
+ enumValues: [string, ...string[]];
12056
+ baseColumn: never;
12057
+ identity: undefined;
12058
+ generated: undefined;
12059
+ }, {}, {}>;
12060
+ value: drizzle_orm_mysql_core.MySqlColumn<{
12061
+ name: "value";
12062
+ tableName: "agent_channel_state";
12063
+ dataType: "string";
12064
+ columnType: "MySqlText";
12065
+ data: string;
12066
+ driverParam: string;
12067
+ notNull: false;
12068
+ hasDefault: false;
12069
+ isPrimaryKey: false;
12070
+ isAutoincrement: false;
12071
+ hasRuntimeDefault: false;
12072
+ enumValues: [string, ...string[]];
12073
+ baseColumn: never;
12074
+ identity: undefined;
12075
+ generated: undefined;
12076
+ }, {}, {}>;
12077
+ expiresAt: drizzle_orm_mysql_core.MySqlColumn<{
12078
+ name: "expires_at";
12079
+ tableName: "agent_channel_state";
12080
+ dataType: "number";
12081
+ columnType: "MySqlBigInt53";
12082
+ data: number;
12083
+ driverParam: string | number;
12084
+ notNull: true;
12085
+ hasDefault: false;
12086
+ isPrimaryKey: false;
12087
+ isAutoincrement: false;
12088
+ hasRuntimeDefault: false;
12089
+ enumValues: undefined;
12090
+ baseColumn: never;
12091
+ identity: undefined;
12092
+ generated: undefined;
12093
+ }, {}, {}>;
12094
+ createdAt: drizzle_orm_mysql_core.MySqlColumn<{
12095
+ name: "created_at";
12096
+ tableName: "agent_channel_state";
12097
+ dataType: "number";
12098
+ columnType: "MySqlBigInt53";
12099
+ data: number;
12100
+ driverParam: string | number;
12101
+ notNull: true;
12102
+ hasDefault: false;
12103
+ isPrimaryKey: false;
12104
+ isAutoincrement: false;
12105
+ hasRuntimeDefault: false;
12106
+ enumValues: undefined;
12107
+ baseColumn: never;
12108
+ identity: undefined;
12109
+ generated: undefined;
12110
+ }, {}, {}>;
12111
+ };
12112
+ dialect: "mysql";
12113
+ }>;
11770
12114
  agentStreamFrame: drizzle_orm_mysql_core.MySqlTableWithColumns<{
11771
12115
  name: "agent_stream_frame";
11772
12116
  schema: undefined;
@@ -11861,4 +12205,4 @@ declare const mysqlAgentSchema: {
11861
12205
  }>;
11862
12206
  };
11863
12207
 
11864
- export { type AgentDialect, type AgentDrizzleDb, type AgentMemoryRow, type AgentMessageRow, type AgentMySqlDb, type AgentPgDb, type AgentQueuedMessageRow, type AgentRunRow, type AgentRunStatus, type AgentSqliteDb, type AgentThreadRow, DrizzleActionProposalStore, DrizzleAgentStore, DrizzleAgentStoreModule, type DrizzleAgentStoreModuleOptions, DrizzleConfirmTokenStore, DrizzleGovernanceQueries, DrizzleMemoryProvider, DrizzlePricingStore, DrizzleRagIngestionLog, DrizzleStreamFrameTable, DrizzleTokenStreamSink, RAG_INGESTION_LOG_PAGE_ORDER, type RagIngestionLogCursor, type RagIngestionLogIterateOptions, type RagIngestionLogQuery, type RagIngestionLogRow, type RagIngestionLogWhere, type RagIngestionStatus, agentActionProposal, agentConfirmToken, agentDialectOf, agentMemory, agentMessage, agentModelPricing, agentQueuedMessage, agentRun, agentSchema, agentSchemaDdl, agentStreamFrame, agentThread, agentTokenUsage, agentToolCall, ensureAgentSchema, mysqlAgentSchema, pgAgentSchema, ragIngestionLog };
12208
+ export { type AgentDialect, type AgentDrizzleDb, type AgentMemoryRow, type AgentMessageRow, type AgentMySqlDb, type AgentPgDb, type AgentQueuedMessageRow, type AgentRunRow, type AgentRunStatus, type AgentSqliteDb, type AgentThreadRow, DrizzleActionProposalStore, DrizzleAgentStore, DrizzleAgentStoreModule, type DrizzleAgentStoreModuleOptions, DrizzleChannelStore, type DrizzleChannelStoreOptions, DrizzleConfirmTokenStore, DrizzleGovernanceQueries, DrizzleMemoryProvider, DrizzlePricingStore, DrizzleRagIngestionLog, DrizzleStreamFrameTable, DrizzleTokenStreamSink, RAG_INGESTION_LOG_PAGE_ORDER, type RagIngestionLogCursor, type RagIngestionLogIterateOptions, type RagIngestionLogQuery, type RagIngestionLogRow, type RagIngestionLogWhere, type RagIngestionStatus, agentActionProposal, agentChannelState, agentConfirmToken, agentDialectOf, agentMemory, agentMessage, agentModelPricing, agentQueuedMessage, agentRun, agentSchema, agentSchemaDdl, agentStreamFrame, agentThread, agentTokenUsage, agentToolCall, ensureAgentSchema, mysqlAgentSchema, pgAgentSchema, ragIngestionLog };