opensentinel 3.6.1 → 3.7.0

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 (197) hide show
  1. package/README.md +12 -0
  2. package/dist/{agent-manager-7N7REQZQ.js → agent-manager-JZ4IM7XI.js} +8 -8
  3. package/dist/{agent-processor-I23VWQY3.js → agent-processor-DDDHC2SO.js} +22 -21
  4. package/dist/{agent-processor-I23VWQY3.js.map → agent-processor-DDDHC2SO.js.map} +1 -1
  5. package/dist/{alerting-4I37GG4U.js → alerting-LK7VVYTX.js} +4 -4
  6. package/dist/alerting-LK7VVYTX.js.map +1 -0
  7. package/dist/analyzer-OTWE3ARE.js +22 -0
  8. package/dist/{archiver-XLRIIXPY.js → archiver-FPGKRP6P.js} +16 -85
  9. package/dist/archiver-FPGKRP6P.js.map +1 -0
  10. package/dist/{audit-logger-AU3TMWKI.js → audit-logger-CI4WZQPD.js} +5 -5
  11. package/dist/bot-VDHBGUVI.js +47 -0
  12. package/dist/{brain-SLA474EU.js → brain-6QTXN4QP.js} +18 -17
  13. package/dist/{chunk-AR34B6XR.js → chunk-2I5QHYG6.js} +3 -3
  14. package/dist/chunk-2I5QHYG6.js.map +1 -0
  15. package/dist/chunk-3AWAWRWB.js +143 -0
  16. package/dist/chunk-3AWAWRWB.js.map +1 -0
  17. package/dist/{chunk-PUNIMPMY.js → chunk-4KIHDIXZ.js} +13 -2
  18. package/dist/chunk-4KIHDIXZ.js.map +1 -0
  19. package/dist/{chunk-GUKKW7JI.js → chunk-4WH6MFEW.js} +2 -2
  20. package/dist/chunk-4WH6MFEW.js.map +1 -0
  21. package/dist/{chunk-M7YLQHFP.js → chunk-56UJS2LA.js} +6 -6
  22. package/dist/{chunk-S4NJJS5C.js → chunk-5BTVJR7R.js} +3 -3
  23. package/dist/{chunk-HKOPRRDJ.js → chunk-5JJTLWOR.js} +3 -3
  24. package/dist/chunk-5JJTLWOR.js.map +1 -0
  25. package/dist/chunk-66SAOZPU.js +236 -0
  26. package/dist/chunk-66SAOZPU.js.map +1 -0
  27. package/dist/chunk-6HGMRR4J.js +113 -0
  28. package/dist/chunk-6HGMRR4J.js.map +1 -0
  29. package/dist/{chunk-BMOUYXLX.js → chunk-6ZNCY2GI.js} +5 -5
  30. package/dist/chunk-7BNFELEK.js +31 -0
  31. package/dist/chunk-7BNFELEK.js.map +1 -0
  32. package/dist/{chunk-KABG5PG3.js → chunk-BBN4VCNK.js} +4 -4
  33. package/dist/chunk-BBN4VCNK.js.map +1 -0
  34. package/dist/{chunk-4YJRBMMA.js → chunk-BNZHWAZC.js} +2 -2
  35. package/dist/{chunk-TAAZB5KN.js → chunk-CWT6CAE5.js} +2 -2
  36. package/dist/{chunk-UWUIJTT4.js → chunk-CZTMGHUC.js} +1 -1
  37. package/dist/chunk-CZTMGHUC.js.map +1 -0
  38. package/dist/chunk-DTISLIMB.js +89 -0
  39. package/dist/chunk-DTISLIMB.js.map +1 -0
  40. package/dist/{chunk-VKMFUIVA.js → chunk-GBVJTRXS.js} +2 -2
  41. package/dist/{chunk-MFK34XSY.js → chunk-GJETKBOY.js} +15 -15
  42. package/dist/chunk-GJETKBOY.js.map +1 -0
  43. package/dist/{chunk-HTF2GIQC.js → chunk-GW6V4D43.js} +2 -2
  44. package/dist/chunk-GW6V4D43.js.map +1 -0
  45. package/dist/{chunk-2RGPWU77.js → chunk-HJSEEFO3.js} +2 -2
  46. package/dist/{chunk-JOA5A3G3.js → chunk-HQZQFEAX.js} +5 -5
  47. package/dist/{chunk-45YXODSB.js → chunk-J4JW73TT.js} +2 -2
  48. package/dist/{chunk-KT7NLIXP.js → chunk-JHYYFPKX.js} +2 -2
  49. package/dist/{chunk-XMCVRVTF.js → chunk-P64EV4YY.js} +1 -1
  50. package/dist/chunk-P64EV4YY.js.map +1 -0
  51. package/dist/chunk-PBOCSGNL.js +84 -0
  52. package/dist/chunk-PBOCSGNL.js.map +1 -0
  53. package/dist/{chunk-H3BOLSTS.js → chunk-PD3CTDO6.js} +2 -2
  54. package/dist/{chunk-6UZPE35A.js → chunk-QPY3WRVM.js} +10 -87
  55. package/dist/chunk-QPY3WRVM.js.map +1 -0
  56. package/dist/{chunk-AD6YEH6U.js → chunk-S2EOIVF4.js} +590 -91
  57. package/dist/chunk-S2EOIVF4.js.map +1 -0
  58. package/dist/chunk-SDLOMKCW.js +213 -0
  59. package/dist/chunk-SDLOMKCW.js.map +1 -0
  60. package/dist/{chunk-7MZN73J2.js → chunk-TKBVW7ZJ.js} +4 -4
  61. package/dist/{chunk-A24GPVLY.js → chunk-V3OKHQUX.js} +5 -5
  62. package/dist/{chunk-NMSHVO5O.js → chunk-WMDVOWN6.js} +4 -4
  63. package/dist/{chunk-643M3AP5.js → chunk-WMFYI7XC.js} +7 -7
  64. package/dist/{chunk-6LTLIYAQ.js → chunk-YEDEAX6Y.js} +3 -3
  65. package/dist/{chunk-NYVBXUGD.js → chunk-ZIBRVA3Y.js} +60 -1
  66. package/dist/chunk-ZIBRVA3Y.js.map +1 -0
  67. package/dist/{chunk-6JY4HNUH.js → chunk-ZMML6T63.js} +361 -24
  68. package/dist/chunk-ZMML6T63.js.map +1 -0
  69. package/dist/{chunk-FFV2SXFD.js → chunk-ZVHG4KF2.js} +4 -4
  70. package/dist/cli.js.map +1 -1
  71. package/dist/commands/setup.js +1 -1
  72. package/dist/commands/start.js +2 -2
  73. package/dist/commands/status.js +1 -1
  74. package/dist/commands/stop.js +1 -1
  75. package/dist/commands/utils.js +1 -1
  76. package/dist/{cost-tracker-EMOIOYH7.js → cost-tracker-KZQSTSE2.js} +2 -2
  77. package/dist/{db-LRIOKQBO.js → db-I7MNG6CL.js} +10 -4
  78. package/dist/{discord-NKR3X4AV.js → discord-6UQHCN27.js} +24 -23
  79. package/dist/{documents-EYIYLZK2.js → documents-PFHSK7SZ.js} +19 -19
  80. package/dist/{email-EAQNULVD.js → email-6OIN4SYL.js} +22 -21
  81. package/dist/email-6OIN4SYL.js.map +1 -0
  82. package/dist/{enhanced-retrieval-OGHT6TS5.js → enhanced-retrieval-JWX2HWU4.js} +7 -6
  83. package/dist/{enhanced-retrieval-OGHT6TS5.js.map → enhanced-retrieval-JWX2HWU4.js.map} +1 -1
  84. package/dist/enrichment-pipeline-7FE5R5ZI.js +14 -0
  85. package/dist/{entity-resolution-4X4JU43O.js → entity-resolution-7Z6STVXX.js} +5 -5
  86. package/dist/{env-CHOFICED.js → env-GN5VHI43.js} +2 -2
  87. package/dist/{error-tracker-SVQSDQDW.js → error-tracker-64DEH3D7.js} +6 -6
  88. package/dist/{github-KGNILDWJ.js → github-DUWSXCNP.js} +4 -4
  89. package/dist/graph-client-NB475AK5.js +17 -0
  90. package/dist/{imessage-V2XNDDHT.js → imessage-DSGSGUZS.js} +19 -18
  91. package/dist/{inbox-summarizer-DKKRYXDR.js → inbox-summarizer-F2KAU72V.js} +19 -18
  92. package/dist/{incident-response-ZTIKUWEO.js → incident-response-E3UGMX5G.js} +5 -5
  93. package/dist/incident-response-E3UGMX5G.js.map +1 -0
  94. package/dist/{knowledge-base-J7PJ7MZ3.js → knowledge-base-5SMMOGQJ.js} +5 -5
  95. package/dist/lib.d.ts +21 -0
  96. package/dist/lib.js +64 -57
  97. package/dist/lib.js.map +1 -1
  98. package/dist/{matrix-XHTR53VQ.js → matrix-WYGEOZL5.js} +18 -17
  99. package/dist/{matrix-XHTR53VQ.js.map → matrix-WYGEOZL5.js.map} +1 -1
  100. package/dist/{mcp-3C2TN67D.js → mcp-DJ2QDA6A.js} +2 -2
  101. package/dist/{metrics-VJDWQWU7.js → metrics-BH3ZLGEV.js} +5 -5
  102. package/dist/{multi-user-S56GUD6L.js → multi-user-XAEMB244.js} +4 -4
  103. package/dist/oauth-UPJYFOVU.js +34 -0
  104. package/dist/{ocr-LGUIPKVZ.js → ocr-UONKTQU7.js} +4 -4
  105. package/dist/{presentations-HXTAMGHT.js → presentations-UOET2FVZ.js} +2 -2
  106. package/dist/{providers-H6YIC3MG.js → providers-2YQ6E3IF.js} +3 -3
  107. package/dist/{scheduler-CA5UNHZV.js → scheduler-6PLLAQI7.js} +21 -20
  108. package/dist/{schema-ALJ67YVG.js → schema-ETY7L2VA.js} +8 -2
  109. package/dist/sharepoint-V5P4Q62L.js +30 -0
  110. package/dist/{signal-X7IQJGRQ.js → signal-7D5EPGVL.js} +19 -18
  111. package/dist/{slack-P2LFUJUQ.js → slack-KSS6YK5Z.js} +23 -22
  112. package/dist/slack-KSS6YK5Z.js.map +1 -0
  113. package/dist/{sms-4VME2HUL.js → sms-CSUCC7HL.js} +3 -3
  114. package/dist/sms-CSUCC7HL.js.map +1 -0
  115. package/dist/{src-S5KX4YEV.js → src-GO7GGW7O.js} +48 -41
  116. package/dist/{src-S5KX4YEV.js.map → src-GO7GGW7O.js.map} +1 -1
  117. package/dist/token-store-SEWRX6RE.js +20 -0
  118. package/dist/token-store-SEWRX6RE.js.map +1 -0
  119. package/dist/{tools-FGPN522P.js → tools-PJZ6RI4P.js} +18 -17
  120. package/dist/tools-PJZ6RI4P.js.map +1 -0
  121. package/dist/{whatsapp-KRPQ4YUX.js → whatsapp-DWXK25V2.js} +19 -18
  122. package/dist/whatsapp-DWXK25V2.js.map +1 -0
  123. package/dist/{word-document-D6N2C47N.js → word-document-AV3YB4L2.js} +2 -2
  124. package/dist/{workflow-store-ZYAYE5P6.js → workflow-store-5Y56GUP7.js} +4 -4
  125. package/drizzle/0002_mushy_master_mold.sql +139 -139
  126. package/drizzle/0003_overjoyed_rhodey.sql +46 -0
  127. package/drizzle/meta/0002_snapshot.json +3636 -3636
  128. package/drizzle/meta/0003_snapshot.json +3946 -0
  129. package/drizzle/meta/_journal.json +7 -0
  130. package/package.json +110 -110
  131. package/dist/alerting-4I37GG4U.js.map +0 -1
  132. package/dist/archiver-XLRIIXPY.js.map +0 -1
  133. package/dist/bot-MU2TJQ3Y.js +0 -46
  134. package/dist/chunk-6JY4HNUH.js.map +0 -1
  135. package/dist/chunk-6UZPE35A.js.map +0 -1
  136. package/dist/chunk-AD6YEH6U.js.map +0 -1
  137. package/dist/chunk-AR34B6XR.js.map +0 -1
  138. package/dist/chunk-GUKKW7JI.js.map +0 -1
  139. package/dist/chunk-HKOPRRDJ.js.map +0 -1
  140. package/dist/chunk-HTF2GIQC.js.map +0 -1
  141. package/dist/chunk-KABG5PG3.js.map +0 -1
  142. package/dist/chunk-MFK34XSY.js.map +0 -1
  143. package/dist/chunk-NYVBXUGD.js.map +0 -1
  144. package/dist/chunk-PUNIMPMY.js.map +0 -1
  145. package/dist/chunk-UWUIJTT4.js.map +0 -1
  146. package/dist/chunk-XMCVRVTF.js.map +0 -1
  147. package/dist/email-EAQNULVD.js.map +0 -1
  148. package/dist/enrichment-pipeline-CMUVBDC7.js +0 -14
  149. package/dist/incident-response-ZTIKUWEO.js.map +0 -1
  150. /package/dist/{agent-manager-7N7REQZQ.js.map → agent-manager-JZ4IM7XI.js.map} +0 -0
  151. /package/dist/{audit-logger-AU3TMWKI.js.map → analyzer-OTWE3ARE.js.map} +0 -0
  152. /package/dist/{bot-MU2TJQ3Y.js.map → audit-logger-CI4WZQPD.js.map} +0 -0
  153. /package/dist/{brain-SLA474EU.js.map → bot-VDHBGUVI.js.map} +0 -0
  154. /package/dist/{cost-tracker-EMOIOYH7.js.map → brain-6QTXN4QP.js.map} +0 -0
  155. /package/dist/{chunk-M7YLQHFP.js.map → chunk-56UJS2LA.js.map} +0 -0
  156. /package/dist/{chunk-S4NJJS5C.js.map → chunk-5BTVJR7R.js.map} +0 -0
  157. /package/dist/{chunk-BMOUYXLX.js.map → chunk-6ZNCY2GI.js.map} +0 -0
  158. /package/dist/{chunk-4YJRBMMA.js.map → chunk-BNZHWAZC.js.map} +0 -0
  159. /package/dist/{chunk-TAAZB5KN.js.map → chunk-CWT6CAE5.js.map} +0 -0
  160. /package/dist/{chunk-VKMFUIVA.js.map → chunk-GBVJTRXS.js.map} +0 -0
  161. /package/dist/{chunk-2RGPWU77.js.map → chunk-HJSEEFO3.js.map} +0 -0
  162. /package/dist/{chunk-JOA5A3G3.js.map → chunk-HQZQFEAX.js.map} +0 -0
  163. /package/dist/{chunk-45YXODSB.js.map → chunk-J4JW73TT.js.map} +0 -0
  164. /package/dist/{chunk-KT7NLIXP.js.map → chunk-JHYYFPKX.js.map} +0 -0
  165. /package/dist/{chunk-H3BOLSTS.js.map → chunk-PD3CTDO6.js.map} +0 -0
  166. /package/dist/{chunk-7MZN73J2.js.map → chunk-TKBVW7ZJ.js.map} +0 -0
  167. /package/dist/{chunk-A24GPVLY.js.map → chunk-V3OKHQUX.js.map} +0 -0
  168. /package/dist/{chunk-NMSHVO5O.js.map → chunk-WMDVOWN6.js.map} +0 -0
  169. /package/dist/{chunk-643M3AP5.js.map → chunk-WMFYI7XC.js.map} +0 -0
  170. /package/dist/{chunk-6LTLIYAQ.js.map → chunk-YEDEAX6Y.js.map} +0 -0
  171. /package/dist/{chunk-FFV2SXFD.js.map → chunk-ZVHG4KF2.js.map} +0 -0
  172. /package/dist/{db-LRIOKQBO.js.map → cost-tracker-KZQSTSE2.js.map} +0 -0
  173. /package/dist/{discord-NKR3X4AV.js.map → db-I7MNG6CL.js.map} +0 -0
  174. /package/dist/{enrichment-pipeline-CMUVBDC7.js.map → discord-6UQHCN27.js.map} +0 -0
  175. /package/dist/{documents-EYIYLZK2.js.map → documents-PFHSK7SZ.js.map} +0 -0
  176. /package/dist/{entity-resolution-4X4JU43O.js.map → enrichment-pipeline-7FE5R5ZI.js.map} +0 -0
  177. /package/dist/{env-CHOFICED.js.map → entity-resolution-7Z6STVXX.js.map} +0 -0
  178. /package/dist/{error-tracker-SVQSDQDW.js.map → env-GN5VHI43.js.map} +0 -0
  179. /package/dist/{imessage-V2XNDDHT.js.map → error-tracker-64DEH3D7.js.map} +0 -0
  180. /package/dist/{github-KGNILDWJ.js.map → github-DUWSXCNP.js.map} +0 -0
  181. /package/dist/{inbox-summarizer-DKKRYXDR.js.map → graph-client-NB475AK5.js.map} +0 -0
  182. /package/dist/{knowledge-base-J7PJ7MZ3.js.map → imessage-DSGSGUZS.js.map} +0 -0
  183. /package/dist/{mcp-3C2TN67D.js.map → inbox-summarizer-F2KAU72V.js.map} +0 -0
  184. /package/dist/{metrics-VJDWQWU7.js.map → knowledge-base-5SMMOGQJ.js.map} +0 -0
  185. /package/dist/{ocr-LGUIPKVZ.js.map → mcp-DJ2QDA6A.js.map} +0 -0
  186. /package/dist/{providers-H6YIC3MG.js.map → metrics-BH3ZLGEV.js.map} +0 -0
  187. /package/dist/{multi-user-S56GUD6L.js.map → multi-user-XAEMB244.js.map} +0 -0
  188. /package/dist/{scheduler-CA5UNHZV.js.map → oauth-UPJYFOVU.js.map} +0 -0
  189. /package/dist/{schema-ALJ67YVG.js.map → ocr-UONKTQU7.js.map} +0 -0
  190. /package/dist/{presentations-HXTAMGHT.js.map → presentations-UOET2FVZ.js.map} +0 -0
  191. /package/dist/{signal-X7IQJGRQ.js.map → providers-2YQ6E3IF.js.map} +0 -0
  192. /package/dist/{slack-P2LFUJUQ.js.map → scheduler-6PLLAQI7.js.map} +0 -0
  193. /package/dist/{sms-4VME2HUL.js.map → schema-ETY7L2VA.js.map} +0 -0
  194. /package/dist/{tools-FGPN522P.js.map → sharepoint-V5P4Q62L.js.map} +0 -0
  195. /package/dist/{whatsapp-KRPQ4YUX.js.map → signal-7D5EPGVL.js.map} +0 -0
  196. /package/dist/{word-document-D6N2C47N.js.map → word-document-AV3YB4L2.js.map} +0 -0
  197. /package/dist/{workflow-store-ZYAYE5P6.js.map → workflow-store-5Y56GUP7.js.map} +0 -0
