@babyclaw/gateway 0.0.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.
@@ -0,0 +1,109 @@
1
+ CREATE TABLE `ChannelMessageLink` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `platform` text NOT NULL,
4
+ `platformChatId` text NOT NULL,
5
+ `platformMessageId` text NOT NULL,
6
+ `sessionKey` text NOT NULL,
7
+ `scheduleId` text,
8
+ `scheduleRunId` text,
9
+ `createdAt` integer NOT NULL,
10
+ FOREIGN KEY (`scheduleId`) REFERENCES `Schedule`(`id`) ON UPDATE no action ON DELETE set null,
11
+ FOREIGN KEY (`scheduleRunId`) REFERENCES `ScheduleRun`(`id`) ON UPDATE no action ON DELETE set null
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE UNIQUE INDEX `ChannelMessageLink_platform_chatId_messageId_key` ON `ChannelMessageLink` (`platform`,`platformChatId`,`platformMessageId`);--> statement-breakpoint
15
+ CREATE INDEX `ChannelMessageLink_sessionKey_idx` ON `ChannelMessageLink` (`sessionKey`);--> statement-breakpoint
16
+ CREATE INDEX `ChannelMessageLink_scheduleId_idx` ON `ChannelMessageLink` (`scheduleId`);--> statement-breakpoint
17
+ CREATE INDEX `ChannelMessageLink_scheduleRunId_idx` ON `ChannelMessageLink` (`scheduleRunId`);--> statement-breakpoint
18
+ CREATE TABLE `Chat` (
19
+ `id` text PRIMARY KEY NOT NULL,
20
+ `platform` text NOT NULL,
21
+ `platformChatId` text NOT NULL,
22
+ `type` text NOT NULL,
23
+ `title` text,
24
+ `alias` text,
25
+ `isMain` integer DEFAULT false NOT NULL,
26
+ `linkedAt` integer,
27
+ `createdAt` integer NOT NULL,
28
+ `updatedAt` integer NOT NULL
29
+ );
30
+ --> statement-breakpoint
31
+ CREATE UNIQUE INDEX `Chat_platform_platformChatId_key` ON `Chat` (`platform`,`platformChatId`);--> statement-breakpoint
32
+ CREATE UNIQUE INDEX `Chat_platform_alias_key` ON `Chat` (`platform`,`alias`);--> statement-breakpoint
33
+ CREATE TABLE `HeartbeatRun` (
34
+ `id` text PRIMARY KEY NOT NULL,
35
+ `startedAt` integer NOT NULL,
36
+ `finishedAt` integer,
37
+ `outcome` text NOT NULL,
38
+ `summary` text,
39
+ `error` text,
40
+ `createdAt` integer NOT NULL
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE INDEX `HeartbeatRun_createdAt_idx` ON `HeartbeatRun` (`createdAt`);--> statement-breakpoint
44
+ CREATE TABLE `Message` (
45
+ `id` text PRIMARY KEY NOT NULL,
46
+ `sessionId` text NOT NULL,
47
+ `role` text NOT NULL,
48
+ `content` text NOT NULL,
49
+ `metadata` text,
50
+ `createdAt` integer NOT NULL,
51
+ FOREIGN KEY (`sessionId`) REFERENCES `Session`(`id`) ON UPDATE no action ON DELETE cascade
52
+ );
53
+ --> statement-breakpoint
54
+ CREATE INDEX `Message_sessionId_createdAt_idx` ON `Message` (`sessionId`,`createdAt`);--> statement-breakpoint
55
+ CREATE TABLE `ScheduleRun` (
56
+ `id` text PRIMARY KEY NOT NULL,
57
+ `scheduleId` text NOT NULL,
58
+ `scheduledFor` integer NOT NULL,
59
+ `status` text DEFAULT 'pending' NOT NULL,
60
+ `attempt` integer DEFAULT 1 NOT NULL,
61
+ `sessionKey` text,
62
+ `assistantMessageId` integer,
63
+ `error` text,
64
+ `startedAt` integer,
65
+ `finishedAt` integer,
66
+ `createdAt` integer NOT NULL,
67
+ FOREIGN KEY (`scheduleId`) REFERENCES `Schedule`(`id`) ON UPDATE no action ON DELETE cascade
68
+ );
69
+ --> statement-breakpoint
70
+ CREATE INDEX `ScheduleRun_scheduleId_createdAt_idx` ON `ScheduleRun` (`scheduleId`,`createdAt`);--> statement-breakpoint
71
+ CREATE INDEX `ScheduleRun_status_createdAt_idx` ON `ScheduleRun` (`status`,`createdAt`);--> statement-breakpoint
72
+ CREATE INDEX `ScheduleRun_sessionKey_idx` ON `ScheduleRun` (`sessionKey`);--> statement-breakpoint
73
+ CREATE TABLE `Schedule` (
74
+ `id` text PRIMARY KEY NOT NULL,
75
+ `chatId` integer NOT NULL,
76
+ `createdByUserId` integer NOT NULL,
77
+ `threadId` integer,
78
+ `directMessagesTopicId` integer,
79
+ `title` text,
80
+ `taskPrompt` text NOT NULL,
81
+ `sourceText` text NOT NULL,
82
+ `type` text NOT NULL,
83
+ `cronExpression` text,
84
+ `runAt` integer,
85
+ `timezone` text NOT NULL,
86
+ `status` text DEFAULT 'active' NOT NULL,
87
+ `nextRunAt` integer,
88
+ `lastRunAt` integer,
89
+ `createdAt` integer NOT NULL,
90
+ `updatedAt` integer NOT NULL,
91
+ `targetChatRef` text,
92
+ `canceledAt` integer
93
+ );
94
+ --> statement-breakpoint
95
+ CREATE INDEX `Schedule_chatId_status_nextRunAt_idx` ON `Schedule` (`chatId`,`status`,`nextRunAt`);--> statement-breakpoint
96
+ CREATE TABLE `Session` (
97
+ `id` text PRIMARY KEY NOT NULL,
98
+ `key` text NOT NULL,
99
+ `chatId` integer NOT NULL,
100
+ `threadId` integer,
101
+ `title` text,
102
+ `workingMemory` text,
103
+ `lastActivityAt` integer,
104
+ `memoriesLastExtractedAt` integer,
105
+ `createdAt` integer NOT NULL,
106
+ `updatedAt` integer NOT NULL
107
+ );
108
+ --> statement-breakpoint
109
+ CREATE UNIQUE INDEX `Session_key_unique` ON `Session` (`key`);