@happyvertical/smrt-messages 0.62.6 → 0.62.8

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 (83) hide show
  1. package/AGENTS.md +102 -0
  2. package/dist/access-enforcement.d.ts +20 -0
  3. package/dist/access-enforcement.d.ts.map +1 -0
  4. package/dist/access.d.ts +203 -0
  5. package/dist/access.d.ts.map +1 -0
  6. package/dist/chunks/AttachmentCollection-DhCoruwp.js +308 -0
  7. package/dist/chunks/AttachmentCollection-DhCoruwp.js.map +1 -0
  8. package/dist/chunks/{Email-ChfbMCSF.js → Email-CmNoK1lj.js} +9 -6
  9. package/dist/chunks/Email-CmNoK1lj.js.map +1 -0
  10. package/dist/chunks/EmailAccountCollection-CHizpsxL.js +1555 -0
  11. package/dist/chunks/EmailAccountCollection-CHizpsxL.js.map +1 -0
  12. package/dist/chunks/EmailCollection-Yo2wBv_1.js +181 -0
  13. package/dist/chunks/EmailCollection-Yo2wBv_1.js.map +1 -0
  14. package/dist/chunks/{EmailFolder-XH5eH4Ed.js → EmailFolder-Dks5clxA.js} +25 -6
  15. package/dist/chunks/EmailFolder-Dks5clxA.js.map +1 -0
  16. package/dist/chunks/EmailFolderCollection-nIR4Kpcr.js +177 -0
  17. package/dist/chunks/EmailFolderCollection-nIR4Kpcr.js.map +1 -0
  18. package/dist/chunks/EmailSender-B-Rtq9du.js +147 -0
  19. package/dist/chunks/EmailSender-B-Rtq9du.js.map +1 -0
  20. package/dist/chunks/{Message-C6P1V5C_.js → Message-e99HkbG8.js} +30 -6
  21. package/dist/chunks/Message-e99HkbG8.js.map +1 -0
  22. package/dist/chunks/{MessageCollection-CjCT06XE.js → MessageCollection-t8cLUSNJ.js} +2 -2
  23. package/dist/chunks/{MessageCollection-CjCT06XE.js.map → MessageCollection-t8cLUSNJ.js.map} +1 -1
  24. package/dist/chunks/MessagingEndpointCollection-CGtAL77R.js +97 -0
  25. package/dist/chunks/MessagingEndpointCollection-CGtAL77R.js.map +1 -0
  26. package/dist/chunks/{SlackSender-CjSvwY1K.js → SlackSender-CetlSe6D.js} +2 -2
  27. package/dist/chunks/{SlackSender-CjSvwY1K.js.map → SlackSender-CetlSe6D.js.map} +1 -1
  28. package/dist/chunks/{TweetSender-CcLPNNi1.js → TweetSender-Dw-TDxIB.js} +2 -2
  29. package/dist/chunks/{TweetSender-CcLPNNi1.js.map → TweetSender-Dw-TDxIB.js.map} +1 -1
  30. package/dist/chunks/{providers-4iLula-V.js → providers-Bz_F_ywF.js} +36 -1
  31. package/dist/chunks/{providers-4iLula-V.js.map → providers-Bz_F_ywF.js.map} +1 -1
  32. package/dist/collections/AttachmentCollection.d.ts +6 -0
  33. package/dist/collections/AttachmentCollection.d.ts.map +1 -1
  34. package/dist/collections/EmailAccountCollection.d.ts.map +1 -1
  35. package/dist/connect.d.ts +82 -0
  36. package/dist/connect.d.ts.map +1 -0
  37. package/dist/connect.js +126 -0
  38. package/dist/connect.js.map +1 -0
  39. package/dist/index.d.ts +3 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +507 -1402
  42. package/dist/index.js.map +1 -1
  43. package/dist/mail-sync-jobs.d.ts +48 -0
  44. package/dist/mail-sync-jobs.d.ts.map +1 -0
  45. package/dist/mail-sync.d.ts +58 -0
  46. package/dist/mail-sync.d.ts.map +1 -0
  47. package/dist/manifest.json +1040 -56
  48. package/dist/models/Account.d.ts +23 -0
  49. package/dist/models/Account.d.ts.map +1 -1
  50. package/dist/models/Attachment.d.ts +14 -0
  51. package/dist/models/Attachment.d.ts.map +1 -1
  52. package/dist/models/Email.d.ts +1 -0
  53. package/dist/models/Email.d.ts.map +1 -1
  54. package/dist/models/EmailAccount.d.ts +32 -2
  55. package/dist/models/EmailAccount.d.ts.map +1 -1
  56. package/dist/models/EmailFolder.d.ts +7 -0
  57. package/dist/models/EmailFolder.d.ts.map +1 -1
  58. package/dist/models/Message.d.ts +7 -0
  59. package/dist/models/Message.d.ts.map +1 -1
  60. package/dist/permissions.d.ts +11 -0
  61. package/dist/permissions.d.ts.map +1 -1
  62. package/dist/providers/email.js +3 -2
  63. package/dist/providers/email.js.map +1 -1
  64. package/dist/providers/slack.js +2 -2
  65. package/dist/providers/twitter.js +2 -2
  66. package/dist/providers.d.ts.map +1 -1
  67. package/dist/recipes.d.ts +1 -1
  68. package/dist/services/MessagingSettingsService.d.ts +86 -0
  69. package/dist/services/MessagingSettingsService.d.ts.map +1 -1
  70. package/dist/services/NotificationOutboxService.d.ts +3 -0
  71. package/dist/services/NotificationOutboxService.d.ts.map +1 -1
  72. package/dist/smrt-knowledge.json +826 -29
  73. package/dist/smrt-knowledge.okf.md +4 -2
  74. package/dist/types.d.ts +10 -1
  75. package/dist/types.d.ts.map +1 -1
  76. package/package.json +21 -16
  77. package/dist/chunks/AccountCollection-RP_hLf6L.js +0 -257
  78. package/dist/chunks/AccountCollection-RP_hLf6L.js.map +0 -1
  79. package/dist/chunks/Email-ChfbMCSF.js.map +0 -1
  80. package/dist/chunks/EmailFolder-XH5eH4Ed.js.map +0 -1
  81. package/dist/chunks/Message-C6P1V5C_.js.map +0 -1
  82. package/dist/chunks/__smrt-register__-CfOb1uCN.js +0 -6
  83. package/dist/chunks/__smrt-register__-CfOb1uCN.js.map +0 -1
@@ -3,18 +3,19 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-messages",
6
- "packageVersion": "0.62.6",
6
+ "packageVersion": "0.62.8",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "69e9bc8f4035399e8714671a13cda5a09845639c1c2a19e210417cefc3b31557",
11
- "packageJson": "2a0f053d714f42a08aaa7594bc78683d2c45bd57168e6869a247ce56468adaef",
12
- "agents": "982506bdb93396f2cba5ca381c00b3e016199c2852e8f05eec27dc2de40ea106",
10
+ "manifest": "a96b8fdd5313347a372e26a66d66bbc52953b2e5ad113fc8b42cf302f130304c",
11
+ "packageJson": "5028e9ffa88bda2ddda443593a8328574db036fece8ac463703c7d621d305471",
12
+ "agents": "d0e96fb1da71c991c47f14bf2add20ff51b97deb3ff4482cc7569800ef11f047",
13
13
  "moduleDoc:agents/notification-outbox.md": "0e9a870c4b2d5f0fec47af0dff6e61d216fb0121d384d99bccfc506beb6e38ad",
14
14
  "moduleDoc:agents/profile-recipients.md": "1b6710bf646ddeafd6836df8270fcbb8e29226dceda716a693d945cc2e914606"
15
15
  },
16
16
  "exports": [
17
17
  ".",
18
+ "./connect",
18
19
  "./manifest",
19
20
  "./manifest.json",
20
21
  "./playground",
@@ -31,10 +32,11 @@
31
32
  "@happyvertical/logger": "catalog:",
32
33
  "@happyvertical/messages": "catalog:",
33
34
  "@happyvertical/smrt-core": "workspace:*",
35
+ "@happyvertical/smrt-jobs": "workspace:*",
34
36
  "@happyvertical/smrt-profiles": "workspace:*",
35
- "@happyvertical/smrt-types": "workspace:*",
36
37
  "@happyvertical/smrt-secrets": "workspace:*",
37
38
  "@happyvertical/smrt-tenancy": "workspace:*",
39
+ "@happyvertical/smrt-types": "workspace:*",
38
40
  "@happyvertical/smrt-ui": "workspace:*",
39
41
  "@happyvertical/smrt-users": "workspace:*",
40
42
  "@happyvertical/sql": "catalog:",
@@ -53,6 +55,7 @@
53
55
  },
54
56
  "smrtDependencies": [
55
57
  "@happyvertical/smrt-core",
58
+ "@happyvertical/smrt-jobs",
56
59
  "@happyvertical/smrt-ledgers",
57
60
  "@happyvertical/smrt-profiles",
58
61
  "@happyvertical/smrt-secrets",
@@ -83,7 +86,7 @@
83
86
  "typescript"
84
87
  ],
85
88
  "risks": [
86
- "cross-package-refs:10",
89
+ "cross-package-refs:16",
87
90
  "sensitive-fields-excluded",
88
91
  "sti-inheritance"
89
92
  ],
@@ -253,6 +256,7 @@
253
256
  "fields": [],
254
257
  "relationships": [],
255
258
  "methods": [
259
+ "backfillAccountIds",
256
260
  "deleteByMessage",
257
261
  "findByTenant",
258
262
  "findGlobal",
@@ -271,6 +275,11 @@
271
275
  "searchByFilename"
272
276
  ],
273
277
  "methodSignatures": [
278
+ {
279
+ "name": "backfillAccountIds",
280
+ "async": true,
281
+ "returns": "Promise<number>"
282
+ },
274
283
  {
275
284
  "name": "deleteByMessage",
276
285
  "async": true,
@@ -392,6 +401,12 @@
392
401
  }
393
402
  ],
394
403
  "surfaces": [
404
+ {
405
+ "kind": "cli",
406
+ "name": "attachmentcollection_backfillAccountIds",
407
+ "operation": "backfillAccountIds",
408
+ "objectName": "@happyvertical/smrt-messages:AttachmentCollection"
409
+ },
395
410
  {
396
411
  "kind": "cli",
397
412
  "name": "attachmentcollection_getByMessage",
@@ -490,6 +505,13 @@
490
505
  }
491
506
  ],