@@ -1,13 +1,24 @@
1
1
  import {
2
2
  textToSpeech
3
- } from "./chunk-45YXODSB.js";
3
+ } from "./chunk-J4JW73TT.js";
4
4
  import {
5
5
  transcribeAudio
6
- } from "./chunk-4YJRBMMA.js";
6
+ } from "./chunk-BNZHWAZC.js";
7
7
  import {
8
- getErrorStats,
9
- getRecentErrors
10
- } from "./chunk-7MZN73J2.js";
8
+ analyzeEmail,
9
+ listAnalyses,
10
+ persistAnalysis
11
+ } from "./chunk-SDLOMKCW.js";
12
+ import {
13
+ extractTextFromDriveItem,
14
+ getDefaultDrive,
15
+ getDriveItem,
16
+ getSite,
17
+ listDriveChildren,
18
+ listDriveRoot,
19
+ listDrives,
20
+ listSites
21
+ } from "./chunk-66SAOZPU.js";
11
22
  import {
12
23
  ImapClient,
13
24
  SmtpClient,
@@ -20,46 +31,78 @@ import {
20
31
  init_imap_client,
21
32
  init_smtp_client,
22
33
  prioritizeTools
23
- } from "./chunk-6JY4HNUH.js";
34
+ } from "./chunk-ZMML6T63.js";
24
35
  import {
25
- decryptField,
26
36
  deleteMemory,
27
37
  exportMemories,
28
38
  getMemoryById,
29
39
  searchMemories,
30
40
  storeMemory,
31
41
  updateMemory
32
- } from "./chunk-6UZPE35A.js";
42
+ } from "./chunk-QPY3WRVM.js";
43
+ import {
44
+ getErrorStats,
45
+ getRecentErrors
46
+ } from "./chunk-TKBVW7ZJ.js";
47
+ import {
48
+ deleteConnection,
49
+ getAccessToken,
50
+ getConnection,
51
+ saveConnection
52
+ } from "./chunk-6HGMRR4J.js";
53
+ import {
54
+ decryptField
55
+ } from "./chunk-DTISLIMB.js";
56
+ import {
57
+ buildAuthorizeUrl,
58
+ cleanupExpiredStates,
59
+ consumeState,
60
+ exchangeCodeForTokens,
61
+ generateCodeChallenge,
62
+ generateCodeVerifier,
63
+ getM365Config,
64
+ isM365Configured,
65
+ persistState
66
+ } from "./chunk-3AWAWRWB.js";
67
+ import {
68
+ getMe,
69
+ getMessage,
70
+ listMessages,
71
+ stripHtml
72
+ } from "./chunk-PBOCSGNL.js";
73
+ import {
74
+ createLogger
75
+ } from "./chunk-7BNFELEK.js";
33
76
  import {
34
77
  brainTelemetry
35
- } from "./chunk-643M3AP5.js";
78
+ } from "./chunk-WMFYI7XC.js";
36
79
  import {
37
80
  flushMetrics,
38
81
  getMetricAggregates,
39
82
  getMetricTimeSeries,
40
83
  recordMetric
41
- } from "./chunk-6LTLIYAQ.js";
84
+ } from "./chunk-YEDEAX6Y.js";
42
85
  import {
43
86
  costTracker
44
- } from "./chunk-BMOUYXLX.js";
87
+ } from "./chunk-6ZNCY2GI.js";
45
88
  import {
46
89
  createPublicRecords
47
- } from "./chunk-A24GPVLY.js";
90
+ } from "./chunk-V3OKHQUX.js";
48
91
  import {
49
92
  resolveEntity
50
- } from "./chunk-AR34B6XR.js";
93
+ } from "./chunk-2I5QHYG6.js";
51
94
  import {
52
95
  audit,
53
96
  getAuditChainIntegrity,
54
97
  logAudit,
55
98
  queryAuditLogs
56
- } from "./chunk-KABG5PG3.js";
99
+ } from "./chunk-BBN4VCNK.js";
57
100
  import {
58
101
  db
59
- } from "./chunk-S4NJJS5C.js";
102
+ } from "./chunk-5BTVJR7R.js";
60
103
  import {
61
104
  env
62
- } from "./chunk-PUNIMPMY.js";
105
+ } from "./chunk-4KIHDIXZ.js";
63
106
  import {
64
107
  apiKeys,
65
108
  conversations,
@@ -68,13 +111,13 @@ import {
68
111
  memories,
69
112
  messages,
70
113
  sessions
71
- } from "./chunk-NYVBXUGD.js";
114
+ } from "./chunk-ZIBRVA3Y.js";
72
115
  import {
73
116
  __require
74
117
  } from "./chunk-UP2VWCW5.js";
