@artil-ai/server 0.0.0-stage → 0.1.1

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,118 @@
1
+ CREATE TABLE `access` (
2
+ `agent_id` text NOT NULL,
3
+ `channel` text NOT NULL,
4
+ `admit` text NOT NULL,
5
+ `senders` text NOT NULL,
6
+ PRIMARY KEY(`agent_id`, `channel`),
7
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade
8
+ );
9
+ --> statement-breakpoint
10
+ CREATE TABLE `addresses` (
11
+ `id` text PRIMARY KEY NOT NULL,
12
+ `agent_id` text NOT NULL,
13
+ `channel` text NOT NULL,
14
+ `value` text NOT NULL,
15
+ `credentials` text,
16
+ `created_at` integer NOT NULL,
17
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade
18
+ );
19
+ --> statement-breakpoint
20
+ CREATE UNIQUE INDEX `addresses_channel_value_idx` ON `addresses` (`channel`,`value`) WHERE "addresses"."credentials" is not null;--> statement-breakpoint
21
+ CREATE INDEX `addresses_agent_id_idx` ON `addresses` (`agent_id`);--> statement-breakpoint
22
+ CREATE TABLE `agents` (
23
+ `id` text PRIMARY KEY NOT NULL,
24
+ `name` text NOT NULL,
25
+ `created_at` integer NOT NULL
26
+ );
27
+ --> statement-breakpoint
28
+ CREATE UNIQUE INDEX `agents_name_idx` ON `agents` (lower("name"));--> statement-breakpoint
29
+ CREATE TABLE `connections` (
30
+ `agent_id` text PRIMARY KEY NOT NULL,
31
+ `id` text NOT NULL,
32
+ `token_hash` text NOT NULL,
33
+ `client` text NOT NULL,
34
+ `machine` text,
35
+ `starts_after` integer NOT NULL,
36
+ `listened_at` integer,
37
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade,
38
+ FOREIGN KEY (`token_hash`) REFERENCES `tokens`(`hash`) ON UPDATE no action ON DELETE cascade
39
+ );
40
+ --> statement-breakpoint
41
+ CREATE TABLE `events` (
42
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
43
+ `agent_id` text NOT NULL,
44
+ `type` text NOT NULL,
45
+ `channel` text NOT NULL,
46
+ `message_id` text NOT NULL,
47
+ `text` text,
48
+ `sender` text,
49
+ `thread` text,
50
+ `to_thread` text,
51
+ `client` text,
52
+ `created_at` integer NOT NULL,
53
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade
54
+ );
55
+ --> statement-breakpoint
56
+ CREATE INDEX `events_agent_id_id_idx` ON `events` (`agent_id`,`id`);--> statement-breakpoint
57
+ CREATE TABLE `files` (
58
+ `id` text PRIMARY KEY NOT NULL,
59
+ `agent_id` text NOT NULL,
60
+ `message_id` text NOT NULL,
61
+ `name` text NOT NULL,
62
+ `type` text NOT NULL,
63
+ `size` integer NOT NULL,
64
+ `key` text,
65
+ `expires_at` integer,
66
+ `created_at` integer NOT NULL,
67
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade
68
+ );
69
+ --> statement-breakpoint
70
+ CREATE INDEX `files_message_id_idx` ON `files` (`message_id`);--> statement-breakpoint
71
+ CREATE TABLE `messages` (
72
+ `id` text PRIMARY KEY NOT NULL,
73
+ `agent_id` text NOT NULL,
74
+ `address_id` text NOT NULL,
75
+ `channel` text NOT NULL,
76
+ `direction` text NOT NULL,
77
+ `external_id` text,
78
+ `counterpart` text NOT NULL,
79
+ `counterpart_name` text,
80
+ `to` text NOT NULL,
81
+ `text` text NOT NULL,
82
+ `status` text NOT NULL,
83
+ `refusal` text,
84
+ `admission` text,
85
+ `error` text,
86
+ `created_at` integer NOT NULL,
87
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade,
88
+ FOREIGN KEY (`address_id`) REFERENCES `addresses`(`id`) ON UPDATE no action ON DELETE cascade
89
+ );
90
+ --> statement-breakpoint
91
+ CREATE INDEX `messages_agent_id_created_at_idx` ON `messages` (`agent_id`,`created_at`);--> statement-breakpoint
92
+ CREATE UNIQUE INDEX `messages_address_id_external_id_idx` ON `messages` (`address_id`,`direction`,`external_id`) WHERE "messages"."external_id" is not null;--> statement-breakpoint
93
+ CREATE TABLE `sign_ins` (
94
+ `id` text PRIMARY KEY NOT NULL,
95
+ `kind` text NOT NULL,
96
+ `client_id` text,
97
+ `client_name` text NOT NULL,
98
+ `redirect_uri` text NOT NULL,
99
+ `challenge` text NOT NULL,
100
+ `state` text,
101
+ `agent_id` text,
102
+ `code_hash` text,
103
+ `expires_at` integer NOT NULL,
104
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade
105
+ );
106
+ --> statement-breakpoint
107
+ CREATE UNIQUE INDEX `sign_ins_code_hash_unique` ON `sign_ins` (`code_hash`);--> statement-breakpoint
108
+ CREATE TABLE `tokens` (
109
+ `id` text PRIMARY KEY NOT NULL,
110
+ `agent_id` text NOT NULL,
111
+ `hash` text NOT NULL,
112
+ `name` text NOT NULL,
113
+ `created_at` integer NOT NULL,
114
+ FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade
115
+ );
116
+ --> statement-breakpoint
117
+ CREATE UNIQUE INDEX `tokens_hash_unique` ON `tokens` (`hash`);--> statement-breakpoint
118
+ CREATE INDEX `tokens_agent_id_idx` ON `tokens` (`agent_id`);