@cat-factory/node-server 0.6.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.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/dist/config.d.ts +3 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +297 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/container.d.ts +88 -0
  7. package/dist/container.d.ts.map +1 -0
  8. package/dist/container.js +937 -0
  9. package/dist/container.js.map +1 -0
  10. package/dist/db/client.d.ts +13 -0
  11. package/dist/db/client.d.ts.map +1 -0
  12. package/dist/db/client.js +21 -0
  13. package/dist/db/client.js.map +1 -0
  14. package/dist/db/migrate.d.ts +12 -0
  15. package/dist/db/migrate.d.ts.map +1 -0
  16. package/dist/db/migrate.js +40 -0
  17. package/dist/db/migrate.js.map +1 -0
  18. package/dist/db/schema.d.ts +7858 -0
  19. package/dist/db/schema.d.ts.map +1 -0
  20. package/dist/db/schema.js +928 -0
  21. package/dist/db/schema.js.map +1 -0
  22. package/dist/environments.d.ts +11 -0
  23. package/dist/environments.d.ts.map +1 -0
  24. package/dist/environments.js +31 -0
  25. package/dist/environments.js.map +1 -0
  26. package/dist/execution/bootstrapRunner.d.ts +27 -0
  27. package/dist/execution/bootstrapRunner.d.ts.map +1 -0
  28. package/dist/execution/bootstrapRunner.js +79 -0
  29. package/dist/execution/bootstrapRunner.js.map +1 -0
  30. package/dist/execution/config.d.ts +37 -0
  31. package/dist/execution/config.d.ts.map +1 -0
  32. package/dist/execution/config.js +86 -0
  33. package/dist/execution/config.js.map +1 -0
  34. package/dist/execution/drive.d.ts +6 -0
  35. package/dist/execution/drive.d.ts.map +1 -0
  36. package/dist/execution/drive.js +13 -0
  37. package/dist/execution/drive.js.map +1 -0
  38. package/dist/execution/pgBossRunner.d.ts +82 -0
  39. package/dist/execution/pgBossRunner.d.ts.map +1 -0
  40. package/dist/execution/pgBossRunner.js +163 -0
  41. package/dist/execution/pgBossRunner.js.map +1 -0
  42. package/dist/gateways.d.ts +4 -0
  43. package/dist/gateways.d.ts.map +1 -0
  44. package/dist/gateways.js +91 -0
  45. package/dist/gateways.js.map +1 -0
  46. package/dist/index.d.ts +13 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +22 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/main.d.ts +2 -0
  51. package/dist/main.d.ts.map +1 -0
  52. package/dist/main.js +9 -0
  53. package/dist/main.js.map +1 -0
  54. package/dist/modelProvider.d.ts +6 -0
  55. package/dist/modelProvider.d.ts.map +1 -0
  56. package/dist/modelProvider.js +72 -0
  57. package/dist/modelProvider.js.map +1 -0
  58. package/dist/realtime.d.ts +62 -0
  59. package/dist/realtime.d.ts.map +1 -0
  60. package/dist/realtime.js +171 -0
  61. package/dist/realtime.js.map +1 -0
  62. package/dist/recurring.d.ts +11 -0
  63. package/dist/recurring.d.ts.map +1 -0
  64. package/dist/recurring.js +33 -0
  65. package/dist/recurring.js.map +1 -0
  66. package/dist/repositories/bootstrap.d.ts +25 -0
  67. package/dist/repositories/bootstrap.d.ts.map +1 -0
  68. package/dist/repositories/bootstrap.js +280 -0
  69. package/dist/repositories/bootstrap.js.map +1 -0
  70. package/dist/repositories/containerExecution.d.ts +33 -0
  71. package/dist/repositories/containerExecution.d.ts.map +1 -0
  72. package/dist/repositories/containerExecution.js +199 -0
  73. package/dist/repositories/containerExecution.js.map +1 -0
  74. package/dist/repositories/documents.d.ts +31 -0
  75. package/dist/repositories/documents.d.ts.map +1 -0
  76. package/dist/repositories/documents.js +176 -0
  77. package/dist/repositories/documents.js.map +1 -0
  78. package/dist/repositories/drizzle.d.ts +105 -0
  79. package/dist/repositories/drizzle.d.ts.map +1 -0
  80. package/dist/repositories/drizzle.js +1872 -0
  81. package/dist/repositories/drizzle.js.map +1 -0
  82. package/dist/repositories/environments.d.ts +23 -0
  83. package/dist/repositories/environments.d.ts.map +1 -0
  84. package/dist/repositories/environments.js +162 -0
  85. package/dist/repositories/environments.js.map +1 -0
  86. package/dist/repositories/fragments.d.ts +23 -0
  87. package/dist/repositories/fragments.d.ts.map +1 -0
  88. package/dist/repositories/fragments.js +190 -0
  89. package/dist/repositories/fragments.js.map +1 -0
  90. package/dist/repositories/github.d.ts +53 -0
  91. package/dist/repositories/github.d.ts.map +1 -0
  92. package/dist/repositories/github.js +441 -0
  93. package/dist/repositories/github.js.map +1 -0
  94. package/dist/repositories/localModelEndpoint.d.ts +12 -0
  95. package/dist/repositories/localModelEndpoint.d.ts.map +1 -0
  96. package/dist/repositories/localModelEndpoint.js +75 -0
  97. package/dist/repositories/localModelEndpoint.js.map +1 -0
  98. package/dist/repositories/notifications.d.ts +11 -0
  99. package/dist/repositories/notifications.d.ts.map +1 -0
  100. package/dist/repositories/notifications.js +88 -0
  101. package/dist/repositories/notifications.js.map +1 -0
  102. package/dist/repositories/personalSubscription.d.ts +22 -0
  103. package/dist/repositories/personalSubscription.d.ts.map +1 -0
  104. package/dist/repositories/personalSubscription.js +159 -0
  105. package/dist/repositories/personalSubscription.js.map +1 -0
  106. package/dist/repositories/providerApiKey.d.ts +18 -0
  107. package/dist/repositories/providerApiKey.d.ts.map +1 -0
  108. package/dist/repositories/providerApiKey.js +111 -0
  109. package/dist/repositories/providerApiKey.js.map +1 -0
  110. package/dist/repositories/providerSubscription.d.ts +16 -0
  111. package/dist/repositories/providerSubscription.d.ts.map +1 -0
  112. package/dist/repositories/providerSubscription.js +88 -0
  113. package/dist/repositories/providerSubscription.js.map +1 -0
  114. package/dist/repositories/slack.d.ts +23 -0
  115. package/dist/repositories/slack.d.ts.map +1 -0
  116. package/dist/repositories/slack.js +150 -0
  117. package/dist/repositories/slack.js.map +1 -0
  118. package/dist/repositories/tasks.d.ts +24 -0
  119. package/dist/repositories/tasks.d.ts.map +1 -0
  120. package/dist/repositories/tasks.js +194 -0
  121. package/dist/repositories/tasks.js.map +1 -0
  122. package/dist/retention.d.ts +38 -0
  123. package/dist/retention.d.ts.map +1 -0
  124. package/dist/retention.js +53 -0
  125. package/dist/retention.js.map +1 -0
  126. package/dist/runtime.d.ts +10 -0
  127. package/dist/runtime.d.ts.map +1 -0
  128. package/dist/runtime.js +13 -0
  129. package/dist/runtime.js.map +1 -0
  130. package/dist/server.d.ts +41 -0
  131. package/dist/server.d.ts.map +1 -0
  132. package/dist/server.js +138 -0
  133. package/dist/server.js.map +1 -0
  134. package/dist/tasks/JiraProvider.d.ts +27 -0
  135. package/dist/tasks/JiraProvider.d.ts.map +1 -0
  136. package/dist/tasks/JiraProvider.js +79 -0
  137. package/dist/tasks/JiraProvider.js.map +1 -0
  138. package/drizzle/20260622175812_flashy_maginty/migration.sql +689 -0
  139. package/drizzle/20260622175812_flashy_maginty/snapshot.json +8318 -0
  140. package/drizzle/20260623172634_loud_wallop/migration.sql +11 -0
  141. package/drizzle/20260623172634_loud_wallop/snapshot.json +8439 -0
  142. package/drizzle/20260623174706_acoustic_zemo/migration.sql +16 -0
  143. package/drizzle/20260623174706_acoustic_zemo/snapshot.json +8506 -0
  144. package/drizzle/20260623184400_silent_cardiac/migration.sql +24 -0
  145. package/drizzle/20260623184400_silent_cardiac/snapshot.json +8639 -0
  146. package/drizzle/20260623205323_quick_arclight/migration.sql +1 -0
  147. package/drizzle/20260623205323_quick_arclight/snapshot.json +8963 -0
  148. package/drizzle/20260623221910_black_zombie/migration.sql +22 -0
  149. package/drizzle/20260623221910_black_zombie/snapshot.json +9189 -0
  150. package/drizzle/20260624131343_far_lily_hollister/migration.sql +3 -0
  151. package/drizzle/20260624131343_far_lily_hollister/snapshot.json +9228 -0
  152. package/drizzle/20260624135452_tiny_norman_osborn/migration.sql +11 -0
  153. package/drizzle/20260624135452_tiny_norman_osborn/snapshot.json +9126 -0
  154. package/drizzle/20260624140138_wandering_avengers/migration.sql +1 -0
  155. package/drizzle/20260624140138_wandering_avengers/snapshot.json +9045 -0
  156. package/package.json +62 -0
