@intelligo-dev/core 1.0.0-beta.1 → 1.0.0-beta.14

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 (356) hide show
  1. package/NOTICE +6 -0
  2. package/README.md +102 -0
  3. package/dist/attachments/errors.d.ts +7 -0
  4. package/dist/attachments/errors.d.ts.map +1 -0
  5. package/dist/attachments/errors.js +11 -0
  6. package/dist/attachments/errors.js.map +1 -0
  7. package/dist/attachments/index.d.ts +8 -0
  8. package/dist/attachments/index.d.ts.map +1 -0
  9. package/dist/attachments/index.js +7 -0
  10. package/dist/attachments/index.js.map +1 -0
  11. package/dist/attachments/service.d.ts +45 -0
  12. package/dist/attachments/service.d.ts.map +1 -0
  13. package/dist/attachments/service.js +100 -0
  14. package/dist/attachments/service.js.map +1 -0
  15. package/dist/attachments/types.d.ts +6 -0
  16. package/dist/attachments/types.d.ts.map +1 -0
  17. package/dist/attachments/types.js +2 -0
  18. package/dist/attachments/types.js.map +1 -0
  19. package/dist/conversations/errors.d.ts +2 -8
  20. package/dist/conversations/errors.d.ts.map +1 -1
  21. package/dist/conversations/errors.js +2 -8
  22. package/dist/conversations/errors.js.map +1 -1
  23. package/dist/conversations/index.d.ts +4 -12
  24. package/dist/conversations/index.d.ts.map +1 -1
  25. package/dist/conversations/index.js +2 -11
  26. package/dist/conversations/index.js.map +1 -1
  27. package/dist/conversations/service.d.ts +49 -61
  28. package/dist/conversations/service.d.ts.map +1 -1
  29. package/dist/conversations/service.js +110 -83
  30. package/dist/conversations/service.js.map +1 -1
  31. package/dist/conversations/types.d.ts +1 -4
  32. package/dist/conversations/types.d.ts.map +1 -1
  33. package/dist/conversations/types.js +0 -3
  34. package/dist/conversations/types.js.map +1 -1
  35. package/dist/db/client.d.ts +21 -10
  36. package/dist/db/client.d.ts.map +1 -1
  37. package/dist/db/client.js +43 -18
  38. package/dist/db/client.js.map +1 -1
  39. package/dist/db/index.d.ts +3 -3
  40. package/dist/db/index.d.ts.map +1 -1
  41. package/dist/db/index.js +3 -7
  42. package/dist/db/index.js.map +1 -1
  43. package/dist/db/schema/agents.d.ts +14 -51
  44. package/dist/db/schema/agents.d.ts.map +1 -1
  45. package/dist/db/schema/agents.js +9 -21
  46. package/dist/db/schema/agents.js.map +1 -1
  47. package/dist/db/schema/ai.d.ts +86 -1556
  48. package/dist/db/schema/ai.d.ts.map +1 -1
  49. package/dist/db/schema/ai.js +32 -236
  50. package/dist/db/schema/ai.js.map +1 -1
  51. package/dist/db/schema/auth.d.ts +5 -34
  52. package/dist/db/schema/auth.d.ts.map +1 -1
  53. package/dist/db/schema/auth.js +25 -56
  54. package/dist/db/schema/auth.js.map +1 -1
  55. package/dist/db/schema/billing.d.ts +339 -105
  56. package/dist/db/schema/billing.d.ts.map +1 -1
  57. package/dist/db/schema/billing.js +99 -58
  58. package/dist/db/schema/billing.js.map +1 -1
  59. package/dist/db/schema/feature-flags.d.ts +3 -12
  60. package/dist/db/schema/feature-flags.d.ts.map +1 -1
  61. package/dist/db/schema/feature-flags.js +3 -12
  62. package/dist/db/schema/feature-flags.js.map +1 -1
  63. package/dist/db/schema/identity.d.ts +12 -274
  64. package/dist/db/schema/identity.d.ts.map +1 -1
  65. package/dist/db/schema/identity.js +19 -104
  66. package/dist/db/schema/identity.js.map +1 -1
  67. package/dist/db/schema/index.d.ts +8 -15
  68. package/dist/db/schema/index.d.ts.map +1 -1
  69. package/dist/db/schema/index.js +12 -42
  70. package/dist/db/schema/index.js.map +1 -1
  71. package/dist/db/schema/notifications.d.ts +3 -17
  72. package/dist/db/schema/notifications.d.ts.map +1 -1
  73. package/dist/db/schema/notifications.js +3 -17
  74. package/dist/db/schema/notifications.js.map +1 -1
  75. package/dist/db/schema/usage.d.ts +94 -77
  76. package/dist/db/schema/usage.d.ts.map +1 -1
  77. package/dist/db/schema/usage.js +59 -89
  78. package/dist/db/schema/usage.js.map +1 -1
  79. package/dist/db/validate.d.ts +2 -11
  80. package/dist/db/validate.d.ts.map +1 -1
  81. package/dist/db/validate.js +6 -17
  82. package/dist/db/validate.js.map +1 -1
  83. package/dist/db/workspace-queries.d.ts +5 -29
  84. package/dist/db/workspace-queries.d.ts.map +1 -1
  85. package/dist/db/workspace-queries.js +5 -29
  86. package/dist/db/workspace-queries.js.map +1 -1
  87. package/dist/documents/classifier.d.ts +5 -12
  88. package/dist/documents/classifier.d.ts.map +1 -1
  89. package/dist/documents/classifier.js +16 -16
  90. package/dist/documents/classifier.js.map +1 -1
  91. package/dist/documents/errors.d.ts +2 -10
  92. package/dist/documents/errors.d.ts.map +1 -1
  93. package/dist/documents/errors.js +2 -10
  94. package/dist/documents/errors.js.map +1 -1
  95. package/dist/documents/index.d.ts +4 -13
  96. package/dist/documents/index.d.ts.map +1 -1
  97. package/dist/documents/index.js +3 -12
  98. package/dist/documents/index.js.map +1 -1
  99. package/dist/documents/service.d.ts +19 -26
  100. package/dist/documents/service.d.ts.map +1 -1
  101. package/dist/documents/service.js +44 -38
  102. package/dist/documents/service.js.map +1 -1
  103. package/dist/documents/types.d.ts +6 -10
  104. package/dist/documents/types.d.ts.map +1 -1
  105. package/dist/documents/types.js +0 -3
  106. package/dist/documents/types.js.map +1 -1
  107. package/dist/email/brand.d.ts +17 -0
  108. package/dist/email/brand.d.ts.map +1 -0
  109. package/dist/email/brand.js +9 -0
  110. package/dist/email/brand.js.map +1 -0
  111. package/dist/email/index.d.ts +4 -4
  112. package/dist/email/index.js +4 -4
  113. package/dist/email/provider.d.ts +1 -7
  114. package/dist/email/provider.d.ts.map +1 -1
  115. package/dist/email/provider.js +10 -19
  116. package/dist/email/provider.js.map +1 -1
  117. package/dist/email/send.d.ts +12 -12
  118. package/dist/email/send.d.ts.map +1 -1
  119. package/dist/email/send.js +5 -19
  120. package/dist/email/send.js.map +1 -1
  121. package/dist/email/senders.d.ts +17 -30
  122. package/dist/email/senders.d.ts.map +1 -1
  123. package/dist/email/senders.js +33 -47
  124. package/dist/email/senders.js.map +1 -1
  125. package/dist/email/templates/base-layout.d.ts +1 -1
  126. package/dist/email/templates/base-layout.d.ts.map +1 -1
  127. package/dist/email/templates/base-layout.js +4 -6
  128. package/dist/email/templates/base-layout.js.map +1 -1
  129. package/dist/email/templates/index.d.ts +10 -10
  130. package/dist/email/templates/index.d.ts.map +1 -1
  131. package/dist/email/templates/index.js +10 -16
  132. package/dist/email/templates/index.js.map +1 -1
  133. package/dist/email/templates/password-reset.d.ts +2 -2
  134. package/dist/email/templates/password-reset.d.ts.map +1 -1
  135. package/dist/email/templates/password-reset.js +10 -22
  136. package/dist/email/templates/password-reset.js.map +1 -1
  137. package/dist/email/templates/payment-failed.d.ts +2 -2
  138. package/dist/email/templates/payment-failed.d.ts.map +1 -1
  139. package/dist/email/templates/payment-failed.js +11 -24
  140. package/dist/email/templates/payment-failed.js.map +1 -1
  141. package/dist/email/templates/quota-warning.d.ts +4 -4
  142. package/dist/email/templates/quota-warning.d.ts.map +1 -1
  143. package/dist/email/templates/quota-warning.js +19 -39
  144. package/dist/email/templates/quota-warning.js.map +1 -1
  145. package/dist/email/templates/subscription-confirmed.d.ts +2 -2
  146. package/dist/email/templates/subscription-confirmed.d.ts.map +1 -1
  147. package/dist/email/templates/subscription-confirmed.js +13 -28
  148. package/dist/email/templates/subscription-confirmed.js.map +1 -1
  149. package/dist/email/templates/trial-expiry.d.ts +2 -2
  150. package/dist/email/templates/trial-expiry.d.ts.map +1 -1
  151. package/dist/email/templates/trial-expiry.js +12 -36
  152. package/dist/email/templates/trial-expiry.js.map +1 -1
  153. package/dist/email/templates/trial-warning.d.ts +2 -2
  154. package/dist/email/templates/trial-warning.d.ts.map +1 -1
  155. package/dist/email/templates/trial-warning.js +15 -32
  156. package/dist/email/templates/trial-warning.js.map +1 -1
  157. package/dist/email/templates/verify-email.d.ts +2 -2
  158. package/dist/email/templates/verify-email.d.ts.map +1 -1
  159. package/dist/email/templates/verify-email.js +10 -22
  160. package/dist/email/templates/verify-email.js.map +1 -1
  161. package/dist/email/templates/welcome.d.ts +2 -2
  162. package/dist/email/templates/welcome.d.ts.map +1 -1
  163. package/dist/email/templates/welcome.js +13 -20
  164. package/dist/email/templates/welcome.js.map +1 -1
  165. package/dist/email/templates/workspace-invitation.d.ts +2 -2
  166. package/dist/email/templates/workspace-invitation.d.ts.map +1 -1
  167. package/dist/email/templates/workspace-invitation.js +12 -26
  168. package/dist/email/templates/workspace-invitation.js.map +1 -1
  169. package/dist/env.d.ts +5 -10
  170. package/dist/env.d.ts.map +1 -1
  171. package/dist/env.js +41 -31
  172. package/dist/env.js.map +1 -1
  173. package/dist/identity/audit.d.ts +11 -24
  174. package/dist/identity/audit.d.ts.map +1 -1
  175. package/dist/identity/audit.js +13 -27
  176. package/dist/identity/audit.js.map +1 -1
  177. package/dist/identity/errors.d.ts +4 -12
  178. package/dist/identity/errors.d.ts.map +1 -1
  179. package/dist/identity/errors.js +2 -8
  180. package/dist/identity/errors.js.map +1 -1
  181. package/dist/identity/index.d.ts +6 -13
  182. package/dist/identity/index.d.ts.map +1 -1
  183. package/dist/identity/index.js +5 -12
  184. package/dist/identity/index.js.map +1 -1
  185. package/dist/identity/service.d.ts +29 -47
  186. package/dist/identity/service.d.ts.map +1 -1
  187. package/dist/identity/service.js +107 -79
  188. package/dist/identity/service.js.map +1 -1
  189. package/dist/identity/types.d.ts +28 -4
  190. package/dist/identity/types.d.ts.map +1 -1
  191. package/dist/identity/types.js +0 -3
  192. package/dist/identity/types.js.map +1 -1
  193. package/dist/index.d.ts +1 -2
  194. package/dist/index.d.ts.map +1 -1
  195. package/dist/index.js +3 -10
  196. package/dist/index.js.map +1 -1
  197. package/dist/logger.d.ts +7 -18
  198. package/dist/logger.d.ts.map +1 -1
  199. package/dist/logger.js +45 -49
  200. package/dist/logger.js.map +1 -1
  201. package/dist/money.d.ts +95 -0
  202. package/dist/money.d.ts.map +1 -0
  203. package/dist/money.js +208 -0
  204. package/dist/money.js.map +1 -0
  205. package/dist/notifications/index.d.ts +9 -43
  206. package/dist/notifications/index.d.ts.map +1 -1
  207. package/dist/notifications/index.js +9 -49
  208. package/dist/notifications/index.js.map +1 -1
  209. package/dist/notifications/triggers.d.ts +9 -32
  210. package/dist/notifications/triggers.d.ts.map +1 -1
  211. package/dist/notifications/triggers.js +21 -58
  212. package/dist/notifications/triggers.js.map +1 -1
  213. package/dist/notifications/types.d.ts +6 -8
  214. package/dist/notifications/types.d.ts.map +1 -1
  215. package/dist/notifications/types.js +0 -9
  216. package/dist/notifications/types.js.map +1 -1
  217. package/dist/prompt.d.ts +38 -0
  218. package/dist/prompt.d.ts.map +1 -0
  219. package/dist/prompt.js +118 -0
  220. package/dist/prompt.js.map +1 -0
  221. package/dist/registry.d.ts +32 -0
  222. package/dist/registry.d.ts.map +1 -0
  223. package/dist/registry.js +60 -0
  224. package/dist/registry.js.map +1 -0
  225. package/dist/request-context.d.ts +49 -0
  226. package/dist/request-context.d.ts.map +1 -0
  227. package/dist/request-context.js +100 -0
  228. package/dist/request-context.js.map +1 -0
  229. package/dist/storage/index.d.ts +65 -0
  230. package/dist/storage/index.d.ts.map +1 -0
  231. package/dist/storage/index.js +109 -0
  232. package/dist/storage/index.js.map +1 -0
  233. package/package.json +74 -24
  234. package/src/attachments/errors.ts +18 -0
  235. package/src/attachments/index.ts +22 -0
  236. package/src/attachments/service.ts +178 -0
  237. package/src/attachments/types.ts +6 -0
  238. package/src/conversations/errors.ts +45 -0
  239. package/src/conversations/index.ts +39 -0
  240. package/src/conversations/service.ts +594 -0
  241. package/src/conversations/types.ts +15 -0
  242. package/src/db/client.ts +91 -0
  243. package/src/db/index.ts +3 -0
  244. package/src/db/migrations/0000_baseline.sql +652 -0
  245. package/src/db/migrations/0001_reconcile_chain_built_databases.sql +53 -0
  246. package/src/db/migrations/0002_webhook_claim_lease.sql +1 -0
  247. package/src/db/migrations/0003_local_payments.sql +18 -0
  248. package/src/db/migrations/README.md +103 -36
  249. package/src/db/migrations/legacy-chain.json +206 -0
  250. package/src/db/migrations/meta/0000_snapshot.json +4182 -157
  251. package/src/db/migrations/meta/0002_snapshot.json +2478 -368
  252. package/src/db/migrations/meta/0003_snapshot.json +2567 -554
  253. package/src/db/migrations/meta/_journal.json +8 -274
  254. package/src/db/schema/agents.ts +57 -0
  255. package/src/db/schema/ai.ts +174 -0
  256. package/src/db/schema/auth.ts +183 -0
  257. package/src/db/schema/billing.ts +245 -0
  258. package/src/db/schema/feature-flags.ts +20 -0
  259. package/src/db/schema/identity.ts +250 -0
  260. package/src/db/schema/index.ts +12 -0
  261. package/src/db/schema/notifications.ts +31 -0
  262. package/src/db/schema/usage.ts +269 -0
  263. package/src/db/validate.ts +63 -0
  264. package/src/db/workspace-queries.ts +64 -0
  265. package/src/documents/classifier.ts +61 -0
  266. package/src/documents/errors.ts +44 -0
  267. package/src/documents/index.ts +24 -0
  268. package/src/documents/service.ts +256 -0
  269. package/src/documents/types.ts +24 -0
  270. package/src/email/brand.ts +24 -0
  271. package/src/email/index.ts +19 -0
  272. package/src/email/provider.ts +278 -0
  273. package/src/email/send.ts +169 -0
  274. package/src/email/senders.ts +292 -0
  275. package/src/email/templates/base-layout.tsx +145 -0
  276. package/src/email/templates/index.ts +28 -0
  277. package/src/email/templates/password-reset.tsx +72 -0
  278. package/src/email/templates/payment-failed.tsx +77 -0
  279. package/src/email/templates/quota-warning.tsx +118 -0
  280. package/src/email/templates/subscription-confirmed.tsx +91 -0
  281. package/src/email/templates/trial-expiry.tsx +124 -0
  282. package/src/email/templates/trial-warning.tsx +104 -0
  283. package/src/email/templates/verify-email.tsx +72 -0
  284. package/src/email/templates/welcome.tsx +64 -0
  285. package/src/email/templates/workspace-invitation.tsx +105 -0
  286. package/src/env.ts +180 -0
  287. package/src/identity/audit.ts +65 -0
  288. package/src/identity/errors.ts +44 -0
  289. package/src/identity/index.ts +29 -0
  290. package/src/identity/service.ts +303 -0
  291. package/src/identity/types.ts +58 -0
  292. package/src/index.ts +4 -0
  293. package/src/logger.ts +198 -0
  294. package/src/money.ts +270 -0
  295. package/src/notifications/index.ts +112 -0
  296. package/src/notifications/triggers.ts +158 -0
  297. package/src/notifications/types.ts +26 -0
  298. package/src/prompt.ts +142 -0
  299. package/src/registry.ts +75 -0
  300. package/src/request-context.ts +137 -0
  301. package/src/storage/index.ts +153 -0
  302. package/dist/db/schema/rag.d.ts +0 -171
  303. package/dist/db/schema/rag.d.ts.map +0 -1
  304. package/dist/db/schema/rag.js +0 -42
  305. package/dist/db/schema/rag.js.map +0 -1
  306. package/src/db/migrations/0000_sharp_night_nurse.sql +0 -52
  307. package/src/db/migrations/0001_hesitant_vapor.sql +0 -40
  308. package/src/db/migrations/0002_numerous_lady_vermin.sql +0 -235
  309. package/src/db/migrations/0003_mighty_jean_grey.sql +0 -37
  310. package/src/db/migrations/0004_cynical_grandmaster.sql +0 -2
  311. package/src/db/migrations/0005_careful_switch.sql +0 -8
  312. package/src/db/migrations/0006_tense_blue_marvel.sql +0 -16
  313. package/src/db/migrations/0007_next_squadron_sinister.sql +0 -1
  314. package/src/db/migrations/0008_powerful_scream.sql +0 -39
  315. package/src/db/migrations/0009_sad_ink.sql +0 -1
  316. package/src/db/migrations/0010_shocking_omega_flight.sql +0 -2
  317. package/src/db/migrations/0011_ambiguous_otto_octavius.sql +0 -151
  318. package/src/db/migrations/0011_hnsw_vector_index.sql +0 -17
  319. package/src/db/migrations/0012_user_profiles.sql +0 -30
  320. package/src/db/migrations/0013_trending_seasonal_columns.sql +0 -9
  321. package/src/db/migrations/0014_add_product_type_to_agents.sql +0 -6
  322. package/src/db/migrations/0015_new_v1_tables.sql +0 -149
  323. package/src/db/migrations/0016_document_types.sql +0 -30
  324. package/src/db/migrations/0017_document_metadata.sql +0 -2
  325. package/src/db/migrations/0018_identity_graph.sql +0 -200
  326. package/src/db/migrations/0019_db_driven_prompts.sql +0 -20
  327. package/src/db/migrations/0020_pending_extractions.sql +0 -35
  328. package/src/db/migrations/0021_rag_documents.sql +0 -39
  329. package/src/db/migrations/0022_user_quotas_usage_jsonb.sql +0 -70
  330. package/src/db/migrations/0023_user_facts_user_scoped_unique.sql +0 -17
  331. package/src/db/migrations/0024_user_memories_hnsw.sql +0 -23
  332. package/src/db/migrations/0025_audit_trigger_errcode.sql +0 -21
  333. package/src/db/migrations/0026_user_profile_snapshots_composite_pk.sql +0 -17
  334. package/src/db/migrations/0027_billing_settings_mnt_columns.sql +0 -54
  335. package/src/db/migrations/0028_trial_credits_normalized_email.sql +0 -37
  336. package/src/db/migrations/0029_usage_records_conversation_idx.sql +0 -13
  337. package/src/db/migrations/0030_pending_extractions_composite_idx.sql +0 -11
  338. package/src/db/migrations/0031_rag_documents_hnsw.sql +0 -16
  339. package/src/db/migrations/0032_rate_limit_unique_idx.sql +0 -16
  340. package/src/db/migrations/0033_pending_extractions_partial_idx.sql +0 -18
  341. package/src/db/migrations/0034_rate_limit_count.sql +0 -9
  342. package/src/db/migrations/0035_credit_reservations.sql +0 -24
  343. package/src/db/migrations/0036_executions_audit_jobs.sql +0 -96
  344. package/src/db/migrations/0037_rate_limit_minute_bucket.sql +0 -46
  345. package/src/db/migrations/0038_user_quotas_generic_usage.sql +0 -25
  346. package/src/db/migrations/0039_platform_admin_impersonation.sql +0 -27
  347. package/src/db/migrations/0040_ee_audit_chain.sql +0 -23
  348. package/src/db/migrations/meta/0001_snapshot.json +0 -631
  349. package/src/db/migrations/meta/0004_snapshot.json +0 -2500
  350. package/src/db/migrations/meta/0005_snapshot.json +0 -2548
  351. package/src/db/migrations/meta/0006_snapshot.json +0 -2650
  352. package/src/db/migrations/meta/0007_snapshot.json +0 -2657
  353. package/src/db/migrations/meta/0008_snapshot.json +0 -2719
  354. package/src/db/migrations/meta/0009_snapshot.json +0 -2726
  355. package/src/db/migrations/meta/0010_snapshot.json +0 -2739
  356. package/src/db/migrations/meta/0011_snapshot.json +0 -3886
