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

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 (355) 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 +136 -107
  56. package/dist/db/schema/billing.d.ts.map +1 -1
  57. package/dist/db/schema/billing.js +72 -60
  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 +5 -13
  182. package/dist/identity/index.d.ts.map +1 -1
  183. package/dist/identity/index.js +4 -12
  184. package/dist/identity/index.js.map +1 -1
  185. package/dist/identity/service.d.ts +13 -47
  186. package/dist/identity/service.d.ts.map +1 -1
  187. package/dist/identity/service.js +31 -78
  188. package/dist/identity/service.js.map +1 -1
  189. package/dist/identity/types.d.ts +1 -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 +1 -10
  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/README.md +74 -36
  248. package/src/db/migrations/legacy-chain.json +197 -0
  249. package/src/db/migrations/meta/0000_snapshot.json +4182 -157
  250. package/src/db/migrations/meta/0002_snapshot.json +2478 -368
  251. package/src/db/migrations/meta/_journal.json +6 -279
  252. package/src/db/schema/agents.ts +57 -0
  253. package/src/db/schema/ai.ts +174 -0
  254. package/src/db/schema/auth.ts +183 -0
  255. package/src/db/schema/billing.ts +209 -0
  256. package/src/db/schema/feature-flags.ts +20 -0
  257. package/src/db/schema/identity.ts +250 -0
  258. package/src/db/schema/index.ts +12 -0
  259. package/src/db/schema/notifications.ts +31 -0
  260. package/src/db/schema/usage.ts +269 -0
  261. package/src/db/validate.ts +63 -0
  262. package/src/db/workspace-queries.ts +64 -0
  263. package/src/documents/classifier.ts +61 -0
  264. package/src/documents/errors.ts +44 -0
  265. package/src/documents/index.ts +24 -0
  266. package/src/documents/service.ts +256 -0
  267. package/src/documents/types.ts +24 -0
  268. package/src/email/brand.ts +24 -0
  269. package/src/email/index.ts +19 -0
  270. package/src/email/provider.ts +278 -0
  271. package/src/email/send.ts +169 -0
  272. package/src/email/senders.ts +292 -0
  273. package/src/email/templates/base-layout.tsx +145 -0
  274. package/src/email/templates/index.ts +28 -0
  275. package/src/email/templates/password-reset.tsx +72 -0
  276. package/src/email/templates/payment-failed.tsx +77 -0
  277. package/src/email/templates/quota-warning.tsx +118 -0
  278. package/src/email/templates/subscription-confirmed.tsx +91 -0
  279. package/src/email/templates/trial-expiry.tsx +124 -0
  280. package/src/email/templates/trial-warning.tsx +104 -0
  281. package/src/email/templates/verify-email.tsx +72 -0
  282. package/src/email/templates/welcome.tsx +64 -0
  283. package/src/email/templates/workspace-invitation.tsx +105 -0
  284. package/src/env.ts +180 -0
  285. package/src/identity/audit.ts +65 -0
  286. package/src/identity/errors.ts +44 -0
  287. package/src/identity/index.ts +26 -0
  288. package/src/identity/service.ts +202 -0
  289. package/src/identity/types.ts +28 -0
  290. package/src/index.ts +4 -0
  291. package/src/logger.ts +198 -0
  292. package/src/money.ts +270 -0
  293. package/src/notifications/index.ts +108 -0
  294. package/src/notifications/triggers.ts +158 -0
  295. package/src/notifications/types.ts +18 -0
  296. package/src/prompt.ts +142 -0
  297. package/src/registry.ts +75 -0
  298. package/src/request-context.ts +137 -0
  299. package/src/storage/index.ts +153 -0
  300. package/dist/db/schema/rag.d.ts +0 -171
  301. package/dist/db/schema/rag.d.ts.map +0 -1
  302. package/dist/db/schema/rag.js +0 -42
  303. package/dist/db/schema/rag.js.map +0 -1
  304. package/src/db/migrations/0000_sharp_night_nurse.sql +0 -52
  305. package/src/db/migrations/0001_hesitant_vapor.sql +0 -40
  306. package/src/db/migrations/0002_numerous_lady_vermin.sql +0 -235
  307. package/src/db/migrations/0003_mighty_jean_grey.sql +0 -37
  308. package/src/db/migrations/0004_cynical_grandmaster.sql +0 -2
  309. package/src/db/migrations/0005_careful_switch.sql +0 -8
  310. package/src/db/migrations/0006_tense_blue_marvel.sql +0 -16
  311. package/src/db/migrations/0007_next_squadron_sinister.sql +0 -1
  312. package/src/db/migrations/0008_powerful_scream.sql +0 -39
  313. package/src/db/migrations/0009_sad_ink.sql +0 -1
  314. package/src/db/migrations/0010_shocking_omega_flight.sql +0 -2
  315. package/src/db/migrations/0011_ambiguous_otto_octavius.sql +0 -151
  316. package/src/db/migrations/0011_hnsw_vector_index.sql +0 -17
  317. package/src/db/migrations/0012_user_profiles.sql +0 -30
  318. package/src/db/migrations/0013_trending_seasonal_columns.sql +0 -9
  319. package/src/db/migrations/0014_add_product_type_to_agents.sql +0 -6
  320. package/src/db/migrations/0015_new_v1_tables.sql +0 -149
  321. package/src/db/migrations/0016_document_types.sql +0 -30
  322. package/src/db/migrations/0017_document_metadata.sql +0 -2
  323. package/src/db/migrations/0018_identity_graph.sql +0 -200
  324. package/src/db/migrations/0019_db_driven_prompts.sql +0 -20
  325. package/src/db/migrations/0020_pending_extractions.sql +0 -35
  326. package/src/db/migrations/0021_rag_documents.sql +0 -39
  327. package/src/db/migrations/0022_user_quotas_usage_jsonb.sql +0 -70
  328. package/src/db/migrations/0023_user_facts_user_scoped_unique.sql +0 -17
  329. package/src/db/migrations/0024_user_memories_hnsw.sql +0 -23
  330. package/src/db/migrations/0025_audit_trigger_errcode.sql +0 -21
  331. package/src/db/migrations/0026_user_profile_snapshots_composite_pk.sql +0 -17
  332. package/src/db/migrations/0027_billing_settings_mnt_columns.sql +0 -54
  333. package/src/db/migrations/0028_trial_credits_normalized_email.sql +0 -37
  334. package/src/db/migrations/0029_usage_records_conversation_idx.sql +0 -13
  335. package/src/db/migrations/0030_pending_extractions_composite_idx.sql +0 -11
  336. package/src/db/migrations/0031_rag_documents_hnsw.sql +0 -16
  337. package/src/db/migrations/0032_rate_limit_unique_idx.sql +0 -16
  338. package/src/db/migrations/0033_pending_extractions_partial_idx.sql +0 -18
  339. package/src/db/migrations/0034_rate_limit_count.sql +0 -9
  340. package/src/db/migrations/0035_credit_reservations.sql +0 -24
  341. package/src/db/migrations/0036_executions_audit_jobs.sql +0 -96
  342. package/src/db/migrations/0037_rate_limit_minute_bucket.sql +0 -46
  343. package/src/db/migrations/0038_user_quotas_generic_usage.sql +0 -25
  344. package/src/db/migrations/0039_platform_admin_impersonation.sql +0 -27
  345. package/src/db/migrations/0040_ee_audit_chain.sql +0 -23
  346. package/src/db/migrations/meta/0001_snapshot.json +0 -631
  347. package/src/db/migrations/meta/0003_snapshot.json +0 -2488
  348. package/src/db/migrations/meta/0004_snapshot.json +0 -2500
  349. package/src/db/migrations/meta/0005_snapshot.json +0 -2548
  350. package/src/db/migrations/meta/0006_snapshot.json +0 -2650
  351. package/src/db/migrations/meta/0007_snapshot.json +0 -2657
  352. package/src/db/migrations/meta/0008_snapshot.json +0 -2719
  353. package/src/db/migrations/meta/0009_snapshot.json +0 -2726
  354. package/src/db/migrations/meta/0010_snapshot.json +0 -2739
  355. package/src/db/migrations/meta/0011_snapshot.json +0 -3886
