@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.cjs +983 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9946 -4031
- package/dist/index.d.ts +9946 -4031
- package/dist/index.js +963 -21
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -8,11 +8,11 @@ var __export = (target, all) => {
|
|
|
8
8
|
for (var name in all)
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
|
-
var __copyProps = (to, from, except,
|
|
11
|
+
var __copyProps = (to, from, except, desc5) => {
|
|
12
12
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
13
|
for (let key2 of __getOwnPropNames(from))
|
|
14
14
|
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
15
|
-
__defProp(to, key2, { get: () => from[key2], enumerable: !(
|
|
15
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc5 = __getOwnPropDesc(from, key2)) || desc5.enumerable });
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
@@ -28,6 +28,8 @@ __export(index_exports, {
|
|
|
28
28
|
DrizzleConfirmTokenStore: () => DrizzleConfirmTokenStore,
|
|
29
29
|
DrizzleGovernanceQueries: () => DrizzleGovernanceQueries,
|
|
30
30
|
DrizzleMemoryProvider: () => DrizzleMemoryProvider,
|
|
31
|
+
DrizzlePoppyConnectionStore: () => DrizzlePoppyConnectionStore,
|
|
32
|
+
DrizzlePoppyStore: () => DrizzlePoppyStore,
|
|
31
33
|
DrizzlePricingStore: () => DrizzlePricingStore,
|
|
32
34
|
DrizzleRagIngestionLog: () => DrizzleRagIngestionLog,
|
|
33
35
|
DrizzleStreamFrameTable: () => DrizzleStreamFrameTable,
|
|
@@ -37,9 +39,15 @@ __export(index_exports, {
|
|
|
37
39
|
agentChannelState: () => agentChannelState,
|
|
38
40
|
agentConfirmToken: () => agentConfirmToken,
|
|
39
41
|
agentDialectOf: () => agentDialectOf,
|
|
42
|
+
agentGenuiCall: () => agentGenuiCall,
|
|
40
43
|
agentMemory: () => agentMemory,
|
|
41
44
|
agentMessage: () => agentMessage,
|
|
42
45
|
agentModelPricing: () => agentModelPricing,
|
|
46
|
+
agentPoppyConnect: () => agentPoppyConnect,
|
|
47
|
+
agentPoppyConnection: () => agentPoppyConnection,
|
|
48
|
+
agentPoppyConversation: () => agentPoppyConversation,
|
|
49
|
+
agentPoppyEvent: () => agentPoppyEvent,
|
|
50
|
+
agentPoppyMessage: () => agentPoppyMessage,
|
|
43
51
|
agentQueuedMessage: () => agentQueuedMessage,
|
|
44
52
|
agentRun: () => agentRun,
|
|
45
53
|
agentSchema: () => agentSchema,
|
|
@@ -247,6 +255,37 @@ var agentTokenUsage = (0, import_sqlite_core.sqliteTable)("agent_token_usage", {
|
|
|
247
255
|
}, (table) => [
|
|
248
256
|
(0, import_sqlite_core.index)("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
|
|
249
257
|
]);
|
|
258
|
+
var agentGenuiCall = (0, import_sqlite_core.sqliteTable)("agent_genui_call", {
|
|
259
|
+
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
260
|
+
runId: (0, import_sqlite_core.text)("run_id").notNull(),
|
|
261
|
+
threadId: (0, import_sqlite_core.text)("thread_id").notNull().references(() => agentThread.id, {
|
|
262
|
+
onDelete: "cascade"
|
|
263
|
+
}),
|
|
264
|
+
actorRef: (0, import_sqlite_core.text)("actor_ref").notNull(),
|
|
265
|
+
agentName: (0, import_sqlite_core.text)("agent_name"),
|
|
266
|
+
step: (0, import_sqlite_core.integer)("step").notNull(),
|
|
267
|
+
toolName: (0, import_sqlite_core.text)("tool_name").notNull(),
|
|
268
|
+
channel: (0, import_sqlite_core.text)("channel").notNull(),
|
|
269
|
+
mode: (0, import_sqlite_core.text)("mode").$type().notNull(),
|
|
270
|
+
modelId: (0, import_sqlite_core.text)("model_id").notNull(),
|
|
271
|
+
attempt: (0, import_sqlite_core.integer)("attempt").notNull(),
|
|
272
|
+
outcome: (0, import_sqlite_core.text)("outcome").$type().notNull(),
|
|
273
|
+
validity: (0, import_sqlite_core.text)("validity").$type().notNull(),
|
|
274
|
+
errorCategory: (0, import_sqlite_core.text)("error_category").$type(),
|
|
275
|
+
errorMessage: (0, import_sqlite_core.text)("error_message"),
|
|
276
|
+
inputTokens: (0, import_sqlite_core.integer)("input_tokens").notNull(),
|
|
277
|
+
outputTokens: (0, import_sqlite_core.integer)("output_tokens").notNull(),
|
|
278
|
+
costUsd: (0, import_sqlite_core.real)("cost_usd"),
|
|
279
|
+
costSource: (0, import_sqlite_core.text)("cost_source").$type(),
|
|
280
|
+
firstFrameMs: (0, import_sqlite_core.integer)("first_frame_ms"),
|
|
281
|
+
completeFrameMs: (0, import_sqlite_core.integer)("complete_frame_ms"),
|
|
282
|
+
payloadBytes: (0, import_sqlite_core.integer)("payload_bytes").notNull(),
|
|
283
|
+
payload: (0, import_sqlite_core.text)("payload"),
|
|
284
|
+
createdAt: (0, import_sqlite_core.integer)("created_at").notNull()
|
|
285
|
+
}, (table) => [
|
|
286
|
+
(0, import_sqlite_core.index)("agent_genui_call_created_idx").on(table.createdAt),
|
|
287
|
+
(0, import_sqlite_core.index)("agent_genui_call_run_idx").on(table.runId)
|
|
288
|
+
]);
|
|
250
289
|
var agentModelPricing = (0, import_sqlite_core.sqliteTable)("agent_model_pricing", {
|
|
251
290
|
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
252
291
|
modelId: (0, import_sqlite_core.text)("model_id").notNull(),
|
|
@@ -404,6 +443,94 @@ var agentActionProposal = (0, import_sqlite_core.sqliteTable)("agent_action_prop
|
|
|
404
443
|
(0, import_sqlite_core.uniqueIndex)("agent_action_proposal_outcome_idx").on(table.outcomeIdKey),
|
|
405
444
|
(0, import_sqlite_core.index)("agent_action_proposal_scope_idx").on(table.scopeKey, table.createdAt, table.id)
|
|
406
445
|
]);
|
|
446
|
+
var agentPoppyConversation = (0, import_sqlite_core.sqliteTable)("agent_poppy_conversation", {
|
|
447
|
+
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
448
|
+
clientId: (0, import_sqlite_core.text)("client_id").notNull(),
|
|
449
|
+
userId: (0, import_sqlite_core.text)("user_id").notNull(),
|
|
450
|
+
accountRef: (0, import_sqlite_core.text)("account_ref"),
|
|
451
|
+
agentName: (0, import_sqlite_core.text)("agent_name").notNull(),
|
|
452
|
+
threadId: (0, import_sqlite_core.text)("thread_id"),
|
|
453
|
+
parentId: (0, import_sqlite_core.text)("parent_id"),
|
|
454
|
+
openDirectId: (0, import_sqlite_core.text)("open_direct_id"),
|
|
455
|
+
status: (0, import_sqlite_core.text)("status").notNull(),
|
|
456
|
+
responder: (0, import_sqlite_core.text)("responder").notNull(),
|
|
457
|
+
context: (0, import_sqlite_core.text)("context"),
|
|
458
|
+
activeRunId: (0, import_sqlite_core.text)("active_run_id"),
|
|
459
|
+
turnSeq: (0, import_sqlite_core.integer)("turn_seq").notNull(),
|
|
460
|
+
grantInfo: (0, import_sqlite_core.text)("grant_info"),
|
|
461
|
+
readerHolder: (0, import_sqlite_core.text)("reader_holder"),
|
|
462
|
+
readerUntil: (0, import_sqlite_core.integer)("reader_until"),
|
|
463
|
+
prunedSeq: (0, import_sqlite_core.integer)("pruned_seq").notNull(),
|
|
464
|
+
createdAt: (0, import_sqlite_core.integer)("created_at").notNull(),
|
|
465
|
+
updatedAt: (0, import_sqlite_core.integer)("updated_at").notNull()
|
|
466
|
+
});
|
|
467
|
+
var agentPoppyEvent = (0, import_sqlite_core.sqliteTable)("agent_poppy_event", {
|
|
468
|
+
conversationId: (0, import_sqlite_core.text)("conversation_id").notNull(),
|
|
469
|
+
seq: (0, import_sqlite_core.integer)("seq").notNull(),
|
|
470
|
+
id: (0, import_sqlite_core.text)("id").notNull(),
|
|
471
|
+
type: (0, import_sqlite_core.text)("type").notNull(),
|
|
472
|
+
event: (0, import_sqlite_core.text)("event").notNull(),
|
|
473
|
+
eventKey: (0, import_sqlite_core.text)("event_key"),
|
|
474
|
+
createdAt: (0, import_sqlite_core.integer)("created_at").notNull()
|
|
475
|
+
}, (table) => [
|
|
476
|
+
(0, import_sqlite_core.primaryKey)({
|
|
477
|
+
columns: [
|
|
478
|
+
table.conversationId,
|
|
479
|
+
table.seq
|
|
480
|
+
]
|
|
481
|
+
}),
|
|
482
|
+
(0, import_sqlite_core.uniqueIndex)("agent_poppy_event_key_idx").on(table.conversationId, table.eventKey),
|
|
483
|
+
(0, import_sqlite_core.index)("agent_poppy_event_id_idx").on(table.conversationId, table.id)
|
|
484
|
+
]);
|
|
485
|
+
var agentPoppyMessage = (0, import_sqlite_core.sqliteTable)("agent_poppy_message", {
|
|
486
|
+
owner: (0, import_sqlite_core.text)("owner").notNull(),
|
|
487
|
+
messageId: (0, import_sqlite_core.text)("message_id").notNull(),
|
|
488
|
+
fingerprint: (0, import_sqlite_core.text)("fingerprint").notNull(),
|
|
489
|
+
conversationId: (0, import_sqlite_core.text)("conversation_id").notNull(),
|
|
490
|
+
response: (0, import_sqlite_core.text)("response").notNull(),
|
|
491
|
+
createdAt: (0, import_sqlite_core.integer)("created_at").notNull()
|
|
492
|
+
}, (table) => [
|
|
493
|
+
(0, import_sqlite_core.primaryKey)({
|
|
494
|
+
columns: [
|
|
495
|
+
table.owner,
|
|
496
|
+
table.messageId
|
|
497
|
+
]
|
|
498
|
+
})
|
|
499
|
+
]);
|
|
500
|
+
var agentPoppyConnection = (0, import_sqlite_core.sqliteTable)("agent_poppy_connection", {
|
|
501
|
+
owner: (0, import_sqlite_core.text)("owner").notNull(),
|
|
502
|
+
issuer: (0, import_sqlite_core.text)("issuer").notNull(),
|
|
503
|
+
domain: (0, import_sqlite_core.text)("domain").notNull(),
|
|
504
|
+
organization: (0, import_sqlite_core.text)("organization").notNull(),
|
|
505
|
+
scope: (0, import_sqlite_core.text)("scope").notNull(),
|
|
506
|
+
status: (0, import_sqlite_core.text)("status").notNull(),
|
|
507
|
+
state: (0, import_sqlite_core.text)("state").notNull(),
|
|
508
|
+
createdAt: (0, import_sqlite_core.integer)("created_at").notNull(),
|
|
509
|
+
updatedAt: (0, import_sqlite_core.integer)("updated_at").notNull()
|
|
510
|
+
}, (table) => [
|
|
511
|
+
(0, import_sqlite_core.primaryKey)({
|
|
512
|
+
columns: [
|
|
513
|
+
table.owner,
|
|
514
|
+
table.issuer
|
|
515
|
+
]
|
|
516
|
+
})
|
|
517
|
+
]);
|
|
518
|
+
var agentPoppyConnect = (0, import_sqlite_core.sqliteTable)("agent_poppy_connect", {
|
|
519
|
+
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
520
|
+
owner: (0, import_sqlite_core.text)("owner").notNull(),
|
|
521
|
+
domain: (0, import_sqlite_core.text)("domain").notNull(),
|
|
522
|
+
issuer: (0, import_sqlite_core.text)("issuer").notNull(),
|
|
523
|
+
organization: (0, import_sqlite_core.text)("organization").notNull(),
|
|
524
|
+
scope: (0, import_sqlite_core.text)("scope").notNull(),
|
|
525
|
+
actor: (0, import_sqlite_core.text)("actor"),
|
|
526
|
+
threadId: (0, import_sqlite_core.text)("thread_id"),
|
|
527
|
+
runId: (0, import_sqlite_core.text)("run_id"),
|
|
528
|
+
toolCallId: (0, import_sqlite_core.text)("tool_call_id"),
|
|
529
|
+
flow: (0, import_sqlite_core.text)("flow"),
|
|
530
|
+
status: (0, import_sqlite_core.text)("status").notNull(),
|
|
531
|
+
expiresAt: (0, import_sqlite_core.integer)("expires_at").notNull(),
|
|
532
|
+
createdAt: (0, import_sqlite_core.integer)("created_at").notNull()
|
|
533
|
+
});
|
|
407
534
|
var agentSchema = {
|
|
408
535
|
agentActionProposal,
|
|
409
536
|
agentThread,
|
|
@@ -411,13 +538,19 @@ var agentSchema = {
|
|
|
411
538
|
agentQueuedMessage,
|
|
412
539
|
agentToolCall,
|
|
413
540
|
agentTokenUsage,
|
|
541
|
+
agentGenuiCall,
|
|
414
542
|
agentModelPricing,
|
|
415
543
|
agentRun,
|
|
416
544
|
agentMemory,
|
|
417
545
|
ragIngestionLog,
|
|
418
546
|
agentConfirmToken,
|
|
419
547
|
agentChannelState,
|
|
420
|
-
agentStreamFrame
|
|
548
|
+
agentStreamFrame,
|
|
549
|
+
agentPoppyConversation,
|
|
550
|
+
agentPoppyEvent,
|
|
551
|
+
agentPoppyMessage,
|
|
552
|
+
agentPoppyConnection,
|
|
553
|
+
agentPoppyConnect
|
|
421
554
|
};
|
|
422
555
|
|
|
423
556
|
// src/ensure-schema.ts
|
|
@@ -552,6 +685,45 @@ var agentTokenUsage2 = (0, import_mysql_core.mysqlTable)("agent_token_usage", {
|
|
|
552
685
|
}, (table) => [
|
|
553
686
|
(0, import_mysql_core.index)("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
|
|
554
687
|
]);
|
|
688
|
+
var agentGenuiCall2 = (0, import_mysql_core.mysqlTable)("agent_genui_call", {
|
|
689
|
+
id: key("id").primaryKey(),
|
|
690
|
+
runId: key("run_id").notNull(),
|
|
691
|
+
threadId: key("thread_id").notNull().references(() => agentThread2.id, {
|
|
692
|
+
onDelete: "cascade"
|
|
693
|
+
}),
|
|
694
|
+
actorRef: key("actor_ref").notNull(),
|
|
695
|
+
agentName: key("agent_name"),
|
|
696
|
+
step: (0, import_mysql_core.int)("step").notNull(),
|
|
697
|
+
toolName: key("tool_name").notNull(),
|
|
698
|
+
channel: key("channel").notNull(),
|
|
699
|
+
mode: key("mode").$type().notNull(),
|
|
700
|
+
modelId: key("model_id").notNull(),
|
|
701
|
+
attempt: (0, import_mysql_core.int)("attempt").notNull(),
|
|
702
|
+
outcome: key("outcome").$type().notNull(),
|
|
703
|
+
validity: key("validity").$type().notNull(),
|
|
704
|
+
errorCategory: key("error_category").$type(),
|
|
705
|
+
errorMessage: (0, import_mysql_core.longtext)("error_message"),
|
|
706
|
+
inputTokens: (0, import_mysql_core.int)("input_tokens").notNull(),
|
|
707
|
+
outputTokens: (0, import_mysql_core.int)("output_tokens").notNull(),
|
|
708
|
+
costUsd: (0, import_mysql_core.double)("cost_usd"),
|
|
709
|
+
costSource: (0, import_mysql_core.varchar)("cost_source", {
|
|
710
|
+
length: 16
|
|
711
|
+
}).$type(),
|
|
712
|
+
firstFrameMs: (0, import_mysql_core.bigint)("first_frame_ms", {
|
|
713
|
+
mode: "number"
|
|
714
|
+
}),
|
|
715
|
+
completeFrameMs: (0, import_mysql_core.bigint)("complete_frame_ms", {
|
|
716
|
+
mode: "number"
|
|
717
|
+
}),
|
|
718
|
+
payloadBytes: (0, import_mysql_core.int)("payload_bytes").notNull(),
|
|
719
|
+
payload: (0, import_mysql_core.longtext)("payload"),
|
|
720
|
+
createdAt: (0, import_mysql_core.bigint)("created_at", {
|
|
721
|
+
mode: "number"
|
|
722
|
+
}).notNull()
|
|
723
|
+
}, (table) => [
|
|
724
|
+
(0, import_mysql_core.index)("agent_genui_call_created_idx").on(table.createdAt),
|
|
725
|
+
(0, import_mysql_core.index)("agent_genui_call_run_idx").on(table.runId)
|
|
726
|
+
]);
|
|
555
727
|
var agentModelPricing2 = (0, import_mysql_core.mysqlTable)("agent_model_pricing", {
|
|
556
728
|
id: key("id").primaryKey(),
|
|
557
729
|
modelId: key("model_id").notNull(),
|
|
@@ -700,6 +872,124 @@ var agentActionProposal2 = (0, import_mysql_core.mysqlTable)("agent_action_propo
|
|
|
700
872
|
(0, import_mysql_core.uniqueIndex)("agent_action_proposal_outcome_idx").on(table.outcomeIdKey),
|
|
701
873
|
(0, import_mysql_core.index)("agent_action_proposal_scope_idx").on(table.scopeKey, table.createdAt, table.id)
|
|
702
874
|
]);
|
|
875
|
+
var agentPoppyConversation2 = (0, import_mysql_core.mysqlTable)("agent_poppy_conversation", {
|
|
876
|
+
id: key("id").primaryKey(),
|
|
877
|
+
clientId: (0, import_mysql_core.varchar)("client_id", {
|
|
878
|
+
length: 2048
|
|
879
|
+
}).notNull(),
|
|
880
|
+
userId: key("user_id").notNull(),
|
|
881
|
+
accountRef: key("account_ref"),
|
|
882
|
+
agentName: key("agent_name").notNull(),
|
|
883
|
+
threadId: key("thread_id"),
|
|
884
|
+
parentId: key("parent_id"),
|
|
885
|
+
openDirectId: key("open_direct_id"),
|
|
886
|
+
status: key("status").notNull(),
|
|
887
|
+
responder: key("responder").notNull(),
|
|
888
|
+
context: (0, import_mysql_core.longtext)("context"),
|
|
889
|
+
activeRunId: key("active_run_id"),
|
|
890
|
+
turnSeq: (0, import_mysql_core.bigint)("turn_seq", {
|
|
891
|
+
mode: "number"
|
|
892
|
+
}).notNull(),
|
|
893
|
+
grantInfo: (0, import_mysql_core.longtext)("grant_info"),
|
|
894
|
+
readerHolder: key("reader_holder"),
|
|
895
|
+
readerUntil: (0, import_mysql_core.bigint)("reader_until", {
|
|
896
|
+
mode: "number"
|
|
897
|
+
}),
|
|
898
|
+
prunedSeq: (0, import_mysql_core.bigint)("pruned_seq", {
|
|
899
|
+
mode: "number"
|
|
900
|
+
}).notNull(),
|
|
901
|
+
createdAt: (0, import_mysql_core.bigint)("created_at", {
|
|
902
|
+
mode: "number"
|
|
903
|
+
}).notNull(),
|
|
904
|
+
updatedAt: (0, import_mysql_core.bigint)("updated_at", {
|
|
905
|
+
mode: "number"
|
|
906
|
+
}).notNull()
|
|
907
|
+
});
|
|
908
|
+
var agentPoppyEvent2 = (0, import_mysql_core.mysqlTable)("agent_poppy_event", {
|
|
909
|
+
conversationId: key("conversation_id").notNull(),
|
|
910
|
+
seq: (0, import_mysql_core.bigint)("seq", {
|
|
911
|
+
mode: "number"
|
|
912
|
+
}).notNull(),
|
|
913
|
+
id: key("id").notNull(),
|
|
914
|
+
type: key("type").notNull(),
|
|
915
|
+
event: (0, import_mysql_core.longtext)("event").notNull(),
|
|
916
|
+
eventKey: key("event_key"),
|
|
917
|
+
createdAt: (0, import_mysql_core.bigint)("created_at", {
|
|
918
|
+
mode: "number"
|
|
919
|
+
}).notNull()
|
|
920
|
+
}, (table) => [
|
|
921
|
+
(0, import_mysql_core.primaryKey)({
|
|
922
|
+
columns: [
|
|
923
|
+
table.conversationId,
|
|
924
|
+
table.seq
|
|
925
|
+
]
|
|
926
|
+
}),
|
|
927
|
+
(0, import_mysql_core.uniqueIndex)("agent_poppy_event_key_idx").on(table.conversationId, table.eventKey),
|
|
928
|
+
(0, import_mysql_core.index)("agent_poppy_event_id_idx").on(table.conversationId, table.id)
|
|
929
|
+
]);
|
|
930
|
+
var agentPoppyMessage2 = (0, import_mysql_core.mysqlTable)("agent_poppy_message", {
|
|
931
|
+
owner: key("owner").notNull(),
|
|
932
|
+
messageId: key("message_id").notNull(),
|
|
933
|
+
fingerprint: key("fingerprint").notNull(),
|
|
934
|
+
conversationId: key("conversation_id").notNull(),
|
|
935
|
+
response: (0, import_mysql_core.longtext)("response").notNull(),
|
|
936
|
+
createdAt: (0, import_mysql_core.bigint)("created_at", {
|
|
937
|
+
mode: "number"
|
|
938
|
+
}).notNull()
|
|
939
|
+
}, (table) => [
|
|
940
|
+
(0, import_mysql_core.primaryKey)({
|
|
941
|
+
columns: [
|
|
942
|
+
table.owner,
|
|
943
|
+
table.messageId
|
|
944
|
+
]
|
|
945
|
+
})
|
|
946
|
+
]);
|
|
947
|
+
var agentPoppyConnection2 = (0, import_mysql_core.mysqlTable)("agent_poppy_connection", {
|
|
948
|
+
owner: key("owner").notNull(),
|
|
949
|
+
issuer: (0, import_mysql_core.varchar)("issuer", {
|
|
950
|
+
length: 512
|
|
951
|
+
}).notNull(),
|
|
952
|
+
domain: key("domain").notNull(),
|
|
953
|
+
organization: key("organization").notNull(),
|
|
954
|
+
scope: (0, import_mysql_core.longtext)("scope").notNull(),
|
|
955
|
+
status: key("status").notNull(),
|
|
956
|
+
state: (0, import_mysql_core.longtext)("state").notNull(),
|
|
957
|
+
createdAt: (0, import_mysql_core.bigint)("created_at", {
|
|
958
|
+
mode: "number"
|
|
959
|
+
}).notNull(),
|
|
960
|
+
updatedAt: (0, import_mysql_core.bigint)("updated_at", {
|
|
961
|
+
mode: "number"
|
|
962
|
+
}).notNull()
|
|
963
|
+
}, (table) => [
|
|
964
|
+
(0, import_mysql_core.primaryKey)({
|
|
965
|
+
columns: [
|
|
966
|
+
table.owner,
|
|
967
|
+
table.issuer
|
|
968
|
+
]
|
|
969
|
+
})
|
|
970
|
+
]);
|
|
971
|
+
var agentPoppyConnect2 = (0, import_mysql_core.mysqlTable)("agent_poppy_connect", {
|
|
972
|
+
id: key("id").primaryKey(),
|
|
973
|
+
owner: key("owner").notNull(),
|
|
974
|
+
domain: key("domain").notNull(),
|
|
975
|
+
issuer: (0, import_mysql_core.varchar)("issuer", {
|
|
976
|
+
length: 512
|
|
977
|
+
}).notNull(),
|
|
978
|
+
organization: key("organization").notNull(),
|
|
979
|
+
scope: (0, import_mysql_core.longtext)("scope").notNull(),
|
|
980
|
+
actor: (0, import_mysql_core.longtext)("actor"),
|
|
981
|
+
threadId: key("thread_id"),
|
|
982
|
+
runId: key("run_id"),
|
|
983
|
+
toolCallId: key("tool_call_id"),
|
|
984
|
+
flow: (0, import_mysql_core.longtext)("flow"),
|
|
985
|
+
status: key("status").notNull(),
|
|
986
|
+
expiresAt: (0, import_mysql_core.bigint)("expires_at", {
|
|
987
|
+
mode: "number"
|
|
988
|
+
}).notNull(),
|
|
989
|
+
createdAt: (0, import_mysql_core.bigint)("created_at", {
|
|
990
|
+
mode: "number"
|
|
991
|
+
}).notNull()
|
|
992
|
+
});
|
|
703
993
|
var mysqlAgentSchema = {
|
|
704
994
|
agentActionProposal: agentActionProposal2,
|
|
705
995
|
agentThread: agentThread2,
|
|
@@ -707,13 +997,19 @@ var mysqlAgentSchema = {
|
|
|
707
997
|
agentQueuedMessage: agentQueuedMessage2,
|
|
708
998
|
agentToolCall: agentToolCall2,
|
|
709
999
|
agentTokenUsage: agentTokenUsage2,
|
|
1000
|
+
agentGenuiCall: agentGenuiCall2,
|
|
710
1001
|
agentModelPricing: agentModelPricing2,
|
|
711
1002
|
agentRun: agentRun2,
|
|
712
1003
|
agentMemory: agentMemory2,
|
|
713
1004
|
ragIngestionLog: ragIngestionLog2,
|
|
714
1005
|
agentConfirmToken: agentConfirmToken2,
|
|
715
1006
|
agentChannelState: agentChannelState2,
|
|
716
|
-
agentStreamFrame: agentStreamFrame2
|
|
1007
|
+
agentStreamFrame: agentStreamFrame2,
|
|
1008
|
+
agentPoppyConversation: agentPoppyConversation2,
|
|
1009
|
+
agentPoppyEvent: agentPoppyEvent2,
|
|
1010
|
+
agentPoppyMessage: agentPoppyMessage2,
|
|
1011
|
+
agentPoppyConnection: agentPoppyConnection2,
|
|
1012
|
+
agentPoppyConnect: agentPoppyConnect2
|
|
717
1013
|
};
|
|
718
1014
|
|
|
719
1015
|
// src/schema-pg.ts
|
|
@@ -835,6 +1131,45 @@ var agentTokenUsage3 = (0, import_pg_core.pgTable)("agent_token_usage", {
|
|
|
835
1131
|
}, (table) => [
|
|
836
1132
|
(0, import_pg_core.index)("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
|
|
837
1133
|
]);
|
|
1134
|
+
var agentGenuiCall3 = (0, import_pg_core.pgTable)("agent_genui_call", {
|
|
1135
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
1136
|
+
runId: (0, import_pg_core.text)("run_id").notNull(),
|
|
1137
|
+
threadId: (0, import_pg_core.text)("thread_id").notNull().references(() => agentThread3.id, {
|
|
1138
|
+
onDelete: "cascade"
|
|
1139
|
+
}),
|
|
1140
|
+
actorRef: (0, import_pg_core.text)("actor_ref").notNull(),
|
|
1141
|
+
agentName: (0, import_pg_core.text)("agent_name"),
|
|
1142
|
+
step: (0, import_pg_core.integer)("step").notNull(),
|
|
1143
|
+
toolName: (0, import_pg_core.text)("tool_name").notNull(),
|
|
1144
|
+
channel: (0, import_pg_core.text)("channel").notNull(),
|
|
1145
|
+
mode: (0, import_pg_core.text)("mode").$type().notNull(),
|
|
1146
|
+
modelId: (0, import_pg_core.text)("model_id").notNull(),
|
|
1147
|
+
attempt: (0, import_pg_core.integer)("attempt").notNull(),
|
|
1148
|
+
outcome: (0, import_pg_core.text)("outcome").$type().notNull(),
|
|
1149
|
+
validity: (0, import_pg_core.text)("validity").$type().notNull(),
|
|
1150
|
+
errorCategory: (0, import_pg_core.text)("error_category").$type(),
|
|
1151
|
+
errorMessage: (0, import_pg_core.text)("error_message"),
|
|
1152
|
+
inputTokens: (0, import_pg_core.integer)("input_tokens").notNull(),
|
|
1153
|
+
outputTokens: (0, import_pg_core.integer)("output_tokens").notNull(),
|
|
1154
|
+
costUsd: (0, import_pg_core.doublePrecision)("cost_usd"),
|
|
1155
|
+
costSource: (0, import_pg_core.varchar)("cost_source", {
|
|
1156
|
+
length: 16
|
|
1157
|
+
}).$type(),
|
|
1158
|
+
firstFrameMs: (0, import_pg_core.bigint)("first_frame_ms", {
|
|
1159
|
+
mode: "number"
|
|
1160
|
+
}),
|
|
1161
|
+
completeFrameMs: (0, import_pg_core.bigint)("complete_frame_ms", {
|
|
1162
|
+
mode: "number"
|
|
1163
|
+
}),
|
|
1164
|
+
payloadBytes: (0, import_pg_core.integer)("payload_bytes").notNull(),
|
|
1165
|
+
payload: (0, import_pg_core.text)("payload"),
|
|
1166
|
+
createdAt: (0, import_pg_core.bigint)("created_at", {
|
|
1167
|
+
mode: "number"
|
|
1168
|
+
}).notNull()
|
|
1169
|
+
}, (table) => [
|
|
1170
|
+
(0, import_pg_core.index)("agent_genui_call_created_idx").on(table.createdAt),
|
|
1171
|
+
(0, import_pg_core.index)("agent_genui_call_run_idx").on(table.runId)
|
|
1172
|
+
]);
|
|
838
1173
|
var agentModelPricing3 = (0, import_pg_core.pgTable)("agent_model_pricing", {
|
|
839
1174
|
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
840
1175
|
modelId: (0, import_pg_core.text)("model_id").notNull(),
|
|
@@ -981,6 +1316,118 @@ var agentActionProposal3 = (0, import_pg_core.pgTable)("agent_action_proposal",
|
|
|
981
1316
|
(0, import_pg_core.uniqueIndex)("agent_action_proposal_outcome_idx").on(table.outcomeIdKey),
|
|
982
1317
|
(0, import_pg_core.index)("agent_action_proposal_scope_idx").on(table.scopeKey, table.createdAt, table.id)
|
|
983
1318
|
]);
|
|
1319
|
+
var agentPoppyConversation3 = (0, import_pg_core.pgTable)("agent_poppy_conversation", {
|
|
1320
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
1321
|
+
clientId: (0, import_pg_core.text)("client_id").notNull(),
|
|
1322
|
+
userId: (0, import_pg_core.text)("user_id").notNull(),
|
|
1323
|
+
accountRef: (0, import_pg_core.text)("account_ref"),
|
|
1324
|
+
agentName: (0, import_pg_core.text)("agent_name").notNull(),
|
|
1325
|
+
threadId: (0, import_pg_core.text)("thread_id"),
|
|
1326
|
+
parentId: (0, import_pg_core.text)("parent_id"),
|
|
1327
|
+
openDirectId: (0, import_pg_core.text)("open_direct_id"),
|
|
1328
|
+
status: (0, import_pg_core.text)("status").notNull(),
|
|
1329
|
+
responder: (0, import_pg_core.text)("responder").notNull(),
|
|
1330
|
+
context: (0, import_pg_core.text)("context"),
|
|
1331
|
+
activeRunId: (0, import_pg_core.text)("active_run_id"),
|
|
1332
|
+
turnSeq: (0, import_pg_core.bigint)("turn_seq", {
|
|
1333
|
+
mode: "number"
|
|
1334
|
+
}).notNull(),
|
|
1335
|
+
grantInfo: (0, import_pg_core.text)("grant_info"),
|
|
1336
|
+
readerHolder: (0, import_pg_core.text)("reader_holder"),
|
|
1337
|
+
readerUntil: (0, import_pg_core.bigint)("reader_until", {
|
|
1338
|
+
mode: "number"
|
|
1339
|
+
}),
|
|
1340
|
+
prunedSeq: (0, import_pg_core.bigint)("pruned_seq", {
|
|
1341
|
+
mode: "number"
|
|
1342
|
+
}).notNull(),
|
|
1343
|
+
createdAt: (0, import_pg_core.bigint)("created_at", {
|
|
1344
|
+
mode: "number"
|
|
1345
|
+
}).notNull(),
|
|
1346
|
+
updatedAt: (0, import_pg_core.bigint)("updated_at", {
|
|
1347
|
+
mode: "number"
|
|
1348
|
+
}).notNull()
|
|
1349
|
+
});
|
|
1350
|
+
var agentPoppyEvent3 = (0, import_pg_core.pgTable)("agent_poppy_event", {
|
|
1351
|
+
conversationId: (0, import_pg_core.text)("conversation_id").notNull(),
|
|
1352
|
+
seq: (0, import_pg_core.bigint)("seq", {
|
|
1353
|
+
mode: "number"
|
|
1354
|
+
}).notNull(),
|
|
1355
|
+
id: (0, import_pg_core.text)("id").notNull(),
|
|
1356
|
+
type: (0, import_pg_core.text)("type").notNull(),
|
|
1357
|
+
event: (0, import_pg_core.text)("event").notNull(),
|
|
1358
|
+
eventKey: (0, import_pg_core.text)("event_key"),
|
|
1359
|
+
createdAt: (0, import_pg_core.bigint)("created_at", {
|
|
1360
|
+
mode: "number"
|
|
1361
|
+
}).notNull()
|
|
1362
|
+
}, (table) => [
|
|
1363
|
+
(0, import_pg_core.primaryKey)({
|
|
1364
|
+
columns: [
|
|
1365
|
+
table.conversationId,
|
|
1366
|
+
table.seq
|
|
1367
|
+
]
|
|
1368
|
+
}),
|
|
1369
|
+
(0, import_pg_core.uniqueIndex)("agent_poppy_event_key_idx").on(table.conversationId, table.eventKey),
|
|
1370
|
+
(0, import_pg_core.index)("agent_poppy_event_id_idx").on(table.conversationId, table.id)
|
|
1371
|
+
]);
|
|
1372
|
+
var agentPoppyMessage3 = (0, import_pg_core.pgTable)("agent_poppy_message", {
|
|
1373
|
+
owner: (0, import_pg_core.text)("owner").notNull(),
|
|
1374
|
+
messageId: (0, import_pg_core.text)("message_id").notNull(),
|
|
1375
|
+
fingerprint: (0, import_pg_core.text)("fingerprint").notNull(),
|
|
1376
|
+
conversationId: (0, import_pg_core.text)("conversation_id").notNull(),
|
|
1377
|
+
response: (0, import_pg_core.text)("response").notNull(),
|
|
1378
|
+
createdAt: (0, import_pg_core.bigint)("created_at", {
|
|
1379
|
+
mode: "number"
|
|
1380
|
+
}).notNull()
|
|
1381
|
+
}, (table) => [
|
|
1382
|
+
(0, import_pg_core.primaryKey)({
|
|
1383
|
+
columns: [
|
|
1384
|
+
table.owner,
|
|
1385
|
+
table.messageId
|
|
1386
|
+
]
|
|
1387
|
+
})
|
|
1388
|
+
]);
|
|
1389
|
+
var agentPoppyConnection3 = (0, import_pg_core.pgTable)("agent_poppy_connection", {
|
|
1390
|
+
owner: (0, import_pg_core.text)("owner").notNull(),
|
|
1391
|
+
issuer: (0, import_pg_core.text)("issuer").notNull(),
|
|
1392
|
+
domain: (0, import_pg_core.text)("domain").notNull(),
|
|
1393
|
+
organization: (0, import_pg_core.text)("organization").notNull(),
|
|
1394
|
+
scope: (0, import_pg_core.text)("scope").notNull(),
|
|
1395
|
+
status: (0, import_pg_core.text)("status").notNull(),
|
|
1396
|
+
state: (0, import_pg_core.text)("state").notNull(),
|
|
1397
|
+
createdAt: (0, import_pg_core.bigint)("created_at", {
|
|
1398
|
+
mode: "number"
|
|
1399
|
+
}).notNull(),
|
|
1400
|
+
updatedAt: (0, import_pg_core.bigint)("updated_at", {
|
|
1401
|
+
mode: "number"
|
|
1402
|
+
}).notNull()
|
|
1403
|
+
}, (table) => [
|
|
1404
|
+
(0, import_pg_core.primaryKey)({
|
|
1405
|
+
columns: [
|
|
1406
|
+
table.owner,
|
|
1407
|
+
table.issuer
|
|
1408
|
+
]
|
|
1409
|
+
})
|
|
1410
|
+
]);
|
|
1411
|
+
var agentPoppyConnect3 = (0, import_pg_core.pgTable)("agent_poppy_connect", {
|
|
1412
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
1413
|
+
owner: (0, import_pg_core.text)("owner").notNull(),
|
|
1414
|
+
domain: (0, import_pg_core.text)("domain").notNull(),
|
|
1415
|
+
issuer: (0, import_pg_core.text)("issuer").notNull(),
|
|
1416
|
+
organization: (0, import_pg_core.text)("organization").notNull(),
|
|
1417
|
+
scope: (0, import_pg_core.text)("scope").notNull(),
|
|
1418
|
+
actor: (0, import_pg_core.text)("actor"),
|
|
1419
|
+
threadId: (0, import_pg_core.text)("thread_id"),
|
|
1420
|
+
runId: (0, import_pg_core.text)("run_id"),
|
|
1421
|
+
toolCallId: (0, import_pg_core.text)("tool_call_id"),
|
|
1422
|
+
flow: (0, import_pg_core.text)("flow"),
|
|
1423
|
+
status: (0, import_pg_core.text)("status").notNull(),
|
|
1424
|
+
expiresAt: (0, import_pg_core.bigint)("expires_at", {
|
|
1425
|
+
mode: "number"
|
|
1426
|
+
}).notNull(),
|
|
1427
|
+
createdAt: (0, import_pg_core.bigint)("created_at", {
|
|
1428
|
+
mode: "number"
|
|
1429
|
+
}).notNull()
|
|
1430
|
+
});
|
|
984
1431
|
var pgAgentSchema = {
|
|
985
1432
|
agentActionProposal: agentActionProposal3,
|
|
986
1433
|
agentThread: agentThread3,
|
|
@@ -988,13 +1435,19 @@ var pgAgentSchema = {
|
|
|
988
1435
|
agentQueuedMessage: agentQueuedMessage3,
|
|
989
1436
|
agentToolCall: agentToolCall3,
|
|
990
1437
|
agentTokenUsage: agentTokenUsage3,
|
|
1438
|
+
agentGenuiCall: agentGenuiCall3,
|
|
991
1439
|
agentModelPricing: agentModelPricing3,
|
|
992
1440
|
agentRun: agentRun3,
|
|
993
1441
|
agentMemory: agentMemory3,
|
|
994
1442
|
ragIngestionLog: ragIngestionLog3,
|
|
995
1443
|
agentConfirmToken: agentConfirmToken3,
|
|
996
1444
|
agentChannelState: agentChannelState3,
|
|
997
|
-
agentStreamFrame: agentStreamFrame3
|
|
1445
|
+
agentStreamFrame: agentStreamFrame3,
|
|
1446
|
+
agentPoppyConversation: agentPoppyConversation3,
|
|
1447
|
+
agentPoppyEvent: agentPoppyEvent3,
|
|
1448
|
+
agentPoppyMessage: agentPoppyMessage3,
|
|
1449
|
+
agentPoppyConnection: agentPoppyConnection3,
|
|
1450
|
+
agentPoppyConnect: agentPoppyConnect3
|
|
998
1451
|
};
|
|
999
1452
|
|
|
1000
1453
|
// src/dialect.ts
|
|
@@ -2592,6 +3045,44 @@ var DrizzleAgentStore = class {
|
|
|
2592
3045
|
createdAt: /* @__PURE__ */ new Date()
|
|
2593
3046
|
});
|
|
2594
3047
|
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Generative-UI telemetry: one `agent_genui_call` row per UI tool call, upserted by its tool call
|
|
3050
|
+
* id — a replayed record replaces the row (keeping the first `created_at`) rather than adding one.
|
|
3051
|
+
*/
|
|
3052
|
+
async recordGenuiCalls(rows) {
|
|
3053
|
+
const table = this.t.agentGenuiCall;
|
|
3054
|
+
for (const row of rows) {
|
|
3055
|
+
const columns = {
|
|
3056
|
+
runId: row.runId,
|
|
3057
|
+
threadId: row.threadId,
|
|
3058
|
+
actorRef: row.actorRef,
|
|
3059
|
+
agentName: row.agentName ?? null,
|
|
3060
|
+
step: row.step,
|
|
3061
|
+
toolName: row.toolName,
|
|
3062
|
+
channel: row.channel,
|
|
3063
|
+
mode: row.mode,
|
|
3064
|
+
modelId: row.modelId,
|
|
3065
|
+
attempt: row.attempt,
|
|
3066
|
+
outcome: row.outcome,
|
|
3067
|
+
validity: row.validity,
|
|
3068
|
+
errorCategory: row.errorCategory ?? null,
|
|
3069
|
+
errorMessage: row.errorMessage ?? null,
|
|
3070
|
+
inputTokens: row.inputTokens,
|
|
3071
|
+
outputTokens: row.outputTokens,
|
|
3072
|
+
costUsd: row.costUsd ?? null,
|
|
3073
|
+
costSource: row.costSource ?? null,
|
|
3074
|
+
firstFrameMs: row.firstFrameMs ?? null,
|
|
3075
|
+
completeFrameMs: row.completeFrameMs ?? null,
|
|
3076
|
+
payloadBytes: row.payloadBytes,
|
|
3077
|
+
payload: row.payload ?? null
|
|
3078
|
+
};
|
|
3079
|
+
await upsert(this.dialect, this.db.insert(table).values({
|
|
3080
|
+
id: row.toolCallId,
|
|
3081
|
+
...columns,
|
|
3082
|
+
createdAt: Date.now()
|
|
3083
|
+
}), table.id, columns);
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
2595
3086
|
async quotaToday(actorRef, day) {
|
|
2596
3087
|
return this.usageBetween(actorRef, day, day);
|
|
2597
3088
|
}
|
|
@@ -2764,6 +3255,51 @@ function emptyPage(query) {
|
|
|
2764
3255
|
};
|
|
2765
3256
|
}
|
|
2766
3257
|
__name(emptyPage, "emptyPage");
|
|
3258
|
+
function toGenuiCallRow(row) {
|
|
3259
|
+
return {
|
|
3260
|
+
toolCallId: row.id,
|
|
3261
|
+
runId: row.runId,
|
|
3262
|
+
threadId: row.threadId,
|
|
3263
|
+
actorRef: row.actorRef,
|
|
3264
|
+
...row.agentName !== null ? {
|
|
3265
|
+
agentName: row.agentName
|
|
3266
|
+
} : {},
|
|
3267
|
+
step: Number(row.step),
|
|
3268
|
+
toolName: row.toolName,
|
|
3269
|
+
channel: row.channel,
|
|
3270
|
+
mode: row.mode,
|
|
3271
|
+
modelId: row.modelId,
|
|
3272
|
+
attempt: Number(row.attempt),
|
|
3273
|
+
outcome: row.outcome,
|
|
3274
|
+
validity: row.validity,
|
|
3275
|
+
...row.errorCategory !== null ? {
|
|
3276
|
+
errorCategory: row.errorCategory
|
|
3277
|
+
} : {},
|
|
3278
|
+
...row.errorMessage !== null ? {
|
|
3279
|
+
errorMessage: row.errorMessage
|
|
3280
|
+
} : {},
|
|
3281
|
+
inputTokens: Number(row.inputTokens),
|
|
3282
|
+
outputTokens: Number(row.outputTokens),
|
|
3283
|
+
...row.costUsd !== null ? {
|
|
3284
|
+
costUsd: Number(row.costUsd)
|
|
3285
|
+
} : {},
|
|
3286
|
+
...row.costSource !== null ? {
|
|
3287
|
+
costSource: row.costSource
|
|
3288
|
+
} : {},
|
|
3289
|
+
...row.firstFrameMs !== null ? {
|
|
3290
|
+
firstFrameMs: Number(row.firstFrameMs)
|
|
3291
|
+
} : {},
|
|
3292
|
+
...row.completeFrameMs !== null ? {
|
|
3293
|
+
completeFrameMs: Number(row.completeFrameMs)
|
|
3294
|
+
} : {},
|
|
3295
|
+
payloadBytes: Number(row.payloadBytes),
|
|
3296
|
+
...row.payload !== null ? {
|
|
3297
|
+
payload: row.payload
|
|
3298
|
+
} : {},
|
|
3299
|
+
createdAt: new Date(Number(row.createdAt))
|
|
3300
|
+
};
|
|
3301
|
+
}
|
|
3302
|
+
__name(toGenuiCallRow, "toGenuiCallRow");
|
|
2767
3303
|
function toRecentRunRow(run) {
|
|
2768
3304
|
return {
|
|
2769
3305
|
runId: run.id,
|
|
@@ -3349,6 +3885,13 @@ var DrizzleGovernanceQueries = class {
|
|
|
3349
3885
|
})
|
|
3350
3886
|
};
|
|
3351
3887
|
}
|
|
3888
|
+
/** Generative-UI stats over the `agent_genui_call` rows created in the (UTC, inclusive) day range. */
|
|
3889
|
+
async genuiStats(range) {
|
|
3890
|
+
const { start, end } = (0, import_nestjs_agent_core5.dayBoundsUtc)(range);
|
|
3891
|
+
const table = this.t.agentGenuiCall;
|
|
3892
|
+
const rows = await this.db.select().from(table).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.gte)(table.createdAt, start.getTime()), (0, import_drizzle_orm5.lte)(table.createdAt, end.getTime())));
|
|
3893
|
+
return (0, import_nestjs_agent_core5.summarizeGenuiCalls)(rows.map(toGenuiCallRow));
|
|
3894
|
+
}
|
|
3352
3895
|
/** Tool-call counts for a set of messages in ONE grouped query — the detail view's no-N+1 guarantee. */
|
|
3353
3896
|
async toolCallCountsByMessage(messageIds) {
|
|
3354
3897
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -3735,14 +4278,392 @@ var DrizzleChannelStore = class {
|
|
|
3735
4278
|
}
|
|
3736
4279
|
};
|
|
3737
4280
|
|
|
4281
|
+
// src/drizzle-poppy-store.ts
|
|
4282
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
4283
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
4284
|
+
var MAX_APPEND_ATTEMPTS = 50;
|
|
4285
|
+
var sleep = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep");
|
|
4286
|
+
var nullable = /* @__PURE__ */ __name((value) => value == null ? null : String(value), "nullable");
|
|
4287
|
+
function toInt(value) {
|
|
4288
|
+
if (typeof value === "number") return value;
|
|
4289
|
+
if (typeof value === "bigint") return Number(value);
|
|
4290
|
+
if (typeof value === "string") return Number.parseInt(value, 10) || 0;
|
|
4291
|
+
return 0;
|
|
4292
|
+
}
|
|
4293
|
+
__name(toInt, "toInt");
|
|
4294
|
+
var PATCH_COLUMNS = {
|
|
4295
|
+
accountRef: "accountRef",
|
|
4296
|
+
threadId: "threadId",
|
|
4297
|
+
openDirectId: "openDirectId",
|
|
4298
|
+
status: "status",
|
|
4299
|
+
responder: "responder",
|
|
4300
|
+
context: "context",
|
|
4301
|
+
activeRunId: "activeRunId",
|
|
4302
|
+
turnSeq: "turnSeq",
|
|
4303
|
+
grant: "grantInfo",
|
|
4304
|
+
prunedSeq: "prunedSeq"
|
|
4305
|
+
};
|
|
4306
|
+
var DrizzlePoppyStore = class {
|
|
4307
|
+
static {
|
|
4308
|
+
__name(this, "DrizzlePoppyStore");
|
|
4309
|
+
}
|
|
4310
|
+
db;
|
|
4311
|
+
dialect;
|
|
4312
|
+
t;
|
|
4313
|
+
constructor(db) {
|
|
4314
|
+
this.dialect = agentDialectOf(db);
|
|
4315
|
+
this.t = agentTablesFor(this.dialect);
|
|
4316
|
+
this.db = asBuilder(db);
|
|
4317
|
+
}
|
|
4318
|
+
async createConversation(record) {
|
|
4319
|
+
await this.db.insert(this.t.agentPoppyConversation).values({
|
|
4320
|
+
id: record.id,
|
|
4321
|
+
clientId: record.clientId,
|
|
4322
|
+
userId: record.userId,
|
|
4323
|
+
accountRef: record.accountRef,
|
|
4324
|
+
agentName: record.agentName,
|
|
4325
|
+
threadId: record.threadId,
|
|
4326
|
+
parentId: record.parentId,
|
|
4327
|
+
openDirectId: record.openDirectId,
|
|
4328
|
+
status: record.status,
|
|
4329
|
+
responder: record.responder,
|
|
4330
|
+
context: JSON.stringify(record.context),
|
|
4331
|
+
activeRunId: record.activeRunId,
|
|
4332
|
+
turnSeq: record.turnSeq,
|
|
4333
|
+
grantInfo: record.grant === null ? null : JSON.stringify(record.grant),
|
|
4334
|
+
readerHolder: null,
|
|
4335
|
+
readerUntil: null,
|
|
4336
|
+
prunedSeq: record.prunedSeq,
|
|
4337
|
+
createdAt: record.createdAt,
|
|
4338
|
+
updatedAt: record.updatedAt
|
|
4339
|
+
});
|
|
4340
|
+
}
|
|
4341
|
+
async getConversation(id) {
|
|
4342
|
+
const table = this.t.agentPoppyConversation;
|
|
4343
|
+
const [row] = await this.db.select().from(table).where((0, import_drizzle_orm11.eq)(table.id, id)).limit(1);
|
|
4344
|
+
if (!row) return null;
|
|
4345
|
+
return {
|
|
4346
|
+
id: row.id,
|
|
4347
|
+
clientId: row.clientId,
|
|
4348
|
+
userId: row.userId,
|
|
4349
|
+
accountRef: nullable(row.accountRef),
|
|
4350
|
+
agentName: row.agentName,
|
|
4351
|
+
threadId: nullable(row.threadId),
|
|
4352
|
+
parentId: nullable(row.parentId),
|
|
4353
|
+
openDirectId: nullable(row.openDirectId),
|
|
4354
|
+
status: row.status,
|
|
4355
|
+
responder: row.responder,
|
|
4356
|
+
context: row.context == null ? {} : JSON.parse(row.context),
|
|
4357
|
+
activeRunId: nullable(row.activeRunId),
|
|
4358
|
+
turnSeq: toInt(row.turnSeq),
|
|
4359
|
+
grant: row.grantInfo == null ? null : JSON.parse(row.grantInfo),
|
|
4360
|
+
prunedSeq: toInt(row.prunedSeq),
|
|
4361
|
+
createdAt: toInt(row.createdAt),
|
|
4362
|
+
updatedAt: toInt(row.updatedAt)
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4365
|
+
async updateConversation(id, patch) {
|
|
4366
|
+
const table = this.t.agentPoppyConversation;
|
|
4367
|
+
const set = {
|
|
4368
|
+
updatedAt: Date.now()
|
|
4369
|
+
};
|
|
4370
|
+
for (const [key2, column] of Object.entries(PATCH_COLUMNS)) {
|
|
4371
|
+
const value = patch[key2];
|
|
4372
|
+
if (value === void 0) continue;
|
|
4373
|
+
set[column] = key2 === "context" || key2 === "grant" && value !== null ? JSON.stringify(value) : value;
|
|
4374
|
+
}
|
|
4375
|
+
await this.db.update(table).set(set).where((0, import_drizzle_orm11.eq)(table.id, id));
|
|
4376
|
+
}
|
|
4377
|
+
async appendEvent(conversationId, body, options = {}) {
|
|
4378
|
+
const table = this.t.agentPoppyEvent;
|
|
4379
|
+
for (let attempt = 1; ; attempt++) {
|
|
4380
|
+
if (options.key !== void 0) {
|
|
4381
|
+
const [existing] = await this.db.select({
|
|
4382
|
+
seq: table.seq,
|
|
4383
|
+
event: table.event
|
|
4384
|
+
}).from(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.conversationId, conversationId), (0, import_drizzle_orm11.eq)(table.eventKey, options.key))).limit(1);
|
|
4385
|
+
if (existing) {
|
|
4386
|
+
return {
|
|
4387
|
+
event: {
|
|
4388
|
+
seq: toInt(existing.seq),
|
|
4389
|
+
event: JSON.parse(existing.event)
|
|
4390
|
+
},
|
|
4391
|
+
created: false
|
|
4392
|
+
};
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
const seq = await this.lastSeq(conversationId) + 1;
|
|
4396
|
+
const now = Date.now();
|
|
4397
|
+
const stored = {
|
|
4398
|
+
seq,
|
|
4399
|
+
event: {
|
|
4400
|
+
id: (0, import_nestjs_agent_core8.newEventId)(seq),
|
|
4401
|
+
created_at: new Date(now).toISOString(),
|
|
4402
|
+
...body
|
|
4403
|
+
}
|
|
4404
|
+
};
|
|
4405
|
+
let inserted = false;
|
|
4406
|
+
try {
|
|
4407
|
+
inserted = await this.insertIgnore(table, {
|
|
4408
|
+
conversationId,
|
|
4409
|
+
seq,
|
|
4410
|
+
id: stored.event.id,
|
|
4411
|
+
type: body.type,
|
|
4412
|
+
event: JSON.stringify(stored.event),
|
|
4413
|
+
eventKey: options.key ?? null,
|
|
4414
|
+
createdAt: now
|
|
4415
|
+
});
|
|
4416
|
+
} catch (error) {
|
|
4417
|
+
if (!isUniqueViolation(error)) throw error;
|
|
4418
|
+
}
|
|
4419
|
+
if (inserted) return {
|
|
4420
|
+
event: stored,
|
|
4421
|
+
created: true
|
|
4422
|
+
};
|
|
4423
|
+
if (attempt >= MAX_APPEND_ATTEMPTS) {
|
|
4424
|
+
throw new Error(`poppy: could not append to ${conversationId} after ${attempt} attempts`);
|
|
4425
|
+
}
|
|
4426
|
+
await sleep(Math.random() * Math.min(attempt, 10) * 2);
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4429
|
+
/** The last position taken: the last event's, or — every event pruned — the pruned floor. */
|
|
4430
|
+
async lastSeq(conversationId) {
|
|
4431
|
+
const table = this.t.agentPoppyEvent;
|
|
4432
|
+
const [last] = await this.db.select({
|
|
4433
|
+
seq: table.seq
|
|
4434
|
+
}).from(table).where((0, import_drizzle_orm11.eq)(table.conversationId, conversationId)).orderBy((0, import_drizzle_orm11.desc)(table.seq)).limit(1);
|
|
4435
|
+
if (last) return toInt(last.seq);
|
|
4436
|
+
const conversations = this.t.agentPoppyConversation;
|
|
4437
|
+
const [conversation] = await this.db.select({
|
|
4438
|
+
prunedSeq: conversations.prunedSeq
|
|
4439
|
+
}).from(conversations).where((0, import_drizzle_orm11.eq)(conversations.id, conversationId)).limit(1);
|
|
4440
|
+
return toInt(conversation?.prunedSeq);
|
|
4441
|
+
}
|
|
4442
|
+
async listEvents(conversationId, afterSeq, limit) {
|
|
4443
|
+
const table = this.t.agentPoppyEvent;
|
|
4444
|
+
const rows = await this.db.select({
|
|
4445
|
+
seq: table.seq,
|
|
4446
|
+
event: table.event
|
|
4447
|
+
}).from(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.conversationId, conversationId), (0, import_drizzle_orm11.gt)(table.seq, afterSeq))).orderBy(table.seq).limit(limit);
|
|
4448
|
+
return rows.map((row) => ({
|
|
4449
|
+
seq: toInt(row.seq),
|
|
4450
|
+
event: JSON.parse(row.event)
|
|
4451
|
+
}));
|
|
4452
|
+
}
|
|
4453
|
+
async findEventSeq(conversationId, eventId) {
|
|
4454
|
+
const table = this.t.agentPoppyEvent;
|
|
4455
|
+
const [row] = await this.db.select({
|
|
4456
|
+
seq: table.seq
|
|
4457
|
+
}).from(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.conversationId, conversationId), (0, import_drizzle_orm11.eq)(table.id, eventId))).limit(1);
|
|
4458
|
+
return row ? toInt(row.seq) : null;
|
|
4459
|
+
}
|
|
4460
|
+
async pruneEvents(conversationId, before) {
|
|
4461
|
+
const table = this.t.agentPoppyEvent;
|
|
4462
|
+
const [last] = await this.db.select({
|
|
4463
|
+
seq: table.seq
|
|
4464
|
+
}).from(table).where((0, import_drizzle_orm11.eq)(table.conversationId, conversationId)).orderBy((0, import_drizzle_orm11.desc)(table.seq)).limit(1);
|
|
4465
|
+
if (!last) return;
|
|
4466
|
+
const [dropped] = await this.db.select({
|
|
4467
|
+
seq: table.seq
|
|
4468
|
+
}).from(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.conversationId, conversationId), (0, import_drizzle_orm11.lt)(table.createdAt, before), (0, import_drizzle_orm11.lt)(table.seq, toInt(last.seq)))).orderBy((0, import_drizzle_orm11.desc)(table.seq)).limit(1);
|
|
4469
|
+
if (!dropped) return;
|
|
4470
|
+
const upTo = toInt(dropped.seq);
|
|
4471
|
+
const conversations = this.t.agentPoppyConversation;
|
|
4472
|
+
await this.db.update(conversations).set({
|
|
4473
|
+
prunedSeq: upTo
|
|
4474
|
+
}).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(conversations.id, conversationId), (0, import_drizzle_orm11.lt)(conversations.prunedSeq, upTo)));
|
|
4475
|
+
await this.db.delete(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.conversationId, conversationId), (0, import_drizzle_orm11.lte)(table.seq, upTo)));
|
|
4476
|
+
}
|
|
4477
|
+
async claimMessage(owner, messageId, receipt) {
|
|
4478
|
+
const table = this.t.agentPoppyMessage;
|
|
4479
|
+
for (let attempt = 1; ; attempt++) {
|
|
4480
|
+
const inserted = await this.insertIgnore(table, {
|
|
4481
|
+
owner,
|
|
4482
|
+
messageId,
|
|
4483
|
+
fingerprint: receipt.fingerprint,
|
|
4484
|
+
conversationId: receipt.conversationId,
|
|
4485
|
+
response: JSON.stringify(receipt.response),
|
|
4486
|
+
createdAt: Date.now()
|
|
4487
|
+
});
|
|
4488
|
+
if (inserted) return {
|
|
4489
|
+
status: "claimed"
|
|
4490
|
+
};
|
|
4491
|
+
const [row] = await this.db.select().from(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.owner, owner), (0, import_drizzle_orm11.eq)(table.messageId, messageId))).limit(1);
|
|
4492
|
+
if (row) {
|
|
4493
|
+
return {
|
|
4494
|
+
status: "existing",
|
|
4495
|
+
fingerprint: row.fingerprint,
|
|
4496
|
+
conversationId: row.conversationId,
|
|
4497
|
+
response: JSON.parse(row.response)
|
|
4498
|
+
};
|
|
4499
|
+
}
|
|
4500
|
+
if (attempt >= 5) throw new Error(`poppy: could not claim message ${messageId}`);
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
async releaseMessage(owner, messageId) {
|
|
4504
|
+
const table = this.t.agentPoppyMessage;
|
|
4505
|
+
await this.db.delete(table).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.owner, owner), (0, import_drizzle_orm11.eq)(table.messageId, messageId)));
|
|
4506
|
+
}
|
|
4507
|
+
async leaseReader(conversationId, holder, ttlMs) {
|
|
4508
|
+
const table = this.t.agentPoppyConversation;
|
|
4509
|
+
const now = Date.now();
|
|
4510
|
+
const taken = await affectedRows(this.dialect, this.db.update(table).set({
|
|
4511
|
+
readerHolder: holder,
|
|
4512
|
+
readerUntil: now + ttlMs
|
|
4513
|
+
}).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.id, conversationId), (0, import_drizzle_orm11.or)((0, import_drizzle_orm11.isNull)(table.readerHolder), (0, import_drizzle_orm11.eq)(table.readerHolder, holder), (0, import_drizzle_orm11.lte)(table.readerUntil, now)))), table.id);
|
|
4514
|
+
if (taken === 1) return true;
|
|
4515
|
+
if (this.dialect !== "mysql") return false;
|
|
4516
|
+
const [row] = await this.db.select({
|
|
4517
|
+
holder: table.readerHolder
|
|
4518
|
+
}).from(table).where((0, import_drizzle_orm11.eq)(table.id, conversationId)).limit(1);
|
|
4519
|
+
return row?.holder === holder;
|
|
4520
|
+
}
|
|
4521
|
+
async releaseReader(conversationId, holder) {
|
|
4522
|
+
const table = this.t.agentPoppyConversation;
|
|
4523
|
+
await this.db.update(table).set({
|
|
4524
|
+
readerHolder: null,
|
|
4525
|
+
readerUntil: null
|
|
4526
|
+
}).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(table.id, conversationId), (0, import_drizzle_orm11.eq)(table.readerHolder, holder)));
|
|
4527
|
+
}
|
|
4528
|
+
/** Insert `row`, skipping it on any duplicate key. `true` when it went in. */
|
|
4529
|
+
async insertIgnore(table, row) {
|
|
4530
|
+
if (this.dialect === "mysql") {
|
|
4531
|
+
const insert = this.db.insert(table);
|
|
4532
|
+
return mysqlAffectedRows(await insert.ignore().values(row)) === 1;
|
|
4533
|
+
}
|
|
4534
|
+
const statement = this.db.insert(table).values(row).onConflictDoNothing();
|
|
4535
|
+
return await affectedRows(this.dialect, statement, table.createdAt) === 1;
|
|
4536
|
+
}
|
|
4537
|
+
};
|
|
4538
|
+
|
|
4539
|
+
// src/drizzle-poppy-connection-store.ts
|
|
4540
|
+
var import_drizzle_orm12 = require("drizzle-orm");
|
|
4541
|
+
var nullable2 = /* @__PURE__ */ __name((value) => value == null ? null : String(value), "nullable");
|
|
4542
|
+
var toInt2 = /* @__PURE__ */ __name((value) => typeof value === "number" ? value : Number(value ?? 0), "toInt");
|
|
4543
|
+
var DrizzlePoppyConnectionStore = class {
|
|
4544
|
+
static {
|
|
4545
|
+
__name(this, "DrizzlePoppyConnectionStore");
|
|
4546
|
+
}
|
|
4547
|
+
db;
|
|
4548
|
+
dialect;
|
|
4549
|
+
t;
|
|
4550
|
+
constructor(db) {
|
|
4551
|
+
this.dialect = agentDialectOf(db);
|
|
4552
|
+
this.t = agentTablesFor(this.dialect);
|
|
4553
|
+
this.db = asBuilder(db);
|
|
4554
|
+
}
|
|
4555
|
+
async listConnections(owner) {
|
|
4556
|
+
const table = this.t.agentPoppyConnection;
|
|
4557
|
+
const rows = await this.db.select().from(table).where((0, import_drizzle_orm12.eq)(table.owner, owner)).orderBy((0, import_drizzle_orm12.asc)(table.domain), (0, import_drizzle_orm12.asc)(table.issuer));
|
|
4558
|
+
return rows.map(toConnection);
|
|
4559
|
+
}
|
|
4560
|
+
async getConnection(owner, issuer) {
|
|
4561
|
+
const table = this.t.agentPoppyConnection;
|
|
4562
|
+
const [row] = await this.db.select().from(table).where((0, import_drizzle_orm12.and)((0, import_drizzle_orm12.eq)(table.owner, owner), (0, import_drizzle_orm12.eq)(table.issuer, issuer))).limit(1);
|
|
4563
|
+
return row ? toConnection(row) : null;
|
|
4564
|
+
}
|
|
4565
|
+
async saveConnection(record) {
|
|
4566
|
+
const table = this.t.agentPoppyConnection;
|
|
4567
|
+
const columns = {
|
|
4568
|
+
domain: record.domain,
|
|
4569
|
+
organization: record.organization,
|
|
4570
|
+
scope: record.scope,
|
|
4571
|
+
status: record.status,
|
|
4572
|
+
state: record.state,
|
|
4573
|
+
updatedAt: record.updatedAt
|
|
4574
|
+
};
|
|
4575
|
+
await upsert(this.dialect, this.db.insert(table).values({
|
|
4576
|
+
owner: record.owner,
|
|
4577
|
+
issuer: record.issuer,
|
|
4578
|
+
createdAt: record.createdAt,
|
|
4579
|
+
...columns
|
|
4580
|
+
}), [
|
|
4581
|
+
table.owner,
|
|
4582
|
+
table.issuer
|
|
4583
|
+
], columns);
|
|
4584
|
+
}
|
|
4585
|
+
async deleteConnection(owner, issuer) {
|
|
4586
|
+
const table = this.t.agentPoppyConnection;
|
|
4587
|
+
await this.db.delete(table).where((0, import_drizzle_orm12.and)((0, import_drizzle_orm12.eq)(table.owner, owner), (0, import_drizzle_orm12.eq)(table.issuer, issuer)));
|
|
4588
|
+
}
|
|
4589
|
+
async createPending(record) {
|
|
4590
|
+
const table = this.t.agentPoppyConnect;
|
|
4591
|
+
const row = {
|
|
4592
|
+
id: record.id,
|
|
4593
|
+
owner: record.owner,
|
|
4594
|
+
domain: record.domain,
|
|
4595
|
+
issuer: record.issuer,
|
|
4596
|
+
organization: record.organization,
|
|
4597
|
+
scope: record.scope,
|
|
4598
|
+
actor: record.actor === null ? null : JSON.stringify(record.actor),
|
|
4599
|
+
threadId: record.threadId,
|
|
4600
|
+
runId: record.runId,
|
|
4601
|
+
toolCallId: record.toolCallId,
|
|
4602
|
+
flow: record.flow,
|
|
4603
|
+
status: record.status,
|
|
4604
|
+
expiresAt: record.expiresAt,
|
|
4605
|
+
createdAt: record.createdAt
|
|
4606
|
+
};
|
|
4607
|
+
if (this.dialect === "mysql") {
|
|
4608
|
+
const insert = this.db.insert(table);
|
|
4609
|
+
await insert.ignore().values(row);
|
|
4610
|
+
return;
|
|
4611
|
+
}
|
|
4612
|
+
await this.db.insert(table).values(row).onConflictDoNothing();
|
|
4613
|
+
}
|
|
4614
|
+
async getPending(id) {
|
|
4615
|
+
const table = this.t.agentPoppyConnect;
|
|
4616
|
+
const [row] = await this.db.select().from(table).where((0, import_drizzle_orm12.eq)(table.id, id)).limit(1);
|
|
4617
|
+
if (!row) return null;
|
|
4618
|
+
return {
|
|
4619
|
+
id: row.id,
|
|
4620
|
+
owner: row.owner,
|
|
4621
|
+
domain: row.domain,
|
|
4622
|
+
issuer: row.issuer,
|
|
4623
|
+
organization: row.organization,
|
|
4624
|
+
scope: row.scope ?? "",
|
|
4625
|
+
actor: row.actor == null ? null : JSON.parse(row.actor),
|
|
4626
|
+
threadId: nullable2(row.threadId),
|
|
4627
|
+
runId: nullable2(row.runId),
|
|
4628
|
+
toolCallId: nullable2(row.toolCallId),
|
|
4629
|
+
flow: nullable2(row.flow),
|
|
4630
|
+
status: row.status,
|
|
4631
|
+
expiresAt: toInt2(row.expiresAt),
|
|
4632
|
+
createdAt: toInt2(row.createdAt)
|
|
4633
|
+
};
|
|
4634
|
+
}
|
|
4635
|
+
async updatePending(id, patch) {
|
|
4636
|
+
const set = {};
|
|
4637
|
+
if (patch.flow !== void 0) set.flow = patch.flow;
|
|
4638
|
+
if (patch.status !== void 0) set.status = patch.status;
|
|
4639
|
+
if (Object.keys(set).length === 0) return;
|
|
4640
|
+
const table = this.t.agentPoppyConnect;
|
|
4641
|
+
await this.db.update(table).set(set).where((0, import_drizzle_orm12.eq)(table.id, id));
|
|
4642
|
+
}
|
|
4643
|
+
};
|
|
4644
|
+
function toConnection(row) {
|
|
4645
|
+
return {
|
|
4646
|
+
owner: row.owner,
|
|
4647
|
+
issuer: row.issuer,
|
|
4648
|
+
domain: row.domain,
|
|
4649
|
+
organization: row.organization,
|
|
4650
|
+
scope: row.scope ?? "",
|
|
4651
|
+
status: row.status,
|
|
4652
|
+
state: row.state,
|
|
4653
|
+
createdAt: toInt2(row.createdAt),
|
|
4654
|
+
updatedAt: toInt2(row.updatedAt)
|
|
4655
|
+
};
|
|
4656
|
+
}
|
|
4657
|
+
__name(toConnection, "toConnection");
|
|
4658
|
+
|
|
3738
4659
|
// src/drizzle-rag-ingestion-log.ts
|
|
3739
4660
|
var import_node_diagnostics_channel = require("diagnostics_channel");
|
|
3740
4661
|
var import_common = require("@nestjs/common");
|
|
3741
|
-
var
|
|
3742
|
-
function _ts_decorate(decorators, target, key2,
|
|
3743
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
4662
|
+
var import_drizzle_orm13 = require("drizzle-orm");
|
|
4663
|
+
function _ts_decorate(decorators, target, key2, desc5) {
|
|
4664
|
+
var c = arguments.length, r = c < 3 ? target : desc5 === null ? desc5 = Object.getOwnPropertyDescriptor(target, key2) : desc5, d;
|
|
3744
4665
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3745
|
-
r = Reflect.decorate(decorators, target, key2,
|
|
4666
|
+
r = Reflect.decorate(decorators, target, key2, desc5);
|
|
3746
4667
|
} else {
|
|
3747
4668
|
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
3748
4669
|
if (d = decorators[i]) {
|
|
@@ -3786,8 +4707,8 @@ function num(value) {
|
|
|
3786
4707
|
}
|
|
3787
4708
|
__name(num, "num");
|
|
3788
4709
|
var RAG_INGESTION_LOG_PAGE_ORDER = [
|
|
3789
|
-
(0,
|
|
3790
|
-
(0,
|
|
4710
|
+
(0, import_drizzle_orm13.desc)(ragIngestionLog.updatedAt),
|
|
4711
|
+
(0, import_drizzle_orm13.asc)(ragIngestionLog.documentId)
|
|
3791
4712
|
];
|
|
3792
4713
|
var DEFAULT_PAGE_SIZE = 200;
|
|
3793
4714
|
var DEFAULT_BATCH_SIZE = 200;
|
|
@@ -3858,7 +4779,7 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
|
|
|
3858
4779
|
*/
|
|
3859
4780
|
async listPage(query = {}) {
|
|
3860
4781
|
const [totalRow] = await this.db.select({
|
|
3861
|
-
value: (0,
|
|
4782
|
+
value: (0, import_drizzle_orm13.count)()
|
|
3862
4783
|
}).from(this.t.ragIngestionLog).where(this.where(query));
|
|
3863
4784
|
return {
|
|
3864
4785
|
rows: await this.list(query),
|
|
@@ -3937,17 +4858,17 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
|
|
|
3937
4858
|
}
|
|
3938
4859
|
/** The latest recorded outcome for one document, or null if it was never attempted. */
|
|
3939
4860
|
async get(documentId) {
|
|
3940
|
-
const [row] = await this.db.select().from(this.t.ragIngestionLog).where((0,
|
|
4861
|
+
const [row] = await this.db.select().from(this.t.ragIngestionLog).where((0, import_drizzle_orm13.eq)(this.t.ragIngestionLog.documentId, documentId));
|
|
3941
4862
|
return row ?? null;
|
|
3942
4863
|
}
|
|
3943
4864
|
/** Forget one document's record. Returns whether a row was actually removed. */
|
|
3944
4865
|
async remove(documentId) {
|
|
3945
|
-
const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where((0,
|
|
4866
|
+
const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where((0, import_drizzle_orm13.eq)(this.t.ragIngestionLog.documentId, documentId)), this.t.ragIngestionLog.documentId);
|
|
3946
4867
|
return removed > 0;
|
|
3947
4868
|
}
|
|
3948
4869
|
/** Forget every record for a collection — for when the collection itself is deleted. */
|
|
3949
4870
|
async removeByCollection(collection) {
|
|
3950
|
-
const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where((0,
|
|
4871
|
+
const removed = await affectedRows(this.dialect, this.db.delete(this.t.ragIngestionLog).where((0, import_drizzle_orm13.eq)(this.t.ragIngestionLog.collection, collection)), this.t.ragIngestionLog.documentId);
|
|
3951
4872
|
return removed;
|
|
3952
4873
|
}
|
|
3953
4874
|
/**
|
|
@@ -3977,7 +4898,7 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
|
|
|
3977
4898
|
}
|
|
3978
4899
|
}
|
|
3979
4900
|
where(query) {
|
|
3980
|
-
return (0,
|
|
4901
|
+
return (0, import_drizzle_orm13.and)(query.collection !== void 0 ? (0, import_drizzle_orm13.eq)(this.t.ragIngestionLog.collection, query.collection) : void 0, query.status !== void 0 ? (0, import_drizzle_orm13.eq)(this.t.ragIngestionLog.status, query.status) : void 0);
|
|
3981
4902
|
}
|
|
3982
4903
|
/**
|
|
3983
4904
|
* The coordinates filter AND'd with "strictly after `cursor` in
|
|
@@ -3992,7 +4913,7 @@ var DrizzleRagIngestionLog = class _DrizzleRagIngestionLog {
|
|
|
3992
4913
|
if (cursor === void 0) {
|
|
3993
4914
|
return base;
|
|
3994
4915
|
}
|
|
3995
|
-
return (0,
|
|
4916
|
+
return (0, import_drizzle_orm13.and)(base, (0, import_drizzle_orm13.or)((0, import_drizzle_orm13.lt)(this.t.ragIngestionLog.updatedAt, cursor.updatedAt), (0, import_drizzle_orm13.and)((0, import_drizzle_orm13.eq)(this.t.ragIngestionLog.updatedAt, cursor.updatedAt), (0, import_drizzle_orm13.gt)(this.t.ragIngestionLog.documentId, cursor.documentId))));
|
|
3996
4917
|
}
|
|
3997
4918
|
/**
|
|
3998
4919
|
* Upsert one outcome. Keyed by document id so the row always reflects the *current* state — a
|
|
@@ -4065,12 +4986,12 @@ DrizzleRagIngestionLog = _ts_decorate([
|
|
|
4065
4986
|
], DrizzleRagIngestionLog);
|
|
4066
4987
|
|
|
4067
4988
|
// src/drizzle-agent-store.module.ts
|
|
4068
|
-
var
|
|
4989
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
4069
4990
|
var import_common2 = require("@nestjs/common");
|
|
4070
|
-
function _ts_decorate2(decorators, target, key2,
|
|
4071
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
4991
|
+
function _ts_decorate2(decorators, target, key2, desc5) {
|
|
4992
|
+
var c = arguments.length, r = c < 3 ? target : desc5 === null ? desc5 = Object.getOwnPropertyDescriptor(target, key2) : desc5, d;
|
|
4072
4993
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4073
|
-
r = Reflect.decorate(decorators, target, key2,
|
|
4994
|
+
r = Reflect.decorate(decorators, target, key2, desc5);
|
|
4074
4995
|
} else {
|
|
4075
4996
|
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
4076
4997
|
if (d = decorators[i]) {
|
|
@@ -4102,7 +5023,7 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
|
|
|
4102
5023
|
useFactory: /* @__PURE__ */ __name(() => new DrizzleAgentStore(options.db), "useFactory")
|
|
4103
5024
|
},
|
|
4104
5025
|
{
|
|
4105
|
-
provide:
|
|
5026
|
+
provide: import_nestjs_agent_core9.AGENT_STORE,
|
|
4106
5027
|
useExisting: DrizzleAgentStore
|
|
4107
5028
|
},
|
|
4108
5029
|
// Exported, never bound to AGENT_MEMORY: that token's PRESENCE is what turns memory on, so
|
|
@@ -4119,21 +5040,21 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
|
|
|
4119
5040
|
// AGENT_PRICING_STORE: the host's own store when supplied, else the default Drizzle one.
|
|
4120
5041
|
// DrizzleGovernanceQueries prices usage against whatever is bound here.
|
|
4121
5042
|
options.pricingStore ? {
|
|
4122
|
-
provide:
|
|
5043
|
+
provide: import_nestjs_agent_core9.AGENT_PRICING_STORE,
|
|
4123
5044
|
useClass: options.pricingStore
|
|
4124
5045
|
} : {
|
|
4125
|
-
provide:
|
|
5046
|
+
provide: import_nestjs_agent_core9.AGENT_PRICING_STORE,
|
|
4126
5047
|
useExisting: DrizzlePricingStore
|
|
4127
5048
|
},
|
|
4128
5049
|
{
|
|
4129
5050
|
provide: DrizzleGovernanceQueries,
|
|
4130
5051
|
useFactory: /* @__PURE__ */ __name((pricingStore) => new DrizzleGovernanceQueries(options.db, pricingStore), "useFactory"),
|
|
4131
5052
|
inject: [
|
|
4132
|
-
|
|
5053
|
+
import_nestjs_agent_core9.AGENT_PRICING_STORE
|
|
4133
5054
|
]
|
|
4134
5055
|
},
|
|
4135
5056
|
{
|
|
4136
|
-
provide:
|
|
5057
|
+
provide: import_nestjs_agent_core9.AGENT_GOVERNANCE_QUERIES,
|
|
4137
5058
|
useExisting: DrizzleGovernanceQueries
|
|
4138
5059
|
},
|
|
4139
5060
|
// What makes a `defineConfirmedTool` confirmation single use across replicas.
|
|
@@ -4142,7 +5063,7 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
|
|
|
4142
5063
|
useFactory: /* @__PURE__ */ __name(() => new DrizzleConfirmTokenStore(options.db), "useFactory")
|
|
4143
5064
|
},
|
|
4144
5065
|
{
|
|
4145
|
-
provide:
|
|
5066
|
+
provide: import_nestjs_agent_core9.AGENT_CONFIRM_TOKEN_STORE,
|
|
4146
5067
|
useExisting: DrizzleConfirmTokenStore
|
|
4147
5068
|
},
|
|
4148
5069
|
// Text channels' state (`@dudousxd/nestjs-agent-channels`), shared by every replica.
|
|
@@ -4151,8 +5072,25 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
|
|
|
4151
5072
|
useFactory: /* @__PURE__ */ __name(() => new DrizzleChannelStore(options.db), "useFactory")
|
|
4152
5073
|
},
|
|
4153
5074
|
{
|
|
4154
|
-
provide:
|
|
5075
|
+
provide: import_nestjs_agent_core9.AGENT_CHANNEL_STORE,
|
|
4155
5076
|
useExisting: DrizzleChannelStore
|
|
5077
|
+
},
|
|
5078
|
+
// Personal Agent Protocol (Poppy) conversations and connections, shared by every replica.
|
|
5079
|
+
{
|
|
5080
|
+
provide: DrizzlePoppyStore,
|
|
5081
|
+
useFactory: /* @__PURE__ */ __name(() => new DrizzlePoppyStore(options.db), "useFactory")
|
|
5082
|
+
},
|
|
5083
|
+
{
|
|
5084
|
+
provide: import_nestjs_agent_core9.AGENT_POPPY_STORE,
|
|
5085
|
+
useExisting: DrizzlePoppyStore
|
|
5086
|
+
},
|
|
5087
|
+
{
|
|
5088
|
+
provide: DrizzlePoppyConnectionStore,
|
|
5089
|
+
useFactory: /* @__PURE__ */ __name(() => new DrizzlePoppyConnectionStore(options.db), "useFactory")
|
|
5090
|
+
},
|
|
5091
|
+
{
|
|
5092
|
+
provide: import_nestjs_agent_core9.AGENT_POPPY_CONNECTION_STORE,
|
|
5093
|
+
useExisting: DrizzlePoppyConnectionStore
|
|
4156
5094
|
}
|
|
4157
5095
|
],
|
|
4158
5096
|
exports: [
|
|
@@ -4160,16 +5098,20 @@ var DrizzleAgentStoreModule = class _DrizzleAgentStoreModule {
|
|
|
4160
5098
|
DrizzleRagIngestionLog
|
|
4161
5099
|
],
|
|
4162
5100
|
DrizzleAgentStore,
|
|
4163
|
-
|
|
5101
|
+
import_nestjs_agent_core9.AGENT_STORE,
|
|
4164
5102
|
DrizzleMemoryProvider,
|
|
4165
5103
|
DrizzleGovernanceQueries,
|
|
4166
|
-
|
|
5104
|
+
import_nestjs_agent_core9.AGENT_GOVERNANCE_QUERIES,
|
|
4167
5105
|
DrizzlePricingStore,
|
|
4168
|
-
|
|
5106
|
+
import_nestjs_agent_core9.AGENT_PRICING_STORE,
|
|
4169
5107
|
DrizzleConfirmTokenStore,
|
|
4170
|
-
|
|
5108
|
+
import_nestjs_agent_core9.AGENT_CONFIRM_TOKEN_STORE,
|
|
4171
5109
|
DrizzleChannelStore,
|
|
4172
|
-
|
|
5110
|
+
import_nestjs_agent_core9.AGENT_CHANNEL_STORE,
|
|
5111
|
+
DrizzlePoppyStore,
|
|
5112
|
+
import_nestjs_agent_core9.AGENT_POPPY_STORE,
|
|
5113
|
+
DrizzlePoppyConnectionStore,
|
|
5114
|
+
import_nestjs_agent_core9.AGENT_POPPY_CONNECTION_STORE
|
|
4173
5115
|
]
|
|
4174
5116
|
};
|
|
4175
5117
|
}
|
|
@@ -4186,6 +5128,8 @@ DrizzleAgentStoreModule = _ts_decorate2([
|
|
|
4186
5128
|
DrizzleConfirmTokenStore,
|
|
4187
5129
|
DrizzleGovernanceQueries,
|
|
4188
5130
|
DrizzleMemoryProvider,
|
|
5131
|
+
DrizzlePoppyConnectionStore,
|
|
5132
|
+
DrizzlePoppyStore,
|
|
4189
5133
|
DrizzlePricingStore,
|
|
4190
5134
|
DrizzleRagIngestionLog,
|
|
4191
5135
|
DrizzleStreamFrameTable,
|
|
@@ -4195,9 +5139,15 @@ DrizzleAgentStoreModule = _ts_decorate2([
|
|
|
4195
5139
|
agentChannelState,
|
|
4196
5140
|
agentConfirmToken,
|
|
4197
5141
|
agentDialectOf,
|
|
5142
|
+
agentGenuiCall,
|
|
4198
5143
|
agentMemory,
|
|
4199
5144
|
agentMessage,
|
|
4200
5145
|
agentModelPricing,
|
|
5146
|
+
agentPoppyConnect,
|
|
5147
|
+
agentPoppyConnection,
|
|
5148
|
+
agentPoppyConversation,
|
|
5149
|
+
agentPoppyEvent,
|
|
5150
|
+
agentPoppyMessage,
|
|
4201
5151
|
agentQueuedMessage,
|
|
4202
5152
|
agentRun,
|
|
4203
5153
|
agentSchema,
|