@@ -0,0 +1,689 @@
1
+ CREATE TABLE "account_invitations" (
2
+ "id" text PRIMARY KEY,
3
+ "account_id" text NOT NULL,
4
+ "email" text NOT NULL,
5
+ "roles" text DEFAULT 'developer' NOT NULL,
6
+ "token_hash" text NOT NULL,
7
+ "invited_by" text NOT NULL,
8
+ "status" text DEFAULT 'pending' NOT NULL,
9
+ "expires_at" bigint NOT NULL,
10
+ "created_at" bigint NOT NULL
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "accounts" (
14
+ "id" text PRIMARY KEY,
15
+ "type" text NOT NULL,
16
+ "name" text NOT NULL,
17
+ "github_account_login" text,
18
+ "owner_user_id" text,
19
+ "created_at" bigint NOT NULL,
20
+ "default_cloud_provider" text
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE TABLE "agent_runs" (
24
+ "workspace_id" text,
25
+ "id" text,
26
+ "kind" text NOT NULL,
27
+ "block_id" text,
28
+ "status" text NOT NULL,
29
+ "detail" text DEFAULT '{}' NOT NULL,
30
+ "subtasks" text,
31
+ "error" text,
32
+ "failure" text,
33
+ "workflow_instance_id" text,
34
+ "created_at" bigint NOT NULL,
35
+ "updated_at" bigint NOT NULL,
36
+ "service_id" text,
37
+ CONSTRAINT "agent_runs_pkey" PRIMARY KEY("workspace_id","id")
38
+ );
39
+ --> statement-breakpoint
40
+ CREATE TABLE "blocks" (
41
+ "workspace_id" text,
42
+ "id" text,
43
+ "title" text NOT NULL,
44
+ "type" text NOT NULL,
45
+ "description" text DEFAULT '' NOT NULL,
46
+ "pos_x" double precision DEFAULT 0 NOT NULL,
47
+ "pos_y" double precision DEFAULT 0 NOT NULL,
48
+ "width" double precision,
49
+ "height" double precision,
50
+ "status" text NOT NULL,
51
+ "progress" double precision DEFAULT 0 NOT NULL,
52
+ "depends_on" text DEFAULT '[]' NOT NULL,
53
+ "execution_id" text,
54
+ "level" text DEFAULT 'frame' NOT NULL,
55
+ "parent_id" text,
56
+ "confidence" double precision,
57
+ "module_name" text,
58
+ "fragment_ids" text,
59
+ "service_fragment_ids" text,
60
+ "model_id" text,
61
+ "pull_request" text,
62
+ "merge_preset_id" text,
63
+ "pipeline_id" text,
64
+ "agent_config" text,
65
+ "test_compose_path" text,
66
+ "no_infra_dependencies" integer,
67
+ "cloud_provider" text,
68
+ "instance_size" text,
69
+ "service_id" text,
70
+ "created_by" text,
71
+ "responsible_product_user_id" text,
72
+ CONSTRAINT "blocks_pkey" PRIMARY KEY("workspace_id","id")
73
+ );
74
+ --> statement-breakpoint
75
+ CREATE TABLE "document_connections" (
76
+ "workspace_id" text,
77
+ "source" text,
78
+ "credentials" text NOT NULL,
79
+ "label" text DEFAULT '' NOT NULL,
80
+ "created_at" bigint NOT NULL,
81
+ "deleted_at" bigint,
82
+ CONSTRAINT "document_connections_pkey" PRIMARY KEY("workspace_id","source")
83
+ );
84
+ --> statement-breakpoint
85
+ CREATE TABLE "documents" (
86
+ "workspace_id" text,
87
+ "source" text,
88
+ "external_id" text,
89
+ "title" text NOT NULL,
90
+ "url" text NOT NULL,
91
+ "excerpt" text DEFAULT '' NOT NULL,
92
+ "body" text DEFAULT '' NOT NULL,
93
+ "linked_block_id" text,
94
+ "synced_at" bigint NOT NULL,
95
+ "deleted_at" bigint,
96
+ CONSTRAINT "documents_pkey" PRIMARY KEY("workspace_id","source","external_id")
97
+ );
98
+ --> statement-breakpoint
99
+ CREATE TABLE "email_connections" (
100
+ "account_id" text PRIMARY KEY,
101
+ "provider" text NOT NULL,
102
+ "from_address" text NOT NULL,
103
+ "api_key_cipher" text NOT NULL,
104
+ "created_at" bigint NOT NULL,
105
+ "updated_at" bigint NOT NULL,
106
+ "deleted_at" bigint
107
+ );
108
+ --> statement-breakpoint
109
+ CREATE TABLE "environment_connections" (
110
+ "workspace_id" text,
111
+ "provider_id" text,
112
+ "label" text NOT NULL,
113
+ "base_url" text NOT NULL,
114
+ "manifest_json" text NOT NULL,
115
+ "secrets_cipher" text NOT NULL,
116
+ "created_at" bigint NOT NULL,
117
+ "deleted_at" bigint,
118
+ CONSTRAINT "environment_connections_pkey" PRIMARY KEY("workspace_id","provider_id")
119
+ );
120
+ --> statement-breakpoint
121
+ CREATE TABLE "environments" (
122
+ "id" text PRIMARY KEY,
123
+ "workspace_id" text NOT NULL,
124
+ "block_id" text,
125
+ "execution_id" text,
126
+ "provider_id" text NOT NULL,
127
+ "external_id" text,
128
+ "url" text,
129
+ "status" text NOT NULL,
130
+ "access_cipher" text,
131
+ "provision_fields_cipher" text,
132
+ "created_at" bigint NOT NULL,
133
+ "expires_at" bigint,
134
+ "last_error" text,
135
+ "deleted_at" bigint
136
+ );
137
+ --> statement-breakpoint
138
+ CREATE TABLE "fragment_sources" (
139
+ "id" text PRIMARY KEY,
140
+ "owner_kind" text NOT NULL,
141
+ "owner_id" text NOT NULL,
142
+ "repo_owner" text NOT NULL,
143
+ "repo_name" text NOT NULL,
144
+ "git_ref" text DEFAULT 'HEAD' NOT NULL,
145
+ "dir_path" text DEFAULT '' NOT NULL,
146
+ "last_synced_sha" text,
147
+ "last_synced_at" bigint,
148
+ "created_at" bigint NOT NULL,
149
+ "deleted_at" bigint
150
+ );
151
+ --> statement-breakpoint
152
+ CREATE TABLE "github_branches" (
153
+ "workspace_id" text,
154
+ "repo_github_id" bigint,
155
+ "name" text,
156
+ "head_sha" text NOT NULL,
157
+ "protected" integer DEFAULT 0 NOT NULL,
158
+ "synced_at" bigint NOT NULL,
159
+ "deleted_at" bigint,
160
+ CONSTRAINT "github_branches_pkey" PRIMARY KEY("workspace_id","repo_github_id","name")
161
+ );
162
+ --> statement-breakpoint
163
+ CREATE TABLE "github_check_runs" (
164
+ "workspace_id" text,
165
+ "repo_github_id" bigint,
166
+ "github_id" bigint,
167
+ "head_sha" text NOT NULL,
168
+ "name" text NOT NULL,
169
+ "status" text NOT NULL,
170
+ "conclusion" text,
171
+ "synced_at" bigint NOT NULL,
172
+ CONSTRAINT "github_check_runs_pkey" PRIMARY KEY("workspace_id","repo_github_id","github_id")
173
+ );
174
+ --> statement-breakpoint
175
+ CREATE TABLE "github_commits" (
176
+ "workspace_id" text,
177
+ "repo_github_id" bigint,
178
+ "sha" text,
179
+ "message" text NOT NULL,
180
+ "author" text,
181
+ "authored_at" bigint,
182
+ "synced_at" bigint NOT NULL,
183
+ CONSTRAINT "github_commits_pkey" PRIMARY KEY("workspace_id","repo_github_id","sha")
184
+ );
185
+ --> statement-breakpoint
186
+ CREATE TABLE "github_installations" (
187
+ "installation_id" bigint PRIMARY KEY,
188
+ "workspace_id" text NOT NULL,
189
+ "account_id" text,
190
+ "account_login" text NOT NULL,
191
+ "target_type" text NOT NULL,
192
+ "app_id" text,
193
+ "cached_token" text,
194
+ "token_expires_at" bigint,
195
+ "created_at" bigint NOT NULL,
196
+ "deleted_at" bigint
197
+ );
198
+ --> statement-breakpoint
199
+ CREATE TABLE "github_issues" (
200
+ "workspace_id" text,
201
+ "repo_github_id" bigint,
202
+ "number" integer,
203
+ "github_id" bigint NOT NULL,
204
+ "title" text NOT NULL,
205
+ "state" text NOT NULL,
206
+ "author" text,
207
+ "labels" text DEFAULT '[]' NOT NULL,
208
+ "gh_updated_at" bigint,
209
+ "synced_at" bigint NOT NULL,
210
+ "deleted_at" bigint,
211
+ CONSTRAINT "github_issues_pkey" PRIMARY KEY("workspace_id","repo_github_id","number")
212
+ );
213
+ --> statement-breakpoint
214
+ CREATE TABLE "github_pull_requests" (
215
+ "workspace_id" text,
216
+ "repo_github_id" bigint,
217
+ "number" integer,
218
+ "github_id" bigint NOT NULL,
219
+ "title" text NOT NULL,
220
+ "state" text NOT NULL,
221
+ "head_ref" text,
222
+ "base_ref" text,
223
+ "head_sha" text,
224
+ "merged" integer DEFAULT 0 NOT NULL,
225
+ "author" text,
226
+ "gh_updated_at" bigint,
227
+ "synced_at" bigint NOT NULL,
228
+ "deleted_at" bigint,
229
+ CONSTRAINT "github_pull_requests_pkey" PRIMARY KEY("workspace_id","repo_github_id","number")
230
+ );
231
+ --> statement-breakpoint
232
+ CREATE TABLE "github_repos" (
233
+ "workspace_id" text,
234
+ "github_id" bigint,
235
+ "installation_id" bigint NOT NULL,
236
+ "owner" text NOT NULL,
237
+ "name" text NOT NULL,
238
+ "default_branch" text,
239
+ "private" integer DEFAULT 0 NOT NULL,
240
+ "block_id" text,
241
+ "is_monorepo" integer DEFAULT 0 NOT NULL,
242
+ "etag" text,
243
+ "synced_at" bigint NOT NULL,
244
+ "deleted_at" bigint,
245
+ CONSTRAINT "github_repos_pkey" PRIMARY KEY("workspace_id","github_id")
246
+ );
247
+ --> statement-breakpoint
248
+ CREATE TABLE "github_sync_cursors" (
249
+ "installation_id" bigint,
250
+ "repo_github_id" bigint,
251
+ "kind" text,
252
+ "etag" text,
253
+ "last_synced_at" bigint,
254
+ "since_iso" text,
255
+ CONSTRAINT "github_sync_cursors_pkey" PRIMARY KEY("installation_id","repo_github_id","kind")
256
+ );
257
+ --> statement-breakpoint
258
+ CREATE TABLE "llm_call_metrics" (
259
+ "id" text PRIMARY KEY,
260
+ "workspace_id" text NOT NULL,
261
+ "execution_id" text,
262
+ "agent_kind" text NOT NULL,
263
+ "provider" text NOT NULL,
264
+ "model" text NOT NULL,
265
+ "created_at" bigint NOT NULL,
266
+ "streaming" integer DEFAULT 0 NOT NULL,
267
+ "message_count" integer DEFAULT 0 NOT NULL,
268
+ "tool_count" integer DEFAULT 0 NOT NULL,
269
+ "request_max_tokens" integer,
270
+ "prompt_tokens" integer DEFAULT 0 NOT NULL,
271
+ "cached_prompt_tokens" integer DEFAULT 0 NOT NULL,
272
+ "completion_tokens" integer DEFAULT 0 NOT NULL,
273
+ "total_tokens" integer DEFAULT 0 NOT NULL,
274
+ "finish_reason" text,
275
+ "upstream_ms" integer DEFAULT 0 NOT NULL,
276
+ "overhead_ms" integer DEFAULT 0 NOT NULL,
277
+ "total_ms" integer DEFAULT 0 NOT NULL,
278
+ "ok" integer DEFAULT 1 NOT NULL,
279
+ "http_status" integer,
280
+ "error_message" text,
281
+ "prompt_text" text DEFAULT '' NOT NULL,
282
+ "prompt_prefix_count" integer DEFAULT 0 NOT NULL,
283
+ "prompt_hash" text DEFAULT '' NOT NULL,
284
+ "response_text" text DEFAULT '' NOT NULL
285
+ );
286
+ --> statement-breakpoint
287
+ CREATE TABLE "memberships" (
288
+ "account_id" text,
289
+ "user_id" text,
290
+ "roles" text DEFAULT 'developer' NOT NULL,
291
+ "created_at" bigint NOT NULL,
292
+ CONSTRAINT "memberships_pkey" PRIMARY KEY("account_id","user_id")
293
+ );
294
+ --> statement-breakpoint
295
+ CREATE TABLE "merge_threshold_presets" (
296
+ "workspace_id" text,
297
+ "id" text,
298
+ "name" text NOT NULL,
299
+ "max_complexity" double precision NOT NULL,
300
+ "max_risk" double precision NOT NULL,
301
+ "max_impact" double precision NOT NULL,
302
+ "ci_max_attempts" integer NOT NULL,
303
+ "max_requirement_iterations" integer DEFAULT 3 NOT NULL,
304
+ "max_requirement_concern_allowed" text DEFAULT 'none' NOT NULL,
305
+ "is_default" integer DEFAULT 0 NOT NULL,
306
+ "created_at" bigint NOT NULL,
307
+ CONSTRAINT "merge_threshold_presets_pkey" PRIMARY KEY("workspace_id","id")
308
+ );
309
+ --> statement-breakpoint
310
+ CREATE TABLE "notifications" (
311
+ "workspace_id" text,
312
+ "id" text,
313
+ "type" text NOT NULL,
314
+ "status" text NOT NULL,
315
+ "block_id" text,
316
+ "execution_id" text,
317
+ "title" text NOT NULL,
318
+ "body" text NOT NULL,
319
+ "payload" text,
320
+ "created_at" bigint NOT NULL,
321
+ "resolved_at" bigint,
322
+ CONSTRAINT "notifications_pkey" PRIMARY KEY("workspace_id","id")
323
+ );
324
+ --> statement-breakpoint
325
+ CREATE TABLE "personal_subscriptions" (
326
+ "id" text PRIMARY KEY,
327
+ "user_id" text NOT NULL,
328
+ "vendor" text NOT NULL,
329
+ "label" text NOT NULL,
330
+ "token_cipher" text NOT NULL,
331
+ "expires_at" bigint,
332
+ "created_at" bigint NOT NULL,
333
+ "updated_at" bigint NOT NULL,
334
+ "last_used_at" bigint,
335
+ "deleted_at" bigint
336
+ );
337
+ --> statement-breakpoint
338
+ CREATE TABLE "pipeline_schedule_runs" (
339
+ "workspace_id" text,
340
+ "id" text,
341
+ "schedule_id" text NOT NULL,
342
+ "execution_id" text,
343
+ "status" text NOT NULL,
344
+ "started_at" bigint NOT NULL,
345
+ "finished_at" bigint,
346
+ "outcome" text,
347
+ CONSTRAINT "pipeline_schedule_runs_pkey" PRIMARY KEY("workspace_id","id")
348
+ );
349
+ --> statement-breakpoint
350
+ CREATE TABLE "pipeline_schedules" (
351
+ "workspace_id" text,
352
+ "id" text,
353
+ "service_id" text,
354
+ "block_id" text NOT NULL,
355
+ "frame_id" text NOT NULL,
356
+ "pipeline_id" text NOT NULL,
357
+ "template" text NOT NULL,
358
+ "name" text NOT NULL,
359
+ "interval_hours" integer NOT NULL,
360
+ "weekdays" text DEFAULT '[]' NOT NULL,
361
+ "window_start_hour" integer,
362
+ "window_end_hour" integer,
363
+ "timezone" text DEFAULT 'UTC' NOT NULL,
364
+ "enabled" integer DEFAULT 1 NOT NULL,
365
+ "last_run_at" bigint,
366
+ "next_run_at" bigint NOT NULL,
367
+ "created_at" bigint NOT NULL,
368
+ CONSTRAINT "pipeline_schedules_pkey" PRIMARY KEY("workspace_id","id")
369
+ );
370
+ --> statement-breakpoint
371
+ CREATE TABLE "pipelines" (
372
+ "workspace_id" text,
373
+ "id" text,
374
+ "name" text NOT NULL,
375
+ "agent_kinds" text DEFAULT '[]' NOT NULL,
376
+ "gates" text,
377
+ "thresholds" text,
378
+ "enabled" text,
379
+ "builtin" integer,
380
+ "seq" serial,
381
+ CONSTRAINT "pipelines_pkey" PRIMARY KEY("workspace_id","id")
382
+ );
383
+ --> statement-breakpoint
384
+ CREATE TABLE "prompt_fragments" (
385
+ "fragment_id" text,
386
+ "owner_kind" text,
387
+ "owner_id" text,
388
+ "version" text NOT NULL,
389
+ "title" text NOT NULL,
390
+ "category" text,
391
+ "summary" text NOT NULL,
392
+ "body" text NOT NULL,
393
+ "applies_to" text,
394
+ "tags" text,
395
+ "source_id" text,
396
+ "source_path" text,
397
+ "source_sha" text,
398
+ "created_at" bigint NOT NULL,
399
+ "updated_at" bigint NOT NULL,
400
+ "deleted_at" bigint,
401
+ CONSTRAINT "prompt_fragments_pkey" PRIMARY KEY("owner_kind","owner_id","fragment_id")
402
+ );
403
+ --> statement-breakpoint
404
+ CREATE TABLE "provider_api_keys" (
405
+ "id" text PRIMARY KEY,
406
+ "scope" text NOT NULL,
407
+ "scope_id" text NOT NULL,
408
+ "provider" text NOT NULL,
409
+ "label" text NOT NULL,
410
+ "key_cipher" text NOT NULL,
411
+ "created_at" bigint NOT NULL,
412
+ "last_used_at" bigint,
413
+ "window_started_at" bigint,
414
+ "input_tokens" bigint DEFAULT 0 NOT NULL,
415
+ "output_tokens" bigint DEFAULT 0 NOT NULL,
416
+ "request_count" integer DEFAULT 0 NOT NULL,
417
+ "deleted_at" bigint
418
+ );
419
+ --> statement-breakpoint
420
+ CREATE TABLE "provider_subscription_tokens" (
421
+ "id" text PRIMARY KEY,
422
+ "workspace_id" text NOT NULL,
423
+ "vendor" text NOT NULL,
424
+ "label" text NOT NULL,
425
+ "token_cipher" text NOT NULL,
426
+ "created_at" bigint NOT NULL,
427
+ "last_used_at" bigint,
428
+ "window_started_at" bigint,
429
+ "input_tokens" bigint DEFAULT 0 NOT NULL,
430
+ "output_tokens" bigint DEFAULT 0 NOT NULL,
431
+ "request_count" integer DEFAULT 0 NOT NULL,
432
+ "deleted_at" bigint
433
+ );
434
+ --> statement-breakpoint
435
+ CREATE TABLE "reference_architectures" (
436
+ "id" text PRIMARY KEY,
437
+ "workspace_id" text NOT NULL,
438
+ "name" text NOT NULL,
439
+ "description" text DEFAULT '' NOT NULL,
440
+ "repo_owner" text NOT NULL,
441
+ "repo_name" text NOT NULL,
442
+ "default_instructions" text DEFAULT '' NOT NULL,
443
+ "created_at" bigint NOT NULL,
444
+ "updated_at" bigint NOT NULL,
445
+ "deleted_at" bigint
446
+ );
447
+ --> statement-breakpoint
448
+ CREATE TABLE "repo_blueprints" (
449
+ "id" text PRIMARY KEY,
450
+ "workspace_id" text NOT NULL,
451
+ "repo_owner" text NOT NULL,
452
+ "repo_name" text NOT NULL,
453
+ "source" text NOT NULL,
454
+ "service_json" text NOT NULL,
455
+ "created_at" bigint NOT NULL,
456
+ "updated_at" bigint NOT NULL
457
+ );
458
+ --> statement-breakpoint
459
+ CREATE TABLE "requirement_reviews" (
460
+ "workspace_id" text,
461
+ "id" text,
462
+ "block_id" text NOT NULL,
463
+ "status" text NOT NULL,
464
+ "items" text DEFAULT '[]' NOT NULL,
465
+ "model" text,
466
+ "incorporated_requirements" text,
467
+ "iteration" integer DEFAULT 1 NOT NULL,
468
+ "max_iterations" integer DEFAULT 1 NOT NULL,
469
+ "created_at" bigint NOT NULL,
470
+ "updated_at" bigint NOT NULL,
471
+ CONSTRAINT "requirement_reviews_pkey" PRIMARY KEY("workspace_id","id")
472
+ );
473
+ --> statement-breakpoint
474
+ CREATE TABLE "runner_pool_connections" (
475
+ "workspace_id" text,
476
+ "provider_id" text,
477
+ "label" text NOT NULL,
478
+ "base_url" text NOT NULL,
479
+ "manifest_json" text NOT NULL,
480
+ "secrets_cipher" text NOT NULL,
481
+ "created_at" bigint NOT NULL,
482
+ "deleted_at" bigint,
483
+ CONSTRAINT "runner_pool_connections_pkey" PRIMARY KEY("workspace_id","provider_id")
484
+ );
485
+ --> statement-breakpoint
486
+ CREATE TABLE "services" (
487
+ "id" text PRIMARY KEY,
488
+ "account_id" text,
489
+ "frame_block_id" text NOT NULL,
490
+ "installation_id" bigint,
491
+ "repo_github_id" bigint,
492
+ "directory" text,
493
+ "created_at" bigint NOT NULL
494
+ );
495
+ --> statement-breakpoint
496
+ CREATE TABLE "slack_connections" (
497
+ "account_id" text PRIMARY KEY,
498
+ "team_id" text NOT NULL,
499
+ "team_name" text NOT NULL,
500
+ "team_icon_url" text,
501
+ "bot_user_id" text,
502
+ "scopes" text,
503
+ "token_cipher" text NOT NULL,
504
+ "created_at" bigint NOT NULL,
505
+ "deleted_at" bigint
506
+ );
507
+ --> statement-breakpoint
508
+ CREATE TABLE "slack_member_mappings" (
509
+ "account_id" text PRIMARY KEY,
510
+ "entries" text DEFAULT '[]' NOT NULL,
511
+ "updated_at" bigint NOT NULL
512
+ );
513
+ --> statement-breakpoint
514
+ CREATE TABLE "slack_settings" (
515
+ "workspace_id" text PRIMARY KEY,
516
+ "routes" text DEFAULT '{}' NOT NULL,
517
+ "mentions_enabled" integer DEFAULT 0 NOT NULL,
518
+ "updated_at" bigint NOT NULL
519
+ );
520
+ --> statement-breakpoint
521
+ CREATE TABLE "subscription_activations" (
522
+ "id" text PRIMARY KEY,
523
+ "execution_id" text NOT NULL,
524
+ "user_id" text NOT NULL,
525
+ "vendor" text NOT NULL,
526
+ "token_cipher" text NOT NULL,
527
+ "created_at" bigint NOT NULL,
528
+ "expires_at" bigint NOT NULL
529
+ );
530
+ --> statement-breakpoint
531
+ CREATE TABLE "task_connections" (
532
+ "workspace_id" text,
533
+ "source" text,
534
+ "credentials" text NOT NULL,
535
+ "label" text DEFAULT '' NOT NULL,
536
+ "created_at" bigint NOT NULL,
537
+ "deleted_at" bigint,
538
+ CONSTRAINT "task_connections_pkey" PRIMARY KEY("workspace_id","source")
539
+ );
540
+ --> statement-breakpoint
541
+ CREATE TABLE "tasks" (
542
+ "workspace_id" text,
543
+ "source" text,
544
+ "external_id" text,
545
+ "title" text NOT NULL,
546
+ "url" text NOT NULL,
547
+ "status" text DEFAULT '' NOT NULL,
548
+ "type" text DEFAULT '' NOT NULL,
549
+ "assignee" text,
550
+ "priority" text,
551
+ "labels" text DEFAULT '[]' NOT NULL,
552
+ "description" text DEFAULT '' NOT NULL,
553
+ "comments" text DEFAULT '[]' NOT NULL,
554
+ "excerpt" text DEFAULT '' NOT NULL,
555
+ "linked_block_id" text,
556
+ "synced_at" bigint NOT NULL,
557
+ "deleted_at" bigint,
558
+ CONSTRAINT "tasks_pkey" PRIMARY KEY("workspace_id","source","external_id")
559
+ );
560
+ --> statement-breakpoint
561
+ CREATE TABLE "token_usage" (
562
+ "id" text PRIMARY KEY,
563
+ "workspace_id" text NOT NULL,
564
+ "execution_id" text,
565
+ "agent_kind" text NOT NULL,
566
+ "provider" text NOT NULL,
567
+ "model" text NOT NULL,
568
+ "input_tokens" integer DEFAULT 0 NOT NULL,
569
+ "output_tokens" integer DEFAULT 0 NOT NULL,
570
+ "cost_estimate" double precision DEFAULT 0 NOT NULL,
571
+ "created_at" bigint NOT NULL
572
+ );
573
+ --> statement-breakpoint
574
+ CREATE TABLE "tracker_settings" (
575
+ "workspace_id" text PRIMARY KEY,
576
+ "tracker" text,
577
+ "jira_project_key" text,
578
+ "updated_at" bigint NOT NULL
579
+ );
580
+ --> statement-breakpoint
581
+ CREATE TABLE "user_identities" (
582
+ "user_id" text NOT NULL,
583
+ "provider" text,
584
+ "subject" text,
585
+ "secret" text,
586
+ "metadata" text,
587
+ "created_at" bigint NOT NULL,
588
+ CONSTRAINT "user_identities_pkey" PRIMARY KEY("provider","subject")
589
+ );
590
+ --> statement-breakpoint
591
+ CREATE TABLE "users" (
592
+ "id" text PRIMARY KEY,
593
+ "name" text,
594
+ "email" text,
595
+ "avatar_url" text,
596
+ "created_at" bigint NOT NULL
597
+ );
598
+ --> statement-breakpoint
599
+ CREATE TABLE "workspace_fragment_defaults" (
600
+ "workspace_id" text PRIMARY KEY,
601
+ "fragment_ids" text NOT NULL,
602
+ "updated_at" bigint NOT NULL
603
+ );
604
+ --> statement-breakpoint
605
+ CREATE TABLE "workspace_model_defaults" (
606
+ "workspace_id" text,
607
+ "agent_kind" text,
608
+ "model_id" text NOT NULL,
609
+ "updated_at" bigint NOT NULL,
610
+ CONSTRAINT "workspace_model_defaults_pkey" PRIMARY KEY("workspace_id","agent_kind")
611
+ );
612
+ --> statement-breakpoint
613
+ CREATE TABLE "workspace_services" (
614
+ "workspace_id" text,
615
+ "service_id" text,
616
+ "pos_x" double precision DEFAULT 0 NOT NULL,
617
+ "pos_y" double precision DEFAULT 0 NOT NULL,
618
+ "width" double precision,
619
+ "height" double precision,
620
+ "created_at" bigint NOT NULL,
621
+ CONSTRAINT "workspace_services_pkey" PRIMARY KEY("workspace_id","service_id")
622
+ );
623
+ --> statement-breakpoint
624
+ CREATE TABLE "workspaces" (
625
+ "id" text PRIMARY KEY,
626
+ "name" text NOT NULL,
627
+ "description" text,
628
+ "created_at" bigint NOT NULL,
629
+ "account_id" text,
630
+ "owner_user_id" text
631
+ );
632
+ --> statement-breakpoint
633
+ CREATE INDEX "idx_account_invitations_account" ON "account_invitations" ("account_id");--> statement-breakpoint
634
+ CREATE UNIQUE INDEX "idx_account_invitations_token" ON "account_invitations" ("token_hash");--> statement-breakpoint
635
+ CREATE UNIQUE INDEX "idx_accounts_personal" ON "accounts" ("owner_user_id") WHERE type = 'personal';--> statement-breakpoint
636
+ CREATE INDEX "idx_agent_runs_workspace" ON "agent_runs" ("workspace_id","created_at");--> statement-breakpoint
637
+ CREATE INDEX "idx_agent_runs_status_lease" ON "agent_runs" ("status","updated_at");--> statement-breakpoint
638
+ CREATE INDEX "idx_agent_runs_block" ON "agent_runs" ("workspace_id","block_id");--> statement-breakpoint
639
+ CREATE INDEX "idx_agent_runs_service" ON "agent_runs" ("service_id");--> statement-breakpoint
640
+ CREATE INDEX "idx_blocks_parent" ON "blocks" ("workspace_id","parent_id");--> statement-breakpoint
641
+ CREATE INDEX "idx_blocks_service" ON "blocks" ("service_id");--> statement-breakpoint
642
+ CREATE INDEX "idx_blocks_id" ON "blocks" ("id");--> statement-breakpoint
643
+ CREATE INDEX "idx_documents_block" ON "documents" ("workspace_id","linked_block_id");--> statement-breakpoint
644
+ CREATE UNIQUE INDEX "idx_environment_conn_workspace" ON "environment_connections" ("workspace_id") WHERE "deleted_at" IS NULL;--> statement-breakpoint
645
+ CREATE INDEX "idx_environments_block" ON "environments" ("workspace_id","block_id") WHERE "deleted_at" IS NULL;--> statement-breakpoint
646
+ CREATE INDEX "idx_environments_expiry" ON "environments" ("expires_at") WHERE "deleted_at" IS NULL AND "expires_at" IS NOT NULL;--> statement-breakpoint
647
+ CREATE UNIQUE INDEX "idx_fragment_sources_unique" ON "fragment_sources" ("owner_kind","owner_id","repo_owner","repo_name","git_ref","dir_path");--> statement-breakpoint
648
+ CREATE INDEX "idx_fragment_sources_owner" ON "fragment_sources" ("owner_kind","owner_id") WHERE "deleted_at" IS NULL;--> statement-breakpoint
649
+ CREATE INDEX "idx_gh_checks_sha" ON "github_check_runs" ("workspace_id","repo_github_id","head_sha");--> statement-breakpoint
650
+ CREATE UNIQUE INDEX "idx_gh_install_workspace" ON "github_installations" ("workspace_id") WHERE deleted_at IS NULL;--> statement-breakpoint
651
+ CREATE INDEX "idx_gh_install_account" ON "github_installations" ("account_id") WHERE deleted_at IS NULL;--> statement-breakpoint
652
+ CREATE INDEX "idx_gh_pr_state" ON "github_pull_requests" ("workspace_id","state");--> statement-breakpoint
653
+ CREATE INDEX "idx_gh_repos_install" ON "github_repos" ("installation_id");--> statement-breakpoint
654
+ CREATE INDEX "idx_llm_call_metrics_execution" ON "llm_call_metrics" ("workspace_id","execution_id","created_at");--> statement-breakpoint
655
+ CREATE INDEX "idx_llm_call_metrics_created" ON "llm_call_metrics" ("created_at");--> statement-breakpoint
656
+ CREATE INDEX "idx_memberships_user" ON "memberships" ("user_id");--> statement-breakpoint
657
+ CREATE INDEX "idx_merge_presets_default" ON "merge_threshold_presets" ("workspace_id","is_default");--> statement-breakpoint
658
+ CREATE INDEX "idx_notifications_open" ON "notifications" ("workspace_id","status","created_at");--> statement-breakpoint
659
+ CREATE INDEX "idx_notifications_block" ON "notifications" ("workspace_id","block_id","type","status");--> statement-breakpoint
660
+ CREATE UNIQUE INDEX "idx_personal_subs_user_vendor" ON "personal_subscriptions" ("user_id","vendor") WHERE "deleted_at" IS NULL;--> statement-breakpoint
661
+ CREATE INDEX "idx_personal_subs_expiry" ON "personal_subscriptions" ("expires_at") WHERE "deleted_at" IS NULL;--> statement-breakpoint
662
+ CREATE INDEX "idx_schedule_runs_schedule" ON "pipeline_schedule_runs" ("workspace_id","schedule_id","started_at");--> statement-breakpoint
663
+ CREATE INDEX "idx_schedule_runs_started" ON "pipeline_schedule_runs" ("started_at");--> statement-breakpoint
664
+ CREATE INDEX "idx_pipeline_schedules_due" ON "pipeline_schedules" ("enabled","next_run_at");--> statement-breakpoint
665
+ CREATE INDEX "idx_pipeline_schedules_block" ON "pipeline_schedules" ("workspace_id","block_id");--> statement-breakpoint
666
+ CREATE INDEX "idx_pipeline_schedules_service" ON "pipeline_schedules" ("service_id");--> statement-breakpoint
667
+ CREATE INDEX "idx_prompt_fragments_owner" ON "prompt_fragments" ("owner_kind","owner_id") WHERE "deleted_at" IS NULL;--> statement-breakpoint
668
+ CREATE INDEX "idx_prompt_fragments_source" ON "prompt_fragments" ("source_id") WHERE "deleted_at" IS NULL;--> statement-breakpoint
669
+ CREATE INDEX "idx_provider_api_keys_pool" ON "provider_api_keys" ("scope","scope_id","provider","deleted_at");--> statement-breakpoint
670
+ CREATE INDEX "idx_provider_subs_pool" ON "provider_subscription_tokens" ("workspace_id","vendor","deleted_at");--> statement-breakpoint
671
+ CREATE INDEX "idx_reference_architectures_workspace" ON "reference_architectures" ("workspace_id") WHERE "deleted_at" IS NULL;--> statement-breakpoint
672
+ CREATE UNIQUE INDEX "idx_repo_blueprints_repo" ON "repo_blueprints" ("workspace_id","repo_owner","repo_name");--> statement-breakpoint
673
+ CREATE INDEX "idx_repo_blueprints_workspace" ON "repo_blueprints" ("workspace_id","updated_at");--> statement-breakpoint
674
+ CREATE INDEX "idx_requirement_reviews_block" ON "requirement_reviews" ("workspace_id","block_id");--> statement-breakpoint
675
+ CREATE UNIQUE INDEX "idx_runner_pool_conn_workspace" ON "runner_pool_connections" ("workspace_id") WHERE deleted_at IS NULL;--> statement-breakpoint
676
+ CREATE INDEX "idx_services_account" ON "services" ("account_id");--> statement-breakpoint
677
+ CREATE UNIQUE INDEX "idx_services_frame" ON "services" ("account_id","frame_block_id");--> statement-breakpoint
678
+ CREATE INDEX "idx_services_frame_block" ON "services" ("frame_block_id");--> statement-breakpoint
679
+ CREATE INDEX "idx_services_repo" ON "services" ("installation_id","repo_github_id");--> statement-breakpoint
680
+ CREATE UNIQUE INDEX "idx_slack_conn_team" ON "slack_connections" ("team_id") WHERE deleted_at IS NULL;--> statement-breakpoint
681
+ CREATE UNIQUE INDEX "idx_sub_activations_run" ON "subscription_activations" ("execution_id","user_id","vendor");--> statement-breakpoint
682
+ CREATE INDEX "idx_sub_activations_expiry" ON "subscription_activations" ("expires_at");--> statement-breakpoint
683
+ CREATE INDEX "idx_tasks_block" ON "tasks" ("workspace_id","linked_block_id");--> statement-breakpoint
684
+ CREATE INDEX "idx_token_usage_created" ON "token_usage" ("created_at");--> statement-breakpoint
685
+ CREATE INDEX "idx_user_identities_user" ON "user_identities" ("user_id");--> statement-breakpoint
686
+ CREATE UNIQUE INDEX "idx_users_email" ON "users" ("email") WHERE email IS NOT NULL;--> statement-breakpoint
687
+ CREATE INDEX "idx_workspace_services_service" ON "workspace_services" ("service_id");--> statement-breakpoint
688
+ CREATE INDEX "idx_workspaces_owner" ON "workspaces" ("owner_user_id");--> statement-breakpoint
689
+ CREATE INDEX "idx_workspaces_account" ON "workspaces" ("account_id");