492
507
  "withheldSurfaces": [
508
+ {
509
+ "kind": "api",
510
+ "operation": "backfillAccountIds",
511
+ "code": "not-included",
512
+ "reason": "not listed in api.include",
513
+ "objectName": "@happyvertical/smrt-messages:AttachmentCollection"
514
+ },
493
515
  {
494
516
  "kind": "api",
495
517
  "operation": "deleteByMessage",
@@ -960,6 +982,7 @@
960
982
  "fields": [],
961
983
  "relationships": [],
962
984
  "methods": [
985
+ "backfillAccountIds",
963
986
  "deleteByEmail",
964
987
  "deleteByMessage",
965
988
  "findByTenant",
@@ -980,6 +1003,11 @@
980
1003
  "searchByFilename"
981
1004
  ],
982
1005
  "methodSignatures": [
1006
+ {
1007
+ "name": "backfillAccountIds",
1008
+ "async": true,
1009
+ "returns": "Promise<number>"
1010
+ },
983
1011
  {
984
1012
  "name": "deleteByEmail",
985
1013
  "async": true,
@@ -1117,6 +1145,12 @@
1117
1145
  }
1118
1146
  ],
1119
1147
  "surfaces": [
1148
+ {
1149
+ "kind": "cli",
1150
+ "name": "emailattachmentcollection_backfillAccountIds",
1151
+ "operation": "backfillAccountIds",
1152
+ "objectName": "@happyvertical/smrt-messages:EmailAttachmentCollection"
1153
+ },
1120
1154
  {
1121
1155
  "kind": "cli",
1122
1156
  "name": "emailattachmentcollection_getByMessage",
@@ -1227,6 +1261,13 @@
1227
1261
  }
1228
1262
  ],
1229
1263
  "withheldSurfaces": [
1264
+ {
1265
+ "kind": "api",
1266
+ "operation": "backfillAccountIds",
1267
+ "code": "not-included",
1268
+ "reason": "not listed in api.include",
1269
+ "objectName": "@happyvertical/smrt-messages:EmailAttachmentCollection"
1270
+ },
1230
1271
  {
1231
1272
  "kind": "api",
1232
1273
  "operation": "deleteByEmail",
@@ -3062,6 +3103,35 @@
3062
3103
  "default": true,
3063
3104
  "description": "Whether this account is enabled for messaging."
3064
3105
  },
3106
+ {
3107
+ "name": "ownerUserId",
3108
+ "type": "crossPackageRef",
3109
+ "required": false,
3110
+ "related": "@happyvertical/smrt-users:User",
3111
+ "columnType": "UUID",
3112
+ "description": "The person who owns this account and decides who else may use it."
3113
+ },
3114
+ {
3115
+ "name": "label",
3116
+ "type": "text",
3117
+ "required": false,
3118
+ "columnType": "TEXT",
3119
+ "description": "A short name shown beside this account, such as Support or Personal."
3120
+ },
3121
+ {
3122
+ "name": "connectionStatus",
3123
+ "type": "text",
3124
+ "required": false,
3125
+ "columnType": "TEXT",
3126
+ "description": "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."
3127
+ },
3128
+ {
3129
+ "name": "statusMessage",
3130
+ "type": "text",
3131
+ "required": false,
3132
+ "columnType": "TEXT",
3133
+ "description": "Why the account needs attention, in plain words."
3134
+ },
3065
3135
  {
3066
3136
  "name": "lastSyncAt",
3067
3137
  "type": "datetime",
@@ -3091,7 +3161,15 @@
3091
3161
  "description": "When this account was last changed."
3092
3162
  }
3093
3163
  ],
3094
- "relationships": [],
3164
+ "relationships": [
3165
+ {
3166
+ "name": "ownerUserId",
3167
+ "type": "crossPackageRef",
3168
+ "required": false,
3169
+ "related": "@happyvertical/smrt-users:User",
3170
+ "columnType": "UUID"
3171
+ }
3172
+ ],
3095
3173
  "methods": [
3096
3174
  "activate",
3097
3175
  "createSender",
@@ -3099,6 +3177,9 @@
3099
3177
  "getConfiguration",
3100
3178
  "getCredentials",
3101
3179
  "getSettings",
3180
+ "markConnected",
3181
+ "markNeedsReconnect",
3182
+ "removeCredentials",
3102
3183
  "setConfiguration",
3103
3184
  "setCredentials",
3104
3185
  "setSettings"
@@ -3132,6 +3213,24 @@
3132
3213
  "name": "getSettings",
3133
3214
  "returns": "Record<string, unknown>"
3134
3215
  },
3216
+ {
3217
+ "name": "markConnected",
3218
+ "async": true,
3219
+ "returns": "Promise<void>"
3220
+ },
3221
+ {
3222
+ "name": "markNeedsReconnect",
3223
+ "async": true,
3224
+ "params": [
3225
+ "reason: string"
3226
+ ],
3227
+ "returns": "Promise<void>"
3228
+ },
3229
+ {
3230
+ "name": "removeCredentials",
3231
+ "async": true,
3232
+ "returns": "Promise<void>"
3233
+ },
3135
3234
  {
3136
3235
  "name": "setConfiguration",
3137
3236
  "params": [
@@ -3253,6 +3352,27 @@
3253
3352
  "reason": "not listed in api.include",
3254
3353
  "objectName": "@happyvertical/smrt-messages:Account"
3255
3354
  },
3355
+ {
3356
+ "kind": "api",
3357
+ "operation": "markConnected",
3358
+ "code": "not-included",
3359
+ "reason": "not listed in api.include",
3360
+ "objectName": "@happyvertical/smrt-messages:Account"
3361
+ },
3362
+ {
3363
+ "kind": "api",
3364
+ "operation": "markNeedsReconnect",
3365
+ "code": "not-included",
3366
+ "reason": "not listed in api.include",
3367
+ "objectName": "@happyvertical/smrt-messages:Account"
3368
+ },
3369
+ {
3370
+ "kind": "api",
3371
+ "operation": "removeCredentials",
3372
+ "code": "not-included",
3373
+ "reason": "not listed in api.include",
3374
+ "objectName": "@happyvertical/smrt-messages:Account"
3375
+ },
3256
3376
  {
3257
3377
  "kind": "api",
3258
3378
  "operation": "setConfiguration",
@@ -3276,6 +3396,7 @@
3276
3396
  }
3277
3397
  ],
3278
3398
  "relationshipFeatures": [
3399
+ "crossPackageRef",
3279
3400
  "uuidColumns"
3280
3401
  ],
3281
3402
  "tags": [],
@@ -3302,6 +3423,13 @@
3302
3423
  "related": "Message",
3303
3424
  "columnType": "UUID"
3304
3425
  },
3426
+ {
3427
+ "name": "accountId",
3428
+ "type": "foreignKey",
3429
+ "required": false,
3430
+ "related": "Account",
3431
+ "columnType": "UUID"
3432
+ },
3305
3433
  {
3306
3434
  "name": "filename",
3307
3435
  "type": "text",
@@ -3360,6 +3488,13 @@
3360
3488
  "required": false,
3361
3489
  "related": "Message",
3362
3490
  "columnType": "UUID"
3491
+ },
3492
+ {
3493
+ "name": "accountId",
3494
+ "type": "foreignKey",
3495
+ "required": false,
3496
+ "related": "Account",
3497
+ "columnType": "UUID"
3363
3498
  }
3364
3499
  ],
3365
3500
  "methods": [
@@ -3370,6 +3505,8 @@
3370
3505
  "isImage",
3371
3506
  "isInline",
3372
3507
  "isPdf",
3508
+ "loadFromId",
3509
+ "loadFromSlug",
3373
3510
  "readContent"
3374
3511
  ],
3375
3512
  "methodSignatures": [
@@ -3402,6 +3539,16 @@
3402
3539
  "name": "isPdf",
3403
3540
  "returns": "boolean"
3404
3541
  },
3542
+ {
3543
+ "name": "loadFromId",
3544
+ "async": true,
3545
+ "returns": "any"
3546
+ },
3547
+ {
3548
+ "name": "loadFromSlug",
3549
+ "async": true,
3550
+ "returns": "any"
3551
+ },
3405
3552
  {
3406
3553
  "name": "readContent",
3407
3554
  "async": true,
@@ -3592,6 +3739,20 @@
3592
3739
  "reason": "not listed in api.include",
3593
3740
  "objectName": "@happyvertical/smrt-messages:Attachment"
3594
3741
  },
3742
+ {
3743
+ "kind": "api",
3744
+ "operation": "loadFromId",
3745
+ "code": "lifecycle-method",
3746
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
3747
+ "objectName": "@happyvertical/smrt-messages:Attachment"
3748
+ },
3749
+ {
3750
+ "kind": "api",
3751
+ "operation": "loadFromSlug",
3752
+ "code": "lifecycle-method",
3753
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
3754
+ "objectName": "@happyvertical/smrt-messages:Attachment"
3755
+ },
3595
3756
  {
3596
3757
  "kind": "api",
3597
3758
  "operation": "readContent",
@@ -4029,6 +4190,13 @@
4029
4190
  "columnType": "TEXT",
4030
4191
  "description": "The sender-assigned reference of the email being replied to."
4031
4192
  },
4193
+ {
4194
+ "name": "providerMessageId",
4195
+ "type": "text",
4196
+ "required": false,
4197
+ "columnType": "TEXT",
4198
+ "description": "The mail server's own id for this email, used to keep mailbox sync from storing it twice."
4199
+ },
4032
4200
  {
4033
4201
  "name": "ccAddresses",
4034
4202
  "type": "text",
@@ -4182,6 +4350,8 @@
4182
4350
  "getToAddresses",
4183
4351
  "isSendOutcomeUnknown",
4184
4352
  "isUnread",
4353
+ "loadFromId",
4354
+ "loadFromSlug",
4185
4355
  "markRead",
4186
4356
  "markUnread",
4187
4357
  "retrySend",
@@ -4299,6 +4469,16 @@
4299
4469
  "name": "isUnread",
4300
4470
  "returns": "boolean"
4301
4471
  },
4472
+ {
4473
+ "name": "loadFromId",
4474
+ "async": true,
4475
+ "returns": "any"
4476
+ },
4477
+ {
4478
+ "name": "loadFromSlug",
4479
+ "async": true,
4480
+ "returns": "any"
4481
+ },
4302
4482
  {
4303
4483
  "name": "markRead",
4304
4484
  "async": true,
@@ -4780,6 +4960,20 @@
4780
4960
  "reason": "not listed in api.include",
4781
4961
  "objectName": "@happyvertical/smrt-messages:Email"
4782
4962
  },
4963
+ {
4964
+ "kind": "api",
4965
+ "operation": "loadFromId",
4966
+ "code": "lifecycle-method",
4967
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
4968
+ "objectName": "@happyvertical/smrt-messages:Email"
4969
+ },
4970
+ {
4971
+ "kind": "api",
4972
+ "operation": "loadFromSlug",
4973
+ "code": "lifecycle-method",
4974
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
4975
+ "objectName": "@happyvertical/smrt-messages:Email"
4976
+ },
4783
4977
  {
4784
4978
  "kind": "api",
4785
4979
  "operation": "markRead",
@@ -4922,6 +5116,35 @@
4922
5116
  "default": true,
4923
5117
  "description": "Whether this account is enabled for messaging."
4924
5118
  },
5119
+ {
5120
+ "name": "ownerUserId",
5121
+ "type": "crossPackageRef",
5122
+ "required": false,
5123
+ "related": "@happyvertical/smrt-users:User",
5124
+ "columnType": "UUID",
5125
+ "description": "The person who owns this account and decides who else may use it."
5126
+ },
5127
+ {
5128
+ "name": "label",
5129
+ "type": "text",
5130
+ "required": false,
5131
+ "columnType": "TEXT",
5132
+ "description": "A short name shown beside this account, such as Support or Personal."
5133
+ },
5134
+ {
5135
+ "name": "connectionStatus",
5136
+ "type": "text",
5137
+ "required": false,
5138
+ "columnType": "TEXT",
5139
+ "description": "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."
5140
+ },
5141
+ {
5142
+ "name": "statusMessage",
5143
+ "type": "text",
5144
+ "required": false,
5145
+ "columnType": "TEXT",
5146
+ "description": "Why the account needs attention, in plain words."
5147
+ },
4925
5148
  {
4926
5149
  "name": "lastSyncAt",
4927
5150
  "type": "datetime",
@@ -4966,24 +5189,38 @@
4966
5189
  "description": "The time in minutes between scheduled mailbox checks."
4967
5190
  }