@@ -1,9 +1,291 @@
1
1
  {
2
- "id": "ff5fb189-bd70-4db4-99ab-23accd856ce2",
3
- "prevId": "ad471214-0088-4a54-949d-6a14719f3d4c",
2
+ "id": "25fa76d2-5b6b-4004-9785-846ea1227c55",
3
+ "prevId": "a97fa64b-3f7b-4597-88fd-508f9295e563",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
6
6
  "tables": {
7
+ "public.agents": {
8
+ "name": "agents",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "name": {
18
+ "name": "name",
19
+ "type": "jsonb",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "description": {
24
+ "name": "description",
25
+ "type": "jsonb",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "system_prompt_key": {
30
+ "name": "system_prompt_key",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "system_prompt": {
36
+ "name": "system_prompt",
37
+ "type": "jsonb",
38
+ "primaryKey": false,
39
+ "notNull": false
40
+ },
41
+ "model_config": {
42
+ "name": "model_config",
43
+ "type": "jsonb",
44
+ "primaryKey": false,
45
+ "notNull": false
46
+ },
47
+ "icon": {
48
+ "name": "icon",
49
+ "type": "text",
50
+ "primaryKey": false,
51
+ "notNull": true
52
+ },
53
+ "default_model": {
54
+ "name": "default_model",
55
+ "type": "text",
56
+ "primaryKey": false,
57
+ "notNull": true
58
+ },
59
+ "max_steps": {
60
+ "name": "max_steps",
61
+ "type": "integer",
62
+ "primaryKey": false,
63
+ "notNull": true
64
+ },
65
+ "context_window_size": {
66
+ "name": "context_window_size",
67
+ "type": "integer",
68
+ "primaryKey": false,
69
+ "notNull": true
70
+ },
71
+ "tools": {
72
+ "name": "tools",
73
+ "type": "jsonb",
74
+ "primaryKey": false,
75
+ "notNull": true,
76
+ "default": "'[]'::jsonb"
77
+ },
78
+ "base_path": {
79
+ "name": "base_path",
80
+ "type": "text",
81
+ "primaryKey": false,
82
+ "notNull": true
83
+ },
84
+ "is_active": {
85
+ "name": "is_active",
86
+ "type": "boolean",
87
+ "primaryKey": false,
88
+ "notNull": true,
89
+ "default": true
90
+ },
91
+ "suggestions": {
92
+ "name": "suggestions",
93
+ "type": "jsonb",
94
+ "primaryKey": false,
95
+ "notNull": true,
96
+ "default": "'[]'::jsonb"
97
+ },
98
+ "is_system": {
99
+ "name": "is_system",
100
+ "type": "boolean",
101
+ "primaryKey": false,
102
+ "notNull": true,
103
+ "default": true
104
+ },
105
+ "feature_key": {
106
+ "name": "feature_key",
107
+ "type": "text",
108
+ "primaryKey": false,
109
+ "notNull": false
110
+ },
111
+ "color": {
112
+ "name": "color",
113
+ "type": "text",
114
+ "primaryKey": false,
115
+ "notNull": true,
116
+ "default": "'bg-gray-500'"
117
+ },
118
+ "created_at": {
119
+ "name": "created_at",
120
+ "type": "timestamp",
121
+ "primaryKey": false,
122
+ "notNull": true,
123
+ "default": "now()"
124
+ },
125
+ "updated_at": {
126
+ "name": "updated_at",
127
+ "type": "timestamp",
128
+ "primaryKey": false,
129
+ "notNull": true,
130
+ "default": "now()"
131
+ }
132
+ },
133
+ "indexes": {},
134
+ "foreignKeys": {},
135
+ "compositePrimaryKeys": {},
136
+ "uniqueConstraints": {},
137
+ "policies": {},
138
+ "checkConstraints": {},
139
+ "isRLSEnabled": false
140
+ },
141
+ "public.attachments": {
142
+ "name": "attachments",
143
+ "schema": "",
144
+ "columns": {
145
+ "id": {
146
+ "name": "id",
147
+ "type": "text",
148
+ "primaryKey": true,
149
+ "notNull": true
150
+ },
151
+ "workspace_id": {
152
+ "name": "workspace_id",
153
+ "type": "text",
154
+ "primaryKey": false,
155
+ "notNull": true
156
+ },
157
+ "user_id": {
158
+ "name": "user_id",
159
+ "type": "text",
160
+ "primaryKey": false,
161
+ "notNull": true
162
+ },
163
+ "conversation_id": {
164
+ "name": "conversation_id",
165
+ "type": "text",
166
+ "primaryKey": false,
167
+ "notNull": false
168
+ },
169
+ "storage_key": {
170
+ "name": "storage_key",
171
+ "type": "text",
172
+ "primaryKey": false,
173
+ "notNull": true
174
+ },
175
+ "filename": {
176
+ "name": "filename",
177
+ "type": "text",
178
+ "primaryKey": false,
179
+ "notNull": true
180
+ },
181
+ "media_type": {
182
+ "name": "media_type",
183
+ "type": "text",
184
+ "primaryKey": false,
185
+ "notNull": true
186
+ },
187
+ "size_bytes": {
188
+ "name": "size_bytes",
189
+ "type": "integer",
190
+ "primaryKey": false,
191
+ "notNull": true
192
+ },
193
+ "extracted_text": {
194
+ "name": "extracted_text",
195
+ "type": "text",
196
+ "primaryKey": false,
197
+ "notNull": false
198
+ },
199
+ "created_at": {
200
+ "name": "created_at",
201
+ "type": "timestamp",
202
+ "primaryKey": false,
203
+ "notNull": true,
204
+ "default": "now()"
205
+ }
206
+ },
207
+ "indexes": {
208
+ "attachments_workspace_id_idx": {
209
+ "name": "attachments_workspace_id_idx",
210
+ "columns": [
211
+ {
212
+ "expression": "workspace_id",
213
+ "isExpression": false,
214
+ "asc": true,
215
+ "nulls": "last"
216
+ }
217
+ ],
218
+ "isUnique": false,
219
+ "concurrently": false,
220
+ "method": "btree",
221
+ "with": {}
222
+ },
223
+ "attachments_conversation_id_idx": {
224
+ "name": "attachments_conversation_id_idx",
225
+ "columns": [
226
+ {
227
+ "expression": "conversation_id",
228
+ "isExpression": false,
229
+ "asc": true,
230
+ "nulls": "last"
231
+ }
232
+ ],
233
+ "isUnique": false,
234
+ "concurrently": false,
235
+ "method": "btree",
236
+ "with": {}
237
+ },
238
+ "attachments_storage_key_idx": {
239
+ "name": "attachments_storage_key_idx",
240
+ "columns": [
241
+ {
242
+ "expression": "storage_key",
243
+ "isExpression": false,
244
+ "asc": true,
245
+ "nulls": "last"
246
+ }
247
+ ],
248
+ "isUnique": true,
249
+ "concurrently": false,
250
+ "method": "btree",
251
+ "with": {}
252
+ }
253
+ },
254
+ "foreignKeys": {
255
+ "attachments_workspace_id_organization_id_fk": {
256
+ "name": "attachments_workspace_id_organization_id_fk",
257
+ "tableFrom": "attachments",
258
+ "tableTo": "organization",
259
+ "columnsFrom": ["workspace_id"],
260
+ "columnsTo": ["id"],
261
+ "onDelete": "cascade",
262
+ "onUpdate": "no action"
263
+ },
264
+ "attachments_user_id_users_id_fk": {
265
+ "name": "attachments_user_id_users_id_fk",
266
+ "tableFrom": "attachments",
267
+ "tableTo": "users",
268
+ "columnsFrom": ["user_id"],
269
+ "columnsTo": ["id"],
270
+ "onDelete": "cascade",
271
+ "onUpdate": "no action"
272
+ },
273
+ "attachments_conversation_id_conversations_id_fk": {
274
+ "name": "attachments_conversation_id_conversations_id_fk",
275
+ "tableFrom": "attachments",
276
+ "tableTo": "conversations",
277
+ "columnsFrom": ["conversation_id"],
278
+ "columnsTo": ["id"],
279
+ "onDelete": "set null",
280
+ "onUpdate": "no action"
281
+ }
282
+ },
283
+ "compositePrimaryKeys": {},
284
+ "uniqueConstraints": {},
285
+ "policies": {},
286
+ "checkConstraints": {},
287
+ "isRLSEnabled": false
288
+ },
7
289
  "public.conversations": {
8
290
  "name": "conversations",
9
291
  "schema": "",
@@ -51,6 +333,12 @@
51
333
  "notNull": true,
52
334
  "default": "'private'"
53
335
  },
336
+ "metadata": {
337
+ "name": "metadata",
338
+ "type": "jsonb",
339
+ "primaryKey": false,
340
+ "notNull": false
341
+ },
54
342
  "created_at": {
55
343
  "name": "created_at",
56
344
  "type": "timestamp",
@@ -117,6 +405,27 @@
117
405
  "concurrently": false,
118
406
  "method": "btree",
119
407
  "with": {}
408
+ },
409
+ "conversations_workspace_user_idx": {
410
+ "name": "conversations_workspace_user_idx",
411
+ "columns": [
412
+ {
413
+ "expression": "workspace_id",
414
+ "isExpression": false,
415
+ "asc": true,
416
+ "nulls": "last"
417
+ },
418
+ {
419
+ "expression": "user_id",
420
+ "isExpression": false,
421
+ "asc": true,
422
+ "nulls": "last"
423
+ }
424
+ ],
425
+ "isUnique": false,
426
+ "concurrently": false,
427
+ "method": "btree",
428
+ "with": {}
120
429
  }
121
430
  },
122
431
  "foreignKeys": {
@@ -181,96 +490,31 @@
181
490
  "notNull": true,
182
491
  "default": "'text'"
183
492
  },
493
+ "metadata": {
494
+ "name": "metadata",
495
+ "type": "jsonb",
496
+ "primaryKey": false,
497
+ "notNull": false
498
+ },
184
499
  "user_id": {
185
500
  "name": "user_id",
186
501
  "type": "text",
187
502
  "primaryKey": false,
188
503
  "notNull": true
189
- }
190
- },
191
- "indexes": {},
192
- "foreignKeys": {
193
- "documents_user_id_users_id_fk": {
194
- "name": "documents_user_id_users_id_fk",
195
- "tableFrom": "documents",
196
- "tableTo": "users",
197
- "columnsFrom": ["user_id"],
198
- "columnsTo": ["id"],
199
- "onDelete": "cascade",
200
- "onUpdate": "no action"
201
- }
202
- },
203
- "compositePrimaryKeys": {
204
- "documents_id_created_at_pk": {
205
- "name": "documents_id_created_at_pk",
206
- "columns": ["id", "created_at"]
207
- }
208
- },
209
- "uniqueConstraints": {},
210
- "policies": {},
211
- "checkConstraints": {},
212
- "isRLSEnabled": false
213
- },
214
- "public.knowledge_chunks": {
215
- "name": "knowledge_chunks",
216
- "schema": "",
217
- "columns": {
218
- "id": {
219
- "name": "id",
220
- "type": "text",
221
- "primaryKey": true,
222
- "notNull": true
223
- },
224
- "document_id": {
225
- "name": "document_id",
226
- "type": "text",
227
- "primaryKey": false,
228
- "notNull": true
229
- },
230
- "workspace_id": {
231
- "name": "workspace_id",
232
- "type": "text",
233
- "primaryKey": false,
234
- "notNull": true
235
- },
236
- "content": {
237
- "name": "content",
238
- "type": "text",
239
- "primaryKey": false,
240
- "notNull": true
241
- },
242
- "embedding": {
243
- "name": "embedding",
244
- "type": "vector(1536)",
245
- "primaryKey": false,
246
- "notNull": false
247
- },
248
- "metadata": {
249
- "name": "metadata",
250
- "type": "text",
251
- "primaryKey": false,
252
- "notNull": false
253
- },
254
- "chunk_index": {
255
- "name": "chunk_index",
256
- "type": "integer",
257
- "primaryKey": false,
258
- "notNull": true
259
- },
260
- "created_at": {
261
- "name": "created_at",
262
- "type": "timestamp",
263
- "primaryKey": false,
264
- "notNull": true,
265
- "default": "now()"
504
+ },
505
+ "workspace_id": {
506
+ "name": "workspace_id",
507
+ "type": "text",
508
+ "primaryKey": false,
509
+ "notNull": true
266
510
  }
267
511
  },
268
512
  "indexes": {
269
- "knowledge_chunks_document_id_idx": {
270
- "name": "knowledge_chunks_document_id_idx",
513
+ "documents_workspace_id_idx": {
514
+ "name": "documents_workspace_id_idx",
271
515
  "columns": [
272
516
  {
273
- "expression": "document_id",
517
+ "expression": "workspace_id",
274
518
  "isExpression": false,
275
519
  "asc": true,
276
520
  "nulls": "last"
@@ -281,11 +525,11 @@
281
525
  "method": "btree",
282
526
  "with": {}
283
527
  },
284
- "knowledge_chunks_workspace_id_idx": {
285
- "name": "knowledge_chunks_workspace_id_idx",
528
+ "documents_user_id_idx": {
529
+ "name": "documents_user_id_idx",
286
530
  "columns": [
287
531
  {
288
- "expression": "workspace_id",
532
+ "expression": "user_id",
289
533
  "isExpression": false,
290
534
  "asc": true,
291
535
  "nulls": "last"
@@ -298,18 +542,18 @@
298
542
  }
299
543
  },
300
544
  "foreignKeys": {
301
- "knowledge_chunks_document_id_knowledge_documents_id_fk": {
302
- "name": "knowledge_chunks_document_id_knowledge_documents_id_fk",
303
- "tableFrom": "knowledge_chunks",
304
- "tableTo": "knowledge_documents",
305
- "columnsFrom": ["document_id"],
545
+ "documents_user_id_users_id_fk": {
546
+ "name": "documents_user_id_users_id_fk",
547
+ "tableFrom": "documents",
548
+ "tableTo": "users",
549
+ "columnsFrom": ["user_id"],
306
550
  "columnsTo": ["id"],
307
551
  "onDelete": "cascade",
308
552
  "onUpdate": "no action"
309
553
  },
310
- "knowledge_chunks_workspace_id_organization_id_fk": {
311
- "name": "knowledge_chunks_workspace_id_organization_id_fk",
312
- "tableFrom": "knowledge_chunks",
554
+ "documents_workspace_id_organization_id_fk": {
555
+ "name": "documents_workspace_id_organization_id_fk",
556
+ "tableFrom": "documents",
313
557
  "tableTo": "organization",
314
558
  "columnsFrom": ["workspace_id"],
315
559
  "columnsTo": ["id"],
@@ -317,109 +561,12 @@
317
561
  "onUpdate": "no action"
318
562
  }
319
563
  },
320
- "compositePrimaryKeys": {},
321
- "uniqueConstraints": {},
322
- "policies": {},
323
- "checkConstraints": {},
324
- "isRLSEnabled": false
325
- },
326
- "public.knowledge_documents": {
327
- "name": "knowledge_documents",
328
- "schema": "",
329
- "columns": {
330
- "id": {
331
- "name": "id",
332
- "type": "text",
333
- "primaryKey": true,
334
- "notNull": true
335
- },
336
- "workspace_id": {
337
- "name": "workspace_id",
338
- "type": "text",
339
- "primaryKey": false,
340
- "notNull": true
341
- },
342
- "filename": {
343
- "name": "filename",
344
- "type": "text",
345
- "primaryKey": false,
346
- "notNull": true
347
- },
348
- "mime_type": {
349
- "name": "mime_type",
350
- "type": "text",
351
- "primaryKey": false,
352
- "notNull": true
353
- },
354
- "size_bytes": {
355
- "name": "size_bytes",
356
- "type": "integer",
357
- "primaryKey": false,
358
- "notNull": false
359
- },
360
- "chunk_count": {
361
- "name": "chunk_count",
362
- "type": "integer",
363
- "primaryKey": false,
364
- "notNull": false,
365
- "default": 0
366
- },
367
- "status": {
368
- "name": "status",
369
- "type": "text",
370
- "primaryKey": false,
371
- "notNull": true,
372
- "default": "'processing'"
373
- },
374
- "product": {
375
- "name": "product",
376
- "type": "text",
377
- "primaryKey": false,
378
- "notNull": false
379
- },
380
- "metadata": {
381
- "name": "metadata",
382
- "type": "text",
383
- "primaryKey": false,
384
- "notNull": false
385
- },
386
- "created_at": {
387
- "name": "created_at",
388
- "type": "timestamp",
389
- "primaryKey": false,
390
- "notNull": true,
391
- "default": "now()"
392
- }
393
- },
394
- "indexes": {
395
- "knowledge_documents_workspace_id_idx": {
396
- "name": "knowledge_documents_workspace_id_idx",
397
- "columns": [
398
- {
399
- "expression": "workspace_id",
400
- "isExpression": false,
401
- "asc": true,
402
- "nulls": "last"
403
- }
404
- ],
405
- "isUnique": false,
406
- "concurrently": false,
407
- "method": "btree",
408
- "with": {}
409
- }
410
- },
411
- "foreignKeys": {
412
- "knowledge_documents_workspace_id_organization_id_fk": {
413
- "name": "knowledge_documents_workspace_id_organization_id_fk",
414
- "tableFrom": "knowledge_documents",
415
- "tableTo": "organization",
416
- "columnsFrom": ["workspace_id"],
417
- "columnsTo": ["id"],
418
- "onDelete": "cascade",
419
- "onUpdate": "no action"
564
+ "compositePrimaryKeys": {
565
+ "documents_id_created_at_pk": {
566
+ "name": "documents_id_created_at_pk",
567
+ "columns": ["id", "created_at"]
420
568
  }
421
569
  },
422
- "compositePrimaryKeys": {},
423
570
  "uniqueConstraints": {},
424
571
  "policies": {},
425
572
  "checkConstraints": {},
@@ -540,85 +687,6 @@
540
687
  "checkConstraints": {},
541
688
  "isRLSEnabled": false
542
689
  },
543
- "public.suggestions": {
544
- "name": "suggestions",
545
- "schema": "",
546
- "columns": {
547
- "id": {
548
- "name": "id",
549
- "type": "text",
550
- "primaryKey": true,
551
- "notNull": true
552
- },
553
- "document_id": {
554
- "name": "document_id",
555
- "type": "text",
556
- "primaryKey": false,
557
- "notNull": true
558
- },
559
- "document_created_at": {
560
- "name": "document_created_at",
561
- "type": "timestamp",
562
- "primaryKey": false,
563
- "notNull": true
564
- },
565
- "original_text": {
566
- "name": "original_text",
567
- "type": "text",
568
- "primaryKey": false,
569
- "notNull": true
570
- },
571
- "suggested_text": {
572
- "name": "suggested_text",
573
- "type": "text",
574
- "primaryKey": false,
575
- "notNull": true
576
- },
577
- "description": {
578
- "name": "description",
579
- "type": "text",
580
- "primaryKey": false,
581
- "notNull": false
582
- },
583
- "is_resolved": {
584
- "name": "is_resolved",
585
- "type": "boolean",
586
- "primaryKey": false,
587
- "notNull": true,
588
- "default": false
589
- },
590
- "user_id": {
591
- "name": "user_id",
592
- "type": "text",
593
- "primaryKey": false,
594
- "notNull": true
595
- },
596
- "created_at": {
597
- "name": "created_at",
598
- "type": "timestamp",
599
- "primaryKey": false,
600
- "notNull": true,
601
- "default": "now()"
602
- }
603
- },
604
- "indexes": {},
605
- "foreignKeys": {
606
- "suggestions_user_id_users_id_fk": {
607
- "name": "suggestions_user_id_users_id_fk",
608
- "tableFrom": "suggestions",
609
- "tableTo": "users",
610
- "columnsFrom": ["user_id"],
611
- "columnsTo": ["id"],
612
- "onDelete": "cascade",
613
- "onUpdate": "no action"
614
- }
615
- },
616
- "compositePrimaryKeys": {},
617
- "uniqueConstraints": {},
618
- "policies": {},
619
- "checkConstraints": {},
620
- "isRLSEnabled": false
621
- },
622
690
  "public.votes": {
623
691
  "name": "votes",
624
692
  "schema": "",
@@ -642,7 +710,23 @@
642
710
  "notNull": true
643
711
  }
644
712
  },
645
- "indexes": {},
713
+ "indexes": {
714
+ "votes_message_id_idx": {
715
+ "name": "votes_message_id_idx",
716
+ "columns": [
717
+ {
718
+ "expression": "message_id",
719
+ "isExpression": false,
720
+ "asc": true,
721
+ "nulls": "last"
722
+ }
723
+ ],
724
+ "isUnique": false,
725
+ "concurrently": false,
726
+ "method": "btree",
727
+ "with": {}
728
+ }
729
+ },
646
730
  "foreignKeys": {
647
731
  "votes_chat_id_conversations_id_fk": {
648
732
  "name": "votes_chat_id_conversations_id_fk",
@@ -837,7 +921,7 @@
837
921
  "name": "inviter_id",
838
922
  "type": "text",
839
923
  "primaryKey": false,
840
- "notNull": true
924
+ "notNull": false
841
925
  },
842
926
  "created_at": {
843
927
  "name": "created_at",
@@ -902,7 +986,7 @@
902
986
  "tableTo": "users",
903
987
  "columnsFrom": ["inviter_id"],
904
988
  "columnsTo": ["id"],
905
- "onDelete": "no action",
989
+ "onDelete": "set null",
906
990
  "onUpdate": "no action"
907
991
  }
908
992
  },
@@ -985,12 +1069,33 @@
985
1069
  "concurrently": false,
986
1070
  "method": "btree",
987
1071
  "with": {}
988
- }
989
- },
990
- "foreignKeys": {
991
- "member_organization_id_organization_id_fk": {
992
- "name": "member_organization_id_organization_id_fk",
993
- "tableFrom": "member",
1072
+ },
1073
+ "member_organization_user_uniq": {
1074
+ "name": "member_organization_user_uniq",
1075
+ "columns": [
1076
+ {
1077
+ "expression": "organization_id",
1078
+ "isExpression": false,
1079
+ "asc": true,
1080
+ "nulls": "last"
1081
+ },
1082
+ {
1083
+ "expression": "user_id",
1084
+ "isExpression": false,
1085
+ "asc": true,
1086
+ "nulls": "last"
1087
+ }
1088
+ ],
1089
+ "isUnique": true,
1090
+ "concurrently": false,
1091
+ "method": "btree",
1092
+ "with": {}
1093
+ }
1094
+ },
1095
+ "foreignKeys": {
1096
+ "member_organization_id_organization_id_fk": {
1097
+ "name": "member_organization_id_organization_id_fk",
1098
+ "tableFrom": "member",
994
1099
  "tableTo": "organization",
995
1100
  "columnsFrom": ["organization_id"],
996
1101
  "columnsTo": ["id"],
@@ -1116,6 +1221,18 @@
1116
1221
  "primaryKey": false,
1117
1222
  "notNull": false
1118
1223
  },
1224
+ "impersonated_by": {
1225
+ "name": "impersonated_by",
1226
+ "type": "text",
1227
+ "primaryKey": false,
1228
+ "notNull": false
1229
+ },
1230
+ "active_organization_id": {
1231
+ "name": "active_organization_id",
1232
+ "type": "text",
1233
+ "primaryKey": false,
1234
+ "notNull": false
1235
+ },
1119
1236
  "created_at": {
1120
1237
  "name": "created_at",
1121
1238
  "type": "timestamp",
@@ -1206,6 +1323,12 @@
1206
1323
  "primaryKey": false,
1207
1324
  "notNull": false
1208
1325
  },
1326
+ "deleted_at": {
1327
+ "name": "deleted_at",
1328
+ "type": "timestamp",
1329
+ "primaryKey": false,
1330
+ "notNull": false
1331
+ },
1209
1332
  "created_at": {
1210
1333
  "name": "created_at",
1211
1334
  "type": "timestamp",
@@ -1219,9 +1342,71 @@
1219
1342
  "primaryKey": false,
1220
1343
  "notNull": true,
1221
1344
  "default": "now()"
1345
+ },
1346
+ "onboarding_completed": {
1347
+ "name": "onboarding_completed",
1348
+ "type": "boolean",
1349
+ "primaryKey": false,
1350
+ "notNull": true,
1351
+ "default": false
1352
+ },
1353
+ "onboarding_step": {
1354
+ "name": "onboarding_step",
1355
+ "type": "text",
1356
+ "primaryKey": false,
1357
+ "notNull": false
1358
+ },
1359
+ "preferred_language": {
1360
+ "name": "preferred_language",
1361
+ "type": "text",
1362
+ "primaryKey": false,
1363
+ "notNull": true,
1364
+ "default": "'en'"
1365
+ },
1366
+ "role": {
1367
+ "name": "role",
1368
+ "type": "text",
1369
+ "primaryKey": false,
1370
+ "notNull": false
1371
+ },
1372
+ "banned": {
1373
+ "name": "banned",
1374
+ "type": "boolean",
1375
+ "primaryKey": false,
1376
+ "notNull": true,
1377
+ "default": false
1378
+ },
1379
+ "ban_reason": {
1380
+ "name": "ban_reason",
1381
+ "type": "text",
1382
+ "primaryKey": false,
1383
+ "notNull": false
1384
+ },
1385
+ "ban_expires": {
1386
+ "name": "ban_expires",
1387
+ "type": "timestamp",
1388
+ "primaryKey": false,
1389
+ "notNull": false
1390
+ }
1391
+ },
1392
+ "indexes": {
1393
+ "users_role_idx": {
1394
+ "name": "users_role_idx",
1395
+ "columns": [
1396
+ {
1397
+ "expression": "role",
1398
+ "isExpression": false,
1399
+ "asc": true,
1400
+ "nulls": "last"
1401
+ }
1402
+ ],
1403
+ "isUnique": false,
1404
+ "where": "\"users\".\"role\" IS NOT NULL",
1405
+ "concurrently": false,
1406
+ "method": "btree",
1407
+ "with": {}
1222
1408
  }
1223
1409
  },
1224
- "indexes": {},
1225
1410
  "foreignKeys": {},
1226
1411
  "compositePrimaryKeys": {},
1227
1412
  "uniqueConstraints": {
@@ -1286,6 +1471,53 @@
1286
1471
  "checkConstraints": {},
1287
1472
  "isRLSEnabled": false
1288
1473
  },
1474
+ "public.billing_settings": {
1475
+ "name": "billing_settings",
1476
+ "schema": "",
1477
+ "columns": {
1478
+ "id": {
1479
+ "name": "id",
1480
+ "type": "text",
1481
+ "primaryKey": true,
1482
+ "notNull": true
1483
+ },
1484
+ "currency": {
1485
+ "name": "currency",
1486
+ "type": "text",
1487
+ "primaryKey": false,
1488
+ "notNull": true,
1489
+ "default": "'USD'"
1490
+ },
1491
+ "usd_rate_micros": {
1492
+ "name": "usd_rate_micros",
1493
+ "type": "bigint",
1494
+ "primaryKey": false,
1495
+ "notNull": true,
1496
+ "default": 1000000
1497
+ },
1498
+ "margin_bp": {
1499
+ "name": "margin_bp",
1500
+ "type": "integer",
1501
+ "primaryKey": false,
1502
+ "notNull": true,
1503
+ "default": 40000
1504
+ },
1505
+ "updated_at": {
1506
+ "name": "updated_at",
1507
+ "type": "timestamp",
1508
+ "primaryKey": false,
1509
+ "notNull": true,
1510
+ "default": "now()"
1511
+ }
1512
+ },
1513
+ "indexes": {},
1514
+ "foreignKeys": {},
1515
+ "compositePrimaryKeys": {},
1516
+ "uniqueConstraints": {},
1517
+ "policies": {},
1518
+ "checkConstraints": {},
1519
+ "isRLSEnabled": false
1520
+ },
1289
1521
  "public.credit_balances": {
1290
1522
  "name": "credit_balances",
1291
1523
  "schema": "",
@@ -1302,27 +1534,34 @@
1302
1534
  "primaryKey": false,
1303
1535
  "notNull": true
1304
1536
  },
1305
- "balance": {
1306
- "name": "balance",
1307
- "type": "integer",
1537
+ "balance_micros": {
1538
+ "name": "balance_micros",
1539
+ "type": "bigint",
1308
1540
  "primaryKey": false,
1309
1541
  "notNull": true,
1310
1542
  "default": 0
1311
1543
  },
1312
- "total_purchased": {
1313
- "name": "total_purchased",
1314
- "type": "integer",
1544
+ "total_purchased_micros": {
1545
+ "name": "total_purchased_micros",
1546
+ "type": "bigint",
1315
1547
  "primaryKey": false,
1316
1548
  "notNull": true,
1317
1549
  "default": 0
1318
1550
  },
1319
- "total_used": {
1320
- "name": "total_used",
1321
- "type": "integer",
1551
+ "total_used_micros": {
1552
+ "name": "total_used_micros",
1553
+ "type": "bigint",
1322
1554
  "primaryKey": false,
1323
1555
  "notNull": true,
1324
1556
  "default": 0
1325
1557
  },
1558
+ "currency": {
1559
+ "name": "currency",
1560
+ "type": "text",
1561
+ "primaryKey": false,
1562
+ "notNull": true,
1563
+ "default": "'USD'"
1564
+ },
1326
1565
  "updated_at": {
1327
1566
  "name": "updated_at",
1328
1567
  "type": "timestamp",
@@ -1371,17 +1610,29 @@
1371
1610
  "primaryKey": false,
1372
1611
  "notNull": true
1373
1612
  },
1374
- "amount": {
1375
- "name": "amount",
1613
+ "price_minor": {
1614
+ "name": "price_minor",
1376
1615
  "type": "integer",
1377
1616
  "primaryKey": false,
1378
- "notNull": true
1617
+ "notNull": false
1379
1618
  },
1380
- "credits": {
1381
- "name": "credits",
1382
- "type": "integer",
1619
+ "price_currency": {
1620
+ "name": "price_currency",
1621
+ "type": "text",
1383
1622
  "primaryKey": false,
1384
- "notNull": true
1623
+ "notNull": false
1624
+ },
1625
+ "granted_micros": {
1626
+ "name": "granted_micros",
1627
+ "type": "bigint",
1628
+ "primaryKey": false,
1629
+ "notNull": false
1630
+ },
1631
+ "granted_currency": {
1632
+ "name": "granted_currency",
1633
+ "type": "text",
1634
+ "primaryKey": false,
1635
+ "notNull": false
1385
1636
  },
1386
1637
  "stripe_payment_intent_id": {
1387
1638
  "name": "stripe_payment_intent_id",
@@ -1444,6 +1695,121 @@
1444
1695
  "checkConstraints": {},
1445
1696
  "isRLSEnabled": false
1446
1697
  },
1698
+ "public.credit_reservations": {
1699
+ "name": "credit_reservations",
1700
+ "schema": "",
1701
+ "columns": {
1702
+ "id": {
1703
+ "name": "id",
1704
+ "type": "text",
1705
+ "primaryKey": true,
1706
+ "notNull": true
1707
+ },
1708
+ "workspace_id": {
1709
+ "name": "workspace_id",
1710
+ "type": "text",
1711
+ "primaryKey": false,
1712
+ "notNull": true
1713
+ },
1714
+ "request_id": {
1715
+ "name": "request_id",
1716
+ "type": "text",
1717
+ "primaryKey": false,
1718
+ "notNull": true
1719
+ },
1720
+ "estimated_micros": {
1721
+ "name": "estimated_micros",
1722
+ "type": "bigint",
1723
+ "primaryKey": false,
1724
+ "notNull": true,
1725
+ "default": 0
1726
+ },
1727
+ "currency": {
1728
+ "name": "currency",
1729
+ "type": "text",
1730
+ "primaryKey": false,
1731
+ "notNull": true,
1732
+ "default": "'USD'"
1733
+ },
1734
+ "status": {
1735
+ "name": "status",
1736
+ "type": "text",
1737
+ "primaryKey": false,
1738
+ "notNull": true,
1739
+ "default": "'active'"
1740
+ },
1741
+ "created_at": {
1742
+ "name": "created_at",
1743
+ "type": "timestamp",
1744
+ "primaryKey": false,
1745
+ "notNull": true,
1746
+ "default": "now()"
1747
+ },
1748
+ "expires_at": {
1749
+ "name": "expires_at",
1750
+ "type": "timestamp",
1751
+ "primaryKey": false,
1752
+ "notNull": true
1753
+ },
1754
+ "settled_at": {
1755
+ "name": "settled_at",
1756
+ "type": "timestamp",
1757
+ "primaryKey": false,
1758
+ "notNull": false
1759
+ }
1760
+ },
1761
+ "indexes": {
1762
+ "credit_reservations_active_idx": {
1763
+ "name": "credit_reservations_active_idx",
1764
+ "columns": [
1765
+ {
1766
+ "expression": "workspace_id",
1767
+ "isExpression": false,
1768
+ "asc": true,
1769
+ "nulls": "last"
1770
+ },
1771
+ {
1772
+ "expression": "status",
1773
+ "isExpression": false,
1774
+ "asc": true,
1775
+ "nulls": "last"
1776
+ },
1777
+ {
1778
+ "expression": "expires_at",
1779
+ "isExpression": false,
1780
+ "asc": true,
1781
+ "nulls": "last"
1782
+ }
1783
+ ],
1784
+ "isUnique": false,
1785
+ "concurrently": false,
1786
+ "method": "btree",
1787
+ "with": {}
1788
+ }
1789
+ },
1790
+ "foreignKeys": {
1791
+ "credit_reservations_workspace_id_organization_id_fk": {
1792
+ "name": "credit_reservations_workspace_id_organization_id_fk",
1793
+ "tableFrom": "credit_reservations",
1794
+ "tableTo": "organization",
1795
+ "columnsFrom": ["workspace_id"],
1796
+ "columnsTo": ["id"],
1797
+ "onDelete": "cascade",
1798
+ "onUpdate": "no action"
1799
+ }
1800
+ },
1801
+ "compositePrimaryKeys": {},
1802
+ "uniqueConstraints": {
1803
+ "credit_reservations_request_id_unique": {
1804
+ "name": "credit_reservations_request_id_unique",
1805
+ "nullsNotDistinct": false,
1806
+ "columns": ["request_id"]
1807
+ }
1808
+ },
1809
+ "policies": {},
1810
+ "checkConstraints": {},
1811
+ "isRLSEnabled": false
1812
+ },
1447
1813
  "public.finance_events": {
1448
1814
  "name": "finance_events",
1449
1815
  "schema": "",
@@ -1472,8 +1838,8 @@
1472
1838
  "primaryKey": false,
1473
1839
  "notNull": true
1474
1840
  },
1475
- "amount": {
1476
- "name": "amount",
1841
+ "amount_minor": {
1842
+ "name": "amount_minor",
1477
1843
  "type": "integer",
1478
1844
  "primaryKey": false,
1479
1845
  "notNull": false
@@ -1483,7 +1849,7 @@
1483
1849
  "type": "text",
1484
1850
  "primaryKey": false,
1485
1851
  "notNull": false,
1486
- "default": "'usd'"
1852
+ "default": "'USD'"
1487
1853
  },
1488
1854
  "metadata": {
1489
1855
  "name": "metadata",
@@ -1491,6 +1857,12 @@
1491
1857
  "primaryKey": false,
1492
1858
  "notNull": false
1493
1859
  },
1860
+ "claimed_at": {
1861
+ "name": "claimed_at",
1862
+ "type": "timestamp",
1863
+ "primaryKey": false,
1864
+ "notNull": false
1865
+ },
1494
1866
  "processed_at": {
1495
1867
  "name": "processed_at",
1496
1868
  "type": "timestamp",
@@ -1513,7 +1885,7 @@
1513
1885
  "tableTo": "organization",
1514
1886
  "columnsFrom": ["workspace_id"],
1515
1887
  "columnsTo": ["id"],
1516
- "onDelete": "no action",
1888
+ "onDelete": "set null",
1517
1889
  "onUpdate": "no action"
1518
1890
  }
1519
1891
  },
@@ -1529,8 +1901,8 @@
1529
1901
  "checkConstraints": {},
1530
1902
  "isRLSEnabled": false
1531
1903
  },
1532
- "public.plans": {
1533
- "name": "plans",
1904
+ "public.payments": {
1905
+ "name": "payments",
1534
1906
  "schema": "",
1535
1907
  "columns": {
1536
1908
  "id": {
@@ -1539,27 +1911,149 @@
1539
1911
  "primaryKey": true,
1540
1912
  "notNull": true
1541
1913
  },
1542
- "name": {
1543
- "name": "name",
1914
+ "provider": {
1915
+ "name": "provider",
1544
1916
  "type": "text",
1545
1917
  "primaryKey": false,
1546
1918
  "notNull": true
1547
1919
  },
1548
- "slug": {
1549
- "name": "slug",
1920
+ "invoice_id": {
1921
+ "name": "invoice_id",
1550
1922
  "type": "text",
1551
1923
  "primaryKey": false,
1552
1924
  "notNull": true
1553
1925
  },
1554
- "description": {
1555
- "name": "description",
1926
+ "workspace_id": {
1927
+ "name": "workspace_id",
1556
1928
  "type": "text",
1557
1929
  "primaryKey": false,
1558
- "notNull": false
1930
+ "notNull": true
1559
1931
  },
1560
- "price_monthly": {
1561
- "name": "price_monthly",
1562
- "type": "integer",
1932
+ "user_id": {
1933
+ "name": "user_id",
1934
+ "type": "text",
1935
+ "primaryKey": false,
1936
+ "notNull": false
1937
+ },
1938
+ "reference": {
1939
+ "name": "reference",
1940
+ "type": "text",
1941
+ "primaryKey": false,
1942
+ "notNull": true
1943
+ },
1944
+ "amount_minor": {
1945
+ "name": "amount_minor",
1946
+ "type": "integer",
1947
+ "primaryKey": false,
1948
+ "notNull": true
1949
+ },
1950
+ "currency": {
1951
+ "name": "currency",
1952
+ "type": "text",
1953
+ "primaryKey": false,
1954
+ "notNull": true
1955
+ },
1956
+ "status": {
1957
+ "name": "status",
1958
+ "type": "text",
1959
+ "primaryKey": false,
1960
+ "notNull": true,
1961
+ "default": "'pending'"
1962
+ },
1963
+ "fulfilled_at": {
1964
+ "name": "fulfilled_at",
1965
+ "type": "timestamp",
1966
+ "primaryKey": false,
1967
+ "notNull": false
1968
+ },
1969
+ "created_at": {
1970
+ "name": "created_at",
1971
+ "type": "timestamp",
1972
+ "primaryKey": false,
1973
+ "notNull": true,
1974
+ "default": "now()"
1975
+ }
1976
+ },
1977
+ "indexes": {
1978
+ "payments_workspace_id_idx": {
1979
+ "name": "payments_workspace_id_idx",
1980
+ "columns": [
1981
+ {
1982
+ "expression": "workspace_id",
1983
+ "isExpression": false,
1984
+ "asc": true,
1985
+ "nulls": "last"
1986
+ }
1987
+ ],
1988
+ "isUnique": false,
1989
+ "concurrently": false,
1990
+ "method": "btree",
1991
+ "with": {}
1992
+ }
1993
+ },
1994
+ "foreignKeys": {
1995
+ "payments_workspace_id_organization_id_fk": {
1996
+ "name": "payments_workspace_id_organization_id_fk",
1997
+ "tableFrom": "payments",
1998
+ "tableTo": "organization",
1999
+ "columnsFrom": ["workspace_id"],
2000
+ "columnsTo": ["id"],
2001
+ "onDelete": "cascade",
2002
+ "onUpdate": "no action"
2003
+ },
2004
+ "payments_user_id_users_id_fk": {
2005
+ "name": "payments_user_id_users_id_fk",
2006
+ "tableFrom": "payments",
2007
+ "tableTo": "users",
2008
+ "columnsFrom": ["user_id"],
2009
+ "columnsTo": ["id"],
2010
+ "onDelete": "set null",
2011
+ "onUpdate": "no action"
2012
+ }
2013
+ },
2014
+ "compositePrimaryKeys": {},
2015
+ "uniqueConstraints": {
2016
+ "payments_invoice_id_unique": {
2017
+ "name": "payments_invoice_id_unique",
2018
+ "nullsNotDistinct": false,
2019
+ "columns": ["invoice_id"]
2020
+ }
2021
+ },
2022
+ "policies": {},
2023
+ "checkConstraints": {},
2024
+ "isRLSEnabled": false
2025
+ },
2026
+ "public.plans": {
2027
+ "name": "plans",
2028
+ "schema": "",
2029
+ "columns": {
2030
+ "id": {
2031
+ "name": "id",
2032
+ "type": "text",
2033
+ "primaryKey": true,
2034
+ "notNull": true
2035
+ },
2036
+ "name": {
2037
+ "name": "name",
2038
+ "type": "text",
2039
+ "primaryKey": false,
2040
+ "notNull": true
2041
+ },
2042
+ "slug": {
2043
+ "name": "slug",
2044
+ "type": "text",
2045
+ "primaryKey": false,
2046
+ "notNull": true
2047
+ },
2048
+ "description": {
2049
+ "name": "description",
2050
+ "type": "text",
2051
+ "primaryKey": false,
2052
+ "notNull": false
2053
+ },
2054
+ "price_monthly": {
2055
+ "name": "price_monthly",
2056
+ "type": "integer",
1563
2057
  "primaryKey": false,
1564
2058
  "notNull": true
1565
2059
  },
@@ -1751,7 +2245,7 @@
1751
2245
  "tableTo": "plans",
1752
2246
  "columnsFrom": ["plan_id"],
1753
2247
  "columnsTo": ["id"],
1754
- "onDelete": "no action",
2248
+ "onDelete": "restrict",
1755
2249
  "onUpdate": "no action"
1756
2250
  }
1757
2251
  },
@@ -1836,8 +2330,8 @@
1836
2330
  "checkConstraints": {},
1837
2331
  "isRLSEnabled": false
1838
2332
  },
1839
- "public.monthly_usage": {
1840
- "name": "monthly_usage",
2333
+ "public.user_facts": {
2334
+ "name": "user_facts",
1841
2335
  "schema": "",
1842
2336
  "columns": {
1843
2337
  "id": {
@@ -1846,67 +2340,192 @@
1846
2340
  "primaryKey": true,
1847
2341
  "notNull": true
1848
2342
  },
2343
+ "user_id": {
2344
+ "name": "user_id",
2345
+ "type": "text",
2346
+ "primaryKey": false,
2347
+ "notNull": true
2348
+ },
1849
2349
  "workspace_id": {
1850
2350
  "name": "workspace_id",
1851
2351
  "type": "text",
1852
2352
  "primaryKey": false,
1853
2353
  "notNull": true
1854
2354
  },
1855
- "period_start": {
1856
- "name": "period_start",
1857
- "type": "timestamp",
2355
+ "category": {
2356
+ "name": "category",
2357
+ "type": "text",
1858
2358
  "primaryKey": false,
1859
2359
  "notNull": true
1860
2360
  },
1861
- "period_end": {
1862
- "name": "period_end",
1863
- "type": "timestamp",
2361
+ "key": {
2362
+ "name": "key",
2363
+ "type": "text",
1864
2364
  "primaryKey": false,
1865
2365
  "notNull": true
1866
2366
  },
1867
- "tokens_used": {
1868
- "name": "tokens_used",
1869
- "type": "integer",
2367
+ "value": {
2368
+ "name": "value",
2369
+ "type": "jsonb",
1870
2370
  "primaryKey": false,
1871
- "notNull": true,
1872
- "default": 0
2371
+ "notNull": true
1873
2372
  },
1874
- "request_count": {
1875
- "name": "request_count",
2373
+ "confidence": {
2374
+ "name": "confidence",
2375
+ "type": "double precision",
2376
+ "primaryKey": false,
2377
+ "notNull": true
2378
+ },
2379
+ "importance": {
2380
+ "name": "importance",
1876
2381
  "type": "integer",
1877
2382
  "primaryKey": false,
1878
2383
  "notNull": true,
1879
- "default": 0
2384
+ "default": 5
1880
2385
  },
1881
- "updated_at": {
1882
- "name": "updated_at",
2386
+ "source_product": {
2387
+ "name": "source_product",
2388
+ "type": "text",
2389
+ "primaryKey": false,
2390
+ "notNull": false
2391
+ },
2392
+ "source_session_id": {
2393
+ "name": "source_session_id",
2394
+ "type": "text",
2395
+ "primaryKey": false,
2396
+ "notNull": false
2397
+ },
2398
+ "source_message_id": {
2399
+ "name": "source_message_id",
2400
+ "type": "text",
2401
+ "primaryKey": false,
2402
+ "notNull": false
2403
+ },
2404
+ "extraction_method": {
2405
+ "name": "extraction_method",
2406
+ "type": "text",
2407
+ "primaryKey": false,
2408
+ "notNull": false
2409
+ },
2410
+ "created_at": {
2411
+ "name": "created_at",
1883
2412
  "type": "timestamp",
1884
2413
  "primaryKey": false,
1885
2414
  "notNull": true,
1886
2415
  "default": "now()"
2416
+ },
2417
+ "last_confirmed_at": {
2418
+ "name": "last_confirmed_at",
2419
+ "type": "timestamp",
2420
+ "primaryKey": false,
2421
+ "notNull": false
2422
+ },
2423
+ "expires_at": {
2424
+ "name": "expires_at",
2425
+ "type": "timestamp",
2426
+ "primaryKey": false,
2427
+ "notNull": false
1887
2428
  }
1888
2429
  },
1889
2430
  "indexes": {
1890
- "monthly_usage_workspace_id_idx": {
1891
- "name": "monthly_usage_workspace_id_idx",
2431
+ "user_facts_user_idx": {
2432
+ "name": "user_facts_user_idx",
2433
+ "columns": [
2434
+ {
2435
+ "expression": "user_id",
2436
+ "isExpression": false,
2437
+ "asc": true,
2438
+ "nulls": "last"
2439
+ }
2440
+ ],
2441
+ "isUnique": false,
2442
+ "concurrently": false,
2443
+ "method": "btree",
2444
+ "with": {}
2445
+ },
2446
+ "user_facts_workspace_idx": {
2447
+ "name": "user_facts_workspace_idx",
2448
+ "columns": [
2449
+ {
2450
+ "expression": "workspace_id",
2451
+ "isExpression": false,
2452
+ "asc": true,
2453
+ "nulls": "last"
2454
+ }
2455
+ ],
2456
+ "isUnique": false,
2457
+ "concurrently": false,
2458
+ "method": "btree",
2459
+ "with": {}
2460
+ },
2461
+ "user_facts_category_idx": {
2462
+ "name": "user_facts_category_idx",
1892
2463
  "columns": [
1893
2464
  {
1894
2465
  "expression": "workspace_id",
1895
2466
  "isExpression": false,
1896
2467
  "asc": true,
1897
2468
  "nulls": "last"
2469
+ },
2470
+ {
2471
+ "expression": "category",
2472
+ "isExpression": false,
2473
+ "asc": true,
2474
+ "nulls": "last"
1898
2475
  }
1899
2476
  ],
1900
2477
  "isUnique": false,
1901
2478
  "concurrently": false,
1902
2479
  "method": "btree",
1903
2480
  "with": {}
2481
+ },
2482
+ "user_facts_user_workspace_category_key_uniq": {
2483
+ "name": "user_facts_user_workspace_category_key_uniq",
2484
+ "columns": [
2485
+ {
2486
+ "expression": "user_id",
2487
+ "isExpression": false,
2488
+ "asc": true,
2489
+ "nulls": "last"
2490
+ },
2491
+ {
2492
+ "expression": "workspace_id",
2493
+ "isExpression": false,
2494
+ "asc": true,
2495
+ "nulls": "last"
2496
+ },
2497
+ {
2498
+ "expression": "category",
2499
+ "isExpression": false,
2500
+ "asc": true,
2501
+ "nulls": "last"
2502
+ },
2503
+ {
2504
+ "expression": "key",
2505
+ "isExpression": false,
2506
+ "asc": true,
2507
+ "nulls": "last"
2508
+ }
2509
+ ],
2510
+ "isUnique": true,
2511
+ "concurrently": false,
2512
+ "method": "btree",
2513
+ "with": {}
1904
2514
  }
1905
2515
  },
1906
2516
  "foreignKeys": {
1907
- "monthly_usage_workspace_id_organization_id_fk": {
1908
- "name": "monthly_usage_workspace_id_organization_id_fk",
1909
- "tableFrom": "monthly_usage",
2517
+ "user_facts_user_id_users_id_fk": {
2518
+ "name": "user_facts_user_id_users_id_fk",
2519
+ "tableFrom": "user_facts",
2520
+ "tableTo": "users",
2521
+ "columnsFrom": ["user_id"],
2522
+ "columnsTo": ["id"],
2523
+ "onDelete": "cascade",
2524
+ "onUpdate": "no action"
2525
+ },
2526
+ "user_facts_workspace_id_organization_id_fk": {
2527
+ "name": "user_facts_workspace_id_organization_id_fk",
2528
+ "tableFrom": "user_facts",
1910
2529
  "tableTo": "organization",
1911
2530
  "columnsFrom": ["workspace_id"],
1912
2531
  "columnsTo": ["id"],
@@ -1915,19 +2534,13 @@
1915
2534
  }
1916
2535
  },
1917
2536
  "compositePrimaryKeys": {},
1918
- "uniqueConstraints": {
1919
- "monthly_usage_workspace_period_unique": {
1920
- "name": "monthly_usage_workspace_period_unique",
1921
- "nullsNotDistinct": false,
1922
- "columns": ["workspace_id", "period_start"]
1923
- }
1924
- },
2537
+ "uniqueConstraints": {},
1925
2538
  "policies": {},
1926
2539
  "checkConstraints": {},
1927
2540
  "isRLSEnabled": false
1928
2541
  },
1929
- "public.notification_history": {
1930
- "name": "notification_history",
2542
+ "public.user_memories": {
2543
+ "name": "user_memories",
1931
2544
  "schema": "",
1932
2545
  "columns": {
1933
2546
  "id": {
@@ -1936,48 +2549,1241 @@
1936
2549
  "primaryKey": true,
1937
2550
  "notNull": true
1938
2551
  },
1939
- "workspace_id": {
1940
- "name": "workspace_id",
2552
+ "user_id": {
2553
+ "name": "user_id",
1941
2554
  "type": "text",
1942
2555
  "primaryKey": false,
1943
2556
  "notNull": true
1944
2557
  },
1945
- "type": {
1946
- "name": "type",
2558
+ "workspace_id": {
2559
+ "name": "workspace_id",
1947
2560
  "type": "text",
1948
2561
  "primaryKey": false,
1949
2562
  "notNull": true
1950
2563
  },
1951
- "period_key": {
2564
+ "kind": {
2565
+ "name": "kind",
2566
+ "type": "text",
2567
+ "primaryKey": false,
2568
+ "notNull": true
2569
+ },
2570
+ "content": {
2571
+ "name": "content",
2572
+ "type": "text",
2573
+ "primaryKey": false,
2574
+ "notNull": true
2575
+ },
2576
+ "embedding": {
2577
+ "name": "embedding",
2578
+ "type": "vector(1536)",
2579
+ "primaryKey": false,
2580
+ "notNull": false
2581
+ },
2582
+ "source_product": {
2583
+ "name": "source_product",
2584
+ "type": "text",
2585
+ "primaryKey": false,
2586
+ "notNull": false
2587
+ },
2588
+ "source_session_id": {
2589
+ "name": "source_session_id",
2590
+ "type": "text",
2591
+ "primaryKey": false,
2592
+ "notNull": false
2593
+ },
2594
+ "source_message_ids": {
2595
+ "name": "source_message_ids",
2596
+ "type": "text[]",
2597
+ "primaryKey": false,
2598
+ "notNull": false
2599
+ },
2600
+ "importance": {
2601
+ "name": "importance",
2602
+ "type": "integer",
2603
+ "primaryKey": false,
2604
+ "notNull": true,
2605
+ "default": 5
2606
+ },
2607
+ "decay_factor": {
2608
+ "name": "decay_factor",
2609
+ "type": "double precision",
2610
+ "primaryKey": false,
2611
+ "notNull": true,
2612
+ "default": 1
2613
+ },
2614
+ "metadata": {
2615
+ "name": "metadata",
2616
+ "type": "jsonb",
2617
+ "primaryKey": false,
2618
+ "notNull": false
2619
+ },
2620
+ "created_at": {
2621
+ "name": "created_at",
2622
+ "type": "timestamp",
2623
+ "primaryKey": false,
2624
+ "notNull": true,
2625
+ "default": "now()"
2626
+ }
2627
+ },
2628
+ "indexes": {
2629
+ "user_memories_user_idx": {
2630
+ "name": "user_memories_user_idx",
2631
+ "columns": [
2632
+ {
2633
+ "expression": "user_id",
2634
+ "isExpression": false,
2635
+ "asc": true,
2636
+ "nulls": "last"
2637
+ }
2638
+ ],
2639
+ "isUnique": false,
2640
+ "concurrently": false,
2641
+ "method": "btree",
2642
+ "with": {}
2643
+ },
2644
+ "user_memories_workspace_idx": {
2645
+ "name": "user_memories_workspace_idx",
2646
+ "columns": [
2647
+ {
2648
+ "expression": "workspace_id",
2649
+ "isExpression": false,
2650
+ "asc": true,
2651
+ "nulls": "last"
2652
+ }
2653
+ ],
2654
+ "isUnique": false,
2655
+ "concurrently": false,
2656
+ "method": "btree",
2657
+ "with": {}
2658
+ },
2659
+ "user_memories_kind_idx": {
2660
+ "name": "user_memories_kind_idx",
2661
+ "columns": [
2662
+ {
2663
+ "expression": "workspace_id",
2664
+ "isExpression": false,
2665
+ "asc": true,
2666
+ "nulls": "last"
2667
+ },
2668
+ {
2669
+ "expression": "kind",
2670
+ "isExpression": false,
2671
+ "asc": true,
2672
+ "nulls": "last"
2673
+ }
2674
+ ],
2675
+ "isUnique": false,
2676
+ "concurrently": false,
2677
+ "method": "btree",
2678
+ "with": {}
2679
+ }
2680
+ },
2681
+ "foreignKeys": {
2682
+ "user_memories_user_id_users_id_fk": {
2683
+ "name": "user_memories_user_id_users_id_fk",
2684
+ "tableFrom": "user_memories",
2685
+ "tableTo": "users",
2686
+ "columnsFrom": ["user_id"],
2687
+ "columnsTo": ["id"],
2688
+ "onDelete": "cascade",
2689
+ "onUpdate": "no action"
2690
+ },
2691
+ "user_memories_workspace_id_organization_id_fk": {
2692
+ "name": "user_memories_workspace_id_organization_id_fk",
2693
+ "tableFrom": "user_memories",
2694
+ "tableTo": "organization",
2695
+ "columnsFrom": ["workspace_id"],
2696
+ "columnsTo": ["id"],
2697
+ "onDelete": "cascade",
2698
+ "onUpdate": "no action"
2699
+ }
2700
+ },
2701
+ "compositePrimaryKeys": {},
2702
+ "uniqueConstraints": {},
2703
+ "policies": {},
2704
+ "checkConstraints": {},
2705
+ "isRLSEnabled": false
2706
+ },
2707
+ "public.user_memory_audit": {
2708
+ "name": "user_memory_audit",
2709
+ "schema": "",
2710
+ "columns": {
2711
+ "id": {
2712
+ "name": "id",
2713
+ "type": "text",
2714
+ "primaryKey": true,
2715
+ "notNull": true
2716
+ },
2717
+ "user_id": {
2718
+ "name": "user_id",
2719
+ "type": "text",
2720
+ "primaryKey": false,
2721
+ "notNull": true
2722
+ },
2723
+ "workspace_id": {
2724
+ "name": "workspace_id",
2725
+ "type": "text",
2726
+ "primaryKey": false,
2727
+ "notNull": true
2728
+ },
2729
+ "target_kind": {
2730
+ "name": "target_kind",
2731
+ "type": "text",
2732
+ "primaryKey": false,
2733
+ "notNull": true
2734
+ },
2735
+ "target_id": {
2736
+ "name": "target_id",
2737
+ "type": "text",
2738
+ "primaryKey": false,
2739
+ "notNull": true
2740
+ },
2741
+ "action": {
2742
+ "name": "action",
2743
+ "type": "text",
2744
+ "primaryKey": false,
2745
+ "notNull": true
2746
+ },
2747
+ "actor_kind": {
2748
+ "name": "actor_kind",
2749
+ "type": "text",
2750
+ "primaryKey": false,
2751
+ "notNull": true
2752
+ },
2753
+ "actor_id": {
2754
+ "name": "actor_id",
2755
+ "type": "text",
2756
+ "primaryKey": false,
2757
+ "notNull": false
2758
+ },
2759
+ "before_value": {
2760
+ "name": "before_value",
2761
+ "type": "jsonb",
2762
+ "primaryKey": false,
2763
+ "notNull": false
2764
+ },
2765
+ "after_value": {
2766
+ "name": "after_value",
2767
+ "type": "jsonb",
2768
+ "primaryKey": false,
2769
+ "notNull": false
2770
+ },
2771
+ "reason": {
2772
+ "name": "reason",
2773
+ "type": "text",
2774
+ "primaryKey": false,
2775
+ "notNull": false
2776
+ },
2777
+ "created_at": {
2778
+ "name": "created_at",
2779
+ "type": "timestamp",
2780
+ "primaryKey": false,
2781
+ "notNull": true,
2782
+ "default": "now()"
2783
+ }
2784
+ },
2785
+ "indexes": {
2786
+ "user_memory_audit_user_idx": {
2787
+ "name": "user_memory_audit_user_idx",
2788
+ "columns": [
2789
+ {
2790
+ "expression": "user_id",
2791
+ "isExpression": false,
2792
+ "asc": true,
2793
+ "nulls": "last"
2794
+ }
2795
+ ],
2796
+ "isUnique": false,
2797
+ "concurrently": false,
2798
+ "method": "btree",
2799
+ "with": {}
2800
+ },
2801
+ "user_memory_audit_workspace_idx": {
2802
+ "name": "user_memory_audit_workspace_idx",
2803
+ "columns": [
2804
+ {
2805
+ "expression": "workspace_id",
2806
+ "isExpression": false,
2807
+ "asc": true,
2808
+ "nulls": "last"
2809
+ }
2810
+ ],
2811
+ "isUnique": false,
2812
+ "concurrently": false,
2813
+ "method": "btree",
2814
+ "with": {}
2815
+ },
2816
+ "user_memory_audit_target_idx": {
2817
+ "name": "user_memory_audit_target_idx",
2818
+ "columns": [
2819
+ {
2820
+ "expression": "target_kind",
2821
+ "isExpression": false,
2822
+ "asc": true,
2823
+ "nulls": "last"
2824
+ },
2825
+ {
2826
+ "expression": "target_id",
2827
+ "isExpression": false,
2828
+ "asc": true,
2829
+ "nulls": "last"
2830
+ }
2831
+ ],
2832
+ "isUnique": false,
2833
+ "concurrently": false,
2834
+ "method": "btree",
2835
+ "with": {}
2836
+ }
2837
+ },
2838
+ "foreignKeys": {
2839
+ "user_memory_audit_user_id_users_id_fk": {
2840
+ "name": "user_memory_audit_user_id_users_id_fk",
2841
+ "tableFrom": "user_memory_audit",
2842
+ "tableTo": "users",
2843
+ "columnsFrom": ["user_id"],
2844
+ "columnsTo": ["id"],
2845
+ "onDelete": "cascade",
2846
+ "onUpdate": "no action"
2847
+ },
2848
+ "user_memory_audit_workspace_id_organization_id_fk": {
2849
+ "name": "user_memory_audit_workspace_id_organization_id_fk",
2850
+ "tableFrom": "user_memory_audit",
2851
+ "tableTo": "organization",
2852
+ "columnsFrom": ["workspace_id"],
2853
+ "columnsTo": ["id"],
2854
+ "onDelete": "cascade",
2855
+ "onUpdate": "no action"
2856
+ }
2857
+ },
2858
+ "compositePrimaryKeys": {},
2859
+ "uniqueConstraints": {},
2860
+ "policies": {},
2861
+ "checkConstraints": {},
2862
+ "isRLSEnabled": false
2863
+ },
2864
+ "public.user_profile_snapshots": {
2865
+ "name": "user_profile_snapshots",
2866
+ "schema": "",
2867
+ "columns": {
2868
+ "user_id": {
2869
+ "name": "user_id",
2870
+ "type": "text",
2871
+ "primaryKey": false,
2872
+ "notNull": true
2873
+ },
2874
+ "workspace_id": {
2875
+ "name": "workspace_id",
2876
+ "type": "text",
2877
+ "primaryKey": false,
2878
+ "notNull": true
2879
+ },
2880
+ "version": {
2881
+ "name": "version",
2882
+ "type": "integer",
2883
+ "primaryKey": false,
2884
+ "notNull": true
2885
+ },
2886
+ "summary": {
2887
+ "name": "summary",
2888
+ "type": "text",
2889
+ "primaryKey": false,
2890
+ "notNull": true
2891
+ },
2892
+ "summary_en": {
2893
+ "name": "summary_en",
2894
+ "type": "text",
2895
+ "primaryKey": false,
2896
+ "notNull": false
2897
+ },
2898
+ "summary_mn": {
2899
+ "name": "summary_mn",
2900
+ "type": "text",
2901
+ "primaryKey": false,
2902
+ "notNull": false
2903
+ },
2904
+ "facts_digest": {
2905
+ "name": "facts_digest",
2906
+ "type": "jsonb",
2907
+ "primaryKey": false,
2908
+ "notNull": true
2909
+ },
2910
+ "active_goals": {
2911
+ "name": "active_goals",
2912
+ "type": "jsonb",
2913
+ "primaryKey": false,
2914
+ "notNull": false
2915
+ },
2916
+ "personality_signals": {
2917
+ "name": "personality_signals",
2918
+ "type": "jsonb",
2919
+ "primaryKey": false,
2920
+ "notNull": false
2921
+ },
2922
+ "relationship_notes": {
2923
+ "name": "relationship_notes",
2924
+ "type": "jsonb",
2925
+ "primaryKey": false,
2926
+ "notNull": false
2927
+ },
2928
+ "synthesized_by_model": {
2929
+ "name": "synthesized_by_model",
2930
+ "type": "text",
2931
+ "primaryKey": false,
2932
+ "notNull": false
2933
+ },
2934
+ "synthesized_at": {
2935
+ "name": "synthesized_at",
2936
+ "type": "timestamp",
2937
+ "primaryKey": false,
2938
+ "notNull": true,
2939
+ "default": "now()"
2940
+ },
2941
+ "next_synthesis_at": {
2942
+ "name": "next_synthesis_at",
2943
+ "type": "timestamp",
2944
+ "primaryKey": false,
2945
+ "notNull": false
2946
+ },
2947
+ "trigger_reason": {
2948
+ "name": "trigger_reason",
2949
+ "type": "text",
2950
+ "primaryKey": false,
2951
+ "notNull": false
2952
+ }
2953
+ },
2954
+ "indexes": {
2955
+ "user_profile_snapshots_workspace_idx": {
2956
+ "name": "user_profile_snapshots_workspace_idx",
2957
+ "columns": [
2958
+ {
2959
+ "expression": "workspace_id",
2960
+ "isExpression": false,
2961
+ "asc": true,
2962
+ "nulls": "last"
2963
+ }
2964
+ ],
2965
+ "isUnique": false,
2966
+ "concurrently": false,
2967
+ "method": "btree",
2968
+ "with": {}
2969
+ }
2970
+ },
2971
+ "foreignKeys": {
2972
+ "user_profile_snapshots_user_id_users_id_fk": {
2973
+ "name": "user_profile_snapshots_user_id_users_id_fk",
2974
+ "tableFrom": "user_profile_snapshots",
2975
+ "tableTo": "users",
2976
+ "columnsFrom": ["user_id"],
2977
+ "columnsTo": ["id"],
2978
+ "onDelete": "cascade",
2979
+ "onUpdate": "no action"
2980
+ },
2981
+ "user_profile_snapshots_workspace_id_organization_id_fk": {
2982
+ "name": "user_profile_snapshots_workspace_id_organization_id_fk",
2983
+ "tableFrom": "user_profile_snapshots",
2984
+ "tableTo": "organization",
2985
+ "columnsFrom": ["workspace_id"],
2986
+ "columnsTo": ["id"],
2987
+ "onDelete": "cascade",
2988
+ "onUpdate": "no action"
2989
+ }
2990
+ },
2991
+ "compositePrimaryKeys": {
2992
+ "user_profile_snapshots_user_id_workspace_id_pk": {
2993
+ "name": "user_profile_snapshots_user_id_workspace_id_pk",
2994
+ "columns": ["user_id", "workspace_id"]
2995
+ }
2996
+ },
2997
+ "uniqueConstraints": {},
2998
+ "policies": {},
2999
+ "checkConstraints": {},
3000
+ "isRLSEnabled": false
3001
+ },
3002
+ "public.monthly_usage": {
3003
+ "name": "monthly_usage",
3004
+ "schema": "",
3005
+ "columns": {
3006
+ "id": {
3007
+ "name": "id",
3008
+ "type": "text",
3009
+ "primaryKey": true,
3010
+ "notNull": true
3011
+ },
3012
+ "workspace_id": {
3013
+ "name": "workspace_id",
3014
+ "type": "text",
3015
+ "primaryKey": false,
3016
+ "notNull": true
3017
+ },
3018
+ "period_start": {
3019
+ "name": "period_start",
3020
+ "type": "timestamp",
3021
+ "primaryKey": false,
3022
+ "notNull": true
3023
+ },
3024
+ "period_end": {
3025
+ "name": "period_end",
3026
+ "type": "timestamp",
3027
+ "primaryKey": false,
3028
+ "notNull": true
3029
+ },
3030
+ "tokens_used": {
3031
+ "name": "tokens_used",
3032
+ "type": "integer",
3033
+ "primaryKey": false,
3034
+ "notNull": true,
3035
+ "default": 0
3036
+ },
3037
+ "allowance_used_micros": {
3038
+ "name": "allowance_used_micros",
3039
+ "type": "bigint",
3040
+ "primaryKey": false,
3041
+ "notNull": true,
3042
+ "default": 0
3043
+ },
3044
+ "currency": {
3045
+ "name": "currency",
3046
+ "type": "text",
3047
+ "primaryKey": false,
3048
+ "notNull": true,
3049
+ "default": "'USD'"
3050
+ },
3051
+ "request_count": {
3052
+ "name": "request_count",
3053
+ "type": "integer",
3054
+ "primaryKey": false,
3055
+ "notNull": true,
3056
+ "default": 0
3057
+ },
3058
+ "updated_at": {
3059
+ "name": "updated_at",
3060
+ "type": "timestamp",
3061
+ "primaryKey": false,
3062
+ "notNull": true,
3063
+ "default": "now()"
3064
+ }
3065
+ },
3066
+ "indexes": {
3067
+ "monthly_usage_workspace_id_idx": {
3068
+ "name": "monthly_usage_workspace_id_idx",
3069
+ "columns": [
3070
+ {
3071
+ "expression": "workspace_id",
3072
+ "isExpression": false,
3073
+ "asc": true,
3074
+ "nulls": "last"
3075
+ }
3076
+ ],
3077
+ "isUnique": false,
3078
+ "concurrently": false,
3079
+ "method": "btree",
3080
+ "with": {}
3081
+ }
3082
+ },
3083
+ "foreignKeys": {
3084
+ "monthly_usage_workspace_id_organization_id_fk": {
3085
+ "name": "monthly_usage_workspace_id_organization_id_fk",
3086
+ "tableFrom": "monthly_usage",
3087
+ "tableTo": "organization",
3088
+ "columnsFrom": ["workspace_id"],
3089
+ "columnsTo": ["id"],
3090
+ "onDelete": "cascade",
3091
+ "onUpdate": "no action"
3092
+ }
3093
+ },
3094
+ "compositePrimaryKeys": {},
3095
+ "uniqueConstraints": {
3096
+ "monthly_usage_workspace_period_unique": {
3097
+ "name": "monthly_usage_workspace_period_unique",
3098
+ "nullsNotDistinct": false,
3099
+ "columns": ["workspace_id", "period_start"]
3100
+ }
3101
+ },
3102
+ "policies": {},
3103
+ "checkConstraints": {},
3104
+ "isRLSEnabled": false
3105
+ },
3106
+ "public.notification_history": {
3107
+ "name": "notification_history",
3108
+ "schema": "",
3109
+ "columns": {
3110
+ "id": {
3111
+ "name": "id",
3112
+ "type": "text",
3113
+ "primaryKey": true,
3114
+ "notNull": true
3115
+ },
3116
+ "workspace_id": {
3117
+ "name": "workspace_id",
3118
+ "type": "text",
3119
+ "primaryKey": false,
3120
+ "notNull": true
3121
+ },
3122
+ "type": {
3123
+ "name": "type",
3124
+ "type": "text",
3125
+ "primaryKey": false,
3126
+ "notNull": true
3127
+ },
3128
+ "period_key": {
1952
3129
  "name": "period_key",
1953
3130
  "type": "text",
1954
3131
  "primaryKey": false,
1955
3132
  "notNull": true
1956
3133
  },
1957
- "sent_at": {
1958
- "name": "sent_at",
1959
- "type": "timestamp",
3134
+ "sent_at": {
3135
+ "name": "sent_at",
3136
+ "type": "timestamp",
3137
+ "primaryKey": false,
3138
+ "notNull": true,
3139
+ "default": "now()"
3140
+ },
3141
+ "channel": {
3142
+ "name": "channel",
3143
+ "type": "text",
3144
+ "primaryKey": false,
3145
+ "notNull": true,
3146
+ "default": "'console'"
3147
+ },
3148
+ "metadata": {
3149
+ "name": "metadata",
3150
+ "type": "text",
3151
+ "primaryKey": false,
3152
+ "notNull": false
3153
+ }
3154
+ },
3155
+ "indexes": {
3156
+ "notification_history_workspace_id_idx": {
3157
+ "name": "notification_history_workspace_id_idx",
3158
+ "columns": [
3159
+ {
3160
+ "expression": "workspace_id",
3161
+ "isExpression": false,
3162
+ "asc": true,
3163
+ "nulls": "last"
3164
+ }
3165
+ ],
3166
+ "isUnique": false,
3167
+ "concurrently": false,
3168
+ "method": "btree",
3169
+ "with": {}
3170
+ }
3171
+ },
3172
+ "foreignKeys": {
3173
+ "notification_history_workspace_id_organization_id_fk": {
3174
+ "name": "notification_history_workspace_id_organization_id_fk",
3175
+ "tableFrom": "notification_history",
3176
+ "tableTo": "organization",
3177
+ "columnsFrom": ["workspace_id"],
3178
+ "columnsTo": ["id"],
3179
+ "onDelete": "cascade",
3180
+ "onUpdate": "no action"
3181
+ }
3182
+ },
3183
+ "compositePrimaryKeys": {},
3184
+ "uniqueConstraints": {
3185
+ "notification_history_dedup_unique": {
3186
+ "name": "notification_history_dedup_unique",
3187
+ "nullsNotDistinct": false,
3188
+ "columns": ["workspace_id", "type", "period_key"]
3189
+ }
3190
+ },
3191
+ "policies": {},
3192
+ "checkConstraints": {},
3193
+ "isRLSEnabled": false
3194
+ },
3195
+ "public.rate_limit_entries": {
3196
+ "name": "rate_limit_entries",
3197
+ "schema": "",
3198
+ "columns": {
3199
+ "id": {
3200
+ "name": "id",
3201
+ "type": "text",
3202
+ "primaryKey": true,
3203
+ "notNull": true
3204
+ },
3205
+ "workspace_id": {
3206
+ "name": "workspace_id",
3207
+ "type": "text",
3208
+ "primaryKey": false,
3209
+ "notNull": true
3210
+ },
3211
+ "endpoint": {
3212
+ "name": "endpoint",
3213
+ "type": "text",
3214
+ "primaryKey": false,
3215
+ "notNull": true,
3216
+ "default": "'chat'"
3217
+ },
3218
+ "requested_at": {
3219
+ "name": "requested_at",
3220
+ "type": "timestamp",
3221
+ "primaryKey": false,
3222
+ "notNull": true,
3223
+ "default": "now()"
3224
+ },
3225
+ "minute_bucket": {
3226
+ "name": "minute_bucket",
3227
+ "type": "timestamp",
3228
+ "primaryKey": false,
3229
+ "notNull": true
3230
+ },
3231
+ "count": {
3232
+ "name": "count",
3233
+ "type": "integer",
3234
+ "primaryKey": false,
3235
+ "notNull": true,
3236
+ "default": 1
3237
+ }
3238
+ },
3239
+ "indexes": {
3240
+ "rate_limit_entries_window_idx": {
3241
+ "name": "rate_limit_entries_window_idx",
3242
+ "columns": [
3243
+ {
3244
+ "expression": "workspace_id",
3245
+ "isExpression": false,
3246
+ "asc": true,
3247
+ "nulls": "last"
3248
+ },
3249
+ {
3250
+ "expression": "endpoint",
3251
+ "isExpression": false,
3252
+ "asc": true,
3253
+ "nulls": "last"
3254
+ },
3255
+ {
3256
+ "expression": "requested_at",
3257
+ "isExpression": false,
3258
+ "asc": true,
3259
+ "nulls": "last"
3260
+ }
3261
+ ],
3262
+ "isUnique": false,
3263
+ "concurrently": false,
3264
+ "method": "btree",
3265
+ "with": {}
3266
+ }
3267
+ },
3268
+ "foreignKeys": {
3269
+ "rate_limit_entries_workspace_id_organization_id_fk": {
3270
+ "name": "rate_limit_entries_workspace_id_organization_id_fk",
3271
+ "tableFrom": "rate_limit_entries",
3272
+ "tableTo": "organization",
3273
+ "columnsFrom": ["workspace_id"],
3274
+ "columnsTo": ["id"],
3275
+ "onDelete": "cascade",
3276
+ "onUpdate": "no action"
3277
+ }
3278
+ },
3279
+ "compositePrimaryKeys": {},
3280
+ "uniqueConstraints": {
3281
+ "rate_limit_entries_unique_bucket_idx": {
3282
+ "name": "rate_limit_entries_unique_bucket_idx",
3283
+ "nullsNotDistinct": false,
3284
+ "columns": ["workspace_id", "endpoint", "minute_bucket"]
3285
+ }
3286
+ },
3287
+ "policies": {},
3288
+ "checkConstraints": {},
3289
+ "isRLSEnabled": false
3290
+ },
3291
+ "public.trial_credits": {
3292
+ "name": "trial_credits",
3293
+ "schema": "",
3294
+ "columns": {
3295
+ "id": {
3296
+ "name": "id",
3297
+ "type": "text",
3298
+ "primaryKey": true,
3299
+ "notNull": true
3300
+ },
3301
+ "workspace_id": {
3302
+ "name": "workspace_id",
3303
+ "type": "text",
3304
+ "primaryKey": false,
3305
+ "notNull": true
3306
+ },
3307
+ "initial_credits": {
3308
+ "name": "initial_credits",
3309
+ "type": "integer",
3310
+ "primaryKey": false,
3311
+ "notNull": true,
3312
+ "default": 100000
3313
+ },
3314
+ "credits_used": {
3315
+ "name": "credits_used",
3316
+ "type": "integer",
3317
+ "primaryKey": false,
3318
+ "notNull": true,
3319
+ "default": 0
3320
+ },
3321
+ "credits_remaining": {
3322
+ "name": "credits_remaining",
3323
+ "type": "integer",
3324
+ "primaryKey": false,
3325
+ "notNull": true,
3326
+ "default": 100000
3327
+ },
3328
+ "initial_micros": {
3329
+ "name": "initial_micros",
3330
+ "type": "bigint",
3331
+ "primaryKey": false,
3332
+ "notNull": true,
3333
+ "default": 0
3334
+ },
3335
+ "used_micros": {
3336
+ "name": "used_micros",
3337
+ "type": "bigint",
3338
+ "primaryKey": false,
3339
+ "notNull": true,
3340
+ "default": 0
3341
+ },
3342
+ "remaining_micros": {
3343
+ "name": "remaining_micros",
3344
+ "type": "bigint",
3345
+ "primaryKey": false,
3346
+ "notNull": true,
3347
+ "default": 0
3348
+ },
3349
+ "currency": {
3350
+ "name": "currency",
3351
+ "type": "text",
3352
+ "primaryKey": false,
3353
+ "notNull": true,
3354
+ "default": "'USD'"
3355
+ },
3356
+ "status": {
3357
+ "name": "status",
3358
+ "type": "text",
3359
+ "primaryKey": false,
3360
+ "notNull": true,
3361
+ "default": "'active'"
3362
+ },
3363
+ "provisioned_at": {
3364
+ "name": "provisioned_at",
3365
+ "type": "timestamp",
3366
+ "primaryKey": false,
3367
+ "notNull": true,
3368
+ "default": "now()"
3369
+ },
3370
+ "trial_end_date": {
3371
+ "name": "trial_end_date",
3372
+ "type": "timestamp",
3373
+ "primaryKey": false,
3374
+ "notNull": false
3375
+ },
3376
+ "depleted_at": {
3377
+ "name": "depleted_at",
3378
+ "type": "timestamp",
3379
+ "primaryKey": false,
3380
+ "notNull": false
3381
+ },
3382
+ "converted_at": {
3383
+ "name": "converted_at",
3384
+ "type": "timestamp",
3385
+ "primaryKey": false,
3386
+ "notNull": false
3387
+ },
3388
+ "created_by_ip": {
3389
+ "name": "created_by_ip",
3390
+ "type": "text",
3391
+ "primaryKey": false,
3392
+ "notNull": false
3393
+ },
3394
+ "created_by_email": {
3395
+ "name": "created_by_email",
3396
+ "type": "text",
3397
+ "primaryKey": false,
3398
+ "notNull": false
3399
+ },
3400
+ "normalized_email": {
3401
+ "name": "normalized_email",
3402
+ "type": "text",
3403
+ "primaryKey": false,
3404
+ "notNull": false
3405
+ }
3406
+ },
3407
+ "indexes": {
3408
+ "trial_credits_expiry_idx": {
3409
+ "name": "trial_credits_expiry_idx",
3410
+ "columns": [
3411
+ {
3412
+ "expression": "status",
3413
+ "isExpression": false,
3414
+ "asc": true,
3415
+ "nulls": "last"
3416
+ },
3417
+ {
3418
+ "expression": "trial_end_date",
3419
+ "isExpression": false,
3420
+ "asc": true,
3421
+ "nulls": "last"
3422
+ }
3423
+ ],
3424
+ "isUnique": false,
3425
+ "concurrently": false,
3426
+ "method": "btree",
3427
+ "with": {}
3428
+ },
3429
+ "trial_credits_normalized_email_idx": {
3430
+ "name": "trial_credits_normalized_email_idx",
3431
+ "columns": [
3432
+ {
3433
+ "expression": "normalized_email",
3434
+ "isExpression": false,
3435
+ "asc": true,
3436
+ "nulls": "last"
3437
+ }
3438
+ ],
3439
+ "isUnique": false,
3440
+ "concurrently": false,
3441
+ "method": "btree",
3442
+ "with": {}
3443
+ }
3444
+ },
3445
+ "foreignKeys": {
3446
+ "trial_credits_workspace_id_organization_id_fk": {
3447
+ "name": "trial_credits_workspace_id_organization_id_fk",
3448
+ "tableFrom": "trial_credits",
3449
+ "tableTo": "organization",
3450
+ "columnsFrom": ["workspace_id"],
3451
+ "columnsTo": ["id"],
3452
+ "onDelete": "cascade",
3453
+ "onUpdate": "no action"
3454
+ }
3455
+ },
3456
+ "compositePrimaryKeys": {},
3457
+ "uniqueConstraints": {
3458
+ "trial_credits_workspace_id_unique": {
3459
+ "name": "trial_credits_workspace_id_unique",
3460
+ "nullsNotDistinct": false,
3461
+ "columns": ["workspace_id"]
3462
+ }
3463
+ },
3464
+ "policies": {},
3465
+ "checkConstraints": {},
3466
+ "isRLSEnabled": false
3467
+ },
3468
+ "public.usage_records": {
3469
+ "name": "usage_records",
3470
+ "schema": "",
3471
+ "columns": {
3472
+ "id": {
3473
+ "name": "id",
3474
+ "type": "text",
3475
+ "primaryKey": true,
3476
+ "notNull": true
3477
+ },
3478
+ "workspace_id": {
3479
+ "name": "workspace_id",
3480
+ "type": "text",
3481
+ "primaryKey": false,
3482
+ "notNull": true
3483
+ },
3484
+ "user_id": {
3485
+ "name": "user_id",
3486
+ "type": "text",
3487
+ "primaryKey": false,
3488
+ "notNull": true
3489
+ },
3490
+ "type": {
3491
+ "name": "type",
3492
+ "type": "text",
3493
+ "primaryKey": false,
3494
+ "notNull": true
3495
+ },
3496
+ "model": {
3497
+ "name": "model",
3498
+ "type": "text",
3499
+ "primaryKey": false,
3500
+ "notNull": false
3501
+ },
3502
+ "agent": {
3503
+ "name": "agent",
3504
+ "type": "text",
3505
+ "primaryKey": false,
3506
+ "notNull": false
3507
+ },
3508
+ "input_tokens": {
3509
+ "name": "input_tokens",
3510
+ "type": "integer",
3511
+ "primaryKey": false,
3512
+ "notNull": true,
3513
+ "default": 0
3514
+ },
3515
+ "output_tokens": {
3516
+ "name": "output_tokens",
3517
+ "type": "integer",
3518
+ "primaryKey": false,
3519
+ "notNull": true,
3520
+ "default": 0
3521
+ },
3522
+ "total_tokens": {
3523
+ "name": "total_tokens",
3524
+ "type": "integer",
3525
+ "primaryKey": false,
3526
+ "notNull": true,
3527
+ "default": 0
3528
+ },
3529
+ "provider_cost_micros": {
3530
+ "name": "provider_cost_micros",
3531
+ "type": "bigint",
3532
+ "primaryKey": false,
3533
+ "notNull": true,
3534
+ "default": 0
3535
+ },
3536
+ "margin_bp": {
3537
+ "name": "margin_bp",
3538
+ "type": "integer",
3539
+ "primaryKey": false,
3540
+ "notNull": true,
3541
+ "default": 0
3542
+ },
3543
+ "usd_rate_micros": {
3544
+ "name": "usd_rate_micros",
3545
+ "type": "bigint",
3546
+ "primaryKey": false,
3547
+ "notNull": true,
3548
+ "default": 0
3549
+ },
3550
+ "charged_micros": {
3551
+ "name": "charged_micros",
3552
+ "type": "bigint",
3553
+ "primaryKey": false,
3554
+ "notNull": true,
3555
+ "default": 0
3556
+ },
3557
+ "currency": {
3558
+ "name": "currency",
3559
+ "type": "text",
3560
+ "primaryKey": false,
3561
+ "notNull": true,
3562
+ "default": "'USD'"
3563
+ },
3564
+ "request_id": {
3565
+ "name": "request_id",
3566
+ "type": "text",
3567
+ "primaryKey": false,
3568
+ "notNull": false
3569
+ },
3570
+ "execution_id": {
3571
+ "name": "execution_id",
3572
+ "type": "text",
3573
+ "primaryKey": false,
3574
+ "notNull": false
3575
+ },
3576
+ "conversation_id": {
3577
+ "name": "conversation_id",
3578
+ "type": "text",
3579
+ "primaryKey": false,
3580
+ "notNull": false
3581
+ },
3582
+ "metadata": {
3583
+ "name": "metadata",
3584
+ "type": "text",
3585
+ "primaryKey": false,
3586
+ "notNull": false
3587
+ },
3588
+ "recorded_at": {
3589
+ "name": "recorded_at",
3590
+ "type": "timestamp",
3591
+ "primaryKey": false,
3592
+ "notNull": true,
3593
+ "default": "now()"
3594
+ }
3595
+ },
3596
+ "indexes": {
3597
+ "usage_records_workspace_id_idx": {
3598
+ "name": "usage_records_workspace_id_idx",
3599
+ "columns": [
3600
+ {
3601
+ "expression": "workspace_id",
3602
+ "isExpression": false,
3603
+ "asc": true,
3604
+ "nulls": "last"
3605
+ }
3606
+ ],
3607
+ "isUnique": false,
3608
+ "concurrently": false,
3609
+ "method": "btree",
3610
+ "with": {}
3611
+ },
3612
+ "usage_records_workspace_recorded_at_idx": {
3613
+ "name": "usage_records_workspace_recorded_at_idx",
3614
+ "columns": [
3615
+ {
3616
+ "expression": "workspace_id",
3617
+ "isExpression": false,
3618
+ "asc": true,
3619
+ "nulls": "last"
3620
+ },
3621
+ {
3622
+ "expression": "recorded_at",
3623
+ "isExpression": false,
3624
+ "asc": true,
3625
+ "nulls": "last"
3626
+ }
3627
+ ],
3628
+ "isUnique": false,
3629
+ "concurrently": false,
3630
+ "method": "btree",
3631
+ "with": {}
3632
+ },
3633
+ "usage_records_workspace_type_idx": {
3634
+ "name": "usage_records_workspace_type_idx",
3635
+ "columns": [
3636
+ {
3637
+ "expression": "workspace_id",
3638
+ "isExpression": false,
3639
+ "asc": true,
3640
+ "nulls": "last"
3641
+ },
3642
+ {
3643
+ "expression": "type",
3644
+ "isExpression": false,
3645
+ "asc": true,
3646
+ "nulls": "last"
3647
+ }
3648
+ ],
3649
+ "isUnique": false,
3650
+ "concurrently": false,
3651
+ "method": "btree",
3652
+ "with": {}
3653
+ },
3654
+ "usage_records_conversation_id_idx": {
3655
+ "name": "usage_records_conversation_id_idx",
3656
+ "columns": [
3657
+ {
3658
+ "expression": "conversation_id",
3659
+ "isExpression": false,
3660
+ "asc": true,
3661
+ "nulls": "last"
3662
+ }
3663
+ ],
3664
+ "isUnique": false,
3665
+ "concurrently": false,
3666
+ "method": "btree",
3667
+ "with": {}
3668
+ },
3669
+ "usage_records_execution_id_idx": {
3670
+ "name": "usage_records_execution_id_idx",
3671
+ "columns": [
3672
+ {
3673
+ "expression": "execution_id",
3674
+ "isExpression": false,
3675
+ "asc": true,
3676
+ "nulls": "last"
3677
+ }
3678
+ ],
3679
+ "isUnique": false,
3680
+ "concurrently": false,
3681
+ "method": "btree",
3682
+ "with": {}
3683
+ }
3684
+ },
3685
+ "foreignKeys": {
3686
+ "usage_records_workspace_id_organization_id_fk": {
3687
+ "name": "usage_records_workspace_id_organization_id_fk",
3688
+ "tableFrom": "usage_records",
3689
+ "tableTo": "organization",
3690
+ "columnsFrom": ["workspace_id"],
3691
+ "columnsTo": ["id"],
3692
+ "onDelete": "cascade",
3693
+ "onUpdate": "no action"
3694
+ },
3695
+ "usage_records_user_id_users_id_fk": {
3696
+ "name": "usage_records_user_id_users_id_fk",
3697
+ "tableFrom": "usage_records",
3698
+ "tableTo": "users",
3699
+ "columnsFrom": ["user_id"],
3700
+ "columnsTo": ["id"],
3701
+ "onDelete": "cascade",
3702
+ "onUpdate": "no action"
3703
+ }
3704
+ },
3705
+ "compositePrimaryKeys": {},
3706
+ "uniqueConstraints": {},
3707
+ "policies": {},
3708
+ "checkConstraints": {},
3709
+ "isRLSEnabled": false
3710
+ },
3711
+ "public.user_quotas": {
3712
+ "name": "user_quotas",
3713
+ "schema": "",
3714
+ "columns": {
3715
+ "id": {
3716
+ "name": "id",
3717
+ "type": "text",
3718
+ "primaryKey": true,
3719
+ "notNull": true
3720
+ },
3721
+ "user_id": {
3722
+ "name": "user_id",
3723
+ "type": "text",
3724
+ "primaryKey": false,
3725
+ "notNull": true
3726
+ },
3727
+ "workspace_id": {
3728
+ "name": "workspace_id",
3729
+ "type": "text",
1960
3730
  "primaryKey": false,
1961
- "notNull": true,
1962
- "default": "now()"
3731
+ "notNull": true
1963
3732
  },
1964
- "channel": {
1965
- "name": "channel",
3733
+ "plan": {
3734
+ "name": "plan",
1966
3735
  "type": "text",
1967
3736
  "primaryKey": false,
1968
3737
  "notNull": true,
1969
- "default": "'console'"
3738
+ "default": "'free'"
1970
3739
  },
1971
- "metadata": {
1972
- "name": "metadata",
1973
- "type": "text",
3740
+ "usage": {
3741
+ "name": "usage",
3742
+ "type": "jsonb",
1974
3743
  "primaryKey": false,
1975
- "notNull": false
3744
+ "notNull": true,
3745
+ "default": "'{}'::jsonb"
3746
+ },
3747
+ "total_cost_usd": {
3748
+ "name": "total_cost_usd",
3749
+ "type": "real",
3750
+ "primaryKey": false,
3751
+ "notNull": true,
3752
+ "default": 0
3753
+ },
3754
+ "created_at": {
3755
+ "name": "created_at",
3756
+ "type": "timestamp",
3757
+ "primaryKey": false,
3758
+ "notNull": true,
3759
+ "default": "now()"
3760
+ },
3761
+ "updated_at": {
3762
+ "name": "updated_at",
3763
+ "type": "timestamp",
3764
+ "primaryKey": false,
3765
+ "notNull": true,
3766
+ "default": "now()"
1976
3767
  }
1977
3768
  },
1978
3769
  "indexes": {
1979
- "notification_history_workspace_id_idx": {
1980
- "name": "notification_history_workspace_id_idx",
3770
+ "user_quotas_user_id_idx": {
3771
+ "name": "user_quotas_user_id_idx",
3772
+ "columns": [
3773
+ {
3774
+ "expression": "user_id",
3775
+ "isExpression": false,
3776
+ "asc": true,
3777
+ "nulls": "last"
3778
+ }
3779
+ ],
3780
+ "isUnique": false,
3781
+ "concurrently": false,
3782
+ "method": "btree",
3783
+ "with": {}
3784
+ },
3785
+ "user_quotas_workspace_id_idx": {
3786
+ "name": "user_quotas_workspace_id_idx",
1981
3787
  "columns": [
1982
3788
  {
1983
3789
  "expression": "workspace_id",
@@ -1993,9 +3799,18 @@
1993
3799
  }
1994
3800
  },
1995
3801
  "foreignKeys": {
1996
- "notification_history_workspace_id_organization_id_fk": {
1997
- "name": "notification_history_workspace_id_organization_id_fk",
1998
- "tableFrom": "notification_history",
3802
+ "user_quotas_user_id_users_id_fk": {
3803
+ "name": "user_quotas_user_id_users_id_fk",
3804
+ "tableFrom": "user_quotas",
3805
+ "tableTo": "users",
3806
+ "columnsFrom": ["user_id"],
3807
+ "columnsTo": ["id"],
3808
+ "onDelete": "cascade",
3809
+ "onUpdate": "no action"
3810
+ },
3811
+ "user_quotas_workspace_id_organization_id_fk": {
3812
+ "name": "user_quotas_workspace_id_organization_id_fk",
3813
+ "tableFrom": "user_quotas",
1999
3814
  "tableTo": "organization",
2000
3815
  "columnsFrom": ["workspace_id"],
2001
3816
  "columnsTo": ["id"],
@@ -2005,18 +3820,18 @@
2005
3820
  },
2006
3821
  "compositePrimaryKeys": {},
2007
3822
  "uniqueConstraints": {
2008
- "notification_history_dedup_unique": {
2009
- "name": "notification_history_dedup_unique",
3823
+ "user_quotas_user_workspace_unique": {
3824
+ "name": "user_quotas_user_workspace_unique",
2010
3825
  "nullsNotDistinct": false,
2011
- "columns": ["workspace_id", "type", "period_key"]
3826
+ "columns": ["user_id", "workspace_id"]
2012
3827
  }
2013
3828
  },
2014
3829
  "policies": {},
2015
3830
  "checkConstraints": {},
2016
3831
  "isRLSEnabled": false
2017
3832
  },
2018
- "public.rate_limit_entries": {
2019
- "name": "rate_limit_entries",
3833
+ "public.notifications": {
3834
+ "name": "notifications",
2020
3835
  "schema": "",
2021
3836
  "columns": {
2022
3837
  "id": {
@@ -2025,21 +3840,51 @@
2025
3840
  "primaryKey": true,
2026
3841
  "notNull": true
2027
3842
  },
3843
+ "user_id": {
3844
+ "name": "user_id",
3845
+ "type": "text",
3846
+ "primaryKey": false,
3847
+ "notNull": true
3848
+ },
2028
3849
  "workspace_id": {
2029
3850
  "name": "workspace_id",
2030
3851
  "type": "text",
2031
3852
  "primaryKey": false,
3853
+ "notNull": false
3854
+ },
3855
+ "type": {
3856
+ "name": "type",
3857
+ "type": "text",
3858
+ "primaryKey": false,
2032
3859
  "notNull": true
2033
3860
  },
2034
- "endpoint": {
2035
- "name": "endpoint",
3861
+ "title": {
3862
+ "name": "title",
3863
+ "type": "text",
3864
+ "primaryKey": false,
3865
+ "notNull": true
3866
+ },
3867
+ "message": {
3868
+ "name": "message",
2036
3869
  "type": "text",
2037
3870
  "primaryKey": false,
3871
+ "notNull": true
3872
+ },
3873
+ "is_read": {
3874
+ "name": "is_read",
3875
+ "type": "boolean",
3876
+ "primaryKey": false,
2038
3877
  "notNull": true,
2039
- "default": "'chat'"
3878
+ "default": false
2040
3879
  },
2041
- "requested_at": {
2042
- "name": "requested_at",
3880
+ "metadata": {
3881
+ "name": "metadata",
3882
+ "type": "text",
3883
+ "primaryKey": false,
3884
+ "notNull": false
3885
+ },
3886
+ "created_at": {
3887
+ "name": "created_at",
2043
3888
  "type": "timestamp",
2044
3889
  "primaryKey": false,
2045
3890
  "notNull": true,
@@ -2047,23 +3892,187 @@
2047
3892
  }
2048
3893
  },
2049
3894
  "indexes": {
2050
- "rate_limit_entries_window_idx": {
2051
- "name": "rate_limit_entries_window_idx",
3895
+ "notifications_user_id_idx": {
3896
+ "name": "notifications_user_id_idx",
3897
+ "columns": [
3898
+ {
3899
+ "expression": "user_id",
3900
+ "isExpression": false,
3901
+ "asc": true,
3902
+ "nulls": "last"
3903
+ }
3904
+ ],
3905
+ "isUnique": false,
3906
+ "concurrently": false,
3907
+ "method": "btree",
3908
+ "with": {}
3909
+ },
3910
+ "notifications_user_id_is_read_idx": {
3911
+ "name": "notifications_user_id_is_read_idx",
3912
+ "columns": [
3913
+ {
3914
+ "expression": "user_id",
3915
+ "isExpression": false,
3916
+ "asc": true,
3917
+ "nulls": "last"
3918
+ },
3919
+ {
3920
+ "expression": "is_read",
3921
+ "isExpression": false,
3922
+ "asc": true,
3923
+ "nulls": "last"
3924
+ }
3925
+ ],
3926
+ "isUnique": false,
3927
+ "concurrently": false,
3928
+ "method": "btree",
3929
+ "with": {}
3930
+ },
3931
+ "notifications_created_at_idx": {
3932
+ "name": "notifications_created_at_idx",
3933
+ "columns": [
3934
+ {
3935
+ "expression": "created_at",
3936
+ "isExpression": false,
3937
+ "asc": true,
3938
+ "nulls": "last"
3939
+ }
3940
+ ],
3941
+ "isUnique": false,
3942
+ "concurrently": false,
3943
+ "method": "btree",
3944
+ "with": {}
3945
+ }
3946
+ },
3947
+ "foreignKeys": {},
3948
+ "compositePrimaryKeys": {},
3949
+ "uniqueConstraints": {},
3950
+ "policies": {},
3951
+ "checkConstraints": {},
3952
+ "isRLSEnabled": false
3953
+ },
3954
+ "public.audit_events": {
3955
+ "name": "audit_events",
3956
+ "schema": "",
3957
+ "columns": {
3958
+ "id": {
3959
+ "name": "id",
3960
+ "type": "text",
3961
+ "primaryKey": true,
3962
+ "notNull": true
3963
+ },
3964
+ "workspace_id": {
3965
+ "name": "workspace_id",
3966
+ "type": "text",
3967
+ "primaryKey": false,
3968
+ "notNull": false
3969
+ },
3970
+ "actor_id": {
3971
+ "name": "actor_id",
3972
+ "type": "text",
3973
+ "primaryKey": false,
3974
+ "notNull": false
3975
+ },
3976
+ "actor_kind": {
3977
+ "name": "actor_kind",
3978
+ "type": "text",
3979
+ "primaryKey": false,
3980
+ "notNull": true,
3981
+ "default": "'user'"
3982
+ },
3983
+ "action": {
3984
+ "name": "action",
3985
+ "type": "text",
3986
+ "primaryKey": false,
3987
+ "notNull": true
3988
+ },
3989
+ "resource_kind": {
3990
+ "name": "resource_kind",
3991
+ "type": "text",
3992
+ "primaryKey": false,
3993
+ "notNull": true
3994
+ },
3995
+ "resource_id": {
3996
+ "name": "resource_id",
3997
+ "type": "text",
3998
+ "primaryKey": false,
3999
+ "notNull": false
4000
+ },
4001
+ "outcome": {
4002
+ "name": "outcome",
4003
+ "type": "text",
4004
+ "primaryKey": false,
4005
+ "notNull": true,
4006
+ "default": "'ok'"
4007
+ },
4008
+ "metadata": {
4009
+ "name": "metadata",
4010
+ "type": "jsonb",
4011
+ "primaryKey": false,
4012
+ "notNull": false
4013
+ },
4014
+ "created_at": {
4015
+ "name": "created_at",
4016
+ "type": "timestamp",
4017
+ "primaryKey": false,
4018
+ "notNull": true,
4019
+ "default": "now()"
4020
+ }
4021
+ },
4022
+ "indexes": {
4023
+ "audit_events_workspace_created_idx": {
4024
+ "name": "audit_events_workspace_created_idx",
4025
+ "columns": [
4026
+ {
4027
+ "expression": "workspace_id",
4028
+ "isExpression": false,
4029
+ "asc": true,
4030
+ "nulls": "last"
4031
+ },
4032
+ {
4033
+ "expression": "created_at",
4034
+ "isExpression": false,
4035
+ "asc": true,
4036
+ "nulls": "last"
4037
+ }
4038
+ ],
4039
+ "isUnique": false,
4040
+ "concurrently": false,
4041
+ "method": "btree",
4042
+ "with": {}
4043
+ },
4044
+ "audit_events_action_idx": {
4045
+ "name": "audit_events_action_idx",
4046
+ "columns": [
4047
+ {
4048
+ "expression": "action",
4049
+ "isExpression": false,
4050
+ "asc": true,
4051
+ "nulls": "last"
4052
+ },
4053
+ {
4054
+ "expression": "created_at",
4055
+ "isExpression": false,
4056
+ "asc": true,
4057
+ "nulls": "last"
4058
+ }
4059
+ ],
4060
+ "isUnique": false,
4061
+ "concurrently": false,
4062
+ "method": "btree",
4063
+ "with": {}
4064
+ },
4065
+ "audit_events_resource_idx": {
4066
+ "name": "audit_events_resource_idx",
2052
4067
  "columns": [
2053
4068
  {
2054
- "expression": "workspace_id",
2055
- "isExpression": false,
2056
- "asc": true,
2057
- "nulls": "last"
2058
- },
2059
- {
2060
- "expression": "endpoint",
4069
+ "expression": "resource_kind",
2061
4070
  "isExpression": false,
2062
4071
  "asc": true,
2063
4072
  "nulls": "last"
2064
4073
  },
2065
4074
  {
2066
- "expression": "requested_at",
4075
+ "expression": "resource_id",
2067
4076
  "isExpression": false,
2068
4077
  "asc": true,
2069
4078
  "nulls": "last"
@@ -2076,13 +4085,22 @@
2076
4085
  }
2077
4086
  },
2078
4087
  "foreignKeys": {
2079
- "rate_limit_entries_workspace_id_organization_id_fk": {
2080
- "name": "rate_limit_entries_workspace_id_organization_id_fk",
2081
- "tableFrom": "rate_limit_entries",
4088
+ "audit_events_workspace_id_organization_id_fk": {
4089
+ "name": "audit_events_workspace_id_organization_id_fk",
4090
+ "tableFrom": "audit_events",
2082
4091
  "tableTo": "organization",
2083
4092
  "columnsFrom": ["workspace_id"],
2084
4093
  "columnsTo": ["id"],
2085
- "onDelete": "cascade",
4094
+ "onDelete": "set null",
4095
+ "onUpdate": "no action"
4096
+ },
4097
+ "audit_events_actor_id_users_id_fk": {
4098
+ "name": "audit_events_actor_id_users_id_fk",
4099
+ "tableFrom": "audit_events",
4100
+ "tableTo": "users",
4101
+ "columnsFrom": ["actor_id"],
4102
+ "columnsTo": ["id"],
4103
+ "onDelete": "set null",
2086
4104
  "onUpdate": "no action"
2087
4105
  }
2088
4106
  },
@@ -2092,8 +4110,8 @@
2092
4110
  "checkConstraints": {},
2093
4111
  "isRLSEnabled": false
2094
4112
  },
2095
- "public.trial_credits": {
2096
- "name": "trial_credits",
4113
+ "public.executions": {
4114
+ "name": "executions",
2097
4115
  "schema": "",
2098
4116
  "columns": {
2099
4117
  "id": {
@@ -2108,174 +4126,126 @@
2108
4126
  "primaryKey": false,
2109
4127
  "notNull": true
2110
4128
  },
2111
- "initial_credits": {
2112
- "name": "initial_credits",
2113
- "type": "integer",
4129
+ "user_id": {
4130
+ "name": "user_id",
4131
+ "type": "text",
2114
4132
  "primaryKey": false,
2115
- "notNull": true,
2116
- "default": 100000
4133
+ "notNull": false
2117
4134
  },
2118
- "credits_used": {
2119
- "name": "credits_used",
2120
- "type": "integer",
4135
+ "capability": {
4136
+ "name": "capability",
4137
+ "type": "text",
2121
4138
  "primaryKey": false,
2122
- "notNull": true,
2123
- "default": 0
4139
+ "notNull": true
2124
4140
  },
2125
- "credits_remaining": {
2126
- "name": "credits_remaining",
2127
- "type": "integer",
4141
+ "request_id": {
4142
+ "name": "request_id",
4143
+ "type": "text",
2128
4144
  "primaryKey": false,
2129
- "notNull": true,
2130
- "default": 100000
4145
+ "notNull": true
2131
4146
  },
2132
4147
  "status": {
2133
4148
  "name": "status",
2134
4149
  "type": "text",
2135
4150
  "primaryKey": false,
2136
4151
  "notNull": true,
2137
- "default": "'active'"
2138
- },
2139
- "provisioned_at": {
2140
- "name": "provisioned_at",
2141
- "type": "timestamp",
2142
- "primaryKey": false,
2143
- "notNull": true,
2144
- "default": "now()"
4152
+ "default": "'running'"
2145
4153
  },
2146
- "depleted_at": {
2147
- "name": "depleted_at",
2148
- "type": "timestamp",
4154
+ "model": {
4155
+ "name": "model",
4156
+ "type": "text",
2149
4157
  "primaryKey": false,
2150
4158
  "notNull": false
2151
4159
  },
2152
- "converted_at": {
2153
- "name": "converted_at",
2154
- "type": "timestamp",
4160
+ "input_tokens": {
4161
+ "name": "input_tokens",
4162
+ "type": "integer",
2155
4163
  "primaryKey": false,
2156
4164
  "notNull": false
2157
4165
  },
2158
- "created_by_ip": {
2159
- "name": "created_by_ip",
2160
- "type": "text",
4166
+ "output_tokens": {
4167
+ "name": "output_tokens",
4168
+ "type": "integer",
2161
4169
  "primaryKey": false,
2162
4170
  "notNull": false
2163
4171
  },
2164
- "created_by_email": {
2165
- "name": "created_by_email",
2166
- "type": "text",
4172
+ "total_tokens": {
4173
+ "name": "total_tokens",
4174
+ "type": "integer",
2167
4175
  "primaryKey": false,
2168
4176
  "notNull": false
2169
- }
2170
- },
2171
- "indexes": {},
2172
- "foreignKeys": {
2173
- "trial_credits_workspace_id_organization_id_fk": {
2174
- "name": "trial_credits_workspace_id_organization_id_fk",
2175
- "tableFrom": "trial_credits",
2176
- "tableTo": "organization",
2177
- "columnsFrom": ["workspace_id"],
2178
- "columnsTo": ["id"],
2179
- "onDelete": "cascade",
2180
- "onUpdate": "no action"
2181
- }
2182
- },
2183
- "compositePrimaryKeys": {},
2184
- "uniqueConstraints": {
2185
- "trial_credits_workspace_id_unique": {
2186
- "name": "trial_credits_workspace_id_unique",
2187
- "nullsNotDistinct": false,
2188
- "columns": ["workspace_id"]
2189
- }
2190
- },
2191
- "policies": {},
2192
- "checkConstraints": {},
2193
- "isRLSEnabled": false
2194
- },
2195
- "public.usage_records": {
2196
- "name": "usage_records",
2197
- "schema": "",
2198
- "columns": {
2199
- "id": {
2200
- "name": "id",
2201
- "type": "text",
2202
- "primaryKey": true,
2203
- "notNull": true
2204
4177
  },
2205
- "workspace_id": {
2206
- "name": "workspace_id",
2207
- "type": "text",
4178
+ "charged_micros": {
4179
+ "name": "charged_micros",
4180
+ "type": "bigint",
2208
4181
  "primaryKey": false,
2209
- "notNull": true
4182
+ "notNull": false
2210
4183
  },
2211
- "user_id": {
2212
- "name": "user_id",
2213
- "type": "text",
4184
+ "reserved_micros": {
4185
+ "name": "reserved_micros",
4186
+ "type": "bigint",
2214
4187
  "primaryKey": false,
2215
- "notNull": true
4188
+ "notNull": false
2216
4189
  },
2217
- "type": {
2218
- "name": "type",
4190
+ "currency": {
4191
+ "name": "currency",
2219
4192
  "type": "text",
2220
4193
  "primaryKey": false,
2221
- "notNull": true
4194
+ "notNull": false
2222
4195
  },
2223
- "model": {
2224
- "name": "model",
4196
+ "refusal_reason": {
4197
+ "name": "refusal_reason",
2225
4198
  "type": "text",
2226
4199
  "primaryKey": false,
2227
4200
  "notNull": false
2228
4201
  },
2229
- "agent": {
2230
- "name": "agent",
4202
+ "error_message": {
4203
+ "name": "error_message",
2231
4204
  "type": "text",
2232
4205
  "primaryKey": false,
2233
4206
  "notNull": false
2234
4207
  },
2235
- "input_tokens": {
2236
- "name": "input_tokens",
2237
- "type": "integer",
4208
+ "started_at": {
4209
+ "name": "started_at",
4210
+ "type": "timestamp",
2238
4211
  "primaryKey": false,
2239
4212
  "notNull": true,
2240
- "default": 0
4213
+ "default": "now()"
2241
4214
  },
2242
- "output_tokens": {
2243
- "name": "output_tokens",
2244
- "type": "integer",
4215
+ "finished_at": {
4216
+ "name": "finished_at",
4217
+ "type": "timestamp",
2245
4218
  "primaryKey": false,
2246
- "notNull": true,
2247
- "default": 0
4219
+ "notNull": false
2248
4220
  },
2249
- "total_tokens": {
2250
- "name": "total_tokens",
4221
+ "duration_ms": {
4222
+ "name": "duration_ms",
2251
4223
  "type": "integer",
2252
4224
  "primaryKey": false,
2253
- "notNull": true,
2254
- "default": 0
4225
+ "notNull": false
2255
4226
  },
2256
4227
  "metadata": {
2257
4228
  "name": "metadata",
2258
- "type": "text",
4229
+ "type": "jsonb",
2259
4230
  "primaryKey": false,
2260
4231
  "notNull": false
2261
- },
2262
- "recorded_at": {
2263
- "name": "recorded_at",
2264
- "type": "timestamp",
2265
- "primaryKey": false,
2266
- "notNull": true,
2267
- "default": "now()"
2268
4232
  }
2269
4233
  },
2270
4234
  "indexes": {
2271
- "usage_records_workspace_id_idx": {
2272
- "name": "usage_records_workspace_id_idx",
4235
+ "executions_workspace_started_idx": {
4236
+ "name": "executions_workspace_started_idx",
2273
4237
  "columns": [
2274
4238
  {
2275
4239
  "expression": "workspace_id",
2276
4240
  "isExpression": false,
2277
4241
  "asc": true,
2278
4242
  "nulls": "last"
4243
+ },
4244
+ {
4245
+ "expression": "started_at",
4246
+ "isExpression": false,
4247
+ "asc": true,
4248
+ "nulls": "last"
2279
4249
  }
2280
4250
  ],
2281
4251
  "isUnique": false,
@@ -2283,17 +4253,17 @@
2283
4253
  "method": "btree",
2284
4254
  "with": {}
2285
4255
  },
2286
- "usage_records_workspace_recorded_at_idx": {
2287
- "name": "usage_records_workspace_recorded_at_idx",
4256
+ "executions_status_idx": {
4257
+ "name": "executions_status_idx",
2288
4258
  "columns": [
2289
4259
  {
2290
- "expression": "workspace_id",
4260
+ "expression": "status",
2291
4261
  "isExpression": false,
2292
4262
  "asc": true,
2293
4263
  "nulls": "last"
2294
4264
  },
2295
4265
  {
2296
- "expression": "recorded_at",
4266
+ "expression": "started_at",
2297
4267
  "isExpression": false,
2298
4268
  "asc": true,
2299
4269
  "nulls": "last"
@@ -2304,17 +4274,17 @@
2304
4274
  "method": "btree",
2305
4275
  "with": {}
2306
4276
  },
2307
- "usage_records_workspace_type_idx": {
2308
- "name": "usage_records_workspace_type_idx",
4277
+ "executions_capability_idx": {
4278
+ "name": "executions_capability_idx",
2309
4279
  "columns": [
2310
4280
  {
2311
- "expression": "workspace_id",
4281
+ "expression": "capability",
2312
4282
  "isExpression": false,
2313
4283
  "asc": true,
2314
4284
  "nulls": "last"
2315
4285
  },
2316
4286
  {
2317
- "expression": "type",
4287
+ "expression": "started_at",
2318
4288
  "isExpression": false,
2319
4289
  "asc": true,
2320
4290
  "nulls": "last"
@@ -2327,33 +4297,39 @@
2327
4297
  }
2328
4298
  },
2329
4299
  "foreignKeys": {
2330
- "usage_records_workspace_id_organization_id_fk": {
2331
- "name": "usage_records_workspace_id_organization_id_fk",
2332
- "tableFrom": "usage_records",
4300
+ "executions_workspace_id_organization_id_fk": {
4301
+ "name": "executions_workspace_id_organization_id_fk",
4302
+ "tableFrom": "executions",
2333
4303
  "tableTo": "organization",
2334
4304
  "columnsFrom": ["workspace_id"],
2335
4305
  "columnsTo": ["id"],
2336
4306
  "onDelete": "cascade",
2337
4307
  "onUpdate": "no action"
2338
4308
  },
2339
- "usage_records_user_id_users_id_fk": {
2340
- "name": "usage_records_user_id_users_id_fk",
2341
- "tableFrom": "usage_records",
4309
+ "executions_user_id_users_id_fk": {
4310
+ "name": "executions_user_id_users_id_fk",
4311
+ "tableFrom": "executions",
2342
4312
  "tableTo": "users",
2343
4313
  "columnsFrom": ["user_id"],
2344
4314
  "columnsTo": ["id"],
2345
- "onDelete": "cascade",
4315
+ "onDelete": "set null",
2346
4316
  "onUpdate": "no action"
2347
4317
  }
2348
4318
  },
2349
4319
  "compositePrimaryKeys": {},
2350
- "uniqueConstraints": {},
4320
+ "uniqueConstraints": {
4321
+ "executions_request_id_unique": {
4322
+ "name": "executions_request_id_unique",
4323
+ "nullsNotDistinct": false,
4324
+ "columns": ["request_id"]
4325
+ }
4326
+ },
2351
4327
  "policies": {},
2352
4328
  "checkConstraints": {},
2353
4329
  "isRLSEnabled": false
2354
4330
  },
2355
- "public.notifications": {
2356
- "name": "notifications",
4331
+ "public.jobs": {
4332
+ "name": "jobs",
2357
4333
  "schema": "",
2358
4334
  "columns": {
2359
4335
  "id": {
@@ -2362,45 +4338,66 @@
2362
4338
  "primaryKey": true,
2363
4339
  "notNull": true
2364
4340
  },
2365
- "user_id": {
2366
- "name": "user_id",
2367
- "type": "text",
2368
- "primaryKey": false,
2369
- "notNull": true
2370
- },
2371
4341
  "workspace_id": {
2372
4342
  "name": "workspace_id",
2373
4343
  "type": "text",
2374
4344
  "primaryKey": false,
2375
4345
  "notNull": false
2376
4346
  },
2377
- "type": {
2378
- "name": "type",
4347
+ "kind": {
4348
+ "name": "kind",
2379
4349
  "type": "text",
2380
4350
  "primaryKey": false,
2381
4351
  "notNull": true
2382
4352
  },
2383
- "title": {
2384
- "name": "title",
2385
- "type": "text",
4353
+ "payload": {
4354
+ "name": "payload",
4355
+ "type": "jsonb",
2386
4356
  "primaryKey": false,
2387
- "notNull": true
4357
+ "notNull": false
2388
4358
  },
2389
- "message": {
2390
- "name": "message",
4359
+ "status": {
4360
+ "name": "status",
2391
4361
  "type": "text",
2392
4362
  "primaryKey": false,
2393
- "notNull": true
4363
+ "notNull": true,
4364
+ "default": "'pending'"
2394
4365
  },
2395
- "is_read": {
2396
- "name": "is_read",
2397
- "type": "boolean",
4366
+ "attempts": {
4367
+ "name": "attempts",
4368
+ "type": "integer",
2398
4369
  "primaryKey": false,
2399
4370
  "notNull": true,
2400
- "default": false
4371
+ "default": 0
2401
4372
  },
2402
- "metadata": {
2403
- "name": "metadata",
4373
+ "max_attempts": {
4374
+ "name": "max_attempts",
4375
+ "type": "integer",
4376
+ "primaryKey": false,
4377
+ "notNull": true,
4378
+ "default": 3
4379
+ },
4380
+ "run_at": {
4381
+ "name": "run_at",
4382
+ "type": "timestamp",
4383
+ "primaryKey": false,
4384
+ "notNull": true,
4385
+ "default": "now()"
4386
+ },
4387
+ "started_at": {
4388
+ "name": "started_at",
4389
+ "type": "timestamp",
4390
+ "primaryKey": false,
4391
+ "notNull": false
4392
+ },
4393
+ "finished_at": {
4394
+ "name": "finished_at",
4395
+ "type": "timestamp",
4396
+ "primaryKey": false,
4397
+ "notNull": false
4398
+ },
4399
+ "last_error": {
4400
+ "name": "last_error",
2404
4401
  "type": "text",
2405
4402
  "primaryKey": false,
2406
4403
  "notNull": false
@@ -2414,11 +4411,17 @@
2414
4411
  }
2415
4412
  },
2416
4413
  "indexes": {
2417
- "notifications_user_id_idx": {
2418
- "name": "notifications_user_id_idx",
4414
+ "jobs_claim_idx": {
4415
+ "name": "jobs_claim_idx",
2419
4416
  "columns": [
2420
4417
  {
2421
- "expression": "user_id",
4418
+ "expression": "status",
4419
+ "isExpression": false,
4420
+ "asc": true,
4421
+ "nulls": "last"
4422
+ },
4423
+ {
4424
+ "expression": "run_at",
2422
4425
  "isExpression": false,
2423
4426
  "asc": true,
2424
4427
  "nulls": "last"
@@ -2429,17 +4432,17 @@
2429
4432
  "method": "btree",
2430
4433
  "with": {}
2431
4434
  },
2432
- "notifications_user_id_is_read_idx": {
2433
- "name": "notifications_user_id_is_read_idx",
4435
+ "jobs_kind_idx": {
4436
+ "name": "jobs_kind_idx",
2434
4437
  "columns": [
2435
4438
  {
2436
- "expression": "user_id",
4439
+ "expression": "kind",
2437
4440
  "isExpression": false,
2438
4441
  "asc": true,
2439
4442
  "nulls": "last"
2440
4443
  },
2441
4444
  {
2442
- "expression": "is_read",
4445
+ "expression": "status",
2443
4446
  "isExpression": false,
2444
4447
  "asc": true,
2445
4448
  "nulls": "last"
@@ -2450,11 +4453,11 @@
2450
4453
  "method": "btree",
2451
4454
  "with": {}
2452
4455
  },
2453
- "notifications_created_at_idx": {
2454
- "name": "notifications_created_at_idx",
4456
+ "jobs_workspace_idx": {
4457
+ "name": "jobs_workspace_idx",
2455
4458
  "columns": [
2456
4459
  {
2457
- "expression": "created_at",
4460
+ "expression": "workspace_id",
2458
4461
  "isExpression": false,
2459
4462
  "asc": true,
2460
4463
  "nulls": "last"
@@ -2466,7 +4469,17 @@
2466
4469
  "with": {}
2467
4470
  }
2468
4471
  },
2469
- "foreignKeys": {},
4472
+ "foreignKeys": {
4473
+ "jobs_workspace_id_organization_id_fk": {
4474
+ "name": "jobs_workspace_id_organization_id_fk",
4475
+ "tableFrom": "jobs",
4476
+ "tableTo": "organization",
4477
+ "columnsFrom": ["workspace_id"],
4478
+ "columnsTo": ["id"],
4479
+ "onDelete": "cascade",
4480
+ "onUpdate": "no action"
4481
+ }
4482
+ },
2470
4483
  "compositePrimaryKeys": {},
2471
4484
  "uniqueConstraints": {},
2472
4485
  "policies": {},