@openscout/scout 0.2.70 → 0.2.73
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/LICENSE +202 -0
- package/README.md +59 -3
- package/bin/openscout-runtime.mjs +23 -2
- package/bin/scout +34 -0
- package/bin/scout.mjs +195 -18
- package/bin/scoutd +0 -0
- package/dist/client/apple-touch-icon.png +0 -0
- package/dist/client/assets/RepoDiffViewer-D8gg36W3.js +56 -0
- package/dist/client/assets/{addon-fit-BNV7JPhj.js → addon-fit-D4KdY-pj.js} +1 -1
- package/dist/client/assets/{addon-webgl-B-_Y5L3F.js → addon-webgl-Bo_tmKBp.js} +1 -1
- package/dist/client/assets/arc.es-D0gujIKy.js +188 -0
- package/dist/client/assets/embed-entry-CUVNwyB_.js +1 -0
- package/dist/client/assets/index-CRkjiso5.js +257 -0
- package/dist/client/assets/index-D_RX2cRb.css +1 -0
- package/dist/client/assets/{xterm-Cx1oABPt.js → xterm-RfflDFod.js} +1 -1
- package/dist/client/favicon-16.png +0 -0
- package/dist/client/favicon-32.png +0 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/favicon.svg +48 -0
- package/dist/client/index.html +42 -2
- package/dist/client/openscout-icon.png +0 -0
- package/dist/client/site.webmanifest +19 -0
- package/dist/client/web-app-icon-192.png +0 -0
- package/dist/client/web-app-icon-512.png +0 -0
- package/dist/drizzle/0000_curly_iron_monger.sql +592 -0
- package/dist/drizzle/0001_invocation-status-columns.sql +7 -0
- package/dist/drizzle/0002_invocation-flight-metadata.sql +21 -0
- package/dist/drizzle/README.md +81 -0
- package/dist/drizzle/meta/0000_snapshot.json +4575 -0
- package/dist/drizzle/meta/0001_snapshot.json +4624 -0
- package/dist/drizzle/meta/0002_snapshot.json +4631 -0
- package/dist/drizzle/meta/_journal.json +27 -0
- package/dist/main.mjs +77080 -60152
- package/dist/node/main.mjs +7607 -0
- package/dist/openscout-terminal-relay.mjs +3830 -152
- package/dist/{pair-supervisor.mjs → pairing-runtime-controller.mjs} +50837 -41212
- package/dist/runtime/base-daemon.mjs +2219 -488
- package/dist/runtime/broker-daemon.mjs +39082 -25118
- package/dist/runtime/broker-process-manager.mjs +2048 -392
- package/dist/runtime/mesh-discover.mjs +2012 -391
- package/dist/scout-control-plane-web.mjs +58128 -34736
- package/dist/scout-web-server.mjs +58128 -34736
- package/dist/statusline.mjs +287 -0
- package/package.json +8 -4
- package/dist/client/assets/index-BJri_z5a.css +0 -1
- package/dist/client/assets/index-Ccjo5BZz.js +0 -199
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
CREATE TABLE `activity_items` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`kind` text NOT NULL,
|
|
4
|
+
`ts` integer NOT NULL,
|
|
5
|
+
`conversation_id` text,
|
|
6
|
+
`message_id` text,
|
|
7
|
+
`invocation_id` text,
|
|
8
|
+
`flight_id` text,
|
|
9
|
+
`record_id` text,
|
|
10
|
+
`actor_id` text,
|
|
11
|
+
`counterpart_id` text,
|
|
12
|
+
`agent_id` text,
|
|
13
|
+
`workspace_root` text,
|
|
14
|
+
`session_id` text,
|
|
15
|
+
`title` text,
|
|
16
|
+
`summary` text,
|
|
17
|
+
`payload_json` text,
|
|
18
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
19
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
20
|
+
FOREIGN KEY (`invocation_id`) REFERENCES `invocations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
21
|
+
FOREIGN KEY (`flight_id`) REFERENCES `flights`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
22
|
+
FOREIGN KEY (`record_id`) REFERENCES `collaboration_records`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
23
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE set null,
|
|
24
|
+
FOREIGN KEY (`counterpart_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE set null,
|
|
25
|
+
FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE set null
|
|
26
|
+
);
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
CREATE INDEX `idx_activity_items_agent_ts` ON `activity_items` (`agent_id`,"ts" desc);--> statement-breakpoint
|
|
29
|
+
CREATE INDEX `idx_activity_items_actor_ts` ON `activity_items` (`actor_id`,"ts" desc);--> statement-breakpoint
|
|
30
|
+
CREATE INDEX `idx_activity_items_conversation_ts` ON `activity_items` (`conversation_id`,"ts" desc);--> statement-breakpoint
|
|
31
|
+
CREATE INDEX `idx_activity_items_ts` ON `activity_items` ("ts" desc);--> statement-breakpoint
|
|
32
|
+
CREATE INDEX `idx_activity_items_workspace_ts` ON `activity_items` (`workspace_root`,"ts" desc);--> statement-breakpoint
|
|
33
|
+
CREATE INDEX `idx_activity_items_kind_ts` ON `activity_items` (`kind`,"ts" desc);--> statement-breakpoint
|
|
34
|
+
CREATE INDEX `idx_activity_items_session_ts` ON `activity_items` (`session_id`,"ts" desc);--> statement-breakpoint
|
|
35
|
+
CREATE TABLE `actors` (
|
|
36
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
37
|
+
`kind` text NOT NULL,
|
|
38
|
+
`display_name` text NOT NULL,
|
|
39
|
+
`handle` text,
|
|
40
|
+
`labels_json` text,
|
|
41
|
+
`metadata_json` text,
|
|
42
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL
|
|
43
|
+
);
|
|
44
|
+
--> statement-breakpoint
|
|
45
|
+
CREATE TABLE `agent_endpoints` (
|
|
46
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
47
|
+
`agent_id` text NOT NULL,
|
|
48
|
+
`node_id` text NOT NULL,
|
|
49
|
+
`harness` text NOT NULL,
|
|
50
|
+
`transport` text NOT NULL,
|
|
51
|
+
`state` text NOT NULL,
|
|
52
|
+
`address` text,
|
|
53
|
+
`session_id` text,
|
|
54
|
+
`pane` text,
|
|
55
|
+
`cwd` text,
|
|
56
|
+
`project_root` text,
|
|
57
|
+
`metadata_json` text,
|
|
58
|
+
`updated_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL,
|
|
59
|
+
FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
60
|
+
FOREIGN KEY (`node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict
|
|
61
|
+
);
|
|
62
|
+
--> statement-breakpoint
|
|
63
|
+
CREATE INDEX `idx_agent_endpoints_agent_updated_at` ON `agent_endpoints` (`agent_id`,"updated_at" desc);--> statement-breakpoint
|
|
64
|
+
CREATE TABLE `agents` (
|
|
65
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
66
|
+
`definition_id` text NOT NULL,
|
|
67
|
+
`node_qualifier` text,
|
|
68
|
+
`workspace_qualifier` text,
|
|
69
|
+
`selector` text,
|
|
70
|
+
`default_selector` text,
|
|
71
|
+
`agent_class` text NOT NULL,
|
|
72
|
+
`capabilities_json` text NOT NULL,
|
|
73
|
+
`wake_policy` text NOT NULL,
|
|
74
|
+
`home_node_id` text NOT NULL,
|
|
75
|
+
`authority_node_id` text NOT NULL,
|
|
76
|
+
`advertise_scope` text NOT NULL,
|
|
77
|
+
`owner_id` text,
|
|
78
|
+
`metadata_json` text,
|
|
79
|
+
FOREIGN KEY (`id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
80
|
+
FOREIGN KEY (`home_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
81
|
+
FOREIGN KEY (`authority_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict
|
|
82
|
+
);
|
|
83
|
+
--> statement-breakpoint
|
|
84
|
+
CREATE TABLE `bindings` (
|
|
85
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
86
|
+
`conversation_id` text NOT NULL,
|
|
87
|
+
`platform` text NOT NULL,
|
|
88
|
+
`mode` text NOT NULL,
|
|
89
|
+
`external_channel_id` text NOT NULL,
|
|
90
|
+
`external_thread_id` text,
|
|
91
|
+
`metadata_json` text,
|
|
92
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade
|
|
93
|
+
);
|
|
94
|
+
--> statement-breakpoint
|
|
95
|
+
CREATE TABLE `briefings` (
|
|
96
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
97
|
+
`kind` text NOT NULL,
|
|
98
|
+
`title` text NOT NULL,
|
|
99
|
+
`summary` text NOT NULL,
|
|
100
|
+
`recommendation` text,
|
|
101
|
+
`prepared_at` integer NOT NULL,
|
|
102
|
+
`ttl_ms` integer NOT NULL,
|
|
103
|
+
`brief_json` text NOT NULL,
|
|
104
|
+
`observations_json` text NOT NULL,
|
|
105
|
+
`snapshot_json` text NOT NULL,
|
|
106
|
+
`call_json` text NOT NULL,
|
|
107
|
+
`markdown` text,
|
|
108
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL
|
|
109
|
+
);
|
|
110
|
+
--> statement-breakpoint
|
|
111
|
+
CREATE INDEX `idx_briefings_created_at` ON `briefings` ("created_at" desc);--> statement-breakpoint
|
|
112
|
+
CREATE INDEX `idx_briefings_kind_created_at` ON `briefings` (`kind`,"created_at" desc);--> statement-breakpoint
|
|
113
|
+
CREATE TABLE `budget_quota_window_snapshots` (
|
|
114
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
115
|
+
`source` text NOT NULL,
|
|
116
|
+
`provider` text,
|
|
117
|
+
`harness` text,
|
|
118
|
+
`transport` text,
|
|
119
|
+
`model` text,
|
|
120
|
+
`agent_id` text,
|
|
121
|
+
`endpoint_id` text,
|
|
122
|
+
`session_id` text,
|
|
123
|
+
`user_id` text,
|
|
124
|
+
`account_id` text,
|
|
125
|
+
`plan_type` text,
|
|
126
|
+
`label` text NOT NULL,
|
|
127
|
+
`window_kind` text,
|
|
128
|
+
`used_percent` real,
|
|
129
|
+
`percent_remaining` real,
|
|
130
|
+
`used` real,
|
|
131
|
+
`limit_value` real,
|
|
132
|
+
`reset_at` integer,
|
|
133
|
+
`window_ms` integer,
|
|
134
|
+
`captured_at` integer NOT NULL,
|
|
135
|
+
`metadata_json` text,
|
|
136
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL
|
|
137
|
+
);
|
|
138
|
+
--> statement-breakpoint
|
|
139
|
+
CREATE INDEX `idx_budget_quota_windows_session_captured` ON `budget_quota_window_snapshots` (`session_id`,"captured_at" desc);--> statement-breakpoint
|
|
140
|
+
CREATE INDEX `idx_budget_quota_windows_provider_label` ON `budget_quota_window_snapshots` (`provider`,`label`,"captured_at" desc);--> statement-breakpoint
|
|
141
|
+
CREATE TABLE `budget_usage_events` (
|
|
142
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
143
|
+
`scope` text NOT NULL,
|
|
144
|
+
`source` text NOT NULL,
|
|
145
|
+
`provider` text,
|
|
146
|
+
`harness` text,
|
|
147
|
+
`transport` text,
|
|
148
|
+
`model` text,
|
|
149
|
+
`agent_id` text,
|
|
150
|
+
`endpoint_id` text,
|
|
151
|
+
`session_id` text,
|
|
152
|
+
`project_root` text,
|
|
153
|
+
`conversation_id` text,
|
|
154
|
+
`message_id` text,
|
|
155
|
+
`invocation_id` text,
|
|
156
|
+
`flight_id` text,
|
|
157
|
+
`work_id` text,
|
|
158
|
+
`occurred_at` integer NOT NULL,
|
|
159
|
+
`input_tokens` integer,
|
|
160
|
+
`output_tokens` integer,
|
|
161
|
+
`reasoning_output_tokens` integer,
|
|
162
|
+
`cache_creation_input_tokens` integer,
|
|
163
|
+
`cache_read_input_tokens` integer,
|
|
164
|
+
`total_tokens` integer,
|
|
165
|
+
`estimated_usd` real,
|
|
166
|
+
`billed_usd` real,
|
|
167
|
+
`currency` text,
|
|
168
|
+
`dedup_key` text,
|
|
169
|
+
`metadata_json` text,
|
|
170
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL
|
|
171
|
+
);
|
|
172
|
+
--> statement-breakpoint
|
|
173
|
+
CREATE INDEX `idx_budget_usage_events_scope_occurred` ON `budget_usage_events` (`scope`,"occurred_at" desc);--> statement-breakpoint
|
|
174
|
+
CREATE INDEX `idx_budget_usage_events_session_occurred` ON `budget_usage_events` (`session_id`,"occurred_at" desc);--> statement-breakpoint
|
|
175
|
+
CREATE INDEX `idx_budget_usage_events_invocation` ON `budget_usage_events` (`invocation_id`,"occurred_at" desc);--> statement-breakpoint
|
|
176
|
+
CREATE INDEX `idx_budget_usage_events_flight` ON `budget_usage_events` (`flight_id`,"occurred_at" desc);--> statement-breakpoint
|
|
177
|
+
CREATE UNIQUE INDEX `idx_budget_usage_events_dedup` ON `budget_usage_events` (`scope`,`source`,`dedup_key`) WHERE dedup_key IS NOT NULL AND dedup_key != '';--> statement-breakpoint
|
|
178
|
+
CREATE TABLE `collaboration_events` (
|
|
179
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
180
|
+
`record_id` text NOT NULL,
|
|
181
|
+
`record_kind` text NOT NULL,
|
|
182
|
+
`kind` text NOT NULL,
|
|
183
|
+
`actor_id` text NOT NULL,
|
|
184
|
+
`summary` text,
|
|
185
|
+
`metadata_json` text,
|
|
186
|
+
`created_at` integer NOT NULL,
|
|
187
|
+
FOREIGN KEY (`record_id`) REFERENCES `collaboration_records`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
188
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE restrict
|
|
189
|
+
);
|
|
190
|
+
--> statement-breakpoint
|
|
191
|
+
CREATE INDEX `idx_collaboration_events_record_created_at` ON `collaboration_events` (`record_id`,`created_at`);--> statement-breakpoint
|
|
192
|
+
CREATE TABLE `collaboration_records` (
|
|
193
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
194
|
+
`kind` text NOT NULL,
|
|
195
|
+
`state` text NOT NULL,
|
|
196
|
+
`acceptance_state` text NOT NULL,
|
|
197
|
+
`title` text NOT NULL,
|
|
198
|
+
`summary` text,
|
|
199
|
+
`created_by_id` text NOT NULL,
|
|
200
|
+
`owner_id` text,
|
|
201
|
+
`next_move_owner_id` text,
|
|
202
|
+
`conversation_id` text,
|
|
203
|
+
`parent_id` text,
|
|
204
|
+
`priority` text,
|
|
205
|
+
`labels_json` text,
|
|
206
|
+
`relations_json` text,
|
|
207
|
+
`detail_json` text,
|
|
208
|
+
`created_at` integer NOT NULL,
|
|
209
|
+
`updated_at` integer NOT NULL,
|
|
210
|
+
FOREIGN KEY (`created_by_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
211
|
+
FOREIGN KEY (`owner_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE set null,
|
|
212
|
+
FOREIGN KEY (`next_move_owner_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE set null,
|
|
213
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE set null,
|
|
214
|
+
FOREIGN KEY (`parent_id`) REFERENCES `collaboration_records`(`id`) ON UPDATE no action ON DELETE set null
|
|
215
|
+
);
|
|
216
|
+
--> statement-breakpoint
|
|
217
|
+
CREATE INDEX `idx_collaboration_records_state` ON `collaboration_records` (`state`);--> statement-breakpoint
|
|
218
|
+
CREATE INDEX `idx_collaboration_records_updated_at` ON `collaboration_records` (`updated_at`);--> statement-breakpoint
|
|
219
|
+
CREATE INDEX `idx_collaboration_records_kind_state_updated_at` ON `collaboration_records` (`kind`,`state`,"updated_at" desc);--> statement-breakpoint
|
|
220
|
+
CREATE INDEX `idx_collaboration_records_parent_kind_state_updated_at` ON `collaboration_records` (`parent_id`,`kind`,`state`,"updated_at" desc);--> statement-breakpoint
|
|
221
|
+
CREATE INDEX `idx_collaboration_records_owner_kind_state_updated_at` ON `collaboration_records` (`owner_id`,`kind`,`state`,"updated_at" desc);--> statement-breakpoint
|
|
222
|
+
CREATE INDEX `idx_collaboration_records_next_move_owner_kind_state_updated_at` ON `collaboration_records` (`next_move_owner_id`,`kind`,`state`,"updated_at" desc);--> statement-breakpoint
|
|
223
|
+
CREATE TABLE `conversation_members` (
|
|
224
|
+
`conversation_id` text NOT NULL,
|
|
225
|
+
`actor_id` text NOT NULL,
|
|
226
|
+
`role` text,
|
|
227
|
+
PRIMARY KEY(`conversation_id`, `actor_id`),
|
|
228
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
229
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE cascade
|
|
230
|
+
);
|
|
231
|
+
--> statement-breakpoint
|
|
232
|
+
CREATE TABLE `conversation_read_cursors` (
|
|
233
|
+
`conversation_id` text NOT NULL,
|
|
234
|
+
`actor_id` text NOT NULL,
|
|
235
|
+
`reader_node_id` text,
|
|
236
|
+
`last_read_message_id` text,
|
|
237
|
+
`last_read_seq` integer,
|
|
238
|
+
`last_read_at` integer NOT NULL,
|
|
239
|
+
`updated_at` integer NOT NULL,
|
|
240
|
+
`metadata_json` text,
|
|
241
|
+
PRIMARY KEY(`conversation_id`, `actor_id`),
|
|
242
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
243
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
244
|
+
FOREIGN KEY (`reader_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE set null,
|
|
245
|
+
FOREIGN KEY (`last_read_message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE set null
|
|
246
|
+
);
|
|
247
|
+
--> statement-breakpoint
|
|
248
|
+
CREATE INDEX `idx_read_cursors_conversation_updated_at` ON `conversation_read_cursors` (`conversation_id`,"updated_at" desc);--> statement-breakpoint
|
|
249
|
+
CREATE TABLE `conversations` (
|
|
250
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
251
|
+
`kind` text NOT NULL,
|
|
252
|
+
`title` text NOT NULL,
|
|
253
|
+
`visibility` text NOT NULL,
|
|
254
|
+
`share_mode` text NOT NULL,
|
|
255
|
+
`authority_node_id` text NOT NULL,
|
|
256
|
+
`topic` text,
|
|
257
|
+
`parent_conversation_id` text,
|
|
258
|
+
`message_id` text,
|
|
259
|
+
`metadata_json` text,
|
|
260
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL,
|
|
261
|
+
FOREIGN KEY (`authority_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
262
|
+
FOREIGN KEY (`parent_conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE set null
|
|
263
|
+
);
|
|
264
|
+
--> statement-breakpoint
|
|
265
|
+
CREATE INDEX `idx_conversations_created_at` ON `conversations` ("created_at" desc);--> statement-breakpoint
|
|
266
|
+
CREATE TABLE `deliveries` (
|
|
267
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
268
|
+
`message_id` text,
|
|
269
|
+
`invocation_id` text,
|
|
270
|
+
`target_id` text NOT NULL,
|
|
271
|
+
`target_node_id` text,
|
|
272
|
+
`target_kind` text NOT NULL,
|
|
273
|
+
`transport` text NOT NULL,
|
|
274
|
+
`reason` text NOT NULL,
|
|
275
|
+
`policy` text NOT NULL,
|
|
276
|
+
`status` text NOT NULL,
|
|
277
|
+
`binding_id` text,
|
|
278
|
+
`lease_owner` text,
|
|
279
|
+
`lease_expires_at` integer,
|
|
280
|
+
`metadata_json` text,
|
|
281
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL,
|
|
282
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
283
|
+
FOREIGN KEY (`invocation_id`) REFERENCES `invocations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
284
|
+
FOREIGN KEY (`target_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE set null,
|
|
285
|
+
FOREIGN KEY (`binding_id`) REFERENCES `bindings`(`id`) ON UPDATE no action ON DELETE set null
|
|
286
|
+
);
|
|
287
|
+
--> statement-breakpoint
|
|
288
|
+
CREATE INDEX `idx_deliveries_status_transport` ON `deliveries` (`status`,`transport`);--> statement-breakpoint
|
|
289
|
+
CREATE INDEX `idx_deliveries_created_at` ON `deliveries` ("created_at" desc);--> statement-breakpoint
|
|
290
|
+
CREATE TABLE `delivery_attempts` (
|
|
291
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
292
|
+
`delivery_id` text NOT NULL,
|
|
293
|
+
`attempt` integer NOT NULL,
|
|
294
|
+
`status` text NOT NULL,
|
|
295
|
+
`error` text,
|
|
296
|
+
`external_ref` text,
|
|
297
|
+
`metadata_json` text,
|
|
298
|
+
`created_at` integer NOT NULL,
|
|
299
|
+
FOREIGN KEY (`delivery_id`) REFERENCES `deliveries`(`id`) ON UPDATE no action ON DELETE cascade
|
|
300
|
+
);
|
|
301
|
+
--> statement-breakpoint
|
|
302
|
+
CREATE INDEX `idx_delivery_attempts_created_at` ON `delivery_attempts` ("created_at" desc);--> statement-breakpoint
|
|
303
|
+
CREATE TABLE `durable_actions` (
|
|
304
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
305
|
+
`kind` text NOT NULL,
|
|
306
|
+
`subject_id` text NOT NULL,
|
|
307
|
+
`authority_cell_id` text NOT NULL,
|
|
308
|
+
`state` text NOT NULL,
|
|
309
|
+
`idempotency_key` text,
|
|
310
|
+
`lease_owner` text,
|
|
311
|
+
`lease_generation` integer DEFAULT 0 NOT NULL,
|
|
312
|
+
`lease_expires_at` integer,
|
|
313
|
+
`metadata_json` text,
|
|
314
|
+
`created_at` integer NOT NULL,
|
|
315
|
+
`updated_at` integer NOT NULL
|
|
316
|
+
);
|
|
317
|
+
--> statement-breakpoint
|
|
318
|
+
CREATE UNIQUE INDEX `idx_durable_actions_idempotency_key` ON `durable_actions` (`authority_cell_id`,`kind`,`idempotency_key`) WHERE idempotency_key IS NOT NULL;--> statement-breakpoint
|
|
319
|
+
CREATE INDEX `idx_durable_actions_authority_state_lease` ON `durable_actions` (`authority_cell_id`,`state`,`lease_expires_at`);--> statement-breakpoint
|
|
320
|
+
CREATE INDEX `idx_durable_actions_subject` ON `durable_actions` (`kind`,`subject_id`);--> statement-breakpoint
|
|
321
|
+
-- hand-edited: drizzle-kit 0.31 comma-splits sql`` index expressions (see
|
|
322
|
+
-- DURABLE_ACTIONS_DUE_AT_INDEX_SQL in drizzle-schema.ts); this is the correct
|
|
323
|
+
-- form of the statement it mangled. The parity test pins it against the raw schema.
|
|
324
|
+
CREATE INDEX `idx_durable_actions_kind_due_at_updated_at` ON `durable_actions` (`kind`,COALESCE(CAST(json_extract(metadata_json, '$.dueAt') AS REAL), CAST(json_extract(metadata_json, '$.due_at') AS REAL)),`updated_at`);--> statement-breakpoint
|
|
325
|
+
CREATE TABLE `durable_attempts` (
|
|
326
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
327
|
+
`action_id` text NOT NULL,
|
|
328
|
+
`attempt` integer NOT NULL,
|
|
329
|
+
`state` text NOT NULL,
|
|
330
|
+
`lease_generation` integer NOT NULL,
|
|
331
|
+
`error` text,
|
|
332
|
+
`started_at` integer,
|
|
333
|
+
`completed_at` integer,
|
|
334
|
+
`metadata_json` text,
|
|
335
|
+
FOREIGN KEY (`action_id`) REFERENCES `durable_actions`(`id`) ON UPDATE no action ON DELETE cascade
|
|
336
|
+
);
|
|
337
|
+
--> statement-breakpoint
|
|
338
|
+
CREATE INDEX `idx_durable_attempts_action_attempt` ON `durable_attempts` (`action_id`,`attempt`);--> statement-breakpoint
|
|
339
|
+
CREATE UNIQUE INDEX `durable_attempts_action_id_attempt_unique` ON `durable_attempts` (`action_id`,`attempt`);--> statement-breakpoint
|
|
340
|
+
CREATE TABLE `durable_checkpoints` (
|
|
341
|
+
`action_id` text NOT NULL,
|
|
342
|
+
`name` text NOT NULL,
|
|
343
|
+
`payload_json` text,
|
|
344
|
+
`owner_attempt_id` text,
|
|
345
|
+
`created_at` integer NOT NULL,
|
|
346
|
+
PRIMARY KEY(`action_id`, `name`),
|
|
347
|
+
FOREIGN KEY (`action_id`) REFERENCES `durable_actions`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
348
|
+
FOREIGN KEY (`owner_attempt_id`) REFERENCES `durable_attempts`(`id`) ON UPDATE no action ON DELETE set null
|
|
349
|
+
);
|
|
350
|
+
--> statement-breakpoint
|
|
351
|
+
CREATE TABLE `durable_signals` (
|
|
352
|
+
`action_id` text NOT NULL,
|
|
353
|
+
`name` text NOT NULL,
|
|
354
|
+
`payload_json` text,
|
|
355
|
+
`emitted_at` integer NOT NULL,
|
|
356
|
+
PRIMARY KEY(`action_id`, `name`),
|
|
357
|
+
FOREIGN KEY (`action_id`) REFERENCES `durable_actions`(`id`) ON UPDATE no action ON DELETE cascade
|
|
358
|
+
);
|
|
359
|
+
--> statement-breakpoint
|
|
360
|
+
CREATE TABLE `events` (
|
|
361
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
362
|
+
`kind` text NOT NULL,
|
|
363
|
+
`actor_id` text NOT NULL,
|
|
364
|
+
`node_id` text,
|
|
365
|
+
`ts` integer NOT NULL,
|
|
366
|
+
`payload_json` text NOT NULL
|
|
367
|
+
);
|
|
368
|
+
--> statement-breakpoint
|
|
369
|
+
CREATE INDEX `idx_events_kind_ts` ON `events` (`kind`,`ts`);--> statement-breakpoint
|
|
370
|
+
CREATE TABLE `flights` (
|
|
371
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
372
|
+
`invocation_id` text NOT NULL,
|
|
373
|
+
`requester_id` text NOT NULL,
|
|
374
|
+
`target_agent_id` text NOT NULL,
|
|
375
|
+
`state` text NOT NULL,
|
|
376
|
+
`summary` text,
|
|
377
|
+
`output` text,
|
|
378
|
+
`error` text,
|
|
379
|
+
`labels_json` text,
|
|
380
|
+
`metadata_json` text,
|
|
381
|
+
`started_at` integer,
|
|
382
|
+
`completed_at` integer,
|
|
383
|
+
FOREIGN KEY (`invocation_id`) REFERENCES `invocations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
384
|
+
FOREIGN KEY (`requester_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
385
|
+
FOREIGN KEY (`target_agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE restrict
|
|
386
|
+
);
|
|
387
|
+
--> statement-breakpoint
|
|
388
|
+
CREATE INDEX `idx_flights_target_state` ON `flights` (`target_agent_id`,`state`);--> statement-breakpoint
|
|
389
|
+
CREATE INDEX `idx_flights_invocation_id` ON `flights` (`invocation_id`);--> statement-breakpoint
|
|
390
|
+
CREATE TABLE `invocations` (
|
|
391
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
392
|
+
`requester_id` text NOT NULL,
|
|
393
|
+
`requester_node_id` text NOT NULL,
|
|
394
|
+
`target_agent_id` text NOT NULL,
|
|
395
|
+
`target_node_id` text,
|
|
396
|
+
`action` text NOT NULL,
|
|
397
|
+
`task` text NOT NULL,
|
|
398
|
+
`collaboration_record_id` text,
|
|
399
|
+
`conversation_id` text,
|
|
400
|
+
`message_id` text,
|
|
401
|
+
`context_json` text,
|
|
402
|
+
`execution_json` text,
|
|
403
|
+
`ensure_awake` integer DEFAULT 1 NOT NULL,
|
|
404
|
+
`stream` integer DEFAULT 1 NOT NULL,
|
|
405
|
+
`timeout_ms` integer,
|
|
406
|
+
`labels_json` text,
|
|
407
|
+
`metadata_json` text,
|
|
408
|
+
`created_at` integer NOT NULL,
|
|
409
|
+
FOREIGN KEY (`requester_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
410
|
+
FOREIGN KEY (`requester_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
411
|
+
FOREIGN KEY (`target_agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
412
|
+
FOREIGN KEY (`target_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE set null,
|
|
413
|
+
FOREIGN KEY (`collaboration_record_id`) REFERENCES `collaboration_records`(`id`) ON UPDATE no action ON DELETE set null,
|
|
414
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE set null,
|
|
415
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE set null
|
|
416
|
+
);
|
|
417
|
+
--> statement-breakpoint
|
|
418
|
+
CREATE INDEX `idx_invocations_target_created_at` ON `invocations` (`target_agent_id`,`created_at`);--> statement-breakpoint
|
|
419
|
+
CREATE INDEX `idx_invocations_requester_created_at` ON `invocations` (`requester_id`,"created_at" desc);--> statement-breakpoint
|
|
420
|
+
CREATE TABLE `message_attachments` (
|
|
421
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
422
|
+
`message_id` text NOT NULL,
|
|
423
|
+
`media_type` text NOT NULL,
|
|
424
|
+
`file_name` text,
|
|
425
|
+
`blob_key` text,
|
|
426
|
+
`url` text,
|
|
427
|
+
`metadata_json` text,
|
|
428
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade
|
|
429
|
+
);
|
|
430
|
+
--> statement-breakpoint
|
|
431
|
+
CREATE TABLE `message_mentions` (
|
|
432
|
+
`message_id` text NOT NULL,
|
|
433
|
+
`actor_id` text NOT NULL,
|
|
434
|
+
`label` text,
|
|
435
|
+
PRIMARY KEY(`message_id`, `actor_id`),
|
|
436
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
437
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE cascade
|
|
438
|
+
);
|
|
439
|
+
--> statement-breakpoint
|
|
440
|
+
CREATE TABLE `messages` (
|
|
441
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
442
|
+
`conversation_id` text NOT NULL,
|
|
443
|
+
`actor_id` text NOT NULL,
|
|
444
|
+
`origin_node_id` text NOT NULL,
|
|
445
|
+
`class` text NOT NULL,
|
|
446
|
+
`body` text NOT NULL,
|
|
447
|
+
`reply_to_message_id` text,
|
|
448
|
+
`thread_conversation_id` text,
|
|
449
|
+
`speech_json` text,
|
|
450
|
+
`audience_json` text,
|
|
451
|
+
`visibility` text NOT NULL,
|
|
452
|
+
`policy` text NOT NULL,
|
|
453
|
+
`metadata_json` text,
|
|
454
|
+
`created_at` integer NOT NULL,
|
|
455
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
456
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
457
|
+
FOREIGN KEY (`origin_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
458
|
+
FOREIGN KEY (`reply_to_message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE set null,
|
|
459
|
+
FOREIGN KEY (`thread_conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE set null
|
|
460
|
+
);
|
|
461
|
+
--> statement-breakpoint
|
|
462
|
+
CREATE INDEX `idx_messages_conversation_created_at` ON `messages` (`conversation_id`,`created_at`);--> statement-breakpoint
|
|
463
|
+
CREATE INDEX `idx_messages_created_at` ON `messages` ("created_at" desc);--> statement-breakpoint
|
|
464
|
+
CREATE INDEX `idx_messages_actor_created_at` ON `messages` (`actor_id`,"created_at" desc);--> statement-breakpoint
|
|
465
|
+
CREATE TABLE `mobile_push_registrations` (
|
|
466
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
467
|
+
`device_id` text NOT NULL,
|
|
468
|
+
`platform` text NOT NULL,
|
|
469
|
+
`app_bundle_id` text NOT NULL,
|
|
470
|
+
`apns_environment` text NOT NULL,
|
|
471
|
+
`push_token` text NOT NULL,
|
|
472
|
+
`authorization_status` text NOT NULL,
|
|
473
|
+
`app_version` text,
|
|
474
|
+
`build_number` text,
|
|
475
|
+
`device_model` text,
|
|
476
|
+
`system_version` text,
|
|
477
|
+
`created_at` integer NOT NULL,
|
|
478
|
+
`updated_at` integer NOT NULL
|
|
479
|
+
);
|
|
480
|
+
--> statement-breakpoint
|
|
481
|
+
CREATE UNIQUE INDEX `idx_mobile_push_registrations_device_bundle_env` ON `mobile_push_registrations` (`device_id`,`platform`,`app_bundle_id`,`apns_environment`);--> statement-breakpoint
|
|
482
|
+
CREATE UNIQUE INDEX `idx_mobile_push_registrations_push_token` ON `mobile_push_registrations` (`push_token`);--> statement-breakpoint
|
|
483
|
+
CREATE INDEX `idx_mobile_push_registrations_device_updated_at` ON `mobile_push_registrations` (`device_id`,"updated_at" desc);--> statement-breakpoint
|
|
484
|
+
CREATE TABLE `nodes` (
|
|
485
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
486
|
+
`mesh_id` text NOT NULL,
|
|
487
|
+
`name` text NOT NULL,
|
|
488
|
+
`host_name` text,
|
|
489
|
+
`advertise_scope` text NOT NULL,
|
|
490
|
+
`broker_url` text,
|
|
491
|
+
`tailnet_name` text,
|
|
492
|
+
`capabilities_json` text,
|
|
493
|
+
`labels_json` text,
|
|
494
|
+
`metadata_json` text,
|
|
495
|
+
`last_seen_at` integer,
|
|
496
|
+
`registered_at` integer NOT NULL
|
|
497
|
+
);
|
|
498
|
+
--> statement-breakpoint
|
|
499
|
+
CREATE INDEX `idx_nodes_mesh_id` ON `nodes` (`mesh_id`);--> statement-breakpoint
|
|
500
|
+
CREATE TABLE `runtime_session_aliases` (
|
|
501
|
+
`alias` text NOT NULL,
|
|
502
|
+
`session_id` text NOT NULL,
|
|
503
|
+
`alias_kind` text NOT NULL,
|
|
504
|
+
`agent_id` text NOT NULL,
|
|
505
|
+
`endpoint_id` text NOT NULL,
|
|
506
|
+
`node_id` text NOT NULL,
|
|
507
|
+
`harness` text NOT NULL,
|
|
508
|
+
`transport` text NOT NULL,
|
|
509
|
+
`first_seen_at` integer NOT NULL,
|
|
510
|
+
`last_seen_at` integer NOT NULL,
|
|
511
|
+
`expires_at` integer,
|
|
512
|
+
PRIMARY KEY(`alias`, `session_id`),
|
|
513
|
+
FOREIGN KEY (`session_id`) REFERENCES `runtime_sessions`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
514
|
+
FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
515
|
+
FOREIGN KEY (`endpoint_id`) REFERENCES `agent_endpoints`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
516
|
+
FOREIGN KEY (`node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict
|
|
517
|
+
);
|
|
518
|
+
--> statement-breakpoint
|
|
519
|
+
CREATE INDEX `idx_runtime_session_aliases_alias` ON `runtime_session_aliases` (`alias`,"last_seen_at" desc);--> statement-breakpoint
|
|
520
|
+
CREATE INDEX `idx_runtime_session_aliases_session` ON `runtime_session_aliases` (`session_id`);--> statement-breakpoint
|
|
521
|
+
CREATE INDEX `idx_runtime_session_aliases_expires` ON `runtime_session_aliases` (`expires_at`) WHERE expires_at IS NOT NULL;--> statement-breakpoint
|
|
522
|
+
CREATE TABLE `runtime_sessions` (
|
|
523
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
524
|
+
`agent_id` text NOT NULL,
|
|
525
|
+
`endpoint_id` text NOT NULL,
|
|
526
|
+
`node_id` text NOT NULL,
|
|
527
|
+
`harness` text NOT NULL,
|
|
528
|
+
`transport` text NOT NULL,
|
|
529
|
+
`state` text NOT NULL,
|
|
530
|
+
`primary_alias` text NOT NULL,
|
|
531
|
+
`external_session_id` text,
|
|
532
|
+
`cwd` text,
|
|
533
|
+
`project_root` text,
|
|
534
|
+
`started_at` integer,
|
|
535
|
+
`last_seen_at` integer NOT NULL,
|
|
536
|
+
`ended_at` integer,
|
|
537
|
+
`expires_at` integer,
|
|
538
|
+
`metadata_json` text,
|
|
539
|
+
`created_at` integer DEFAULT (CAST(strftime('%s','now') AS INTEGER) * 1000) NOT NULL,
|
|
540
|
+
`updated_at` integer NOT NULL,
|
|
541
|
+
FOREIGN KEY (`agent_id`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
542
|
+
FOREIGN KEY (`endpoint_id`) REFERENCES `agent_endpoints`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
543
|
+
FOREIGN KEY (`node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict
|
|
544
|
+
);
|
|
545
|
+
--> statement-breakpoint
|
|
546
|
+
CREATE INDEX `idx_runtime_sessions_agent_last_seen` ON `runtime_sessions` (`agent_id`,"last_seen_at" desc);--> statement-breakpoint
|
|
547
|
+
CREATE INDEX `idx_runtime_sessions_endpoint_last_seen` ON `runtime_sessions` (`endpoint_id`,"last_seen_at" desc);--> statement-breakpoint
|
|
548
|
+
CREATE INDEX `idx_runtime_sessions_external` ON `runtime_sessions` (`external_session_id`);--> statement-breakpoint
|
|
549
|
+
CREATE INDEX `idx_runtime_sessions_expires` ON `runtime_sessions` (`expires_at`) WHERE expires_at IS NOT NULL;--> statement-breakpoint
|
|
550
|
+
CREATE TABLE `scout_dispatches` (
|
|
551
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
552
|
+
`kind` text NOT NULL,
|
|
553
|
+
`asked_label` text NOT NULL,
|
|
554
|
+
`detail` text NOT NULL,
|
|
555
|
+
`invocation_id` text,
|
|
556
|
+
`conversation_id` text,
|
|
557
|
+
`requester_id` text,
|
|
558
|
+
`dispatcher_node_id` text NOT NULL,
|
|
559
|
+
`dispatched_at` integer NOT NULL,
|
|
560
|
+
`payload_json` text NOT NULL
|
|
561
|
+
);
|
|
562
|
+
--> statement-breakpoint
|
|
563
|
+
CREATE INDEX `idx_scout_dispatches_dispatched_at` ON `scout_dispatches` ("dispatched_at" desc);--> statement-breakpoint
|
|
564
|
+
CREATE INDEX `idx_scout_dispatches_conversation_ts` ON `scout_dispatches` (`conversation_id`,"dispatched_at" desc);--> statement-breakpoint
|
|
565
|
+
CREATE TABLE `thread_cursors` (
|
|
566
|
+
`conversation_id` text NOT NULL,
|
|
567
|
+
`authority_node_id` text NOT NULL,
|
|
568
|
+
`last_applied_seq` integer NOT NULL,
|
|
569
|
+
`updated_at` integer NOT NULL,
|
|
570
|
+
PRIMARY KEY(`conversation_id`, `authority_node_id`),
|
|
571
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
572
|
+
FOREIGN KEY (`authority_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict
|
|
573
|
+
);
|
|
574
|
+
--> statement-breakpoint
|
|
575
|
+
CREATE TABLE `thread_events` (
|
|
576
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
577
|
+
`conversation_id` text NOT NULL,
|
|
578
|
+
`authority_node_id` text NOT NULL,
|
|
579
|
+
`seq` integer NOT NULL,
|
|
580
|
+
`kind` text NOT NULL,
|
|
581
|
+
`actor_id` text,
|
|
582
|
+
`ts` integer NOT NULL,
|
|
583
|
+
`payload_json` text NOT NULL,
|
|
584
|
+
`notification_json` text,
|
|
585
|
+
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
586
|
+
FOREIGN KEY (`authority_node_id`) REFERENCES `nodes`(`id`) ON UPDATE no action ON DELETE restrict,
|
|
587
|
+
FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON UPDATE no action ON DELETE set null
|
|
588
|
+
);
|
|
589
|
+
--> statement-breakpoint
|
|
590
|
+
CREATE INDEX `idx_thread_events_conversation_seq` ON `thread_events` (`conversation_id`,"seq" desc);--> statement-breakpoint
|
|
591
|
+
CREATE INDEX `idx_thread_events_conversation_ts` ON `thread_events` (`conversation_id`,"ts" desc);--> statement-breakpoint
|
|
592
|
+
CREATE UNIQUE INDEX `thread_events_conversation_id_seq_unique` ON `thread_events` (`conversation_id`,`seq`);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ALTER TABLE `invocations` ADD `flight_id` text;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE `invocations` ADD `state` text;--> statement-breakpoint
|
|
3
|
+
ALTER TABLE `invocations` ADD `summary` text;--> statement-breakpoint
|
|
4
|
+
ALTER TABLE `invocations` ADD `output` text;--> statement-breakpoint
|
|
5
|
+
ALTER TABLE `invocations` ADD `error` text;--> statement-breakpoint
|
|
6
|
+
ALTER TABLE `invocations` ADD `started_at` integer;--> statement-breakpoint
|
|
7
|
+
ALTER TABLE `invocations` ADD `completed_at` integer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
ALTER TABLE `invocations` ADD `flight_metadata_json` text;--> statement-breakpoint
|
|
2
|
+
UPDATE invocations AS inv
|
|
3
|
+
SET
|
|
4
|
+
flight_id = latest.id,
|
|
5
|
+
state = latest.state,
|
|
6
|
+
summary = latest.summary,
|
|
7
|
+
output = latest.output,
|
|
8
|
+
error = latest.error,
|
|
9
|
+
started_at = latest.started_at,
|
|
10
|
+
completed_at = latest.completed_at,
|
|
11
|
+
flight_metadata_json = latest.metadata_json
|
|
12
|
+
FROM (
|
|
13
|
+
SELECT invocation_id, id, state, summary, output, error, started_at, completed_at, metadata_json,
|
|
14
|
+
ROW_NUMBER() OVER (
|
|
15
|
+
PARTITION BY invocation_id
|
|
16
|
+
ORDER BY COALESCE(completed_at, started_at, 0) DESC, rowid DESC
|
|
17
|
+
) AS rn
|
|
18
|
+
FROM flights
|
|
19
|
+
) AS latest
|
|
20
|
+
WHERE latest.invocation_id = inv.id
|
|
21
|
+
AND latest.rn = 1;
|