4968
5191
  ],
4969
- "relationships": [],
5192
+ "relationships": [
5193
+ {
5194
+ "name": "ownerUserId",
5195
+ "type": "crossPackageRef",
5196
+ "required": false,
5197
+ "related": "@happyvertical/smrt-users:User",
5198
+ "columnType": "UUID"
5199
+ }
5200
+ ],
4970
5201
  "methods": [
4971
5202
  "activate",
5203
+ "childOptions",
4972
5204
  "createClient",
4973
5205
  "createSender",
4974
5206
  "deactivate",
5207
+ "fetchThread",
4975
5208
  "getConfiguration",
4976
5209
  "getCredentials",
4977
5210
  "getEmails",
4978
5211
  "getFolders",
4979
5212
  "getSettings",
4980
5213
  "getUnreadCount",
5214
+ "markConnected",
5215
+ "markNeedsReconnect",
4981
5216
  "migrateToSecrets",
4982
5217
  "readIntakeMessage",
5218
+ "removeCredentials",
4983
5219
  "setConfiguration",
4984
5220
  "setCredentials",
4985
5221
  "setSettings",
4986
5222
  "syncAll",
5223
+ "syncChanges",
4987
5224
  "syncFrom"
4988
5225
  ],
4989
5226
  "methodSignatures": [
@@ -4992,6 +5229,10 @@
4992
5229
  "async": true,
4993
5230
  "returns": "Promise<void>"
4994
5231
  },
5232
+ {
5233
+ "name": "childOptions",
5234
+ "returns": "Record<string, unknown>"
5235
+ },
4995
5236
  {
4996
5237
  "name": "createClient",
4997
5238
  "async": true,
@@ -5007,6 +5248,14 @@
5007
5248
  "async": true,
5008
5249
  "returns": "Promise<void>"
5009
5250
  },
5251
+ {
5252
+ "name": "fetchThread",
5253
+ "async": true,
5254
+ "params": [
5255
+ "threadId: string"
5256
+ ],
5257
+ "returns": "any"
5258
+ },
5010
5259
  {
5011
5260
  "name": "getConfiguration",
5012
5261
  "returns": "Record<string, unknown>"
@@ -5038,6 +5287,19 @@
5038
5287
  "async": true,
5039
5288
  "returns": "Promise<number>"
5040
5289
  },
5290
+ {
5291
+ "name": "markConnected",
5292
+ "async": true,
5293
+ "returns": "Promise<void>"
5294
+ },
5295
+ {
5296
+ "name": "markNeedsReconnect",
5297
+ "async": true,
5298
+ "params": [
5299
+ "reason: string"
5300
+ ],
5301
+ "returns": "Promise<void>"
5302
+ },
5041
5303
  {
5042
5304
  "name": "migrateToSecrets",
5043
5305
  "async": true,
@@ -5053,6 +5315,11 @@
5053
5315
  ],
5054
5316
  "returns": "any"
5055
5317
  },
5318
+ {
5319
+ "name": "removeCredentials",
5320
+ "async": true,
5321
+ "returns": "Promise<void>"
5322
+ },
5056
5323
  {
5057
5324
  "name": "setConfiguration",
5058
5325
  "params": [
@@ -5084,6 +5351,14 @@
5084
5351
  ],
5085
5352
  "returns": "Promise<Map<string, object>>"
5086
5353
  },
5354
+ {
5355
+ "name": "syncChanges",
5356
+ "async": true,
5357
+ "params": [
5358
+ "options?: MailSyncOptions"
5359
+ ],
5360
+ "returns": "Promise<MailSyncResult>"
5361
+ },
5087
5362
  {
5088
5363
  "name": "syncFrom",
5089
5364
  "async": true,
@@ -5144,6 +5419,13 @@
5144
5419
  "reason": "not listed in api.include",
5145
5420
  "objectName": "@happyvertical/smrt-messages:EmailAccount"
5146
5421
  },
5422
+ {
5423
+ "kind": "api",
5424
+ "operation": "childOptions",
5425
+ "code": "not-included",
5426
+ "reason": "not listed in api.include",
5427
+ "objectName": "@happyvertical/smrt-messages:EmailAccount"
5428
+ },
5147
5429
  {
5148
5430
  "kind": "api",
5149
5431
  "operation": "createClient",
@@ -5165,6 +5447,13 @@
5165
5447
  "reason": "not listed in api.include",
5166
5448
  "objectName": "@happyvertical/smrt-messages:EmailAccount"
5167
5449
  },
5450
+ {
5451
+ "kind": "api",
5452
+ "operation": "fetchThread",
5453
+ "code": "not-included",
5454
+ "reason": "not listed in api.include",
5455
+ "objectName": "@happyvertical/smrt-messages:EmailAccount"
5456
+ },
5168
5457
  {
5169
5458
  "kind": "api",
5170
5459
  "operation": "getConfiguration",
@@ -5207,6 +5496,20 @@
5207
5496
  "reason": "not listed in api.include",
5208
5497
  "objectName": "@happyvertical/smrt-messages:EmailAccount"
5209
5498
  },
5499
+ {
5500
+ "kind": "api",
5501
+ "operation": "markConnected",
5502
+ "code": "not-included",
5503
+ "reason": "not listed in api.include",
5504
+ "objectName": "@happyvertical/smrt-messages:EmailAccount"
5505
+ },
5506
+ {
5507
+ "kind": "api",
5508
+ "operation": "markNeedsReconnect",
5509
+ "code": "not-included",
5510
+ "reason": "not listed in api.include",
5511
+ "objectName": "@happyvertical/smrt-messages:EmailAccount"
5512
+ },
5210
5513
  {
5211
5514
  "kind": "api",
5212
5515
  "operation": "migrateToSecrets",
@@ -5221,6 +5524,13 @@
5221
5524
  "reason": "not listed in api.include",
5222
5525
  "objectName": "@happyvertical/smrt-messages:EmailAccount"
5223
5526
  },
5527
+ {
5528
+ "kind": "api",
5529
+ "operation": "removeCredentials",
5530
+ "code": "not-included",
5531
+ "reason": "not listed in api.include",
5532
+ "objectName": "@happyvertical/smrt-messages:EmailAccount"
5533
+ },
5224
5534
  {
5225
5535
  "kind": "api",
5226
5536
  "operation": "setConfiguration",
@@ -5249,6 +5559,13 @@
5249
5559
  "reason": "not listed in api.include",
5250
5560
  "objectName": "@happyvertical/smrt-messages:EmailAccount"
5251
5561
  },
5562
+ {
5563
+ "kind": "api",
5564
+ "operation": "syncChanges",
5565
+ "code": "not-included",
5566
+ "reason": "not listed in api.include",
5567
+ "objectName": "@happyvertical/smrt-messages:EmailAccount"
5568
+ },
5252
5569
  {
5253
5570
  "kind": "api",
5254
5571
  "operation": "syncFrom",
@@ -5258,6 +5575,7 @@
5258
5575
  }
5259
5576
  ],
5260
5577
  "relationshipFeatures": [
5578
+ "crossPackageRef",
5261
5579
  "uuidColumns"
5262
5580
  ],
5263
5581
  "tags": [],
@@ -5284,6 +5602,13 @@
5284
5602
  "related": "Message",
5285
5603
  "columnType": "UUID"
5286
5604
  },
5605
+ {
5606
+ "name": "accountId",
5607
+ "type": "foreignKey",
5608
+ "required": false,
5609
+ "related": "Account",
5610
+ "columnType": "UUID"
5611
+ },
5287
5612
  {
5288
5613
  "name": "filename",
5289
5614
  "type": "text",
@@ -5342,6 +5667,13 @@
5342
5667
  "required": false,
5343
5668
  "related": "Message",
5344
5669
  "columnType": "UUID"
5670
+ },
5671
+ {
5672
+ "name": "accountId",
5673
+ "type": "foreignKey",
5674
+ "required": false,
5675
+ "related": "Account",
5676
+ "columnType": "UUID"
5345
5677
  }
5346
5678
  ],
5347
5679
  "methods": [
@@ -5353,6 +5685,8 @@
5353
5685
  "isImage",
5354
5686
  "isInline",
5355
5687
  "isPdf",
5688
+ "loadFromId",
5689
+ "loadFromSlug",
5356
5690
  "readContent"
5357
5691
  ],
5358
5692
  "methodSignatures": [
@@ -5390,6 +5724,16 @@
5390
5724
  "name": "isPdf",
5391
5725
  "returns": "boolean"
5392
5726
  },
5727
+ {
5728
+ "name": "loadFromId",
5729
+ "async": true,
5730
+ "returns": "any"
5731
+ },
5732
+ {
5733
+ "name": "loadFromSlug",
5734
+ "async": true,
5735
+ "returns": "any"
5736
+ },
5393
5737
  {
5394
5738
  "name": "readContent",
5395
5739
  "async": true,
@@ -5588,6 +5932,20 @@
5588
5932
  "reason": "not listed in api.include",
5589
5933
  "objectName": "@happyvertical/smrt-messages:EmailAttachment"
5590
5934
  },
5935
+ {
5936
+ "kind": "api",
5937
+ "operation": "loadFromId",
5938
+ "code": "lifecycle-method",
5939
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
5940
+ "objectName": "@happyvertical/smrt-messages:EmailAttachment"
5941
+ },
5942
+ {
5943
+ "kind": "api",
5944
+ "operation": "loadFromSlug",
5945
+ "code": "lifecycle-method",
5946
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
5947
+ "objectName": "@happyvertical/smrt-messages:EmailAttachment"
5948
+ },
5591
5949
  {
5592
5950
  "kind": "api",
5593
5951
  "operation": "readContent",
@@ -5702,6 +6060,8 @@
5702
6060
  "isSpam",
5703
6061
  "isSystemFolder",
5704
6062
  "isTrash",
6063
+ "loadFromId",
6064
+ "loadFromSlug",
5705
6065
  "refreshCounts",
5706
6066
  "subscribe",
5707
6067
  "unsubscribe"
@@ -5752,6 +6112,16 @@
5752
6112
  "name": "isTrash",
5753
6113
  "returns": "boolean"
5754
6114
  },
6115
+ {
6116
+ "name": "loadFromId",
6117
+ "async": true,
6118
+ "returns": "any"
6119
+ },
6120
+ {
6121
+ "name": "loadFromSlug",
6122
+ "async": true,
6123
+ "returns": "any"
6124
+ },
5755
6125
  {
5756
6126
  "name": "refreshCounts",
5757
6127
  "async": true,
@@ -5998,6 +6368,20 @@
5998
6368
  "reason": "not listed in api.include",
5999
6369
  "objectName": "@happyvertical/smrt-messages:EmailFolder"
6000
6370
  },