@@ -1,11 +1,11 @@
1
1
  {
2
- "id": "ad471214-0088-4a54-949d-6a14719f3d4c",
3
- "prevId": "1626d8bc-a1a5-4357-8a02-3b3edcf241b0",
2
+ "id": "a97fa64b-3f7b-4597-88fd-508f9295e563",
3
+ "prevId": "181d1942-a29e-4d2b-8618-976e94ae505a",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
6
6
  "tables": {
7
- "public.conversations": {
8
- "name": "conversations",
7
+ "public.agents": {
8
+ "name": "agents",
9
9
  "schema": "",
10
10
  "columns": {
11
11
  "id": {
@@ -14,36 +14,107 @@
14
14
  "primaryKey": true,
15
15
  "notNull": true
16
16
  },
17
- "workspace_id": {
18
- "name": "workspace_id",
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",
19
31
  "type": "text",
20
32
  "primaryKey": false,
21
33
  "notNull": true
22
34
  },
23
- "user_id": {
24
- "name": "user_id",
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",
25
49
  "type": "text",
26
50
  "primaryKey": false,
27
51
  "notNull": true
28
52
  },
29
- "agent_id": {
30
- "name": "agent_id",
53
+ "default_model": {
54
+ "name": "default_model",
31
55
  "type": "text",
32
56
  "primaryKey": false,
33
57
  "notNull": true
34
58
  },
35
- "title": {
36
- "name": "title",
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",
37
80
  "type": "text",
38
81
  "primaryKey": false,
39
- "notNull": false
82
+ "notNull": true
40
83
  },
41
- "model_id": {
42
- "name": "model_id",
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",
43
107
  "type": "text",
44
108
  "primaryKey": false,
45
109
  "notNull": false
46
110
  },
111
+ "color": {
112
+ "name": "color",
113
+ "type": "text",
114
+ "primaryKey": false,
115
+ "notNull": true,
116
+ "default": "'bg-gray-500'"
117
+ },
47
118
  "created_at": {
48
119
  "name": "created_at",
49
120
  "type": "timestamp",
@@ -59,9 +130,83 @@
59
130
  "default": "now()"
60
131
  }
61
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
+ },
62
207
  "indexes": {
63
- "conversations_workspace_id_idx": {
64
- "name": "conversations_workspace_id_idx",
208
+ "attachments_workspace_id_idx": {
209
+ "name": "attachments_workspace_id_idx",
65
210
  "columns": [
66
211
  {
67
212
  "expression": "workspace_id",
@@ -75,11 +220,11 @@
75
220
  "method": "btree",
76
221
  "with": {}
77
222
  },
78
- "conversations_user_id_idx": {
79
- "name": "conversations_user_id_idx",
223
+ "attachments_conversation_id_idx": {
224
+ "name": "attachments_conversation_id_idx",
80
225
  "columns": [
81
226
  {
82
- "expression": "user_id",
227
+ "expression": "conversation_id",
83
228
  "isExpression": false,
84
229
  "asc": true,
85
230
  "nulls": "last"
@@ -90,46 +235,49 @@
90
235
  "method": "btree",
91
236
  "with": {}
92
237
  },
93
- "conversations_workspace_updated_idx": {
94
- "name": "conversations_workspace_updated_idx",
238
+ "attachments_storage_key_idx": {
239
+ "name": "attachments_storage_key_idx",
95
240
  "columns": [
96
241
  {
97
- "expression": "workspace_id",
98
- "isExpression": false,
99
- "asc": true,
100
- "nulls": "last"
101
- },
102
- {
103
- "expression": "updated_at",
242
+ "expression": "storage_key",
104
243
  "isExpression": false,
105
244
  "asc": true,
106
245
  "nulls": "last"
107
246
  }
108
247
  ],
109
- "isUnique": false,
248
+ "isUnique": true,
110
249
  "concurrently": false,
111
250
  "method": "btree",
112
251
  "with": {}
113
252
  }
114
253
  },
115
254
  "foreignKeys": {
116
- "conversations_workspace_id_organization_id_fk": {
117
- "name": "conversations_workspace_id_organization_id_fk",
118
- "tableFrom": "conversations",
255
+ "attachments_workspace_id_organization_id_fk": {
256
+ "name": "attachments_workspace_id_organization_id_fk",
257
+ "tableFrom": "attachments",
119
258
  "tableTo": "organization",
120
259
  "columnsFrom": ["workspace_id"],
121
260
  "columnsTo": ["id"],
122
261
  "onDelete": "cascade",
123
262
  "onUpdate": "no action"
124
263
  },
125
- "conversations_user_id_users_id_fk": {
126
- "name": "conversations_user_id_users_id_fk",
127
- "tableFrom": "conversations",
264
+ "attachments_user_id_users_id_fk": {
265
+ "name": "attachments_user_id_users_id_fk",
266
+ "tableFrom": "attachments",
128
267
  "tableTo": "users",
129
268
  "columnsFrom": ["user_id"],
130
269
  "columnsTo": ["id"],
131
270
  "onDelete": "cascade",
132
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"
133
281
  }
134
282
  },
135
283
  "compositePrimaryKeys": {},
@@ -138,8 +286,8 @@
138
286
  "checkConstraints": {},
139
287
  "isRLSEnabled": false
140
288
  },
141
- "public.knowledge_chunks": {
142
- "name": "knowledge_chunks",
289
+ "public.conversations": {
290
+ "name": "conversations",
143
291
  "schema": "",
144
292
  "columns": {
145
293
  "id": {
@@ -148,41 +296,48 @@
148
296
  "primaryKey": true,
149
297
  "notNull": true
150
298
  },
151
- "document_id": {
152
- "name": "document_id",
299
+ "workspace_id": {
300
+ "name": "workspace_id",
153
301
  "type": "text",
154
302
  "primaryKey": false,
155
303
  "notNull": true
156
304
  },
157
- "workspace_id": {
158
- "name": "workspace_id",
305
+ "user_id": {
306
+ "name": "user_id",
159
307
  "type": "text",
160
308
  "primaryKey": false,
161
309
  "notNull": true
162
310
  },
163
- "content": {
164
- "name": "content",
311
+ "agent_id": {
312
+ "name": "agent_id",
165
313
  "type": "text",
166
314
  "primaryKey": false,
167
315
  "notNull": true
168
316
  },
169
- "embedding": {
170
- "name": "embedding",
171
- "type": "vector(1536)",
317
+ "title": {
318
+ "name": "title",
319
+ "type": "text",
172
320
  "primaryKey": false,
173
321
  "notNull": false
174
322
  },
175
- "metadata": {
176
- "name": "metadata",
323
+ "model_id": {
324
+ "name": "model_id",
177
325
  "type": "text",
178
326
  "primaryKey": false,
179
327
  "notNull": false
180
328
  },
181
- "chunk_index": {
182
- "name": "chunk_index",
183
- "type": "integer",
329
+ "visibility": {
330
+ "name": "visibility",
331
+ "type": "text",
184
332
  "primaryKey": false,
185
- "notNull": true
333
+ "notNull": true,
334
+ "default": "'private'"
335
+ },
336
+ "metadata": {
337
+ "name": "metadata",
338
+ "type": "jsonb",
339
+ "primaryKey": false,
340
+ "notNull": false
186
341
  },
187
342
  "created_at": {
188
343
  "name": "created_at",
@@ -190,14 +345,57 @@
190
345
  "primaryKey": false,
191
346
  "notNull": true,
192
347
  "default": "now()"
348
+ },
349
+ "updated_at": {
350
+ "name": "updated_at",
351
+ "type": "timestamp",
352
+ "primaryKey": false,
353
+ "notNull": true,
354
+ "default": "now()"
193
355
  }
194
356
  },
195
357
  "indexes": {
196
- "knowledge_chunks_document_id_idx": {
197
- "name": "knowledge_chunks_document_id_idx",
358
+ "conversations_workspace_id_idx": {
359
+ "name": "conversations_workspace_id_idx",
360
+ "columns": [
361
+ {
362
+ "expression": "workspace_id",
363
+ "isExpression": false,
364
+ "asc": true,
365
+ "nulls": "last"
366
+ }
367
+ ],
368
+ "isUnique": false,
369
+ "concurrently": false,
370
+ "method": "btree",
371
+ "with": {}
372
+ },
373
+ "conversations_user_id_idx": {
374
+ "name": "conversations_user_id_idx",
198
375
  "columns": [
199
376
  {
200
- "expression": "document_id",
377
+ "expression": "user_id",
378
+ "isExpression": false,
379
+ "asc": true,
380
+ "nulls": "last"
381
+ }
382
+ ],
383
+ "isUnique": false,
384
+ "concurrently": false,
385
+ "method": "btree",
386
+ "with": {}
387
+ },
388
+ "conversations_workspace_updated_idx": {
389
+ "name": "conversations_workspace_updated_idx",
390
+ "columns": [
391
+ {
392
+ "expression": "workspace_id",
393
+ "isExpression": false,
394
+ "asc": true,
395
+ "nulls": "last"
396
+ },
397
+ {
398
+ "expression": "updated_at",
201
399
  "isExpression": false,
202
400
  "asc": true,
203
401
  "nulls": "last"
@@ -208,14 +406,20 @@
208
406
  "method": "btree",
209
407
  "with": {}
210
408
  },
211
- "knowledge_chunks_workspace_id_idx": {
212
- "name": "knowledge_chunks_workspace_id_idx",
409
+ "conversations_workspace_user_idx": {
410
+ "name": "conversations_workspace_user_idx",
213
411
  "columns": [
214
412
  {
215
413
  "expression": "workspace_id",
216
414
  "isExpression": false,
217
415
  "asc": true,
218
416
  "nulls": "last"
417
+ },
418
+ {
419
+ "expression": "user_id",
420
+ "isExpression": false,
421
+ "asc": true,
422
+ "nulls": "last"
219
423
  }
220
424
  ],
221
425
  "isUnique": false,
@@ -225,20 +429,20 @@
225
429
  }
226
430
  },
227
431
  "foreignKeys": {
228
- "knowledge_chunks_document_id_knowledge_documents_id_fk": {
229
- "name": "knowledge_chunks_document_id_knowledge_documents_id_fk",
230
- "tableFrom": "knowledge_chunks",
231
- "tableTo": "knowledge_documents",
232
- "columnsFrom": ["document_id"],
432
+ "conversations_workspace_id_organization_id_fk": {
433
+ "name": "conversations_workspace_id_organization_id_fk",
434
+ "tableFrom": "conversations",
435
+ "tableTo": "organization",
436
+ "columnsFrom": ["workspace_id"],
233
437
  "columnsTo": ["id"],
234
438
  "onDelete": "cascade",
235
439
  "onUpdate": "no action"
236
440
  },
237
- "knowledge_chunks_workspace_id_organization_id_fk": {
238
- "name": "knowledge_chunks_workspace_id_organization_id_fk",
239
- "tableFrom": "knowledge_chunks",
240
- "tableTo": "organization",
241
- "columnsFrom": ["workspace_id"],
441
+ "conversations_user_id_users_id_fk": {
442
+ "name": "conversations_user_id_users_id_fk",
443
+ "tableFrom": "conversations",
444
+ "tableTo": "users",
445
+ "columnsFrom": ["user_id"],
242
446
  "columnsTo": ["id"],
243
447
  "onDelete": "cascade",
244
448
  "onUpdate": "no action"
@@ -250,77 +454,64 @@
250
454
  "checkConstraints": {},
251
455
  "isRLSEnabled": false
252
456
  },
253
- "public.knowledge_documents": {
254
- "name": "knowledge_documents",
457
+ "public.documents": {
458
+ "name": "documents",
255
459
  "schema": "",
256
460
  "columns": {
257
461
  "id": {
258
462
  "name": "id",
259
463
  "type": "text",
260
- "primaryKey": true,
261
- "notNull": true
262
- },
263
- "workspace_id": {
264
- "name": "workspace_id",
265
- "type": "text",
266
464
  "primaryKey": false,
267
465
  "notNull": true
268
466
  },
269
- "filename": {
270
- "name": "filename",
271
- "type": "text",
467
+ "created_at": {
468
+ "name": "created_at",
469
+ "type": "timestamp",
272
470
  "primaryKey": false,
273
- "notNull": true
471
+ "notNull": true,
472
+ "default": "now()"
274
473
  },
275
- "mime_type": {
276
- "name": "mime_type",
474
+ "title": {
475
+ "name": "title",
277
476
  "type": "text",
278
477
  "primaryKey": false,
279
478
  "notNull": true
280
479
  },
281
- "size_bytes": {
282
- "name": "size_bytes",
283
- "type": "integer",
480
+ "content": {
481
+ "name": "content",
482
+ "type": "text",
284
483
  "primaryKey": false,
285
484
  "notNull": false
286
485
  },
287
- "chunk_count": {
288
- "name": "chunk_count",
289
- "type": "integer",
290
- "primaryKey": false,
291
- "notNull": false,
292
- "default": 0
293
- },
294
- "status": {
295
- "name": "status",
486
+ "kind": {
487
+ "name": "kind",
296
488
  "type": "text",
297
489
  "primaryKey": false,
298
490
  "notNull": true,
299
- "default": "'processing'"
491
+ "default": "'text'"
300
492
  },
301
- "product": {
302
- "name": "product",
303
- "type": "text",
493
+ "metadata": {
494
+ "name": "metadata",
495
+ "type": "jsonb",
304
496
  "primaryKey": false,
305
497
  "notNull": false
306
498
  },
307
- "metadata": {
308
- "name": "metadata",
499
+ "user_id": {
500
+ "name": "user_id",
309
501
  "type": "text",
310
502
  "primaryKey": false,
311
- "notNull": false
503
+ "notNull": true
312
504
  },
313
- "created_at": {
314
- "name": "created_at",
315
- "type": "timestamp",
505
+ "workspace_id": {
506
+ "name": "workspace_id",
507
+ "type": "text",
316
508
  "primaryKey": false,
317
- "notNull": true,
318
- "default": "now()"
509
+ "notNull": true
319
510
  }
320
511
  },
321
512
  "indexes": {
322
- "knowledge_documents_workspace_id_idx": {
323
- "name": "knowledge_documents_workspace_id_idx",
513
+ "documents_workspace_id_idx": {
514
+ "name": "documents_workspace_id_idx",
324
515
  "columns": [
325
516
  {
326
517
  "expression": "workspace_id",
@@ -333,12 +524,36 @@
333
524
  "concurrently": false,
334
525
  "method": "btree",
335
526
  "with": {}
527
+ },
528
+ "documents_user_id_idx": {
529
+ "name": "documents_user_id_idx",
530
+ "columns": [
531
+ {
532
+ "expression": "user_id",
533
+ "isExpression": false,
534
+ "asc": true,
535
+ "nulls": "last"
536
+ }
537
+ ],
538
+ "isUnique": false,
539
+ "concurrently": false,
540
+ "method": "btree",
541
+ "with": {}
336
542
  }
337
543
  },
338
544
  "foreignKeys": {
339
- "knowledge_documents_workspace_id_organization_id_fk": {
340
- "name": "knowledge_documents_workspace_id_organization_id_fk",
341
- "tableFrom": "knowledge_documents",
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"],
550
+ "columnsTo": ["id"],
551
+ "onDelete": "cascade",
552
+ "onUpdate": "no action"
553
+ },
554
+ "documents_workspace_id_organization_id_fk": {
555
+ "name": "documents_workspace_id_organization_id_fk",
556
+ "tableFrom": "documents",
342
557
  "tableTo": "organization",
343
558
  "columnsFrom": ["workspace_id"],
344
559
  "columnsTo": ["id"],
@@ -346,7 +561,12 @@
346
561
  "onUpdate": "no action"
347
562
  }
348
563
  },
349
- "compositePrimaryKeys": {},
564
+ "compositePrimaryKeys": {
565
+ "documents_id_created_at_pk": {
566
+ "name": "documents_id_created_at_pk",
567
+ "columns": ["id", "created_at"]
568
+ }
569
+ },
350
570
  "uniqueConstraints": {},
351
571
  "policies": {},
352
572
  "checkConstraints": {},
@@ -378,8 +598,20 @@
378
598
  "name": "content",
379
599
  "type": "text",
380
600
  "primaryKey": false,
601
+ "notNull": false
602
+ },
603
+ "parts": {
604
+ "name": "parts",
605
+ "type": "text",
606
+ "primaryKey": false,
381
607
  "notNull": true
382
608
  },
609
+ "attachments": {
610
+ "name": "attachments",
611
+ "type": "text",
612
+ "primaryKey": false,
613
+ "notNull": false
614
+ },
383
615
  "tool_invocations": {
384
616
  "name": "tool_invocations",
385
617
  "type": "text",
@@ -455,6 +687,77 @@
455
687
  "checkConstraints": {},
456
688
  "isRLSEnabled": false
457
689
  },
690
+ "public.votes": {
691
+ "name": "votes",
692
+ "schema": "",
693
+ "columns": {
694
+ "chat_id": {
695
+ "name": "chat_id",
696
+ "type": "text",
697
+ "primaryKey": false,
698
+ "notNull": true
699
+ },
700
+ "message_id": {
701
+ "name": "message_id",
702
+ "type": "text",
703
+ "primaryKey": false,
704
+ "notNull": true
705
+ },
706
+ "is_upvoted": {
707
+ "name": "is_upvoted",
708
+ "type": "boolean",
709
+ "primaryKey": false,
710
+ "notNull": true
711
+ }
712
+ },
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
+ },
730
+ "foreignKeys": {
731
+ "votes_chat_id_conversations_id_fk": {
732
+ "name": "votes_chat_id_conversations_id_fk",
733
+ "tableFrom": "votes",
734
+ "tableTo": "conversations",
735
+ "columnsFrom": ["chat_id"],
736
+ "columnsTo": ["id"],
737
+ "onDelete": "cascade",
738
+ "onUpdate": "no action"
739
+ },
740
+ "votes_message_id_messages_id_fk": {
741
+ "name": "votes_message_id_messages_id_fk",
742
+ "tableFrom": "votes",
743
+ "tableTo": "messages",
744
+ "columnsFrom": ["message_id"],
745
+ "columnsTo": ["id"],
746
+ "onDelete": "cascade",
747
+ "onUpdate": "no action"
748
+ }
749
+ },
750
+ "compositePrimaryKeys": {
751
+ "votes_chat_id_message_id_pk": {
752
+ "name": "votes_chat_id_message_id_pk",
753
+ "columns": ["chat_id", "message_id"]
754
+ }
755
+ },
756
+ "uniqueConstraints": {},
757
+ "policies": {},
758
+ "checkConstraints": {},
759
+ "isRLSEnabled": false
760
+ },
458
761
  "public.accounts": {
459
762
  "name": "accounts",
460
763
  "schema": "",
@@ -618,7 +921,7 @@
618
921
  "name": "inviter_id",
619
922
  "type": "text",
620
923
  "primaryKey": false,
621
- "notNull": true
924
+ "notNull": false
622
925
  },
623
926
  "created_at": {
624
927
  "name": "created_at",
@@ -683,7 +986,7 @@
683
986
  "tableTo": "users",
684
987
  "columnsFrom": ["inviter_id"],
685
988
  "columnsTo": ["id"],
686
- "onDelete": "no action",
989
+ "onDelete": "set null",
687
990
  "onUpdate": "no action"
688
991
  }
689
992
  },
@@ -766,6 +1069,27 @@
766
1069
  "concurrently": false,
767
1070
  "method": "btree",
768
1071
  "with": {}
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": {}
769
1093
  }
770
1094
  },
771
1095
  "foreignKeys": {
@@ -897,6 +1221,18 @@
897
1221
  "primaryKey": false,
898
1222
  "notNull": false
899
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
+ },
900
1236
  "created_at": {
901
1237
  "name": "created_at",
902
1238
  "type": "timestamp",
@@ -987,6 +1323,12 @@
987
1323
  "primaryKey": false,
988
1324
  "notNull": false
989
1325
  },
1326
+ "deleted_at": {
1327
+ "name": "deleted_at",
1328
+ "type": "timestamp",
1329
+ "primaryKey": false,
1330
+ "notNull": false
1331
+ },
990
1332
  "created_at": {
991
1333
  "name": "created_at",
992
1334
  "type": "timestamp",
@@ -1000,9 +1342,71 @@
1000
1342
  "primaryKey": false,
1001
1343
  "notNull": true,
1002
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": {}
1003
1408
  }
1004
1409
  },
1005
- "indexes": {},
1006
1410
  "foreignKeys": {},
1007
1411
  "compositePrimaryKeys": {},
1008
1412
  "uniqueConstraints": {
@@ -1067,6 +1471,53 @@
1067
1471
  "checkConstraints": {},
1068
1472
  "isRLSEnabled": false
1069
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
+ },
1070
1521
  "public.credit_balances": {
1071
1522
  "name": "credit_balances",
1072
1523
  "schema": "",
@@ -1083,27 +1534,34 @@
1083
1534
  "primaryKey": false,
1084
1535
  "notNull": true
1085
1536
  },
1086
- "balance": {
1087
- "name": "balance",
1088
- "type": "integer",
1537
+ "balance_micros": {
1538
+ "name": "balance_micros",
1539
+ "type": "bigint",
1089
1540
  "primaryKey": false,
1090
1541
  "notNull": true,
1091
1542
  "default": 0
1092
1543
  },
1093
- "total_purchased": {
1094
- "name": "total_purchased",
1095
- "type": "integer",
1544
+ "total_purchased_micros": {
1545
+ "name": "total_purchased_micros",
1546
+ "type": "bigint",
1096
1547
  "primaryKey": false,
1097
1548
  "notNull": true,
1098
1549
  "default": 0
1099
1550
  },
1100
- "total_used": {
1101
- "name": "total_used",
1102
- "type": "integer",
1551
+ "total_used_micros": {
1552
+ "name": "total_used_micros",
1553
+ "type": "bigint",
1103
1554
  "primaryKey": false,
1104
1555
  "notNull": true,
1105
1556
  "default": 0
1106
1557
  },
1558
+ "currency": {
1559
+ "name": "currency",
1560
+ "type": "text",
1561
+ "primaryKey": false,
1562
+ "notNull": true,
1563
+ "default": "'USD'"
1564
+ },
1107
1565
  "updated_at": {
1108
1566
  "name": "updated_at",
1109
1567
  "type": "timestamp",
@@ -1152,17 +1610,29 @@
1152
1610
  "primaryKey": false,
1153
1611
  "notNull": true
1154
1612
  },
1155
- "amount": {
1156
- "name": "amount",
1613
+ "price_minor": {
1614
+ "name": "price_minor",
1157
1615
  "type": "integer",
1158
1616
  "primaryKey": false,
1159
- "notNull": true
1617
+ "notNull": false
1160
1618
  },
1161
- "credits": {
1162
- "name": "credits",
1163
- "type": "integer",
1619
+ "price_currency": {
1620
+ "name": "price_currency",
1621
+ "type": "text",
1164
1622
  "primaryKey": false,
1165
- "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
1166
1636
  },
1167
1637
  "stripe_payment_intent_id": {
1168
1638
  "name": "stripe_payment_intent_id",
@@ -1225,7 +1695,122 @@
1225
1695
  "checkConstraints": {},
1226
1696
  "isRLSEnabled": false
1227
1697
  },
1228
- "public.finance_events": {
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
+ },
1813
+ "public.finance_events": {
1229
1814
  "name": "finance_events",
1230
1815
  "schema": "",
1231
1816
  "columns": {
@@ -1253,8 +1838,8 @@
1253
1838
  "primaryKey": false,
1254
1839
  "notNull": true
1255
1840
  },
1256
- "amount": {
1257
- "name": "amount",
1841
+ "amount_minor": {
1842
+ "name": "amount_minor",
1258
1843
  "type": "integer",
1259
1844
  "primaryKey": false,
1260
1845
  "notNull": false
@@ -1264,7 +1849,7 @@
1264
1849
  "type": "text",
1265
1850
  "primaryKey": false,
1266
1851
  "notNull": false,
1267
- "default": "'usd'"
1852
+ "default": "'USD'"
1268
1853
  },
1269
1854
  "metadata": {
1270
1855
  "name": "metadata",
@@ -1272,6 +1857,12 @@
1272
1857
  "primaryKey": false,
1273
1858
  "notNull": false
1274
1859
  },
1860
+ "claimed_at": {
1861
+ "name": "claimed_at",
1862
+ "type": "timestamp",
1863
+ "primaryKey": false,
1864
+ "notNull": false
1865
+ },
1275
1866
  "processed_at": {
1276
1867
  "name": "processed_at",
1277
1868
  "type": "timestamp",
@@ -1294,7 +1885,7 @@
1294
1885
  "tableTo": "organization",
1295
1886
  "columnsFrom": ["workspace_id"],
1296
1887
  "columnsTo": ["id"],
1297
- "onDelete": "no action",
1888
+ "onDelete": "set null",
1298
1889
  "onUpdate": "no action"
1299
1890
  }
1300
1891
  },
@@ -1532,7 +2123,7 @@
1532
2123
  "tableTo": "plans",
1533
2124
  "columnsFrom": ["plan_id"],
1534
2125
  "columnsTo": ["id"],
1535
- "onDelete": "no action",
2126
+ "onDelete": "restrict",
1536
2127
  "onUpdate": "no action"
1537
2128
  }
1538
2129
  },
@@ -1617,8 +2208,8 @@
1617
2208
  "checkConstraints": {},
1618
2209
  "isRLSEnabled": false
1619
2210
  },
1620
- "public.monthly_usage": {
1621
- "name": "monthly_usage",
2211
+ "public.user_facts": {
2212
+ "name": "user_facts",
1622
2213
  "schema": "",
1623
2214
  "columns": {
1624
2215
  "id": {
@@ -1627,67 +2218,192 @@
1627
2218
  "primaryKey": true,
1628
2219
  "notNull": true
1629
2220
  },
2221
+ "user_id": {
2222
+ "name": "user_id",
2223
+ "type": "text",
2224
+ "primaryKey": false,
2225
+ "notNull": true
2226
+ },
1630
2227
  "workspace_id": {
1631
2228
  "name": "workspace_id",
1632
2229
  "type": "text",
1633
2230
  "primaryKey": false,
1634
2231
  "notNull": true
1635
2232
  },
1636
- "period_start": {
1637
- "name": "period_start",
1638
- "type": "timestamp",
2233
+ "category": {
2234
+ "name": "category",
2235
+ "type": "text",
1639
2236
  "primaryKey": false,
1640
2237
  "notNull": true
1641
2238
  },
1642
- "period_end": {
1643
- "name": "period_end",
1644
- "type": "timestamp",
2239
+ "key": {
2240
+ "name": "key",
2241
+ "type": "text",
1645
2242
  "primaryKey": false,
1646
2243
  "notNull": true
1647
2244
  },
1648
- "tokens_used": {
1649
- "name": "tokens_used",
1650
- "type": "integer",
2245
+ "value": {
2246
+ "name": "value",
2247
+ "type": "jsonb",
1651
2248
  "primaryKey": false,
1652
- "notNull": true,
1653
- "default": 0
2249
+ "notNull": true
1654
2250
  },
1655
- "request_count": {
1656
- "name": "request_count",
2251
+ "confidence": {
2252
+ "name": "confidence",
2253
+ "type": "double precision",
2254
+ "primaryKey": false,
2255
+ "notNull": true
2256
+ },
2257
+ "importance": {
2258
+ "name": "importance",
1657
2259
  "type": "integer",
1658
2260
  "primaryKey": false,
1659
2261
  "notNull": true,
1660
- "default": 0
2262
+ "default": 5
1661
2263
  },
1662
- "updated_at": {
1663
- "name": "updated_at",
2264
+ "source_product": {
2265
+ "name": "source_product",
2266
+ "type": "text",
2267
+ "primaryKey": false,
2268
+ "notNull": false
2269
+ },
2270
+ "source_session_id": {
2271
+ "name": "source_session_id",
2272
+ "type": "text",
2273
+ "primaryKey": false,
2274
+ "notNull": false
2275
+ },
2276
+ "source_message_id": {
2277
+ "name": "source_message_id",
2278
+ "type": "text",
2279
+ "primaryKey": false,
2280
+ "notNull": false
2281
+ },
2282
+ "extraction_method": {
2283
+ "name": "extraction_method",
2284
+ "type": "text",
2285
+ "primaryKey": false,
2286
+ "notNull": false
2287
+ },
2288
+ "created_at": {
2289
+ "name": "created_at",
1664
2290
  "type": "timestamp",
1665
2291
  "primaryKey": false,
1666
2292
  "notNull": true,
1667
2293
  "default": "now()"
2294
+ },
2295
+ "last_confirmed_at": {
2296
+ "name": "last_confirmed_at",
2297
+ "type": "timestamp",
2298
+ "primaryKey": false,
2299
+ "notNull": false
2300
+ },
2301
+ "expires_at": {
2302
+ "name": "expires_at",
2303
+ "type": "timestamp",
2304
+ "primaryKey": false,
2305
+ "notNull": false
1668
2306
  }
1669
2307
  },
1670
2308
  "indexes": {
1671
- "monthly_usage_workspace_id_idx": {
1672
- "name": "monthly_usage_workspace_id_idx",
2309
+ "user_facts_user_idx": {
2310
+ "name": "user_facts_user_idx",
2311
+ "columns": [
2312
+ {
2313
+ "expression": "user_id",
2314
+ "isExpression": false,
2315
+ "asc": true,
2316
+ "nulls": "last"
2317
+ }
2318
+ ],
2319
+ "isUnique": false,
2320
+ "concurrently": false,
2321
+ "method": "btree",
2322
+ "with": {}
2323
+ },
2324
+ "user_facts_workspace_idx": {
2325
+ "name": "user_facts_workspace_idx",
2326
+ "columns": [
2327
+ {
2328
+ "expression": "workspace_id",
2329
+ "isExpression": false,
2330
+ "asc": true,
2331
+ "nulls": "last"
2332
+ }
2333
+ ],
2334
+ "isUnique": false,
2335
+ "concurrently": false,
2336
+ "method": "btree",
2337
+ "with": {}
2338
+ },
2339
+ "user_facts_category_idx": {
2340
+ "name": "user_facts_category_idx",
1673
2341
  "columns": [
1674
2342
  {
1675
2343
  "expression": "workspace_id",
1676
2344
  "isExpression": false,
1677
2345
  "asc": true,
1678
2346
  "nulls": "last"
2347
+ },
2348
+ {
2349
+ "expression": "category",
2350
+ "isExpression": false,
2351
+ "asc": true,
2352
+ "nulls": "last"
1679
2353
  }
1680
2354
  ],
1681
2355
  "isUnique": false,
1682
2356
  "concurrently": false,
1683
2357
  "method": "btree",
1684
2358
  "with": {}
2359
+ },
2360
+ "user_facts_user_workspace_category_key_uniq": {
2361
+ "name": "user_facts_user_workspace_category_key_uniq",
2362
+ "columns": [
2363
+ {
2364
+ "expression": "user_id",
2365
+ "isExpression": false,
2366
+ "asc": true,
2367
+ "nulls": "last"
2368
+ },
2369
+ {
2370
+ "expression": "workspace_id",
2371
+ "isExpression": false,
2372
+ "asc": true,
2373
+ "nulls": "last"
2374
+ },
2375
+ {
2376
+ "expression": "category",
2377
+ "isExpression": false,
2378
+ "asc": true,
2379
+ "nulls": "last"
2380
+ },
2381
+ {
2382
+ "expression": "key",
2383
+ "isExpression": false,
2384
+ "asc": true,
2385
+ "nulls": "last"
2386
+ }
2387
+ ],
2388
+ "isUnique": true,
2389
+ "concurrently": false,
2390
+ "method": "btree",
2391
+ "with": {}
1685
2392
  }
1686
2393
  },
1687
2394
  "foreignKeys": {
1688
- "monthly_usage_workspace_id_organization_id_fk": {
1689
- "name": "monthly_usage_workspace_id_organization_id_fk",
1690
- "tableFrom": "monthly_usage",
2395
+ "user_facts_user_id_users_id_fk": {
2396
+ "name": "user_facts_user_id_users_id_fk",
2397
+ "tableFrom": "user_facts",
2398
+ "tableTo": "users",
2399
+ "columnsFrom": ["user_id"],
2400
+ "columnsTo": ["id"],
2401
+ "onDelete": "cascade",
2402
+ "onUpdate": "no action"
2403
+ },
2404
+ "user_facts_workspace_id_organization_id_fk": {
2405
+ "name": "user_facts_workspace_id_organization_id_fk",
2406
+ "tableFrom": "user_facts",
1691
2407
  "tableTo": "organization",
1692
2408
  "columnsFrom": ["workspace_id"],
1693
2409
  "columnsTo": ["id"],
@@ -1696,19 +2412,13 @@
1696
2412
  }
1697
2413
  },
1698
2414
  "compositePrimaryKeys": {},
1699
- "uniqueConstraints": {
1700
- "monthly_usage_workspace_period_unique": {
1701
- "name": "monthly_usage_workspace_period_unique",
1702
- "nullsNotDistinct": false,
1703
- "columns": ["workspace_id", "period_start"]
1704
- }
1705
- },
2415
+ "uniqueConstraints": {},
1706
2416
  "policies": {},
1707
2417
  "checkConstraints": {},
1708
2418
  "isRLSEnabled": false
1709
2419
  },
1710
- "public.notification_history": {
1711
- "name": "notification_history",
2420
+ "public.user_memories": {
2421
+ "name": "user_memories",
1712
2422
  "schema": "",
1713
2423
  "columns": {
1714
2424
  "id": {
@@ -1717,48 +2427,1241 @@
1717
2427
  "primaryKey": true,
1718
2428
  "notNull": true
1719
2429
  },
2430
+ "user_id": {
2431
+ "name": "user_id",
2432
+ "type": "text",
2433
+ "primaryKey": false,
2434
+ "notNull": true
2435
+ },
1720
2436
  "workspace_id": {
1721
2437
  "name": "workspace_id",
1722
2438
  "type": "text",
1723
2439
  "primaryKey": false,
1724
2440
  "notNull": true
1725
2441
  },
1726
- "type": {
1727
- "name": "type",
2442
+ "kind": {
2443
+ "name": "kind",
1728
2444
  "type": "text",
1729
2445
  "primaryKey": false,
1730
2446
  "notNull": true
1731
2447
  },
1732
- "period_key": {
1733
- "name": "period_key",
2448
+ "content": {
2449
+ "name": "content",
1734
2450
  "type": "text",
1735
2451
  "primaryKey": false,
1736
2452
  "notNull": true
1737
2453
  },
1738
- "sent_at": {
1739
- "name": "sent_at",
1740
- "type": "timestamp",
1741
- "primaryKey": false,
2454
+ "embedding": {
2455
+ "name": "embedding",
2456
+ "type": "vector(1536)",
2457
+ "primaryKey": false,
2458
+ "notNull": false
2459
+ },
2460
+ "source_product": {
2461
+ "name": "source_product",
2462
+ "type": "text",
2463
+ "primaryKey": false,
2464
+ "notNull": false
2465
+ },
2466
+ "source_session_id": {
2467
+ "name": "source_session_id",
2468
+ "type": "text",
2469
+ "primaryKey": false,
2470
+ "notNull": false
2471
+ },
2472
+ "source_message_ids": {
2473
+ "name": "source_message_ids",
2474
+ "type": "text[]",
2475
+ "primaryKey": false,
2476
+ "notNull": false
2477
+ },
2478
+ "importance": {
2479
+ "name": "importance",
2480
+ "type": "integer",
2481
+ "primaryKey": false,
2482
+ "notNull": true,
2483
+ "default": 5
2484
+ },
2485
+ "decay_factor": {
2486
+ "name": "decay_factor",
2487
+ "type": "double precision",
2488
+ "primaryKey": false,
2489
+ "notNull": true,
2490
+ "default": 1
2491
+ },
2492
+ "metadata": {
2493
+ "name": "metadata",
2494
+ "type": "jsonb",
2495
+ "primaryKey": false,
2496
+ "notNull": false
2497
+ },
2498
+ "created_at": {
2499
+ "name": "created_at",
2500
+ "type": "timestamp",
2501
+ "primaryKey": false,
2502
+ "notNull": true,
2503
+ "default": "now()"
2504
+ }
2505
+ },
2506
+ "indexes": {
2507
+ "user_memories_user_idx": {
2508
+ "name": "user_memories_user_idx",
2509
+ "columns": [
2510
+ {
2511
+ "expression": "user_id",
2512
+ "isExpression": false,
2513
+ "asc": true,
2514
+ "nulls": "last"
2515
+ }
2516
+ ],
2517
+ "isUnique": false,
2518
+ "concurrently": false,
2519
+ "method": "btree",
2520
+ "with": {}
2521
+ },
2522
+ "user_memories_workspace_idx": {
2523
+ "name": "user_memories_workspace_idx",
2524
+ "columns": [
2525
+ {
2526
+ "expression": "workspace_id",
2527
+ "isExpression": false,
2528
+ "asc": true,
2529
+ "nulls": "last"
2530
+ }
2531
+ ],
2532
+ "isUnique": false,
2533
+ "concurrently": false,
2534
+ "method": "btree",
2535
+ "with": {}
2536
+ },
2537
+ "user_memories_kind_idx": {
2538
+ "name": "user_memories_kind_idx",
2539
+ "columns": [
2540
+ {
2541
+ "expression": "workspace_id",
2542
+ "isExpression": false,
2543
+ "asc": true,
2544
+ "nulls": "last"
2545
+ },
2546
+ {
2547
+ "expression": "kind",
2548
+ "isExpression": false,
2549
+ "asc": true,
2550
+ "nulls": "last"
2551
+ }
2552
+ ],
2553
+ "isUnique": false,
2554
+ "concurrently": false,
2555
+ "method": "btree",
2556
+ "with": {}
2557
+ }
2558
+ },
2559
+ "foreignKeys": {
2560
+ "user_memories_user_id_users_id_fk": {
2561
+ "name": "user_memories_user_id_users_id_fk",
2562
+ "tableFrom": "user_memories",
2563
+ "tableTo": "users",
2564
+ "columnsFrom": ["user_id"],
2565
+ "columnsTo": ["id"],
2566
+ "onDelete": "cascade",
2567
+ "onUpdate": "no action"
2568
+ },
2569
+ "user_memories_workspace_id_organization_id_fk": {
2570
+ "name": "user_memories_workspace_id_organization_id_fk",
2571
+ "tableFrom": "user_memories",
2572
+ "tableTo": "organization",
2573
+ "columnsFrom": ["workspace_id"],
2574
+ "columnsTo": ["id"],
2575
+ "onDelete": "cascade",
2576
+ "onUpdate": "no action"
2577
+ }
2578
+ },
2579
+ "compositePrimaryKeys": {},
2580
+ "uniqueConstraints": {},
2581
+ "policies": {},
2582
+ "checkConstraints": {},
2583
+ "isRLSEnabled": false
2584
+ },
2585
+ "public.user_memory_audit": {
2586
+ "name": "user_memory_audit",
2587
+ "schema": "",
2588
+ "columns": {
2589
+ "id": {
2590
+ "name": "id",
2591
+ "type": "text",
2592
+ "primaryKey": true,
2593
+ "notNull": true
2594
+ },
2595
+ "user_id": {
2596
+ "name": "user_id",
2597
+ "type": "text",
2598
+ "primaryKey": false,
2599
+ "notNull": true
2600
+ },
2601
+ "workspace_id": {
2602
+ "name": "workspace_id",
2603
+ "type": "text",
2604
+ "primaryKey": false,
2605
+ "notNull": true
2606
+ },
2607
+ "target_kind": {
2608
+ "name": "target_kind",
2609
+ "type": "text",
2610
+ "primaryKey": false,
2611
+ "notNull": true
2612
+ },
2613
+ "target_id": {
2614
+ "name": "target_id",
2615
+ "type": "text",
2616
+ "primaryKey": false,
2617
+ "notNull": true
2618
+ },
2619
+ "action": {
2620
+ "name": "action",
2621
+ "type": "text",
2622
+ "primaryKey": false,
2623
+ "notNull": true
2624
+ },
2625
+ "actor_kind": {
2626
+ "name": "actor_kind",
2627
+ "type": "text",
2628
+ "primaryKey": false,
2629
+ "notNull": true
2630
+ },
2631
+ "actor_id": {
2632
+ "name": "actor_id",
2633
+ "type": "text",
2634
+ "primaryKey": false,
2635
+ "notNull": false
2636
+ },
2637
+ "before_value": {
2638
+ "name": "before_value",
2639
+ "type": "jsonb",
2640
+ "primaryKey": false,
2641
+ "notNull": false
2642
+ },
2643
+ "after_value": {
2644
+ "name": "after_value",
2645
+ "type": "jsonb",
2646
+ "primaryKey": false,
2647
+ "notNull": false
2648
+ },
2649
+ "reason": {
2650
+ "name": "reason",
2651
+ "type": "text",
2652
+ "primaryKey": false,
2653
+ "notNull": false
2654
+ },
2655
+ "created_at": {
2656
+ "name": "created_at",
2657
+ "type": "timestamp",
2658
+ "primaryKey": false,
2659
+ "notNull": true,
2660
+ "default": "now()"
2661
+ }
2662
+ },
2663
+ "indexes": {
2664
+ "user_memory_audit_user_idx": {
2665
+ "name": "user_memory_audit_user_idx",
2666
+ "columns": [
2667
+ {
2668
+ "expression": "user_id",
2669
+ "isExpression": false,
2670
+ "asc": true,
2671
+ "nulls": "last"
2672
+ }
2673
+ ],
2674
+ "isUnique": false,
2675
+ "concurrently": false,
2676
+ "method": "btree",
2677
+ "with": {}
2678
+ },
2679
+ "user_memory_audit_workspace_idx": {
2680
+ "name": "user_memory_audit_workspace_idx",
2681
+ "columns": [
2682
+ {
2683
+ "expression": "workspace_id",
2684
+ "isExpression": false,
2685
+ "asc": true,
2686
+ "nulls": "last"
2687
+ }
2688
+ ],
2689
+ "isUnique": false,
2690
+ "concurrently": false,
2691
+ "method": "btree",
2692
+ "with": {}
2693
+ },
2694
+ "user_memory_audit_target_idx": {
2695
+ "name": "user_memory_audit_target_idx",
2696
+ "columns": [
2697
+ {
2698
+ "expression": "target_kind",
2699
+ "isExpression": false,
2700
+ "asc": true,
2701
+ "nulls": "last"
2702
+ },
2703
+ {
2704
+ "expression": "target_id",
2705
+ "isExpression": false,
2706
+ "asc": true,
2707
+ "nulls": "last"
2708
+ }
2709
+ ],
2710
+ "isUnique": false,
2711
+ "concurrently": false,
2712
+ "method": "btree",
2713
+ "with": {}
2714
+ }
2715
+ },
2716
+ "foreignKeys": {
2717
+ "user_memory_audit_user_id_users_id_fk": {
2718
+ "name": "user_memory_audit_user_id_users_id_fk",
2719
+ "tableFrom": "user_memory_audit",
2720
+ "tableTo": "users",
2721
+ "columnsFrom": ["user_id"],
2722
+ "columnsTo": ["id"],
2723
+ "onDelete": "cascade",
2724
+ "onUpdate": "no action"
2725
+ },
2726
+ "user_memory_audit_workspace_id_organization_id_fk": {
2727
+ "name": "user_memory_audit_workspace_id_organization_id_fk",
2728
+ "tableFrom": "user_memory_audit",
2729
+ "tableTo": "organization",
2730
+ "columnsFrom": ["workspace_id"],
2731
+ "columnsTo": ["id"],
2732
+ "onDelete": "cascade",
2733
+ "onUpdate": "no action"
2734
+ }
2735
+ },
2736
+ "compositePrimaryKeys": {},
2737
+ "uniqueConstraints": {},
2738
+ "policies": {},
2739
+ "checkConstraints": {},
2740
+ "isRLSEnabled": false
2741
+ },
2742
+ "public.user_profile_snapshots": {
2743
+ "name": "user_profile_snapshots",
2744
+ "schema": "",
2745
+ "columns": {
2746
+ "user_id": {
2747
+ "name": "user_id",
2748
+ "type": "text",
2749
+ "primaryKey": false,
2750
+ "notNull": true
2751
+ },
2752
+ "workspace_id": {
2753
+ "name": "workspace_id",
2754
+ "type": "text",
2755
+ "primaryKey": false,
2756
+ "notNull": true
2757
+ },
2758
+ "version": {
2759
+ "name": "version",
2760
+ "type": "integer",
2761
+ "primaryKey": false,
2762
+ "notNull": true
2763
+ },
2764
+ "summary": {
2765
+ "name": "summary",
2766
+ "type": "text",
2767
+ "primaryKey": false,
2768
+ "notNull": true
2769
+ },
2770
+ "summary_en": {
2771
+ "name": "summary_en",
2772
+ "type": "text",
2773
+ "primaryKey": false,
2774
+ "notNull": false
2775
+ },
2776
+ "summary_mn": {
2777
+ "name": "summary_mn",
2778
+ "type": "text",
2779
+ "primaryKey": false,
2780
+ "notNull": false
2781
+ },
2782
+ "facts_digest": {
2783
+ "name": "facts_digest",
2784
+ "type": "jsonb",
2785
+ "primaryKey": false,
2786
+ "notNull": true
2787
+ },
2788
+ "active_goals": {
2789
+ "name": "active_goals",
2790
+ "type": "jsonb",
2791
+ "primaryKey": false,
2792
+ "notNull": false
2793
+ },
2794
+ "personality_signals": {
2795
+ "name": "personality_signals",
2796
+ "type": "jsonb",
2797
+ "primaryKey": false,
2798
+ "notNull": false
2799
+ },
2800
+ "relationship_notes": {
2801
+ "name": "relationship_notes",
2802
+ "type": "jsonb",
2803
+ "primaryKey": false,
2804
+ "notNull": false
2805
+ },
2806
+ "synthesized_by_model": {
2807
+ "name": "synthesized_by_model",
2808
+ "type": "text",
2809
+ "primaryKey": false,
2810
+ "notNull": false
2811
+ },
2812
+ "synthesized_at": {
2813
+ "name": "synthesized_at",
2814
+ "type": "timestamp",
2815
+ "primaryKey": false,
2816
+ "notNull": true,
2817
+ "default": "now()"
2818
+ },
2819
+ "next_synthesis_at": {
2820
+ "name": "next_synthesis_at",
2821
+ "type": "timestamp",
2822
+ "primaryKey": false,
2823
+ "notNull": false
2824
+ },
2825
+ "trigger_reason": {
2826
+ "name": "trigger_reason",
2827
+ "type": "text",
2828
+ "primaryKey": false,
2829
+ "notNull": false
2830
+ }
2831
+ },
2832
+ "indexes": {
2833
+ "user_profile_snapshots_workspace_idx": {
2834
+ "name": "user_profile_snapshots_workspace_idx",
2835
+ "columns": [
2836
+ {
2837
+ "expression": "workspace_id",
2838
+ "isExpression": false,
2839
+ "asc": true,
2840
+ "nulls": "last"
2841
+ }
2842
+ ],
2843
+ "isUnique": false,
2844
+ "concurrently": false,
2845
+ "method": "btree",
2846
+ "with": {}
2847
+ }
2848
+ },
2849
+ "foreignKeys": {
2850
+ "user_profile_snapshots_user_id_users_id_fk": {
2851
+ "name": "user_profile_snapshots_user_id_users_id_fk",
2852
+ "tableFrom": "user_profile_snapshots",
2853
+ "tableTo": "users",
2854
+ "columnsFrom": ["user_id"],
2855
+ "columnsTo": ["id"],
2856
+ "onDelete": "cascade",
2857
+ "onUpdate": "no action"
2858
+ },
2859
+ "user_profile_snapshots_workspace_id_organization_id_fk": {
2860
+ "name": "user_profile_snapshots_workspace_id_organization_id_fk",
2861
+ "tableFrom": "user_profile_snapshots",
2862
+ "tableTo": "organization",
2863
+ "columnsFrom": ["workspace_id"],
2864
+ "columnsTo": ["id"],
2865
+ "onDelete": "cascade",
2866
+ "onUpdate": "no action"
2867
+ }
2868
+ },
2869
+ "compositePrimaryKeys": {
2870
+ "user_profile_snapshots_user_id_workspace_id_pk": {
2871
+ "name": "user_profile_snapshots_user_id_workspace_id_pk",
2872
+ "columns": ["user_id", "workspace_id"]
2873
+ }
2874
+ },
2875
+ "uniqueConstraints": {},
2876
+ "policies": {},
2877
+ "checkConstraints": {},
2878
+ "isRLSEnabled": false
2879
+ },
2880
+ "public.monthly_usage": {
2881
+ "name": "monthly_usage",
2882
+ "schema": "",
2883
+ "columns": {
2884
+ "id": {
2885
+ "name": "id",
2886
+ "type": "text",
2887
+ "primaryKey": true,
2888
+ "notNull": true
2889
+ },
2890
+ "workspace_id": {
2891
+ "name": "workspace_id",
2892
+ "type": "text",
2893
+ "primaryKey": false,
2894
+ "notNull": true
2895
+ },
2896
+ "period_start": {
2897
+ "name": "period_start",
2898
+ "type": "timestamp",
2899
+ "primaryKey": false,
2900
+ "notNull": true
2901
+ },
2902
+ "period_end": {
2903
+ "name": "period_end",
2904
+ "type": "timestamp",
2905
+ "primaryKey": false,
2906
+ "notNull": true
2907
+ },
2908
+ "tokens_used": {
2909
+ "name": "tokens_used",
2910
+ "type": "integer",
2911
+ "primaryKey": false,
2912
+ "notNull": true,
2913
+ "default": 0
2914
+ },
2915
+ "allowance_used_micros": {
2916
+ "name": "allowance_used_micros",
2917
+ "type": "bigint",
2918
+ "primaryKey": false,
2919
+ "notNull": true,
2920
+ "default": 0
2921
+ },
2922
+ "currency": {
2923
+ "name": "currency",
2924
+ "type": "text",
2925
+ "primaryKey": false,
2926
+ "notNull": true,
2927
+ "default": "'USD'"
2928
+ },
2929
+ "request_count": {
2930
+ "name": "request_count",
2931
+ "type": "integer",
2932
+ "primaryKey": false,
2933
+ "notNull": true,
2934
+ "default": 0
2935
+ },
2936
+ "updated_at": {
2937
+ "name": "updated_at",
2938
+ "type": "timestamp",
2939
+ "primaryKey": false,
2940
+ "notNull": true,
2941
+ "default": "now()"
2942
+ }
2943
+ },
2944
+ "indexes": {
2945
+ "monthly_usage_workspace_id_idx": {
2946
+ "name": "monthly_usage_workspace_id_idx",
2947
+ "columns": [
2948
+ {
2949
+ "expression": "workspace_id",
2950
+ "isExpression": false,
2951
+ "asc": true,
2952
+ "nulls": "last"
2953
+ }
2954
+ ],
2955
+ "isUnique": false,
2956
+ "concurrently": false,
2957
+ "method": "btree",
2958
+ "with": {}
2959
+ }
2960
+ },
2961
+ "foreignKeys": {
2962
+ "monthly_usage_workspace_id_organization_id_fk": {
2963
+ "name": "monthly_usage_workspace_id_organization_id_fk",
2964
+ "tableFrom": "monthly_usage",
2965
+ "tableTo": "organization",
2966
+ "columnsFrom": ["workspace_id"],
2967
+ "columnsTo": ["id"],
2968
+ "onDelete": "cascade",
2969
+ "onUpdate": "no action"
2970
+ }
2971
+ },
2972
+ "compositePrimaryKeys": {},
2973
+ "uniqueConstraints": {
2974
+ "monthly_usage_workspace_period_unique": {
2975
+ "name": "monthly_usage_workspace_period_unique",
2976
+ "nullsNotDistinct": false,
2977
+ "columns": ["workspace_id", "period_start"]
2978
+ }
2979
+ },
2980
+ "policies": {},
2981
+ "checkConstraints": {},
2982
+ "isRLSEnabled": false
2983
+ },
2984
+ "public.notification_history": {
2985
+ "name": "notification_history",
2986
+ "schema": "",
2987
+ "columns": {
2988
+ "id": {
2989
+ "name": "id",
2990
+ "type": "text",
2991
+ "primaryKey": true,
2992
+ "notNull": true
2993
+ },
2994
+ "workspace_id": {
2995
+ "name": "workspace_id",
2996
+ "type": "text",
2997
+ "primaryKey": false,
2998
+ "notNull": true
2999
+ },
3000
+ "type": {
3001
+ "name": "type",
3002
+ "type": "text",
3003
+ "primaryKey": false,
3004
+ "notNull": true
3005
+ },
3006
+ "period_key": {
3007
+ "name": "period_key",
3008
+ "type": "text",
3009
+ "primaryKey": false,
3010
+ "notNull": true
3011
+ },
3012
+ "sent_at": {
3013
+ "name": "sent_at",
3014
+ "type": "timestamp",
3015
+ "primaryKey": false,
3016
+ "notNull": true,
3017
+ "default": "now()"
3018
+ },
3019
+ "channel": {
3020
+ "name": "channel",
3021
+ "type": "text",
3022
+ "primaryKey": false,
3023
+ "notNull": true,
3024
+ "default": "'console'"
3025
+ },
3026
+ "metadata": {
3027
+ "name": "metadata",
3028
+ "type": "text",
3029
+ "primaryKey": false,
3030
+ "notNull": false
3031
+ }
3032
+ },
3033
+ "indexes": {
3034
+ "notification_history_workspace_id_idx": {
3035
+ "name": "notification_history_workspace_id_idx",
3036
+ "columns": [
3037
+ {
3038
+ "expression": "workspace_id",
3039
+ "isExpression": false,
3040
+ "asc": true,
3041
+ "nulls": "last"
3042
+ }
3043
+ ],
3044
+ "isUnique": false,
3045
+ "concurrently": false,
3046
+ "method": "btree",
3047
+ "with": {}
3048
+ }
3049
+ },
3050
+ "foreignKeys": {
3051
+ "notification_history_workspace_id_organization_id_fk": {
3052
+ "name": "notification_history_workspace_id_organization_id_fk",
3053
+ "tableFrom": "notification_history",
3054
+ "tableTo": "organization",
3055
+ "columnsFrom": ["workspace_id"],
3056
+ "columnsTo": ["id"],
3057
+ "onDelete": "cascade",
3058
+ "onUpdate": "no action"
3059
+ }
3060
+ },
3061
+ "compositePrimaryKeys": {},
3062
+ "uniqueConstraints": {
3063
+ "notification_history_dedup_unique": {
3064
+ "name": "notification_history_dedup_unique",
3065
+ "nullsNotDistinct": false,
3066
+ "columns": ["workspace_id", "type", "period_key"]
3067
+ }
3068
+ },
3069
+ "policies": {},
3070
+ "checkConstraints": {},
3071
+ "isRLSEnabled": false
3072
+ },
3073
+ "public.rate_limit_entries": {
3074
+ "name": "rate_limit_entries",
3075
+ "schema": "",
3076
+ "columns": {
3077
+ "id": {
3078
+ "name": "id",
3079
+ "type": "text",
3080
+ "primaryKey": true,
3081
+ "notNull": true
3082
+ },
3083
+ "workspace_id": {
3084
+ "name": "workspace_id",
3085
+ "type": "text",
3086
+ "primaryKey": false,
3087
+ "notNull": true
3088
+ },
3089
+ "endpoint": {
3090
+ "name": "endpoint",
3091
+ "type": "text",
3092
+ "primaryKey": false,
3093
+ "notNull": true,
3094
+ "default": "'chat'"
3095
+ },
3096
+ "requested_at": {
3097
+ "name": "requested_at",
3098
+ "type": "timestamp",
3099
+ "primaryKey": false,
3100
+ "notNull": true,
3101
+ "default": "now()"
3102
+ },
3103
+ "minute_bucket": {
3104
+ "name": "minute_bucket",
3105
+ "type": "timestamp",
3106
+ "primaryKey": false,
3107
+ "notNull": true
3108
+ },
3109
+ "count": {
3110
+ "name": "count",
3111
+ "type": "integer",
3112
+ "primaryKey": false,
3113
+ "notNull": true,
3114
+ "default": 1
3115
+ }
3116
+ },
3117
+ "indexes": {
3118
+ "rate_limit_entries_window_idx": {
3119
+ "name": "rate_limit_entries_window_idx",
3120
+ "columns": [
3121
+ {
3122
+ "expression": "workspace_id",
3123
+ "isExpression": false,
3124
+ "asc": true,
3125
+ "nulls": "last"
3126
+ },
3127
+ {
3128
+ "expression": "endpoint",
3129
+ "isExpression": false,
3130
+ "asc": true,
3131
+ "nulls": "last"
3132
+ },
3133
+ {
3134
+ "expression": "requested_at",
3135
+ "isExpression": false,
3136
+ "asc": true,
3137
+ "nulls": "last"
3138
+ }
3139
+ ],
3140
+ "isUnique": false,
3141
+ "concurrently": false,
3142
+ "method": "btree",
3143
+ "with": {}
3144
+ }
3145
+ },
3146
+ "foreignKeys": {
3147
+ "rate_limit_entries_workspace_id_organization_id_fk": {
3148
+ "name": "rate_limit_entries_workspace_id_organization_id_fk",
3149
+ "tableFrom": "rate_limit_entries",
3150
+ "tableTo": "organization",
3151
+ "columnsFrom": ["workspace_id"],
3152
+ "columnsTo": ["id"],
3153
+ "onDelete": "cascade",
3154
+ "onUpdate": "no action"
3155
+ }
3156
+ },
3157
+ "compositePrimaryKeys": {},
3158
+ "uniqueConstraints": {
3159
+ "rate_limit_entries_unique_bucket_idx": {
3160
+ "name": "rate_limit_entries_unique_bucket_idx",
3161
+ "nullsNotDistinct": false,
3162
+ "columns": ["workspace_id", "endpoint", "minute_bucket"]
3163
+ }
3164
+ },
3165
+ "policies": {},
3166
+ "checkConstraints": {},
3167
+ "isRLSEnabled": false
3168
+ },
3169
+ "public.trial_credits": {
3170
+ "name": "trial_credits",
3171
+ "schema": "",
3172
+ "columns": {
3173
+ "id": {
3174
+ "name": "id",
3175
+ "type": "text",
3176
+ "primaryKey": true,
3177
+ "notNull": true
3178
+ },
3179
+ "workspace_id": {
3180
+ "name": "workspace_id",
3181
+ "type": "text",
3182
+ "primaryKey": false,
3183
+ "notNull": true
3184
+ },
3185
+ "initial_credits": {
3186
+ "name": "initial_credits",
3187
+ "type": "integer",
3188
+ "primaryKey": false,
3189
+ "notNull": true,
3190
+ "default": 100000
3191
+ },
3192
+ "credits_used": {
3193
+ "name": "credits_used",
3194
+ "type": "integer",
3195
+ "primaryKey": false,
3196
+ "notNull": true,
3197
+ "default": 0
3198
+ },
3199
+ "credits_remaining": {
3200
+ "name": "credits_remaining",
3201
+ "type": "integer",
3202
+ "primaryKey": false,
3203
+ "notNull": true,
3204
+ "default": 100000
3205
+ },
3206
+ "initial_micros": {
3207
+ "name": "initial_micros",
3208
+ "type": "bigint",
3209
+ "primaryKey": false,
3210
+ "notNull": true,
3211
+ "default": 0
3212
+ },
3213
+ "used_micros": {
3214
+ "name": "used_micros",
3215
+ "type": "bigint",
3216
+ "primaryKey": false,
3217
+ "notNull": true,
3218
+ "default": 0
3219
+ },
3220
+ "remaining_micros": {
3221
+ "name": "remaining_micros",
3222
+ "type": "bigint",
3223
+ "primaryKey": false,
3224
+ "notNull": true,
3225
+ "default": 0
3226
+ },
3227
+ "currency": {
3228
+ "name": "currency",
3229
+ "type": "text",
3230
+ "primaryKey": false,
3231
+ "notNull": true,
3232
+ "default": "'USD'"
3233
+ },
3234
+ "status": {
3235
+ "name": "status",
3236
+ "type": "text",
3237
+ "primaryKey": false,
3238
+ "notNull": true,
3239
+ "default": "'active'"
3240
+ },
3241
+ "provisioned_at": {
3242
+ "name": "provisioned_at",
3243
+ "type": "timestamp",
3244
+ "primaryKey": false,
3245
+ "notNull": true,
3246
+ "default": "now()"
3247
+ },
3248
+ "trial_end_date": {
3249
+ "name": "trial_end_date",
3250
+ "type": "timestamp",
3251
+ "primaryKey": false,
3252
+ "notNull": false
3253
+ },
3254
+ "depleted_at": {
3255
+ "name": "depleted_at",
3256
+ "type": "timestamp",
3257
+ "primaryKey": false,
3258
+ "notNull": false
3259
+ },
3260
+ "converted_at": {
3261
+ "name": "converted_at",
3262
+ "type": "timestamp",
3263
+ "primaryKey": false,
3264
+ "notNull": false
3265
+ },
3266
+ "created_by_ip": {
3267
+ "name": "created_by_ip",
3268
+ "type": "text",
3269
+ "primaryKey": false,
3270
+ "notNull": false
3271
+ },
3272
+ "created_by_email": {
3273
+ "name": "created_by_email",
3274
+ "type": "text",
3275
+ "primaryKey": false,
3276
+ "notNull": false
3277
+ },
3278
+ "normalized_email": {
3279
+ "name": "normalized_email",
3280
+ "type": "text",
3281
+ "primaryKey": false,
3282
+ "notNull": false
3283
+ }
3284
+ },
3285
+ "indexes": {
3286
+ "trial_credits_expiry_idx": {
3287
+ "name": "trial_credits_expiry_idx",
3288
+ "columns": [
3289
+ {
3290
+ "expression": "status",
3291
+ "isExpression": false,
3292
+ "asc": true,
3293
+ "nulls": "last"
3294
+ },
3295
+ {
3296
+ "expression": "trial_end_date",
3297
+ "isExpression": false,
3298
+ "asc": true,
3299
+ "nulls": "last"
3300
+ }
3301
+ ],
3302
+ "isUnique": false,
3303
+ "concurrently": false,
3304
+ "method": "btree",
3305
+ "with": {}
3306
+ },
3307
+ "trial_credits_normalized_email_idx": {
3308
+ "name": "trial_credits_normalized_email_idx",
3309
+ "columns": [
3310
+ {
3311
+ "expression": "normalized_email",
3312
+ "isExpression": false,
3313
+ "asc": true,
3314
+ "nulls": "last"
3315
+ }
3316
+ ],
3317
+ "isUnique": false,
3318
+ "concurrently": false,
3319
+ "method": "btree",
3320
+ "with": {}
3321
+ }
3322
+ },
3323
+ "foreignKeys": {
3324
+ "trial_credits_workspace_id_organization_id_fk": {
3325
+ "name": "trial_credits_workspace_id_organization_id_fk",
3326
+ "tableFrom": "trial_credits",
3327
+ "tableTo": "organization",
3328
+ "columnsFrom": ["workspace_id"],
3329
+ "columnsTo": ["id"],
3330
+ "onDelete": "cascade",
3331
+ "onUpdate": "no action"
3332
+ }
3333
+ },
3334
+ "compositePrimaryKeys": {},
3335
+ "uniqueConstraints": {
3336
+ "trial_credits_workspace_id_unique": {
3337
+ "name": "trial_credits_workspace_id_unique",
3338
+ "nullsNotDistinct": false,
3339
+ "columns": ["workspace_id"]
3340
+ }
3341
+ },
3342
+ "policies": {},
3343
+ "checkConstraints": {},
3344
+ "isRLSEnabled": false
3345
+ },
3346
+ "public.usage_records": {
3347
+ "name": "usage_records",
3348
+ "schema": "",
3349
+ "columns": {
3350
+ "id": {
3351
+ "name": "id",
3352
+ "type": "text",
3353
+ "primaryKey": true,
3354
+ "notNull": true
3355
+ },
3356
+ "workspace_id": {
3357
+ "name": "workspace_id",
3358
+ "type": "text",
3359
+ "primaryKey": false,
3360
+ "notNull": true
3361
+ },
3362
+ "user_id": {
3363
+ "name": "user_id",
3364
+ "type": "text",
3365
+ "primaryKey": false,
3366
+ "notNull": true
3367
+ },
3368
+ "type": {
3369
+ "name": "type",
3370
+ "type": "text",
3371
+ "primaryKey": false,
3372
+ "notNull": true
3373
+ },
3374
+ "model": {
3375
+ "name": "model",
3376
+ "type": "text",
3377
+ "primaryKey": false,
3378
+ "notNull": false
3379
+ },
3380
+ "agent": {
3381
+ "name": "agent",
3382
+ "type": "text",
3383
+ "primaryKey": false,
3384
+ "notNull": false
3385
+ },
3386
+ "input_tokens": {
3387
+ "name": "input_tokens",
3388
+ "type": "integer",
3389
+ "primaryKey": false,
3390
+ "notNull": true,
3391
+ "default": 0
3392
+ },
3393
+ "output_tokens": {
3394
+ "name": "output_tokens",
3395
+ "type": "integer",
3396
+ "primaryKey": false,
3397
+ "notNull": true,
3398
+ "default": 0
3399
+ },
3400
+ "total_tokens": {
3401
+ "name": "total_tokens",
3402
+ "type": "integer",
3403
+ "primaryKey": false,
3404
+ "notNull": true,
3405
+ "default": 0
3406
+ },
3407
+ "provider_cost_micros": {
3408
+ "name": "provider_cost_micros",
3409
+ "type": "bigint",
3410
+ "primaryKey": false,
3411
+ "notNull": true,
3412
+ "default": 0
3413
+ },
3414
+ "margin_bp": {
3415
+ "name": "margin_bp",
3416
+ "type": "integer",
3417
+ "primaryKey": false,
3418
+ "notNull": true,
3419
+ "default": 0
3420
+ },
3421
+ "usd_rate_micros": {
3422
+ "name": "usd_rate_micros",
3423
+ "type": "bigint",
3424
+ "primaryKey": false,
3425
+ "notNull": true,
3426
+ "default": 0
3427
+ },
3428
+ "charged_micros": {
3429
+ "name": "charged_micros",
3430
+ "type": "bigint",
3431
+ "primaryKey": false,
3432
+ "notNull": true,
3433
+ "default": 0
3434
+ },
3435
+ "currency": {
3436
+ "name": "currency",
3437
+ "type": "text",
3438
+ "primaryKey": false,
3439
+ "notNull": true,
3440
+ "default": "'USD'"
3441
+ },
3442
+ "request_id": {
3443
+ "name": "request_id",
3444
+ "type": "text",
3445
+ "primaryKey": false,
3446
+ "notNull": false
3447
+ },
3448
+ "execution_id": {
3449
+ "name": "execution_id",
3450
+ "type": "text",
3451
+ "primaryKey": false,
3452
+ "notNull": false
3453
+ },
3454
+ "conversation_id": {
3455
+ "name": "conversation_id",
3456
+ "type": "text",
3457
+ "primaryKey": false,
3458
+ "notNull": false
3459
+ },
3460
+ "metadata": {
3461
+ "name": "metadata",
3462
+ "type": "text",
3463
+ "primaryKey": false,
3464
+ "notNull": false
3465
+ },
3466
+ "recorded_at": {
3467
+ "name": "recorded_at",
3468
+ "type": "timestamp",
3469
+ "primaryKey": false,
1742
3470
  "notNull": true,
1743
3471
  "default": "now()"
3472
+ }
3473
+ },
3474
+ "indexes": {
3475
+ "usage_records_workspace_id_idx": {
3476
+ "name": "usage_records_workspace_id_idx",
3477
+ "columns": [
3478
+ {
3479
+ "expression": "workspace_id",
3480
+ "isExpression": false,
3481
+ "asc": true,
3482
+ "nulls": "last"
3483
+ }
3484
+ ],
3485
+ "isUnique": false,
3486
+ "concurrently": false,
3487
+ "method": "btree",
3488
+ "with": {}
3489
+ },
3490
+ "usage_records_workspace_recorded_at_idx": {
3491
+ "name": "usage_records_workspace_recorded_at_idx",
3492
+ "columns": [
3493
+ {
3494
+ "expression": "workspace_id",
3495
+ "isExpression": false,
3496
+ "asc": true,
3497
+ "nulls": "last"
3498
+ },
3499
+ {
3500
+ "expression": "recorded_at",
3501
+ "isExpression": false,
3502
+ "asc": true,
3503
+ "nulls": "last"
3504
+ }
3505
+ ],
3506
+ "isUnique": false,
3507
+ "concurrently": false,
3508
+ "method": "btree",
3509
+ "with": {}
3510
+ },
3511
+ "usage_records_workspace_type_idx": {
3512
+ "name": "usage_records_workspace_type_idx",
3513
+ "columns": [
3514
+ {
3515
+ "expression": "workspace_id",
3516
+ "isExpression": false,
3517
+ "asc": true,
3518
+ "nulls": "last"
3519
+ },
3520
+ {
3521
+ "expression": "type",
3522
+ "isExpression": false,
3523
+ "asc": true,
3524
+ "nulls": "last"
3525
+ }
3526
+ ],
3527
+ "isUnique": false,
3528
+ "concurrently": false,
3529
+ "method": "btree",
3530
+ "with": {}
3531
+ },
3532
+ "usage_records_conversation_id_idx": {
3533
+ "name": "usage_records_conversation_id_idx",
3534
+ "columns": [
3535
+ {
3536
+ "expression": "conversation_id",
3537
+ "isExpression": false,
3538
+ "asc": true,
3539
+ "nulls": "last"
3540
+ }
3541
+ ],
3542
+ "isUnique": false,
3543
+ "concurrently": false,
3544
+ "method": "btree",
3545
+ "with": {}
3546
+ },
3547
+ "usage_records_execution_id_idx": {
3548
+ "name": "usage_records_execution_id_idx",
3549
+ "columns": [
3550
+ {
3551
+ "expression": "execution_id",
3552
+ "isExpression": false,
3553
+ "asc": true,
3554
+ "nulls": "last"
3555
+ }
3556
+ ],
3557
+ "isUnique": false,
3558
+ "concurrently": false,
3559
+ "method": "btree",
3560
+ "with": {}
3561
+ }
3562
+ },
3563
+ "foreignKeys": {
3564
+ "usage_records_workspace_id_organization_id_fk": {
3565
+ "name": "usage_records_workspace_id_organization_id_fk",
3566
+ "tableFrom": "usage_records",
3567
+ "tableTo": "organization",
3568
+ "columnsFrom": ["workspace_id"],
3569
+ "columnsTo": ["id"],
3570
+ "onDelete": "cascade",
3571
+ "onUpdate": "no action"
3572
+ },
3573
+ "usage_records_user_id_users_id_fk": {
3574
+ "name": "usage_records_user_id_users_id_fk",
3575
+ "tableFrom": "usage_records",
3576
+ "tableTo": "users",
3577
+ "columnsFrom": ["user_id"],
3578
+ "columnsTo": ["id"],
3579
+ "onDelete": "cascade",
3580
+ "onUpdate": "no action"
3581
+ }
3582
+ },
3583
+ "compositePrimaryKeys": {},
3584
+ "uniqueConstraints": {},
3585
+ "policies": {},
3586
+ "checkConstraints": {},
3587
+ "isRLSEnabled": false
3588
+ },
3589
+ "public.user_quotas": {
3590
+ "name": "user_quotas",
3591
+ "schema": "",
3592
+ "columns": {
3593
+ "id": {
3594
+ "name": "id",
3595
+ "type": "text",
3596
+ "primaryKey": true,
3597
+ "notNull": true
1744
3598
  },
1745
- "channel": {
1746
- "name": "channel",
3599
+ "user_id": {
3600
+ "name": "user_id",
1747
3601
  "type": "text",
1748
3602
  "primaryKey": false,
1749
- "notNull": true,
1750
- "default": "'console'"
3603
+ "notNull": true
1751
3604
  },
1752
- "metadata": {
1753
- "name": "metadata",
3605
+ "workspace_id": {
3606
+ "name": "workspace_id",
1754
3607
  "type": "text",
1755
3608
  "primaryKey": false,
1756
- "notNull": false
3609
+ "notNull": true
3610
+ },
3611
+ "plan": {
3612
+ "name": "plan",
3613
+ "type": "text",
3614
+ "primaryKey": false,
3615
+ "notNull": true,
3616
+ "default": "'free'"
3617
+ },
3618
+ "usage": {
3619
+ "name": "usage",
3620
+ "type": "jsonb",
3621
+ "primaryKey": false,
3622
+ "notNull": true,
3623
+ "default": "'{}'::jsonb"
3624
+ },
3625
+ "total_cost_usd": {
3626
+ "name": "total_cost_usd",
3627
+ "type": "real",
3628
+ "primaryKey": false,
3629
+ "notNull": true,
3630
+ "default": 0
3631
+ },
3632
+ "created_at": {
3633
+ "name": "created_at",
3634
+ "type": "timestamp",
3635
+ "primaryKey": false,
3636
+ "notNull": true,
3637
+ "default": "now()"
3638
+ },
3639
+ "updated_at": {
3640
+ "name": "updated_at",
3641
+ "type": "timestamp",
3642
+ "primaryKey": false,
3643
+ "notNull": true,
3644
+ "default": "now()"
1757
3645
  }
1758
3646
  },
1759
3647
  "indexes": {
1760
- "notification_history_workspace_id_idx": {
1761
- "name": "notification_history_workspace_id_idx",
3648
+ "user_quotas_user_id_idx": {
3649
+ "name": "user_quotas_user_id_idx",
3650
+ "columns": [
3651
+ {
3652
+ "expression": "user_id",
3653
+ "isExpression": false,
3654
+ "asc": true,
3655
+ "nulls": "last"
3656
+ }
3657
+ ],
3658
+ "isUnique": false,
3659
+ "concurrently": false,
3660
+ "method": "btree",
3661
+ "with": {}
3662
+ },
3663
+ "user_quotas_workspace_id_idx": {
3664
+ "name": "user_quotas_workspace_id_idx",
1762
3665
  "columns": [
1763
3666
  {
1764
3667
  "expression": "workspace_id",
@@ -1774,9 +3677,18 @@
1774
3677
  }
1775
3678
  },
1776
3679
  "foreignKeys": {
1777
- "notification_history_workspace_id_organization_id_fk": {
1778
- "name": "notification_history_workspace_id_organization_id_fk",
1779
- "tableFrom": "notification_history",
3680
+ "user_quotas_user_id_users_id_fk": {
3681
+ "name": "user_quotas_user_id_users_id_fk",
3682
+ "tableFrom": "user_quotas",
3683
+ "tableTo": "users",
3684
+ "columnsFrom": ["user_id"],
3685
+ "columnsTo": ["id"],
3686
+ "onDelete": "cascade",
3687
+ "onUpdate": "no action"
3688
+ },
3689
+ "user_quotas_workspace_id_organization_id_fk": {
3690
+ "name": "user_quotas_workspace_id_organization_id_fk",
3691
+ "tableFrom": "user_quotas",
1780
3692
  "tableTo": "organization",
1781
3693
  "columnsFrom": ["workspace_id"],
1782
3694
  "columnsTo": ["id"],
@@ -1786,18 +3698,18 @@
1786
3698
  },
1787
3699
  "compositePrimaryKeys": {},
1788
3700
  "uniqueConstraints": {
1789
- "notification_history_dedup_unique": {
1790
- "name": "notification_history_dedup_unique",
3701
+ "user_quotas_user_workspace_unique": {
3702
+ "name": "user_quotas_user_workspace_unique",
1791
3703
  "nullsNotDistinct": false,
1792
- "columns": ["workspace_id", "type", "period_key"]
3704
+ "columns": ["user_id", "workspace_id"]
1793
3705
  }
1794
3706
  },
1795
3707
  "policies": {},
1796
3708
  "checkConstraints": {},
1797
3709
  "isRLSEnabled": false
1798
3710
  },
1799
- "public.rate_limit_entries": {
1800
- "name": "rate_limit_entries",
3711
+ "public.notifications": {
3712
+ "name": "notifications",
1801
3713
  "schema": "",
1802
3714
  "columns": {
1803
3715
  "id": {
@@ -1806,21 +3718,51 @@
1806
3718
  "primaryKey": true,
1807
3719
  "notNull": true
1808
3720
  },
3721
+ "user_id": {
3722
+ "name": "user_id",
3723
+ "type": "text",
3724
+ "primaryKey": false,
3725
+ "notNull": true
3726
+ },
1809
3727
  "workspace_id": {
1810
3728
  "name": "workspace_id",
1811
3729
  "type": "text",
1812
3730
  "primaryKey": false,
3731
+ "notNull": false
3732
+ },
3733
+ "type": {
3734
+ "name": "type",
3735
+ "type": "text",
3736
+ "primaryKey": false,
1813
3737
  "notNull": true
1814
3738
  },
1815
- "endpoint": {
1816
- "name": "endpoint",
3739
+ "title": {
3740
+ "name": "title",
3741
+ "type": "text",
3742
+ "primaryKey": false,
3743
+ "notNull": true
3744
+ },
3745
+ "message": {
3746
+ "name": "message",
1817
3747
  "type": "text",
1818
3748
  "primaryKey": false,
3749
+ "notNull": true
3750
+ },
3751
+ "is_read": {
3752
+ "name": "is_read",
3753
+ "type": "boolean",
3754
+ "primaryKey": false,
1819
3755
  "notNull": true,
1820
- "default": "'chat'"
3756
+ "default": false
1821
3757
  },
1822
- "requested_at": {
1823
- "name": "requested_at",
3758
+ "metadata": {
3759
+ "name": "metadata",
3760
+ "type": "text",
3761
+ "primaryKey": false,
3762
+ "notNull": false
3763
+ },
3764
+ "created_at": {
3765
+ "name": "created_at",
1824
3766
  "type": "timestamp",
1825
3767
  "primaryKey": false,
1826
3768
  "notNull": true,
@@ -1828,23 +3770,187 @@
1828
3770
  }
1829
3771
  },
1830
3772
  "indexes": {
1831
- "rate_limit_entries_window_idx": {
1832
- "name": "rate_limit_entries_window_idx",
3773
+ "notifications_user_id_idx": {
3774
+ "name": "notifications_user_id_idx",
3775
+ "columns": [
3776
+ {
3777
+ "expression": "user_id",
3778
+ "isExpression": false,
3779
+ "asc": true,
3780
+ "nulls": "last"
3781
+ }
3782
+ ],
3783
+ "isUnique": false,
3784
+ "concurrently": false,
3785
+ "method": "btree",
3786
+ "with": {}
3787
+ },
3788
+ "notifications_user_id_is_read_idx": {
3789
+ "name": "notifications_user_id_is_read_idx",
3790
+ "columns": [
3791
+ {
3792
+ "expression": "user_id",
3793
+ "isExpression": false,
3794
+ "asc": true,
3795
+ "nulls": "last"
3796
+ },
3797
+ {
3798
+ "expression": "is_read",
3799
+ "isExpression": false,
3800
+ "asc": true,
3801
+ "nulls": "last"
3802
+ }
3803
+ ],
3804
+ "isUnique": false,
3805
+ "concurrently": false,
3806
+ "method": "btree",
3807
+ "with": {}
3808
+ },
3809
+ "notifications_created_at_idx": {
3810
+ "name": "notifications_created_at_idx",
3811
+ "columns": [
3812
+ {
3813
+ "expression": "created_at",
3814
+ "isExpression": false,
3815
+ "asc": true,
3816
+ "nulls": "last"
3817
+ }
3818
+ ],
3819
+ "isUnique": false,
3820
+ "concurrently": false,
3821
+ "method": "btree",
3822
+ "with": {}
3823
+ }
3824
+ },
3825
+ "foreignKeys": {},
3826
+ "compositePrimaryKeys": {},
3827
+ "uniqueConstraints": {},
3828
+ "policies": {},
3829
+ "checkConstraints": {},
3830
+ "isRLSEnabled": false
3831
+ },
3832
+ "public.audit_events": {
3833
+ "name": "audit_events",
3834
+ "schema": "",
3835
+ "columns": {
3836
+ "id": {
3837
+ "name": "id",
3838
+ "type": "text",
3839
+ "primaryKey": true,
3840
+ "notNull": true
3841
+ },
3842
+ "workspace_id": {
3843
+ "name": "workspace_id",
3844
+ "type": "text",
3845
+ "primaryKey": false,
3846
+ "notNull": false
3847
+ },
3848
+ "actor_id": {
3849
+ "name": "actor_id",
3850
+ "type": "text",
3851
+ "primaryKey": false,
3852
+ "notNull": false
3853
+ },
3854
+ "actor_kind": {
3855
+ "name": "actor_kind",
3856
+ "type": "text",
3857
+ "primaryKey": false,
3858
+ "notNull": true,
3859
+ "default": "'user'"
3860
+ },
3861
+ "action": {
3862
+ "name": "action",
3863
+ "type": "text",
3864
+ "primaryKey": false,
3865
+ "notNull": true
3866
+ },
3867
+ "resource_kind": {
3868
+ "name": "resource_kind",
3869
+ "type": "text",
3870
+ "primaryKey": false,
3871
+ "notNull": true
3872
+ },
3873
+ "resource_id": {
3874
+ "name": "resource_id",
3875
+ "type": "text",
3876
+ "primaryKey": false,
3877
+ "notNull": false
3878
+ },
3879
+ "outcome": {
3880
+ "name": "outcome",
3881
+ "type": "text",
3882
+ "primaryKey": false,
3883
+ "notNull": true,
3884
+ "default": "'ok'"
3885
+ },
3886
+ "metadata": {
3887
+ "name": "metadata",
3888
+ "type": "jsonb",
3889
+ "primaryKey": false,
3890
+ "notNull": false
3891
+ },
3892
+ "created_at": {
3893
+ "name": "created_at",
3894
+ "type": "timestamp",
3895
+ "primaryKey": false,
3896
+ "notNull": true,
3897
+ "default": "now()"
3898
+ }
3899
+ },
3900
+ "indexes": {
3901
+ "audit_events_workspace_created_idx": {
3902
+ "name": "audit_events_workspace_created_idx",
1833
3903
  "columns": [
1834
3904
  {
1835
3905
  "expression": "workspace_id",
1836
3906
  "isExpression": false,
1837
3907
  "asc": true,
1838
3908
  "nulls": "last"
1839
- },
3909
+ },
3910
+ {
3911
+ "expression": "created_at",
3912
+ "isExpression": false,
3913
+ "asc": true,
3914
+ "nulls": "last"
3915
+ }
3916
+ ],
3917
+ "isUnique": false,
3918
+ "concurrently": false,
3919
+ "method": "btree",
3920
+ "with": {}
3921
+ },
3922
+ "audit_events_action_idx": {
3923
+ "name": "audit_events_action_idx",
3924
+ "columns": [
3925
+ {
3926
+ "expression": "action",
3927
+ "isExpression": false,
3928
+ "asc": true,
3929
+ "nulls": "last"
3930
+ },
3931
+ {
3932
+ "expression": "created_at",
3933
+ "isExpression": false,
3934
+ "asc": true,
3935
+ "nulls": "last"
3936
+ }
3937
+ ],
3938
+ "isUnique": false,
3939
+ "concurrently": false,
3940
+ "method": "btree",
3941
+ "with": {}
3942
+ },
3943
+ "audit_events_resource_idx": {
3944
+ "name": "audit_events_resource_idx",
3945
+ "columns": [
1840
3946
  {
1841
- "expression": "endpoint",
3947
+ "expression": "resource_kind",
1842
3948
  "isExpression": false,
1843
3949
  "asc": true,
1844
3950
  "nulls": "last"
1845
3951
  },
1846
3952
  {
1847
- "expression": "requested_at",
3953
+ "expression": "resource_id",
1848
3954
  "isExpression": false,
1849
3955
  "asc": true,
1850
3956
  "nulls": "last"
@@ -1857,13 +3963,22 @@
1857
3963
  }
1858
3964
  },
1859
3965
  "foreignKeys": {
1860
- "rate_limit_entries_workspace_id_organization_id_fk": {
1861
- "name": "rate_limit_entries_workspace_id_organization_id_fk",
1862
- "tableFrom": "rate_limit_entries",
3966
+ "audit_events_workspace_id_organization_id_fk": {
3967
+ "name": "audit_events_workspace_id_organization_id_fk",
3968
+ "tableFrom": "audit_events",
1863
3969
  "tableTo": "organization",
1864
3970
  "columnsFrom": ["workspace_id"],
1865
3971
  "columnsTo": ["id"],
1866
- "onDelete": "cascade",
3972
+ "onDelete": "set null",
3973
+ "onUpdate": "no action"
3974
+ },
3975
+ "audit_events_actor_id_users_id_fk": {
3976
+ "name": "audit_events_actor_id_users_id_fk",
3977
+ "tableFrom": "audit_events",
3978
+ "tableTo": "users",
3979
+ "columnsFrom": ["actor_id"],
3980
+ "columnsTo": ["id"],
3981
+ "onDelete": "set null",
1867
3982
  "onUpdate": "no action"
1868
3983
  }
1869
3984
  },
@@ -1873,8 +3988,8 @@
1873
3988
  "checkConstraints": {},
1874
3989
  "isRLSEnabled": false
1875
3990
  },
1876
- "public.trial_credits": {
1877
- "name": "trial_credits",
3991
+ "public.executions": {
3992
+ "name": "executions",
1878
3993
  "schema": "",
1879
3994
  "columns": {
1880
3995
  "id": {
@@ -1889,174 +4004,126 @@
1889
4004
  "primaryKey": false,
1890
4005
  "notNull": true
1891
4006
  },
1892
- "initial_credits": {
1893
- "name": "initial_credits",
1894
- "type": "integer",
4007
+ "user_id": {
4008
+ "name": "user_id",
4009
+ "type": "text",
1895
4010
  "primaryKey": false,
1896
- "notNull": true,
1897
- "default": 100000
4011
+ "notNull": false
1898
4012
  },
1899
- "credits_used": {
1900
- "name": "credits_used",
1901
- "type": "integer",
4013
+ "capability": {
4014
+ "name": "capability",
4015
+ "type": "text",
1902
4016
  "primaryKey": false,
1903
- "notNull": true,
1904
- "default": 0
4017
+ "notNull": true
1905
4018
  },
1906
- "credits_remaining": {
1907
- "name": "credits_remaining",
1908
- "type": "integer",
4019
+ "request_id": {
4020
+ "name": "request_id",
4021
+ "type": "text",
1909
4022
  "primaryKey": false,
1910
- "notNull": true,
1911
- "default": 100000
4023
+ "notNull": true
1912
4024
  },
1913
4025
  "status": {
1914
4026
  "name": "status",
1915
4027
  "type": "text",
1916
4028
  "primaryKey": false,
1917
4029
  "notNull": true,
1918
- "default": "'active'"
1919
- },
1920
- "provisioned_at": {
1921
- "name": "provisioned_at",
1922
- "type": "timestamp",
1923
- "primaryKey": false,
1924
- "notNull": true,
1925
- "default": "now()"
4030
+ "default": "'running'"
1926
4031
  },
1927
- "depleted_at": {
1928
- "name": "depleted_at",
1929
- "type": "timestamp",
4032
+ "model": {
4033
+ "name": "model",
4034
+ "type": "text",
1930
4035
  "primaryKey": false,
1931
4036
  "notNull": false
1932
4037
  },
1933
- "converted_at": {
1934
- "name": "converted_at",
1935
- "type": "timestamp",
4038
+ "input_tokens": {
4039
+ "name": "input_tokens",
4040
+ "type": "integer",
1936
4041
  "primaryKey": false,
1937
4042
  "notNull": false
1938
4043
  },
1939
- "created_by_ip": {
1940
- "name": "created_by_ip",
1941
- "type": "text",
4044
+ "output_tokens": {
4045
+ "name": "output_tokens",
4046
+ "type": "integer",
1942
4047
  "primaryKey": false,
1943
4048
  "notNull": false
1944
4049
  },
1945
- "created_by_email": {
1946
- "name": "created_by_email",
1947
- "type": "text",
4050
+ "total_tokens": {
4051
+ "name": "total_tokens",
4052
+ "type": "integer",
1948
4053
  "primaryKey": false,
1949
4054
  "notNull": false
1950
- }
1951
- },
1952
- "indexes": {},
1953
- "foreignKeys": {
1954
- "trial_credits_workspace_id_organization_id_fk": {
1955
- "name": "trial_credits_workspace_id_organization_id_fk",
1956
- "tableFrom": "trial_credits",
1957
- "tableTo": "organization",
1958
- "columnsFrom": ["workspace_id"],
1959
- "columnsTo": ["id"],
1960
- "onDelete": "cascade",
1961
- "onUpdate": "no action"
1962
- }
1963
- },
1964
- "compositePrimaryKeys": {},
1965
- "uniqueConstraints": {
1966
- "trial_credits_workspace_id_unique": {
1967
- "name": "trial_credits_workspace_id_unique",
1968
- "nullsNotDistinct": false,
1969
- "columns": ["workspace_id"]
1970
- }
1971
- },
1972
- "policies": {},
1973
- "checkConstraints": {},
1974
- "isRLSEnabled": false
1975
- },
1976
- "public.usage_records": {
1977
- "name": "usage_records",
1978
- "schema": "",
1979
- "columns": {
1980
- "id": {
1981
- "name": "id",
1982
- "type": "text",
1983
- "primaryKey": true,
1984
- "notNull": true
1985
4055
  },
1986
- "workspace_id": {
1987
- "name": "workspace_id",
1988
- "type": "text",
4056
+ "charged_micros": {
4057
+ "name": "charged_micros",
4058
+ "type": "bigint",
1989
4059
  "primaryKey": false,
1990
- "notNull": true
4060
+ "notNull": false
1991
4061
  },
1992
- "user_id": {
1993
- "name": "user_id",
1994
- "type": "text",
4062
+ "reserved_micros": {
4063
+ "name": "reserved_micros",
4064
+ "type": "bigint",
1995
4065
  "primaryKey": false,
1996
- "notNull": true
4066
+ "notNull": false
1997
4067
  },
1998
- "type": {
1999
- "name": "type",
4068
+ "currency": {
4069
+ "name": "currency",
2000
4070
  "type": "text",
2001
4071
  "primaryKey": false,
2002
- "notNull": true
4072
+ "notNull": false
2003
4073
  },
2004
- "model": {
2005
- "name": "model",
4074
+ "refusal_reason": {
4075
+ "name": "refusal_reason",
2006
4076
  "type": "text",
2007
4077
  "primaryKey": false,
2008
4078
  "notNull": false
2009
4079
  },
2010
- "agent": {
2011
- "name": "agent",
4080
+ "error_message": {
4081
+ "name": "error_message",
2012
4082
  "type": "text",
2013
4083
  "primaryKey": false,
2014
4084
  "notNull": false
2015
4085
  },
2016
- "input_tokens": {
2017
- "name": "input_tokens",
2018
- "type": "integer",
4086
+ "started_at": {
4087
+ "name": "started_at",
4088
+ "type": "timestamp",
2019
4089
  "primaryKey": false,
2020
4090
  "notNull": true,
2021
- "default": 0
4091
+ "default": "now()"
2022
4092
  },
2023
- "output_tokens": {
2024
- "name": "output_tokens",
2025
- "type": "integer",
4093
+ "finished_at": {
4094
+ "name": "finished_at",
4095
+ "type": "timestamp",
2026
4096
  "primaryKey": false,
2027
- "notNull": true,
2028
- "default": 0
4097
+ "notNull": false
2029
4098
  },
2030
- "total_tokens": {
2031
- "name": "total_tokens",
4099
+ "duration_ms": {
4100
+ "name": "duration_ms",
2032
4101
  "type": "integer",
2033
4102
  "primaryKey": false,
2034
- "notNull": true,
2035
- "default": 0
4103
+ "notNull": false
2036
4104
  },
2037
4105
  "metadata": {
2038
4106
  "name": "metadata",
2039
- "type": "text",
4107
+ "type": "jsonb",
2040
4108
  "primaryKey": false,
2041
4109
  "notNull": false
2042
- },
2043
- "recorded_at": {
2044
- "name": "recorded_at",
2045
- "type": "timestamp",
2046
- "primaryKey": false,
2047
- "notNull": true,
2048
- "default": "now()"
2049
4110
  }
2050
4111
  },
2051
4112
  "indexes": {
2052
- "usage_records_workspace_id_idx": {
2053
- "name": "usage_records_workspace_id_idx",
4113
+ "executions_workspace_started_idx": {
4114
+ "name": "executions_workspace_started_idx",
2054
4115
  "columns": [
2055
4116
  {
2056
4117
  "expression": "workspace_id",
2057
4118
  "isExpression": false,
2058
4119
  "asc": true,
2059
4120
  "nulls": "last"
4121
+ },
4122
+ {
4123
+ "expression": "started_at",
4124
+ "isExpression": false,
4125
+ "asc": true,
4126
+ "nulls": "last"
2060
4127
  }
2061
4128
  ],
2062
4129
  "isUnique": false,
@@ -2064,17 +4131,17 @@
2064
4131
  "method": "btree",
2065
4132
  "with": {}
2066
4133
  },
2067
- "usage_records_workspace_recorded_at_idx": {
2068
- "name": "usage_records_workspace_recorded_at_idx",
4134
+ "executions_status_idx": {
4135
+ "name": "executions_status_idx",
2069
4136
  "columns": [
2070
4137
  {
2071
- "expression": "workspace_id",
4138
+ "expression": "status",
2072
4139
  "isExpression": false,
2073
4140
  "asc": true,
2074
4141
  "nulls": "last"
2075
4142
  },
2076
4143
  {
2077
- "expression": "recorded_at",
4144
+ "expression": "started_at",
2078
4145
  "isExpression": false,
2079
4146
  "asc": true,
2080
4147
  "nulls": "last"
@@ -2085,17 +4152,17 @@
2085
4152
  "method": "btree",
2086
4153
  "with": {}
2087
4154
  },
2088
- "usage_records_workspace_type_idx": {
2089
- "name": "usage_records_workspace_type_idx",
4155
+ "executions_capability_idx": {
4156
+ "name": "executions_capability_idx",
2090
4157
  "columns": [
2091
4158
  {
2092
- "expression": "workspace_id",
4159
+ "expression": "capability",
2093
4160
  "isExpression": false,
2094
4161
  "asc": true,
2095
4162
  "nulls": "last"
2096
4163
  },
2097
4164
  {
2098
- "expression": "type",
4165
+ "expression": "started_at",
2099
4166
  "isExpression": false,
2100
4167
  "asc": true,
2101
4168
  "nulls": "last"
@@ -2108,33 +4175,39 @@
2108
4175
  }
2109
4176
  },
2110
4177
  "foreignKeys": {
2111
- "usage_records_workspace_id_organization_id_fk": {
2112
- "name": "usage_records_workspace_id_organization_id_fk",
2113
- "tableFrom": "usage_records",
4178
+ "executions_workspace_id_organization_id_fk": {
4179
+ "name": "executions_workspace_id_organization_id_fk",
4180
+ "tableFrom": "executions",
2114
4181
  "tableTo": "organization",
2115
4182
  "columnsFrom": ["workspace_id"],
2116
4183
  "columnsTo": ["id"],
2117
4184
  "onDelete": "cascade",
2118
4185
  "onUpdate": "no action"
2119
4186
  },
2120
- "usage_records_user_id_users_id_fk": {
2121
- "name": "usage_records_user_id_users_id_fk",
2122
- "tableFrom": "usage_records",
4187
+ "executions_user_id_users_id_fk": {
4188
+ "name": "executions_user_id_users_id_fk",
4189
+ "tableFrom": "executions",
2123
4190
  "tableTo": "users",
2124
4191
  "columnsFrom": ["user_id"],
2125
4192
  "columnsTo": ["id"],
2126
- "onDelete": "cascade",
4193
+ "onDelete": "set null",
2127
4194
  "onUpdate": "no action"
2128
4195
  }
2129
4196
  },
2130
4197
  "compositePrimaryKeys": {},
2131
- "uniqueConstraints": {},
4198
+ "uniqueConstraints": {
4199
+ "executions_request_id_unique": {
4200
+ "name": "executions_request_id_unique",
4201
+ "nullsNotDistinct": false,
4202
+ "columns": ["request_id"]
4203
+ }
4204
+ },
2132
4205
  "policies": {},
2133
4206
  "checkConstraints": {},
2134
4207
  "isRLSEnabled": false
2135
4208
  },
2136
- "public.notifications": {
2137
- "name": "notifications",
4209
+ "public.jobs": {
4210
+ "name": "jobs",
2138
4211
  "schema": "",
2139
4212
  "columns": {
2140
4213
  "id": {
@@ -2143,45 +4216,66 @@
2143
4216
  "primaryKey": true,
2144
4217
  "notNull": true
2145
4218
  },
2146
- "user_id": {
2147
- "name": "user_id",
2148
- "type": "text",
2149
- "primaryKey": false,
2150
- "notNull": true
2151
- },
2152
4219
  "workspace_id": {
2153
4220
  "name": "workspace_id",
2154
4221
  "type": "text",
2155
4222
  "primaryKey": false,
2156
4223
  "notNull": false
2157
4224
  },
2158
- "type": {
2159
- "name": "type",
4225
+ "kind": {
4226
+ "name": "kind",
2160
4227
  "type": "text",
2161
4228
  "primaryKey": false,
2162
4229
  "notNull": true
2163
4230
  },
2164
- "title": {
2165
- "name": "title",
2166
- "type": "text",
4231
+ "payload": {
4232
+ "name": "payload",
4233
+ "type": "jsonb",
2167
4234
  "primaryKey": false,
2168
- "notNull": true
4235
+ "notNull": false
2169
4236
  },
2170
- "message": {
2171
- "name": "message",
4237
+ "status": {
4238
+ "name": "status",
2172
4239
  "type": "text",
2173
4240
  "primaryKey": false,
2174
- "notNull": true
4241
+ "notNull": true,
4242
+ "default": "'pending'"
2175
4243
  },
2176
- "is_read": {
2177
- "name": "is_read",
2178
- "type": "boolean",
4244
+ "attempts": {
4245
+ "name": "attempts",
4246
+ "type": "integer",
2179
4247
  "primaryKey": false,
2180
4248
  "notNull": true,
2181
- "default": false
4249
+ "default": 0
2182
4250
  },
2183
- "metadata": {
2184
- "name": "metadata",
4251
+ "max_attempts": {
4252
+ "name": "max_attempts",
4253
+ "type": "integer",
4254
+ "primaryKey": false,
4255
+ "notNull": true,
4256
+ "default": 3
4257
+ },
4258
+ "run_at": {
4259
+ "name": "run_at",
4260
+ "type": "timestamp",
4261
+ "primaryKey": false,
4262
+ "notNull": true,
4263
+ "default": "now()"
4264
+ },
4265
+ "started_at": {
4266
+ "name": "started_at",
4267
+ "type": "timestamp",
4268
+ "primaryKey": false,
4269
+ "notNull": false
4270
+ },
4271
+ "finished_at": {
4272
+ "name": "finished_at",
4273
+ "type": "timestamp",
4274
+ "primaryKey": false,
4275
+ "notNull": false
4276
+ },
4277
+ "last_error": {
4278
+ "name": "last_error",
2185
4279
  "type": "text",
2186
4280
  "primaryKey": false,
2187
4281
  "notNull": false
@@ -2195,11 +4289,17 @@
2195
4289
  }
2196
4290
  },
2197
4291
  "indexes": {
2198
- "notifications_user_id_idx": {
2199
- "name": "notifications_user_id_idx",
4292
+ "jobs_claim_idx": {
4293
+ "name": "jobs_claim_idx",
2200
4294
  "columns": [
2201
4295
  {
2202
- "expression": "user_id",
4296
+ "expression": "status",
4297
+ "isExpression": false,
4298
+ "asc": true,
4299
+ "nulls": "last"
4300
+ },
4301
+ {
4302
+ "expression": "run_at",
2203
4303
  "isExpression": false,
2204
4304
  "asc": true,
2205
4305
  "nulls": "last"
@@ -2210,17 +4310,17 @@
2210
4310
  "method": "btree",
2211
4311
  "with": {}
2212
4312
  },
2213
- "notifications_user_id_is_read_idx": {
2214
- "name": "notifications_user_id_is_read_idx",
4313
+ "jobs_kind_idx": {
4314
+ "name": "jobs_kind_idx",
2215
4315
  "columns": [
2216
4316
  {
2217
- "expression": "user_id",
4317
+ "expression": "kind",
2218
4318
  "isExpression": false,
2219
4319
  "asc": true,
2220
4320
  "nulls": "last"
2221
4321
  },
2222
4322
  {
2223
- "expression": "is_read",
4323
+ "expression": "status",
2224
4324
  "isExpression": false,
2225
4325
  "asc": true,
2226
4326
  "nulls": "last"
@@ -2231,11 +4331,11 @@
2231
4331
  "method": "btree",
2232
4332
  "with": {}
2233
4333
  },
2234
- "notifications_created_at_idx": {
2235
- "name": "notifications_created_at_idx",
4334
+ "jobs_workspace_idx": {
4335
+ "name": "jobs_workspace_idx",
2236
4336
  "columns": [
2237
4337
  {
2238
- "expression": "created_at",
4338
+ "expression": "workspace_id",
2239
4339
  "isExpression": false,
2240
4340
  "asc": true,
2241
4341
  "nulls": "last"
@@ -2247,7 +4347,17 @@
2247
4347
  "with": {}
2248
4348
  }
2249
4349
  },
2250
- "foreignKeys": {},
4350
+ "foreignKeys": {
4351
+ "jobs_workspace_id_organization_id_fk": {
4352
+ "name": "jobs_workspace_id_organization_id_fk",
4353
+ "tableFrom": "jobs",
4354
+ "tableTo": "organization",
4355
+ "columnsFrom": ["workspace_id"],
4356
+ "columnsTo": ["id"],
4357
+ "onDelete": "cascade",
4358
+ "onUpdate": "no action"
4359
+ }
4360
+ },
2251
4361
  "compositePrimaryKeys": {},
2252
4362
  "uniqueConstraints": {},
2253
4363
  "policies": {},