75
118
 
76
119
  // src/inputs/api/server.ts
77
- import { Hono as Hono14 } from "hono";
120
+ import { Hono as Hono15 } from "hono";
78
121
  import { cors } from "hono/cors";
79
122
  import { logger } from "hono/logger";
80
123
  import { desc as desc2, eq as eq4 } from "drizzle-orm";
@@ -171,7 +214,17 @@ function timingSafeEqual(a, b) {
171
214
  }
172
215
 
173
216
  // src/core/security/auth-middleware.ts
174
- var PUBLIC_ROUTES = ["/health", "/api/system/status", "/api/pair", "/api/sdk/register"];
217
+ var PUBLIC_ROUTES = [
218
+ "/health",
219
+ "/api/system/status",
220
+ "/api/pair",
221
+ "/api/sdk/register",
222
+ // M365 OAuth endpoints — user is unauthenticated during login + callback.
223
+ "/api/m365/auth/login",
224
+ "/api/m365/auth/callback",
225
+ // Legacy Entra redirect URI (aliased to /api/m365/auth/callback).
226
+ "/api/callbacks/outlook"
227
+ ];
175
228
  var SDK_PREFIX = "/api/sdk/";
176
229
  function authMiddleware() {
177
230
  return async (c, next) => {
@@ -561,7 +614,7 @@ osint.post("/enrich", async (c) => {
561
614
  requestId: `osint-enrich-${enrichStart}`,
562
615
  data: { toolName: "osint_enrich", entityId: body.entityId, entityName, sources: body.sources, depth: body.depth ?? 1 }
563
616
  });
564
- const { enrichEntity } = await import("./enrichment-pipeline-CMUVBDC7.js");
617
+ const { enrichEntity } = await import("./enrichment-pipeline-7FE5R5ZI.js");
565
618
  const result = await enrichEntity(body.entityId, body.sources, body.depth ?? 1);
566
619
  const enrichLatency = Date.now() - enrichStart;
567
620
  brainTelemetry.emitEvent({
@@ -670,7 +723,7 @@ osint.get("/financial-flow", async (c) => {
670
723
  osint.get("/duplicates", async (c) => {
671
724
  try {
672
725
  const threshold = parseFloat(c.req.query("threshold") || "0.85");
673
- const { findDuplicates } = await import("./entity-resolution-4X4JU43O.js");
726
+ const { findDuplicates } = await import("./entity-resolution-7Z6STVXX.js");
674
727
  const duplicates = await findDuplicates(threshold);
675
728
  return c.json({ duplicates, total: duplicates.length });
676
729
  } catch (error) {
@@ -821,6 +874,17 @@ email.use("*", async (c, next) => {
821
874
  }
822
875
  await next();
823
876
  });
877
+ email.get("/accounts", async (c) => {
878
+ const accounts = [];
879
+ if (env.EMAIL_USER) accounts.push(env.EMAIL_USER);
880
+ const extra = process.env.EMAIL_ACCOUNTS;
881
+ if (extra) {
882
+ for (const addr of extra.split(",").map((a) => a.trim()).filter(Boolean)) {
883
+ if (!accounts.includes(addr)) accounts.push(addr);
884
+ }
885
+ }
886
+ return c.json({ accounts });
887
+ });
824
888
  email.get("/folders", async (c) => {
825
889
  const emailAddress = c.req.query("email_address");
826
890
  if (!emailAddress) {
@@ -1211,7 +1275,7 @@ sdkRoutes.post("/chat", async (c) => {
1211
1275
  }
1212
1276
  messages2.push({ role: "user", content: body.message });
1213
1277
  const toolsUsed = [];
1214
- const response = body.useTools !== false ? await chatWithTools(messages2, `sdk:${app2.id}`, (tool) => toolsUsed.push(tool), { appType: app2.type }) : await (await import("./brain-SLA474EU.js")).chat(messages2, body.systemPrompt);
1278
+ const response = body.useTools !== false ? await chatWithTools(messages2, `sdk:${app2.id}`, (tool) => toolsUsed.push(tool), { appType: app2.type }) : await (await import("./brain-6QTXN4QP.js")).chat(messages2, body.systemPrompt);
1215
1279
  await storeMemory({
1216
1280
  content: `[${app2.name}] User asked: ${body.message.slice(0, 200)}`,
1217
1281
  type: "episodic",
@@ -1257,7 +1321,7 @@ sdkRoutes.post("/notify", async (c) => {
1257
1321
  break;
1258
1322
  }
1259
1323
  case "discord": {
1260
- const { createDiscordBot } = await import("./discord-NKR3X4AV.js");
1324
+ const { createDiscordBot } = await import("./discord-6UQHCN27.js");
1261
1325
  const discord = createDiscordBot({
1262
1326
  token: env.DISCORD_BOT_TOKEN || "",
1263
1327
  clientId: env.DISCORD_CLIENT_ID || ""
@@ -1269,7 +1333,7 @@ sdkRoutes.post("/notify", async (c) => {
1269
1333
  break;
1270
1334
  }
1271
1335
  case "slack": {
1272
- const { createSlackBot } = await import("./slack-P2LFUJUQ.js");
1336
+ const { createSlackBot } = await import("./slack-KSS6YK5Z.js");
1273
1337
  const slack = createSlackBot({
1274
1338
  token: env.SLACK_BOT_TOKEN || "",
1275
1339
  signingSecret: env.SLACK_SIGNING_SECRET || ""
@@ -1281,7 +1345,7 @@ sdkRoutes.post("/notify", async (c) => {
1281
1345
  break;
1282
1346
  }
1283
1347
  case "email": {
1284
- const { SmtpClient: SmtpClient2 } = await import("./email-EAQNULVD.js");
1348
+ const { SmtpClient: SmtpClient2 } = await import("./email-6OIN4SYL.js");
1285
1349
  const smtp = new SmtpClient2({
1286
1350
  host: env.EMAIL_SMTP_HOST || "localhost",
1287
1351
  port: env.EMAIL_SMTP_PORT || 587,
@@ -1591,7 +1655,7 @@ brainRouter.get("/scores", async (c) => {
1591
1655
  brainRouter.get("/agents", async (c) => {
1592
1656
  const userId = c.req.query("userId");
1593
1657
  try {
1594
- const { getUserAgents, getAllAgents } = await import("./agent-manager-7N7REQZQ.js");
1658
+ const { getUserAgents, getAllAgents } = await import("./agent-manager-JZ4IM7XI.js");
1595
1659
  const agents = userId ? await getUserAgents(userId, void 0, 20) : await getAllAgents(void 0, 50);
1596
1660
  return c.json(agents);
1597
1661
  } catch {
@@ -1610,7 +1674,11 @@ brainRouter.get("/memory-graph", async (c) => {
1610
1674
  const entityId = c.req.query("entityId");
1611
1675
  const limit = parseInt(c.req.query("limit") || "50");
1612
1676
  try {
1613
- const memories2 = await searchMemories("", void 0, limit);
1677
+ let memories2 = [];
1678
+ try {
1679
+ memories2 = await searchMemories("*", void 0, limit);
1680
+ } catch {
1681
+ }
1614
1682
  const nodes = [];
1615
1683
  const edges = [];
1616
1684
  for (const mem of memories2) {
@@ -1626,8 +1694,8 @@ brainRouter.get("/memory-graph", async (c) => {
1626
1694
  }
1627
1695
  if (entityId) {
1628
1696
  try {
1629
- const { db: db2 } = await import("./db-LRIOKQBO.js");
1630
- const { graphEntities: graphEntities2 } = await import("./schema-ALJ67YVG.js");
1697
+ const { db: db2 } = await import("./db-I7MNG6CL.js");
1698
+ const { graphEntities: graphEntities2 } = await import("./schema-ETY7L2VA.js");
1631
1699
  const { eq: eq5 } = await import("drizzle-orm");
1632
1700
  const [entity] = await db2.select().from(graphEntities2).where(eq5(graphEntities2.id, entityId)).limit(1);
1633
1701
  if (entity) {
@@ -1706,13 +1774,13 @@ brainRouter.post("/agents/spawn", async (c) => {
1706
1774
  if (!type || !objective) {
1707
1775
  return c.json({ error: "type and objective are required" }, 400);
1708
1776
  }
1709
- const { db: db2 } = await import("./db-LRIOKQBO.js");
1710
- const { users: users2 } = await import("./schema-ALJ67YVG.js");
1777
+ const { db: db2 } = await import("./db-I7MNG6CL.js");
1778
+ const { users: users2 } = await import("./schema-ETY7L2VA.js");
1711
1779
  let systemUser = await db2.select().from(users2).limit(1);
1712
1780
  if (systemUser.length === 0) {
1713
1781
  systemUser = await db2.insert(users2).values({ name: "Dashboard" }).returning();
1714
1782
  }
1715
- const { spawnAgent } = await import("./agent-manager-7N7REQZQ.js");
1783
+ const { spawnAgent } = await import("./agent-manager-JZ4IM7XI.js");
1716
1784
  const agent = await spawnAgent({
1717
1785
  type,
1718
1786
  objective,
@@ -1725,8 +1793,8 @@ brainRouter.post("/agents/spawn", async (c) => {
1725
1793
  });
1726
1794
  brainRouter.post("/agents/seed", async (c) => {
1727
1795
  try {
1728
- const { db: db2 } = await import("./db-LRIOKQBO.js");
1729
- const { subAgents, agentProgress, users: users2 } = await import("./schema-ALJ67YVG.js");
1796
+ const { db: db2 } = await import("./db-I7MNG6CL.js");
1797
+ const { subAgents, agentProgress, users: users2 } = await import("./schema-ETY7L2VA.js");
1730
1798
  let systemUser = await db2.select().from(users2).limit(1);
1731
1799
  if (systemUser.length === 0) {
1732
1800
  systemUser = await db2.insert(users2).values({
@@ -1856,8 +1924,8 @@ brainRouter.post("/agents/seed", async (c) => {
1856
1924
  });
1857
1925
  brainRouter.delete("/agents/history", async (c) => {
1858
1926
  try {
1859
- const { db: db2 } = await import("./db-LRIOKQBO.js");
1860
- const { subAgents } = await import("./schema-ALJ67YVG.js");
1927
+ const { db: db2 } = await import("./db-I7MNG6CL.js");
1928
+ const { subAgents } = await import("./schema-ETY7L2VA.js");
1861
1929
  const { inArray } = await import("drizzle-orm");
1862
1930
  await db2.delete(subAgents).where(inArray(subAgents.status, ["completed", "failed", "cancelled"]));
1863
1931
  return c.json({ success: true });
@@ -1876,7 +1944,7 @@ import { Hono as Hono6 } from "hono";
1876
1944
  var schedulerRouter = new Hono6();
1877
1945
  schedulerRouter.get("/jobs", async (c) => {
1878
1946
  try {
1879
- const { taskQueue, maintenanceQueue } = await import("./scheduler-CA5UNHZV.js");
1947
+ const { taskQueue, maintenanceQueue } = await import("./scheduler-6PLLAQI7.js");
1880
1948
  const [taskJobs, maintenanceJobs] = await Promise.allSettled([
1881
1949
  taskQueue?.getRepeatableJobs?.() ?? Promise.resolve([]),
1882
1950
  maintenanceQueue?.getRepeatableJobs?.() ?? Promise.resolve([])
@@ -1892,7 +1960,7 @@ schedulerRouter.get("/jobs", async (c) => {
1892
1960
  });
1893
1961
  schedulerRouter.get("/stats", async (c) => {
1894
1962
  try {
1895
- const { getQueueStats } = await import("./scheduler-CA5UNHZV.js");
1963
+ const { getQueueStats } = await import("./scheduler-6PLLAQI7.js");
1896
1964
  const stats = await getQueueStats();
1897
1965
  return c.json(stats);
1898
1966
  } catch (error) {
@@ -1905,7 +1973,7 @@ schedulerRouter.post("/jobs", async (c) => {
1905
1973
  if (!name || !pattern) {
1906
1974
  return c.json({ error: "name and pattern are required" }, 400);
1907
1975
  }
1908
- const { scheduleRecurring } = await import("./scheduler-CA5UNHZV.js");
1976
+ const { scheduleRecurring } = await import("./scheduler-6PLLAQI7.js");
1909
1977
  await scheduleRecurring(name, task || { type: "custom", name }, pattern);
1910
1978
  return c.json({ success: true }, 201);
1911
1979
  } catch (error) {
@@ -1915,7 +1983,7 @@ schedulerRouter.post("/jobs", async (c) => {
1915
1983
  schedulerRouter.delete("/jobs/:key", async (c) => {
1916
1984
  try {
1917
1985
  const key = decodeURIComponent(c.req.param("key"));
1918
- const { taskQueue } = await import("./scheduler-CA5UNHZV.js");
1986
+ const { taskQueue } = await import("./scheduler-6PLLAQI7.js");
1919
1987
  await taskQueue.removeRepeatableByKey(key);
1920
1988
  return c.json({ success: true });
1921
1989
  } catch (error) {
@@ -1929,7 +1997,7 @@ schedulerRouter.put("/jobs/:key", async (c) => {
1929
1997
  if (!pattern) {
1930
1998
  return c.json({ error: "pattern is required" }, 400);
1931
1999
  }
1932
- const { taskQueue, scheduleRecurring } = await import("./scheduler-CA5UNHZV.js");
2000
+ const { taskQueue, scheduleRecurring } = await import("./scheduler-6PLLAQI7.js");
1933
2001
  await taskQueue.removeRepeatableByKey(key);
1934
2002
  const jobName = name || key.split(":::")[0] || "custom-job";
1935
2003
  await scheduleRecurring(jobName, task || { type: "custom", name: jobName }, pattern);
@@ -1945,7 +2013,7 @@ import { Hono as Hono7 } from "hono";
1945
2013
  var alertsRouter = new Hono7();
1946
2014
  alertsRouter.get("/", async (c) => {
1947
2015
  try {
1948
- const alerting = await import("./alerting-4I37GG4U.js");
2016
+ const alerting = await import("./alerting-LK7VVYTX.js");
1949
2017
  await alerting.loadAlertHistoryFromDb?.();
1950
2018
  const active = alerting.getActiveAlerts?.() ?? [];
1951
2019
  const history = alerting.getAlertHistory?.(50) ?? [];
@@ -1958,7 +2026,7 @@ alertsRouter.post("/:id/acknowledge", async (c) => {
1958
2026
  try {
1959
2027
  const id = c.req.param("id");
1960
2028
  const { by } = await c.req.json();
1961
- const alerting = await import("./alerting-4I37GG4U.js");
2029
+ const alerting = await import("./alerting-LK7VVYTX.js");
1962
2030
  alerting.acknowledgeAlert?.(id, by || "web-user");
1963
2031
  return c.json({ success: true });
1964
2032
  } catch {
@@ -1969,7 +2037,7 @@ alertsRouter.post("/:id/resolve", async (c) => {
1969
2037
  try {
1970
2038
  const id = c.req.param("id");
1971
2039
  const { by } = await c.req.json();
1972
- const alerting = await import("./alerting-4I37GG4U.js");
2040
+ const alerting = await import("./alerting-LK7VVYTX.js");
1973
2041
  alerting.resolveAlert?.(id, by || "web-user");
1974
2042
  return c.json({ success: true });
1975
2043
  } catch {
@@ -1978,7 +2046,7 @@ alertsRouter.post("/:id/resolve", async (c) => {
1978
2046
  });
1979
2047
  alertsRouter.get("/rules", async (c) => {
1980
2048
  try {
1981
- const alerting = await import("./alerting-4I37GG4U.js");
2049
+ const alerting = await import("./alerting-LK7VVYTX.js");
1982
2050
  let rules = alerting.getAlertRules?.() ?? [];
1983
2051
  if (rules.length === 0 && alerting.initializeDefaultRules) {
1984
2052
  alerting.initializeDefaultRules();
@@ -1991,7 +2059,7 @@ alertsRouter.get("/rules", async (c) => {
1991
2059
  });
1992
2060
  alertsRouter.delete("/history", async (c) => {
1993
2061
  try {
1994
- const alerting = await import("./alerting-4I37GG4U.js");
2062
+ const alerting = await import("./alerting-LK7VVYTX.js");
1995
2063
  alerting.clearAlertHistory?.();
1996
2064
  return c.json({ success: true });
1997
2065
  } catch {
@@ -2001,7 +2069,7 @@ alertsRouter.delete("/history", async (c) => {
2001
2069
  alertsRouter.post("/rules", async (c) => {
2002
2070
  try {
2003
2071
  const rule = await c.req.json();
2004
- const alerting = await import("./alerting-4I37GG4U.js");
2072
+ const alerting = await import("./alerting-LK7VVYTX.js");
2005
2073
  alerting.addAlertRule?.(rule);
2006
2074
  return c.json({ success: true }, 201);
2007
2075
  } catch {
@@ -2011,7 +2079,7 @@ alertsRouter.post("/rules", async (c) => {
2011
2079
  alertsRouter.delete("/rules/:id", async (c) => {
2012
2080
  try {
2013
2081
  const id = c.req.param("id");
2014
- const alerting = await import("./alerting-4I37GG4U.js");
2082
+ const alerting = await import("./alerting-LK7VVYTX.js");
2015
2083
  const removed = alerting.removeAlertRule?.(id);
2016
2084
  if (!removed) {
2017
2085
  return c.json({ error: "Rule not found" }, 404);
@@ -2025,7 +2093,7 @@ alertsRouter.put("/rules/:id", async (c) => {
2025
2093
  try {
2026
2094
  const id = c.req.param("id");
2027
2095
  const updates = await c.req.json();
2028
- const alerting = await import("./alerting-4I37GG4U.js");
2096
+ const alerting = await import("./alerting-LK7VVYTX.js");
2029
2097
  const rules = alerting.getAlertRules?.() ?? [];
2030
2098
  const existing = rules.find((r) => r.id === id);
2031
2099
  if (!existing) {
@@ -2046,7 +2114,7 @@ import { v4 as uuidv4 } from "uuid";
2046
2114
  var webhooksRouter = new Hono8();
2047
2115
  webhooksRouter.get("/", async (c) => {
2048
2116
  try {
2049
- const { WorkflowStore } = await import("./workflow-store-ZYAYE5P6.js");
2117
+ const { WorkflowStore } = await import("./workflow-store-5Y56GUP7.js");
2050
2118
  const store = new WorkflowStore();
2051
2119
  const workflows = await store.getAllWorkflows();
2052
2120
  const results = workflows.map((w) => ({
@@ -2076,7 +2144,7 @@ webhooksRouter.post("/", async (c) => {
2076
2144
  if (!body.name) {
2077
2145
  return c.json({ error: "name is required" }, 400);
2078
2146
  }
2079
- const { WorkflowStore } = await import("./workflow-store-ZYAYE5P6.js");
2147
+ const { WorkflowStore } = await import("./workflow-store-5Y56GUP7.js");
2080
2148
  const store = new WorkflowStore();
2081
2149
  const now = /* @__PURE__ */ new Date();
2082
2150
  const workflow = await store.createWorkflow({
@@ -2102,7 +2170,7 @@ webhooksRouter.post("/", async (c) => {
2102
2170
  webhooksRouter.put("/:id/toggle", async (c) => {
2103
2171
  try {
2104
2172
  const id = c.req.param("id");
2105
- const { WorkflowStore } = await import("./workflow-store-ZYAYE5P6.js");
2173
+ const { WorkflowStore } = await import("./workflow-store-5Y56GUP7.js");
2106
2174
  const store = new WorkflowStore();
2107
2175
  const workflow = await store.getWorkflow(id);
2108
2176
  if (!workflow) return c.json({ error: "Workflow not found" }, 404);
@@ -2116,7 +2184,7 @@ webhooksRouter.put("/:id/toggle", async (c) => {
2116
2184
  webhooksRouter.delete("/:id", async (c) => {
2117
2185
  try {
2118
2186
  const id = c.req.param("id");
2119
- const { WorkflowStore } = await import("./workflow-store-ZYAYE5P6.js");
2187
+ const { WorkflowStore } = await import("./workflow-store-5Y56GUP7.js");
2120
2188
  const store = new WorkflowStore();
2121
2189
  await store.deleteWorkflow(id);
2122
2190
  return c.json({ success: true });
@@ -2128,7 +2196,7 @@ webhooksRouter.put("/:id", async (c) => {
2128
2196
  try {
2129
2197
  const id = c.req.param("id");
2130
2198
  const body = await c.req.json();
2131
- const { WorkflowStore } = await import("./workflow-store-ZYAYE5P6.js");
2199
+ const { WorkflowStore } = await import("./workflow-store-5Y56GUP7.js");
2132
2200
  const store = new WorkflowStore();
2133
2201
  const workflow = await store.getWorkflow(id);
2134
2202
  if (!workflow) return c.json({ error: "Workflow not found" }, 404);
@@ -2154,7 +2222,7 @@ webhooksRouter.put("/:id", async (c) => {
2154
2222
  });
2155
2223
  webhooksRouter.post("/seed", async (c) => {
2156
2224
  try {
2157
- const { WorkflowStore } = await import("./workflow-store-ZYAYE5P6.js");
2225
+ const { WorkflowStore } = await import("./workflow-store-5Y56GUP7.js");
2158
2226
  const store = new WorkflowStore();
2159
2227
  const now = /* @__PURE__ */ new Date();
2160
2228
  const defaults = [
@@ -2250,11 +2318,11 @@ import { Hono as Hono9 } from "hono";
2250
2318
  var githubRouter = new Hono9();
2251
2319
  githubRouter.get("/repos", async (c) => {
2252
2320
  try {
2253
- const { env: env2 } = await import("./env-CHOFICED.js");
2321
+ const { env: env2 } = await import("./env-GN5VHI43.js");
2254
2322
  if (!env2.GITHUB_TOKEN) {
2255
2323
  return c.json({ error: "GITHUB_TOKEN not configured" }, 400);
2256
2324
  }
2257
- const github = await import("./github-KGNILDWJ.js");
2325
+ const github = await import("./github-DUWSXCNP.js");
2258
2326
  const repos = await github.listRepositories();
2259
2327
  return c.json(repos);
2260
2328
  } catch (error) {
@@ -2263,13 +2331,13 @@ githubRouter.get("/repos", async (c) => {
2263
2331
  });
2264
2332
  githubRouter.get("/issues", async (c) => {
2265
2333
  try {
2266
- const { env: env2 } = await import("./env-CHOFICED.js");
2334
+ const { env: env2 } = await import("./env-GN5VHI43.js");
2267
2335
  if (!env2.GITHUB_TOKEN) {
2268
2336
  return c.json({ error: "GITHUB_TOKEN not configured" }, 400);
2269
2337
  }
2270
2338
  const repo = c.req.query("repo");
2271
2339
  const state = c.req.query("state") || "open";
2272
- const github = await import("./github-KGNILDWJ.js");
2340
+ const github = await import("./github-DUWSXCNP.js");
2273
2341
  if (repo) {
2274
2342
  const [owner, name] = repo.split("/");
2275
2343
  const issues2 = await github.listIssues(owner, name, { state });
@@ -2283,13 +2351,13 @@ githubRouter.get("/issues", async (c) => {
2283
2351
  });
2284
2352
  githubRouter.get("/prs", async (c) => {
2285
2353
  try {
2286
- const { env: env2 } = await import("./env-CHOFICED.js");
2354
+ const { env: env2 } = await import("./env-GN5VHI43.js");
2287
2355
  if (!env2.GITHUB_TOKEN) {
2288
2356
  return c.json({ error: "GITHUB_TOKEN not configured" }, 400);
2289
2357
  }
2290
2358
  const repo = c.req.query("repo");
2291
2359
  const state = c.req.query("state") || "open";
2292
- const github = await import("./github-KGNILDWJ.js");
2360
+ const github = await import("./github-DUWSXCNP.js");
2293
2361
  if (repo) {
2294
2362
  const [owner, name] = repo.split("/");
2295
2363
  const prs2 = await github.listPullRequests(owner, name, { state });
@@ -2462,7 +2530,7 @@ import { Hono as Hono11 } from "hono";
2462
2530
  var mcpRouter = new Hono11();
2463
2531
  mcpRouter.get("/servers", async (c) => {
2464
2532
  try {
2465
- const { getMCPRegistry } = await import("./tools-FGPN522P.js");
2533
+ const { getMCPRegistry } = await import("./tools-PJZ6RI4P.js");
2466
2534
  const registry = getMCPRegistry();
2467
2535
  if (!registry) {
2468
2536
  return c.json({ enabled: false, servers: [], connectedCount: 0, totalToolCount: 0 });
@@ -2497,7 +2565,7 @@ mcpRouter.get("/servers", async (c) => {
2497
2565
  });
2498
2566
  mcpRouter.post("/servers/:id/refresh", async (c) => {
2499
2567
  try {
2500
- const { getMCPRegistry } = await import("./tools-FGPN522P.js");
2568
+ const { getMCPRegistry } = await import("./tools-PJZ6RI4P.js");
2501
2569
  const registry = getMCPRegistry();
2502
2570
  if (!registry) return c.json({ error: "MCP not initialized" }, 500);
2503
2571
  await registry.refreshAllTools();
@@ -2604,7 +2672,7 @@ function updateEnvFile(updates) {
2604
2672
  }
2605
2673
  botsRouter.get("/status", async (c) => {
2606
2674
  try {
2607
- const { env: env2 } = await import("./env-CHOFICED.js");
2675
+ const { env: env2 } = await import("./env-GN5VHI43.js");
2608
2676
  const bots = [
2609
2677
  {
2610
2678
  id: "telegram",
@@ -2737,12 +2805,434 @@ botsRouter.put("/:id/config", async (c) => {
2737
2805
  });
2738
2806
  var bots_default = botsRouter;
2739
2807
 
2740
- // src/inputs/api/routes/users.ts
2808
+ // src/inputs/api/routes/m365.ts
2741
2809
  import { Hono as Hono13 } from "hono";
2742
- var usersRouter = new Hono13();
2810
+ import { randomBytes as randomBytes3 } from "crypto";
2811
+
2812
+ // src/core/security/rate-limiter-enhanced.ts
2813
+ var tokenBuckets = /* @__PURE__ */ new Map();
2814
+ var cleanup = setInterval(() => {
2815
+ const now = Date.now();
2816
+ for (const [key, bucket] of tokenBuckets) {
2817
+ if (now - bucket.lastRefill > 5 * 60 * 1e3) {
2818
+ tokenBuckets.delete(key);
2819
+ }
2820
+ }
2821
+ }, 5 * 60 * 1e3);
2822
+ if (cleanup.unref) cleanup.unref();
2823
+ function rateLimit(key, maxTokens, refillRate, tokensToConsume = 1) {
2824
+ const now = Date.now();
2825
+ let bucket = tokenBuckets.get(key);
2826
+ if (!bucket) {
2827
+ bucket = { tokens: maxTokens, lastRefill: now };
2828
+ tokenBuckets.set(key, bucket);
2829
+ }
2830
+ const elapsed = (now - bucket.lastRefill) / 1e3;
2831
+ bucket.tokens = Math.min(maxTokens, bucket.tokens + elapsed * refillRate);
2832
+ bucket.lastRefill = now;
2833
+ if (bucket.tokens >= tokensToConsume) {
2834
+ bucket.tokens -= tokensToConsume;
2835
+ return { success: true, remaining: Math.floor(bucket.tokens) };
2836
+ }
2837
+ const retryAfter = Math.ceil(
2838
+ (tokensToConsume - bucket.tokens) / refillRate
2839
+ );
2840
+ return { success: false, retryAfter, remaining: 0 };
2841
+ }
2842
+
2843
+ // src/inputs/api/routes/m365.ts
2844
+ var log = createLogger("api:m365");
2845
+ var m365 = new Hono13();
2846
+ function currentUserKey(c) {
2847
+ const id = getAuthUserId(c);
2848
+ return id || "local";
2849
+ }
2850
+ function configGuard(c) {
2851
+ if (!isM365Configured()) {
2852
+ return c.json(
2853
+ {
2854
+ error: "M365 not configured. Set M365_CLIENT_ID, M365_CLIENT_SECRET (and optionally M365_TENANT_ID, M365_REDIRECT_URI) in .env.",
2855
+ configured: false
2856
+ },
2857
+ 503
2858
+ );
2859
+ }
2860
+ return null;
2861
+ }
2862
+ m365.get("/status", async (c) => {
2863
+ const configured = isM365Configured();
2864
+ const userKey = currentUserKey(c);
2865
+ const conn = configured ? await getConnection(userKey) : null;
2866
+ return c.json({
2867
+ configured,
2868
+ connected: !!conn,
2869
+ userKey,
2870
+ connection: conn ? {
2871
+ email: conn.email,
2872
+ displayName: conn.displayName,
2873
+ microsoftUserId: conn.microsoftUserId,
2874
+ scope: conn.scope,
2875
+ expiresAt: conn.expiresAt.toISOString(),
2876
+ createdAt: conn.createdAt.toISOString(),
2877
+ updatedAt: conn.updatedAt.toISOString()
2878
+ } : null
2879
+ });
2880
+ });
2881
+ m365.get("/auth/login", async (c) => {
2882
+ const guard = configGuard(c);
2883
+ if (guard) return guard;
2884
+ const config = getM365Config();
2885
+ cleanupExpiredStates().catch(() => {
2886
+ });
2887
+ const state = randomBytes3(24).toString("hex");
2888
+ const verifier = generateCodeVerifier();
2889
+ const challenge = generateCodeChallenge(verifier);
2890
+ const userKey = currentUserKey(c);
2891
+ const returnTo = c.req.query("returnTo") || void 0;
2892
+ await persistState({ state, codeVerifier: verifier, userKey, returnTo });
2893
+ const url = buildAuthorizeUrl(config, { state, codeChallenge: challenge });
2894
+ log.info("oauth login initiated", { userKey });
2895
+ if (c.req.query("format") === "json") {
2896
+ return c.json({ url, state });
2897
+ }
2898
+ return c.redirect(url);
2899
+ });
2900
+ m365.get("/auth/callback", async (c) => {
2901
+ const guard = configGuard(c);
2902
+ if (guard) return guard;
2903
+ const config = getM365Config();
2904
+ const error = c.req.query("error");
2905
+ if (error) {
2906
+ return c.html(
2907
+ renderCallbackPage({
2908
+ ok: false,
2909
+ title: "Microsoft sign-in failed",
2910
+ body: `${error}: ${c.req.query("error_description") || ""}`
2911
+ })
2912
+ );
2913
+ }
2914
+ const code = c.req.query("code");
2915
+ const state = c.req.query("state");
2916
+ if (!code || !state) {
2917
+ return c.json({ error: "Missing code or state" }, 400);
2918
+ }
2919
+ const saved = await consumeState(state);
2920
+ if (!saved) {
2921
+ log.warn("callback rejected: unknown or expired state");
2922
+ return c.json({ error: "Invalid or expired state \u2014 start the login flow again." }, 400);
2923
+ }
2924
+ try {
2925
+ const tokens = await exchangeCodeForTokens(config, code, saved.codeVerifier);
2926
+ const me = await getMe(tokens.accessToken);
2927
+ const userKey = saved.userKey || me.mail || me.userPrincipalName || me.id;
2928
+ await saveConnection({
2929
+ userKey,
2930
+ tokens,
2931
+ email: me.mail || me.userPrincipalName,
2932
+ displayName: me.displayName,
2933
+ microsoftUserId: me.id
2934
+ });
2935
+ log.info("oauth callback success", { userKey });
2936
+ if (saved.returnTo) {
2937
+ return c.redirect(saved.returnTo);
2938
+ }
2939
+ return c.html(
2940
+ renderCallbackPage({
2941
+ ok: true,
2942
+ title: "Microsoft 365 connected",
2943
+ body: `Signed in as ${escapeHtml(me.displayName || me.userPrincipalName || me.id)}. You can close this tab.`
2944
+ })
2945
+ );
2946
+ } catch (err) {
2947
+ log.error("oauth callback failed", {
2948
+ error: err instanceof Error ? err.message : String(err)
2949
+ });
2950
+ return c.html(
2951
+ renderCallbackPage({
2952
+ ok: false,
2953
+ title: "Microsoft 365 connection failed",
2954
+ body: err instanceof Error ? err.message : "Unknown error"
2955
+ })
2956
+ );
2957
+ }
2958
+ });
2959
+ m365.post("/auth/logout", async (c) => {
2960
+ const userKey = currentUserKey(c);
2961
+ await deleteConnection(userKey);
2962
+ return c.json({ success: true });
2963
+ });
2964
+ m365.get("/profile", async (c) => {
2965
+ const guard = configGuard(c);
2966
+ if (guard) return guard;
2967
+ const userKey = currentUserKey(c);
2968
+ try {
2969
+ const token = await getAccessToken(userKey);
2970
+ const me = await getMe(token);
2971
+ return c.json(me);
2972
+ } catch (err) {
2973
+ return c.json({ error: err instanceof Error ? err.message : "Failed" }, 401);
2974
+ }
2975
+ });
2976
+ m365.get("/messages", async (c) => {
2977
+ const guard = configGuard(c);
2978
+ if (guard) return guard;
2979
+ const userKey = currentUserKey(c);
2980
+ const top = parseInt(c.req.query("top") || "20", 10);
2981
+ const folder = c.req.query("folder") || "inbox";
2982
+ const unreadOnly = c.req.query("unreadOnly") === "true";
2983
+ const search = c.req.query("search") || void 0;
2984
+ try {
2985
+ const token = await getAccessToken(userKey);
2986
+ const result = await listMessages(token, { top, folder, unreadOnly, search });
2987
+ return c.json(result);
2988
+ } catch (err) {
2989
+ const msg = err instanceof Error ? err.message : "Failed";
2990
+ const status = msg.includes("No M365 connection") ? 401 : 500;
2991
+ return c.json({ error: msg }, status);
2992
+ }
2993
+ });
2994
+ m365.post("/analyze-email", async (c) => {
2995
+ const guard = configGuard(c);
2996
+ const userKey = currentUserKey(c);
2997
+ const limit = rateLimit(
2998
+ `m365:analyze:${userKey}`,
2999
+ env.M365_ANALYZE_RATE_LIMIT,
3000
+ env.M365_ANALYZE_RATE_REFILL
3001
+ );
3002
+ if (!limit.success) {
3003
+ return c.json(
3004
+ { error: "Rate limit exceeded", retryAfter: limit.retryAfter },
3005
+ 429
3006
+ );
3007
+ }
3008
+ const body = await c.req.json();
3009
+ let input = null;
3010
+ let inputId = body.graphMessageId;
3011
+ if (body.graphMessageId) {
3012
+ if (guard) return guard;
3013
+ try {
3014
+ const token = await getAccessToken(userKey);
3015
+ const msg = await getMessage(token, body.graphMessageId);
3016
+ const bodyText = msg.body?.contentType === "html" ? stripHtml(msg.body.content || "") : msg.body?.content || msg.bodyPreview || "";
3017
+ input = {
3018
+ subject: msg.subject || "(no subject)",
3019
+ sender: msg.from?.emailAddress?.address || "unknown",
3020
+ body: bodyText
3021
+ };
3022
+ } catch (err) {
3023
+ return c.json(
3024
+ { error: err instanceof Error ? err.message : "Failed to load message" },
3025
+ 500
3026
+ );
3027
+ }
3028
+ } else {
3029
+ if (!body.subject || !body.sender) {
3030
+ return c.json({ error: "Either graphMessageId or {subject, sender} is required" }, 400);
3031
+ }
3032
+ input = {
3033
+ subject: String(body.subject),
3034
+ sender: String(body.sender),
3035
+ body: body.body ? String(body.body) : void 0
3036
+ };
3037
+ }
3038
+ const result = await analyzeEmail(input);
3039
+ let id;
3040
+ try {
3041
+ id = await persistAnalysis({
3042
+ userKey,
3043
+ input,
3044
+ inputId,
3045
+ inputType: "email",
3046
+ result
3047
+ });
3048
+ } catch (err) {
3049
+ log.warn("persistAnalysis failed \u2014 returning result anyway", {
3050
+ error: err instanceof Error ? err.message : String(err)
3051
+ });
3052
+ }
3053
+ return c.json({ ...result, id });
3054
+ });
3055
+ m365.get("/analyses", async (c) => {
3056
+ const userKey = currentUserKey(c);
3057
+ const limit = Math.max(1, Math.min(parseInt(c.req.query("limit") || "50", 10), 200));
3058
+ const rows = await listAnalyses(userKey, limit);
3059
+ return c.json({ results: rows });
3060
+ });
3061
+ m365.get("/sharepoint/sites", async (c) => {
3062
+ const guard = configGuard(c);
3063
+ if (guard) return guard;
3064
+ const userKey = currentUserKey(c);
3065
+ const search = c.req.query("search") || void 0;
3066
+ const top = parseInt(c.req.query("top") || "50", 10);
3067
+ try {
3068
+ const token = await getAccessToken(userKey);
3069
+ const sites = await listSites(token, { search, top });
3070
+ return c.json({ sites });
3071
+ } catch (err) {
3072
+ const msg = err instanceof Error ? err.message : "Failed";
3073
+ const status = msg.includes("No M365 connection") ? 401 : 500;
3074
+ return c.json({ error: msg }, status);
3075
+ }
3076
+ });
3077
+ m365.get("/sharepoint/sites/:siteId", async (c) => {
3078
+ const guard = configGuard(c);
3079
+ if (guard) return guard;
3080
+ const userKey = currentUserKey(c);
3081
+ try {
3082
+ const token = await getAccessToken(userKey);
3083
+ const site = await getSite(token, c.req.param("siteId"));
3084
+ return c.json(site);
3085
+ } catch (err) {
3086
+ return c.json({ error: err instanceof Error ? err.message : "Failed" }, 500);
3087
+ }
3088
+ });
3089
+ m365.get("/sharepoint/sites/:siteId/drives", async (c) => {
3090
+ const guard = configGuard(c);
3091
+ if (guard) return guard;
3092
+ const userKey = currentUserKey(c);
3093
+ try {
3094
+ const token = await getAccessToken(userKey);
3095
+ const drives = await listDrives(token, c.req.param("siteId"));
3096
+ return c.json({ drives });
3097
+ } catch (err) {
3098
+ return c.json({ error: err instanceof Error ? err.message : "Failed" }, 500);
3099
+ }
3100
+ });
3101
+ m365.get("/sharepoint/sites/:siteId/files", async (c) => {
3102
+ const guard = configGuard(c);
3103
+ if (guard) return guard;
3104
+ const userKey = currentUserKey(c);
3105
+ const search = c.req.query("search") || void 0;
3106
+ const top = parseInt(c.req.query("top") || "50", 10);
3107
+ try {
3108
+ const token = await getAccessToken(userKey);
3109
+ const drive = await getDefaultDrive(token, c.req.param("siteId"));
3110
+ const items = await listDriveRoot(token, drive.id, { search, top });
3111
+ return c.json({ drive, items });
3112
+ } catch (err) {
3113
+ return c.json({ error: err instanceof Error ? err.message : "Failed" }, 500);
3114
+ }
3115
+ });
3116
+ m365.get("/sharepoint/drives/:driveId/children/:itemId", async (c) => {
3117
+ const guard = configGuard(c);
3118
+ if (guard) return guard;
3119
+ const userKey = currentUserKey(c);
3120
+ const top = parseInt(c.req.query("top") || "50", 10);
3121
+ try {
3122
+ const token = await getAccessToken(userKey);
3123
+ const items = await listDriveChildren(
3124
+ token,
3125
+ c.req.param("driveId"),
3126
+ c.req.param("itemId"),
3127
+ { top }
3128
+ );
3129
+ return c.json({ items });
3130
+ } catch (err) {
3131
+ return c.json({ error: err instanceof Error ? err.message : "Failed" }, 500);
3132
+ }
3133
+ });
3134
+ m365.get("/sharepoint/drives/:driveId/items/:itemId", async (c) => {
3135
+ const guard = configGuard(c);
3136
+ if (guard) return guard;
3137
+ const userKey = currentUserKey(c);
3138
+ try {
3139
+ const token = await getAccessToken(userKey);
3140
+ const item = await getDriveItem(token, c.req.param("driveId"), c.req.param("itemId"));
3141
+ return c.json(item);
3142
+ } catch (err) {
3143
+ return c.json({ error: err instanceof Error ? err.message : "Failed" }, 500);
3144
+ }
3145
+ });
3146
+ m365.post("/sharepoint/analyze", async (c) => {
3147
+ const guard = configGuard(c);
3148
+ if (guard) return guard;
3149
+ const userKey = currentUserKey(c);
3150
+ const rl = rateLimit(
3151
+ `m365:analyze:${userKey}`,
3152
+ env.M365_ANALYZE_RATE_LIMIT,
3153
+ env.M365_ANALYZE_RATE_REFILL
3154
+ );
3155
+ if (!rl.success) {
3156
+ return c.json({ error: "Rate limit exceeded", retryAfter: rl.retryAfter }, 429);
3157
+ }
3158
+ const body = await c.req.json();
3159
+ if (!body.driveId || !body.itemId) {
3160
+ return c.json({ error: "driveId and itemId are required" }, 400);
3161
+ }
3162
+ try {
3163
+ const token = await getAccessToken(userKey);
3164
+ const item = await getDriveItem(token, body.driveId, body.itemId);
3165
+ const extracted = await extractTextFromDriveItem(token, body.driveId, body.itemId, item);
3166
+ if (!extracted.text || extracted.text.trim().length === 0) {
3167
+ return c.json({
3168
+ error: `No text could be extracted (source: ${extracted.extractedFrom})`,
3169
+ extractedFrom: extracted.extractedFrom,
3170
+ byteLength: extracted.byteLength
3171
+ }, 422);
3172
+ }
3173
+ const analysisInput = {
3174
+ subject: item.name || "(unnamed file)",
3175
+ sender: item.parentReference?.path || "sharepoint",
3176
+ body: extracted.text.slice(0, 16e3)
3177
+ // cap to keep LLM bill sane
3178
+ };
3179
+ const result = await analyzeEmail(analysisInput);
3180
+ let id;
3181
+ try {
3182
+ id = await persistAnalysis({
3183
+ userKey,
3184
+ input: analysisInput,
3185
+ inputId: `${body.driveId}:${body.itemId}`,
3186
+ inputType: "file",
3187
+ result
3188
+ });
3189
+ } catch (err) {
3190
+ log.warn("persistAnalysis failed", {
3191
+ error: err instanceof Error ? err.message : String(err)
3192
+ });
3193
+ }
3194
+ return c.json({
3195
+ ...result,
3196
+ id,
3197
+ file: { name: item.name, size: item.size, webUrl: item.webUrl, mimeType: item.file?.mimeType },
3198
+ extractedFrom: extracted.extractedFrom,
3199
+ byteLength: extracted.byteLength,
3200
+ textLength: extracted.text.length
3201
+ });
3202
+ } catch (err) {
3203
+ const msg = err instanceof Error ? err.message : "Failed";
3204
+ return c.json({ error: msg }, 500);
3205
+ }
3206
+ });
3207
+ function escapeHtml(s) {
3208
+ return s.replace(
3209
+ /[&<>"']/g,
3210
+ (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]
3211
+ );
3212
+ }
3213
+ function renderCallbackPage(opts) {
3214
+ const color = opts.ok ? "#10b981" : "#ef4444";
3215
+ return `<!doctype html><html><head><meta charset="utf-8"><title>${escapeHtml(opts.title)}</title>
3216
+ <style>
3217
+ body{font-family:system-ui,-apple-system,Segoe UI,Arial,sans-serif;max-width:640px;margin:40px auto;padding:24px;color:#e5e7eb;background:#0b0f17}
3218
+ h1{color:${color};margin-top:0}
3219
+ .card{background:#111827;border:1px solid #1f2937;border-radius:10px;padding:20px}
3220
+ .btn{display:inline-block;margin-top:16px;padding:10px 18px;background:#10b981;color:#fff;text-decoration:none;border-radius:6px;font-weight:600}
3221
+ .btn:hover{background:#059669}
3222
+ </style></head><body>
3223
+ <div class="card">
3224
+ <h1>${escapeHtml(opts.title)}</h1>
3225
+ <p>${escapeHtml(opts.body)}</p>
3226
+ <a class="btn" href="/">Go Back to Dashboard</a>
3227
+ </div></body></html>`;
3228
+ }
3229
+
3230
+ // src/inputs/api/routes/users.ts
3231
+ import { Hono as Hono14 } from "hono";
3232
+ var usersRouter = new Hono14();
2743
3233
  usersRouter.get("/", async (c) => {
2744
3234
  try {
2745
- const { searchUsers } = await import("./multi-user-S56GUD6L.js");
3235
+ const { searchUsers } = await import("./multi-user-XAEMB244.js");
2746
3236
  const users2 = await searchUsers({});
2747
3237
  return c.json(users2);
2748
3238
  } catch {
@@ -2755,7 +3245,7 @@ usersRouter.post("/", async (c) => {
2755
3245
  if (!email2) {
2756
3246
  return c.json({ error: "email is required" }, 400);
2757
3247
  }
2758
- const { createUser } = await import("./multi-user-S56GUD6L.js");
3248
+ const { createUser } = await import("./multi-user-XAEMB244.js");
2759
3249
  const user = await createUser({
2760
3250
  email: email2,
2761
3251
  name: name || "",
@@ -2771,16 +3261,16 @@ usersRouter.put("/:id", async (c) => {
2771
3261
  const id = c.req.param("id");
2772
3262
  const updates = await c.req.json();
2773
3263
  if (updates.status === "suspended") {
2774
- const { suspendUser } = await import("./multi-user-S56GUD6L.js");
3264
+ const { suspendUser } = await import("./multi-user-XAEMB244.js");
2775
3265
  await suspendUser(id, "Suspended via dashboard");
2776
3266
  return c.json({ success: true });
2777
3267
  }
2778
3268
  if (updates.status === "active") {
2779
- const { reactivateUser } = await import("./multi-user-S56GUD6L.js");
3269
+ const { reactivateUser } = await import("./multi-user-XAEMB244.js");
2780
3270
  await reactivateUser(id);
2781
3271
  return c.json({ success: true });
2782
3272
  }
2783
- const { updateUser } = await import("./multi-user-S56GUD6L.js");
3273
+ const { updateUser } = await import("./multi-user-XAEMB244.js");
2784
3274
  await updateUser(id, updates);
2785
3275
  return c.json({ success: true });
2786
3276
  } catch (error) {
@@ -2790,7 +3280,7 @@ usersRouter.put("/:id", async (c) => {
2790
3280
  usersRouter.delete("/:id", async (c) => {
2791
3281
  try {
2792
3282
  const id = c.req.param("id");
2793
- const { deleteUser } = await import("./multi-user-S56GUD6L.js");
3283
+ const { deleteUser } = await import("./multi-user-XAEMB244.js");
2794
3284
  await deleteUser(id);
2795
3285
  return c.json({ success: true });
2796
3286
  } catch (error) {
@@ -2802,14 +3292,14 @@ var users_default = usersRouter;
2802
3292
  // src/inputs/api/server.ts
2803
3293
  import { tmpdir } from "os";
2804
3294
  import { resolve as resolve2, join } from "path";
2805
- import { randomBytes as randomBytes3 } from "crypto";
3295
+ import { randomBytes as randomBytes4 } from "crypto";
2806
3296
  var serveStatic;
2807
3297
  try {
2808
3298
  serveStatic = __require("hono/bun").serveStatic;
2809
3299
  } catch {
2810
3300
  serveStatic = () => async (_c, next) => next();
2811
3301
  }
2812
- var app = new Hono14();
3302
+ var app = new Hono15();
2813
3303
  app.use("*", logger());
2814
3304
  app.use("/api/*", cors());
2815
3305
  app.use("/api/*", authMiddleware());
@@ -3077,7 +3567,7 @@ app.post("/api/pair", async (c) => {
3077
3567
  });
3078
3568
  app.get("/api/providers", async (c) => {
3079
3569
  try {
3080
- const { providerRegistry } = await import("./providers-H6YIC3MG.js");
3570
+ const { providerRegistry } = await import("./providers-2YQ6E3IF.js");
3081
3571
  return c.json({
3082
3572
  providers: providerRegistry.listProviders(),
3083
3573
  default: providerRegistry.getDefaultId()
@@ -3092,7 +3582,7 @@ app.route("/api/sdk", sdkRoutes);
3092
3582
  app.route("/api/admin", admin_default);
3093
3583
  app.get("/api/audit-logs", async (c) => {
3094
3584
  try {
3095
- const { queryAuditLogs: queryAuditLogs2 } = await import("./audit-logger-AU3TMWKI.js");
3585
+ const { queryAuditLogs: queryAuditLogs2 } = await import("./audit-logger-CI4WZQPD.js");
3096
3586
  const url = new URL(c.req.url);
3097
3587
  const options = {};
3098
3588
  const userId = url.searchParams.get("userId");
@@ -3117,7 +3607,7 @@ app.get("/api/audit-logs", async (c) => {
3117
3607
  });
3118
3608
  app.get("/api/audit-logs/integrity", async (c) => {
3119
3609
  try {
3120
- const { getAuditChainIntegrity: getAuditChainIntegrity2 } = await import("./audit-logger-AU3TMWKI.js");
3610
+ const { getAuditChainIntegrity: getAuditChainIntegrity2 } = await import("./audit-logger-CI4WZQPD.js");
3121
3611
  const integrity = await getAuditChainIntegrity2();
3122
3612
  return c.json({ success: true, ...integrity });
3123
3613
  } catch (err) {
@@ -3126,7 +3616,7 @@ app.get("/api/audit-logs/integrity", async (c) => {
3126
3616
  });
3127
3617
  app.delete("/api/audit-logs", async (c) => {
3128
3618
  try {
3129
- const { auditLogs } = await import("./schema-ALJ67YVG.js");
3619
+ const { auditLogs } = await import("./schema-ETY7L2VA.js");
3130
3620
  await db.delete(auditLogs);
3131
3621
  return c.json({ success: true });
3132
3622
  } catch (err) {
@@ -3161,11 +3651,10 @@ app.route("/api/scheduler", scheduler_default);
3161
3651
  app.route("/api/alerts", alerts_default);
3162
3652
  app.route("/api/webhooks", webhooks_default);
3163
3653
  app.route("/api/github", github_default);
3164
- app.route("/api/metrics", metrics_default);
3165
3654
  app.get("/api/metrics/overview", async (c) => {
3166
3655
  try {
3167
- const { getMetricAggregates: getMetricAggregates2 } = await import("./metrics-VJDWQWU7.js");
3168
- const { getErrorStats: getErrorStats2 } = await import("./error-tracker-SVQSDQDW.js");
3656
+ const { getMetricAggregates: getMetricAggregates2 } = await import("./metrics-BH3ZLGEV.js");
3657
+ const { getErrorStats: getErrorStats2 } = await import("./error-tracker-64DEH3D7.js");
3169
3658
  const now = /* @__PURE__ */ new Date();
3170
3659
  const dayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
3171
3660
  const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3);
@@ -3195,12 +3684,22 @@ app.get("/api/metrics/overview", async (c) => {
3195
3684
  return c.json({ last24h: {}, last7d: {} });
3196
3685
  }
3197
3686
  });
3687
+ app.route("/api/metrics", metrics_default);
3198
3688
  app.route("/api/mcp", mcp_default);
3199
3689
  app.route("/api/bots", bots_default);
3690
+ app.route("/api/m365", m365);
3691
+ app.get("/api/callbacks/outlook", async (c) => {
3692
+ const search = new URL(c.req.url).search;
3693
+ const forward = new Request(
3694
+ `http://localhost/api/m365/auth/callback${search}`,
3695
+ { method: "GET", headers: c.req.raw.headers }
3696
+ );
3697
+ return app.fetch(forward);
3698
+ });
3200
3699
  app.route("/api/users", users_default);
3201
3700
  app.get("/api/incidents", requirePermission("admin:settings"), async (c) => {
3202
3701
  try {
3203
- const { getOpenIncidents } = await import("./incident-response-ZTIKUWEO.js");
3702
+ const { getOpenIncidents } = await import("./incident-response-E3UGMX5G.js");
3204
3703
  const severity = c.req.query("severity");
3205
3704
  const type = c.req.query("type");
3206
3705
  const incidents = await getOpenIncidents({ severity, type, limit: 50 });
@@ -3211,7 +3710,7 @@ app.get("/api/incidents", requirePermission("admin:settings"), async (c) => {
3211
3710
  });
3212
3711
  app.get("/api/incidents/:id", requirePermission("admin:settings"), async (c) => {
3213
3712
  try {
3214
- const { generateIncidentReport } = await import("./incident-response-ZTIKUWEO.js");
3713
+ const { generateIncidentReport } = await import("./incident-response-E3UGMX5G.js");
3215
3714
  const id = c.req.param("id");
3216
3715
  const report = await generateIncidentReport(id);
3217
3716
  return c.json(report);
@@ -3221,7 +3720,7 @@ app.get("/api/incidents/:id", requirePermission("admin:settings"), async (c) =>
3221
3720
  });
3222
3721
  app.post("/api/incidents/:id/status", requirePermission("admin:settings"), async (c) => {
3223
3722
  try {
3224
- const { updateIncidentStatus } = await import("./incident-response-ZTIKUWEO.js");
3723
+ const { updateIncidentStatus } = await import("./incident-response-E3UGMX5G.js");
3225
3724
  const id = c.req.param("id");
3226
3725
  const body = await c.req.json();
3227
3726
  const userId = getAuthUserId(c);
@@ -3233,7 +3732,7 @@ app.post("/api/incidents/:id/status", requirePermission("admin:settings"), async
3233
3732
  });
3234
3733
  app.post("/api/incidents/:id/resolve", requirePermission("admin:settings"), async (c) => {
3235
3734
  try {
3236
- const { resolveIncident } = await import("./incident-response-ZTIKUWEO.js");
3735
+ const { resolveIncident } = await import("./incident-response-E3UGMX5G.js");
3237
3736
  const id = c.req.param("id");
3238
3737
  const body = await c.req.json();
3239
3738
  const userId = getAuthUserId(c);
@@ -3245,7 +3744,7 @@ app.post("/api/incidents/:id/resolve", requirePermission("admin:settings"), asyn
3245
3744
  });
3246
3745
  app.get("/api/audit/integrity", requirePermission("admin:settings"), async (c) => {
3247
3746
  try {
3248
- const { getAuditChainIntegrity: getAuditChainIntegrity2 } = await import("./audit-logger-AU3TMWKI.js");
3747
+ const { getAuditChainIntegrity: getAuditChainIntegrity2 } = await import("./audit-logger-CI4WZQPD.js");
3249
3748
  const integrity = await getAuditChainIntegrity2();
3250
3749
  return c.json(integrity);
3251
3750
  } catch (error) {
@@ -3294,7 +3793,7 @@ app.post("/api/tts", async (c) => {
3294
3793
  app.get("/api/system/status", async (c) => {
3295
3794
  return c.json({
3296
3795
  status: "online",
3297
- version: "3.4.0",
3796
+ version: "3.6.1",
3298
3797
  uptime: process.uptime(),
3299
3798
  memory: process.memoryUsage()
3300
3799
  });
@@ -3309,7 +3808,7 @@ app.get("/api/callbacks/spotify", async (c) => {
3309
3808
  if (!code) {
3310
3809
  return c.html(`<h1>Missing Authorization Code</h1><p>No code received from Spotify.</p>`);
3311
3810
  }
3312
- const { env: appEnv } = await import("./env-CHOFICED.js");
3811
+ const { env: appEnv } = await import("./env-GN5VHI43.js");
3313
3812
  if (!appEnv.SPOTIFY_CLIENT_ID || !appEnv.SPOTIFY_CLIENT_SECRET) {
3314
3813
  return c.html(`<h1>Spotify Not Configured</h1><p>Set SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET in .env</p>`);
3315
3814
  }
@@ -3335,7 +3834,7 @@ app.get("/api/callbacks/spotify", async (c) => {
3335
3834
  });
3336
3835
  app.get("/api/spotify/authorize", async (c) => {
3337
3836
  try {
3338
- const { env: appEnv } = await import("./env-CHOFICED.js");
3837
+ const { env: appEnv } = await import("./env-GN5VHI43.js");
3339
3838
  if (!appEnv.SPOTIFY_CLIENT_ID || !appEnv.SPOTIFY_CLIENT_SECRET) {
3340
3839
  return c.json({ error: "Spotify not configured. Set SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET in .env" }, 400);
3341
3840
  }
@@ -3387,7 +3886,7 @@ app.post("/api/files/upload", async (c) => {
3387
3886
  return c.json({ error: "File too large (50MB max)" }, 413);
3388
3887
  }
3389
3888
  const ext = file.name.split(".").pop() || "bin";
3390
- const id = randomBytes3(8).toString("hex");
3889
+ const id = randomBytes4(8).toString("hex");
3391
3890
  const filename = `sentinel-upload-${id}.${ext}`;
3392
3891
  const filePath = join(tmpdir(), filename);
3393
3892
  const buffer = Buffer.from(await file.arrayBuffer());
@@ -3405,4 +3904,4 @@ export {
3405
3904
  timingSafeEqual,
3406
3905
  app
3407
3906
  };
3408
- //# sourceMappingURL=chunk-AD6YEH6U.js.map
3907
+ //# sourceMappingURL=chunk-S2EOIVF4.js.map