6371
+ {
6372
+ "kind": "api",
6373
+ "operation": "loadFromId",
6374
+ "code": "lifecycle-method",
6375
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
6376
+ "objectName": "@happyvertical/smrt-messages:EmailFolder"
6377
+ },
6378
+ {
6379
+ "kind": "api",
6380
+ "operation": "loadFromSlug",
6381
+ "code": "lifecycle-method",
6382
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
6383
+ "objectName": "@happyvertical/smrt-messages:EmailFolder"
6384
+ },
6001
6385
  {
6002
6386
  "kind": "api",
6003
6387
  "operation": "refreshCounts",
@@ -6284,6 +6668,8 @@
6284
6668
  "getToAddresses",
6285
6669
  "isSendOutcomeUnknown",
6286
6670
  "isUnread",
6671
+ "loadFromId",
6672
+ "loadFromSlug",
6287
6673
  "markRead",
6288
6674
  "markUnread",
6289
6675
  "retrySend",
@@ -6364,6 +6750,16 @@
6364
6750
  "name": "isUnread",
6365
6751
  "returns": "boolean"
6366
6752
  },
6753
+ {
6754
+ "name": "loadFromId",
6755
+ "async": true,
6756
+ "returns": "any"
6757
+ },
6758
+ {
6759
+ "name": "loadFromSlug",
6760
+ "async": true,
6761
+ "returns": "any"
6762
+ },
6367
6763
  {
6368
6764
  "name": "markRead",
6369
6765
  "async": true,
@@ -6689,6 +7085,20 @@
6689
7085
  "reason": "not listed in api.include",
6690
7086
  "objectName": "@happyvertical/smrt-messages:Message"
6691
7087
  },
7088
+ {
7089
+ "kind": "api",
7090
+ "operation": "loadFromId",
7091
+ "code": "lifecycle-method",
7092
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
7093
+ "objectName": "@happyvertical/smrt-messages:Message"
7094
+ },
7095
+ {
7096
+ "kind": "api",
7097
+ "operation": "loadFromSlug",
7098
+ "code": "lifecycle-method",
7099
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
7100
+ "objectName": "@happyvertical/smrt-messages:Message"
7101
+ },
6692
7102
  {
6693
7103
  "kind": "api",
6694
7104
  "operation": "markRead",
@@ -7507,6 +7917,35 @@
7507
7917
  "default": true,
7508
7918
  "description": "Whether this account is enabled for messaging."
7509
7919
  },
7920
+ {
7921
+ "name": "ownerUserId",
7922
+ "type": "crossPackageRef",
7923
+ "required": false,
7924
+ "related": "@happyvertical/smrt-users:User",
7925
+ "columnType": "UUID",
7926
+ "description": "The person who owns this account and decides who else may use it."
7927
+ },
7928
+ {
7929
+ "name": "label",
7930
+ "type": "text",
7931
+ "required": false,
7932
+ "columnType": "TEXT",
7933
+ "description": "A short name shown beside this account, such as Support or Personal."
7934
+ },
7935
+ {
7936
+ "name": "connectionStatus",
7937
+ "type": "text",
7938
+ "required": false,
7939
+ "columnType": "TEXT",
7940
+ "description": "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."
7941
+ },
7942
+ {
7943
+ "name": "statusMessage",
7944
+ "type": "text",
7945
+ "required": false,
7946
+ "columnType": "TEXT",
7947
+ "description": "Why the account needs attention, in plain words."
7948
+ },
7510
7949
  {
7511
7950
  "name": "lastSyncAt",
7512
7951
  "type": "datetime",
@@ -7557,7 +7996,15 @@
7557
7996
  "description": "The bot user your application posts as in this workspace."
7558
7997
  }
7559
7998
  ],
7560
- "relationships": [],
7999
+ "relationships": [
8000
+ {
8001
+ "name": "ownerUserId",
8002
+ "type": "crossPackageRef",
8003
+ "required": false,
8004
+ "related": "@happyvertical/smrt-users:User",
8005
+ "columnType": "UUID"
8006
+ }
8007
+ ],
7561
8008
  "methods": [
7562
8009
  "activate",
7563
8010
  "createSender",
@@ -7565,6 +8012,9 @@
7565
8012
  "getConfiguration",
7566
8013
  "getCredentials",
7567
8014
  "getSettings",
8015
+ "markConnected",
8016
+ "markNeedsReconnect",
8017
+ "removeCredentials",
7568
8018
  "setConfiguration",
7569
8019
  "setCredentials",
7570
8020
  "setSettings"
@@ -7598,6 +8048,24 @@
7598
8048
  "name": "getSettings",
7599
8049
  "returns": "Record<string, unknown>"
7600
8050
  },
8051
+ {
8052
+ "name": "markConnected",
8053
+ "async": true,
8054
+ "returns": "Promise<void>"
8055
+ },
8056
+ {
8057
+ "name": "markNeedsReconnect",
8058
+ "async": true,
8059
+ "params": [
8060
+ "reason: string"
8061
+ ],
8062
+ "returns": "Promise<void>"
8063
+ },
8064
+ {
8065
+ "name": "removeCredentials",
8066
+ "async": true,
8067
+ "returns": "Promise<void>"
8068
+ },
7601
8069
  {
7602
8070
  "name": "setConfiguration",
7603
8071
  "params": [
@@ -7663,47 +8131,68 @@
7663
8131
  "name": "slackaccount_get",
7664
8132
  "operation": "get",
7665
8133
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
7666
- }
7667
- ],
7668
- "withheldSurfaces": [
8134
+ }
8135
+ ],
8136
+ "withheldSurfaces": [
8137
+ {
8138
+ "kind": "api",
8139
+ "operation": "activate",
8140
+ "code": "not-included",
8141
+ "reason": "not listed in api.include",
8142
+ "objectName": "@happyvertical/smrt-messages:SlackAccount"
8143
+ },
8144
+ {
8145
+ "kind": "api",
8146
+ "operation": "createSender",
8147
+ "code": "not-included",
8148
+ "reason": "not listed in api.include",
8149
+ "objectName": "@happyvertical/smrt-messages:SlackAccount"
8150
+ },
8151
+ {
8152
+ "kind": "api",
8153
+ "operation": "deactivate",
8154
+ "code": "not-included",
8155
+ "reason": "not listed in api.include",
8156
+ "objectName": "@happyvertical/smrt-messages:SlackAccount"
8157
+ },
7669
8158
  {
7670
8159
  "kind": "api",
7671
- "operation": "activate",
8160
+ "operation": "getConfiguration",
7672
8161
  "code": "not-included",
7673
8162
  "reason": "not listed in api.include",
7674
8163
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
7675
8164
  },
7676
8165
  {
7677
8166
  "kind": "api",
7678
- "operation": "createSender",
8167
+ "operation": "getCredentials",
7679
8168
  "code": "not-included",
7680
8169
  "reason": "not listed in api.include",
7681
8170
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
7682
8171
  },
7683
8172
  {
7684
8173
  "kind": "api",
7685
- "operation": "deactivate",
8174
+ "operation": "getSettings",
7686
8175
  "code": "not-included",
7687
8176
  "reason": "not listed in api.include",
7688
8177
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
7689
8178
  },
7690
8179
  {
7691
8180
  "kind": "api",
7692
- "operation": "getConfiguration",
8181
+ "operation": "markConnected",
7693
8182
  "code": "not-included",
7694
8183
  "reason": "not listed in api.include",
7695
8184
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
7696
8185
  },
7697
8186
  {
7698
8187
  "kind": "api",
7699
- "operation": "getCredentials",
8188
+ "operation": "markNeedsReconnect",
7700
8189
  "code": "not-included",
7701
8190
  "reason": "not listed in api.include",
7702
8191
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
7703
8192
  },
7704
8193
  {
7705
8194
  "kind": "api",
7706
- "operation": "getSettings",
8195
+ "operation": "removeCredentials",
7707
8196
  "code": "not-included",
7708
8197
  "reason": "not listed in api.include",
7709
8198
  "objectName": "@happyvertical/smrt-messages:SlackAccount"
@@ -7731,6 +8220,7 @@
7731
8220
  }
7732
8221
  ],
7733
8222
  "relationshipFeatures": [
8223
+ "crossPackageRef",
7734
8224
  "uuidColumns"
7735
8225
  ],
7736
8226
  "tags": [],
@@ -8054,6 +8544,8 @@
8054
8544
  "isInThread",
8055
8545
  "isSendOutcomeUnknown",
8056
8546
  "isUnread",
8547
+ "loadFromId",
8548
+ "loadFromSlug",
8057
8549
  "markRead",
8058
8550
  "markUnread",
8059
8551
  "retrySend",
@@ -8150,6 +8642,16 @@
8150
8642
  "name": "isUnread",
8151
8643
  "returns": "boolean"
8152
8644
  },
8645
+ {
8646
+ "name": "loadFromId",
8647
+ "async": true,
8648
+ "returns": "any"
8649
+ },
8650
+ {
8651
+ "name": "loadFromSlug",
8652
+ "async": true,
8653
+ "returns": "any"
8654
+ },
8153
8655
  {
8154
8656
  "name": "markRead",
8155
8657
  "async": true,
@@ -8524,6 +9026,20 @@
8524
9026
  "reason": "not listed in api.include",
8525
9027
  "objectName": "@happyvertical/smrt-messages:SlackMessage"
8526
9028
  },
9029
+ {
9030
+ "kind": "api",
9031
+ "operation": "loadFromId",
9032
+ "code": "lifecycle-method",
9033
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
9034
+ "objectName": "@happyvertical/smrt-messages:SlackMessage"
9035
+ },
9036
+ {
9037
+ "kind": "api",
9038
+ "operation": "loadFromSlug",
9039
+ "code": "lifecycle-method",
9040
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
9041
+ "objectName": "@happyvertical/smrt-messages:SlackMessage"
9042
+ },
8527
9043
  {
8528
9044
  "kind": "api",
8529
9045
  "operation": "markRead",
@@ -8645,6 +9161,35 @@
8645
9161
  "default": true,
8646
9162
  "description": "Whether this account is enabled for messaging."
8647
9163
  },
9164
+ {
9165
+ "name": "ownerUserId",
9166
+ "type": "crossPackageRef",
9167
+ "required": false,
9168
+ "related": "@happyvertical/smrt-users:User",
9169
+ "columnType": "UUID",
9170
+ "description": "The person who owns this account and decides who else may use it."
9171
+ },
9172
+ {
9173
+ "name": "label",
9174
+ "type": "text",
9175
+ "required": false,
9176
+ "columnType": "TEXT",
9177
+ "description": "A short name shown beside this account, such as Support or Personal."
9178
+ },
9179
+ {
9180
+ "name": "connectionStatus",
9181
+ "type": "text",
9182
+ "required": false,
9183
+ "columnType": "TEXT",
9184
+ "description": "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."
9185
+ },
9186
+ {
9187
+ "name": "statusMessage",
9188
+ "type": "text",
9189
+ "required": false,
9190
+ "columnType": "TEXT",
9191
+ "description": "Why the account needs attention, in plain words."
9192
+ },
8648
9193
  {
8649
9194
  "name": "lastSyncAt",
8650
9195
  "type": "datetime",
@@ -8674,7 +9219,15 @@
8674
9219
  "description": "When this account was last changed."
8675
9220
  }
8676
9221
  ],
