@dudousxd/nestjs-agent-store-drizzle 0.29.12 → 0.31.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.js CHANGED
@@ -193,6 +193,37 @@ var agentTokenUsage = sqliteTable("agent_token_usage", {
193
193
  }, (table) => [
194
194
  index("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
195
195
  ]);
196
+ var agentGenuiCall = sqliteTable("agent_genui_call", {
197
+ id: text("id").primaryKey(),
198
+ runId: text("run_id").notNull(),
199
+ threadId: text("thread_id").notNull().references(() => agentThread.id, {
200
+ onDelete: "cascade"
201
+ }),
202
+ actorRef: text("actor_ref").notNull(),
203
+ agentName: text("agent_name"),
204
+ step: integer("step").notNull(),
205
+ toolName: text("tool_name").notNull(),
206
+ channel: text("channel").notNull(),
207
+ mode: text("mode").$type().notNull(),
208
+ modelId: text("model_id").notNull(),
209
+ attempt: integer("attempt").notNull(),
210
+ outcome: text("outcome").$type().notNull(),
211
+ validity: text("validity").$type().notNull(),
212
+ errorCategory: text("error_category").$type(),
213
+ errorMessage: text("error_message"),
214
+ inputTokens: integer("input_tokens").notNull(),
215
+ outputTokens: integer("output_tokens").notNull(),
216
+ costUsd: real("cost_usd"),
217
+ costSource: text("cost_source").$type(),
218
+ firstFrameMs: integer("first_frame_ms"),
219
+ completeFrameMs: integer("complete_frame_ms"),
220
+ payloadBytes: integer("payload_bytes").notNull(),
221
+ payload: text("payload"),
222
+ createdAt: integer("created_at").notNull()
223
+ }, (table) => [
224
+ index("agent_genui_call_created_idx").on(table.createdAt),
225
+ index("agent_genui_call_run_idx").on(table.runId)
226
+ ]);
196
227
  var agentModelPricing = sqliteTable("agent_model_pricing", {
197
228
  id: text("id").primaryKey(),
198
229
  modelId: text("model_id").notNull(),
@@ -350,6 +381,94 @@ var agentActionProposal = sqliteTable("agent_action_proposal", {
350
381
  uniqueIndex("agent_action_proposal_outcome_idx").on(table.outcomeIdKey),
351
382
  index("agent_action_proposal_scope_idx").on(table.scopeKey, table.createdAt, table.id)
352
383
  ]);
384
+ var agentPoppyConversation = sqliteTable("agent_poppy_conversation", {
385
+ id: text("id").primaryKey(),
386
+ clientId: text("client_id").notNull(),
387
+ userId: text("user_id").notNull(),
388
+ accountRef: text("account_ref"),
389
+ agentName: text("agent_name").notNull(),
390
+ threadId: text("thread_id"),
391
+ parentId: text("parent_id"),
392
+ openDirectId: text("open_direct_id"),
393
+ status: text("status").notNull(),
394
+ responder: text("responder").notNull(),
395
+ context: text("context"),
396
+ activeRunId: text("active_run_id"),
397
+ turnSeq: integer("turn_seq").notNull(),
398
+ grantInfo: text("grant_info"),
399
+ readerHolder: text("reader_holder"),
400
+ readerUntil: integer("reader_until"),
401
+ prunedSeq: integer("pruned_seq").notNull(),
402
+ createdAt: integer("created_at").notNull(),
403
+ updatedAt: integer("updated_at").notNull()
404
+ });
405
+ var agentPoppyEvent = sqliteTable("agent_poppy_event", {
406
+ conversationId: text("conversation_id").notNull(),
407
+ seq: integer("seq").notNull(),
408
+ id: text("id").notNull(),
409
+ type: text("type").notNull(),
410
+ event: text("event").notNull(),
411
+ eventKey: text("event_key"),
412
+ createdAt: integer("created_at").notNull()
413
+ }, (table) => [
414
+ primaryKey({
415
+ columns: [
416
+ table.conversationId,
417
+ table.seq
418
+ ]
419
+ }),
420
+ uniqueIndex("agent_poppy_event_key_idx").on(table.conversationId, table.eventKey),
421
+ index("agent_poppy_event_id_idx").on(table.conversationId, table.id)
422
+ ]);
423
+ var agentPoppyMessage = sqliteTable("agent_poppy_message", {
424
+ owner: text("owner").notNull(),
425
+ messageId: text("message_id").notNull(),
426
+ fingerprint: text("fingerprint").notNull(),
427
+ conversationId: text("conversation_id").notNull(),
428
+ response: text("response").notNull(),
429
+ createdAt: integer("created_at").notNull()
430
+ }, (table) => [
431
+ primaryKey({
432
+ columns: [
433
+ table.owner,
434
+ table.messageId
435
+ ]
436
+ })
437
+ ]);
438
+ var agentPoppyConnection = sqliteTable("agent_poppy_connection", {
439
+ owner: text("owner").notNull(),
440
+ issuer: text("issuer").notNull(),
441
+ domain: text("domain").notNull(),
442
+ organization: text("organization").notNull(),
443
+ scope: text("scope").notNull(),
444
+ status: text("status").notNull(),
445
+ state: text("state").notNull(),
446
+ createdAt: integer("created_at").notNull(),
447
+ updatedAt: integer("updated_at").notNull()
448
+ }, (table) => [
449
+ primaryKey({
450
+ columns: [
451
+ table.owner,
452
+ table.issuer
453
+ ]
454
+ })
455
+ ]);
456
+ var agentPoppyConnect = sqliteTable("agent_poppy_connect", {
457
+ id: text("id").primaryKey(),
458
+ owner: text("owner").notNull(),
459
+ domain: text("domain").notNull(),
460
+ issuer: text("issuer").notNull(),
461
+ organization: text("organization").notNull(),
462
+ scope: text("scope").notNull(),
463
+ actor: text("actor"),
464
+ threadId: text("thread_id"),
465
+ runId: text("run_id"),
466
+ toolCallId: text("tool_call_id"),
467
+ flow: text("flow"),
468
+ status: text("status").notNull(),
469
+ expiresAt: integer("expires_at").notNull(),
470
+ createdAt: integer("created_at").notNull()
471
+ });
353
472
  var agentSchema = {
354
473
  agentActionProposal,
355
474
  agentThread,
@@ -357,13 +476,19 @@ var agentSchema = {
357
476
  agentQueuedMessage,
358
477
  agentToolCall,
359
478
  agentTokenUsage,
479
+ agentGenuiCall,
360
480
  agentModelPricing,
361
481
  agentRun,
362
482
  agentMemory,
363
483
  ragIngestionLog,
364
484
  agentConfirmToken,
365
485
  agentChannelState,
366
- agentStreamFrame
486
+ agentStreamFrame,
487
+ agentPoppyConversation,
488
+ agentPoppyEvent,
489
+ agentPoppyMessage,
490
+ agentPoppyConnection,
491
+ agentPoppyConnect
367
492
  };
368
493
 
369
494
  // src/ensure-schema.ts
@@ -498,6 +623,45 @@ var agentTokenUsage2 = mysqlTable("agent_token_usage", {
498
623
  }, (table) => [
499
624
  index2("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
500
625
  ]);
626
+ var agentGenuiCall2 = mysqlTable("agent_genui_call", {
627
+ id: key("id").primaryKey(),
628
+ runId: key("run_id").notNull(),
629
+ threadId: key("thread_id").notNull().references(() => agentThread2.id, {
630
+ onDelete: "cascade"
631
+ }),
632
+ actorRef: key("actor_ref").notNull(),
633
+ agentName: key("agent_name"),
634
+ step: int("step").notNull(),
635
+ toolName: key("tool_name").notNull(),
636
+ channel: key("channel").notNull(),
637
+ mode: key("mode").$type().notNull(),
638
+ modelId: key("model_id").notNull(),
639
+ attempt: int("attempt").notNull(),
640
+ outcome: key("outcome").$type().notNull(),
641
+ validity: key("validity").$type().notNull(),
642
+ errorCategory: key("error_category").$type(),
643
+ errorMessage: longtext("error_message"),
644
+ inputTokens: int("input_tokens").notNull(),
645
+ outputTokens: int("output_tokens").notNull(),
646
+ costUsd: double("cost_usd"),
647
+ costSource: varchar("cost_source", {
648
+ length: 16
649
+ }).$type(),
650
+ firstFrameMs: bigint("first_frame_ms", {
651
+ mode: "number"
652
+ }),
653
+ completeFrameMs: bigint("complete_frame_ms", {
654
+ mode: "number"
655
+ }),
656
+ payloadBytes: int("payload_bytes").notNull(),
657
+ payload: longtext("payload"),
658
+ createdAt: bigint("created_at", {
659
+ mode: "number"
660
+ }).notNull()
661
+ }, (table) => [
662
+ index2("agent_genui_call_created_idx").on(table.createdAt),
663
+ index2("agent_genui_call_run_idx").on(table.runId)
664
+ ]);
501
665
  var agentModelPricing2 = mysqlTable("agent_model_pricing", {
502
666
  id: key("id").primaryKey(),
503
667
  modelId: key("model_id").notNull(),
@@ -646,6 +810,124 @@ var agentActionProposal2 = mysqlTable("agent_action_proposal", {
646
810
  uniqueIndex2("agent_action_proposal_outcome_idx").on(table.outcomeIdKey),
647
811
  index2("agent_action_proposal_scope_idx").on(table.scopeKey, table.createdAt, table.id)
648
812
  ]);
813
+ var agentPoppyConversation2 = mysqlTable("agent_poppy_conversation", {
814
+ id: key("id").primaryKey(),
815
+ clientId: varchar("client_id", {
816
+ length: 2048
817
+ }).notNull(),
818
+ userId: key("user_id").notNull(),
819
+ accountRef: key("account_ref"),
820
+ agentName: key("agent_name").notNull(),
821
+ threadId: key("thread_id"),
822
+ parentId: key("parent_id"),
823
+ openDirectId: key("open_direct_id"),
824
+ status: key("status").notNull(),
825
+ responder: key("responder").notNull(),
826
+ context: longtext("context"),
827
+ activeRunId: key("active_run_id"),
828
+ turnSeq: bigint("turn_seq", {
829
+ mode: "number"
830
+ }).notNull(),
831
+ grantInfo: longtext("grant_info"),
832
+ readerHolder: key("reader_holder"),
833
+ readerUntil: bigint("reader_until", {
834
+ mode: "number"
835
+ }),
836
+ prunedSeq: bigint("pruned_seq", {
837
+ mode: "number"
838
+ }).notNull(),
839
+ createdAt: bigint("created_at", {
840
+ mode: "number"
841
+ }).notNull(),
842
+ updatedAt: bigint("updated_at", {
843
+ mode: "number"
844
+ }).notNull()
845
+ });
846
+ var agentPoppyEvent2 = mysqlTable("agent_poppy_event", {
847
+ conversationId: key("conversation_id").notNull(),
848
+ seq: bigint("seq", {
849
+ mode: "number"
850
+ }).notNull(),
851
+ id: key("id").notNull(),
852
+ type: key("type").notNull(),
853
+ event: longtext("event").notNull(),
854
+ eventKey: key("event_key"),
855
+ createdAt: bigint("created_at", {
856
+ mode: "number"
857
+ }).notNull()
858
+ }, (table) => [
859
+ primaryKey2({
860
+ columns: [
861
+ table.conversationId,
862
+ table.seq
863
+ ]
864
+ }),
865
+ uniqueIndex2("agent_poppy_event_key_idx").on(table.conversationId, table.eventKey),
866
+ index2("agent_poppy_event_id_idx").on(table.conversationId, table.id)
867
+ ]);
868
+ var agentPoppyMessage2 = mysqlTable("agent_poppy_message", {
869
+ owner: key("owner").notNull(),
870
+ messageId: key("message_id").notNull(),
871
+ fingerprint: key("fingerprint").notNull(),
872
+ conversationId: key("conversation_id").notNull(),
873
+ response: longtext("response").notNull(),
874
+ createdAt: bigint("created_at", {
875
+ mode: "number"
876
+ }).notNull()
877
+ }, (table) => [
878
+ primaryKey2({
879
+ columns: [
880
+ table.owner,
881
+ table.messageId
882
+ ]
883
+ })
884
+ ]);
885
+ var agentPoppyConnection2 = mysqlTable("agent_poppy_connection", {
886
+ owner: key("owner").notNull(),
887
+ issuer: varchar("issuer", {
888
+ length: 512
889
+ }).notNull(),
890
+ domain: key("domain").notNull(),
891
+ organization: key("organization").notNull(),
892
+ scope: longtext("scope").notNull(),
893
+ status: key("status").notNull(),
894
+ state: longtext("state").notNull(),
895
+ createdAt: bigint("created_at", {
896
+ mode: "number"
897
+ }).notNull(),
898
+ updatedAt: bigint("updated_at", {
899
+ mode: "number"
900
+ }).notNull()
901
+ }, (table) => [
902
+ primaryKey2({
903
+ columns: [
904
+ table.owner,
905
+ table.issuer
906
+ ]
907
+ })
908
+ ]);
909
+ var agentPoppyConnect2 = mysqlTable("agent_poppy_connect", {
910
+ id: key("id").primaryKey(),
911
+ owner: key("owner").notNull(),
912
+ domain: key("domain").notNull(),
913
+ issuer: varchar("issuer", {
914
+ length: 512
915
+ }).notNull(),
916
+ organization: key("organization").notNull(),
917
+ scope: longtext("scope").notNull(),
918
+ actor: longtext("actor"),
919
+ threadId: key("thread_id"),
920
+ runId: key("run_id"),
921
+ toolCallId: key("tool_call_id"),
922
+ flow: longtext("flow"),
923
+ status: key("status").notNull(),
924
+ expiresAt: bigint("expires_at", {
925
+ mode: "number"
926
+ }).notNull(),
927
+ createdAt: bigint("created_at", {
928
+ mode: "number"
929
+ }).notNull()
930
+ });
649
931
  var mysqlAgentSchema = {
650
932
  agentActionProposal: agentActionProposal2,
651
933
  agentThread: agentThread2,
@@ -653,18 +935,24 @@ var mysqlAgentSchema = {
653
935
  agentQueuedMessage: agentQueuedMessage2,
654
936
  agentToolCall: agentToolCall2,
655
937
  agentTokenUsage: agentTokenUsage2,
938
+ agentGenuiCall: agentGenuiCall2,
656
939
  agentModelPricing: agentModelPricing2,
657
940
  agentRun: agentRun2,
658
941
  agentMemory: agentMemory2,
659
942
  ragIngestionLog: ragIngestionLog2,
660
943
  agentConfirmToken: agentConfirmToken2,
661
944
  agentChannelState: agentChannelState2,
662
- agentStreamFrame: agentStreamFrame2
945
+ agentStreamFrame: agentStreamFrame2,
946
+ agentPoppyConversation: agentPoppyConversation2,
947
+ agentPoppyEvent: agentPoppyEvent2,
948
+ agentPoppyMessage: agentPoppyMessage2,
949
+ agentPoppyConnection: agentPoppyConnection2,
950
+ agentPoppyConnect: agentPoppyConnect2
663
951
  };
664
952
 
665
953
  // src/schema-pg.ts
666
954
  import { canonicalActionProposalJson as canonicalActionProposalJson2 } from "@dudousxd/nestjs-agent-core";
667
- import { bigint as bigint2, boolean as boolean2, customType as customType2, doublePrecision, index as index3, integer as integer2, jsonb, pgTable, primaryKey as primaryKey3, text as text2, timestamp, uniqueIndex as uniqueIndex3 } from "drizzle-orm/pg-core";
955
+ import { bigint as bigint2, boolean as boolean2, customType as customType2, doublePrecision, index as index3, integer as integer2, jsonb, pgTable, primaryKey as primaryKey3, text as text2, timestamp, uniqueIndex as uniqueIndex3, varchar as varchar2 } from "drizzle-orm/pg-core";
668
956
  var ts2 = /* @__PURE__ */ __name((name) => timestamp(name, {
669
957
  withTimezone: true,
670
958
  precision: 3,
@@ -781,6 +1069,45 @@ var agentTokenUsage3 = pgTable("agent_token_usage", {
781
1069
  }, (table) => [
782
1070
  index3("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
783
1071
  ]);
1072
+ var agentGenuiCall3 = pgTable("agent_genui_call", {
1073
+ id: text2("id").primaryKey(),
1074
+ runId: text2("run_id").notNull(),
1075
+ threadId: text2("thread_id").notNull().references(() => agentThread3.id, {
1076
+ onDelete: "cascade"
1077
+ }),
1078
+ actorRef: text2("actor_ref").notNull(),
1079
+ agentName: text2("agent_name"),
1080
+ step: integer2("step").notNull(),
1081
+ toolName: text2("tool_name").notNull(),
1082
+ channel: text2("channel").notNull(),
1083
+ mode: text2("mode").$type().notNull(),
1084
+ modelId: text2("model_id").notNull(),
1085
+ attempt: integer2("attempt").notNull(),
1086
+ outcome: text2("outcome").$type().notNull(),
1087
+ validity: text2("validity").$type().notNull(),
1088
+ errorCategory: text2("error_category").$type(),
1089
+ errorMessage: text2("error_message"),
1090
+ inputTokens: integer2("input_tokens").notNull(),
1091
+ outputTokens: integer2("output_tokens").notNull(),
1092
+ costUsd: doublePrecision("cost_usd"),
1093
+ costSource: varchar2("cost_source", {
1094
+ length: 16
1095
+ }).$type(),
1096
+ firstFrameMs: bigint2("first_frame_ms", {
1097
+ mode: "number"
1098
+ }),
1099
+ completeFrameMs: bigint2("complete_frame_ms", {
1100
+ mode: "number"
1101
+ }),
1102
+ payloadBytes: integer2("payload_bytes").notNull(),
1103
+ payload: text2("payload"),
1104
+ createdAt: bigint2("created_at", {
1105
+ mode: "number"
1106
+ }).notNull()
1107
+ }, (table) => [
1108
+ index3("agent_genui_call_created_idx").on(table.createdAt),
1109
+ index3("agent_genui_call_run_idx").on(table.runId)
1110
+ ]);
784
1111
  var agentModelPricing3 = pgTable("agent_model_pricing", {
785
1112
  id: text2("id").primaryKey(),
786
1113
  modelId: text2("model_id").notNull(),
@@ -927,6 +1254,118 @@ var agentActionProposal3 = pgTable("agent_action_proposal", {
927
1254
  uniqueIndex3("agent_action_proposal_outcome_idx").on(table.outcomeIdKey),
928
1255
  index3("agent_action_proposal_scope_idx").on(table.scopeKey, table.createdAt, table.id)
929
1256
  ]);
1257
+ var agentPoppyConversation3 = pgTable("agent_poppy_conversation", {
1258
+ id: text2("id").primaryKey(),
1259
+ clientId: text2("client_id").notNull(),
1260
+ userId: text2("user_id").notNull(),
1261
+ accountRef: text2("account_ref"),
1262
+ agentName: text2("agent_name").notNull(),
1263
+ threadId: text2("thread_id"),
1264
+ parentId: text2("parent_id"),
1265
+ openDirectId: text2("open_direct_id"),
1266
+ status: text2("status").notNull(),
1267
+ responder: text2("responder").notNull(),
1268
+ context: text2("context"),
1269
+ activeRunId: text2("active_run_id"),
1270
+ turnSeq: bigint2("turn_seq", {
1271
+ mode: "number"
1272
+ }).notNull(),
1273
+ grantInfo: text2("grant_info"),
1274
+ readerHolder: text2("reader_holder"),
1275
+ readerUntil: bigint2("reader_until", {
1276
+ mode: "number"
1277
+ }),
1278
+ prunedSeq: bigint2("pruned_seq", {
1279
+ mode: "number"
1280
+ }).notNull(),
1281
+ createdAt: bigint2("created_at", {
1282
+ mode: "number"
1283
+ }).notNull(),
1284
+ updatedAt: bigint2("updated_at", {
1285
+ mode: "number"
1286
+ }).notNull()
1287
+ });
1288
+ var agentPoppyEvent3 = pgTable("agent_poppy_event", {
1289
+ conversationId: text2("conversation_id").notNull(),
1290
+ seq: bigint2("seq", {
1291
+ mode: "number"
1292
+ }).notNull(),
1293
+ id: text2("id").notNull(),
1294
+ type: text2("type").notNull(),
1295
+ event: text2("event").notNull(),
1296
+ eventKey: text2("event_key"),
1297
+ createdAt: bigint2("created_at", {
1298
+ mode: "number"
1299
+ }).notNull()
1300
+ }, (table) => [
1301
+ primaryKey3({
1302
+ columns: [
1303
+ table.conversationId,
1304
+ table.seq
1305
+ ]
1306
+ }),
1307
+ uniqueIndex3("agent_poppy_event_key_idx").on(table.conversationId, table.eventKey),
1308
+ index3("agent_poppy_event_id_idx").on(table.conversationId, table.id)
1309
+ ]);
1310
+ var agentPoppyMessage3 = pgTable("agent_poppy_message", {
1311
+ owner: text2("owner").notNull(),
1312
+ messageId: text2("message_id").notNull(),
1313
+ fingerprint: text2("fingerprint").notNull(),
1314
+ conversationId: text2("conversation_id").notNull(),
1315
+ response: text2("response").notNull(),
1316
+ createdAt: bigint2("created_at", {
1317
+ mode: "number"
1318
+ }).notNull()
1319
+ }, (table) => [
1320
+ primaryKey3({
1321
+ columns: [
1322
+ table.owner,
1323
+ table.messageId
1324
+ ]
1325
+ })
1326
+ ]);
1327
+ var agentPoppyConnection3 = pgTable("agent_poppy_connection", {
1328
+ owner: text2("owner").notNull(),
1329
+ issuer: text2("issuer").notNull(),
1330
+ domain: text2("domain").notNull(),
1331
+ organization: text2("organization").notNull(),
1332
+ scope: text2("scope").notNull(),
1333
+ status: text2("status").notNull(),
1334
+ state: text2("state").notNull(),
1335
+ createdAt: bigint2("created_at", {
1336
+ mode: "number"
1337
+ }).notNull(),
1338
+ updatedAt: bigint2("updated_at", {
1339
+ mode: "number"
1340
+ }).notNull()
1341
+ }, (table) => [
1342
+ primaryKey3({
1343
+ columns: [
1344
+ table.owner,
1345
+ table.issuer
1346
+ ]
1347
+ })
1348
+ ]);
1349
+ var agentPoppyConnect3 = pgTable("agent_poppy_connect", {
1350
+ id: text2("id").primaryKey(),
1351
+ owner: text2("owner").notNull(),
1352
+ domain: text2("domain").notNull(),
1353
+ issuer: text2("issuer").notNull(),
1354
+ organization: text2("organization").notNull(),
1355
+ scope: text2("scope").notNull(),
1356
+ actor: text2("actor"),
1357
+ threadId: text2("thread_id"),
1358
+ runId: text2("run_id"),
1359
+ toolCallId: text2("tool_call_id"),
1360
+ flow: text2("flow"),
1361
+ status: text2("status").notNull(),
1362
+ expiresAt: bigint2("expires_at", {
1363
+ mode: "number"
1364
+ }).notNull(),
1365
+ createdAt: bigint2("created_at", {
1366
+ mode: "number"
1367
+ }).notNull()
1368
+ });
930
1369
  var pgAgentSchema = {
931
1370
  agentActionProposal: agentActionProposal3,
932
1371
  agentThread: agentThread3,
@@ -934,13 +1373,19 @@ var pgAgentSchema = {
934
1373
  agentQueuedMessage: agentQueuedMessage3,
935
1374
  agentToolCall: agentToolCall3,
936
1375
  agentTokenUsage: agentTokenUsage3,
1376
+ agentGenuiCall: agentGenuiCall3,
937
1377
  agentModelPricing: agentModelPricing3,
938
1378
  agentRun: agentRun3,
939
1379
  agentMemory: agentMemory3,
940
1380
  ragIngestionLog: ragIngestionLog3,
941
1381
  agentConfirmToken: agentConfirmToken3,
942
1382
  agentChannelState: agentChannelState3,
943
- agentStreamFrame: agentStreamFrame3
1383
+ agentStreamFrame: agentStreamFrame3,
1384
+ agentPoppyConversation: agentPoppyConversation3,
1385
+ agentPoppyEvent: agentPoppyEvent3,
1386
+ agentPoppyMessage: agentPoppyMessage3,
1387
+ agentPoppyConnection: agentPoppyConnection3,
1388
+ agentPoppyConnect: agentPoppyConnect3
944
1389
  };
945
1390
 
946
1391
  // src/dialect.ts
@@ -2538,6 +2983,44 @@ var DrizzleAgentStore = class {
2538
2983
  createdAt: /* @__PURE__ */ new Date()
2539
2984
  });
2540
2985
  }
2986
+ /**
2987
+ * Generative-UI telemetry: one `agent_genui_call` row per UI tool call, upserted by its tool call
2988
+ * id — a replayed record replaces the row (keeping the first `created_at`) rather than adding one.
2989
+ */
2990
+ async recordGenuiCalls(rows) {
2991
+ const table = this.t.agentGenuiCall;
2992
+ for (const row of rows) {
2993
+ const columns = {
2994
+ runId: row.runId,
2995
+ threadId: row.threadId,
2996
+ actorRef: row.actorRef,
2997
+ agentName: row.agentName ?? null,
2998
+ step: row.step,
2999
+ toolName: row.toolName,
3000
+ channel: row.channel,
3001
+ mode: row.mode,
3002
+ modelId: row.modelId,
3003
+ attempt: row.attempt,
3004
+ outcome: row.outcome,
3005
+ validity: row.validity,
3006
+ errorCategory: row.errorCategory ?? null,
3007
+ errorMessage: row.errorMessage ?? null,
3008
+ inputTokens: row.inputTokens,
3009
+ outputTokens: row.outputTokens,
3010
+ costUsd: row.costUsd ?? null,
3011
+ costSource: row.costSource ?? null,
3012
+ firstFrameMs: row.firstFrameMs ?? null,
3013
+ completeFrameMs: row.completeFrameMs ?? null,
3014
+ payloadBytes: row.payloadBytes,
3015
+ payload: row.payload ?? null
3016
+ };
3017
+ await upsert(this.dialect, this.db.insert(table).values({
3018
+ id: row.toolCallId,
3019
+ ...columns,
3020
+ createdAt: Date.now()
3021
+ }), table.id, columns);
3022
+ }
3023
+ }
2541
3024
  async quotaToday(actorRef, day) {
2542
3025
  return this.usageBetween(actorRef, day, day);
2543
3026
  }
@@ -2651,7 +3134,7 @@ function toQueuedMessage(row) {
2651
3134
  __name(toQueuedMessage, "toQueuedMessage");
2652
3135
 
2653
3136
  // src/drizzle-governance-queries.ts
2654
- import { bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, dayBoundsUtc, rollupThreadUsage, truncateDetailContent } from "@dudousxd/nestjs-agent-core";
3137
+ import { bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, dayBoundsUtc, rollupThreadUsage, summarizeGenuiCalls, truncateDetailContent } from "@dudousxd/nestjs-agent-core";
2655
3138
  import { and as and3, asc as asc3, count, desc as desc2, eq as eq3, gte as gte2, inArray as inArray2, isNull as isNull3, like, lte as lte3, sql as sql4, sum } from "drizzle-orm";
2656
3139
  var UNCLASSIFIED_ERROR_CODE = "unknown";
2657
3140
  var DEFAULT_AGENT_BUCKET = "(default)";
@@ -2710,6 +3193,51 @@ function emptyPage(query) {
2710
3193
  };
2711
3194
  }
2712
3195
  __name(emptyPage, "emptyPage");
3196
+ function toGenuiCallRow(row) {
3197
+ return {
3198
+ toolCallId: row.id,
3199
+ runId: row.runId,
3200
+ threadId: row.threadId,
3201
+ actorRef: row.actorRef,
3202
+ ...row.agentName !== null ? {
3203
+ agentName: row.agentName
3204
+ } : {},
3205
+ step: Number(row.step),
3206
+ toolName: row.toolName,
3207
+ channel: row.channel,
3208
+ mode: row.mode,
3209
+ modelId: row.modelId,
3210
+ attempt: Number(row.attempt),
3211
+ outcome: row.outcome,
3212
+ validity: row.validity,
3213
+ ...row.errorCategory !== null ? {
3214
+ errorCategory: row.errorCategory
3215
+ } : {},
3216
+ ...row.errorMessage !== null ? {
3217
+ errorMessage: row.errorMessage
3218
+ } : {},
3219
+ inputTokens: Number(row.inputTokens),
3220
+ outputTokens: Number(row.outputTokens),
3221
+ ...row.costUsd !== null ? {
3222
+ costUsd: Number(row.costUsd)
3223
+ } : {},
3224
+ ...row.costSource !== null ? {
3225
+ costSource: row.costSource
3226
+ } : {},
3227
+ ...row.firstFrameMs !== null ? {
3228
+ firstFrameMs: Number(row.firstFrameMs)
3229
+ } : {},
3230
+ ...row.completeFrameMs !== null ? {
3231
+ completeFrameMs: Number(row.completeFrameMs)
3232
+ } : {},
3233
+ payloadBytes: Number(row.payloadBytes),
3234
+ ...row.payload !== null ? {
3235
+ payload: row.payload
3236
+ } : {},
3237
+ createdAt: new Date(Number(row.createdAt))
3238
+ };
3239
+ }
3240
+ __name(toGenuiCallRow, "toGenuiCallRow");
2713
3241
  function toRecentRunRow(run) {
2714
3242
  return {
2715
3243
  runId: run.id,
@@ -3295,6 +3823,13 @@ var DrizzleGovernanceQueries = class {
3295
3823
  })
3296
3824
  };
3297
3825
  }
3826
+ /** Generative-UI stats over the `agent_genui_call` rows created in the (UTC, inclusive) day range. */
3827
+ async genuiStats(range) {
3828
+ const { start, end } = dayBoundsUtc(range);
3829
+ const table = this.t.agentGenuiCall;
3830
+ const rows = await this.db.select().from(table).where(and3(gte2(table.createdAt, start.getTime()), lte3(table.createdAt, end.getTime())));
3831
+ return summarizeGenuiCalls(rows.map(toGenuiCallRow));
3832
+ }
3298
3833
  /** Tool-call counts for a set of messages in ONE grouped query — the detail view's no-N+1 guarantee. */
3299
3834
  async toolCallCountsByMessage(messageIds) {
3300
3835
  const counts = /* @__PURE__ */ new Map();
@@ -3681,14 +4216,392 @@ var DrizzleChannelStore = class {
3681
4216
  }
3682
4217
  };
3683
4218
 
4219
+ // src/drizzle-poppy-store.ts
4220
+ import { newEventId } from "@dudousxd/nestjs-agent-core";
4221
+ import { and as and8, desc as desc3, eq as eq9, gt as gt4, isNull as isNull4, lt as lt3, lte as lte5, or as or3 } from "drizzle-orm";
4222
+ var MAX_APPEND_ATTEMPTS = 50;
4223
+ var sleep = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep");
4224
+ var nullable = /* @__PURE__ */ __name((value) => value == null ? null : String(value), "nullable");
4225
+ function toInt(value) {
4226
+ if (typeof value === "number") return value;
4227
+ if (typeof value === "bigint") return Number(value);
4228
+ if (typeof value === "string") return Number.parseInt(value, 10) || 0;
4229
+ return 0;
4230
+ }
4231
+ __name(toInt, "toInt");
4232
+ var PATCH_COLUMNS = {
4233
+ accountRef: "accountRef",
4234
+ threadId: "threadId",
4235
+ openDirectId: "openDirectId",
4236
+ status: "status",
4237
+ responder: "responder",
4238
+ context: "context",
4239
+ activeRunId: "activeRunId",
4240
+ turnSeq: "turnSeq",
4241
+ grant: "grantInfo",
4242
+ prunedSeq: "prunedSeq"
4243
+ };
4244
+ var DrizzlePoppyStore = class {
4245
+ static {
4246
+ __name(this, "DrizzlePoppyStore");
4247
+ }
4248
+ db;
4249
+ dialect;
4250
+ t;
4251
+ constructor(db) {
4252
+ this.dialect = agentDialectOf(db);
4253
+ this.t = agentTablesFor(this.dialect);
4254
+ this.db = asBuilder(db);
4255
+ }
4256
+ async createConversation(record) {
4257
+ await this.db.insert(this.t.agentPoppyConversation).values({
4258
+ id: record.id,
4259
+ clientId: record.clientId,
4260
+ userId: record.userId,
4261
+ accountRef: record.accountRef,
4262
+ agentName: record.agentName,
4263
+ threadId: record.threadId,
4264
+ parentId: record.parentId,
4265
+ openDirectId: record.openDirectId,
4266
+ status: record.status,
4267
+ responder: record.responder,
4268
+ context: JSON.stringify(record.context),
4269
+ activeRunId: record.activeRunId,
4270
+ turnSeq: record.turnSeq,
4271
+ grantInfo: record.grant === null ? null : JSON.stringify(record.grant),
4272
+ readerHolder: null,
4273
+ readerUntil: null,
4274
+ prunedSeq: record.prunedSeq,
4275
+ createdAt: record.createdAt,
4276
+ updatedAt: record.updatedAt
4277
+ });
4278
+ }
4279
+ async getConversation(id) {
4280
+ const table = this.t.agentPoppyConversation;
4281
+ const [row] = await this.db.select().from(table).where(eq9(table.id, id)).limit(1);
4282
+ if (!row) return null;
4283
+ return {
4284
+ id: row.id,
4285
+ clientId: row.clientId,
4286
+ userId: row.userId,
4287
+ accountRef: nullable(row.accountRef),
4288
+ agentName: row.agentName,
4289
+ threadId: nullable(row.threadId),
4290
+ parentId: nullable(row.parentId),
4291
+ openDirectId: nullable(row.openDirectId),
4292
+ status: row.status,
4293
+ responder: row.responder,
4294
+ context: row.context == null ? {} : JSON.parse(row.context),
4295
+ activeRunId: nullable(row.activeRunId),
4296
+ turnSeq: toInt(row.turnSeq),
4297
+ grant: row.grantInfo == null ? null : JSON.parse(row.grantInfo),
4298
+ prunedSeq: toInt(row.prunedSeq),
4299
+ createdAt: toInt(row.createdAt),
4300
+ updatedAt: toInt(row.updatedAt)
4301
+ };
4302
+ }
4303
+ async updateConversation(id, patch) {
4304
+ const table = this.t.agentPoppyConversation;
4305
+ const set = {
4306
+ updatedAt: Date.now()
4307
+ };
4308
+ for (const [key2, column] of Object.entries(PATCH_COLUMNS)) {
4309
+ const value = patch[key2];
4310
+ if (value === void 0) continue;
4311
+ set[column] = key2 === "context" || key2 === "grant" && value !== null ? JSON.stringify(value) : value;
4312
+ }
4313
+ await this.db.update(table).set(set).where(eq9(table.id, id));
4314
+ }
4315
+ async appendEvent(conversationId, body, options = {}) {
4316
+ const table = this.t.agentPoppyEvent;
4317
+ for (let attempt = 1; ; attempt++) {
4318
+ if (options.key !== void 0) {
4319
+ const [existing] = await this.db.select({
4320
+ seq: table.seq,
4321
+ event: table.event
4322
+ }).from(table).where(and8(eq9(table.conversationId, conversationId), eq9(table.eventKey, options.key))).limit(1);
4323
+ if (existing) {
4324
+ return {
4325
+ event: {
4326
+ seq: toInt(existing.seq),
4327
+ event: JSON.parse(existing.event)
4328
+ },
4329
+ created: false
4330
+ };
4331
+ }
4332
+ }
4333
+ const seq = await this.lastSeq(conversationId) + 1;
4334
+ const now = Date.now();
4335
+ const stored = {
4336
+ seq,
4337
+ event: {
4338
+ id: newEventId(seq),
4339
+ created_at: new Date(now).toISOString(),
4340
+ ...body
4341
+ }
4342
+ };
4343
+ let inserted = false;
4344
+ try {
4345
+ inserted = await this.insertIgnore(table, {
4346
+ conversationId,
4347
+ seq,
4348
+ id: stored.event.id,
4349
+ type: body.type,
4350
+ event: JSON.stringify(stored.event),
4351
+ eventKey: options.key ?? null,
4352
+ createdAt: now
4353
+ });
4354
+ } catch (error) {
4355
+ if (!isUniqueViolation(error)) throw error;
4356
+ }
4357
+ if (inserted) return {
4358
+ event: stored,
4359
+ created: true
4360
+ };
4361
+ if (attempt >= MAX_APPEND_ATTEMPTS) {
4362
+ throw new Error(`poppy: could not append to ${conversationId} after ${attempt} attempts`);
4363
+ }
4364
+ await sleep(Math.random() * Math.min(attempt, 10) * 2);
4365
+ }
4366
+ }
4367
+ /** The last position taken: the last event's, or — every event pruned — the pruned floor. */
4368
+ async lastSeq(conversationId) {
4369
+ const table = this.t.agentPoppyEvent;
4370
+ const [last] = await this.db.select({
4371
+ seq: table.seq
4372
+ }).from(table).where(eq9(table.conversationId, conversationId)).orderBy(desc3(table.seq)).limit(1);
4373
+ if (last) return toInt(last.seq);
4374
+ const conversations = this.t.agentPoppyConversation;
4375
+ const [conversation] = await this.db.select({
4376
+ prunedSeq: conversations.prunedSeq
4377
+ }).from(conversations).where(eq9(conversations.id, conversationId)).limit(1);
4378
+ return toInt(conversation?.prunedSeq);
4379
+ }
4380
+ async listEvents(conversationId, afterSeq, limit) {
4381
+ const table = this.t.agentPoppyEvent;
4382
+ const rows = await this.db.select({
4383
+ seq: table.seq,
4384
+ event: table.event
4385
+ }).from(table).where(and8(eq9(table.conversationId, conversationId), gt4(table.seq, afterSeq))).orderBy(table.seq).limit(limit);
4386
+ return rows.map((row) => ({
4387
+ seq: toInt(row.seq),
4388
+ event: JSON.parse(row.event)
4389
+ }));
4390
+ }
4391
+ async findEventSeq(conversationId, eventId) {
4392
+ const table = this.t.agentPoppyEvent;
4393
+ const [row] = await this.db.select({
4394
+ seq: table.seq
4395
+ }).from(table).where(and8(eq9(table.conversationId, conversationId), eq9(table.id, eventId))).limit(1);
4396
+ return row ? toInt(row.seq) : null;
4397
+ }
4398
+ async pruneEvents(conversationId, before) {
4399
+ const table = this.t.agentPoppyEvent;
4400
+ const [last] = await this.db.select({
4401
+ seq: table.seq
4402
+ }).from(table).where(eq9(table.conversationId, conversationId)).orderBy(desc3(table.seq)).limit(1);
4403
+ if (!last) return;
4404
+ const [dropped] = await this.db.select({
4405
+ seq: table.seq
4406
+ }).from(table).where(and8(eq9(table.conversationId, conversationId), lt3(table.createdAt, before), lt3(table.seq, toInt(last.seq)))).orderBy(desc3(table.seq)).limit(1);
4407
+ if (!dropped) return;
4408
+ const upTo = toInt(dropped.seq);
4409
+ const conversations = this.t.agentPoppyConversation;
4410
+ await this.db.update(conversations).set({
4411
+ prunedSeq: upTo
4412
+ }).where(and8(eq9(conversations.id, conversationId), lt3(conversations.prunedSeq, upTo)));
4413
+ await this.db.delete(table).where(and8(eq9(table.conversationId, conversationId), lte5(table.seq, upTo)));
4414
+ }
4415
+ async claimMessage(owner, messageId, receipt) {
4416
+ const table = this.t.agentPoppyMessage;
4417
+ for (let attempt = 1; ; attempt++) {
4418
+ const inserted = await this.insertIgnore(table, {
4419
+ owner,
4420
+ messageId,
4421
+ fingerprint: receipt.fingerprint,
4422
+ conversationId: receipt.conversationId,
4423
+ response: JSON.stringify(receipt.response),
4424
+ createdAt: Date.now()
4425
+ });
4426
+ if (inserted) return {
4427
+ status: "claimed"
4428
+ };
4429
+ const [row] = await this.db.select().from(table).where(and8(eq9(table.owner, owner), eq9(table.messageId, messageId))).limit(1);
4430
+ if (row) {
4431
+ return {
4432
+ status: "existing",
4433
+ fingerprint: row.fingerprint,
4434
+ conversationId: row.conversationId,
4435
+ response: JSON.parse(row.response)
4436
+ };
4437
+ }
4438
+ if (attempt >= 5) throw new Error(`poppy: could not claim message ${messageId}`);
4439
+ }
4440
+ }
4441
+ async releaseMessage(owner, messageId) {
4442
+ const table = this.t.agentPoppyMessage;
4443
+ await this.db.delete(table).where(and8(eq9(table.owner, owner), eq9(table.messageId, messageId)));
4444
+ }
4445
+ async leaseReader(conversationId, holder, ttlMs) {
4446
+ const table = this.t.agentPoppyConversation;
4447
+ const now = Date.now();
4448
+ const taken = await affectedRows(this.dialect, this.db.update(table).set({
4449
+ readerHolder: holder,
4450
+ readerUntil: now + ttlMs
4451
+ }).where(and8(eq9(table.id, conversationId), or3(isNull4(table.readerHolder), eq9(table.readerHolder, holder), lte5(table.readerUntil, now)))), table.id);
4452
+ if (taken === 1) return true;
4453
+ if (this.dialect !== "mysql") return false;
4454
+ const [row] = await this.db.select({
4455
+ holder: table.readerHolder
4456
+ }).from(table).where(eq9(table.id, conversationId)).limit(1);
4457
+ return row?.holder === holder;
4458
+ }
4459
+ async releaseReader(conversationId, holder) {
4460
+ const table = this.t.agentPoppyConversation;
4461
+ await this.db.update(table).set({
4462
+ readerHolder: null,
4463
+ readerUntil: null
4464
+ }).where(and8(eq9(table.id, conversationId), eq9(table.readerHolder, holder)));
4465
+ }
4466
+ /** Insert `row`, skipping it on any duplicate key. `true` when it went in. */
4467
+ async insertIgnore(table, row) {
4468
+ if (this.dialect === "mysql") {
4469
+ const insert = this.db.insert(table);
4470
+ return mysqlAffectedRows(await insert.ignore().values(row)) === 1;
4471
+ }
4472
+ const statement = this.db.insert(table).values(row).onConflictDoNothing();
4473
+ return await affectedRows(this.dialect, statement, table.createdAt) === 1;
4474
+ }
4475
+ };
4476
+
4477
+ // src/drizzle-poppy-connection-store.ts
4478
+ import { and as and9, asc as asc5, eq as eq10 } from "drizzle-orm";
4479
+ var nullable2 = /* @__PURE__ */ __name((value) => value == null ? null : String(value), "nullable");
4480
+ var toInt2 = /* @__PURE__ */ __name((value) => typeof value === "number" ? value : Number(value ?? 0), "toInt");
4481
+ var DrizzlePoppyConnectionStore = class {
4482
+ static {
4483
+ __name(this, "DrizzlePoppyConnectionStore");
4484
+ }
4485
+ db;
4486
+ dialect;
4487
+ t;
4488
+ constructor(db) {
4489
+ this.dialect = agentDialectOf(db);
4490
+ this.t = agentTablesFor(this.dialect);
4491
+ this.db = asBuilder(db);
4492
+ }
4493
+ async listConnections(owner) {
4494
+ const table = this.t.agentPoppyConnection;
4495
+ const rows = await this.db.select().from(table).where(eq10(table.owner, owner)).orderBy(asc5(table.domain), asc5(table.issuer));
4496
+ return rows.map(toConnection);
4497
+ }
4498
+ async getConnection(owner, issuer) {
4499
+ const table = this.t.agentPoppyConnection;
4500
+ const [row] = await this.db.select().from(table).where(and9(eq10(table.owner, owner), eq10(table.issuer, issuer))).limit(1);
4501
+ return row ? toConnection(row) : null;
4502
+ }
4503
+ async saveConnection(record) {
4504
+ const table = this.t.agentPoppyConnection;
4505
+ const columns = {
4506
+ domain: record.domain,
4507
+ organization: record.organization,
4508
+ scope: record.scope,
4509
+ status: record.status,
4510
+ state: record.state,
4511
+ updatedAt: record.updatedAt
4512
+ };
4513
+ await upsert(this.dialect, this.db.insert(table).values({
4514
+ owner: record.owner,
4515
+ issuer: record.issuer,
4516
+ createdAt: record.createdAt,
4517
+ ...columns
4518
+ }), [
4519
+ table.owner,
4520
+ table.issuer
4521
+ ], columns);
4522
+ }
4523
+ async deleteConnection(owner, issuer) {
4524
+ const table = this.t.agentPoppyConnection;
4525
+ await this.db.delete(table).where(and9(eq10(table.owner, owner), eq10(table.issuer, issuer)));
4526
+ }
4527
+ async createPending(record) {
4528
+ const table = this.t.agentPoppyConnect;
4529
+ const row = {
4530
+ id: record.id,
4531
+ owner: record.owner,
4532
+ domain: record.domain,
4533
+ issuer: record.issuer,
4534
+ organization: record.organization,
4535
+ scope: record.scope,
4536
+ actor: record.actor === null ? null : JSON.stringify(record.actor),
4537
+ threadId: record.threadId,
4538
+ runId: record.runId,
4539
+ toolCallId: record.toolCallId,
4540
+ flow: record.flow,
4541
+ status: record.status,
4542
+ expiresAt: record.expiresAt,
4543
+ createdAt: record.createdAt
4544
+ };
4545
+ if (this.dialect === "mysql") {
4546
+ const insert = this.db.insert(table);
4547
+ await insert.ignore().values(row);
4548
+ return;
4549
+ }
4550
+ await this.db.insert(table).values(row).onConflictDoNothing();
4551
+ }
4552
+ async getPending(id) {
4553
+ const table = this.t.agentPoppyConnect;
4554
+ const [row] = await this.db.select().from(table).where(eq10(table.id, id)).limit(1);
4555
+ if (!row) return null;
4556
+ return {
4557
+ id: row.id,
4558
+ owner: row.owner,
4559
+ domain: row.domain,
4560
+ issuer: row.issuer,
4561
+ organization: row.organization,
4562
+ scope: row.scope ?? "",
4563
+ actor: row.actor == null ? null : JSON.parse(row.actor),
4564
+ threadId: nullable2(row.threadId),
4565
+ runId: nullable2(row.runId),
4566
+ toolCallId: nullable2(row.toolCallId),
4567
+ flow: nullable2(row.flow),
4568
+ status: row.status,
4569
+ expiresAt: toInt2(row.expiresAt),
4570
+ createdAt: toInt2(row.createdAt)
4571
+ };
4572
+ }
4573
+ async updatePending(id, patch) {
4574
+ const set = {};
4575
+ if (patch.flow !== void 0) set.flow = patch.flow;
4576
+ if (patch.status !== void 0) set.status = patch.status;
4577
+ if (Object.keys(set).length === 0) return;
4578
+ const table = this.t.agentPoppyConnect;
4579
+ await this.db.update(table).set(set).where(eq10(table.id, id));
4580
+ }
4581
+ };
4582
+ function toConnection(row) {
4583
+ return {
4584
+ owner: row.owner,
4585
+ issuer: row.issuer,
4586
+ domain: row.domain,
4587
+ organization: row.organization,
4588
+ scope: row.scope ?? "",
4589
+ status: row.status,
4590
+ state: row.state,
4591
+ createdAt: toInt2(row.createdAt),
4592
+ updatedAt: toInt2(row.updatedAt)
4593
+ };
4594
+ }
4595
+ __name(toConnection, "toConnection");
4596
+
3684
4597
  // src/drizzle-rag-ingestion-log.ts
3685
4598
  import { subscribe, unsubscribe } from "diagnostics_channel";
3686
4599
  import { Injectable, Logger } from "@nestjs/common";
3687
- import { and as and8, asc as asc5, count as count2, desc as desc3, eq as eq9, gt as gt4, lt as lt3, or as or3 } from "drizzle-orm";
3688
- function _ts_decorate(decorators, target, key2, desc4) {
3689
- var c = arguments.length, r = c < 3 ? target : desc4 === null ? desc4 = Object.getOwnPropertyDescriptor(target, key2) : desc4, d;
4600
+ import { and as and10, asc as asc6, count as count2, desc as desc4, eq as eq11, gt as gt5, lt as lt4, or as or4 } from "drizzle-orm";
4601
+ function _ts_decorate(decorators, target, key2, desc5) {
4602
+ var c = arguments.length, r = c < 3 ? target : desc5 === null ? desc5 = Object.getOwnPropertyDescriptor(target, key2) : desc5, d;
3690
4603
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3691
- r = Reflect.decorate(decorators, target, key2, desc4);
4604
+ r = Reflect.decorate(decorators, target, key2, desc5);
3692
4605
  } else {
3693
4606
  for (var i = decorators.length - 1; i >= 0; i--) {
3694
4607
  if (d = decorators[i]) {
@@ -3732,8 +4645,8 @@ function num(value) {
3732
4645
  }
3733
4646
  __name(num, "num");
3734
4647
  var RAG_INGESTION_LOG_PAGE_ORDER = [
3735
- desc3(ragIngestionLog.updatedAt),
3736
- asc5(ragIngestionLog.documentId)
4648
+ desc4(ragIngestionLog.updatedAt),
4649
+ asc6(ragIngestionLog.documentId)
3737
4650
  ];
3738
4651
  var DEFAULT_PAGE_SIZE = 200;
3739
4652
  var DEFAULT_BATCH_SIZE = 200;
@@ -3883,17 +4796,17 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
3883
4796
  }
3884
4797
  /** The latest recorded outcome for one document, or null if it was never attempted. */
3885
4798
  async get(documentId) {
3886
- const [row] = await this.db.select().from(this.t.ragIngestionLog).where(eq9(this.t.ragIngestionLog.documentId, documentId));
4799
+ const [row] = await this.db.select().from(this.t.ragIngestionLog).where(eq11(this.t.ragIngestionLog.documentId, documentId));
3887
4800
  return row ?? null;
3888
4801
  }
3889
4802
  /** Forget one document's record. Returns whether a row was actually removed. */
3890
4803
  async remove(documentId) {
3891
- const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where(eq9(this.t.ragIngestionLog.documentId, documentId)), this.t.ragIngestionLog.documentId);
4804
+ const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where(eq11(this.t.ragIngestionLog.documentId, documentId)), this.t.ragIngestionLog.documentId);
3892
4805
  return removed > 0;
3893
4806
  }
3894
4807
  /** Forget every record for a collection — for when the collection itself is deleted. */
3895
4808
  async removeByCollection(collection) {
3896
- const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where(eq9(this.t.ragIngestionLog.collection, collection)), this.t.ragIngestionLog.documentId);
4809
+ const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where(eq11(this.t.ragIngestionLog.collection, collection)), this.t.ragIngestionLog.documentId);
3897
4810
  return removed;
3898
4811
  }
3899
4812
  /**
@@ -3923,7 +4836,7 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
3923
4836
  }
3924
4837
  }
3925
4838
  where(query) {
3926
- return and8(query.collection !== void 0 ? eq9(this.t.ragIngestionLog.collection, query.collection) : void 0, query.status !== void 0 ? eq9(this.t.ragIngestionLog.status, query.status) : void 0);
4839
+ return and10(query.collection !== void 0 ? eq11(this.t.ragIngestionLog.collection, query.collection) : void 0, query.status !== void 0 ? eq11(this.t.ragIngestionLog.status, query.status) : void 0);
3927
4840
  }
3928
4841
  /**
3929
4842
  * The coordinates filter AND'd with "strictly after `cursor` in
@@ -3938,7 +4851,7 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
3938
4851
  if (cursor === void 0) {
3939
4852
  return base;
3940
4853
  }
3941
- return and8(base, or3(lt3(this.t.ragIngestionLog.updatedAt, cursor.updatedAt), and8(eq9(this.t.ragIngestionLog.updatedAt, cursor.updatedAt), gt4(this.t.ragIngestionLog.documentId, cursor.documentId))));
4854
+ return and10(base, or4(lt4(this.t.ragIngestionLog.updatedAt, cursor.updatedAt), and10(eq11(this.t.ragIngestionLog.updatedAt, cursor.updatedAt), gt5(this.t.ragIngestionLog.documentId, cursor.documentId))));
3942
4855
  }
3943
4856
  /**
3944
4857
  * Upsert one outcome. Keyed by document id so the row always reflects the *current* state — a
@@ -4011,12 +4924,12 @@ DrizzleRagIngestionLog = _ts_decorate([
4011
4924
  ], DrizzleRagIngestionLog);
4012
4925
 
4013
4926
  // src/drizzle-agent-store.module.ts
4014
- import { AGENT_CHANNEL_STORE, AGENT_CONFIRM_TOKEN_STORE, AGENT_GOVERNANCE_QUERIES, AGENT_PRICING_STORE, AGENT_STORE } from "@dudousxd/nestjs-agent-core";
4927
+ import { AGENT_CHANNEL_STORE, AGENT_CONFIRM_TOKEN_STORE, AGENT_GOVERNANCE_QUERIES, AGENT_POPPY_CONNECTION_STORE, AGENT_POPPY_STORE, AGENT_PRICING_STORE, AGENT_STORE } from "@dudousxd/nestjs-agent-core";
4015
4928
  import { Module } from "@nestjs/common";
4016
- function _ts_decorate2(decorators, target, key2, desc4) {
4017
- var c = arguments.length, r = c < 3 ? target : desc4 === null ? desc4 = Object.getOwnPropertyDescriptor(target, key2) : desc4, d;
4929
+ function _ts_decorate2(decorators, target, key2, desc5) {
4930
+ var c = arguments.length, r = c < 3 ? target : desc5 === null ? desc5 = Object.getOwnPropertyDescriptor(target, key2) : desc5, d;
4018
4931
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4019
- r = Reflect.decorate(decorators, target, key2, desc4);
4932
+ r = Reflect.decorate(decorators, target, key2, desc5);
4020
4933
  } else {
4021
4934
  for (var i = decorators.length - 1; i >= 0; i--) {
4022
4935
  if (d = decorators[i]) {
@@ -4099,6 +5012,23 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
4099
5012
  {
4100
5013
  provide: AGENT_CHANNEL_STORE,
4101
5014
  useExisting: DrizzleChannelStore
5015
+ },
5016
+ // Personal Agent Protocol (Poppy) conversations and connections, shared by every replica.
5017
+ {
5018
+ provide: DrizzlePoppyStore,
5019
+ useFactory: /* @__PURE__ */ __name(() => new DrizzlePoppyStore(options.db), "useFactory")
5020
+ },
5021
+ {
5022
+ provide: AGENT_POPPY_STORE,
5023
+ useExisting: DrizzlePoppyStore
5024
+ },
5025
+ {
5026
+ provide: DrizzlePoppyConnectionStore,
5027
+ useFactory: /* @__PURE__ */ __name(() => new DrizzlePoppyConnectionStore(options.db), "useFactory")
5028
+ },
5029
+ {
5030
+ provide: AGENT_POPPY_CONNECTION_STORE,
5031
+ useExisting: DrizzlePoppyConnectionStore
4102
5032
  }
4103
5033
  ],
4104
5034
  exports: [
@@ -4115,7 +5045,11 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
4115
5045
  DrizzleConfirmTokenStore,
4116
5046
  AGENT_CONFIRM_TOKEN_STORE,
4117
5047
  DrizzleChannelStore,
4118
- AGENT_CHANNEL_STORE
5048
+ AGENT_CHANNEL_STORE,
5049
+ DrizzlePoppyStore,
5050
+ AGENT_POPPY_STORE,
5051
+ DrizzlePoppyConnectionStore,
5052
+ AGENT_POPPY_CONNECTION_STORE
4119
5053
  ]
4120
5054
  };
4121
5055
  }
@@ -4131,6 +5065,8 @@ export {
4131
5065
  DrizzleConfirmTokenStore,
4132
5066
  DrizzleGovernanceQueries,
4133
5067
  DrizzleMemoryProvider,
5068
+ DrizzlePoppyConnectionStore,
5069
+ DrizzlePoppyStore,
4134
5070
  DrizzlePricingStore,
4135
5071
  DrizzleRagIngestionLog,
4136
5072
  DrizzleStreamFrameTable,
@@ -4140,9 +5076,15 @@ export {
4140
5076
  agentChannelState,
4141
5077
  agentConfirmToken,
4142
5078
  agentDialectOf,
5079
+ agentGenuiCall,
4143
5080
  agentMemory,
4144
5081
  agentMessage,
4145
5082
  agentModelPricing,
5083
+ agentPoppyConnect,
5084
+ agentPoppyConnection,
5085
+ agentPoppyConversation,
5086
+ agentPoppyEvent,
5087
+ agentPoppyMessage,
4146
5088
  agentQueuedMessage,
4147
5089
  agentRun,
4148
5090
  agentSchema,