@jsb188/mday 1.1.2

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 (202) hide show
  1. package/package.json +142 -0
  2. package/src/constants/agentMemory.ts +166 -0
  3. package/src/constants/agentNote.ts +212 -0
  4. package/src/constants/aiChat.ts +10 -0
  5. package/src/constants/billing.ts +126 -0
  6. package/src/constants/campaign.ts +236 -0
  7. package/src/constants/contact.ts +72 -0
  8. package/src/constants/csvExport.ts +133 -0
  9. package/src/constants/dataTable.ts +22 -0
  10. package/src/constants/dataTableFieldTypes.generated.ts +59 -0
  11. package/src/constants/docAccess.ts +33 -0
  12. package/src/constants/dt.ts +234 -0
  13. package/src/constants/email.ts +146 -0
  14. package/src/constants/fieldDoc.ts +104 -0
  15. package/src/constants/graphqlReactivity.ts +196 -0
  16. package/src/constants/inboundContact.ts +8 -0
  17. package/src/constants/integration.ts +13 -0
  18. package/src/constants/log.ts +21 -0
  19. package/src/constants/logDisplay/README.md +88 -0
  20. package/src/constants/logDisplay/defaults.ts +39 -0
  21. package/src/constants/logDisplay/index.ts +27 -0
  22. package/src/constants/logDisplay/operations/arable.ts +16 -0
  23. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  24. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  25. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  26. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  27. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  28. package/src/constants/logTaxonomy.generated.ts +2199 -0
  29. package/src/constants/noteDoc.ts +77 -0
  30. package/src/constants/organization.ts +60 -0
  31. package/src/constants/pageRoute.ts +23 -0
  32. package/src/constants/qrCode.ts +30 -0
  33. package/src/constants/sheet.ts +132 -0
  34. package/src/constants/sms.ts +18 -0
  35. package/src/constants/square.ts +16 -0
  36. package/src/constants/storage.ts +85 -0
  37. package/src/constants/usage.ts +82 -0
  38. package/src/constants/workflowSteps.ts +60 -0
  39. package/src/schemas/editLogEntry.ts +879 -0
  40. package/src/schemas/inboundContact.ts +77 -0
  41. package/src/schemas/logsQuery.ts +93 -0
  42. package/src/types/account.d.ts +81 -0
  43. package/src/types/agentMemory.d.ts +100 -0
  44. package/src/types/agentNote.d.ts +441 -0
  45. package/src/types/billing.d.ts +537 -0
  46. package/src/types/campaign.d.ts +1533 -0
  47. package/src/types/contact.d.ts +15 -0
  48. package/src/types/csvExport.d.ts +213 -0
  49. package/src/types/dataAnalysis.d.ts +44 -0
  50. package/src/types/dataTable.d.ts +159 -0
  51. package/src/types/definitionElement.d.ts +35 -0
  52. package/src/types/docAccess.d.ts +96 -0
  53. package/src/types/dt.d.ts +257 -0
  54. package/src/types/email.d.ts +231 -0
  55. package/src/types/emailReplyReport.d.ts +76 -0
  56. package/src/types/fieldDoc.d.ts +702 -0
  57. package/src/types/fieldDocContract.d.ts +90 -0
  58. package/src/types/inboundContact.d.ts +65 -0
  59. package/src/types/integration.d.ts +42 -0
  60. package/src/types/log.d.ts +338 -0
  61. package/src/types/logDisplay.types.ts +85 -0
  62. package/src/types/organization.d.ts +350 -0
  63. package/src/types/pageRoute.d.ts +48 -0
  64. package/src/types/qrCode.d.ts +96 -0
  65. package/src/types/richText.d.ts +81 -0
  66. package/src/types/sheet.d.ts +847 -0
  67. package/src/types/sms.d.ts +38 -0
  68. package/src/types/storage.d.ts +481 -0
  69. package/src/types/usage.d.ts +106 -0
  70. package/src/types/workflow.d.ts +435 -0
  71. package/src/utils/agentMemory.ts +15 -0
  72. package/src/utils/agentNote.ts +850 -0
  73. package/src/utils/aiChat.ts +43 -0
  74. package/src/utils/aiChatWork.ts +64 -0
  75. package/src/utils/billing.ts +37 -0
  76. package/src/utils/campaign.ts +1173 -0
  77. package/src/utils/campaignAI.ts +72 -0
  78. package/src/utils/campaignAccess.ts +239 -0
  79. package/src/utils/campaignEmail.ts +601 -0
  80. package/src/utils/campaignEmailCompiler.ts +372 -0
  81. package/src/utils/campaignEmailImages.ts +60 -0
  82. package/src/utils/campaignEmailStyles.ts +544 -0
  83. package/src/utils/campaignLifecycle.ts +104 -0
  84. package/src/utils/campaignPreview.ts +285 -0
  85. package/src/utils/contact.ts +50 -0
  86. package/src/utils/csvExport.ts +19 -0
  87. package/src/utils/dataTable.ts +311 -0
  88. package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
  89. package/src/utils/dataTableRelativeDate.ts +447 -0
  90. package/src/utils/definitionElement.ts +84 -0
  91. package/src/utils/docAccess.ts +383 -0
  92. package/src/utils/documentName.ts +53 -0
  93. package/src/utils/email.ts +379 -0
  94. package/src/utils/emailReplyReport.test.ts +187 -0
  95. package/src/utils/emailReplyReport.ts +143 -0
  96. package/src/utils/fieldDoc.ts +157 -0
  97. package/src/utils/fieldDocAnswers.ts +128 -0
  98. package/src/utils/fieldDocDefaults.ts +36 -0
  99. package/src/utils/fieldDocProgram.ts +36 -0
  100. package/src/utils/fieldDocSummary.ts +30 -0
  101. package/src/utils/log.ts +357 -0
  102. package/src/utils/logDisplay.helpers.ts +177 -0
  103. package/src/utils/logDisplay.ts +87 -0
  104. package/src/utils/logRegistryValue.ts +90 -0
  105. package/src/utils/logStoreRead.ts +262 -0
  106. package/src/utils/logTaxonomy.helpers.ts +17 -0
  107. package/src/utils/logTaxonomy.ts +76 -0
  108. package/src/utils/logTaxonomyDisplay.ts +395 -0
  109. package/src/utils/noteDoc.ts +609 -0
  110. package/src/utils/organization.ts +669 -0
  111. package/src/utils/pageRoute.ts +71 -0
  112. package/src/utils/qrCode.helpers.ts +189 -0
  113. package/src/utils/qrCode.test.ts +519 -0
  114. package/src/utils/qrCode.ts +273 -0
  115. package/src/utils/richTextHTML.ts +385 -0
  116. package/src/utils/sheet.ts +262 -0
  117. package/src/utils/sheetAxisMove.ts +616 -0
  118. package/src/utils/sheetBootstrap.ts +1402 -0
  119. package/src/utils/sheetCellLiteral.ts +101 -0
  120. package/src/utils/sheetCommand.ts +358 -0
  121. package/src/utils/sheetDesign.ts +705 -0
  122. package/src/utils/sheetExport.ts +186 -0
  123. package/src/utils/sheetFeatureReference.ts +183 -0
  124. package/src/utils/sheetFormulaArgs.ts +168 -0
  125. package/src/utils/sheetFormulaCompile.ts +475 -0
  126. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  127. package/src/utils/sheetFormulaCriteria.ts +656 -0
  128. package/src/utils/sheetFormulaDate.ts +444 -0
  129. package/src/utils/sheetFormulaEvaluation.ts +899 -0
  130. package/src/utils/sheetFormulaEvaluator.ts +997 -0
  131. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  132. package/src/utils/sheetFormulaLogical.ts +116 -0
  133. package/src/utils/sheetFormulaLookup.ts +488 -0
  134. package/src/utils/sheetFormulaMath.ts +48 -0
  135. package/src/utils/sheetFormulaParser.ts +729 -0
  136. package/src/utils/sheetFormulaRange.ts +330 -0
  137. package/src/utils/sheetFormulaReference.ts +703 -0
  138. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  139. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  140. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  141. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  142. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  143. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  144. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  145. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  146. package/src/utils/sheetFormulaText.ts +430 -0
  147. package/src/utils/sheetJournal.ts +200 -0
  148. package/src/utils/sheetNumberFormat.ts +1012 -0
  149. package/src/utils/sheetPreview.ts +68 -0
  150. package/src/utils/sheetSequence.ts +118 -0
  151. package/src/utils/sheetSnapshot.ts +739 -0
  152. package/src/utils/sheetStructureEdit.ts +914 -0
  153. package/src/utils/sheetStructureReferences.ts +389 -0
  154. package/src/utils/square.ts +32 -0
  155. package/src/utils/storage.ts +198 -0
  156. package/src/utils/table-route.ts +262 -0
  157. package/src/utils/time.ts +12 -0
  158. package/src/utils/workflow.ts +506 -0
  159. package/src/utils/workflowLogFingerprint.ts +302 -0
  160. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  161. package/src/utils/workflowProgress.ts +280 -0
  162. package/src/utils/workflowTriggers.ts +61 -0
  163. package/tests/agentNote.test.ts +395 -0
  164. package/tests/campaignAI.test.ts +119 -0
  165. package/tests/campaignAccess.test.ts +239 -0
  166. package/tests/campaignEmail.test.ts +441 -0
  167. package/tests/campaignLifecycle.test.ts +134 -0
  168. package/tests/campaignPublication.test.ts +309 -0
  169. package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
  170. package/tests/dataTableRelativeDate.test.ts +412 -0
  171. package/tests/docAccess.test.ts +525 -0
  172. package/tests/editLogEntry.test.ts +112 -0
  173. package/tests/email.test.ts +39 -0
  174. package/tests/fieldDocProgram.test.ts +114 -0
  175. package/tests/logDisplay.fixtures.ts +67 -0
  176. package/tests/logDisplay.test.ts +227 -0
  177. package/tests/noteDoc.test.ts +514 -0
  178. package/tests/richTextHTML.test.ts +185 -0
  179. package/tests/sheetAxisMove.test.ts +352 -0
  180. package/tests/sheetBootstrap.test.ts +1967 -0
  181. package/tests/sheetFeatureReference.test.ts +22 -0
  182. package/tests/sheetFormulaCriteria.test.ts +269 -0
  183. package/tests/sheetFormulaEvaluator.test.ts +468 -0
  184. package/tests/sheetFormulaFunctions.test.ts +538 -0
  185. package/tests/sheetFormulaLanguage.test.ts +361 -0
  186. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  187. package/tests/sheetFormulaParity.test.ts +188 -0
  188. package/tests/sheetFormulaRange.test.ts +167 -0
  189. package/tests/sheetFormulaReference.test.ts +78 -0
  190. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  191. package/tests/sheetFormulaTextDate.test.ts +512 -0
  192. package/tests/sheetSequence.test.ts +22 -0
  193. package/tests/sheetSnapshot.test.ts +134 -0
  194. package/tests/sheetStructureEdit.test.ts +537 -0
  195. package/tests/sheetStructureReferences.test.ts +589 -0
  196. package/tests/workflowLifecycleStatus.test.ts +60 -0
  197. package/tests/workflowLogFingerprint.test.ts +203 -0
  198. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  199. package/tests/workflowProgress.test.ts +180 -0
  200. package/tests/workflowTriggers.test.ts +29 -0
  201. package/tsconfig.json +12 -0
  202. package/vitest.config.ts +8 -0