8677
- "relationships": [],
9222
+ "relationships": [
9223
+ {
9224
+ "name": "ownerUserId",
9225
+ "type": "crossPackageRef",
9226
+ "required": false,
9227
+ "related": "@happyvertical/smrt-users:User",
9228
+ "columnType": "UUID"
9229
+ }
9230
+ ],
8678
9231
  "methods": [
8679
9232
  "activate",
8680
9233
  "createSender",
@@ -8682,6 +9235,9 @@
8682
9235
  "getConfiguration",
8683
9236
  "getCredentials",
8684
9237
  "getSettings",
9238
+ "markConnected",
9239
+ "markNeedsReconnect",
9240
+ "removeCredentials",
8685
9241
  "setConfiguration",
8686
9242
  "setCredentials",
8687
9243
  "setSettings"
@@ -8715,6 +9271,24 @@
8715
9271
  "name": "getSettings",
8716
9272
  "returns": "Record<string, unknown>"
8717
9273
  },
9274
+ {
9275
+ "name": "markConnected",
9276
+ "async": true,
9277
+ "returns": "Promise<void>"
9278
+ },
9279
+ {
9280
+ "name": "markNeedsReconnect",
9281
+ "async": true,
9282
+ "params": [
9283
+ "reason: string"
9284
+ ],
9285
+ "returns": "Promise<void>"
9286
+ },
9287
+ {
9288
+ "name": "removeCredentials",
9289
+ "async": true,
9290
+ "returns": "Promise<void>"
9291
+ },
8718
9292
  {
8719
9293
  "name": "setConfiguration",
8720
9294
  "params": [
@@ -8825,6 +9399,27 @@
8825
9399
  "reason": "not listed in api.include",
8826
9400
  "objectName": "@happyvertical/smrt-messages:TelegramAccount"
8827
9401
  },
9402
+ {
9403
+ "kind": "api",
9404
+ "operation": "markConnected",
9405
+ "code": "not-included",
9406
+ "reason": "not listed in api.include",
9407
+ "objectName": "@happyvertical/smrt-messages:TelegramAccount"
9408
+ },
9409
+ {
9410
+ "kind": "api",
9411
+ "operation": "markNeedsReconnect",
9412
+ "code": "not-included",
9413
+ "reason": "not listed in api.include",
9414
+ "objectName": "@happyvertical/smrt-messages:TelegramAccount"
9415
+ },
9416
+ {
9417
+ "kind": "api",
9418
+ "operation": "removeCredentials",
9419
+ "code": "not-included",
9420
+ "reason": "not listed in api.include",
9421
+ "objectName": "@happyvertical/smrt-messages:TelegramAccount"
9422
+ },
8828
9423
  {
8829
9424
  "kind": "api",
8830
9425
  "operation": "setConfiguration",
@@ -8848,6 +9443,7 @@
8848
9443
  }
8849
9444
  ],
8850
9445
  "relationshipFeatures": [
9446
+ "crossPackageRef",
8851
9447
  "uuidColumns"
8852
9448
  ],
8853
9449
  "tags": [],
@@ -9173,6 +9769,8 @@
9173
9769
  "getToAddresses",
9174
9770
  "isSendOutcomeUnknown",
9175
9771
  "isUnread",
9772
+ "loadFromId",
9773
+ "loadFromSlug",
9176
9774
  "markRead",
9177
9775
  "markUnread",
9178
9776
  "retrySend",
@@ -9269,6 +9867,16 @@
9269
9867
  "name": "isUnread",
9270
9868
  "returns": "boolean"
9271
9869
  },
9870
+ {
9871
+ "name": "loadFromId",
9872
+ "async": true,
9873
+ "returns": "any"
9874
+ },
9875
+ {
9876
+ "name": "loadFromSlug",
9877
+ "async": true,
9878
+ "returns": "any"
9879
+ },
9272
9880
  {
9273
9881
  "name": "markRead",
9274
9882
  "async": true,
@@ -9643,6 +10251,20 @@
9643
10251
  "reason": "not listed in api.include",
9644
10252
  "objectName": "@happyvertical/smrt-messages:Tweet"
9645
10253
  },
10254
+ {
10255
+ "kind": "api",
10256
+ "operation": "loadFromId",
10257
+ "code": "lifecycle-method",
10258
+ "reason": "`loadFromId` is a framework lifecycle method, not a distinct operation",
10259
+ "objectName": "@happyvertical/smrt-messages:Tweet"
10260
+ },
10261
+ {
10262
+ "kind": "api",
10263
+ "operation": "loadFromSlug",
10264
+ "code": "lifecycle-method",
10265
+ "reason": "`loadFromSlug` is a framework lifecycle method, not a distinct operation",
10266
+ "objectName": "@happyvertical/smrt-messages:Tweet"
10267
+ },
9646
10268
  {
9647
10269
  "kind": "api",
9648
10270
  "operation": "markRead",
@@ -9764,6 +10386,35 @@
9764
10386
  "default": true,
9765
10387
  "description": "Whether this account is enabled for messaging."
9766
10388
  },
10389
+ {
10390
+ "name": "ownerUserId",
10391
+ "type": "crossPackageRef",
10392
+ "required": false,
10393
+ "related": "@happyvertical/smrt-users:User",
10394
+ "columnType": "UUID",
10395
+ "description": "The person who owns this account and decides who else may use it."
10396
+ },
10397
+ {
10398
+ "name": "label",
10399
+ "type": "text",
10400
+ "required": false,
10401
+ "columnType": "TEXT",
10402
+ "description": "A short name shown beside this account, such as Support or Personal."
10403
+ },
10404
+ {
10405
+ "name": "connectionStatus",
10406
+ "type": "text",
10407
+ "required": false,
10408
+ "columnType": "TEXT",
10409
+ "description": "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."
10410
+ },
10411
+ {
10412
+ "name": "statusMessage",
10413
+ "type": "text",
10414
+ "required": false,
10415
+ "columnType": "TEXT",
10416
+ "description": "Why the account needs attention, in plain words."
10417
+ },
9767
10418
  {
9768
10419
  "name": "lastSyncAt",
9769
10420
  "type": "datetime",
@@ -9805,7 +10456,15 @@
9805
10456
  "columnType": "TEXT"
9806
10457
  }
9807
10458
  ],
9808
- "relationships": [],
10459
+ "relationships": [
10460
+ {
10461
+ "name": "ownerUserId",
10462
+ "type": "crossPackageRef",
10463
+ "required": false,
10464
+ "related": "@happyvertical/smrt-users:User",
10465
+ "columnType": "UUID"
10466
+ }
10467
+ ],
9809
10468
  "methods": [
9810
10469
  "activate",
9811
10470
  "createSender",
@@ -9813,6 +10472,9 @@
9813
10472
  "getConfiguration",
9814
10473
  "getCredentials",
9815
10474
  "getSettings",
10475
+ "markConnected",
10476
+ "markNeedsReconnect",
10477
+ "removeCredentials",
9816
10478
  "setConfiguration",
9817
10479
  "setCredentials",
9818
10480
  "setSettings"
@@ -9846,6 +10508,24 @@
9846
10508
  "name": "getSettings",
9847
10509
  "returns": "Record<string, unknown>"
9848
10510
  },
10511
+ {
10512
+ "name": "markConnected",
10513
+ "async": true,
10514
+ "returns": "Promise<void>"
10515
+ },
10516
+ {
10517
+ "name": "markNeedsReconnect",
10518
+ "async": true,
10519
+ "params": [
10520
+ "reason: string"
10521
+ ],
10522
+ "returns": "Promise<void>"
10523
+ },
10524
+ {
10525
+ "name": "removeCredentials",
10526
+ "async": true,
10527
+ "returns": "Promise<void>"
10528
+ },
9849
10529
  {
9850
10530
  "name": "setConfiguration",
9851
10531
  "params": [
@@ -9956,6 +10636,27 @@
9956
10636
  "reason": "not listed in api.include",
9957
10637
  "objectName": "@happyvertical/smrt-messages:TwitterAccount"
9958
10638
  },
10639
+ {
10640
+ "kind": "api",
10641
+ "operation": "markConnected",
10642
+ "code": "not-included",
10643
+ "reason": "not listed in api.include",
10644
+ "objectName": "@happyvertical/smrt-messages:TwitterAccount"
10645
+ },
10646
+ {
10647
+ "kind": "api",
10648
+ "operation": "markNeedsReconnect",
10649
+ "code": "not-included",
10650
+ "reason": "not listed in api.include",
10651
+ "objectName": "@happyvertical/smrt-messages:TwitterAccount"
10652
+ },
10653
+ {
10654
+ "kind": "api",
10655
+ "operation": "removeCredentials",
10656
+ "code": "not-included",
10657
+ "reason": "not listed in api.include",
10658
+ "objectName": "@happyvertical/smrt-messages:TwitterAccount"
10659
+ },
9959
10660
  {
9960
10661
  "kind": "api",
9961
10662
  "operation": "setConfiguration",
@@ -9979,6 +10680,7 @@
9979
10680
  }
9980
10681
  ],
9981
10682
  "relationshipFeatures": [
10683
+ "crossPackageRef",
9982
10684
  "uuidColumns"
9983
10685
  ],
9984
10686
  "tags": [],
@@ -10342,6 +11044,35 @@
10342
11044
  "default": true,
10343
11045
  "description": "Whether this account is enabled for messaging."
10344
11046
  },
11047
+ {
11048
+ "name": "ownerUserId",
11049
+ "type": "crossPackageRef",
11050
+ "required": false,
11051
+ "related": "@happyvertical/smrt-users:User",
11052
+ "columnType": "UUID",
11053
+ "description": "The person who owns this account and decides who else may use it."
11054
+ },
11055
+ {
11056
+ "name": "label",
11057
+ "type": "text",
11058
+ "required": false,
11059
+ "columnType": "TEXT",
11060
+ "description": "A short name shown beside this account, such as Support or Personal."
11061
+ },
11062
+ {
11063
+ "name": "connectionStatus",
11064
+ "type": "text",
11065
+ "required": false,
11066
+ "columnType": "TEXT",
11067
+ "description": "Whether the saved sign-in still works: connected, or needs_reconnect after the server refused it."
11068
+ },
11069
+ {
11070
+ "name": "statusMessage",
11071
+ "type": "text",
11072
+ "required": false,
11073
+ "columnType": "TEXT",
11074
+ "description": "Why the account needs attention, in plain words."
11075
+ },
10345
11076
  {
10346
11077
  "name": "lastSyncAt",
10347
11078
  "type": "datetime",
@@ -10371,7 +11102,15 @@
10371
11102
  "description": "When this account was last changed."
10372
11103
  }
10373
11104
  ],
10374
- "relationships": [],
11105
+ "relationships": [
11106
+ {
11107
+ "name": "ownerUserId",
11108
+ "type": "crossPackageRef",
11109
+ "required": false,
11110
+ "related": "@happyvertical/smrt-users:User",
11111
+ "columnType": "UUID"
11112
+ }
11113
+ ],
10375
11114
  "methods": [
10376
11115
  "activate",
10377
11116
  "createSender",
@@ -10379,6 +11118,9 @@
10379
11118
  "getConfiguration",
10380
11119
  "getCredentials",
10381
11120
  "getSettings",
11121
+ "markConnected",
11122
+ "markNeedsReconnect",
11123
+ "removeCredentials",
10382
11124
  "setConfiguration",
10383
11125
  "setCredentials",
10384
11126
  "setSettings"
@@ -10412,6 +11154,24 @@
10412
11154
  "name": "getSettings",
10413
11155
  "returns": "Record<string, unknown>"
10414
11156
  },
