@intelligo-dev/core 1.0.0-beta.1 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +6 -0
- package/README.md +102 -0
- package/dist/attachments/errors.d.ts +7 -0
- package/dist/attachments/errors.d.ts.map +1 -0
- package/dist/attachments/errors.js +11 -0
- package/dist/attachments/errors.js.map +1 -0
- package/dist/attachments/index.d.ts +8 -0
- package/dist/attachments/index.d.ts.map +1 -0
- package/dist/attachments/index.js +7 -0
- package/dist/attachments/index.js.map +1 -0
- package/dist/attachments/service.d.ts +45 -0
- package/dist/attachments/service.d.ts.map +1 -0
- package/dist/attachments/service.js +100 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/attachments/types.d.ts +6 -0
- package/dist/attachments/types.d.ts.map +1 -0
- package/dist/attachments/types.js +2 -0
- package/dist/attachments/types.js.map +1 -0
- package/dist/conversations/errors.d.ts +2 -8
- package/dist/conversations/errors.d.ts.map +1 -1
- package/dist/conversations/errors.js +2 -8
- package/dist/conversations/errors.js.map +1 -1
- package/dist/conversations/index.d.ts +4 -12
- package/dist/conversations/index.d.ts.map +1 -1
- package/dist/conversations/index.js +2 -11
- package/dist/conversations/index.js.map +1 -1
- package/dist/conversations/service.d.ts +49 -61
- package/dist/conversations/service.d.ts.map +1 -1
- package/dist/conversations/service.js +110 -83
- package/dist/conversations/service.js.map +1 -1
- package/dist/conversations/types.d.ts +1 -4
- package/dist/conversations/types.d.ts.map +1 -1
- package/dist/conversations/types.js +0 -3
- package/dist/conversations/types.js.map +1 -1
- package/dist/db/client.d.ts +21 -10
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +43 -18
- package/dist/db/client.js.map +1 -1
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +3 -7
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema/agents.d.ts +14 -51
- package/dist/db/schema/agents.d.ts.map +1 -1
- package/dist/db/schema/agents.js +9 -21
- package/dist/db/schema/agents.js.map +1 -1
- package/dist/db/schema/ai.d.ts +86 -1556
- package/dist/db/schema/ai.d.ts.map +1 -1
- package/dist/db/schema/ai.js +32 -236
- package/dist/db/schema/ai.js.map +1 -1
- package/dist/db/schema/auth.d.ts +5 -34
- package/dist/db/schema/auth.d.ts.map +1 -1
- package/dist/db/schema/auth.js +25 -56
- package/dist/db/schema/auth.js.map +1 -1
- package/dist/db/schema/billing.d.ts +339 -105
- package/dist/db/schema/billing.d.ts.map +1 -1
- package/dist/db/schema/billing.js +99 -58
- package/dist/db/schema/billing.js.map +1 -1
- package/dist/db/schema/feature-flags.d.ts +3 -12
- package/dist/db/schema/feature-flags.d.ts.map +1 -1
- package/dist/db/schema/feature-flags.js +3 -12
- package/dist/db/schema/feature-flags.js.map +1 -1
- package/dist/db/schema/identity.d.ts +12 -274
- package/dist/db/schema/identity.d.ts.map +1 -1
- package/dist/db/schema/identity.js +19 -104
- package/dist/db/schema/identity.js.map +1 -1
- package/dist/db/schema/index.d.ts +8 -15
- package/dist/db/schema/index.d.ts.map +1 -1
- package/dist/db/schema/index.js +12 -42
- package/dist/db/schema/index.js.map +1 -1
- package/dist/db/schema/notifications.d.ts +3 -17
- package/dist/db/schema/notifications.d.ts.map +1 -1
- package/dist/db/schema/notifications.js +3 -17
- package/dist/db/schema/notifications.js.map +1 -1
- package/dist/db/schema/usage.d.ts +94 -77
- package/dist/db/schema/usage.d.ts.map +1 -1
- package/dist/db/schema/usage.js +59 -89
- package/dist/db/schema/usage.js.map +1 -1
- package/dist/db/validate.d.ts +2 -11
- package/dist/db/validate.d.ts.map +1 -1
- package/dist/db/validate.js +6 -17
- package/dist/db/validate.js.map +1 -1
- package/dist/db/workspace-queries.d.ts +5 -29
- package/dist/db/workspace-queries.d.ts.map +1 -1
- package/dist/db/workspace-queries.js +5 -29
- package/dist/db/workspace-queries.js.map +1 -1
- package/dist/documents/classifier.d.ts +5 -12
- package/dist/documents/classifier.d.ts.map +1 -1
- package/dist/documents/classifier.js +16 -16
- package/dist/documents/classifier.js.map +1 -1
- package/dist/documents/errors.d.ts +2 -10
- package/dist/documents/errors.d.ts.map +1 -1
- package/dist/documents/errors.js +2 -10
- package/dist/documents/errors.js.map +1 -1
- package/dist/documents/index.d.ts +4 -13
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +3 -12
- package/dist/documents/index.js.map +1 -1
- package/dist/documents/service.d.ts +19 -26
- package/dist/documents/service.d.ts.map +1 -1
- package/dist/documents/service.js +44 -38
- package/dist/documents/service.js.map +1 -1
- package/dist/documents/types.d.ts +6 -10
- package/dist/documents/types.d.ts.map +1 -1
- package/dist/documents/types.js +0 -3
- package/dist/documents/types.js.map +1 -1
- package/dist/email/brand.d.ts +17 -0
- package/dist/email/brand.d.ts.map +1 -0
- package/dist/email/brand.js +9 -0
- package/dist/email/brand.js.map +1 -0
- package/dist/email/index.d.ts +4 -4
- package/dist/email/index.js +4 -4
- package/dist/email/provider.d.ts +1 -7
- package/dist/email/provider.d.ts.map +1 -1
- package/dist/email/provider.js +10 -19
- package/dist/email/provider.js.map +1 -1
- package/dist/email/send.d.ts +12 -12
- package/dist/email/send.d.ts.map +1 -1
- package/dist/email/send.js +5 -19
- package/dist/email/send.js.map +1 -1
- package/dist/email/senders.d.ts +17 -30
- package/dist/email/senders.d.ts.map +1 -1
- package/dist/email/senders.js +33 -47
- package/dist/email/senders.js.map +1 -1
- package/dist/email/templates/base-layout.d.ts +1 -1
- package/dist/email/templates/base-layout.d.ts.map +1 -1
- package/dist/email/templates/base-layout.js +4 -6
- package/dist/email/templates/base-layout.js.map +1 -1
- package/dist/email/templates/index.d.ts +10 -10
- package/dist/email/templates/index.d.ts.map +1 -1
- package/dist/email/templates/index.js +10 -16
- package/dist/email/templates/index.js.map +1 -1
- package/dist/email/templates/password-reset.d.ts +2 -2
- package/dist/email/templates/password-reset.d.ts.map +1 -1
- package/dist/email/templates/password-reset.js +10 -22
- package/dist/email/templates/password-reset.js.map +1 -1
- package/dist/email/templates/payment-failed.d.ts +2 -2
- package/dist/email/templates/payment-failed.d.ts.map +1 -1
- package/dist/email/templates/payment-failed.js +11 -24
- package/dist/email/templates/payment-failed.js.map +1 -1
- package/dist/email/templates/quota-warning.d.ts +4 -4
- package/dist/email/templates/quota-warning.d.ts.map +1 -1
- package/dist/email/templates/quota-warning.js +19 -39
- package/dist/email/templates/quota-warning.js.map +1 -1
- package/dist/email/templates/subscription-confirmed.d.ts +2 -2
- package/dist/email/templates/subscription-confirmed.d.ts.map +1 -1
- package/dist/email/templates/subscription-confirmed.js +13 -28
- package/dist/email/templates/subscription-confirmed.js.map +1 -1
- package/dist/email/templates/trial-expiry.d.ts +2 -2
- package/dist/email/templates/trial-expiry.d.ts.map +1 -1
- package/dist/email/templates/trial-expiry.js +12 -36
- package/dist/email/templates/trial-expiry.js.map +1 -1
- package/dist/email/templates/trial-warning.d.ts +2 -2
- package/dist/email/templates/trial-warning.d.ts.map +1 -1
- package/dist/email/templates/trial-warning.js +15 -32
- package/dist/email/templates/trial-warning.js.map +1 -1
- package/dist/email/templates/verify-email.d.ts +2 -2
- package/dist/email/templates/verify-email.d.ts.map +1 -1
- package/dist/email/templates/verify-email.js +10 -22
- package/dist/email/templates/verify-email.js.map +1 -1
- package/dist/email/templates/welcome.d.ts +2 -2
- package/dist/email/templates/welcome.d.ts.map +1 -1
- package/dist/email/templates/welcome.js +13 -20
- package/dist/email/templates/welcome.js.map +1 -1
- package/dist/email/templates/workspace-invitation.d.ts +2 -2
- package/dist/email/templates/workspace-invitation.d.ts.map +1 -1
- package/dist/email/templates/workspace-invitation.js +12 -26
- package/dist/email/templates/workspace-invitation.js.map +1 -1
- package/dist/env.d.ts +5 -10
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +41 -31
- package/dist/env.js.map +1 -1
- package/dist/identity/audit.d.ts +11 -24
- package/dist/identity/audit.d.ts.map +1 -1
- package/dist/identity/audit.js +13 -27
- package/dist/identity/audit.js.map +1 -1
- package/dist/identity/errors.d.ts +4 -12
- package/dist/identity/errors.d.ts.map +1 -1
- package/dist/identity/errors.js +2 -8
- package/dist/identity/errors.js.map +1 -1
- package/dist/identity/index.d.ts +6 -13
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +5 -12
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/service.d.ts +29 -47
- package/dist/identity/service.d.ts.map +1 -1
- package/dist/identity/service.js +107 -79
- package/dist/identity/service.js.map +1 -1
- package/dist/identity/types.d.ts +28 -4
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/identity/types.js +0 -3
- package/dist/identity/types.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -10
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +7 -18
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +45 -49
- package/dist/logger.js.map +1 -1
- package/dist/money.d.ts +95 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +208 -0
- package/dist/money.js.map +1 -0
- package/dist/notifications/index.d.ts +9 -43
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +9 -49
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/triggers.d.ts +9 -32
- package/dist/notifications/triggers.d.ts.map +1 -1
- package/dist/notifications/triggers.js +21 -58
- package/dist/notifications/triggers.js.map +1 -1
- package/dist/notifications/types.d.ts +6 -8
- package/dist/notifications/types.d.ts.map +1 -1
- package/dist/notifications/types.js +0 -9
- package/dist/notifications/types.js.map +1 -1
- package/dist/prompt.d.ts +38 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +118 -0
- package/dist/prompt.js.map +1 -0
- package/dist/registry.d.ts +32 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +60 -0
- package/dist/registry.js.map +1 -0
- package/dist/request-context.d.ts +49 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +100 -0
- package/dist/request-context.js.map +1 -0
- package/dist/storage/index.d.ts +65 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +109 -0
- package/dist/storage/index.js.map +1 -0
- package/package.json +74 -24
- package/src/attachments/errors.ts +18 -0
- package/src/attachments/index.ts +22 -0
- package/src/attachments/service.ts +178 -0
- package/src/attachments/types.ts +6 -0
- package/src/conversations/errors.ts +45 -0
- package/src/conversations/index.ts +39 -0
- package/src/conversations/service.ts +594 -0
- package/src/conversations/types.ts +15 -0
- package/src/db/client.ts +91 -0
- package/src/db/index.ts +3 -0
- package/src/db/migrations/0000_baseline.sql +652 -0
- package/src/db/migrations/0001_reconcile_chain_built_databases.sql +53 -0
- package/src/db/migrations/0002_webhook_claim_lease.sql +1 -0
- package/src/db/migrations/0003_local_payments.sql +18 -0
- package/src/db/migrations/README.md +103 -36
- package/src/db/migrations/legacy-chain.json +206 -0
- package/src/db/migrations/meta/0000_snapshot.json +4182 -157
- package/src/db/migrations/meta/0002_snapshot.json +2478 -368
- package/src/db/migrations/meta/0003_snapshot.json +2567 -554
- package/src/db/migrations/meta/_journal.json +8 -274
- package/src/db/schema/agents.ts +57 -0
- package/src/db/schema/ai.ts +174 -0
- package/src/db/schema/auth.ts +183 -0
- package/src/db/schema/billing.ts +245 -0
- package/src/db/schema/feature-flags.ts +20 -0
- package/src/db/schema/identity.ts +250 -0
- package/src/db/schema/index.ts +12 -0
- package/src/db/schema/notifications.ts +31 -0
- package/src/db/schema/usage.ts +269 -0
- package/src/db/validate.ts +63 -0
- package/src/db/workspace-queries.ts +64 -0
- package/src/documents/classifier.ts +61 -0
- package/src/documents/errors.ts +44 -0
- package/src/documents/index.ts +24 -0
- package/src/documents/service.ts +256 -0
- package/src/documents/types.ts +24 -0
- package/src/email/brand.ts +24 -0
- package/src/email/index.ts +19 -0
- package/src/email/provider.ts +278 -0
- package/src/email/send.ts +169 -0
- package/src/email/senders.ts +292 -0
- package/src/email/templates/base-layout.tsx +145 -0
- package/src/email/templates/index.ts +28 -0
- package/src/email/templates/password-reset.tsx +72 -0
- package/src/email/templates/payment-failed.tsx +77 -0
- package/src/email/templates/quota-warning.tsx +118 -0
- package/src/email/templates/subscription-confirmed.tsx +91 -0
- package/src/email/templates/trial-expiry.tsx +124 -0
- package/src/email/templates/trial-warning.tsx +104 -0
- package/src/email/templates/verify-email.tsx +72 -0
- package/src/email/templates/welcome.tsx +64 -0
- package/src/email/templates/workspace-invitation.tsx +105 -0
- package/src/env.ts +180 -0
- package/src/identity/audit.ts +65 -0
- package/src/identity/errors.ts +44 -0
- package/src/identity/index.ts +29 -0
- package/src/identity/service.ts +303 -0
- package/src/identity/types.ts +58 -0
- package/src/index.ts +4 -0
- package/src/logger.ts +198 -0
- package/src/money.ts +270 -0
- package/src/notifications/index.ts +112 -0
- package/src/notifications/triggers.ts +158 -0
- package/src/notifications/types.ts +26 -0
- package/src/prompt.ts +142 -0
- package/src/registry.ts +75 -0
- package/src/request-context.ts +137 -0
- package/src/storage/index.ts +153 -0
- package/dist/db/schema/rag.d.ts +0 -171
- package/dist/db/schema/rag.d.ts.map +0 -1
- package/dist/db/schema/rag.js +0 -42
- package/dist/db/schema/rag.js.map +0 -1
- package/src/db/migrations/0000_sharp_night_nurse.sql +0 -52
- package/src/db/migrations/0001_hesitant_vapor.sql +0 -40
- package/src/db/migrations/0002_numerous_lady_vermin.sql +0 -235
- package/src/db/migrations/0003_mighty_jean_grey.sql +0 -37
- package/src/db/migrations/0004_cynical_grandmaster.sql +0 -2
- package/src/db/migrations/0005_careful_switch.sql +0 -8
- package/src/db/migrations/0006_tense_blue_marvel.sql +0 -16
- package/src/db/migrations/0007_next_squadron_sinister.sql +0 -1
- package/src/db/migrations/0008_powerful_scream.sql +0 -39
- package/src/db/migrations/0009_sad_ink.sql +0 -1
- package/src/db/migrations/0010_shocking_omega_flight.sql +0 -2
- package/src/db/migrations/0011_ambiguous_otto_octavius.sql +0 -151
- package/src/db/migrations/0011_hnsw_vector_index.sql +0 -17
- package/src/db/migrations/0012_user_profiles.sql +0 -30
- package/src/db/migrations/0013_trending_seasonal_columns.sql +0 -9
- package/src/db/migrations/0014_add_product_type_to_agents.sql +0 -6
- package/src/db/migrations/0015_new_v1_tables.sql +0 -149
- package/src/db/migrations/0016_document_types.sql +0 -30
- package/src/db/migrations/0017_document_metadata.sql +0 -2
- package/src/db/migrations/0018_identity_graph.sql +0 -200
- package/src/db/migrations/0019_db_driven_prompts.sql +0 -20
- package/src/db/migrations/0020_pending_extractions.sql +0 -35
- package/src/db/migrations/0021_rag_documents.sql +0 -39
- package/src/db/migrations/0022_user_quotas_usage_jsonb.sql +0 -70
- package/src/db/migrations/0023_user_facts_user_scoped_unique.sql +0 -17
- package/src/db/migrations/0024_user_memories_hnsw.sql +0 -23
- package/src/db/migrations/0025_audit_trigger_errcode.sql +0 -21
- package/src/db/migrations/0026_user_profile_snapshots_composite_pk.sql +0 -17
- package/src/db/migrations/0027_billing_settings_mnt_columns.sql +0 -54
- package/src/db/migrations/0028_trial_credits_normalized_email.sql +0 -37
- package/src/db/migrations/0029_usage_records_conversation_idx.sql +0 -13
- package/src/db/migrations/0030_pending_extractions_composite_idx.sql +0 -11
- package/src/db/migrations/0031_rag_documents_hnsw.sql +0 -16
- package/src/db/migrations/0032_rate_limit_unique_idx.sql +0 -16
- package/src/db/migrations/0033_pending_extractions_partial_idx.sql +0 -18
- package/src/db/migrations/0034_rate_limit_count.sql +0 -9
- package/src/db/migrations/0035_credit_reservations.sql +0 -24
- package/src/db/migrations/0036_executions_audit_jobs.sql +0 -96
- package/src/db/migrations/0037_rate_limit_minute_bucket.sql +0 -46
- package/src/db/migrations/0038_user_quotas_generic_usage.sql +0 -25
- package/src/db/migrations/0039_platform_admin_impersonation.sql +0 -27
- package/src/db/migrations/0040_ee_audit_chain.sql +0 -23
- package/src/db/migrations/meta/0001_snapshot.json +0 -631
- package/src/db/migrations/meta/0004_snapshot.json +0 -2500
- package/src/db/migrations/meta/0005_snapshot.json +0 -2548
- package/src/db/migrations/meta/0006_snapshot.json +0 -2650
- package/src/db/migrations/meta/0007_snapshot.json +0 -2657
- package/src/db/migrations/meta/0008_snapshot.json +0 -2719
- package/src/db/migrations/meta/0009_snapshot.json +0 -2726
- package/src/db/migrations/meta/0010_snapshot.json +0 -2739
- package/src/db/migrations/meta/0011_snapshot.json +0 -3886
|
@@ -5,295 +5,29 @@
|
|
|
5
5
|
{
|
|
6
6
|
"idx": 0,
|
|
7
7
|
"version": "7",
|
|
8
|
-
"when":
|
|
9
|
-
"tag": "
|
|
8
|
+
"when": 1789740313941,
|
|
9
|
+
"tag": "0000_baseline",
|
|
10
10
|
"breakpoints": true
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"idx": 1,
|
|
14
14
|
"version": "7",
|
|
15
|
-
"when":
|
|
16
|
-
"tag": "
|
|
15
|
+
"when": 1789740314941,
|
|
16
|
+
"tag": "0001_reconcile_chain_built_databases",
|
|
17
17
|
"breakpoints": true
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"idx": 2,
|
|
21
21
|
"version": "7",
|
|
22
|
-
"when":
|
|
23
|
-
"tag": "
|
|
22
|
+
"when": 1789808201382,
|
|
23
|
+
"tag": "0002_webhook_claim_lease",
|
|
24
24
|
"breakpoints": true
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"idx": 3,
|
|
28
28
|
"version": "7",
|
|
29
|
-
"when":
|
|
30
|
-
"tag": "
|
|
31
|
-
"breakpoints": true
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"idx": 4,
|
|
35
|
-
"version": "7",
|
|
36
|
-
"when": 1770743970189,
|
|
37
|
-
"tag": "0004_cynical_grandmaster",
|
|
38
|
-
"breakpoints": true
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"idx": 5,
|
|
42
|
-
"version": "7",
|
|
43
|
-
"when": 1771267120497,
|
|
44
|
-
"tag": "0005_careful_switch",
|
|
45
|
-
"breakpoints": true
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"idx": 6,
|
|
49
|
-
"version": "7",
|
|
50
|
-
"when": 1771340722768,
|
|
51
|
-
"tag": "0006_tense_blue_marvel",
|
|
52
|
-
"breakpoints": true
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"idx": 7,
|
|
56
|
-
"version": "7",
|
|
57
|
-
"when": 1771390659372,
|
|
58
|
-
"tag": "0007_next_squadron_sinister",
|
|
59
|
-
"breakpoints": true
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"idx": 8,
|
|
63
|
-
"version": "7",
|
|
64
|
-
"when": 1771666802968,
|
|
65
|
-
"tag": "0008_powerful_scream",
|
|
66
|
-
"breakpoints": true
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"idx": 9,
|
|
70
|
-
"version": "7",
|
|
71
|
-
"when": 1771669888764,
|
|
72
|
-
"tag": "0009_sad_ink",
|
|
73
|
-
"breakpoints": true
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"idx": 10,
|
|
77
|
-
"version": "7",
|
|
78
|
-
"when": 1771684216541,
|
|
79
|
-
"tag": "0010_shocking_omega_flight",
|
|
80
|
-
"breakpoints": true
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"idx": 11,
|
|
84
|
-
"version": "7",
|
|
85
|
-
"when": 1775401944659,
|
|
86
|
-
"tag": "0011_ambiguous_otto_octavius",
|
|
87
|
-
"breakpoints": true
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"idx": 12,
|
|
91
|
-
"version": "7",
|
|
92
|
-
"when": 1700000012000,
|
|
93
|
-
"tag": "0011_hnsw_vector_index",
|
|
94
|
-
"breakpoints": true
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"idx": 13,
|
|
98
|
-
"version": "7",
|
|
99
|
-
"when": 1700000013000,
|
|
100
|
-
"tag": "0012_user_profiles",
|
|
101
|
-
"breakpoints": true
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"idx": 14,
|
|
105
|
-
"version": "7",
|
|
106
|
-
"when": 1700000014000,
|
|
107
|
-
"tag": "0013_trending_seasonal_columns",
|
|
108
|
-
"breakpoints": true
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"idx": 15,
|
|
112
|
-
"version": "7",
|
|
113
|
-
"when": 1700000015000,
|
|
114
|
-
"tag": "0014_add_product_type_to_agents",
|
|
115
|
-
"breakpoints": true
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"idx": 16,
|
|
119
|
-
"version": "7",
|
|
120
|
-
"when": 1700000016000,
|
|
121
|
-
"tag": "0015_new_v1_tables",
|
|
122
|
-
"breakpoints": true
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"idx": 17,
|
|
126
|
-
"version": "7",
|
|
127
|
-
"when": 1700000017000,
|
|
128
|
-
"tag": "0016_document_types",
|
|
129
|
-
"breakpoints": true
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"idx": 18,
|
|
133
|
-
"version": "7",
|
|
134
|
-
"when": 1700000018000,
|
|
135
|
-
"tag": "0017_document_metadata",
|
|
136
|
-
"breakpoints": true
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"idx": 19,
|
|
140
|
-
"version": "7",
|
|
141
|
-
"when": 1700000019000,
|
|
142
|
-
"tag": "0018_identity_graph",
|
|
143
|
-
"breakpoints": true
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
"idx": 20,
|
|
147
|
-
"version": "7",
|
|
148
|
-
"when": 1700000020000,
|
|
149
|
-
"tag": "0019_db_driven_prompts",
|
|
150
|
-
"breakpoints": true
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
"idx": 21,
|
|
154
|
-
"version": "7",
|
|
155
|
-
"when": 1700000021000,
|
|
156
|
-
"tag": "0020_pending_extractions",
|
|
157
|
-
"breakpoints": true
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"idx": 22,
|
|
161
|
-
"version": "7",
|
|
162
|
-
"when": 1700000022000,
|
|
163
|
-
"tag": "0021_rag_documents",
|
|
164
|
-
"breakpoints": true
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
"idx": 23,
|
|
168
|
-
"version": "7",
|
|
169
|
-
"when": 1700000023000,
|
|
170
|
-
"tag": "0022_user_quotas_usage_jsonb",
|
|
171
|
-
"breakpoints": true
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
"idx": 24,
|
|
175
|
-
"version": "7",
|
|
176
|
-
"when": 1700000024000,
|
|
177
|
-
"tag": "0023_user_facts_user_scoped_unique",
|
|
178
|
-
"breakpoints": true
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"idx": 25,
|
|
182
|
-
"version": "7",
|
|
183
|
-
"when": 1700000025000,
|
|
184
|
-
"tag": "0024_user_memories_hnsw",
|
|
185
|
-
"breakpoints": true
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
"idx": 26,
|
|
189
|
-
"version": "7",
|
|
190
|
-
"when": 1700000026000,
|
|
191
|
-
"tag": "0025_audit_trigger_errcode",
|
|
192
|
-
"breakpoints": true
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
"idx": 27,
|
|
196
|
-
"version": "7",
|
|
197
|
-
"when": 1700000027000,
|
|
198
|
-
"tag": "0026_user_profile_snapshots_composite_pk",
|
|
199
|
-
"breakpoints": true
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
"idx": 28,
|
|
203
|
-
"version": "7",
|
|
204
|
-
"when": 1700000028000,
|
|
205
|
-
"tag": "0027_billing_settings_mnt_columns",
|
|
206
|
-
"breakpoints": true
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"idx": 29,
|
|
210
|
-
"version": "7",
|
|
211
|
-
"when": 1700000029000,
|
|
212
|
-
"tag": "0028_trial_credits_normalized_email",
|
|
213
|
-
"breakpoints": true
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
"idx": 30,
|
|
217
|
-
"version": "7",
|
|
218
|
-
"when": 1700000030000,
|
|
219
|
-
"tag": "0029_usage_records_conversation_idx",
|
|
220
|
-
"breakpoints": true
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"idx": 31,
|
|
224
|
-
"version": "7",
|
|
225
|
-
"when": 1700000031000,
|
|
226
|
-
"tag": "0030_pending_extractions_composite_idx",
|
|
227
|
-
"breakpoints": true
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
"idx": 32,
|
|
231
|
-
"version": "7",
|
|
232
|
-
"when": 1700000032000,
|
|
233
|
-
"tag": "0031_rag_documents_hnsw",
|
|
234
|
-
"breakpoints": true
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"idx": 33,
|
|
238
|
-
"version": "7",
|
|
239
|
-
"when": 1700000033000,
|
|
240
|
-
"tag": "0032_rate_limit_unique_idx",
|
|
241
|
-
"breakpoints": true
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
"idx": 34,
|
|
245
|
-
"version": "7",
|
|
246
|
-
"when": 1700000034000,
|
|
247
|
-
"tag": "0033_pending_extractions_partial_idx",
|
|
248
|
-
"breakpoints": true
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
"idx": 35,
|
|
252
|
-
"version": "7",
|
|
253
|
-
"when": 1700000035000,
|
|
254
|
-
"tag": "0034_rate_limit_count",
|
|
255
|
-
"breakpoints": true
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
"idx": 36,
|
|
259
|
-
"version": "7",
|
|
260
|
-
"when": 1700000036000,
|
|
261
|
-
"tag": "0035_credit_reservations",
|
|
262
|
-
"breakpoints": true
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
"idx": 37,
|
|
266
|
-
"version": "7",
|
|
267
|
-
"when": 1700000037000,
|
|
268
|
-
"tag": "0036_executions_audit_jobs",
|
|
269
|
-
"breakpoints": true
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
"idx": 38,
|
|
273
|
-
"version": "7",
|
|
274
|
-
"when": 1700000038000,
|
|
275
|
-
"tag": "0037_rate_limit_minute_bucket",
|
|
276
|
-
"breakpoints": true
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
"idx": 39,
|
|
280
|
-
"version": "7",
|
|
281
|
-
"when": 1700000039000,
|
|
282
|
-
"tag": "0038_user_quotas_generic_usage",
|
|
283
|
-
"breakpoints": true
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
"idx": 40,
|
|
287
|
-
"version": "7",
|
|
288
|
-
"when": 1700000040000,
|
|
289
|
-
"tag": "0039_platform_admin_impersonation",
|
|
290
|
-
"breakpoints": true
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"idx": 41,
|
|
294
|
-
"version": "7",
|
|
295
|
-
"when": 1700000041000,
|
|
296
|
-
"tag": "0040_ee_audit_chain",
|
|
29
|
+
"when": 1790179158533,
|
|
30
|
+
"tag": "0003_local_payments",
|
|
297
31
|
"breakpoints": true
|
|
298
32
|
}
|
|
299
33
|
]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pgTable,
|
|
3
|
+
text,
|
|
4
|
+
timestamp,
|
|
5
|
+
integer,
|
|
6
|
+
boolean,
|
|
7
|
+
jsonb,
|
|
8
|
+
} from "drizzle-orm/pg-core";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Localized text, keyed by locale tag: `{ en: "…", de: "…" }`. Open, so
|
|
12
|
+
* adding a language is not a schema change.
|
|
13
|
+
*/
|
|
14
|
+
export type LocalizedText = Record<string, string>;
|
|
15
|
+
|
|
16
|
+
/** A quick-start prompt shown for an agent. */
|
|
17
|
+
export type AgentSuggestion = {
|
|
18
|
+
id: string;
|
|
19
|
+
label: LocalizedText;
|
|
20
|
+
prompt: LocalizedText;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Per-agent model routing. Only `primary` is read. */
|
|
24
|
+
export type AgentModelConfig = {
|
|
25
|
+
primary: string;
|
|
26
|
+
fallback?: string;
|
|
27
|
+
routing?: Record<string, string>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** AI agent configuration: system prompt, tools and model per agent. */
|
|
31
|
+
export const agents = pgTable("agents", {
|
|
32
|
+
id: text("id").primaryKey(), // Slug, e.g. "support-assistant"
|
|
33
|
+
name: jsonb("name").notNull().$type<LocalizedText>(), // { en: "Support Assistant", … }
|
|
34
|
+
description: jsonb("description").notNull().$type<LocalizedText>(), // { en: "…", … }
|
|
35
|
+
systemPromptKey: text("system_prompt_key").notNull(), // Translation namespace key; not read at runtime (systemPrompt is).
|
|
36
|
+
systemPrompt: jsonb("system_prompt").$type<LocalizedText | null>(), // Source of truth for agent instructions.
|
|
37
|
+
modelConfig: jsonb("model_config").$type<AgentModelConfig | null>(), // Only `primary` is read.
|
|
38
|
+
icon: text("icon").notNull(), // Icon identifier (e.g., "briefcase", "map-pin")
|
|
39
|
+
defaultModel: text("default_model").notNull(), // AI model ID (e.g., "openai/gpt-4o") — fallback when modelConfig is null.
|
|
40
|
+
maxSteps: integer("max_steps").notNull(), // ToolLoopAgent max iterations
|
|
41
|
+
contextWindowSize: integer("context_window_size").notNull(), // Conversation windowing message count
|
|
42
|
+
tools: jsonb("tools").notNull().default([]).$type<string[]>(), // Array of tool names
|
|
43
|
+
basePath: text("base_path").notNull(), // URL base path (e.g., "/support")
|
|
44
|
+
isActive: boolean("is_active").notNull().default(true), // Whether agent is available to users
|
|
45
|
+
suggestions: jsonb("suggestions")
|
|
46
|
+
.notNull()
|
|
47
|
+
.default([])
|
|
48
|
+
.$type<AgentSuggestion[]>(), // Quick-start suggestion prompts
|
|
49
|
+
isSystem: boolean("is_system").notNull().default(true), // System agents can't be deleted by users
|
|
50
|
+
featureKey: text("feature_key"), // Nullable: billing feature key (e.g., "support_assistant"). Used for feature gating lookups.
|
|
51
|
+
color: text("color").notNull().default("bg-gray-500"), // Tailwind bg class for UI indicators (e.g., "bg-blue-500")
|
|
52
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
53
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type Agent = typeof agents.$inferSelect;
|
|
57
|
+
export type InsertAgent = typeof agents.$inferInsert;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat persistence every product shares: conversations, messages,
|
|
3
|
+
* attachments, votes and documents (artifact versions).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
pgTable,
|
|
8
|
+
text,
|
|
9
|
+
timestamp,
|
|
10
|
+
integer,
|
|
11
|
+
index,
|
|
12
|
+
uniqueIndex,
|
|
13
|
+
boolean,
|
|
14
|
+
primaryKey,
|
|
15
|
+
jsonb,
|
|
16
|
+
} from "drizzle-orm/pg-core";
|
|
17
|
+
import { organization, users } from "./auth";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A product that attaches typed state to a conversation puts it under
|
|
21
|
+
* `productContext` and owns the shape.
|
|
22
|
+
*/
|
|
23
|
+
export type ConversationMetadata = {
|
|
24
|
+
conversationSummary?: string; // LLM-generated summary of pruned messages
|
|
25
|
+
productContext?: Record<string, unknown>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** One chat session between a user and an agent, within a workspace. */
|
|
30
|
+
export const conversations = pgTable(
|
|
31
|
+
"conversations",
|
|
32
|
+
{
|
|
33
|
+
id: text("id").primaryKey(),
|
|
34
|
+
workspaceId: text("workspace_id")
|
|
35
|
+
.notNull()
|
|
36
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
37
|
+
userId: text("user_id")
|
|
38
|
+
.notNull()
|
|
39
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
40
|
+
agentId: text("agent_id").notNull(), // the product's agent slug
|
|
41
|
+
title: text("title"), // Nullable until the product sets one
|
|
42
|
+
modelId: text("model_id"), // e.g., "openai/gpt-4o"
|
|
43
|
+
visibility: text("visibility").notNull().default("private"), // "private" | "public"
|
|
44
|
+
metadata: jsonb("metadata"), // ConversationMetadata
|
|
45
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
46
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
47
|
+
},
|
|
48
|
+
(table) => [
|
|
49
|
+
index("conversations_workspace_id_idx").on(table.workspaceId),
|
|
50
|
+
index("conversations_user_id_idx").on(table.userId),
|
|
51
|
+
index("conversations_workspace_updated_idx").on(
|
|
52
|
+
table.workspaceId,
|
|
53
|
+
table.updatedAt
|
|
54
|
+
),
|
|
55
|
+
index("conversations_workspace_user_idx").on(
|
|
56
|
+
table.workspaceId,
|
|
57
|
+
table.userId
|
|
58
|
+
),
|
|
59
|
+
]
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export const messages = pgTable(
|
|
63
|
+
"messages",
|
|
64
|
+
{
|
|
65
|
+
id: text("id").primaryKey(),
|
|
66
|
+
conversationId: text("conversation_id")
|
|
67
|
+
.notNull()
|
|
68
|
+
.references(() => conversations.id, { onDelete: "cascade" }),
|
|
69
|
+
role: text("role").notNull(), // "user" | "assistant" | "system" | "tool"
|
|
70
|
+
content: text("content"), // Nullable; `parts` holds the message
|
|
71
|
+
parts: text("parts").notNull(), // JSON array of AI SDK UIMessagePart objects
|
|
72
|
+
attachments: text("attachments"), // JSON array of file attachment metadata
|
|
73
|
+
toolInvocations: text("tool_invocations"), // JSON string of tool calls/results (AI SDK format)
|
|
74
|
+
tokenCount: integer("token_count"),
|
|
75
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
76
|
+
},
|
|
77
|
+
(table) => [
|
|
78
|
+
index("messages_conversation_id_idx").on(table.conversationId),
|
|
79
|
+
index("messages_conversation_created_idx").on(
|
|
80
|
+
table.conversationId,
|
|
81
|
+
table.createdAt
|
|
82
|
+
),
|
|
83
|
+
]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Files a user put into a conversation. The object lives behind the
|
|
88
|
+
* storage port under `storage_key`; the
|
|
89
|
+
* row is what makes a URL safe to hand out (tenancy, type, size).
|
|
90
|
+
* `conversation_id` is set once the turn that carried the file is
|
|
91
|
+
* persisted; a row that never gets one is an orphan to sweep.
|
|
92
|
+
*/
|
|
93
|
+
export const attachments = pgTable(
|
|
94
|
+
"attachments",
|
|
95
|
+
{
|
|
96
|
+
id: text("id").primaryKey(),
|
|
97
|
+
workspaceId: text("workspace_id")
|
|
98
|
+
.notNull()
|
|
99
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
100
|
+
userId: text("user_id")
|
|
101
|
+
.notNull()
|
|
102
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
103
|
+
conversationId: text("conversation_id").references(() => conversations.id, {
|
|
104
|
+
onDelete: "set null",
|
|
105
|
+
}),
|
|
106
|
+
storageKey: text("storage_key").notNull(),
|
|
107
|
+
filename: text("filename").notNull(),
|
|
108
|
+
mediaType: text("media_type").notNull(),
|
|
109
|
+
sizeBytes: integer("size_bytes").notNull(),
|
|
110
|
+
extractedText: text("extracted_text"), // document text for the model, when a policy extracts it
|
|
111
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
112
|
+
},
|
|
113
|
+
(table) => [
|
|
114
|
+
index("attachments_workspace_id_idx").on(table.workspaceId),
|
|
115
|
+
index("attachments_conversation_id_idx").on(table.conversationId),
|
|
116
|
+
uniqueIndex("attachments_storage_key_idx").on(table.storageKey),
|
|
117
|
+
]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/** One vote per message (composite key on chat and message). */
|
|
121
|
+
export const votes = pgTable(
|
|
122
|
+
"votes",
|
|
123
|
+
{
|
|
124
|
+
chatId: text("chat_id")
|
|
125
|
+
.notNull()
|
|
126
|
+
.references(() => conversations.id, { onDelete: "cascade" }),
|
|
127
|
+
messageId: text("message_id")
|
|
128
|
+
.notNull()
|
|
129
|
+
.references(() => messages.id, { onDelete: "cascade" }),
|
|
130
|
+
isUpvoted: boolean("is_upvoted").notNull(),
|
|
131
|
+
},
|
|
132
|
+
(table) => [
|
|
133
|
+
primaryKey({ columns: [table.chatId, table.messageId] }),
|
|
134
|
+
index("votes_message_id_idx").on(table.messageId),
|
|
135
|
+
]
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* AI-generated documents with version history: each save is a new row,
|
|
140
|
+
* keyed on id + createdAt.
|
|
141
|
+
*/
|
|
142
|
+
export const documents = pgTable(
|
|
143
|
+
"documents",
|
|
144
|
+
{
|
|
145
|
+
id: text("id").notNull(),
|
|
146
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
147
|
+
title: text("title").notNull(),
|
|
148
|
+
content: text("content"),
|
|
149
|
+
kind: text("kind").notNull().default("text"),
|
|
150
|
+
metadata: jsonb("metadata"), // Structured data (e.g. a report's JSON)
|
|
151
|
+
userId: text("user_id")
|
|
152
|
+
.notNull()
|
|
153
|
+
.references(() => users.id, { onDelete: "cascade" }),
|
|
154
|
+
workspaceId: text("workspace_id")
|
|
155
|
+
.notNull()
|
|
156
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
157
|
+
},
|
|
158
|
+
(table) => [
|
|
159
|
+
primaryKey({ columns: [table.id, table.createdAt] }),
|
|
160
|
+
index("documents_workspace_id_idx").on(table.workspaceId),
|
|
161
|
+
index("documents_user_id_idx").on(table.userId),
|
|
162
|
+
]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
export type Conversation = typeof conversations.$inferSelect;
|
|
166
|
+
export type InsertConversation = typeof conversations.$inferInsert;
|
|
167
|
+
export type Message = typeof messages.$inferSelect;
|
|
168
|
+
export type InsertMessage = typeof messages.$inferInsert;
|
|
169
|
+
export type Attachment = typeof attachments.$inferSelect;
|
|
170
|
+
export type InsertAttachment = typeof attachments.$inferInsert;
|
|
171
|
+
export type Vote = typeof votes.$inferSelect;
|
|
172
|
+
export type InsertVote = typeof votes.$inferInsert;
|
|
173
|
+
export type Document = typeof documents.$inferSelect;
|
|
174
|
+
export type InsertDocument = typeof documents.$inferInsert;
|