package/package.json ADDED
@@ -0,0 +1,142 @@
1
+ {
2
+ "name": "@jsb188/mday",
3
+ "version": "1.1.2",
4
+ "description": "Functions and constants for Marketday app only.",
5
+ "license": "ISC",
6
+ "author": "jsb188",
7
+ "type": "module",
8
+ "exports": {
9
+ "./constants/qrCode.ts": "./src/constants/qrCode.ts",
10
+ "./types/qrCode.d.ts": "./src/types/qrCode.d.ts",
11
+ "./utils/qrCode.ts": "./src/utils/qrCode.ts",
12
+ "./constants/aiChat.ts": "./src/constants/aiChat.ts",
13
+ "./constants/agentMemory.ts": "./src/constants/agentMemory.ts",
14
+ "./constants/agentNote.ts": "./src/constants/agentNote.ts",
15
+ "./constants/log.ts": "./src/constants/log.ts",
16
+ "./constants/logTaxonomy.generated.ts": "./src/constants/logTaxonomy.generated.ts",
17
+ "./constants/email.ts": "./src/constants/email.ts",
18
+ "./constants/organization.ts": "./src/constants/organization.ts",
19
+ "./constants/pageRoute.ts": "./src/constants/pageRoute.ts",
20
+ "./constants/dataTable.ts": "./src/constants/dataTable.ts",
21
+ "./constants/dt.ts": "./src/constants/dt.ts",
22
+ "./constants/docAccess.ts": "./src/constants/docAccess.ts",
23
+ "./constants/graphqlReactivity.ts": "./src/constants/graphqlReactivity.ts",
24
+ "./constants/sheet.ts": "./src/constants/sheet.ts",
25
+ "./constants/storage.ts": "./src/constants/storage.ts",
26
+ "./constants/usage.ts": "./src/constants/usage.ts",
27
+ "./constants/billing.ts": "./src/constants/billing.ts",
28
+ "./constants/campaign.ts": "./src/constants/campaign.ts",
29
+ "./constants/contact.ts": "./src/constants/contact.ts",
30
+ "./constants/csvExport.ts": "./src/constants/csvExport.ts",
31
+ "./types/emailReplyReport.d.ts": "./src/types/emailReplyReport.d.ts",
32
+ "./utils/emailReplyReport.ts": "./src/utils/emailReplyReport.ts",
33
+ "./types/campaign.d.ts": "./src/types/campaign.d.ts",
34
+ "./types/contact.d.ts": "./src/types/contact.d.ts",
35
+ "./types/csvExport.d.ts": "./src/types/csvExport.d.ts",
36
+ "./utils/aiChat.ts": "./src/utils/aiChat.ts",
37
+ "./utils/aiChatWork.ts": "./src/utils/aiChatWork.ts",
38
+ "./utils/billing.ts": "./src/utils/billing.ts",
39
+ "./utils/campaign.ts": "./src/utils/campaign.ts",
40
+ "./utils/campaignAI.ts": "./src/utils/campaignAI.ts",
41
+ "./utils/campaignLifecycle.ts": "./src/utils/campaignLifecycle.ts",
42
+ "./utils/campaignEmail.ts": "./src/utils/campaignEmail.ts",
43
+ "./utils/campaignEmailCompiler.ts": "./src/utils/campaignEmailCompiler.ts",
44
+ "./utils/campaignEmailImages.ts": "./src/utils/campaignEmailImages.ts",
45
+ "./utils/campaignEmailStyles.ts": "./src/utils/campaignEmailStyles.ts",
46
+ "./utils/campaignPreview.ts": "./src/utils/campaignPreview.ts",
47
+ "./utils/campaignAccess.ts": "./src/utils/campaignAccess.ts",
48
+ "./utils/contact.ts": "./src/utils/contact.ts",
49
+ "./constants/fieldDoc.ts": "./src/constants/fieldDoc.ts",
50
+ "./constants/noteDoc.ts": "./src/constants/noteDoc.ts",
51
+ "./constants/sms.ts": "./src/constants/sms.ts",
52
+ "./types/email.d.ts": "./src/types/email.d.ts",
53
+ "./types/agentMemory.d.ts": "./src/types/agentMemory.d.ts",
54
+ "./types/agentNote.d.ts": "./src/types/agentNote.d.ts",
55
+ "./types/inboundContact.d.ts": "./src/types/inboundContact.d.ts",
56
+ "./types/storage.d.ts": "./src/types/storage.d.ts",
57
+ "./types/usage.d.ts": "./src/types/usage.d.ts",
58
+ "./types/billing.d.ts": "./src/types/billing.d.ts",
59
+ "./schemas/editLogEntry.ts": "./src/schemas/editLogEntry.ts",
60
+ "./schemas/inboundContact.ts": "./src/schemas/inboundContact.ts",
61
+ "./schemas/logsQuery.ts": "./src/schemas/logsQuery.ts",
62
+ "./schemas/childOrganizationsQuery.ts": "./src/schemas/childOrganizationsQuery.ts",
63
+ "./types/account.d.ts": "./src/types/account.d.ts",
64
+ "./types/integration.d.ts": "./src/types/integration.d.ts",
65
+ "./types/log.d.ts": "./src/types/log.d.ts",
66
+ "./types/organization.d.ts": "./src/types/organization.d.ts",
67
+ "./types/pageRoute.d.ts": "./src/types/pageRoute.d.ts",
68
+ "./types/fieldDoc.d.ts": "./src/types/fieldDoc.d.ts",
69
+ "./types/fieldDocContract.d.ts": "./src/types/fieldDocContract.d.ts",
70
+ "./types/definitionElement.d.ts": "./src/types/definitionElement.d.ts",
71
+ "./types/dataTable.d.ts": "./src/types/dataTable.d.ts",
72
+ "./types/dt.d.ts": "./src/types/dt.d.ts",
73
+ "./types/docAccess.d.ts": "./src/types/docAccess.d.ts",
74
+ "./types/sheet.d.ts": "./src/types/sheet.d.ts",
75
+ "./types/sms.d.ts": "./src/types/sms.d.ts",
76
+ "./types/workflow.d.ts": "./src/types/workflow.d.ts",
77
+ "./utils/agentNote.ts": "./src/utils/agentNote.ts",
78
+ "./utils/email.ts": "./src/utils/email.ts",
79
+ "./utils/logDisplay.ts": "./src/utils/logDisplay.ts",
80
+ "./types/logDisplay.types.ts": "./src/types/logDisplay.types.ts",
81
+ "./utils/log.ts": "./src/utils/log.ts",
82
+ "./utils/logTaxonomyDisplay.ts": "./src/utils/logTaxonomyDisplay.ts",
83
+ "./utils/logRegistryValue.ts": "./src/utils/logRegistryValue.ts",
84
+ "./utils/organization.ts": "./src/utils/organization.ts",
85
+ "./utils/pageRoute.ts": "./src/utils/pageRoute.ts",
86
+ "./utils/fieldDoc.ts": "./src/utils/fieldDoc.ts",
87
+ "./utils/fieldDocAnswers.ts": "./src/utils/fieldDocAnswers.ts",
88
+ "./utils/fieldDocSummary.ts": "./src/utils/fieldDocSummary.ts",
89
+ "./utils/fieldDocProgram.ts": "./src/utils/fieldDocProgram.ts",
90
+ "./utils/definitionElement.ts": "./src/utils/definitionElement.ts",
91
+ "./utils/storage.ts": "./src/utils/storage.ts",
92
+ "./utils/dataTable.ts": "./src/utils/dataTable.ts",
93
+ "./utils/dataTableFieldTypeRegistry.ts": "./src/utils/dataTableFieldTypeRegistry.ts",
94
+ "./utils/dataTableRelativeDate.ts": "./src/utils/dataTableRelativeDate.ts",
95
+ "./utils/docAccess.ts": "./src/utils/docAccess.ts",
96
+ "./utils/documentName.ts": "./src/utils/documentName.ts",
97
+ "./utils/noteDoc.ts": "./src/utils/noteDoc.ts",
98
+ "./utils/richTextHTML.ts": "./src/utils/richTextHTML.ts",
99
+ "./utils/sheet.ts": "./src/utils/sheet.ts",
100
+ "./utils/sheetDesign.ts": "./src/utils/sheetDesign.ts",
101
+ "./utils/sheetFormulaCompile.ts": "./src/utils/sheetFormulaCompile.ts",
102
+ "./utils/sheetFormulaParser.ts": "./src/utils/sheetFormulaParser.ts",
103
+ "./utils/sheetFormulaSyntax.ts": "./src/utils/sheetFormulaSyntax.ts",
104
+ "./utils/sheetAxisMove.ts": "./src/utils/sheetAxisMove.ts",
105
+ "./utils/sheetCommand.ts": "./src/utils/sheetCommand.ts",
106
+ "./utils/sheetBootstrap.ts": "./src/utils/sheetBootstrap.ts",
107
+ "./utils/sheetJournal.ts": "./src/utils/sheetJournal.ts",
108
+ "./utils/sheetSequence.ts": "./src/utils/sheetSequence.ts",
109
+ "./utils/sheetSnapshot.ts": "./src/utils/sheetSnapshot.ts",
110
+ "./utils/sheetStructureEdit.ts": "./src/utils/sheetStructureEdit.ts",
111
+ "./utils/sheetStructureReferences.ts": "./src/utils/sheetStructureReferences.ts",
112
+ "./utils/sheetExport.ts": "./src/utils/sheetExport.ts",
113
+ "./utils/sheetNumberFormat.ts": "./src/utils/sheetNumberFormat.ts",
114
+ "./utils/sheetFormulaEvaluation.ts": "./src/utils/sheetFormulaEvaluation.ts",
115
+ "./utils/sheetFormulaEvaluator.ts": "./src/utils/sheetFormulaEvaluator.ts",
116
+ "./utils/sheetFormulaRange.ts": "./src/utils/sheetFormulaRange.ts",
117
+ "./utils/sheetFormulaReference.ts": "./src/utils/sheetFormulaReference.ts",
118
+ "./utils/sheetFormulaReferenceRewrite.ts": "./src/utils/sheetFormulaReferenceRewrite.ts",
119
+ "./utils/sheetFeatureReference.ts": "./src/utils/sheetFeatureReference.ts",
120
+ "./utils/table-route.ts": "./src/utils/table-route.ts",
121
+ "./utils/time.ts": "./src/utils/time.ts",
122
+ "./utils/square.ts": "./src/utils/square.ts",
123
+ "./utils/workflow.ts": "./src/utils/workflow.ts",
124
+ "./utils/workflowTriggers.ts": "./src/utils/workflowTriggers.ts",
125
+ "./utils/workflowLogFingerprint.ts": "./src/utils/workflowLogFingerprint.ts",
126
+ "./utils/workflowLogRevisionSnapshot.ts": "./src/utils/workflowLogRevisionSnapshot.ts",
127
+ "./utils/workflowProgress.ts": "./src/utils/workflowProgress.ts",
128
+ "./types/richText.d.ts": "./src/types/richText.d.ts",
129
+ "./utils/sheetCellLiteral.ts": "./src/utils/sheetCellLiteral.ts"
130
+ },
131
+ "dependencies": {
132
+ "luxon": "^3.7.2",
133
+ "parse5": "^8.0.1",
134
+ "zod": "^3.25.76"
135
+ },
136
+ "peerDependencies": {
137
+ "@jsb188/app": "1.1.2"
138
+ },
139
+ "scripts": {
140
+ "test": "vitest run --config ./vitest.config.ts --passWithNoTests"
141
+ }
142
+ }
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Agent memory; scope of a single remembered fact.
3
+ *
4
+ * ORGANIZATION - org-wide conventions; affects every user on every turn
5
+ * ACCOUNT - first-person memory BELONGING TO one user, never about them
6
+ * COUNTERPARTY - one customer, anchored on counterparties.id
7
+ */
8
+
9
+ export const AGENT_MEMORY_SCOPE_ENUMS = [
10
+ 'ORGANIZATION',
11
+ 'ACCOUNT',
12
+ 'COUNTERPARTY',
13
+ ] as const;
14
+
15
+ /**
16
+ * Agent memory; what kind of fact this is. Used for grouping in the UI and for
17
+ * ordering the injected block. Deliberately not rendered into the prompt.
18
+ */
19
+
20
+ export const AGENT_MEMORY_CATEGORY_ENUMS = [
21
+ 'UNIT',
22
+ 'PRODUCT',
23
+ 'PROCEDURE',
24
+ 'PREFERENCE',
25
+ 'OTHER',
26
+ ] as const;
27
+
28
+ /**
29
+ * Agent memory; injection gate. This is an inference gate, NOT an approval:
30
+ * memories inferred by the extractor land PROPOSED and are not injected until
31
+ * they are observed a second time. Explicit tool/UI writes go straight ACTIVE.
32
+ */
33
+
34
+ export const AGENT_MEMORY_STATUS_ENUMS = ['PROPOSED', 'ACTIVE'] as const;
35
+
36
+ /**
37
+ * Agent memory; how the row came to exist.
38
+ */
39
+
40
+ export const AGENT_MEMORY_CREATED_VIA_ENUMS = [
41
+ 'USER_EDIT',
42
+ 'AGENT_TOOL',
43
+ 'AGENT_EXTRACTOR',
44
+ ] as const;
45
+
46
+ /**
47
+ * Agent memory; which agent surface a memory applies to. NULL/empty means
48
+ * every surface. Deliberately excludes the Analyst: CSV export requests are
49
+ * explicit and already carry everything they need.
50
+ */
51
+
52
+ export const AGENT_MEMORY_SURFACE_ENUMS = [
53
+ 'CHAT',
54
+ 'EMAIL',
55
+ 'WORKFLOW',
56
+ ] as const;
57
+
58
+ /**
59
+ * Agent memory; valid "surfaceKey" values for the EMAIL surface.
60
+ *
61
+ * These are inbox KINDS, not subdomains. Several domains map to one inbox
62
+ * (general/info/inquiry all resolve to GENERAL_INQUIRY in DOMAIN_TO_INBOX), so
63
+ * keying memory on the raw subdomain would split one inbox's memory across its
64
+ * aliases. NULL "surfaceKey" applies to every inbox.
65
+ */
66
+
67
+ export const AGENT_MEMORY_EMAIL_SURFACE_KEYS = [
68
+ 'ASSISTANT',
69
+ 'GENERAL_INQUIRY',
70
+ 'ORDERS',
71
+ ] as const;
72
+
73
+ /**
74
+ * Agent memory; hard limits.
75
+ *
76
+ * Content is capped short on purpose - one fact, one sentence. Over-long
77
+ * content fails validation rather than truncating, so a memory is never
78
+ * silently cut in half.
79
+ *
80
+ * Injection caps are enforced in the query, never in the renderer, so a
81
+ * silently truncated memory set is impossible. "permanent" rows are ordered
82
+ * first and bypass the soft cap: dropping a memory someone explicitly
83
+ * protected is the worst available outcome.
84
+ */
85
+
86
+ export const AGENT_MEMORY_LIMITS = {
87
+ contentMaxLength: 255,
88
+ keyMaxLength: 80,
89
+ organizationCap: 20,
90
+ accountCap: 10,
91
+ counterpartyCap: 10,
92
+ maxCounterpartiesPerTurn: 3,
93
+ // Permanent rows bypass per-scope soft caps; this is the shared absolute
94
+ // ceiling across every applicable subject in one prompt.
95
+ permanentHardCeiling: 60,
96
+ // A fact seen twice is a pattern, not a one-off.
97
+ promoteAtObservedCount: 2,
98
+ // A pass proposing more than this is a bug or a bad prompt, not a
99
+ // conversation that genuinely taught the agent many standing rules.
100
+ maxExtractionOpsPerRun: 3,
101
+ // Recent turns the extractor reads. Enough to see a fact stated and
102
+ // confirmed, short enough that the model is not re-reading old chat.
103
+ extractionMessageWindow: 12,
104
+ // Temporary (expiring) ACCOUNT rows injected per viewer. Working state is a
105
+ // handful of "doing right now" facts; more than this is stale accumulation
106
+ // the maintenance pass should have cleaned.
107
+ temporaryCap: 5,
108
+ // A maintenance pass proposing more ops than this is a bug or a bad prompt,
109
+ // not an organization that genuinely churned that much working state.
110
+ maxMaintenanceOpsPerRun: 6,
111
+ // The furthest into the future any temporary memory may expire. Also caps
112
+ // EXTEND ops from the maintenance pass, so working state can never be
113
+ // promoted into de-facto durable memory by repeated extension.
114
+ temporaryMaxTTLMS: 7 * 24 * 60 * 60 * 1000,
115
+ } as const;
116
+
117
+ /**
118
+ * Agent memory; the expiry choices the remember_temporary tool exposes.
119
+ * A closed set on purpose - arbitrary dates would let one bad call park a
120
+ * "current activity" pointer weeks into the future.
121
+ */
122
+
123
+ export const AGENT_MEMORY_TEMPORARY_EXPIRY_ENUMS = [
124
+ 'END_OF_DAY',
125
+ '1_DAY',
126
+ '3_DAYS',
127
+ '7_DAYS',
128
+ ] as const;
129
+
130
+ /**
131
+ * Agent memory; canonical working-state slots shared by foreground tools,
132
+ * background extraction, and post-log session updates.
133
+ */
134
+
135
+ export const AGENT_MEMORY_TEMPORARY_TOPIC_ENUMS = [
136
+ 'CURRENT_SITE',
137
+ 'CURRENT_FIELD_DOC',
138
+ 'CURRENT_CUSTOMER',
139
+ 'CURRENT_TASK',
140
+ ] as const;
141
+
142
+ /**
143
+ * Agent memory; how long to wait before extracting memories from a settled
144
+ * conversation. Long enough that a burst of messages coalesces into one pass,
145
+ * short enough that a fact taught now is usable in the next session.
146
+ */
147
+
148
+ export const AGENT_MEMORY_EXTRACTION_DELAY_MS = 90_000;
149
+
150
+ /**
151
+ * Agent memory; how long after the first write in a burst to run a duplicate
152
+ * merge. Long enough that a teaching session lands as one pass; short enough
153
+ * that duplicates do not sit in the prompt for a working day.
154
+ */
155
+
156
+ export const AGENT_MEMORY_COMPACTION_DELAY_MS = 4 * 60 * 60 * 1000;
157
+
158
+ /**
159
+ * Agent memory; how long after the first temporary-memory write in a burst to
160
+ * run the maintenance pass (expired-row sweep + stale/duplicate cleanup of
161
+ * working state). Much shorter than compaction because temporary rows go stale
162
+ * in hours, not days - but long enough that one field session lands as one
163
+ * pass, not one per log.
164
+ */
165
+
166
+ export const AGENT_MEMORY_MAINTENANCE_DELAY_MS = 20 * 60 * 1000;
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Agent note; what one note summarizes. The three default kinds each have
3
+ * exactly one anchor (a web form campaign, an email campaign or a field
4
+ * doc). INSIGHT notes are trackers created only when a person asks for one,
5
+ * and have no anchor.
6
+ */
7
+
8
+ export const AGENT_NOTE_KIND_ENUMS = ['CAMPAIGN_FORM', 'CAMPAIGN_EMAIL', 'FIELD_DOC', 'INSIGHT', 'REMINDER'] as const;
9
+
10
+ /**
11
+ * Agent note; entity types a note can link to. A "watch" link makes a change
12
+ * to that entity refresh the note; an "owned" link marks an entity created for
13
+ * the note (a tracker ledger table or its managed workflow).
14
+ */
15
+
16
+ export const AGENT_NOTE_LINK_ENTITY_TYPE_ENUMS = [
17
+ 'CAMPAIGN',
18
+ 'FIELD_DOC',
19
+ 'DATA_TABLE',
20
+ 'SHEET',
21
+ 'WORKFLOW',
22
+ 'CHILD_ORG',
23
+ 'LOG_ACTIVITY',
24
+ 'LOG_ACTIVITY_GROUP',
25
+ ] as const;
26
+
27
+ /**
28
+ * Agent note; why the markdown sanitizer changed a body. Listed in the fixed
29
+ * order the sanitizer reports them, so the same input always yields the same
30
+ * issue list.
31
+ */
32
+
33
+ export const AGENT_NOTE_MARKDOWN_ISSUE_ENUMS = [
34
+ 'HTML_REMOVED',
35
+ 'LINK_REMOVED',
36
+ 'IMAGE_REMOVED',
37
+ 'CODE_REMOVED',
38
+ 'HEADING_FLATTENED',
39
+ 'BLOCK_FLATTENED',
40
+ 'STYLE_REMOVED',
41
+ 'TABLE_REMOVED',
42
+ 'TABLE_COLUMNS_TRUNCATED',
43
+ 'TABLE_ROWS_TRUNCATED',
44
+ 'TABLE_ROW_WIDTH_FIXED',
45
+ 'TABLE_CELL_TRUNCATED',
46
+ 'BODY_TRUNCATED',
47
+ ] as const;
48
+
49
+ /**
50
+ * Agent note; hard limits. Lengths are in characters.
51
+ *
52
+ * The body is a short summary (1-3 sentences) plus optional markdown tables,
53
+ * so table caps keep a note readable as a card. Table rows exclude the header.
54
+ * "indexCap" is how many active notes the prompt index lists.
55
+ * "researchMaxCharacters" is the refresh's conversation-research budget: what
56
+ * the research may read and keep, separate from the evidence pack's own budget.
57
+ */
58
+
59
+ export const AGENT_NOTE_LIMITS = {
60
+ emojiMaxLength: 8,
61
+ titleMaxLength: 255,
62
+ headlineMaxLength: 120,
63
+ headlineStorageMaxLength: 160,
64
+ bodyMaxLength: 6000,
65
+ focusMaxLength: 1000,
66
+ archiveReasonMaxLength: 255,
67
+ refreshErrorMaxLength: 1000,
68
+ tableMaxCount: 3,
69
+ tableMaxRows: 25,
70
+ tableMaxColumns: 14,
71
+ tableCellMaxLength: 120,
72
+ indexCap: 10,
73
+ researchMaxCharacters: 10000,
74
+ } as const;
75
+
76
+ /* Server-calculated reports retain complete rows and columns independently of the AI summary's card limits. */
77
+ export const AGENT_NOTE_CALCULATION_LIMITS = {
78
+ questions: 31,
79
+ rows: 500,
80
+ cellLength: 1000,
81
+ bodyLength: 100000,
82
+ } as const;
83
+
84
+ /**
85
+ * Agent note; lifecycle thresholds.
86
+ *
87
+ * A note is archived once its newest activity (data change, read, retention
88
+ * or focus change) is "cleanupDays" old ("insightCleanupDays" for INSIGHT
89
+ * notes), or "attentionCleanupDays" if that is longer while the note needs
90
+ * attention. An INSIGHT note whose managed workflow is active and can still
91
+ * fire is never archived for inactivity. The daily retention review asks
92
+ * about notes within "retentionLeadDays" of that cutoff and keeps a note
93
+ * visible when the predicate probability reaches "retentionProbability". A
94
+ * default note archived for inactivity (or for never publishing) returns
95
+ * when its source shows new activity; an INSIGHT (tracker) note stays
96
+ * archived, with its workflows, refreshes and model calls paused, until a
97
+ * person or the assistant unarchives it.
98
+ */
99
+
100
+ export const AGENT_NOTE_LIFECYCLE = {
101
+ cleanupDays: 14,
102
+ insightCleanupDays: 60,
103
+ attentionCleanupDays: 30,
104
+ retentionLeadDays: 7,
105
+ retentionProbability: 0.7,
106
+ retentionMaxQuestionsPerRequest: 25,
107
+ // Consecutive failed refreshes after which only the daily retry tries the note again
108
+ refreshFailureBudget: 5,
109
+ } as const;
110
+
111
+ /**
112
+ * Agent note; refresh timing. A change schedules a refresh "debounceMS" after
113
+ * the latest change, but never later than "maxWaitMS" after the first unserved
114
+ * change. The hourly sweep re-queues notes whose data changed more than
115
+ * "sweepStaleAfterMS" ago without a refresh.
116
+ */
117
+
118
+ export const AGENT_NOTE_REFRESH_TIMING = {
119
+ manualCooldownMS: 15 * 60 * 1000,
120
+ debounceMS: 12 * 60 * 1000,
121
+ maxWaitMS: 25 * 60 * 1000,
122
+ sweepStaleAfterMS: 30 * 60 * 1000,
123
+ // A never-published note waiting for a backfilling table or pending AI columns is checked again after this
124
+ preparingRecheckMS: 2 * 60 * 1000,
125
+ } as const;
126
+
127
+ /**
128
+ * Agent note; why an archived note was archived ("archiveSource"). Only
129
+ * INACTIVE and UNPUBLISHED archives of default kinds may restore themselves
130
+ * when their source shows new activity; a person, an agent, a merge, the
131
+ * anchor or a campaign delete keeps the note archived until someone restores it.
132
+ */
133
+
134
+ export const AGENT_NOTE_ARCHIVE_SOURCE_ENUMS = [
135
+ 'PERSON',
136
+ 'AGENT',
137
+ 'INACTIVE',
138
+ 'ANCHOR',
139
+ 'MERGED',
140
+ 'UNPUBLISHED',
141
+ 'CAMPAIGN_DELETED',
142
+ ] as const;
143
+
144
+ /**
145
+ * Agent note; who last set "needsAttention". The refresh model owns the flag
146
+ * unless a person set it.
147
+ */
148
+
149
+ export const AGENT_NOTE_ATTENTION_SET_BY_ENUMS = ['MODEL', 'PERSON'] as const;
150
+
151
+ /**
152
+ * Agent note; progress history event types (agent_note_events) and who caused
153
+ * each event.
154
+ */
155
+
156
+ export const AGENT_NOTE_EVENT_TYPE_ENUMS = ['PUBLISHED', 'FAILED', 'ARCHIVED', 'RESTORED', 'MERGED', 'FOCUS_CHANGED'] as const;
157
+
158
+ export const AGENT_NOTE_EVENT_ACTOR_TYPE_ENUMS = ['SYSTEM', 'MODEL', 'PERSON', 'AGENT'] as const;
159
+
160
+ /**
161
+ * Agent note; whether a note has a published body to show: READY (it has
162
+ * one), PREPARING (no body yet, still trying), FAILED (no body after the
163
+ * failure budget) or UNSUPPORTED (its evidence cannot be read).
164
+ */
165
+
166
+ export const AGENT_NOTE_PUBLISH_STATE_ENUMS = ['READY', 'PREPARING', 'FAILED', 'UNSUPPORTED'] as const;
167
+
168
+ /**
169
+ * Agent note; source scopes a note reads beyond its own anchor
170
+ * (agent_note_dependencies), so a change in any of them refreshes the note.
171
+ */
172
+
173
+ export const AGENT_NOTE_DEPENDENCY_SCOPE_TYPE_ENUMS = [
174
+ 'CAMPAIGN',
175
+ 'CAMPAIGN_TEMPLATE',
176
+ 'FIELD_DOC',
177
+ 'WORKFLOW',
178
+ 'CONVERSATION',
179
+ 'ORGANIZATION_MEMORY',
180
+ ] as const;
181
+
182
+ /**
183
+ * Agent note; effective priority, computed at read time:
184
+ * pinned × "pinnedBoost" + needsAttention × "attentionBoost" + importance
185
+ * (the refresh model's 0-100 value, "defaultImportance" when unset), minus
186
+ * "decayPerDay" for each day since the note was last published or its data
187
+ * changed, at most "maxDecay". About "attentionSoftTarget" notes per
188
+ * organization should need attention at a time; the daily pass demotes the
189
+ * lowest-priority model-set flags above "attentionDemoteAbove".
190
+ */
191
+
192
+ export const AGENT_NOTE_PRIORITY = {
193
+ pinnedBoost: 1000,
194
+ attentionBoost: 40,
195
+ defaultImportance: 50,
196
+ decayPerDay: 4,
197
+ maxDecay: 60,
198
+ attentionSoftTarget: 5,
199
+ attentionDemoteAbove: 8,
200
+ } as const;
201
+
202
+ /**
203
+ * Agent note; progress history sizes. Each note keeps its newest
204
+ * "keepPerNote" events; the refresh prompt sees "promptHistory" and the
205
+ * assistant's note read "toolHistory".
206
+ */
207
+
208
+ export const AGENT_NOTE_EVENT_LIMITS = {
209
+ keepPerNote: 30,
210
+ promptHistory: 5,
211
+ toolHistory: 10,
212
+ } as const;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Maximum length of an automatic or user-managed AI chat summary.
3
+ */
4
+
5
+ export const AI_CHAT_SUMMARY_MAX_LENGTH = 80;
6
+
7
+ /*
8
+ * Optional chat categories; null identifies an ordinary AI chat.
9
+ */
10
+ export const AI_CHAT_TYPE_ENUMS = ['ORCHESTRATOR'] as const;
@@ -0,0 +1,126 @@
1
+ /*
2
+ * Subscription plans. Plan identity always comes from the Stripe Product
3
+ * (metadata.nebulaPlanKey), never from a price id.
4
+ */
5
+ export const BILLING_PLAN_KEYS = ['BASIC', 'BUSINESS', 'ENTERPRISE'] as const;
6
+
7
+ /*
8
+ * Plans that can be purchased self-serve; Enterprise is always "contact us".
9
+ */
10
+ export const BILLING_SELF_SERVE_PLAN_KEYS = ['BASIC', 'BUSINESS'] as const;
11
+
12
+ /*
13
+ * Billing intervals offered for self-serve plan prices.
14
+ */
15
+ export const BILLING_INTERVALS = ['MONTH', 'YEAR'] as const;
16
+
17
+ /*
18
+ * Every Stripe recurring interval, uppercased, as stored on billing mirrors.
19
+ */
20
+ export const BILLING_STRIPE_INTERVALS = [
21
+ 'DAY',
22
+ 'WEEK',
23
+ 'MONTH',
24
+ 'YEAR',
25
+ ] as const;
26
+
27
+ /*
28
+ * Whether an organization's access is locked when its paid period lapses.
29
+ */
30
+ export const BILLING_ENFORCEMENT_ENUMS = ['ENFORCED', 'EXEMPT'] as const;
31
+
32
+ /*
33
+ * How a staff-recorded renewal outside Stripe was paid.
34
+ */
35
+ export const BILLING_MANUAL_GRANT_METHODS = [
36
+ 'CHECK',
37
+ 'WIRE',
38
+ 'ACH_TRANSFER',
39
+ 'CASH',
40
+ 'COMPED',
41
+ 'OTHER',
42
+ ] as const;
43
+
44
+ /*
45
+ * Processing states of a recorded Stripe webhook event.
46
+ */
47
+ export const BILLING_STRIPE_EVENT_STATUSES = [
48
+ 'RECEIVED',
49
+ 'PROCESSED',
50
+ 'IGNORED',
51
+ 'FAILED',
52
+ ] as const;
53
+
54
+ /*
55
+ * States of one self-serve purchase attempt.
56
+ */
57
+ export const BILLING_PURCHASE_ATTEMPT_STATUSES = [
58
+ 'PENDING',
59
+ 'SUBSCRIPTION_CREATED',
60
+ 'FAILED',
61
+ ] as const;
62
+
63
+ /*
64
+ * Channels that can receive a throttled "subscription expired" notice.
65
+ */
66
+ export const BILLING_ACCESS_NOTICE_CHANNELS = ['SMS'] as const;
67
+
68
+ /*
69
+ * Stripe intent the client confirms after starting a subscription.
70
+ */
71
+ export const BILLING_INTENT_TYPES = ['PAYMENT', 'SETUP'] as const;
72
+
73
+ /*
74
+ * Days of access kept after the paid-through date before the lock applies.
75
+ */
76
+ export const BILLING_GRACE_DAYS_DEFAULT = 14;
77
+
78
+ /*
79
+ * Minimum minutes between two lapse notices to one organization + recipient.
80
+ */
81
+ export const BILLING_ACCESS_NOTICE_INTERVAL_MINUTES = 10;
82
+
83
+ /*
84
+ * Stripe payment method types accepted for subscriptions (ACH uses instant
85
+ * verification only).
86
+ */
87
+ export const BILLING_PAYMENT_METHOD_TYPES = [
88
+ 'card',
89
+ 'us_bank_account',
90
+ ] as const;
91
+
92
+ /*
93
+ * Stripe subscription statuses that mean "the org has a live subscription".
94
+ */
95
+ export const BILLING_LIVE_SUBSCRIPTION_STATUSES = [
96
+ 'active',
97
+ 'trialing',
98
+ 'past_due',
99
+ 'unpaid',
100
+ ] as const;
101
+
102
+ /*
103
+ * Price lookup keys for the public (self-serve) prices.
104
+ */
105
+ export const BILLING_PRICE_LOOKUP_KEYS = {
106
+ BASIC: { MONTH: 'basic_monthly', YEAR: 'basic_yearly' },
107
+ BUSINESS: { MONTH: 'business_monthly', YEAR: 'business_yearly' },
108
+ } as const;
109
+
110
+ /*
111
+ * Stripe metadata keys written on our Stripe objects (and set by staff in the
112
+ * Dashboard).
113
+ */
114
+ export const BILLING_STRIPE_METADATA_KEYS = {
115
+ // DB organizations.id as a decimal string
116
+ organizationId: 'nebulaOrganizationId',
117
+ // On Products: BASIC | BUSINESS | ENTERPRISE
118
+ planKey: 'nebulaPlanKey',
119
+ // Always BILLING_STRIPE_METADATA_APP
120
+ app: 'nebulaApp',
121
+ } as const;
122
+
123
+ /*
124
+ * Value of the nebulaApp metadata key on every Stripe object we create.
125
+ */
126
+ export const BILLING_STRIPE_METADATA_APP = 'nebula';