@happyvertical/smrt-messages 0.60.13 → 0.60.15
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/AGENTS.md +13 -0
- package/agents/notification-outbox.md +125 -2
- package/agents/profile-recipients.md +32 -0
- package/agents/scoped-attachment-test-matrix.md +46 -0
- package/dist/chunks/{AccountCollection-B7Nen_TO.js → AccountCollection-DBEG6nR7.js} +6 -7
- package/dist/chunks/AccountCollection-DBEG6nR7.js.map +1 -0
- package/dist/chunks/{Email-CnlwhWa0.js → Email-p5qIyMC5.js} +3 -3
- package/dist/chunks/{Email-CnlwhWa0.js.map → Email-p5qIyMC5.js.map} +1 -1
- package/dist/chunks/{EmailFolder-ukdMVI0c.js → EmailFolder-Dk4hxikK.js} +3 -3
- package/dist/chunks/EmailFolder-Dk4hxikK.js.map +1 -0
- package/dist/chunks/{Message-CinnTgyw.js → Message-hIwx07Kt.js} +72 -11
- package/dist/chunks/Message-hIwx07Kt.js.map +1 -0
- package/dist/chunks/{MessageCollection-BquAmxgU.js → MessageCollection-BwnE4a_L.js} +3 -3
- package/dist/chunks/MessageCollection-BwnE4a_L.js.map +1 -0
- package/dist/chunks/__smrt-register__-D3kBjvML.js +6 -0
- package/dist/chunks/__smrt-register__-D3kBjvML.js.map +1 -0
- package/dist/chunks/protected-notification-handoff-mvaEZVp7.js +358 -0
- package/dist/chunks/protected-notification-handoff-mvaEZVp7.js.map +1 -0
- package/dist/host.browser.d.ts +18 -0
- package/dist/host.browser.d.ts.map +1 -0
- package/dist/host.browser.js +27 -0
- package/dist/host.browser.js.map +1 -0
- package/dist/host.d.ts +19 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +35 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +589 -67
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +317 -14
- package/dist/migrations/profileRecipients.d.ts +17 -0
- package/dist/migrations/profileRecipients.d.ts.map +1 -0
- package/dist/models/Account.d.ts.map +1 -1
- package/dist/models/Message.d.ts +7 -0
- package/dist/models/Message.d.ts.map +1 -1
- package/dist/models/NotificationDelivery.d.ts +20 -3
- package/dist/models/NotificationDelivery.d.ts.map +1 -1
- package/dist/notification-recipient-identity.d.ts +17 -0
- package/dist/notification-recipient-identity.d.ts.map +1 -0
- package/dist/permissions.d.ts +1 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/protected-notification-handoff.d.ts +31 -0
- package/dist/protected-notification-handoff.d.ts.map +1 -0
- package/dist/recipes.d.ts +1 -1
- package/dist/senders/EmailSender.d.ts.map +1 -1
- package/dist/services/NotificationOutboxService.d.ts +51 -3
- package/dist/services/NotificationOutboxService.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +184 -12
- package/dist/smrt-knowledge.okf.md +7 -2
- package/package.json +13 -9
- package/dist/chunks/AccountCollection-B7Nen_TO.js.map +0 -1
- package/dist/chunks/EmailFolder-ukdMVI0c.js.map +0 -1
- package/dist/chunks/Message-CinnTgyw.js.map +0 -1
- package/dist/chunks/MessageCollection-BquAmxgU.js.map +0 -1
- package/dist/chunks/__smrt-register__-Dz163WBB.js +0 -6
- package/dist/chunks/__smrt-register__-Dz163WBB.js.map +0 -1
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-messages",
|
|
6
|
-
"packageVersion": "0.60.
|
|
6
|
+
"packageVersion": "0.60.15",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
13
|
-
"moduleDoc:agents/notification-outbox.md": "
|
|
10
|
+
"manifest": "64daf724db93bd0a089432ed7ac608210ae3b54239dda033a8b1dbbeed5396bf",
|
|
11
|
+
"packageJson": "ab034a9bfa8d82a0bd1d7cc7841a289a2af9c78a23502b184f3ecbcb78ee4f40",
|
|
12
|
+
"agents": "fadb167e6030e31ffcd7705b097db7d914a104a4f5f7b8d30d8def2a034a0879",
|
|
13
|
+
"moduleDoc:agents/notification-outbox.md": "0e9a870c4b2d5f0fec47af0dff6e61d216fb0121d384d99bccfc506beb6e38ad",
|
|
14
|
+
"moduleDoc:agents/profile-recipients.md": "1b6710bf646ddeafd6836df8270fcbb8e29226dceda716a693d945cc2e914606"
|
|
14
15
|
},
|
|
15
16
|
"exports": [
|
|
16
17
|
".",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"@happyvertical/logger": "catalog:",
|
|
31
32
|
"@happyvertical/messages": "catalog:",
|
|
32
33
|
"@happyvertical/smrt-core": "workspace:*",
|
|
34
|
+
"@happyvertical/smrt-profiles": "workspace:*",
|
|
33
35
|
"@happyvertical/smrt-types": "workspace:*",
|
|
34
36
|
"@happyvertical/smrt-secrets": "workspace:*",
|
|
35
37
|
"@happyvertical/smrt-tenancy": "workspace:*",
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
"smrtDependencies": [
|
|
53
55
|
"@happyvertical/smrt-core",
|
|
54
56
|
"@happyvertical/smrt-ledgers",
|
|
57
|
+
"@happyvertical/smrt-profiles",
|
|
55
58
|
"@happyvertical/smrt-secrets",
|
|
56
59
|
"@happyvertical/smrt-tenancy",
|
|
57
60
|
"@happyvertical/smrt-types",
|
|
@@ -80,7 +83,7 @@
|
|
|
80
83
|
"typescript"
|
|
81
84
|
],
|
|
82
85
|
"risks": [
|
|
83
|
-
"cross-package-refs:
|
|
86
|
+
"cross-package-refs:10",
|
|
84
87
|
"sensitive-fields-excluded",
|
|
85
88
|
"sti-inheritance"
|
|
86
89
|
],
|
|
@@ -4161,6 +4164,7 @@
|
|
|
4161
4164
|
"abandonSendAttempt",
|
|
4162
4165
|
"createForward",
|
|
4163
4166
|
"createReply",
|
|
4167
|
+
"delete",
|
|
4164
4168
|
"getAccount",
|
|
4165
4169
|
"getAttachments",
|
|
4166
4170
|
"getBccAddresses",
|
|
@@ -4181,6 +4185,7 @@
|
|
|
4181
4185
|
"markRead",
|
|
4182
4186
|
"markUnread",
|
|
4183
4187
|
"retrySend",
|
|
4188
|
+
"save",
|
|
4184
4189
|
"send",
|
|
4185
4190
|
"setFlags",
|
|
4186
4191
|
"setHeaders",
|
|
@@ -4209,6 +4214,14 @@
|
|
|
4209
4214
|
],
|
|
4210
4215
|
"returns": "Email"
|
|
4211
4216
|
},
|
|
4217
|
+
{
|
|
4218
|
+
"name": "delete",
|
|
4219
|
+
"async": true,
|
|
4220
|
+
"params": [
|
|
4221
|
+
"options?: object"
|
|
4222
|
+
],
|
|
4223
|
+
"returns": "Promise<void>"
|
|
4224
|
+
},
|
|
4212
4225
|
{
|
|
4213
4226
|
"name": "getAccount",
|
|
4214
4227
|
"async": true,
|
|
@@ -4304,6 +4317,14 @@
|
|
|
4304
4317
|
],
|
|
4305
4318
|
"returns": "Promise<MessageSendResult>"
|
|
4306
4319
|
},
|
|
4320
|
+
{
|
|
4321
|
+
"name": "save",
|
|
4322
|
+
"async": true,
|
|
4323
|
+
"params": [
|
|
4324
|
+
"options?: SmrtSaveOptions"
|
|
4325
|
+
],
|
|
4326
|
+
"returns": "Promise<this>"
|
|
4327
|
+
},
|
|
4307
4328
|
{
|
|
4308
4329
|
"name": "send",
|
|
4309
4330
|
"async": true,
|
|
@@ -4780,6 +4801,13 @@
|
|
|
4780
4801
|
"reason": "not listed in api.include",
|
|
4781
4802
|
"objectName": "@happyvertical/smrt-messages:Email"
|
|
4782
4803
|
},
|
|
4804
|
+
{
|
|
4805
|
+
"kind": "api",
|
|
4806
|
+
"operation": "save",
|
|
4807
|
+
"code": "lifecycle-method",
|
|
4808
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
4809
|
+
"objectName": "@happyvertical/smrt-messages:Email"
|
|
4810
|
+
},
|
|
4783
4811
|
{
|
|
4784
4812
|
"kind": "api",
|
|
4785
4813
|
"operation": "send",
|
|
@@ -6168,6 +6196,7 @@
|
|
|
6168
6196
|
"abandonSendAttempt",
|
|
6169
6197
|
"createForward",
|
|
6170
6198
|
"createReply",
|
|
6199
|
+
"delete",
|
|
6171
6200
|
"getAccount",
|
|
6172
6201
|
"getAttachments",
|
|
6173
6202
|
"getEndpoint",
|
|
@@ -6180,6 +6209,7 @@
|
|
|
6180
6209
|
"markRead",
|
|
6181
6210
|
"markUnread",
|
|
6182
6211
|
"retrySend",
|
|
6212
|
+
"save",
|
|
6183
6213
|
"send",
|
|
6184
6214
|
"setMetadata",
|
|
6185
6215
|
"setToAddresses",
|
|
@@ -6205,6 +6235,14 @@
|
|
|
6205
6235
|
],
|
|
6206
6236
|
"returns": "Message"
|
|
6207
6237
|
},
|
|
6238
|
+
{
|
|
6239
|
+
"name": "delete",
|
|
6240
|
+
"async": true,
|
|
6241
|
+
"params": [
|
|
6242
|
+
"options?: object"
|
|
6243
|
+
],
|
|
6244
|
+
"returns": "Promise<void>"
|
|
6245
|
+
},
|
|
6208
6246
|
{
|
|
6209
6247
|
"name": "getAccount",
|
|
6210
6248
|
"async": true,
|
|
@@ -6266,6 +6304,14 @@
|
|
|
6266
6304
|
],
|
|
6267
6305
|
"returns": "Promise<MessageSendResult>"
|
|
6268
6306
|
},
|
|
6307
|
+
{
|
|
6308
|
+
"name": "save",
|
|
6309
|
+
"async": true,
|
|
6310
|
+
"params": [
|
|
6311
|
+
"options?: SmrtSaveOptions"
|
|
6312
|
+
],
|
|
6313
|
+
"returns": "Promise<this>"
|
|
6314
|
+
},
|
|
6269
6315
|
{
|
|
6270
6316
|
"name": "send",
|
|
6271
6317
|
"async": true,
|
|
@@ -6586,6 +6632,13 @@
|
|
|
6586
6632
|
"reason": "not listed in api.include",
|
|
6587
6633
|
"objectName": "@happyvertical/smrt-messages:Message"
|
|
6588
6634
|
},
|
|
6635
|
+
{
|
|
6636
|
+
"kind": "api",
|
|
6637
|
+
"operation": "save",
|
|
6638
|
+
"code": "lifecycle-method",
|
|
6639
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
6640
|
+
"objectName": "@happyvertical/smrt-messages:Message"
|
|
6641
|
+
},
|
|
6589
6642
|
{
|
|
6590
6643
|
"kind": "api",
|
|
6591
6644
|
"operation": "send",
|
|
@@ -6815,10 +6868,24 @@
|
|
|
6815
6868
|
{
|
|
6816
6869
|
"name": "recipientUserId",
|
|
6817
6870
|
"type": "crossPackageRef",
|
|
6818
|
-
"required":
|
|
6871
|
+
"required": false,
|
|
6819
6872
|
"related": "@happyvertical/smrt-users:User",
|
|
6820
6873
|
"columnType": "UUID"
|
|
6821
6874
|
},
|
|
6875
|
+
{
|
|
6876
|
+
"name": "recipientProfileId",
|
|
6877
|
+
"type": "crossPackageRef",
|
|
6878
|
+
"required": false,
|
|
6879
|
+
"related": "@happyvertical/smrt-profiles:Profile",
|
|
6880
|
+
"columnType": "UUID"
|
|
6881
|
+
},
|
|
6882
|
+
{
|
|
6883
|
+
"name": "recipientKind",
|
|
6884
|
+
"type": "text",
|
|
6885
|
+
"required": true,
|
|
6886
|
+
"columnType": "TEXT",
|
|
6887
|
+
"default": "user"
|
|
6888
|
+
},
|
|
6822
6889
|
{
|
|
6823
6890
|
"name": "channel",
|
|
6824
6891
|
"type": "text",
|
|
@@ -6838,6 +6905,18 @@
|
|
|
6838
6905
|
"required": true,
|
|
6839
6906
|
"columnType": "TEXT"
|
|
6840
6907
|
},
|
|
6908
|
+
{
|
|
6909
|
+
"name": "requiredDispatchPolicy",
|
|
6910
|
+
"type": "text",
|
|
6911
|
+
"required": false,
|
|
6912
|
+
"columnType": "TEXT"
|
|
6913
|
+
},
|
|
6914
|
+
{
|
|
6915
|
+
"name": "dispatchPolicyBinding",
|
|
6916
|
+
"type": "json",
|
|
6917
|
+
"required": false,
|
|
6918
|
+
"columnType": "JSON"
|
|
6919
|
+
},
|
|
6841
6920
|
{
|
|
6842
6921
|
"name": "subject",
|
|
6843
6922
|
"type": "text",
|
|
@@ -6963,10 +7042,17 @@
|
|
|
6963
7042
|
{
|
|
6964
7043
|
"name": "recipientUserId",
|
|
6965
7044
|
"type": "crossPackageRef",
|
|
6966
|
-
"required":
|
|
7045
|
+
"required": false,
|
|
6967
7046
|
"related": "@happyvertical/smrt-users:User",
|
|
6968
7047
|
"columnType": "UUID"
|
|
6969
7048
|
},
|
|
7049
|
+
{
|
|
7050
|
+
"name": "recipientProfileId",
|
|
7051
|
+
"type": "crossPackageRef",
|
|
7052
|
+
"required": false,
|
|
7053
|
+
"related": "@happyvertical/smrt-profiles:Profile",
|
|
7054
|
+
"columnType": "UUID"
|
|
7055
|
+
},
|
|
6970
7056
|
{
|
|
6971
7057
|
"name": "accountId",
|
|
6972
7058
|
"type": "foreignKey",
|
|
@@ -6983,9 +7069,24 @@
|
|
|
6983
7069
|
}
|
|
6984
7070
|
],
|
|
6985
7071
|
"methods": [
|
|
7072
|
+
"delete",
|
|
7073
|
+
"save",
|
|
6986
7074
|
"transition"
|
|
6987
7075
|
],
|
|
6988
7076
|
"methodSignatures": [
|
|
7077
|
+
{
|
|
7078
|
+
"name": "delete",
|
|
7079
|
+
"async": true,
|
|
7080
|
+
"returns": "Promise<void>"
|
|
7081
|
+
},
|
|
7082
|
+
{
|
|
7083
|
+
"name": "save",
|
|
7084
|
+
"async": true,
|
|
7085
|
+
"params": [
|
|
7086
|
+
"options?: SmrtSaveOptions"
|
|
7087
|
+
],
|
|
7088
|
+
"returns": "Promise<this>"
|
|
7089
|
+
},
|
|
6989
7090
|
{
|
|
6990
7091
|
"name": "transition",
|
|
6991
7092
|
"async": true,
|
|
@@ -7003,12 +7104,28 @@
|
|
|
7003
7104
|
},
|
|
7004
7105
|
"conflictColumns": [
|
|
7005
7106
|
"tenant_id",
|
|
7107
|
+
"recipient_kind",
|
|
7006
7108
|
"recipient_user_id",
|
|
7109
|
+
"recipient_profile_id",
|
|
7007
7110
|
"channel",
|
|
7008
7111
|
"source_ref"
|
|
7009
7112
|
],
|
|
7010
7113
|
"surfaces": [],
|
|
7011
7114
|
"withheldSurfaces": [
|
|
7115
|
+
{
|
|
7116
|
+
"kind": "api",
|
|
7117
|
+
"operation": "delete",
|
|
7118
|
+
"code": "api-disabled",
|
|
7119
|
+
"reason": "api is disabled",
|
|
7120
|
+
"objectName": "@happyvertical/smrt-messages:NotificationDelivery"
|
|
7121
|
+
},
|
|
7122
|
+
{
|
|
7123
|
+
"kind": "api",
|
|
7124
|
+
"operation": "save",
|
|
7125
|
+
"code": "api-disabled",
|
|
7126
|
+
"reason": "api is disabled",
|
|
7127
|
+
"objectName": "@happyvertical/smrt-messages:NotificationDelivery"
|
|
7128
|
+
},
|
|
7012
7129
|
{
|
|
7013
7130
|
"kind": "api",
|
|
7014
7131
|
"operation": "transition",
|
|
@@ -7845,6 +7962,7 @@
|
|
|
7845
7962
|
"abandonSendAttempt",
|
|
7846
7963
|
"createForward",
|
|
7847
7964
|
"createReply",
|
|
7965
|
+
"delete",
|
|
7848
7966
|
"getAccount",
|
|
7849
7967
|
"getAttachments",
|
|
7850
7968
|
"getBlocks",
|
|
@@ -7861,6 +7979,7 @@
|
|
|
7861
7979
|
"markRead",
|
|
7862
7980
|
"markUnread",
|
|
7863
7981
|
"retrySend",
|
|
7982
|
+
"save",
|
|
7864
7983
|
"send",
|
|
7865
7984
|
"setMetadata",
|
|
7866
7985
|
"setToAddresses",
|
|
@@ -7886,6 +8005,14 @@
|
|
|
7886
8005
|
],
|
|
7887
8006
|
"returns": "Message"
|
|
7888
8007
|
},
|
|
8008
|
+
{
|
|
8009
|
+
"name": "delete",
|
|
8010
|
+
"async": true,
|
|
8011
|
+
"params": [
|
|
8012
|
+
"options?: object"
|
|
8013
|
+
],
|
|
8014
|
+
"returns": "Promise<void>"
|
|
8015
|
+
},
|
|
7889
8016
|
{
|
|
7890
8017
|
"name": "getAccount",
|
|
7891
8018
|
"async": true,
|
|
@@ -7963,6 +8090,14 @@
|
|
|
7963
8090
|
],
|
|
7964
8091
|
"returns": "Promise<MessageSendResult>"
|
|
7965
8092
|
},
|
|
8093
|
+
{
|
|
8094
|
+
"name": "save",
|
|
8095
|
+
"async": true,
|
|
8096
|
+
"params": [
|
|
8097
|
+
"options?: SmrtSaveOptions"
|
|
8098
|
+
],
|
|
8099
|
+
"returns": "Promise<this>"
|
|
8100
|
+
},
|
|
7966
8101
|
{
|
|
7967
8102
|
"name": "send",
|
|
7968
8103
|
"async": true,
|
|
@@ -8332,6 +8467,13 @@
|
|
|
8332
8467
|
"reason": "not listed in api.include",
|
|
8333
8468
|
"objectName": "@happyvertical/smrt-messages:SlackMessage"
|
|
8334
8469
|
},
|
|
8470
|
+
{
|
|
8471
|
+
"kind": "api",
|
|
8472
|
+
"operation": "save",
|
|
8473
|
+
"code": "lifecycle-method",
|
|
8474
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
8475
|
+
"objectName": "@happyvertical/smrt-messages:SlackMessage"
|
|
8476
|
+
},
|
|
8335
8477
|
{
|
|
8336
8478
|
"kind": "api",
|
|
8337
8479
|
"operation": "send",
|
|
@@ -8939,6 +9081,7 @@
|
|
|
8939
9081
|
"abandonSendAttempt",
|
|
8940
9082
|
"createForward",
|
|
8941
9083
|
"createReply",
|
|
9084
|
+
"delete",
|
|
8942
9085
|
"getAccount",
|
|
8943
9086
|
"getAttachments",
|
|
8944
9087
|
"getEndpoint",
|
|
@@ -8955,6 +9098,7 @@
|
|
|
8955
9098
|
"markRead",
|
|
8956
9099
|
"markUnread",
|
|
8957
9100
|
"retrySend",
|
|
9101
|
+
"save",
|
|
8958
9102
|
"send",
|
|
8959
9103
|
"setMetadata",
|
|
8960
9104
|
"setToAddresses",
|
|
@@ -8980,6 +9124,14 @@
|
|
|
8980
9124
|
],
|
|
8981
9125
|
"returns": "Message"
|
|
8982
9126
|
},
|
|
9127
|
+
{
|
|
9128
|
+
"name": "delete",
|
|
9129
|
+
"async": true,
|
|
9130
|
+
"params": [
|
|
9131
|
+
"options?: object"
|
|
9132
|
+
],
|
|
9133
|
+
"returns": "Promise<void>"
|
|
9134
|
+
},
|
|
8983
9135
|
{
|
|
8984
9136
|
"name": "getAccount",
|
|
8985
9137
|
"async": true,
|
|
@@ -9057,6 +9209,14 @@
|
|
|
9057
9209
|
],
|
|
9058
9210
|
"returns": "Promise<MessageSendResult>"
|
|
9059
9211
|
},
|
|
9212
|
+
{
|
|
9213
|
+
"name": "save",
|
|
9214
|
+
"async": true,
|
|
9215
|
+
"params": [
|
|
9216
|
+
"options?: SmrtSaveOptions"
|
|
9217
|
+
],
|
|
9218
|
+
"returns": "Promise<this>"
|
|
9219
|
+
},
|
|
9060
9220
|
{
|
|
9061
9221
|
"name": "send",
|
|
9062
9222
|
"async": true,
|
|
@@ -9426,6 +9586,13 @@
|
|
|
9426
9586
|
"reason": "not listed in api.include",
|
|
9427
9587
|
"objectName": "@happyvertical/smrt-messages:Tweet"
|
|
9428
9588
|
},
|
|
9589
|
+
{
|
|
9590
|
+
"kind": "api",
|
|
9591
|
+
"operation": "save",
|
|
9592
|
+
"code": "lifecycle-method",
|
|
9593
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
9594
|
+
"objectName": "@happyvertical/smrt-messages:Tweet"
|
|
9595
|
+
},
|
|
9429
9596
|
{
|
|
9430
9597
|
"kind": "api",
|
|
9431
9598
|
"operation": "send",
|
|
@@ -12737,18 +12904,23 @@
|
|
|
12737
12904
|
"prompts": [],
|
|
12738
12905
|
"relationshipsV2": {
|
|
12739
12906
|
"foreignKeyFields": 18,
|
|
12740
|
-
"crossPackageRefFields":
|
|
12907
|
+
"crossPackageRefFields": 10,
|
|
12741
12908
|
"junctionCollections": 0,
|
|
12742
12909
|
"hierarchicalObjects": 0,
|
|
12743
12910
|
"polymorphicAssociations": 0,
|
|
12744
|
-
"uuidColumns":
|
|
12911
|
+
"uuidColumns": 114
|
|
12745
12912
|
},
|
|
12746
|
-
"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- **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",
|
|
12913
|
+
"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- **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",
|
|
12747
12914
|
"moduleDocs": [
|
|
12748
12915
|
{
|
|
12749
12916
|
"path": "agents/notification-outbox.md",
|
|
12750
12917
|
"module": "notification-outbox",
|
|
12751
|
-
"content": "# Notification email outbox (#4237)\n\n`NotificationOutboxService` turns a host event into at most one outbound email\nper recipient and delivers it from a crash-safe, leased outbox. It pairs with\n`UserNotificationService`: hosts that tell someone in-app and by email pass the\nsame `sourceRef` to both.\n\nSource: `src/models/NotificationDelivery.ts`,\n`src/services/NotificationOutboxService.ts`,\ntests `src/__tests__/notification-outbox*.test.ts`.\n\n## Enqueue\n\n`enqueueEmail({ tenantId, recipientUserId, sourceRef, kind, subject, text, path, notBefore? })`\nstores one `NotificationDelivery` (`notification_deliveries`) per\n`(tenant_id, recipient_user_id, channel, source_ref)`, the conflict identity. A\nrepeat (or a concurrent duplicate that loses the insert) returns the stored row\nuntouched with `created: false`. Encode each distinct event in `sourceRef`, e.g.\n`project-question:<id>:asked` and `project-question:<id>:reminder:<n>`.\n\nHost authorization, all checked before anything is stored:\n\n- `resolveRecipient({ tenantId, recipientUserId, channel })` returns the address\n the host allows for that user in that tenant, or `null` (denied with\n `NotificationOutboxDeniedError`, reason `recipient`). Callers never pass an\n address; the resolved one is snapshotted on the row.\n- `resolveSenderAccountId({ tenantId })` names an active `EmailAccount` owned by\n the same tenant (reason `sender` otherwise). Configuring that account is\n deployment setup; the outbox has no mail transport of its own.\n- With `principal`, enqueue, `listUncertain`, and `reconcile` require\n `messages.send` in the tenant (reason `permission`). Omit it only for trusted\n system code that authorizes itself.\n- `isSuppressed(...)` (optional) is the opt-out hook. A suppressed enqueue stores\n a `cancelled` row (so the event stays deduplicated); suppression at dispatch\n cancels before handoff. The package's own preference store is the\n [opt-out ledger](#opt-out-ledger); wire it with `optOutSuppression`.\n\nDeep links: `path` must be host-relative (`/portal/...`); it is joined to\n`linkBaseUrl` (absolute http(s), no credentials/query/fragment, validated at\nconstruction) and must stay on that origin — `//host`, backslashes, whitespace,\nand control characters are refused (reason `link`). The link is stored on the\nrow, so a duplicate enqueue keeps the first link. Links carry no tokens: they\nlead to the host's normal authenticated route. Subjects must be one line.\n\n## Dispatch\n\n`dispatchDue({ tenantIds?, limit? })` (default 25, max 200) leases due rows —\n`pending` with `nextAttemptAt <= now`, and `sending` rows whose lease lapsed —\nfor the given tenants, or every tenant (discovered under `withSystemContext`)\nwhen `tenantIds` is omitted. Each row is processed under `withTenant(row.tenantId)`.\nRun it from a scheduled job; several workers may run it concurrently.\n\nEvery state change is `NotificationDelivery.transition()`: a compare-and-set on\n`stateVersion` (and the lease token for a lease holder) that writes a unique\n`transitionId` and re-reads the row to prove the write won. PostgreSQL and\nremote LibSQL use one conditional `UPDATE`; local embedded engines use the\nprocess write queue, like `Message.send()`'s claim.\n\nPer row:\n\n1. Acquire: `status = sending`, new `leaseToken`, `leaseExpiresAt = now + leaseMs`\n (default 5 min; must exceed the slowest provider call), `attempts + 1`.\n2. Create the single outbound `Email` and record `messageId`. Its id is\n `notificationDeliveryMessageId(deliveryId)` (a name-based uuid) and it is\n inserted insert-only, so a crashed or stale dispatcher finds or collides\n with the stored row instead of creating a second email; its correlation id\n is `notification-delivery:<deliveryId>`.\n3. Record `handedOffAt`, then call `transport.send({ delivery, message, idempotencyKey })`.\n4. Settle with the lease token: `accepted` → `sent`; `rejected` + `retryable`\n → `pending` after `retryDelayMs(attempts)` (default 1 min · 2ⁿ⁻¹, capped at\n 1 h) until `maxAttempts` (default 5), then `failed`; non-retryable → `failed`;\n `unknown` (including a thrown send) → `uncertain`. A holder whose lease was\n taken over gets `lease-lost` and writes nothing.\n\n## Provider idempotency and reconciliation policy\n\nDelivery is at-most-once once a provider may have seen the message.\n\n- A lapsed lease with no `handedOffAt` never reached the provider: it is resent.\n- Ambiguous provider failures are not rejections. `EmailSender` sets\n `MessageSendResult.outcomeUnknown` unless `isDefiniteSendRejection()` proves\n the send was refused (an SMTP reply code, an SDK auth/validation error, a\n send error that accepted no recipient, or a connection that was never made);\n `Message.send()` sets it when a sender throws. `Message` persists the marker\n in `metadata.sendOutcomeUnknown` with the `failed` status\n (`Message.isSendOutcomeUnknown()`), and `messageSendTransport` maps it to\n `unknown`, so the delivery becomes `uncertain` instead of being retried.\n- A lapsed lease after `handedOffAt` asks `transport.reconcile()`. The default\n `messageSendTransport` reads the canonical `Message.sendStatus`: `sent` →\n delivery `sent` (no resend), `failed` → normal retry (or `uncertain` when the\n failure carries the outcome-unknown marker), `draft`/`pending` → resend,\n anything else (e.g. still `sending`) → `uncertain`.\n- `uncertain` rows are never resent automatically. Operators list them with\n `listUncertain({ tenantId })` and settle them with\n `reconcile({ tenantId, deliveryId, outcome: 'sent' | 'failed' | 'retry', note? })`\n after checking the provider; `retry` accepts the risk of a duplicate. It\n first releases a message a dead sender left `sending`\n (`Message.abandonSendAttempt()`, a compare-and-set to `failed`) so the next\n lease can send it, and refuses when the message is recorded as `sent`.\n- A transport with `idempotent: true` declares that its provider deduplicates on\n `idempotencyKey` (stable per delivery); unknown outcomes are then retried\n instead of parked. SMTP and the current SDK email providers take no key, so\n `messageSendTransport` is not idempotent.\n\n## Transport seam\n\n`NotificationTransport { name; idempotent?; send(request); reconcile?(request) }`.\nThe default delivers through `Message.send()` → account → registered provider\nsender (import `@happyvertical/smrt-messages/providers/email` at server\nstartup). Tests inject a fake; nothing in the outbox reaches a provider SDK.\n\n## Opt-out ledger\n\n`NotificationOptOut` (`notification_opt_outs`, tenant-required, generated\nREST/MCP/CLI off) records one row per `(tenant_id, recipient_user_id, channel,\nscope)`: `channel` is `email`; `scope` is `*` (all notification email in the\ntenant) or a host key such as `project:<uuid>` (lowercase prefix, `:`, then\n`[A-Za-z0-9._:-]{1,200}`; malformed scopes throw). `optedOutAt` is set while\nopted out and cleared by an opt-in (the row stays as history); `updatedBy` is\nthe person's user id, or `system` for host code. It exists because\n`smrt-preferences` is owner-read only, while suppression runs where the recipient\nis not the caller (a manager enqueues, a worker dispatches).\n\n`NotificationOptOutService({ db })`:\n\n- `optOut({ tenantId, recipientUserId, channel, scope, principal? })` and\n `optIn(...)` are idempotent. With `principal: { userId, tenantId }` only\n `principal.userId === recipientUserId` may change the row, and only when\n `principal.tenantId` equals the request's tenant: a principal never acts in\n another tenant (`NotificationOptOutDeniedError`, reason `principal` or\n `tenant`). Without a principal the call is trusted host code that\n authenticated the recipient itself (e.g. a signed unsubscribe link, or a host\n route whose member belongs to a child tenant of the delivery tenant).\n- `isOptedOut({ tenantId, recipientUserId, channel, scope })` is the trusted\n suppression read, under `withTenant`; a `*` row matches every scope.\n- `listForRecipient({ tenantId, recipientUserId, principal })` returns only the\n recipient's own active opt-outs; any other principal is denied.\n\n```ts\nconst optOuts = new NotificationOptOutService({ db });\nnew NotificationOutboxService({\n // ...\n // `scopeOf` maps the host's own event to a scope; null = not opt-out-able.\n // A question's sourceRef names the question, not its project, so the host\n // resolves the project itself (scopeOf may be async).\n isSuppressed: optOutSuppression(optOuts, async (request) => {\n const projectId = await projectIdForSourceRef(request.tenantId, request.sourceRef);\n return projectId ? `project:${projectId}` : null;\n }),\n});\n```\n\nBecause the outbox re-checks at dispatch, an opt-out recorded after enqueue\ncancels the pending delivery before handoff. Tests:\n`src/__tests__/notification-opt-out*.test.ts`.\n\n## Schema\n\nNew tables `notification_opt_outs` (same rules) and `notification_deliveries` (tenant-required, generated REST/MCP/CLI\noff): consumers run `db:migrate`. `recipient_user_id` is a cross-package uuid\nref to `smrt-users:User`; `account_id`/`message_id` are FKs to `accounts` and\n`messages`.\n"
|
|
12918
|
+
"content": "# Notification email outbox (#4237)\n\n`NotificationOutboxService` turns a host event into at most one outbound email\nper recipient and delivers it from a crash-safe, leased outbox. It pairs with\n`UserNotificationService`: hosts that tell someone in-app and by email pass the\nsame `sourceRef` to both.\n\nSource: `src/models/NotificationDelivery.ts`,\n`src/services/NotificationOutboxService.ts`,\ntests `src/__tests__/notification-outbox*.test.ts`.\n\n## Enqueue\n\n`enqueueEmail({ tenantId, recipientUserId, sourceRef, kind, subject, text, path, notBefore? })`\nstores one `NotificationDelivery` (`notification_deliveries`) per\n`(tenant_id, recipient_user_id, channel, source_ref)`, the conflict identity. A\nrepeat (or a concurrent duplicate that loses the insert) returns the stored row\nuntouched with `created: false`. Encode each distinct event in `sourceRef`, e.g.\n`project-question:<id>:asked` and `project-question:<id>:reminder:<n>`.\n\nHost authorization, all checked before anything is stored:\n\n- `resolveRecipient({ tenantId, recipientUserId, channel })` returns the address\n the host allows for that user in that tenant, or `null` (denied with\n `NotificationOutboxDeniedError`, reason `recipient`). Callers never pass an\n address; the resolved one is snapshotted on the row.\n- `resolveSenderAccountId({ tenantId })` names an active `EmailAccount` owned by\n the same tenant (reason `sender` otherwise). Configuring that account is\n deployment setup; the outbox has no mail transport of its own.\n- With `principal`, enqueue, dispatch, `listUncertain`, and `reconcile` require\n `messages.send` in the tenant (reason `permission`). Omit it only for trusted\n system code that authorizes itself.\n- `isSuppressed(...)` (optional) is the opt-out hook. A suppressed enqueue stores\n a `cancelled` row (so the event stays deduplicated); suppression at dispatch\n cancels before handoff. The package's own preference store is the\n [opt-out ledger](#opt-out-ledger); wire it with `optOutSuppression`.\n\nDeep links: `path` must be host-relative (`/portal/...`); it is joined to\n`linkBaseUrl` (absolute http(s), no credentials/query/fragment, validated at\nconstruction) and must stay on that origin — `//host`, backslashes, whitespace,\nand control characters are refused (reason `link`). The link is stored on the\nrow, so a duplicate enqueue keeps the first link. Links carry no tokens: they\nlead to the host's normal authenticated route. Subjects must be one line.\n\n## Dispatch\n\n`dispatchDue({ tenantIds?, deliveryIds?, limit? })` (default 25, max 200) leases due rows —\n`pending` with `nextAttemptAt <= now`, and `sending` rows whose lease lapsed —\nfor the given tenants, or every tenant (discovered under `withSystemContext`)\nwhen `tenantIds` is omitted. Each row is processed under `withTenant(row.tenantId)`.\nRun it from a scheduled job; several workers may run it concurrently.\n\n`deliveryIds` restricts both pending and expired-lease queries before their limits\nand before leases; an empty array selects nothing and malformed UUIDs are\nrejected. A principal defaults to its own tenant when `tenantIds` is omitted;\na principal without a tenant must select explicit tenants. Every explicit scope\nis authorized before discovery, and selected rows are authorized again before\ndispatch. Trusted system code without a principal retains cross-tenant discovery.\n\n`NotificationOutboxService.capabilities` exposes `deliverySelection: true` and\n`attachments: true` so hosts requiring these contracts can refuse an older\nlibrary before leasing any row. This marker does not authorize any sender.\n\n`resolveAttachments({delivery,message,idempotencyKey})` is an optional trusted-host\nhook, called before each fresh provider handoff. It must reauthorize the approved\nresource, immutable version/digest and recipient and return `SendEmailAttachment[]`\nusing actual bytes, never untrusted file paths or URLs. Malformed results or\nresolver failures reject before handoff; attachments are copied into the transport\nrequest and the default transport forwards them to existing `Email.send()`. The\noutbox does not persist bytes or invent document/recipient authority. Omission\npreserves ordinary no-attachment notifications; an explicit resolver returning\n`undefined` fails instead of silently dropping an expected document. Prior-handoff\nreconciliation runs without requiring document bytes; an accepted or uncertain\noutcome does not cause another attachment resolution/send.\n\nProtected documents enqueue with `kind: 'protected:<policyId>'`,\n`requiredDispatchPolicy: '<policyId>'` and an approved `dispatchPolicyBinding`\nobject (resource/version/digest/recipient identities). The trusted constructor\nmap `dispatchPolicies[policyId].resolveAttachments` owns current authorization\nand actual-byte verification. Protected kinds require their exact policy;\nenqueue rejects unknown handlers or missing bindings. A broad dispatcher without\nthe matching policy reports `blocked`, persists a detectable `lastError`, and\nleaves provider calls and lease attempts at zero. A protected policy must return\nat least one valid attachment. Existing source, policy/binding, destination,\nsender and message content cannot change through an ordinary model save;\nprotected clones retaining their kind cannot remove the policy. Missing policy\ndoes not authorize a resend of an uncertain prior attempt. The capability marker\nincludes `requiredPolicy: true`.\n\nThe two additive columns require normal consumer migration. Old rows default to\nan empty policy and retain legacy ordinary-mail behavior; no historical document\nconsent is invented. Never run old dispatcher binaries alongside newly protected\nintents: old versions cannot enforce a contract they do not implement. Rollout\nand real sends require separate authorization.\n\nEvery state change is `NotificationDelivery.transition()`: a compare-and-set on\n`stateVersion` (and the lease token for a lease holder) that writes a unique\n`transitionId` and re-reads the row to prove the write won. PostgreSQL and\nremote LibSQL use one conditional `UPDATE`; local embedded engines use the\nprocess write queue, like `Message.send()`'s claim.\n\nPer row:\n\n1. Acquire: `status = sending`, new `leaseToken`, `leaseExpiresAt = now + leaseMs`\n (default 5 min; must exceed the slowest provider call), `attempts + 1`.\n2. Create the single outbound `Email` and record `messageId`. Its id is\n `notificationDeliveryMessageId(deliveryId)` (a name-based uuid) and it is\n inserted insert-only, so a crashed or stale dispatcher finds or collides\n with the stored row instead of creating a second email; its correlation id\n is `notification-delivery:<deliveryId>`.\n3. Record `handedOffAt`, then call `transport.send({ delivery, message, idempotencyKey })`.\n4. Settle with the lease token: `accepted` → `sent`; `rejected` + `retryable`\n → `pending` after `retryDelayMs(attempts)` (default 1 min · 2ⁿ⁻¹, capped at\n 1 h) until `maxAttempts` (default 5), then `failed`; non-retryable → `failed`;\n `unknown` (including a thrown send) → `uncertain`. A holder whose lease was\n taken over gets `lease-lost` and writes nothing.\n\n## Provider idempotency and reconciliation policy\n\nDelivery is at-most-once once a provider may have seen the message.\n\n- A lapsed lease with no `handedOffAt` never reached the provider: it is resent.\n- Ambiguous provider failures are not rejections. `EmailSender` sets\n `MessageSendResult.outcomeUnknown` unless `isDefiniteSendRejection()` proves\n the send was refused (an SMTP reply code, an SDK auth/validation error, a\n send error that accepted no recipient, or a connection that was never made);\n `Message.send()` sets it when a sender throws. `Message` persists the marker\n in `metadata.sendOutcomeUnknown` with the `failed` status\n (`Message.isSendOutcomeUnknown()`), and `messageSendTransport` maps it to\n `unknown`, so the delivery becomes `uncertain` instead of being retried.\n- A lapsed lease after `handedOffAt` asks `transport.reconcile()`. The default\n `messageSendTransport` reads the canonical `Message.sendStatus`: `sent` →\n delivery `sent` (no resend), `failed` → normal retry (or `uncertain` when the\n failure carries the outcome-unknown marker), `draft`/`pending` → resend,\n anything else (e.g. still `sending`) → `uncertain`.\n- `uncertain` rows are never resent automatically. Operators list them with\n `listUncertain({ tenantId })` and settle them with\n `reconcile({ tenantId, deliveryId, outcome: 'sent' | 'failed' | 'retry', note? })`\n after checking the provider; `retry` accepts the risk of a duplicate. It\n first releases a message a dead sender left `sending`\n (`Message.abandonSendAttempt()`, a compare-and-set to `failed`) so the next\n lease can send it, and refuses when the message is recorded as `sent`.\n- A transport with `idempotent: true` declares that its provider deduplicates on\n `idempotencyKey` (stable per delivery); unknown outcomes are then retried\n instead of parked. SMTP and the current SDK email providers take no key, so\n `messageSendTransport` is not idempotent.\n\n## Transport seam\n\n`NotificationTransport { name; idempotent?; send(request); reconcile?(request) }`.\nThe default delivers through `Message.send()` → account → registered provider\nsender (import `@happyvertical/smrt-messages/providers/email` at server\nstartup). Tests inject a fake; nothing in the outbox reaches a provider SDK.\n\n## Opt-out ledger\n\n`NotificationOptOut` (`notification_opt_outs`, tenant-required, generated\nREST/MCP/CLI off) records one row per `(tenant_id, recipient_user_id, channel,\nscope)`: `channel` is `email`; `scope` is `*` (all notification email in the\ntenant) or a host key such as `project:<uuid>` (lowercase prefix, `:`, then\n`[A-Za-z0-9._:-]{1,200}`; malformed scopes throw). `optedOutAt` is set while\nopted out and cleared by an opt-in (the row stays as history); `updatedBy` is\nthe person's user id, or `system` for host code. It exists because\n`smrt-preferences` is owner-read only, while suppression runs where the recipient\nis not the caller (a manager enqueues, a worker dispatches).\n\n`NotificationOptOutService({ db })`:\n\n- `optOut({ tenantId, recipientUserId, channel, scope, principal? })` and\n `optIn(...)` are idempotent. With `principal: { userId, tenantId }` only\n `principal.userId === recipientUserId` may change the row, and only when\n `principal.tenantId` equals the request's tenant: a principal never acts in\n another tenant (`NotificationOptOutDeniedError`, reason `principal` or\n `tenant`). Without a principal the call is trusted host code that\n authenticated the recipient itself (e.g. a signed unsubscribe link, or a host\n route whose member belongs to a child tenant of the delivery tenant).\n- `isOptedOut({ tenantId, recipientUserId, channel, scope })` is the trusted\n suppression read, under `withTenant`; a `*` row matches every scope.\n- `listForRecipient({ tenantId, recipientUserId, principal })` returns only the\n recipient's own active opt-outs; any other principal is denied.\n\n```ts\nconst optOuts = new NotificationOptOutService({ db });\nnew NotificationOutboxService({\n // ...\n // `scopeOf` maps the host's own event to a scope; null = not opt-out-able.\n // A question's sourceRef names the question, not its project, so the host\n // resolves the project itself (scopeOf may be async).\n isSuppressed: optOutSuppression(optOuts, async (request) => {\n const projectId = await projectIdForSourceRef(request.tenantId, request.sourceRef);\n return projectId ? `project:${projectId}` : null;\n }),\n});\n```\n\nBecause the outbox re-checks at dispatch, an opt-out recorded after enqueue\ncancels the pending delivery before handoff. Tests:\n`src/__tests__/notification-opt-out*.test.ts`.\n\n## Schema\n\nNew tables `notification_opt_outs` (same rules) and `notification_deliveries` (tenant-required, generated REST/MCP/CLI\noff): consumers run `db:migrate`. `recipient_user_id` is a cross-package uuid\nref to `smrt-users:User`; `account_id`/`message_id` are FKs to `accounts` and\n`messages`.\n\n## Protected canonical Message handoff\n\n`capabilities.protectedCanonicalSend` advertises the canonical-send guard in\naddition to `requiredPolicy`. A protected delivery's single canonical Email has\na durable `metadata.__smrtProtectedOutbox` marker, backed by the delivery's\n`messageId`. The marker is not authorization. Protected rows cannot clear or\nchange their marker, correlation, original identity, body, sender/recipients,\ncc/bcc, HTML, raw content or headers through ordinary saves. Constructor-captured\noriginal identity plus persisted old-row inspection also protect a loaded object\nwhose public id/correlation/metadata fields were changed and clones retaining\nprotected provenance. Ordinary model/collection deletion retains that evidence.\nAn existing protected canonical row receives the marker before dispatch; this is\nnon-authorizing migration of metadata, not permission to send.\n\nDirect `Message.send`, `retrySend`, and default `EmailSender.send` refuse protected\nmail without the outbox's private, exact, one-use handoff scope. The scope is\ncreated only after the trusted named policy resolves/authorizes actual bytes.\nIt binds tenant, delivery, canonical message, lease, attempt/state version,\napproved content/destinations and attachment names/types/IDs/dispositions/digests.\nNo capability mint is exported from the package root. Custom trusted transports\nreceive bytes only after a fresh durable lease check. The canonical sender and\nactual default EmailClient boundary repeat that check after attachment I/O;\neffective account-default sender and all destinations/body parts must match.\nSend-time attachment buffers are privately copied before the SDK receives them.\n\nConcurrent/reentrant second calls and detached tasks using an inherited async\ncontext fail closed: scope state is deactivated when its transport callback\nreturns. A local guard denial is a definite pre-provider refusal, not an unknown\nacceptance. Protected lifecycle/unknown-outcome metadata cannot be rewritten by\nordinary saves to make reconciliation mistake a prior uncertain handoff for a\nsafe retry. Existing unknown outcomes retain the normal reconciliation barrier.\nOrdinary unprotected messages, including unsaved direct-sender drafts, retain\ntheir existing contract.\n\nThe trusted-provider boundary is explicit: these guards constrain public package\nMessage/EmailSender and outbox paths. Arbitrary trusted server code calling a\nprovider SDK outside this package, or a custom transport deliberately sending\nthrough its own SDK, remains responsible for that code's authority and behavior.\n\n## Typed external contacts\n\nProtected email also accepts exactly one `recipientProfileId` instead of a User. See [profile recipients](profile-recipients.md) for reserved profile policy identity, current Profile/host relationship checks, explicit schema plan/apply prerequisites and compatibility evidence. No auth account is fabricated.\n\n## Browser/server boundary (#4747)\n\nProtected notifications add no Node-only imports to the browser graph. Existing\npackage/dependency browser-capability declarations still apply. Protected canonical\nhandoff and schema maintenance require the server host: private SHA-256, strict\nbinding comparison, async-local scope, Core migration rebuild operations and\npublic Profile lookup/normalization live behind stable package\n`host.js` / `host.browser.js` entries, following Core's\nexisting browser-map pattern. The browser counterpart never mints or inherits\nhandoff authority and throws before protected operations or maintenance; it does\nnot install a global context, skip durable guards or approximate hashing. Public\nserver APIs and canonical persisted association/lease/one-use checks are unchanged.\nThe owning dist browser bundle gate must remain green without a ratchet waiver.\n\n## Blocked-prefix liveness and final-write protection\n\nThe dispatch limit bounds acquired leases, rather than blocked diagnostics.\nDiscovery walks bounded pages ordered by physical due/lease timestamp and UUID,\nrecovering expired leases before pending rows. Its cursor captures timestamp text\nin the database before hydration, preserving PostgreSQL microseconds. A blocked\npolicy or Profile cannot repeatedly fill the first page and starve eligible mail\nin its own tenant or another authorized scope. Explicit delivery selectors and\npre-discovery tenant authorization apply to every page. Repeated identical\nblocked errors do not rewrite the row; no backoff, cancellation or lease is added,\nso a currently authorized configured host can deliver immediately.\n\nPublic delivery saves bind their checked snapshot through Core's mandatory\n`CollectionInterceptor.writeGuard` at the final persistence operation. An ordinary\nsave cannot adopt a protected natural identity inserted after its initial lookup.\nProtected saves bind tenant, typed recipient, source, policy/binding, content and\nlifecycle version/transition; a concurrent transition wins without being undone.\nThe private per-instance snapshot exists only during the save, and concurrent\nsaves of one instance are refused. Existing revision/sync options, ordinary\nnatural-key upsert and identical protected clones keep their normal contracts.\nSQLite uses Core's existing serialized compare/write; PostgreSQL places the\nmandatory predicate on its final UPDATE. No runtime schema or provider changes.\n"
|
|
12919
|
+
},
|
|
12920
|
+
{
|
|
12921
|
+
"path": "agents/profile-recipients.md",
|
|
12922
|
+
"module": "profile-recipients",
|
|
12923
|
+
"content": "# Protected external-contact email recipients\n\n`enqueueEmail` accepts exactly one of the existing `recipientUserId` or new `recipientProfileId`. Profile recipients are **email only** and reference a real tenant-owned public `smrt-profiles:Profile`; they do not need an auth User. No address, sentinel User, inferred tenant membership or recipient array is accepted. The one public `Profile.email` scalar is normalized by public `normalizeIdentityEmail`; the host's `resolveProfileRecipient` must authorize and return exactly that same current address. Multiple alternative emails are never selected implicitly.\n\nUse `profileNotificationPolicy('your.host-policy.v1')` as `requiredDispatchPolicy` and `kind = 'protected:' + policyId`. Register that exact trusted handler in `dispatchPolicies`, with immutable document/recipient binding. The reserved `profile:` policy namespace and `protected:profile:` kind force profile identity in saves, enqueue, leasing and canonical send. Changing/clearing kind, either identity, address or policy on an existing protected row or natural-key clone is denied. A trusted application inventing a completely separate ordinary event has a distinct identity and is outside the clone threat model.\n\nThe host must check the real resource relationship (for example issued Invoice → Customer.profileId and current Project → Client.contactProfileId), current actor/privacy/field grants and contact authority at preview, approval and every policy handoff. Generic tenancy alone cannot grant that relationship. The service also re-resolves the tenant-owned profile and host callback before leasing and immediately before provider transport, denying changed/deleted/foreign/unrelated contacts. Broad dispatch without the matching protected handler stays blocked with no attempt or provider call. Existing Message/EmailSender protected canonical checks cover profile sends too. Unknown outcomes remain uncertain until reconciliation; this API adds no resend shortcut.\n\nLegacy User inputs and `resolveRecipient` are unchanged. `NotificationSuppressionRequest` and existing `optOutSuppression` retain their required User ID and exact legacy TypeScript contract. Profiles use the separate optional `isProfileSuppressed(NotificationProfileSuppressionRequest)` hook, checked at enqueue and dispatch. It receives a real Profile ID and no User ID; a host supplies its current contact opt-out/resource policy. User opt-out preferences are never inferred onto unrelated external contacts. No global User opt-out row is fabricated.\n\n## Explicit schema maintenance\n\nInspect `planNotificationProfileRecipients(db, 'postgres' | 'sqlite')` first. It is read-only, returning SQL, unexpected invalid/duplicate row IDs and obsolete index inventory. On an existing PostgreSQL database, apply this explicit maintenance **before** the normal PostgreSQL-safe manifest migration: the expanded NULL-equal conflict key requires an atomic writer window and cannot be created by concurrent-index DDL. Then run normal manifest migration and verify the helper's empty replay. On a fresh database, create the normal manifest schema first, then apply this helper to install the physical typed CHECK.\n\n`migrateNotificationProfileRecipients` runs a fresh plan inside one transaction; PostgreSQL takes an exclusive table lock. It never performs runtime auto-DDL. The caller must use a root migration handle in an authorized writer maintenance window. The same public helper supports the legacy-table-first path; do not disable PostgreSQL-safe mode globally to get past its maintenance refusal.\n\nThe migration preserves all legacy row IDs, User references, message/provider IDs, outcome/history and existing data. Legacy rows become `recipientKind='user'` with actual NULL profile reference; profile rows require actual NULL User reference. User/profile unique indexes preserve logical idempotency independently. The expanded natural key `(tenant, kind, User, Profile, channel, sourceRef)` retains public raw-save/upsert semantics. PostgreSQL's obsolete four-column User-only `NULLS NOT DISTINCT` index is the **only** old index removed; otherwise it would collapse distinct profiles with the same source. Unexpected named index or CHECK drift and invalid/duplicate old identities require explicit reconciliation, never guessed repair.\n\nSQLite uses public core `buildSqliteRebuildStatements` to preserve the live DDL, indexes, triggers, rowids and data while relaxing the unused User column, adding profile fields and a real table CHECK. It refuses incoming-FK rebuild shapes and never disables foreign keys. Unsupported/ambiguous schema shapes fail closed for an explicit maintenance path. A failed DDL step rolls back old schema/indexes/history; replay after success is empty.\n\nProfile enqueue/dispatch verifies actual physical nullability, the complete CHECK predicate, required unique indexes and absence of the old four-column NND index. A migration ledger/version flag alone never opens this gate. Ordinary User use is not gated on the extra profile CHECK/index maintenance **after normal framework additive schema migration** has supplied the typed columns/defaults. A zero-new-column old database still needs that normal schema phase; this is not a claim that new ORM code writes old physical columns unchanged. The explicit helper also plans/applies from a legacy table directly during maintenance, preserving old rows. Mixed old binaries must be drained before migration/activation; old binaries cannot honor typed protected contracts. Follow released-package/schema adoption before enabling any real host.\n\n## Risk-based evidence matrix\n\n| Invariant | Reachable positive | Negative/failure | Actor/context | Executor/transaction | Runtime/dialect | External edge | Level |\n| --- | --- | --- | --- | --- | --- | --- | --- |\n| Typed contact identity | real Profile/no User, exact normalized email, actual attachment capture | both/neither/empty/wrong kind/channel/namespace, foreign/deleted/unrelated/revoked/changed contact | current explicit tenant/principal plus host resource policy | all source reads current; no caller address | Node26 SQLite worker, PG18 coordinator | public Profile + host callbacks | shared service suite |\n| Legacy logical identity | repeated/concurrent User enqueue and raw saves; profile same-key replay | profile/user collision, different profiles collapsing, wrong-tenant dispatch | explicit tenant dispatch/permission | DB unique indexes/null-aware upsert | SQLite/PG | no provider writes | source suites |\n| Protected lifecycle | approved bytes through registered handler only | new-ID natural-key clone changes binding/address/lifecycle; namespace downgrade; generic/direct send | trusted resource-aware policy, current actor | lease CAS + canonical one-use handoff | SQLite/PG | capture transport only | existing guard + profile suite |\n| Schema evolution | read-only plan, legacy data/FK/history preservation, atomic apply/replay | obsolete NND collapse, named index/CHECK drift, invalid duplicate old rows, partial DDL failure | maintenance owner only | exclusive PG lock or safe SQLite live-DDL rebuild, rollback | SQLite worker/PG18 coordinator | N/A: database-only maintenance | migration suites |\n\nWorker evidence is narrow in-process only. PostgreSQL migration/rollback, native app no-User PDF browser proof, full validation, canonical knowledge build and release adoption belong to integration. No customer/provider sends are authorized by this documentation.\n"
|
|
12752
12924
|
}
|
|
12753
12925
|
],
|
|
12754
12926
|
"recipes": [
|
|
@@ -5,10 +5,10 @@ description: "Unified multi-channel messaging with STI-based hierarchies"
|
|
|
5
5
|
status: "stable"
|
|
6
6
|
generated:
|
|
7
7
|
by: "smrt/scripts/generate-knowledge-okf.ts"
|
|
8
|
-
at: "2026-11-
|
|
8
|
+
at: "2026-11-08T11:50:49Z"
|
|
9
9
|
audience: "internal"
|
|
10
10
|
evidence_level: "source-inspected"
|
|
11
|
-
source_revision: "sha256:
|
|
11
|
+
source_revision: "sha256:98c94cbe1b459e5e653249097b9d303b5eb5f8520aa073292bb47e9750c2a913"
|
|
12
12
|
sources:
|
|
13
13
|
- id: "manifest"
|
|
14
14
|
resource: "https://github.com/happyvertical/smrt/blob/main/packages/messages/package.json"
|
|
@@ -19,6 +19,9 @@ sources:
|
|
|
19
19
|
- id: "agents-2"
|
|
20
20
|
resource: "https://github.com/happyvertical/smrt/blob/main/packages/messages/agents/notification-outbox.md"
|
|
21
21
|
title: "@happyvertical/smrt-messages packages/messages/agents/notification-outbox.md"
|
|
22
|
+
- id: "agents-3"
|
|
23
|
+
resource: "https://github.com/happyvertical/smrt/blob/main/packages/messages/agents/profile-recipients.md"
|
|
24
|
+
title: "@happyvertical/smrt-messages packages/messages/agents/profile-recipients.md"
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
# @happyvertical/smrt-messages
|
|
@@ -34,11 +37,13 @@ sources:
|
|
|
34
37
|
|
|
35
38
|
- `packages/messages/AGENTS.md`
|
|
36
39
|
- `packages/messages/agents/notification-outbox.md`
|
|
40
|
+
- `packages/messages/agents/profile-recipients.md`
|
|
37
41
|
|
|
38
42
|
## Framework dependencies
|
|
39
43
|
|
|
40
44
|
- [smrt-core](/components/smrt-core.md)
|
|
41
45
|
- [smrt-ledgers](/components/smrt-ledgers.md)
|
|
46
|
+
- [smrt-profiles](/components/smrt-profiles.md)
|
|
42
47
|
- [smrt-secrets](/components/smrt-secrets.md)
|
|
43
48
|
- [smrt-tenancy](/components/smrt-tenancy.md)
|
|
44
49
|
- [smrt-types](/components/smrt-types.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-messages",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.15",
|
|
4
4
|
"smrtJsdoc": "strict",
|
|
5
5
|
"description": "Unified multi-channel messaging with STI-based hierarchies",
|
|
6
6
|
"type": "module",
|
|
@@ -63,12 +63,13 @@
|
|
|
63
63
|
"@happyvertical/files": "^0.111.6",
|
|
64
64
|
"@happyvertical/logger": "^0.111.6",
|
|
65
65
|
"@happyvertical/messages": "^0.111.6",
|
|
66
|
-
"@happyvertical/smrt-core": "0.60.
|
|
67
|
-
"@happyvertical/smrt-
|
|
68
|
-
"@happyvertical/smrt-
|
|
69
|
-
"@happyvertical/smrt-
|
|
70
|
-
"@happyvertical/smrt-
|
|
71
|
-
"@happyvertical/smrt-
|
|
66
|
+
"@happyvertical/smrt-core": "0.60.15",
|
|
67
|
+
"@happyvertical/smrt-profiles": "0.60.15",
|
|
68
|
+
"@happyvertical/smrt-types": "0.60.15",
|
|
69
|
+
"@happyvertical/smrt-secrets": "0.60.15",
|
|
70
|
+
"@happyvertical/smrt-tenancy": "0.60.15",
|
|
71
|
+
"@happyvertical/smrt-ui": "0.60.15",
|
|
72
|
+
"@happyvertical/smrt-users": "0.60.15",
|
|
72
73
|
"@happyvertical/sql": "^0.111.6",
|
|
73
74
|
"@happyvertical/utils": "^0.111.6"
|
|
74
75
|
},
|
|
@@ -85,8 +86,8 @@
|
|
|
85
86
|
}
|
|
86
87
|
},
|
|
87
88
|
"devDependencies": {
|
|
88
|
-
"@happyvertical/smrt-ledgers": "0.60.
|
|
89
|
-
"@happyvertical/smrt-vitest": "0.60.
|
|
89
|
+
"@happyvertical/smrt-ledgers": "0.60.15",
|
|
90
|
+
"@happyvertical/smrt-vitest": "0.60.15",
|
|
90
91
|
"@sveltejs/package": "^2.5.8",
|
|
91
92
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
92
93
|
"@types/node": "24.13.6",
|
|
@@ -117,6 +118,9 @@
|
|
|
117
118
|
"registry": "https://registry.npmjs.org",
|
|
118
119
|
"access": "public"
|
|
119
120
|
},
|
|
121
|
+
"browser": {
|
|
122
|
+
"./dist/host.js": "./dist/host.browser.js"
|
|
123
|
+
},
|
|
120
124
|
"scripts": {
|
|
121
125
|
"build": "vite build --mode library && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json && node ../../scripts/prune-svelte-package-artifacts.js dist",
|
|
122
126
|
"build:watch": "vite build --mode library --watch",
|