11157
+ {
11158
+ "name": "markConnected",
11159
+ "async": true,
11160
+ "returns": "Promise<void>"
11161
+ },
11162
+ {
11163
+ "name": "markNeedsReconnect",
11164
+ "async": true,
11165
+ "params": [
11166
+ "reason: string"
11167
+ ],
11168
+ "returns": "Promise<void>"
11169
+ },
11170
+ {
11171
+ "name": "removeCredentials",
11172
+ "async": true,
11173
+ "returns": "Promise<void>"
11174
+ },
10415
11175
  {
10416
11176
  "name": "setConfiguration",
10417
11177
  "params": [
@@ -10522,6 +11282,27 @@
10522
11282
  "reason": "not listed in api.include",
10523
11283
  "objectName": "@happyvertical/smrt-messages:ZulipAccount"
10524
11284
  },
11285
+ {
11286
+ "kind": "api",
11287
+ "operation": "markConnected",
11288
+ "code": "not-included",
11289
+ "reason": "not listed in api.include",
11290
+ "objectName": "@happyvertical/smrt-messages:ZulipAccount"
11291
+ },
11292
+ {
11293
+ "kind": "api",
11294
+ "operation": "markNeedsReconnect",
11295
+ "code": "not-included",
11296
+ "reason": "not listed in api.include",
11297
+ "objectName": "@happyvertical/smrt-messages:ZulipAccount"
11298
+ },
11299
+ {
11300
+ "kind": "api",
11301
+ "operation": "removeCredentials",
11302
+ "code": "not-included",
11303
+ "reason": "not listed in api.include",
11304
+ "objectName": "@happyvertical/smrt-messages:ZulipAccount"
11305
+ },
10525
11306
  {
10526
11307
  "kind": "api",
10527
11308
  "operation": "setConfiguration",
@@ -10545,6 +11326,7 @@
10545
11326
  }
10546
11327
  ],
10547
11328
  "relationshipFeatures": [
11329
+ "crossPackageRef",
10548
11330
  "uuidColumns"
10549
11331
  ],
10550
11332
  "tags": [],
@@ -10552,6 +11334,12 @@
10552
11334
  }
10553
11335
  ],
10554
11336
  "surfaces": [
11337
+ {
11338
+ "kind": "cli",
11339
+ "name": "attachmentcollection_backfillAccountIds",
11340
+ "operation": "backfillAccountIds",
11341
+ "objectName": "@happyvertical/smrt-messages:AttachmentCollection"
11342
+ },
10555
11343
  {
10556
11344
  "kind": "cli",
10557
11345
  "name": "attachmentcollection_getByMessage",
@@ -10672,6 +11460,12 @@
10672
11460
  "operation": "getMatchingEntry",
10673
11461
  "objectName": "@happyvertical/smrt-messages:BlacklistCollection"
10674
11462
  },
11463
+ {
11464
+ "kind": "cli",
11465
+ "name": "emailattachmentcollection_backfillAccountIds",
11466
+ "operation": "backfillAccountIds",
11467
+ "objectName": "@happyvertical/smrt-messages:EmailAttachmentCollection"
11468
+ },
10675
11469
  {
10676
11470
  "kind": "cli",
10677
11471
  "name": "emailattachmentcollection_getByMessage",
@@ -12981,14 +13775,14 @@
12981
13775
  ],
12982
13776
  "prompts": [],
12983
13777
  "relationshipsV2": {
12984
- "foreignKeyFields": 19,
12985
- "crossPackageRefFields": 10,
13778
+ "foreignKeyFields": 21,
13779
+ "crossPackageRefFields": 16,
12986
13780
  "junctionCollections": 0,
12987
13781
  "hierarchicalObjects": 0,
12988
13782
  "polymorphicAssociations": 0,
12989
- "uuidColumns": 118
13783
+ "uuidColumns": 130
12990
13784
  },
12991
- "agentDoc": "# @happyvertical/smrt-messages\n\nMulti-channel messaging with STI hierarchies for both messages and accounts. Credential encryption via smrt-secrets.\n\n## STI Hierarchies\n\n**Messages** (share `messages` table):\n- `Message` (base): accountId, personaId, endpointId, correlationId, threadId, subject, body, fromAddress, toAddresses (JSON), sendStatus (draft/sending/sent/failed), retryCount\n- `Email`: messageId (RFC 822), inReplyTo, ccAddresses, bccAddresses, htmlBody, textBody, folderId, labels, headers\n- `Tweet`: tweetId, retweetCount, likeCount, mediaUrls, hashtags, mentions\n- `SlackMessage`: channelId, slackTs, slackThreadTs, reactions, blocks\n\n**Accounts** (share `accounts` table):\n- `Account` (base): channelType, providerType, public configuration,\n credentialSecretId, isActive, lastSyncAt, deprecated sensitive settings\n- `EmailAccount`, `TwitterAccount`, `SlackAccount`, `ZulipAccount`,\n `TelegramAccount`: provider-specific identity/sender behavior\n\n## Persona messaging\n\n- `MessagingEndpoint`: tenant-owned, write-only destination JSON with masked\n display helper.\n- `PersonaMessageRoute`: persona → account + endpoint, selected by purpose and\n descending priority.\n- `PersonaMessagingService`: persists and sends through an enabled route.\n- Provider registry: public setup descriptors + optional sender factory. Keep\n channel (`sms`) separate from provider (`twilio`).\n- Permissions: `messages.send`, `messages.manage-routes`,\n `messages.manage-credentials`.\n- `MessagingSettingsService` is the permissioned server boundary;\n its host-supplied `resolvePersonaTenantId` proves cross-package ownership.\n `MessagingSettingsPanel` is the callback-driven Svelte surface.\n- Account, endpoint, and route generated surfaces are read-only. Do not add\n generated mutations around the settings service or make secret fields writable.\n- **Recipe `messages.slack`** (`src/recipes.ts`, help in `src/help/slack.md`): lists Slack messages and workspaces beside the Mailbox and Notifications recipes; workspaces stay read-only and sending goes through the senders, not generated routes. Fields it shows carry `@field({ description })` in plain words; keep them when editing the models.\n\n## In-app notifications (`UserNotification`)\n\nThe in-app channel: one stored row per person, with read state.\n`user_notifications`: `tenantId` (required), `recipientUserId`\n(`@crossPackageRef` smrt-users:User, uuid), `kind`, `title`, `body`, `href`,\n`severity` (info/success/warning/error), `sourceRef`, `occurredAt`, `readAt`,\n`dismissedAt`. Conflict identity `(tenant_id, recipient_user_id, source_ref)`.\n\n- `UserNotificationService` is the only access path: `notify()` /\n `notifyMany()` (dedupe on `sourceRef`, existing row returned untouched;\n a unique ref is generated when omitted), `listForUser()` / `countUnread()`\n across explicit `tenantIds` (each read under `withTenant`), `markRead()`,\n `dismiss()` (also marks read), `markAllRead()`. Every write filters on the\n recipient, so another user's id matches nothing.\n- Generated REST/MCP/CLI are off (`api`/`mcp`/`cli: false`): a tenant-scoped\n list would expose every member's rows. Hosts expose their own routes that\n pass the signed-in user's id, never a request-chosen one.\n- Hosts decide who is told (e.g. `SocialPost.createdByUserId` for a failed\n post). New table: consumers run `db:migrate`.\n\n## Notification email outbox (`NotificationDelivery`)\n\n`NotificationOutboxService` is the external-channel counterpart of\n`UserNotificationService`: `enqueueEmail()` stores one delivery per\n`(tenant, recipient, channel, sourceRef)` after the host resolves the\nrecipient address and same-tenant sender account (callers never choose an\naddress); `dispatchDue()` leases due rows by compare-and-set\n(`NotificationDelivery.transition()`), creates the single outbound `Email`\nunder the lease, and settles sent/retry/failed/uncertain. Never resend an\n`uncertain` row automatically. Contract, retry, and reconciliation policy:\n[agents/notification-outbox.md](agents/notification-outbox.md). New table:\nconsumers run `db:migrate`.\n\n`NotificationOptOut` (`notification_opt_outs`, tenant-required, generated\nsurfaces off) is the per-recipient opt-out ledger for the outbox's\n`isSuppressed` hook, keyed `(tenant, recipient, channel, scope)` with scope `*`\nor `project:<uuid>`-style keys. `NotificationOptOutService`: idempotent\n`optOut`/`optIn` (with a `principal` only `userId === recipientUserId` may\nchange a row, and only in the principal's own `tenantId`, else\n`NotificationOptOutDeniedError`; no principal = trusted host code), trusted `isOptedOut` (a `*` row matches every scope), `listForRecipient`\n(principal required). `optOutSuppression(service, scopeOf)` builds the\n`isSuppressed` function. Details in the outbox doc; consumers run `db:migrate`.\n\n## Credential Security\n\nAccount credentials stored via tenant-bound `credentialSecretId` →\nsmrt-secrets. Use `setCredentials()`/`getCredentials()` — never store passwords\ndirectly. Credential descriptor schemas contain field definitions, never values.\n\n## Send Lifecycle\n\n`message.send()`: resolves account → creates provider sender → updates sendStatus. Retry support with `maxRetries` budget.\nA failure the provider may still have accepted carries\n`MessageSendResult.outcomeUnknown` (set by `EmailSender` unless\n`isDefiniteSendRejection()` proves a refusal, and when a sender throws) and is\npersisted as `metadata.sendOutcomeUnknown`; never auto-resend it.\n`EmailSender` attaches the message's stored `Attachment` rows (read through\n`Attachment.readContent()`, under the message's tenant context) plus\n`SendEmailOptions.attachments` bytes; an unreadable or file-less row fails the\nsend with the error on `sendError`, never a silent drop (#3808).\n`PersonaMessagingService.send({ attachments })` accepts them on email routes only.\n\n## Provider entry points (bundle boundary, #1979)\n\nThe package root is provider-neutral: models, collections, services,\npermissions, and the provider registry carry **zero provider-SDK weight**.\nProvider SDK wrappers (`@happyvertical/email`, `@happyvertical/messages`) are\nreachable only through explicit entry points, imported once at server startup:\n\n```ts\nimport '@happyvertical/smrt-messages/providers/email'; // smtp/imap/pop3/gmail\nimport '@happyvertical/smrt-messages/providers/slack';\nimport '@happyvertical/smrt-messages/providers/twitter';\nimport '@happyvertical/smrt-messages/providers/all'; // all of the above\n```\n\n- Without the matching entry, `EmailAccount.createClient()` (send + mailbox\n sync) throws an actionable error and `SlackSender`/`TweetSender` return a\n failure result naming the entry to import. Telegram and Zulip are\n fetch-based and always work from the root.\n- Builtin registry definitions stay metadata-only (setup fields for UIs); the\n entries upgrade them with `createEmailClient`/`createMessageClient`/\n `createSender` hooks. Never import a provider SDK from any module reachable\n from `src/index.ts` — the consumer bundle gate (`packages/bundle-gate`)\n fails CI when one becomes reachable.\n- `Attachment.readContent()` loads `@happyvertical/files` through core's\n `importOptionalDependency` boundary and keeps its null-on-failure contract\n in builds where the SDK is absent.\n\n## Gotchas\n\n- **Manifest before decorators**: every decorated model imports\n `../__smrt-register__.js`, and `package.json#sideEffects` lists\n `./src/__smrt-register__.ts`. Without both, the library build dropped or\n reordered the self-registration, so dist classes registered with only their\n decorated fields and could adopt smrt-ledgers' same-named `Account` (#3098).\n- **`Account` is not unique**: smrt-ledgers also declares `Account` (on\n `ledger_accounts`). Resolve by constructor or qualified name; the\n coexistence tests (`ledger-account-identity-*`, and the PostgreSQL lane\n `pnpm test:postgres`) load both packages in both orders.\n Both declare the `accounts` collection, so registering the ledgers `Account`\n auto-loads this family from its manifest as STI siblings. Core loads this\n base with them and never takes the ledgers `Account` for it (#4735,\n `ledger-account-identity-sti-siblings.test.ts`).\n- **STI `_meta_type`**: qualified format `@happyvertical/smrt-messages:Email`\n- **JSON fields**: all address/metadata fields are JSON strings with `getX()`/`setX()` helpers\n- **RFC 822 threading**: Email uses `inReplyTo`/`messageId`/`references` — manual management required\n- **Attachment.messageId**: use this field (not `emailId`); old getter/setter mapped via deprecation wrapper\n- **Optional tenancy**: `@TenantScoped({ mode: 'optional' })` on Message, Account, Attachment\n- **Required tenancy**: endpoints and persona routes are always tenant scoped\n- **Secrets are write-only**: never serialize credentials or endpoint.address to an app\n\n## Intake byte snapshots\n\n`EmailAccount.readIntakeMessage(providerLookup, maxBytes, imapIdentity?)` is the authorized host seam for\nopt-in ingestion. It copies full-message attachment bytes from the registered\nemail provider and fails when only attachment metadata is available; it never\nreads provider-supplied paths or advances sync checkpoints. Keep this path\nprovider-neutral and exclude arbitrary headers/credentials from its snapshot.\nIMAP lookup must include folder/UIDVALIDITY/UID verification; sender Message-ID\nis a lookup hint, never the durable delivery identity.\n\nProtected notification Emails carry durable delivery provenance. Their canonical\n`send`/`retrySend`, ordinary save/delete, and default EmailSender handoff are\nconstrained by `protected-notification-handoff.ts` (package-private, never a root\nexport). Only the outbox enters its exact one-use scope after current trusted\npolicy/byte validation. Preserve old-row/constructor identity checks, current\npersisted lease checks at the actual provider boundary, copied byte buffers and\nunknown-outcome marker protection. See the outbox contract and shared protected\nhandoff suite (SQLite and migrated PostgreSQL).\n\n## Protected external contacts\n\nProfile email uses exclusive `recipientProfileId` plus `resolveProfileRecipient`, a reserved `profileNotificationPolicy` and exact current tenant-owned public Profile email. No User account is required. Before activating profiles, run normal framework schema migration and public `planNotificationProfileRecipients` / `migrateNotificationProfileRecipients`; runtime verifies physical constraints and never applies DDL. Legacy User notification and opt-out paths remain User-only. See [profile recipient contract and matrix](agents/profile-recipients.md).\n",
13785
+ "agentDoc": "# @happyvertical/smrt-messages\n\nMulti-channel messaging with STI hierarchies for both messages and accounts. Credential encryption via smrt-secrets.\n\n## STI Hierarchies\n\n**Messages** (share `messages` table):\n- `Message` (base): accountId, personaId, endpointId, correlationId, threadId, subject, body, fromAddress, toAddresses (JSON), sendStatus (draft/sending/sent/failed), retryCount\n- `Email`: messageId (RFC 822), inReplyTo, ccAddresses, bccAddresses, htmlBody, textBody, folderId, labels, headers\n- `Tweet`: tweetId, retweetCount, likeCount, mediaUrls, hashtags, mentions\n- `SlackMessage`: channelId, slackTs, slackThreadTs, reactions, blocks\n\n**Accounts** (share `accounts` table):\n- `Account` (base): channelType, providerType, public configuration,\n credentialSecretId, isActive, lastSyncAt, deprecated sensitive settings\n- `EmailAccount`, `TwitterAccount`, `SlackAccount`, `ZulipAccount`,\n `TelegramAccount`: provider-specific identity/sender behavior\n\n## Persona messaging\n\n- `MessagingEndpoint`: tenant-owned, write-only destination JSON with masked\n display helper.\n- `PersonaMessageRoute`: persona → account + endpoint, selected by purpose and\n descending priority.\n- `PersonaMessagingService`: persists and sends through an enabled route.\n- Provider registry: public setup descriptors + optional sender factory. Keep\n channel (`sms`) separate from provider (`twilio`).\n- Permissions: `messages.send`, `messages.manage-routes`,\n `messages.manage-credentials`.\n- `MessagingSettingsService` is the permissioned server boundary;\n its host-supplied `resolvePersonaTenantId` proves cross-package ownership.\n `MessagingSettingsPanel` is the callback-driven Svelte surface.\n- Account, endpoint, and route generated surfaces are read-only. Do not add\n generated mutations around the settings service or make secret fields writable.\n- **Recipe `messages.slack`** (`src/recipes.ts`, help in `src/help/slack.md`): lists Slack messages and workspaces beside the Mailbox and Notifications recipes; workspaces stay read-only and sending goes through the senders, not generated routes. Fields it shows carry `@field({ description })` in plain words; keep them when editing the models.\n\n## Per-account mail access (owner + grants)\n\nOptional by default: `Account.ownerUserId` is nullable, and an account without\nan owner stays tenant-wide. Apps that want private or shared mailboxes set\nowners and call `configureMailAccess({ options, resolvePrincipal })` at startup\n(`access.ts`); smrt never knows the host's credential model, the host returns a\n`MailPrincipal` (`userId` + tenant, optional `scopes` / `accountIds` ceilings).\n\n- Scopes `read`, `triage`, `draft`, `send` are `ResourceGrant` rows (resource\n type `messages:account`, permission `messages.<scope>`) checked by\n `checkResourceOperationPermission`, so the grantee also needs the tenant\n `messages.<scope>` permission (the ceiling). The owner holds every scope\n implicitly. Agents are `User` rows the host maps its credential to; the\n principal ceilings are intersected with the grant, never added to it.\n- `access-enforcement.ts` is a `GlobalInterceptors` entry registered at package\n load. Emails, folders and attachments (matched by STI ancestry) are filtered\n in `beforeList`/`afterList`/`afterGet`; raw `query()` on them is refused while\n any account is closed to the principal. Fail closed: no principal, no\n resolver or a foreign tenant means owned accounts are invisible. No tenant\n admin or super-admin bypass; trusted work (sync, outbox) uses\n `runWithMailSystemAccess()`. `EmailAccount.syncFrom()` does so itself.\n- Attachments carry a denormalized `accountId` (always derived from the message in a\n `beforeSave` interceptor, never caller-supplied) so lists, projections and counts filter in SQL; run\n `AttachmentCollection.backfillAccountIds()` once after upgrading (legacy rows\n without it are hidden from every read until then).\n- `connectMailbox` refuses by default: give the service `allowedMailHosts`\n (and optionally `allowedMailPorts`) or your own `validateMailbox`. The\n built-in validator never connects to private, loopback or link-local\n addresses and returns only a generic error. Policy lookups use the\n configured db handle, not a caller's transaction.\n- `Message.send()` needs the `send` scope on an owned account. Account rows are\n not filtered (senders, routes and the outbox read them without a principal).\n- `MailAccessService` (`grant`, `revoke`, `list`, `setOwner`) needs tenant\n `messages.manage-access` AND ownership (or delegation); an administrator\n cannot read, self-grant or take over an owned mailbox. Unowned accounts can be\n claimed once with `messages.manage-credentials`.\n- Before `configureMailAccess` is called the policy still fails closed on\n owned accounts: every collection operation on a mail class (the core `onCollectionReady`\n interceptor hook, so STI subclasses on a default collection are covered) registers its\n database, per database, and the policy hides every owned account's mail\n through list, count, projections, facets and raw queries; it learns the database from the first mail or account row it\n sees and, with no principal resolver, hides every owned account's mail.\n Direct hydration (`new Email({ id }).initialize()`, `loadRelated()`) is gated\n in the models' `loadFromId`/`loadFromSlug`.\n- `connectionStatus` (`connected` / `needs_reconnect`) and `statusMessage` mark\n an account whose sign-in the server refused; `syncFrom()` sets it.\n\n## Mailbox connect (provider-neutral)\n\nCredentials reach smrt-secrets in two ways; neither writes the plaintext `settings` fallback.\n\n- **Write-only app password**: `MessagingSettingsService.connectMailbox()`\n (permission `messages.manage-credentials`). The candidate credential is\n validated by opening a session first (`validateMailbox` option, default the\n provider's email client); a refusal leaves no account and no secret, and the\n error text has the secret redacted. The connecting user becomes the owner;\n `label` and the per-account endpoint (`configuration`) are stored; reconnect\n replaces the secret and is owner-only. `setAccountActive()` pauses/resumes\n (`isActive`), `removeAccount()` deletes the secret, the synced mail and the\n account. IMAP/POP3 are admitted here (receive-only), not by `saveAccount`.\n- **Generic OAuth 2.0 / OIDC**: `@happyvertical/smrt-messages/connect`\n (`startMailOAuthConnect`, `completeMailOAuthConnect`, `MailOAuthProvider`)\n on the shared kernel `@happyvertical/smrt-secrets/connect` (single-use\n tenant- and user-bound `ConnectState`, PKCE, safe return path, OIDC\n discovery with issuer check). The signed-in user becomes the owner; an\n account owned by someone else or by no one is never taken over. No role\n checks in the flow: authorize before calling.\n- **Reconnect**: `syncFrom()` marks an auth failure `connectionStatus =\n 'needs_reconnect'` (`Account.markNeedsReconnect/markConnected`) instead of\n failing silently.\n- The Google provider is a later step (sdk#1405), not part of this flow.\n\n## In-app notifications (`UserNotification`)\n\nThe in-app channel: one stored row per person, with read state.\n`user_notifications`: `tenantId` (required), `recipientUserId`\n(`@crossPackageRef` smrt-users:User, uuid), `kind`, `title`, `body`, `href`,\n`severity` (info/success/warning/error), `sourceRef`, `occurredAt`, `readAt`,\n`dismissedAt`. Conflict identity `(tenant_id, recipient_user_id, source_ref)`.\n\n- `UserNotificationService` is the only access path: `notify()` /\n `notifyMany()` (dedupe on `sourceRef`, existing row returned untouched;\n a unique ref is generated when omitted), `listForUser()` / `countUnread()`\n across explicit `tenantIds` (each read under `withTenant`), `markRead()`,\n `dismiss()` (also marks read), `markAllRead()`. Every write filters on the\n recipient, so another user's id matches nothing.\n- Generated REST/MCP/CLI are off (`api`/`mcp`/`cli: false`): a tenant-scoped\n list would expose every member's rows. Hosts expose their own routes that\n pass the signed-in user's id, never a request-chosen one.\n- Hosts decide who is told (e.g. `SocialPost.createdByUserId` for a failed\n post). New table: consumers run `db:migrate`.\n\n## Notification email outbox (`NotificationDelivery`)\n\n`NotificationOutboxService` is the external-channel counterpart of\n`UserNotificationService`: `enqueueEmail()` stores one delivery per\n`(tenant, recipient, channel, sourceRef)` after the host resolves the\nrecipient address and same-tenant sender account (callers never choose an\naddress); `dispatchDue()` leases due rows by compare-and-set\n(`NotificationDelivery.transition()`), creates the single outbound `Email`\nunder the lease, and settles sent/retry/failed/uncertain. Never resend an\n`uncertain` row automatically. Contract, retry, and reconciliation policy:\n[agents/notification-outbox.md](agents/notification-outbox.md). New table:\nconsumers run `db:migrate`.\n\n`NotificationOptOut` (`notification_opt_outs`, tenant-required, generated\nsurfaces off) is the per-recipient opt-out ledger for the outbox's\n`isSuppressed` hook, keyed `(tenant, recipient, channel, scope)` with scope `*`\nor `project:<uuid>`-style keys. `NotificationOptOutService`: idempotent\n`optOut`/`optIn` (with a `principal` only `userId === recipientUserId` may\nchange a row, and only in the principal's own `tenantId`, else\n`NotificationOptOutDeniedError`; no principal = trusted host code), trusted `isOptedOut` (a `*` row matches every scope), `listForRecipient`\n(principal required). `optOutSuppression(service, scopeOf)` builds the\n`isSuppressed` function. Details in the outbox doc; consumers run `db:migrate`.\n\n## Credential Security\n\nAccount credentials stored via tenant-bound `credentialSecretId` →\nsmrt-secrets. Use `setCredentials()`/`getCredentials()` — never store passwords\ndirectly. Credential descriptor schemas contain field definitions, never values.\n\n## Send Lifecycle\n\n`message.send()`: resolves account → creates provider sender → updates sendStatus. Retry support with `maxRetries` budget.\nA failure the provider may still have accepted carries\n`MessageSendResult.outcomeUnknown` (set by `EmailSender` unless\n`isDefiniteSendRejection()` proves a refusal, and when a sender throws) and is\npersisted as `metadata.sendOutcomeUnknown`; never auto-resend it.\n`EmailSender` attaches the message's stored `Attachment` rows (read through\n`Attachment.readContent()`, under the message's tenant context) plus\n`SendEmailOptions.attachments` bytes; an unreadable or file-less row fails the\nsend with the error on `sendError`, never a silent drop (#3808).\n`PersonaMessagingService.send({ attachments })` accepts them on email routes only.\n\n## Provider entry points (bundle boundary, #1979)\n\nThe package root is provider-neutral: models, collections, services,\npermissions, and the provider registry carry **zero provider-SDK weight**.\nProvider SDK wrappers (`@happyvertical/email`, `@happyvertical/messages`) are\nreachable only through explicit entry points, imported once at server startup:\n\n```ts\nimport '@happyvertical/smrt-messages/providers/email'; // smtp/imap/pop3/gmail\nimport '@happyvertical/smrt-messages/providers/slack';\nimport '@happyvertical/smrt-messages/providers/twitter';\nimport '@happyvertical/smrt-messages/providers/all'; // all of the above\n```\n\n- Without the matching entry, `EmailAccount.createClient()` (send + mailbox\n sync) throws an actionable error and `SlackSender`/`TweetSender` return a\n failure result naming the entry to import. Telegram and Zulip are\n fetch-based and always work from the root.\n- Builtin registry definitions stay metadata-only (setup fields for UIs); the\n entries upgrade them with `createEmailClient`/`createMessageClient`/\n `createSender` hooks. Never import a provider SDK from any module reachable\n from `src/index.ts` — the consumer bundle gate (`packages/bundle-gate`)\n fails CI when one becomes reachable.\n- `Attachment.readContent()` loads `@happyvertical/files` through core's\n `importOptionalDependency` boundary and keeps its null-on-failure contract\n in builds where the SDK is absent.\n\n## Gotchas\n\n- **Manifest before decorators**: every decorated model imports\n `../__smrt-register__.js`, and `package.json#sideEffects` lists\n `./src/__smrt-register__.ts`. Without both, the library build dropped or\n reordered the self-registration, so dist classes registered with only their\n decorated fields and could adopt smrt-ledgers' same-named `Account` (#3098).\n- **`Account` is not unique**: smrt-ledgers also declares `Account` (on\n `ledger_accounts`). Resolve by constructor or qualified name; the\n coexistence tests (`ledger-account-identity-*`, and the PostgreSQL lane\n `pnpm test:postgres`) load both packages in both orders.\n Both declare the `accounts` collection, so registering the ledgers `Account`\n auto-loads this family from its manifest as STI siblings. Core loads this\n base with them and never takes the ledgers `Account` for it (#4735,\n `ledger-account-identity-sti-siblings.test.ts`).\n- **STI `_meta_type`**: qualified format `@happyvertical/smrt-messages:Email`\n- **JSON fields**: all address/metadata fields are JSON strings with `getX()`/`setX()` helpers\n- **RFC 822 threading**: Email uses `inReplyTo`/`messageId`/`references` — manual management required\n- **Attachment.messageId**: use this field (not `emailId`); old getter/setter mapped via deprecation wrapper\n- **Optional tenancy**: `@TenantScoped({ mode: 'optional' })` on Message, Account, Attachment\n- **Required tenancy**: endpoints and persona routes are always tenant scoped\n- **Secrets are write-only**: never serialize credentials or endpoint.address to an app\n\n## Intake byte snapshots\n\n`EmailAccount.readIntakeMessage(providerLookup, maxBytes, imapIdentity?)` is the authorized host seam for\nopt-in ingestion. It copies full-message attachment bytes from the registered\nemail provider and fails when only attachment metadata is available; it never\nreads provider-supplied paths or advances sync checkpoints. Keep this path\nprovider-neutral and exclude arbitrary headers/credentials from its snapshot.\nIMAP lookup must include folder/UIDVALIDITY/UID verification; sender Message-ID\nis a lookup hint, never the durable delivery identity.\n\nProtected notification Emails carry durable delivery provenance. Their canonical\n`send`/`retrySend`, ordinary save/delete, and default EmailSender handoff are\nconstrained by `protected-notification-handoff.ts` (package-private, never a root\nexport). Only the outbox enters its exact one-use scope after current trusted\npolicy/byte validation. Preserve old-row/constructor identity checks, current\npersisted lease checks at the actual provider boundary, copied byte buffers and\nunknown-outcome marker protection. See the outbox contract and shared protected\nhandoff suite (SQLite and migrated PostgreSQL).\n\n## Protected external contacts\n\nProfile email uses exclusive `recipientProfileId` plus `resolveProfileRecipient`, a reserved `profileNotificationPolicy` and exact current tenant-owned public Profile email. No User account is required. Before activating profiles, run normal framework schema migration and public `planNotificationProfileRecipients` / `migrateNotificationProfileRecipients`; runtime verifies physical constraints and never applies DDL. Legacy User notification and opt-out paths remain User-only. See [profile recipient contract and matrix](agents/profile-recipients.md).\n\n## Incremental mail sync (change feed)\n\n`EmailAccount.syncChanges({ limit?, maxBatches? })` (`mail-sync.ts`) drives\n`EmailClient.getChanges()` (JMAP provider `jmap`; `@happyvertical/email` 0.114+).\n`syncFrom()` stays the polling path for IMAP/POP3.\n\n- `EmailAccount.syncCursor` is the opaque feed cursor (sensitive + readonly, never\n on generated surfaces). It is saved only after its batch is applied; a failure\n anywhere leaves it where it was, so the job just retries.\n- Rows are keyed on `Email.providerMessageId` (the server's own id, per account),\n so applying a batch twice changes nothing. Added/changed messages upsert,\n `removed` deletes, `folders` upserts `EmailFolder` by path and counts are\n recomputed for touched folders. Metadata-only changes keep stored bodies.\n- `resync-required` clears the cursor and runs a full pass in the same run; a\n full pass from no cursor deletes stored messages (with a `providerMessageId`)\n the server no longer has. A second resync request in one run throws.\n- One lane per account: runs queue behind each other in-process, work on the\n stored (revision-guarded) row, and the job is deduplicated per tenant+account.\n Inactive and `needs_reconnect` accounts, and clients without `getChanges`,\n return `{ status: 'skipped' }`. Auth failures call `markNeedsReconnect()` and\n throw with `retryable: false`. The sync runs under `runWithMailSystemAccess()`.\n- Job: `enqueueMailSync(account)` / `enqueueDueMailSyncs(accounts)`\n (`mail-sync-jobs.ts`, queue `mail-sync`, dedupe key `mail-sync:<accountId>`)\n target `EmailAccount.syncChanges` through `@happyvertical/smrt-jobs` (optional\n peer). The host runs the `TaskRunner` and schedules `enqueueDueMailSyncs`.\n- Known gaps: attachment rows are not created (only `hasAttachments`/`size`);\n a renamed server folder creates a new folder row (stored messages keep the old\n path until they change); `jmap` has no connect-flow validator yet and is not an\n outbound transport.\n",
12992
13786
  "moduleDocs": [
12993
13787
  {
12994
13788
  "path": "agents/notification-outbox.md",
@@ -13096,7 +13890,8 @@
13096
13890
  "options": [
13097
13891
  "imap",
13098
13892
  "pop3",
13099
- "gmail"
13893
+ "gmail",
13894
+ "jmap"
13100
13895
  ],
13101
13896
  "required": true
13102
13897
  },
@@ -13147,7 +13942,7 @@
13147
13942
  "demo": {
13148
13943
  "mode": "server",
13149
13944
  "reasons": [
13150
- "Needs a server because its package depends on @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3617, #3624, #3626, #3627)."
13945
+ "Needs a server because its package depends on @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3626, #3627)."
13151
13946
  ]
13152
13947
  }
13153
13948
  },
@@ -13216,7 +14011,7 @@
13216
14011
  "demo": {
13217
14012
  "mode": "server",
13218
14013
  "reasons": [
13219
- "Needs a server because its package depends on @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3617, #3624, #3626, #3627)."
14014
+ "Needs a server because its package depends on @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3626, #3627)."
13220
14015
  ]
13221
14016
  }
13222
14017
  },
@@ -13449,7 +14244,7 @@
13449
14244
  "demo": {
13450
14245
  "mode": "server",
13451
14246
  "reasons": [
13452
- "Needs a server because its package depends on @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3617, #3624, #3626, #3627)."
14247
+ "Needs a server because its package depends on @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3626, #3627)."
13453
14248
  ]
13454
14249
  }
13455
14250
  }
@@ -13457,12 +14252,14 @@
13457
14252
  "browser": {
13458
14253
  "status": "server-only",
13459
14254
  "issues": [
14255
+ "#3615",
13460
14256
  "#3617",
13461
14257
  "#3624",
13462
14258
  "#3626",
13463
14259
  "#3627"
13464
14260
  ],
13465
14261
  "via": [
14262
+ "@happyvertical/smrt-jobs",
13466
14263
  "@happyvertical/smrt-profiles",
13467
14264
  "@happyvertical/smrt-secrets",
13468
14265
  "@happyvertical/smrt-tenancy",