@circuitwall/jarela 2.2.1 → 2.4.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 (703) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +2 -1
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/routes-manifest.json +8 -0
  6. package/.next/standalone/.next/server/app/_global-error/page.js +68 -68
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page.js +76 -76
  14. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  16. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/.next/standalone/.next/server/app/api/v1/access/[identity]/route.js +100 -93
  22. package/.next/standalone/.next/server/app/api/v1/access/route.js +176 -169
  23. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js +89 -56
  24. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/v1/agents/[id]/display-filters/route.js +139 -127
  26. package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +107 -100
  27. package/.next/standalone/.next/server/app/api/v1/agents/[id]/thread/route.js +765 -753
  28. package/.next/standalone/.next/server/app/api/v1/agents/route.js +72 -65
  29. package/.next/standalone/.next/server/app/api/v1/allowed-sites/[hostname]/route.js +371 -364
  30. package/.next/standalone/.next/server/app/api/v1/allowed-sites/route.js +809 -802
  31. package/.next/standalone/.next/server/app/api/v1/artifacts/lifecycle/route.js +9 -2
  32. package/.next/standalone/.next/server/app/api/v1/attachments/files/route.js +49 -49
  33. package/.next/standalone/.next/server/app/api/v1/attachments/images/route.js +910 -910
  34. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +583 -16
  35. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/[remote_jid]/route.js +41 -30
  37. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/route.js +48 -37
  38. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +697 -130
  39. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +703 -136
  41. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +796 -229
  43. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/[route_id]/route.js +762 -746
  45. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/route.js +1050 -1034
  46. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +673 -106
  47. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js +811 -804
  49. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/v1/bridges/route.js +718 -706
  51. package/.next/standalone/.next/server/app/api/v1/bridges/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +9 -9
  53. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/v1/config/route.js +85 -85
  55. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +709 -709
  56. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/v1/credentials/route.js +2 -2
  58. package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/v1/dashboard/currency/route.js +10 -10
  60. package/.next/standalone/.next/server/app/api/v1/dashboard/metrics/route.js +796 -784
  61. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing/route.js +30 -23
  62. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +86 -86
  63. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +57 -57
  65. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
  66. package/.next/standalone/.next/server/app/api/v1/documents/search/route.js +385 -378
  67. package/.next/standalone/.next/server/app/api/v1/documents/settings/route.js +51 -44
  68. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +65 -65
  69. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
  70. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +122 -122
  71. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
  72. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +37 -37
  73. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
  74. package/.next/standalone/.next/server/app/api/v1/env/route.js +9 -9
  75. package/.next/standalone/.next/server/app/api/v1/env-sync/allowlist/route.js +375 -368
  76. package/.next/standalone/.next/server/app/api/v1/env-sync/route.js +51 -44
  77. package/.next/standalone/.next/server/app/api/v1/events/route.js +745 -178
  78. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/api/v1/events/test/route.js +77 -77
  80. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +763 -763
  81. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
  82. package/.next/standalone/.next/server/app/api/v1/extension/browser/activate/route.js +51 -44
  83. package/.next/standalone/.next/server/app/api/v1/extension/browser/foreground/route.js +16 -9
  84. package/.next/standalone/.next/server/app/api/v1/extension/browser/history/route.js +72 -65
  85. package/.next/standalone/.next/server/app/api/v1/extension/browser/poll/route.js +41 -34
  86. package/.next/standalone/.next/server/app/api/v1/extension/browser/progress/route.js +211 -204
  87. package/.next/standalone/.next/server/app/api/v1/extension/browser/result/route.js +140 -133
  88. package/.next/standalone/.next/server/app/api/v1/extension/browser/retry/route.js +113 -106
  89. package/.next/standalone/.next/server/app/api/v1/extension/browser/status/route.js +121 -114
  90. package/.next/standalone/.next/server/app/api/v1/extension/browser/tabs/route.js +141 -134
  91. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +690 -690
  92. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +93 -93
  94. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +9 -9
  96. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
  97. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +185 -185
  98. package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
  99. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +171 -171
  100. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
  101. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +396 -396
  102. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
  103. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +212 -212
  104. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
  105. package/.next/standalone/.next/server/app/api/v1/files/[name]/route.js +235 -235
  106. package/.next/standalone/.next/server/app/api/v1/fs/browse/route.js +26 -26
  107. package/.next/standalone/.next/server/app/api/v1/harnesses/[id]/route.js +228 -221
  108. package/.next/standalone/.next/server/app/api/v1/harnesses/default/route.js +65 -58
  109. package/.next/standalone/.next/server/app/api/v1/harnesses/route.js +79 -72
  110. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +9 -9
  111. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
  112. package/.next/standalone/.next/server/app/api/v1/health/route.js +783 -771
  113. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/route.js +140 -133
  114. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +9 -9
  115. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
  116. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +370 -363
  117. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +240 -233
  118. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +689 -682
  119. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +886 -879
  120. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +115 -108
  121. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +955 -948
  122. package/.next/standalone/.next/server/app/api/v1/integrations/route.js +223 -216
  123. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js +876 -847
  124. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js.nft.json +1 -1
  125. package/.next/standalone/.next/server/app/api/v1/local-file/route.js +26 -26
  126. package/.next/standalone/.next/server/app/api/v1/logs/route.js +70 -70
  127. package/.next/standalone/.next/server/app/api/v1/maps/embed/route.js +79 -72
  128. package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +991 -979
  129. package/.next/standalone/.next/server/app/api/v1/mcp-servers/registry/route.js +196 -196
  130. package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +19 -7
  131. package/.next/standalone/.next/server/app/api/v1/memory/[namespace]/[key]/route.js +539 -532
  132. package/.next/standalone/.next/server/app/api/v1/memory/policy/route.js +86 -79
  133. package/.next/standalone/.next/server/app/api/v1/memory/route.js +58 -51
  134. package/.next/standalone/.next/server/app/api/v1/memory/search/route.js +138 -131
  135. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js +381 -369
  136. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js.nft.json +1 -1
  137. package/.next/standalone/.next/server/app/api/v1/models/[name]/route.js +150 -143
  138. package/.next/standalone/.next/server/app/api/v1/models/route.js +634 -627
  139. package/.next/standalone/.next/server/app/api/v1/packages/catalog/route.js +445 -445
  140. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +120 -120
  141. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
  142. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +234 -234
  143. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
  144. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +407 -407
  145. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
  146. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +37 -37
  147. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
  148. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +107 -107
  149. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
  150. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +228 -228
  151. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
  152. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +9 -9
  153. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
  154. package/.next/standalone/.next/server/app/api/v1/packages/route.js +148 -148
  155. package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
  156. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +787 -787
  157. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
  158. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +529 -514
  159. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
  160. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +181 -181
  161. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
  162. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +258 -258
  163. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
  164. package/.next/standalone/.next/server/app/api/v1/profile/location/route.js +37 -30
  165. package/.next/standalone/.next/server/app/api/v1/profile/route.js +171 -164
  166. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +51 -44
  167. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/probe/route.js +15 -8
  168. package/.next/standalone/.next/server/app/api/v1/providers/github-copilot/auth/route.js +171 -164
  169. package/.next/standalone/.next/server/app/api/v1/providers/route.js +101 -94
  170. package/.next/standalone/.next/server/app/api/v1/proxy-config/route.js +457 -450
  171. package/.next/standalone/.next/server/app/api/v1/redaction/init/route.js +44 -37
  172. package/.next/standalone/.next/server/app/api/v1/redaction/route.js +65 -58
  173. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/route.js +617 -605
  174. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +44 -44
  175. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
  176. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/route.js +739 -732
  177. package/.next/standalone/.next/server/app/api/v1/security/idle-timeout/route.js +329 -322
  178. package/.next/standalone/.next/server/app/api/v1/security/pin/route.js +204 -197
  179. package/.next/standalone/.next/server/app/api/v1/security/state/route.js +58 -51
  180. package/.next/standalone/.next/server/app/api/v1/security/unlock/route.js +183 -176
  181. package/.next/standalone/.next/server/app/api/v1/security/verify-pin/route.js +194 -187
  182. package/.next/standalone/.next/server/app/api/v1/setup/test-key/route.js +26 -26
  183. package/.next/standalone/.next/server/app/api/v1/skills/[id]/route.js +776 -769
  184. package/.next/standalone/.next/server/app/api/v1/skills/repos/[id]/route.js +122 -115
  185. package/.next/standalone/.next/server/app/api/v1/skills/repos/route.js +334 -327
  186. package/.next/standalone/.next/server/app/api/v1/skills/route.js +873 -866
  187. package/.next/standalone/.next/server/app/api/v1/system/abort/route.js +838 -808
  188. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +177 -177
  189. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
  190. package/.next/standalone/.next/server/app/api/v1/tailscale/route.js +164 -164
  191. package/.next/standalone/.next/server/app/api/v1/tasks/[agent_id]/route.js +122 -115
  192. package/.next/standalone/.next/server/app/api/v1/tasks/route.js +30 -23
  193. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js +1436 -0
  194. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js.nft.json +1 -0
  195. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route_client-reference-manifest.js +1 -0
  196. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js +638 -631
  197. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js.nft.json +1 -1
  198. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +60 -439
  199. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js.nft.json +1 -1
  200. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +172 -173
  201. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
  202. package/.next/standalone/.next/server/app/api/v1/threads/route.js +925 -913
  203. package/.next/standalone/.next/server/app/api/v1/tools/route.js +2 -2
  204. package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
  205. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js +17 -17
  206. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
  207. package/.next/standalone/.next/server/app/api/v1/update/route.js +570 -570
  208. package/.next/standalone/.next/server/app/api/v1/voice/transcribe/route.js +241 -229
  209. package/.next/standalone/.next/server/app/api/v1/voice/tts/route.js +989 -977
  210. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/route.js +40 -28
  211. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +72 -72
  212. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
  213. package/.next/standalone/.next/server/app/api/v1/watchers/reaction-scripts/route.js +128 -128
  214. package/.next/standalone/.next/server/app/api/v1/watchers/route.js +164 -164
  215. package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
  216. package/.next/standalone/.next/server/app/icon.svg/route.js +62 -62
  217. package/.next/standalone/.next/server/app/manifest.webmanifest/route.js +436 -436
  218. package/.next/standalone/.next/server/app/page.js +1179 -743
  219. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  220. package/.next/standalone/.next/server/app/setup/page.js +99 -91
  221. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  222. package/.next/standalone/.next/server/app-paths-manifest.json +2 -1
  223. package/.next/standalone/.next/server/chunks/{424.js → 1388.js} +441 -1022
  224. package/.next/standalone/.next/server/chunks/1433.js +1 -1
  225. package/.next/standalone/.next/server/chunks/1638.js +1 -2
  226. package/.next/standalone/.next/server/chunks/1738.js +1 -1
  227. package/.next/standalone/.next/server/chunks/2068.js +47 -10
  228. package/.next/standalone/.next/server/chunks/210.js +3 -3
  229. package/.next/standalone/.next/server/chunks/2151.js +31 -1
  230. package/.next/standalone/.next/server/chunks/2207.js +1 -0
  231. package/.next/standalone/.next/server/chunks/2447.js +10 -5
  232. package/.next/standalone/.next/server/chunks/2471.js +45 -45
  233. package/.next/standalone/.next/server/chunks/2504.js +1 -1
  234. package/.next/standalone/.next/server/chunks/2695.js +17 -17
  235. package/.next/standalone/.next/server/chunks/3042.js +24 -16
  236. package/.next/standalone/.next/server/chunks/{4540.js → 309.js} +104 -38
  237. package/.next/standalone/.next/server/chunks/{2350.js → 3272.js} +104 -37
  238. package/.next/standalone/.next/server/chunks/3399.js +526 -526
  239. package/.next/standalone/.next/server/chunks/3524.js +150 -67
  240. package/.next/standalone/.next/server/chunks/3566.js +1 -1
  241. package/.next/standalone/.next/server/chunks/4189.js +946 -0
  242. package/.next/standalone/.next/server/chunks/4433.js +146 -146
  243. package/.next/standalone/.next/server/chunks/4508.js +3 -3
  244. package/.next/standalone/.next/server/chunks/4588.js +1 -0
  245. package/.next/standalone/.next/server/chunks/46.js +78 -28
  246. package/.next/standalone/.next/server/chunks/466.js +12 -0
  247. package/.next/standalone/.next/server/chunks/4868.js +206 -206
  248. package/.next/standalone/.next/server/chunks/4992.js +13 -0
  249. package/.next/standalone/.next/server/chunks/5120.js +963 -0
  250. package/.next/standalone/.next/server/chunks/5701.js +1 -1
  251. package/.next/standalone/.next/server/chunks/5900.js +1 -1
  252. package/.next/standalone/.next/server/chunks/5908.js +63 -42
  253. package/.next/standalone/.next/server/chunks/6142.js +10 -2
  254. package/.next/standalone/.next/server/chunks/6210.js +1 -0
  255. package/.next/standalone/.next/server/chunks/6213.js +1 -1
  256. package/.next/standalone/.next/server/chunks/6649.js +3 -3
  257. package/.next/standalone/.next/server/chunks/6703.js +3 -3
  258. package/.next/standalone/.next/server/chunks/7445.js +1 -0
  259. package/.next/standalone/.next/server/chunks/8067.js +12 -0
  260. package/.next/standalone/.next/server/chunks/8461.js +24 -17
  261. package/.next/standalone/.next/server/chunks/8558.js +1 -1
  262. package/.next/standalone/.next/server/chunks/8724.js +1 -1
  263. package/.next/standalone/.next/server/chunks/8849.js +91 -91
  264. package/.next/standalone/.next/server/chunks/9032.js +4 -3
  265. package/.next/standalone/.next/server/chunks/{2563.js → 9164.js} +33389 -31418
  266. package/.next/standalone/.next/server/chunks/9237.js +396 -396
  267. package/.next/standalone/.next/server/chunks/{9640.js → 9304.js} +1672 -575
  268. package/.next/standalone/.next/server/chunks/9406.js +1 -1
  269. package/.next/standalone/.next/server/chunks/9590.js +68 -18
  270. package/.next/standalone/.next/server/chunks/9824.js +98 -98
  271. package/.next/standalone/.next/server/chunks/9826.js +1 -0
  272. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  273. package/.next/standalone/.next/server/middleware.js +486 -415
  274. package/.next/standalone/.next/server/pages/404.html +2 -2
  275. package/.next/standalone/.next/server/pages/500.html +1 -1
  276. package/.next/standalone/.next/server/preview-props.json +3 -3
  277. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  278. package/.next/standalone/.next/static/chunks/{1395-a340fb0a345382a4.js → 1395-e4a99912b8f83044.js} +13 -1
  279. package/.next/standalone/.next/static/chunks/app/_global-error/{page-36cb8b428b38b26a.js → page-6fc5f8e744c81802.js} +1 -1
  280. package/.next/standalone/.next/static/chunks/app/api/v1/access/[identity]/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  281. package/.next/standalone/.next/static/chunks/app/api/v1/access/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  282. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/compact/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  283. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-6fc5f8e744c81802.js +17 -0
  284. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-6fc5f8e744c81802.js +17 -0
  285. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-6fc5f8e744c81802.js +17 -0
  286. package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-6fc5f8e744c81802.js +17 -0
  287. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-6fc5f8e744c81802.js +17 -0
  288. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-6fc5f8e744c81802.js +17 -0
  289. package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-6fc5f8e744c81802.js +17 -0
  290. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-6fc5f8e744c81802.js +17 -0
  291. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-6fc5f8e744c81802.js +17 -0
  292. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-6fc5f8e744c81802.js +17 -0
  293. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-6fc5f8e744c81802.js +17 -0
  294. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-6fc5f8e744c81802.js +17 -0
  295. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-6fc5f8e744c81802.js +17 -0
  296. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-6fc5f8e744c81802.js +17 -0
  297. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-6fc5f8e744c81802.js +17 -0
  298. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-6fc5f8e744c81802.js +17 -0
  299. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-6fc5f8e744c81802.js +17 -0
  300. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-6fc5f8e744c81802.js +17 -0
  301. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-6fc5f8e744c81802.js +17 -0
  302. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-6fc5f8e744c81802.js +17 -0
  303. package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-6fc5f8e744c81802.js +17 -0
  304. package/.next/standalone/.next/static/chunks/app/api/v1/config/route-6fc5f8e744c81802.js +17 -0
  305. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-6fc5f8e744c81802.js +17 -0
  306. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-6fc5f8e744c81802.js +17 -0
  307. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-6fc5f8e744c81802.js +17 -0
  308. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-6fc5f8e744c81802.js +17 -0
  309. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-6fc5f8e744c81802.js +17 -0
  310. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-6fc5f8e744c81802.js +17 -0
  311. package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-6fc5f8e744c81802.js +17 -0
  312. package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-6fc5f8e744c81802.js +17 -0
  313. package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-6fc5f8e744c81802.js +17 -0
  314. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-6fc5f8e744c81802.js +17 -0
  315. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-6fc5f8e744c81802.js +17 -0
  316. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-6fc5f8e744c81802.js +17 -0
  317. package/.next/standalone/.next/static/chunks/app/api/v1/env/route-6fc5f8e744c81802.js +17 -0
  318. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-6fc5f8e744c81802.js +17 -0
  319. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-6fc5f8e744c81802.js +17 -0
  320. package/.next/standalone/.next/static/chunks/app/api/v1/events/route-6fc5f8e744c81802.js +17 -0
  321. package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-6fc5f8e744c81802.js +17 -0
  322. package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-6fc5f8e744c81802.js +17 -0
  323. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-6fc5f8e744c81802.js +17 -0
  324. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-6fc5f8e744c81802.js +17 -0
  325. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-6fc5f8e744c81802.js +17 -0
  326. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-6fc5f8e744c81802.js +17 -0
  327. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-6fc5f8e744c81802.js +17 -0
  328. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-6fc5f8e744c81802.js +17 -0
  329. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-6fc5f8e744c81802.js +17 -0
  330. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-6fc5f8e744c81802.js +17 -0
  331. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-6fc5f8e744c81802.js +17 -0
  332. package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-6fc5f8e744c81802.js +17 -0
  333. package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-6fc5f8e744c81802.js +17 -0
  334. package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-6fc5f8e744c81802.js +17 -0
  335. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-6fc5f8e744c81802.js +17 -0
  336. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-6fc5f8e744c81802.js +17 -0
  337. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-6fc5f8e744c81802.js +17 -0
  338. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-6fc5f8e744c81802.js +17 -0
  339. package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-6fc5f8e744c81802.js +17 -0
  340. package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-6fc5f8e744c81802.js +17 -0
  341. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-6fc5f8e744c81802.js +17 -0
  342. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-6fc5f8e744c81802.js +17 -0
  343. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-6fc5f8e744c81802.js +17 -0
  344. package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-6fc5f8e744c81802.js +17 -0
  345. package/.next/standalone/.next/static/chunks/app/api/v1/health/route-6fc5f8e744c81802.js +17 -0
  346. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-6fc5f8e744c81802.js +17 -0
  347. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-6fc5f8e744c81802.js +17 -0
  348. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-6fc5f8e744c81802.js +17 -0
  349. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-6fc5f8e744c81802.js +17 -0
  350. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-6fc5f8e744c81802.js +17 -0
  351. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-6fc5f8e744c81802.js +17 -0
  352. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-6fc5f8e744c81802.js +17 -0
  353. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-6fc5f8e744c81802.js +17 -0
  354. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-6fc5f8e744c81802.js +17 -0
  355. package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-6fc5f8e744c81802.js +17 -0
  356. package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-6fc5f8e744c81802.js +17 -0
  357. package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-6fc5f8e744c81802.js +17 -0
  358. package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-6fc5f8e744c81802.js +17 -0
  359. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-6fc5f8e744c81802.js +17 -0
  360. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-6fc5f8e744c81802.js +17 -0
  361. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-6fc5f8e744c81802.js +17 -0
  362. package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-6fc5f8e744c81802.js +17 -0
  363. package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-6fc5f8e744c81802.js +17 -0
  364. package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-6fc5f8e744c81802.js +17 -0
  365. package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-6fc5f8e744c81802.js +17 -0
  366. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-6fc5f8e744c81802.js +17 -0
  367. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-6fc5f8e744c81802.js +17 -0
  368. package/.next/standalone/.next/static/chunks/app/api/v1/models/route-6fc5f8e744c81802.js +17 -0
  369. package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-6fc5f8e744c81802.js +17 -0
  370. package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-6fc5f8e744c81802.js +17 -0
  371. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-6fc5f8e744c81802.js +17 -0
  372. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-6fc5f8e744c81802.js +17 -0
  373. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-6fc5f8e744c81802.js +17 -0
  374. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-6fc5f8e744c81802.js +17 -0
  375. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-6fc5f8e744c81802.js +17 -0
  376. package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-6fc5f8e744c81802.js +17 -0
  377. package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-6fc5f8e744c81802.js +17 -0
  378. package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-6fc5f8e744c81802.js +17 -0
  379. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-6fc5f8e744c81802.js +17 -0
  380. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-6fc5f8e744c81802.js +17 -0
  381. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-6fc5f8e744c81802.js +17 -0
  382. package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-6fc5f8e744c81802.js +17 -0
  383. package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-6fc5f8e744c81802.js +17 -0
  384. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-6fc5f8e744c81802.js +17 -0
  385. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-6fc5f8e744c81802.js +17 -0
  386. package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-6fc5f8e744c81802.js +17 -0
  387. package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-6fc5f8e744c81802.js +17 -0
  388. package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-6fc5f8e744c81802.js +17 -0
  389. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-6fc5f8e744c81802.js +17 -0
  390. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-6fc5f8e744c81802.js +17 -0
  391. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-6fc5f8e744c81802.js +17 -0
  392. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-6fc5f8e744c81802.js +17 -0
  393. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-6fc5f8e744c81802.js +17 -0
  394. package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-6fc5f8e744c81802.js +17 -0
  395. package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-6fc5f8e744c81802.js +17 -0
  396. package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-6fc5f8e744c81802.js +17 -0
  397. package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-6fc5f8e744c81802.js +17 -0
  398. package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-6fc5f8e744c81802.js +17 -0
  399. package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-6fc5f8e744c81802.js +17 -0
  400. package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-6fc5f8e744c81802.js +17 -0
  401. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-6fc5f8e744c81802.js +17 -0
  402. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-6fc5f8e744c81802.js +17 -0
  403. package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-6fc5f8e744c81802.js +17 -0
  404. package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-6fc5f8e744c81802.js +17 -0
  405. package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-6fc5f8e744c81802.js +17 -0
  406. package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-6fc5f8e744c81802.js +17 -0
  407. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-6fc5f8e744c81802.js +17 -0
  408. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-6fc5f8e744c81802.js +17 -0
  409. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/activity/route-6fc5f8e744c81802.js +17 -0
  410. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-6fc5f8e744c81802.js +17 -0
  411. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-6fc5f8e744c81802.js +17 -0
  412. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-6fc5f8e744c81802.js +17 -0
  413. package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-6fc5f8e744c81802.js +17 -0
  414. package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-6fc5f8e744c81802.js +17 -0
  415. package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-6fc5f8e744c81802.js +17 -0
  416. package/.next/standalone/.next/static/chunks/app/api/v1/update/route-6fc5f8e744c81802.js +17 -0
  417. package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-6fc5f8e744c81802.js +17 -0
  418. package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-6fc5f8e744c81802.js +17 -0
  419. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-6fc5f8e744c81802.js +17 -0
  420. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-6fc5f8e744c81802.js +17 -0
  421. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-6fc5f8e744c81802.js +17 -0
  422. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-6fc5f8e744c81802.js +17 -0
  423. package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-6fc5f8e744c81802.js +17 -0
  424. package/.next/standalone/.next/static/chunks/app/{page-7017f07f8a7a083c.js → page-04748847c6ff866f.js} +1013 -585
  425. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-6fc5f8e744c81802.js +17 -0
  426. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-6fc5f8e744c81802.js +17 -0
  427. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-6fc5f8e744c81802.js +17 -0
  428. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-6fc5f8e744c81802.js +17 -0
  429. package/.next/standalone/.next/static/css/{d80058f0b9b41c09.css → 2669e8744cc8c212.css} +2 -2
  430. package/.next/standalone/docs/adoption/changesets.json +358 -0
  431. package/.next/standalone/lib/skills/builtins/memory-organization/SKILL.md +16 -0
  432. package/.next/standalone/package.json +3 -3
  433. package/CHANGELOG.md +44 -0
  434. package/api/client.ts +9 -0
  435. package/api/types.ts +29 -0
  436. package/app/api/v1/lifecycle/adoption/route.ts +14 -2
  437. package/app/api/v1/models/[name]/compact-threads/route.ts +14 -11
  438. package/app/api/v1/threads/[thread_id]/activity/route.ts +19 -0
  439. package/app/api/v1/threads/[thread_id]/context-pin/route.test.ts +1 -0
  440. package/app/api/v1/threads/[thread_id]/context-pin/route.ts +2 -1
  441. package/app/api/v1/threads/[thread_id]/route.ts +5 -1
  442. package/app/api/v1/threads/[thread_id]/run/route.ts +0 -1
  443. package/components/chat/ChatView.tsx +52 -11
  444. package/components/chat/ContextBoundary.test.tsx +68 -1
  445. package/components/chat/ContextBoundary.tsx +92 -13
  446. package/components/chat/MessageBubble.tsx +12 -0
  447. package/components/chat/MessageList.test.tsx +31 -0
  448. package/components/chat/MessageList.tsx +49 -28
  449. package/components/chat/ToolList.test.tsx +92 -16
  450. package/components/chat/ToolList.tsx +59 -4
  451. package/components/chat/chat-helpers.test.tsx +24 -1
  452. package/components/chat/chat-helpers.ts +47 -4
  453. package/components/chat/useThreadActivity.test.tsx +113 -0
  454. package/components/chat/useThreadActivity.ts +94 -0
  455. package/components/chat/useThreadData.ts +16 -16
  456. package/components/chat/workflow-step-retry.ts +25 -0
  457. package/components/integrations/NetworkSection.tsx +2 -2
  458. package/components/ui/BootScreen.tsx +17 -0
  459. package/components/ui/WorkflowChecklist.tsx +71 -33
  460. package/hooks/useSSE.ts +28 -3
  461. package/lib/agents/citation-checker.test.ts +40 -2
  462. package/lib/agents/citation-checker.ts +56 -11
  463. package/lib/agents/compaction-pipeline.test.ts +202 -0
  464. package/lib/agents/compaction-pipeline.ts +483 -0
  465. package/lib/agents/context-boundary.ts +5 -6
  466. package/lib/agents/conversation-summary.ts +37 -21
  467. package/lib/agents/instruction-edits.test.ts +120 -0
  468. package/lib/agents/instruction-edits.ts +65 -42
  469. package/lib/agents/prepare/history-window.test.ts +18 -0
  470. package/lib/agents/prepare/history-window.ts +11 -2
  471. package/lib/agents/prepare/request.ts +4 -2
  472. package/lib/agents/prepare/system-prompt.test.ts +49 -0
  473. package/lib/agents/prepare/system-prompt.ts +16 -5
  474. package/lib/agents/prompt-registry.test.ts +5 -140
  475. package/lib/agents/prompt-registry.ts +45 -1
  476. package/lib/agents/prompt-variants.ts +146 -0
  477. package/lib/agents/proposals.test.ts +76 -0
  478. package/lib/agents/proposals.ts +13 -5
  479. package/lib/agents/run-registry.test.ts +22 -0
  480. package/lib/agents/run-registry.ts +29 -0
  481. package/lib/agents/run-thread.auto-boundary.test.ts +125 -5
  482. package/lib/agents/run-thread.retry.test.ts +67 -1
  483. package/lib/agents/run-thread.ts +110 -10
  484. package/lib/agents/sqlite-checkpoint-saver.test.ts +91 -0
  485. package/lib/agents/thread-activity.test.ts +31 -0
  486. package/lib/agents/thread-activity.ts +27 -0
  487. package/lib/agents/thread-compaction-state.test.ts +82 -0
  488. package/lib/agents/thread-compaction-state.ts +121 -0
  489. package/lib/agents/thread-compaction.test.ts +83 -4
  490. package/lib/agents/thread-compaction.ts +34 -11
  491. package/lib/agents/warm-summary-background.test.ts +219 -5
  492. package/lib/agents/warm-summary-background.ts +346 -143
  493. package/lib/agents/warm-topics.test.ts +191 -0
  494. package/lib/agents/warm-topics.ts +317 -0
  495. package/lib/agents/workflow-step-retry.test.ts +96 -0
  496. package/lib/agents/workflow-step-retry.ts +216 -0
  497. package/lib/api/browser-control.ts +0 -3
  498. package/lib/bridges/dispatcher.ts +1 -0
  499. package/lib/bridges/message-role.test.ts +81 -0
  500. package/lib/bridges/message-role.ts +23 -10
  501. package/lib/bridges/types.ts +6 -0
  502. package/lib/bridges/whatsapp-link.test.ts +32 -0
  503. package/lib/bridges/whatsapp-link.ts +21 -0
  504. package/lib/bridges/whatsapp.inbound.test.ts +239 -0
  505. package/lib/bridges/whatsapp.sender.test.ts +80 -1
  506. package/lib/bridges/whatsapp.ts +76 -38
  507. package/lib/db/migrations.ts +5 -0
  508. package/lib/env/config.ts +2 -0
  509. package/lib/env/schema.ts +12 -0
  510. package/lib/lifecycle/changeset-build.test.ts +93 -0
  511. package/lib/lifecycle/changeset-build.ts +210 -0
  512. package/lib/lifecycle/changesets.test.ts +101 -0
  513. package/lib/lifecycle/changesets.ts +166 -0
  514. package/lib/lifecycle/surface-collect.test.ts +88 -0
  515. package/lib/lifecycle/surface-collect.ts +64 -0
  516. package/lib/lifecycle/surface-snapshot.test.ts +104 -0
  517. package/lib/lifecycle/surface-snapshot.ts +210 -0
  518. package/lib/memory/record.ts +0 -2
  519. package/lib/pricing/snapshot.test.ts +70 -0
  520. package/lib/pricing/snapshot.ts +10 -2
  521. package/lib/providers/external.ts +0 -2
  522. package/lib/proxy/dispatcher.test.ts +119 -1
  523. package/lib/proxy/dispatcher.ts +22 -9
  524. package/lib/skills/builtins/memory-organization/SKILL.md +16 -0
  525. package/lib/stores/agent-configs.ts +10 -5
  526. package/lib/stores/bridges.test.ts +81 -0
  527. package/lib/stores/bridges.ts +9 -8
  528. package/lib/stores/proxy-config.test.ts +120 -0
  529. package/lib/stores/proxy-config.ts +22 -4
  530. package/lib/stores/threads.test.ts +9 -0
  531. package/lib/stores/threads.ts +33 -19
  532. package/lib/stores/version-adoption.test.ts +96 -0
  533. package/lib/stores/version-adoption.ts +239 -26
  534. package/lib/stores/workflow-progress.ts +3 -0
  535. package/lib/tools/communications/calendar.test.ts +43 -2
  536. package/lib/tools/communications/calendar.ts +2 -0
  537. package/lib/tools/communications/gmail.test.ts +51 -1
  538. package/lib/tools/communications/gmail.ts +44 -2
  539. package/lib/tools/communications/ms-todo.ts +0 -7
  540. package/lib/tools/communications/outlook-calendar.ts +2 -0
  541. package/lib/tools/communications/outlook.test.ts +33 -2
  542. package/lib/tools/communications/outlook.ts +2 -0
  543. package/lib/tools/filesystem/edit-match.test.ts +133 -0
  544. package/lib/tools/filesystem/edit-match.ts +7 -2
  545. package/lib/tools/general/memory.ts +1 -1
  546. package/lib/tools/general/workflow-progress.ts +2 -0
  547. package/lib/tools/runtime/catalog.ts +1 -25
  548. package/lib/tools/support/result-refs.test.ts +131 -0
  549. package/lib/tools/support/result-refs.ts +41 -9
  550. package/lib/triggers/registry.ts +0 -4
  551. package/lib/utils/source-link.test.ts +51 -0
  552. package/lib/utils/source-link.ts +45 -0
  553. package/package.json +3 -3
  554. package/scripts/install-to-system.ps1 +39 -11
  555. package/scripts/install-to-system.sh +37 -3
  556. package/.next/standalone/.next/server/chunks/3979.js +0 -581
  557. package/.next/standalone/.next/server/chunks/5936.js +0 -594
  558. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-36cb8b428b38b26a.js +0 -17
  559. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-36cb8b428b38b26a.js +0 -17
  560. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-36cb8b428b38b26a.js +0 -17
  561. package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-36cb8b428b38b26a.js +0 -17
  562. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-36cb8b428b38b26a.js +0 -17
  563. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-36cb8b428b38b26a.js +0 -17
  564. package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-36cb8b428b38b26a.js +0 -17
  565. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-36cb8b428b38b26a.js +0 -17
  566. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-36cb8b428b38b26a.js +0 -17
  567. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-36cb8b428b38b26a.js +0 -17
  568. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-36cb8b428b38b26a.js +0 -17
  569. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-36cb8b428b38b26a.js +0 -17
  570. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-36cb8b428b38b26a.js +0 -17
  571. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-36cb8b428b38b26a.js +0 -17
  572. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-36cb8b428b38b26a.js +0 -17
  573. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-36cb8b428b38b26a.js +0 -17
  574. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-36cb8b428b38b26a.js +0 -17
  575. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-36cb8b428b38b26a.js +0 -17
  576. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-36cb8b428b38b26a.js +0 -17
  577. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-36cb8b428b38b26a.js +0 -17
  578. package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-36cb8b428b38b26a.js +0 -17
  579. package/.next/standalone/.next/static/chunks/app/api/v1/config/route-36cb8b428b38b26a.js +0 -17
  580. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-36cb8b428b38b26a.js +0 -17
  581. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-36cb8b428b38b26a.js +0 -17
  582. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-36cb8b428b38b26a.js +0 -17
  583. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-36cb8b428b38b26a.js +0 -17
  584. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-36cb8b428b38b26a.js +0 -17
  585. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-36cb8b428b38b26a.js +0 -17
  586. package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-36cb8b428b38b26a.js +0 -17
  587. package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-36cb8b428b38b26a.js +0 -17
  588. package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-36cb8b428b38b26a.js +0 -17
  589. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-36cb8b428b38b26a.js +0 -17
  590. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-36cb8b428b38b26a.js +0 -17
  591. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-36cb8b428b38b26a.js +0 -17
  592. package/.next/standalone/.next/static/chunks/app/api/v1/env/route-36cb8b428b38b26a.js +0 -17
  593. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-36cb8b428b38b26a.js +0 -17
  594. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-36cb8b428b38b26a.js +0 -17
  595. package/.next/standalone/.next/static/chunks/app/api/v1/events/route-36cb8b428b38b26a.js +0 -17
  596. package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-36cb8b428b38b26a.js +0 -17
  597. package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-36cb8b428b38b26a.js +0 -17
  598. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-36cb8b428b38b26a.js +0 -17
  599. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-36cb8b428b38b26a.js +0 -17
  600. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-36cb8b428b38b26a.js +0 -17
  601. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-36cb8b428b38b26a.js +0 -17
  602. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-36cb8b428b38b26a.js +0 -17
  603. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-36cb8b428b38b26a.js +0 -17
  604. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-36cb8b428b38b26a.js +0 -17
  605. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-36cb8b428b38b26a.js +0 -17
  606. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-36cb8b428b38b26a.js +0 -17
  607. package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-36cb8b428b38b26a.js +0 -17
  608. package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-36cb8b428b38b26a.js +0 -17
  609. package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-36cb8b428b38b26a.js +0 -17
  610. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-36cb8b428b38b26a.js +0 -17
  611. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-36cb8b428b38b26a.js +0 -17
  612. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-36cb8b428b38b26a.js +0 -17
  613. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-36cb8b428b38b26a.js +0 -17
  614. package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-36cb8b428b38b26a.js +0 -17
  615. package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-36cb8b428b38b26a.js +0 -17
  616. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-36cb8b428b38b26a.js +0 -17
  617. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-36cb8b428b38b26a.js +0 -17
  618. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-36cb8b428b38b26a.js +0 -17
  619. package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-36cb8b428b38b26a.js +0 -17
  620. package/.next/standalone/.next/static/chunks/app/api/v1/health/route-36cb8b428b38b26a.js +0 -17
  621. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-36cb8b428b38b26a.js +0 -17
  622. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-36cb8b428b38b26a.js +0 -17
  623. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-36cb8b428b38b26a.js +0 -17
  624. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-36cb8b428b38b26a.js +0 -17
  625. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-36cb8b428b38b26a.js +0 -17
  626. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-36cb8b428b38b26a.js +0 -17
  627. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-36cb8b428b38b26a.js +0 -17
  628. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-36cb8b428b38b26a.js +0 -17
  629. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-36cb8b428b38b26a.js +0 -17
  630. package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-36cb8b428b38b26a.js +0 -17
  631. package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-36cb8b428b38b26a.js +0 -17
  632. package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-36cb8b428b38b26a.js +0 -17
  633. package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-36cb8b428b38b26a.js +0 -17
  634. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-36cb8b428b38b26a.js +0 -17
  635. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-36cb8b428b38b26a.js +0 -17
  636. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-36cb8b428b38b26a.js +0 -17
  637. package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-36cb8b428b38b26a.js +0 -17
  638. package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-36cb8b428b38b26a.js +0 -17
  639. package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-36cb8b428b38b26a.js +0 -17
  640. package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-36cb8b428b38b26a.js +0 -17
  641. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-36cb8b428b38b26a.js +0 -17
  642. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-36cb8b428b38b26a.js +0 -17
  643. package/.next/standalone/.next/static/chunks/app/api/v1/models/route-36cb8b428b38b26a.js +0 -17
  644. package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-36cb8b428b38b26a.js +0 -17
  645. package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-36cb8b428b38b26a.js +0 -17
  646. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-36cb8b428b38b26a.js +0 -17
  647. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-36cb8b428b38b26a.js +0 -17
  648. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-36cb8b428b38b26a.js +0 -17
  649. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-36cb8b428b38b26a.js +0 -17
  650. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-36cb8b428b38b26a.js +0 -17
  651. package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-36cb8b428b38b26a.js +0 -17
  652. package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-36cb8b428b38b26a.js +0 -17
  653. package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-36cb8b428b38b26a.js +0 -17
  654. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-36cb8b428b38b26a.js +0 -17
  655. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-36cb8b428b38b26a.js +0 -17
  656. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-36cb8b428b38b26a.js +0 -17
  657. package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-36cb8b428b38b26a.js +0 -17
  658. package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-36cb8b428b38b26a.js +0 -17
  659. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-36cb8b428b38b26a.js +0 -17
  660. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-36cb8b428b38b26a.js +0 -17
  661. package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-36cb8b428b38b26a.js +0 -17
  662. package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-36cb8b428b38b26a.js +0 -17
  663. package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-36cb8b428b38b26a.js +0 -17
  664. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-36cb8b428b38b26a.js +0 -17
  665. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-36cb8b428b38b26a.js +0 -17
  666. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-36cb8b428b38b26a.js +0 -17
  667. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-36cb8b428b38b26a.js +0 -17
  668. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-36cb8b428b38b26a.js +0 -17
  669. package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-36cb8b428b38b26a.js +0 -17
  670. package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-36cb8b428b38b26a.js +0 -17
  671. package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-36cb8b428b38b26a.js +0 -17
  672. package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-36cb8b428b38b26a.js +0 -17
  673. package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-36cb8b428b38b26a.js +0 -17
  674. package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-36cb8b428b38b26a.js +0 -17
  675. package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-36cb8b428b38b26a.js +0 -17
  676. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-36cb8b428b38b26a.js +0 -17
  677. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-36cb8b428b38b26a.js +0 -17
  678. package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-36cb8b428b38b26a.js +0 -17
  679. package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-36cb8b428b38b26a.js +0 -17
  680. package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-36cb8b428b38b26a.js +0 -17
  681. package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-36cb8b428b38b26a.js +0 -17
  682. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-36cb8b428b38b26a.js +0 -17
  683. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-36cb8b428b38b26a.js +0 -17
  684. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-36cb8b428b38b26a.js +0 -17
  685. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-36cb8b428b38b26a.js +0 -17
  686. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-36cb8b428b38b26a.js +0 -17
  687. package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-36cb8b428b38b26a.js +0 -17
  688. package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-36cb8b428b38b26a.js +0 -17
  689. package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-36cb8b428b38b26a.js +0 -17
  690. package/.next/standalone/.next/static/chunks/app/api/v1/update/route-36cb8b428b38b26a.js +0 -17
  691. package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-36cb8b428b38b26a.js +0 -17
  692. package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-36cb8b428b38b26a.js +0 -17
  693. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-36cb8b428b38b26a.js +0 -17
  694. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-36cb8b428b38b26a.js +0 -17
  695. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-36cb8b428b38b26a.js +0 -17
  696. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-36cb8b428b38b26a.js +0 -17
  697. package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-36cb8b428b38b26a.js +0 -17
  698. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-36cb8b428b38b26a.js +0 -17
  699. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-36cb8b428b38b26a.js +0 -17
  700. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-36cb8b428b38b26a.js +0 -17
  701. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-36cb8b428b38b26a.js +0 -17
  702. /package/.next/standalone/.next/static/{NUrC9xax1sp1Q70nlFqS6 → hwujW4hR1b-r3k5WdMxZO}/_buildManifest.js +0 -0
  703. /package/.next/standalone/.next/static/{NUrC9xax1sp1Q70nlFqS6 → hwujW4hR1b-r3k5WdMxZO}/_ssgManifest.js +0 -0
@@ -378,6 +378,13 @@ module.exports = require("node:path");
378
378
 
379
379
  /***/ }),
380
380
 
381
+ /***/ 77030:
382
+ /***/ ((module) => {
383
+
384
+ module.exports = require("node:net");
385
+
386
+ /***/ }),
387
+
381
388
  /***/ 77598:
382
389
  /***/ ((module) => {
383
390
 
@@ -413,953 +420,953 @@ module.exports = require("http");
413
420
 
414
421
  /***/ }),
415
422
 
416
- /***/ 86439:
417
- /***/ ((module) => {
418
-
419
- module.exports = require("next/dist/shared/lib/no-fallback-error.external");
420
-
421
- /***/ }),
422
-
423
- /***/ 89052:
423
+ /***/ 82637:
424
424
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
425
425
 
426
426
  __webpack_require__.r(__webpack_exports__);
427
427
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
428
- /* harmony export */ GET: () => (/* binding */ GET)
428
+ /* harmony export */ handler: () => (/* binding */ handler),
429
+ /* harmony export */ patchFetch: () => (/* binding */ patchFetch),
430
+ /* harmony export */ routeModule: () => (/* binding */ routeModule),
431
+ /* harmony export */ serverHooks: () => (/* binding */ serverHooks),
432
+ /* harmony export */ workAsyncStorage: () => (/* binding */ workAsyncStorage),
433
+ /* harmony export */ workUnitAsyncStorage: () => (/* binding */ workUnitAsyncStorage)
429
434
  /* harmony export */ });
430
- /* harmony import */ var _lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(89080);
431
- /* harmony import */ var _lib_stores_integrations__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(78228);
432
- /* harmony import */ var _lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67637);
433
- /* harmony import */ var _app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(41044);
434
- /* harmony import */ var _lib_utils_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(22032);
435
+ /* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19225);
436
+ /* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__);
437
+ /* harmony import */ var next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(84006);
438
+ /* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8317);
439
+ /* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__);
440
+ /* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(99373);
441
+ /* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__);
442
+ /* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34775);
443
+ /* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__);
444
+ /* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(24235);
445
+ /* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__);
446
+ /* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(261);
447
+ /* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__);
448
+ /* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(54365);
449
+ /* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__);
450
+ /* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(90771);
451
+ /* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__);
452
+ /* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(73461);
453
+ /* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__);
454
+ /* harmony import */ var next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(67798);
455
+ /* harmony import */ var next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(92280);
456
+ /* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(62018);
457
+ /* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__);
458
+ /* harmony import */ var next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(45696);
459
+ /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(47929);
460
+ /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__);
461
+ /* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(86439);
462
+ /* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__);
463
+ /* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(10246);
464
+ /* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__);
465
+ /* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(37527);
466
+ /* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__);
435
467
 
436
468
 
437
469
 
438
470
 
439
471
 
440
- // GET /api/v1/integrations/outlook/oauth/callback?code=…&state=…
441
- //
442
- // Microsoft redirects the user's browser here after consent. We look up the
443
- // pending flow by `state`, exchange the auth code for a refresh_token,
444
- // persist the integration, and return a small HTML page telling the user
445
- // they can close the tab. The Integrations panel polls /oauth/status.
446
- async function GET(req) {
447
- const url = req.nextUrl;
448
- const state = url.searchParams.get("state") ?? "";
449
- const code = url.searchParams.get("code") ?? "";
450
- const errParam = url.searchParams.get("error");
451
- const errDesc = url.searchParams.get("error_description");
452
- const flow = state ? (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .getFlow */ .lv)(state) : undefined;
453
- if (!flow) {
454
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)("Authorization session not found or expired. Please retry from Jarela.", true);
455
- }
456
- if (errParam) {
457
- const msg = errDesc ? `${errParam}: ${errDesc}` : errParam;
458
- (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
459
- status: "error",
460
- error: msg
461
- });
462
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(`Microsoft reported an error: ${(0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .escapeHtml */ .Z)(msg)}. You can close this tab.`, true);
463
- }
464
- if (!code) {
465
- (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
466
- status: "error",
467
- error: "no code returned"
468
- });
469
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)("Microsoft did not return an authorization code.", true);
470
- }
471
- try {
472
- const tok = await (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .exchangeCode */ .Dd)({
473
- code,
474
- clientId: flow.clientId,
475
- clientSecret: flow.clientSecret,
476
- redirectUri: flow.redirectUri
477
- });
478
- if (!tok.refresh_token) {
479
- const msg = "Microsoft did not return a refresh_token. Make sure your Azure app " + "registration includes the offline_access scope and that the consent " + "screen approves it.";
480
- (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
481
- status: "error",
482
- error: msg
483
- });
484
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(msg, true);
485
- }
486
- const saved = persistRefreshToken({
487
- credentialId: flow.credentialId,
488
- clientId: flow.clientId,
489
- clientSecret: flow.clientSecret,
490
- refreshToken: tok.refresh_token
491
- });
492
- if ("error" in saved) {
493
- (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
494
- status: "error",
495
- error: saved.error
496
- });
497
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(`Failed to save: ${(0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .escapeHtml */ .Z)(saved.error)}`, true);
498
- }
499
- (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
500
- status: "done"
501
- });
502
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)("Outlook connected. You can close this tab and return to Jarela.", false);
503
- } catch (e) {
504
- const msg = (0,_lib_utils_error__WEBPACK_IMPORTED_MODULE_4__/* .errorMessage */ .g)(e);
505
- (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
506
- status: "error",
507
- error: msg
508
- });
509
- return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(`Token exchange failed: ${(0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .escapeHtml */ .Z)(msg)}`, true);
510
- }
511
- }
512
- function persistRefreshToken(input) {
513
- if (input.credentialId) {
514
- const cred = (0,_lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__/* .getCredential */ .w_)(input.credentialId);
515
- if (!cred || cred.provider !== "outlook") {
516
- return {
517
- error: "credential not found"
518
- };
519
- }
520
- const merged = {
521
- ...(0,_lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__/* .getCredentialParams */ .WY)(cred),
522
- client_id: input.clientId,
523
- client_secret: input.clientSecret,
524
- refresh_token: input.refreshToken
525
- };
526
- (0,_lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__/* .updateCredential */ .nZ)(input.credentialId, {
527
- auth_method: "oauth",
528
- params: merged
529
- });
530
- return {
531
- ok: true
532
- };
533
- }
534
- const saved = (0,_lib_stores_integrations__WEBPACK_IMPORTED_MODULE_1__/* .saveIntegration */ .oO)("outlook", {
535
- client_id: input.clientId,
536
- client_secret: input.clientSecret,
537
- refresh_token: input.refreshToken
538
- });
539
- if ("error" in saved) return saved;
540
- return {
541
- ok: true
542
- };
543
- }
544
472
 
545
473
 
546
- /***/ }),
547
474
 
548
- /***/ 89080:
549
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
550
475
 
551
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
552
- /* harmony export */ Ah: () => (/* binding */ updateFlow),
553
- /* harmony export */ Dd: () => (/* binding */ exchangeCode),
554
- /* harmony export */ F8: () => (/* binding */ createFlow),
555
- /* harmony export */ i8: () => (/* binding */ getMicrosoftAccessToken),
556
- /* harmony export */ jG: () => (/* binding */ resolveMicrosoftAuth),
557
- /* harmony export */ lv: () => (/* binding */ getFlow),
558
- /* harmony export */ op: () => (/* binding */ graphPaged),
559
- /* harmony export */ xj: () => (/* binding */ buildAuthorizeUrl),
560
- /* harmony export */ z$: () => (/* binding */ graphFetch)
561
- /* harmony export */ });
562
- /* unused harmony export MICROSOFT_SCOPES */
563
- /* harmony import */ var _lib_stores_integrations__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(78228);
564
- /* harmony import */ var _lib_utils_oauth_flow_store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(56362);
565
- /* harmony import */ var _lib_utils_json__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(53638);
566
- /* harmony import */ var _lib_utils_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(22032);
567
- /* harmony import */ var _lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(22632);
568
- // Ephemeral state store + shared auth helpers for the in-app Microsoft OAuth
569
- // flow. Mirrors lib/integrations/gmail-oauth.ts but targets the Microsoft
570
- // identity platform (v2.0 endpoint, common tenant by default) and Microsoft
571
- // Graph as the downstream API surface (Outlook Mail + Calendar in v1).
572
- //
573
- // The user types client_id + client_secret in the Integrations panel and
574
- // clicks "Connect Outlook". We POST those to /oauth/start, which stashes
575
- // them here keyed by a random `state` token and returns the Microsoft
576
- // authorize URL. The browser opens that URL; MS bounces back to
577
- // /oauth/callback with `?code&state`, which exchanges the code for a
578
- // refresh_token (granted because we asked for `offline_access`) and
579
- // persists the integration. The panel polls /oauth/status separately.
580
- //
581
- // Pinned to globalThis so HMR in dev doesn't lose pending flows.
582
476
 
583
477
 
584
478
 
585
479
 
586
480
 
587
- const flowStore = (0,_lib_utils_oauth_flow_store__WEBPACK_IMPORTED_MODULE_1__/* .createOAuthFlowStore */ .R)({
588
- globalKey: "__msOauthFlows"
481
+
482
+
483
+
484
+
485
+ // We inject the nextConfigOutput here so that we can use them in the route
486
+ // module.
487
+ const nextConfigOutput = "standalone"
488
+ const routeModule = new next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__.AppRouteRouteModule({
489
+ definition: {
490
+ kind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
491
+ page: "/api/v1/integrations/outlook/oauth/callback/route",
492
+ pathname: "/api/v1/integrations/outlook/oauth/callback",
493
+ filename: "route",
494
+ bundlePath: "app/api/v1/integrations/outlook/oauth/callback/route"
495
+ },
496
+ distDir: ".next" || 0,
497
+ relativeProjectDir: false || '',
498
+ resolvedPagePath: "/home/runner/work/jarela/jarela/app/api/v1/integrations/outlook/oauth/callback/route.ts",
499
+ nextConfigOutput,
500
+ // The lazy require factory ensures that:
501
+ // - In dev: devRequestTimingInternalsEnd is set before userland executes,
502
+ // correctly attributing module load time to application-code rather than
503
+ // framework internals.
504
+ // - In all modes: async modules (route files with top-level await) are
505
+ // handled correctly — require() returns a Promise for such modules, which
506
+ // ensureUserland() awaits before the first request is handled.
507
+ userland: ()=>__webpack_require__(89052),
508
+ // In Turbopack dev mode, also provide a synchronous per-request getter so
509
+ // server HMR updates are picked up without re-executing the entry chunk.
510
+ // Using require() (synchronous) avoids adding async overhead that would be
511
+ // incorrectly attributed to application-code time in devRequestTiming.
512
+ ... false ? 0 : {}
589
513
  });
590
- const createFlow = flowStore.create;
591
- const getFlow = flowStore.get;
592
- const updateFlow = flowStore.update;
593
- // Tenant selector. `common` accepts both personal Microsoft accounts
594
- // (@outlook.com, @hotmail.com, @live.com) and work/school M365 accounts.
595
- // Switch to `consumers` to lock to personal only, or `organizations` for
596
- // work/school only. We expose this as an env override for power users but
597
- // don't surface it in the UI yet.
598
- const TENANT = process.env.OUTLOOK_TENANT?.trim() || "common";
599
- // Delegated Graph scopes the agent needs. Keep narrow:
600
- // - offline_access → required for a refresh_token (MS counterpart of
601
- // Google's access_type=offline).
602
- // - User.Read → used by the test endpoint to call /me.
603
- // - Mail.ReadWrite → search/read mail, create drafts, mark read,
604
- // move to folders (incl. DeletedItems).
605
- // - Mail.Send → send mail when the user explicitly asks for it.
606
- // - Calendars.ReadWrite → list/get/create/update/delete events on the
607
- // user's existing calendars.
608
- // - Tasks.ReadWrite → list/get/create/update/complete/delete Microsoft
609
- // To Do tasks and lists (ms_todo_* tools).
610
- // - People.Read → resolve "who is X" / frequent contacts via
611
- // /me/people (ms_people_resolve tool).
612
- const MICROSOFT_SCOPES = [
613
- "offline_access",
614
- "User.Read",
615
- "Mail.ReadWrite",
616
- "Mail.Send",
617
- "Calendars.ReadWrite",
618
- "Tasks.ReadWrite",
619
- "People.Read"
620
- ];
621
- function buildAuthorizeUrl(opts) {
622
- const p = new URLSearchParams({
623
- client_id: opts.clientId,
624
- redirect_uri: opts.redirectUri,
625
- response_type: "code",
626
- response_mode: "query",
627
- scope: MICROSOFT_SCOPES.join(" "),
628
- // Force consent so a returning user actually re-grants any newly-added
629
- // scope (otherwise MS silently reuses the prior grant minus the new bit).
630
- prompt: "consent",
631
- state: opts.state
514
+ // Pull out the exports that we need to expose from the module. This should
515
+ // be eliminated when we've moved the other routes to the new format. These
516
+ // are used to hook into the route.
517
+ const { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;
518
+ function patchFetch() {
519
+ return (0,next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__.patchFetch)({
520
+ workAsyncStorage,
521
+ workUnitAsyncStorage
632
522
  });
633
- return `https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/authorize?${p.toString()}`;
634
523
  }
635
- // NOTE: Unlike Google, MS v2 endpoint **requires** the `scope` parameter on
636
- // every grant_type call (both authorization_code and refresh_token). Leaving
637
- // it out yields `AADSTS900144: The request body must contain the following
638
- // parameter: 'scope'.`. We always pass the full scope set.
639
- async function exchangeCode(opts) {
640
- const clientId = (0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .sanitizeOAuthInput */ .d)(opts.clientId) ?? "";
641
- const clientSecret = (0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .sanitizeOAuthInput */ .d)(opts.clientSecret) ?? "";
642
- const body = new URLSearchParams({
643
- code: opts.code,
644
- client_id: clientId,
645
- client_secret: clientSecret,
646
- redirect_uri: opts.redirectUri,
647
- grant_type: "authorization_code",
648
- scope: MICROSOFT_SCOPES.join(" ")
649
- });
650
- const res = await fetch(`https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/token`, {
651
- method: "POST",
652
- headers: {
653
- "Content-Type": "application/x-www-form-urlencoded"
654
- },
655
- body: body.toString(),
656
- signal: AbortSignal.timeout(30000)
657
- });
658
- const text = await res.text();
659
- const parsed = (0,_lib_utils_json__WEBPACK_IMPORTED_MODULE_3__/* .parseJsonSafe */ .p)(text, {});
660
- if (!res.ok) {
661
- const err = parsed["error_description"] || parsed["error"] || text || `HTTP ${res.status}`;
662
- console.error(`[microsoft-oauth] token exchange rejected (${res.status}): ${err} | client_id ${(0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .secretFingerprint */ .n)(clientId)} | client_secret ${(0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .secretFingerprint */ .n)(clientSecret)}`);
663
- throw new Error(err);
524
+
525
+ async function handler(req, res, ctx) {
526
+ if (ctx.requestMeta) {
527
+ (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.setRequestMeta)(req, ctx.requestMeta);
664
528
  }
665
- return parsed;
666
- }
667
- function resolveMicrosoftAuth() {
668
- const envId = process.env.OUTLOOK_CLIENT_ID;
669
- const envSecret = process.env.OUTLOOK_CLIENT_SECRET;
670
- const envRefresh = process.env.OUTLOOK_REFRESH_TOKEN;
671
- if (envId && envSecret && envRefresh) {
672
- return {
673
- client_id: envId,
674
- client_secret: envSecret,
675
- refresh_token: envRefresh
676
- };
529
+ if (routeModule.isDev) {
530
+ (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.addRequestMeta)(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());
677
531
  }
678
- const saved = (0,_lib_stores_integrations__WEBPACK_IMPORTED_MODULE_0__/* .getIntegrationRaw */ .$G)("outlook");
679
- if (saved?.client_id && saved.client_secret && saved.refresh_token) {
680
- return {
681
- client_id: saved.client_id,
682
- client_secret: saved.client_secret,
683
- refresh_token: saved.refresh_token
684
- };
532
+ let srcPage = "/api/v1/integrations/outlook/oauth/callback/route";
533
+ // turbopack doesn't normalize `/index` in the page name
534
+ // so we need to to process dynamic routes properly
535
+ // TODO: fix turbopack providing differing value from webpack
536
+ if (false) {} else if (srcPage === '/index') {
537
+ // we always normalize /index specifically
538
+ srcPage = '/';
685
539
  }
686
- return {
687
- error: "Microsoft account not connected. Open the gear menu → Integrations tab → " + "Outlook card and click Connect Outlook to authorize Mail, Mail.Send, Calendar, Tasks, and People access."
688
- };
689
- }
690
- const accessTokenCache = new Map();
691
- function cacheKey(auth) {
692
- return auth.refresh_token.slice(0, 20);
693
- }
694
- // Force-evict a cached access token (e.g. after a 401). The next call to
695
- // getMicrosoftAccessToken will refresh against the v2 token endpoint.
696
- function bustAccessToken(auth) {
697
- accessTokenCache.delete(cacheKey(auth));
698
- }
699
- async function getMicrosoftAccessToken(auth) {
700
- const key = cacheKey(auth);
701
- const cached = accessTokenCache.get(key);
702
- if (cached && cached.expires_at > Date.now() + 60000) return cached.token;
703
- const body = new URLSearchParams({
704
- client_id: auth.client_id,
705
- client_secret: auth.client_secret,
706
- refresh_token: auth.refresh_token,
707
- grant_type: "refresh_token",
708
- // Required on the v2 endpoint even for refresh_token grants.
709
- scope: MICROSOFT_SCOPES.join(" ")
540
+ const multiZoneDraftMode = false;
541
+ const prepareResult = await routeModule.prepare(req, res, {
542
+ srcPage,
543
+ multiZoneDraftMode
710
544
  });
711
- try {
712
- const res = await fetch(`https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/token`, {
713
- method: "POST",
714
- headers: {
715
- "Content-Type": "application/x-www-form-urlencoded"
716
- },
717
- body: body.toString(),
718
- signal: AbortSignal.timeout(30000)
719
- });
720
- const text = await res.text();
721
- if (!res.ok) {
722
- accessTokenCache.delete(key);
723
- return {
724
- error: `Microsoft OAuth refresh failed (${res.status}): ${text.slice(0, 300)}`
725
- };
545
+ if (!prepareResult) {
546
+ res.statusCode = 400;
547
+ res.end('Bad Request');
548
+ ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
549
+ return null;
550
+ }
551
+ const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest, previewProps } = prepareResult;
552
+ const normalizedSrcPage = (0,next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__.normalizeAppPath)(srcPage);
553
+ // Only this route's prerenders can establish ISR or admit generated params.
554
+ const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]) && (routeModule.isDev || (0,next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__.isRouteCacheOwner)(resolvedPathname, routeModule.cacheOwner, prerenderManifest.routes[resolvedPathname]));
555
+ let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || isPrerendered);
556
+ const render404 = async ()=>{
557
+ // TODO: should route-module itself handle rendering the 404
558
+ if (routerServerContext == null ? void 0 : routerServerContext.render404) {
559
+ await routerServerContext.render404(req, res, parsedUrl, false);
560
+ } else {
561
+ res.end('This page could not be found');
562
+ }
563
+ return null;
564
+ };
565
+ if (isIsr && !isDraftMode) {
566
+ const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];
567
+ if (prerenderInfo) {
568
+ if (prerenderInfo.fallback === false && !isPrerendered) {
569
+ if (nextConfig.adapterPath) {
570
+ return await render404();
571
+ }
572
+ throw new next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError();
573
+ }
726
574
  }
727
- const parsed = JSON.parse(text);
728
- if (!parsed.access_token) return {
729
- error: "OAuth response missing access_token"
730
- };
731
- const expires_at = Date.now() + (parsed.expires_in ?? 3000) * 1000;
732
- accessTokenCache.set(key, {
733
- token: parsed.access_token,
734
- expires_at
735
- });
736
- return parsed.access_token;
737
- } catch (err) {
738
- return {
739
- error: `Microsoft OAuth refresh threw: ${(0,_lib_utils_error__WEBPACK_IMPORTED_MODULE_4__/* .errorMessage */ .g)(err)}`
740
- };
741
575
  }
742
- }
743
- // Path-prefix → required Graph scope. Used to render helpful 403 messages
744
- // pointing the user at the exact scope they need to reconnect with.
745
- const SCOPE_HINTS = [
746
- {
747
- prefix: "/me/messages",
748
- scope: "Mail.ReadWrite"
749
- },
750
- {
751
- prefix: "/me/mailFolders",
752
- scope: "Mail.ReadWrite"
753
- },
754
- {
755
- prefix: "/me/sendMail",
756
- scope: "Mail.Send"
757
- },
758
- {
759
- prefix: "/me/events",
760
- scope: "Calendars.ReadWrite"
761
- },
762
- {
763
- prefix: "/me/calendar",
764
- scope: "Calendars.ReadWrite"
765
- },
766
- {
767
- prefix: "/me/calendars",
768
- scope: "Calendars.ReadWrite"
769
- },
770
- {
771
- prefix: "/me/todo",
772
- scope: "Tasks.ReadWrite"
773
- },
774
- {
775
- prefix: "/me/people",
776
- scope: "People.Read"
777
- },
778
- {
779
- prefix: "/me/contacts",
780
- scope: "Contacts.Read"
781
- },
782
- {
783
- prefix: "/me/drive",
784
- scope: "Files.Read"
785
- },
786
- {
787
- prefix: "/me/insights",
788
- scope: "Sites.Read.All"
789
- },
790
- {
791
- prefix: "/search/query",
792
- scope: "Mail.Read Files.Read.All"
793
- },
794
- {
795
- prefix: "/me",
796
- scope: "User.Read"
576
+ let cacheKey = null;
577
+ if (isIsr && !routeModule.isDev && !isDraftMode) {
578
+ cacheKey = resolvedPathname;
579
+ // ensure /index and / is normalized to one key
580
+ cacheKey = cacheKey === '/index' ? '/' : cacheKey;
797
581
  }
798
- ];
799
- function scopeHintFor(path) {
800
- const p = path.startsWith("http") ? new URL(path).pathname.replace(/^\/v1\.0/, "") : path;
801
- for (const { prefix, scope } of SCOPE_HINTS){
802
- if (p.startsWith(prefix)) return scope;
582
+ // Before rendering (which initializes component tree modules), we have to
583
+ // set the reference manifests to our global store so Server Action's
584
+ // encryption util can access to them at the top level of the page module.
585
+ if (serverActionsManifest && clientReferenceManifest) {
586
+ (0,next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__.setManifestsSingleton)({
587
+ page: srcPage,
588
+ clientReferenceManifest,
589
+ serverActionsManifest
590
+ });
803
591
  }
804
- return null;
805
- }
806
- function parseRetryAfter(headerVal) {
807
- if (!headerVal) return 0;
808
- const secs = Number.parseInt(headerVal, 10);
809
- if (Number.isFinite(secs) && secs >= 0) return Math.min(secs, 30) * 1000;
810
- const ts = Date.parse(headerVal);
811
- if (!Number.isNaN(ts)) return Math.max(0, Math.min(ts - Date.now(), 30000));
812
- return 0;
813
- }
814
- function backoffFor(attempt) {
815
- return Math.min(500 * 2 ** attempt, 4000);
816
- }
817
- // Shared Graph fetch helper. Used by lib/tools/outlook.ts,
818
- // lib/tools/outlook-calendar.ts, lib/tools/ms-todo.ts, lib/tools/ms-graph.ts.
819
- // Returns parsed JSON or { error: string, url? }. 204 No Content returns
820
- // { ok: true }.
821
- //
822
- // Built-in resilience:
823
- // - 401 Unauthorized → drop the cached access token and retry once with a
824
- // freshly refreshed one (covers token-revoked-mid-cache edge cases).
825
- // - 429 / 503 → honour the `Retry-After` header (capped at 30s) or fall
826
- // back to exponential backoff. Retries up to 3 times.
827
- // - 403 Forbidden → surface a scope hint ("reconnect with X") so the
828
- // operator knows what to grant.
829
- async function graphFetch(auth, path, init) {
830
- const url = path.startsWith("http") ? path : `https://graph.microsoft.com/v1.0${path}`;
831
- let attempt = 0;
832
- let triedReauth = false;
833
- while(true){
834
- const token = await getMicrosoftAccessToken(auth);
835
- if (typeof token !== "string") return token;
836
- let res;
837
- try {
838
- res = await fetch(url, {
839
- ...init,
840
- headers: {
841
- Authorization: `Bearer ${token}`,
842
- Accept: "application/json",
843
- "Content-Type": "application/json",
844
- ...init?.headers ?? {}
845
- },
846
- signal: AbortSignal.timeout(30000)
847
- });
848
- } catch (err) {
849
- return {
850
- error: `Graph fetch threw: ${(0,_lib_utils_error__WEBPACK_IMPORTED_MODULE_4__/* .errorMessage */ .g)(err)}`,
851
- url
852
- };
853
- }
854
- if (res.status === 204) return {
855
- ok: true
856
- };
857
- if (res.status === 401 && !triedReauth) {
858
- triedReauth = true;
859
- bustAccessToken(auth);
860
- continue;
861
- }
862
- if ((res.status === 429 || res.status === 503) && attempt < 3) {
863
- const waitMs = parseRetryAfter(res.headers.get("Retry-After")) ?? backoffFor(attempt);
864
- attempt += 1;
865
- await new Promise((r)=>setTimeout(r, waitMs));
866
- continue;
592
+ const method = req.method || 'GET';
593
+ const tracer = (0,next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.getTracer)();
594
+ const activeSpan = tracer.getActiveScopeSpan();
595
+ const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);
596
+ const isMinimalMode = Boolean((0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'minimalMode'));
597
+ const incrementalCache = (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, previewProps, prerenderManifest, isMinimalMode);
598
+ incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();
599
+ globalThis.__incrementalCache = incrementalCache;
600
+ const context = {
601
+ params,
602
+ previewProps,
603
+ renderOpts: {
604
+ experimental: {
605
+ authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
606
+ useCacheTimeout: nextConfig.experimental.useCacheTimeout,
607
+ durableUseCacheEntries: Boolean(nextConfig.experimental.durableUseCacheEntries)
608
+ },
609
+ cacheComponents: Boolean(nextConfig.cacheComponents),
610
+ validationLevel: nextConfig.experimental.instantInsights.validationLevel,
611
+ isDraftMode,
612
+ incrementalCache,
613
+ hmrRefreshHash: (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'hmrRefreshHash'),
614
+ cacheLifeProfiles: nextConfig.cacheLife,
615
+ staticPageGenerationTimeout: nextConfig.staticPageGenerationTimeout,
616
+ waitUntil: ctx.waitUntil,
617
+ onClose: (cb)=>{
618
+ res.on('close', cb);
619
+ },
620
+ onAfterTaskError: undefined
621
+ },
622
+ sharedContext: {
623
+ buildId,
624
+ deploymentId
867
625
  }
868
- const text = await res.text();
869
- if (!res.ok) {
870
- let msg = `Graph ${res.status}: ${text.slice(0, 500)}`;
871
- if (res.status === 403) {
872
- const hint = scopeHintFor(path);
873
- if (hint) {
874
- msg += ` — reconnect the Microsoft integration with scope: ${hint}`;
626
+ };
627
+ const nodeNextReq = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextRequest(req);
628
+ const nodeNextRes = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextResponse(res);
629
+ const nextReq = next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__.NextRequestAdapter.fromNodeNextRequest(nodeNextReq, (0,next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__.signalFromNodeResponse)(res));
630
+ const responseGenerator = async ({ previousCacheEntry })=>{
631
+ try {
632
+ if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {
633
+ res.statusCode = 404;
634
+ // on-demand revalidate always sets this header
635
+ res.setHeader('x-nextjs-cache', 'REVALIDATED');
636
+ res.end('This page could not be found');
637
+ return null;
638
+ }
639
+ const response = cacheKey === null ? await routeModule.handle(nextReq, context) : await routeModule.prerender(nextReq, context);
640
+ req.fetchMetrics = context.renderOpts.fetchMetrics;
641
+ let pendingWaitUntil = context.renderOpts.pendingWaitUntil;
642
+ // Attempt using provided waitUntil if available
643
+ // if it's not we fallback to sendResponse's handling
644
+ if (pendingWaitUntil) {
645
+ if (ctx.waitUntil) {
646
+ ctx.waitUntil(pendingWaitUntil);
647
+ pendingWaitUntil = undefined;
875
648
  }
876
649
  }
877
- return {
878
- error: msg,
879
- url
880
- };
881
- }
882
- try {
883
- return JSON.parse(text);
884
- } catch {
885
- return text;
650
+ const cacheTags = context.renderOpts.collectedTags;
651
+ // If the request is for a static response, we can cache it so long
652
+ // as it's not edge.
653
+ if (isIsr) {
654
+ const blob = await response.blob();
655
+ // Copy the headers from the response.
656
+ const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.toNodeOutgoingHttpHeaders)(response.headers);
657
+ if (cacheTags) {
658
+ headers[next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER] = cacheTags;
659
+ }
660
+ if (!headers['content-type'] && blob.type) {
661
+ headers['content-type'] = blob.type;
662
+ }
663
+ const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;
664
+ const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? // route has a numeric `revalidate` but didn't declare an
665
+ // explicit `expire` (e.g. via `cacheLife`). This mirrors the
666
+ // build-time fallback in `build/index.ts` so cache entries
667
+ // and the response Cache-Control header agree on the route's
668
+ // effective expire. Routes that opt out of revalidation
669
+ // (`revalidate: false`) or that are dynamic (`revalidate: 0`)
670
+ // keep `expire: undefined`.
671
+ revalidate !== false && revalidate > 0 ? nextConfig.expireTime : undefined : context.renderOpts.collectedExpire;
672
+ // Create the cache entry for the response.
673
+ const cacheEntry = {
674
+ value: {
675
+ kind: next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE,
676
+ status: response.status,
677
+ body: Buffer.from(await blob.arrayBuffer()),
678
+ headers
679
+ },
680
+ cacheControl: {
681
+ revalidate,
682
+ expire
683
+ }
684
+ };
685
+ return cacheEntry;
686
+ } else {
687
+ // send response without caching if not ISR
688
+ await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, response, pendingWaitUntil);
689
+ return null;
690
+ }
691
+ } catch (err) {
692
+ // if this is a background revalidate we need to report
693
+ // the request error here as it won't be bubbled
694
+ if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {
695
+ const silenceLog = false;
696
+ await routeModule.onRequestError(req, err, {
697
+ routerKind: 'App Router',
698
+ routePath: srcPage,
699
+ routeType: 'route',
700
+ revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
701
+ isStaticGeneration: cacheKey !== null,
702
+ isOnDemandRevalidate
703
+ })
704
+ }, silenceLog, routerServerContext);
705
+ }
706
+ throw err;
886
707
  }
887
- }
888
- }
889
- // Follow @odata.nextLink across pages and concatenate `value` arrays.
890
- // Stops at `maxPages` (default 5) to bound context cost. Returns the same
891
- // shape as graphFetch (object with `.value`) but with the merged array, or
892
- // the original error shape if any page errored.
893
- async function graphPaged(auth, path, opts) {
894
- const maxPages = opts?.maxPages ?? 5;
895
- let current = path;
896
- const merged = [];
897
- let pages = 0;
898
- while(current && pages < maxPages){
899
- const page = await graphFetch(auth, current, opts?.init);
900
- if (page && typeof page === "object" && "error" in page) return page;
901
- const body = page;
902
- if (Array.isArray(body.value)) merged.push(...body.value);
903
- current = typeof body["@odata.nextLink"] === "string" ? body["@odata.nextLink"] : null;
904
- pages += 1;
905
- }
906
- return {
907
- value: merged,
908
- pages
909
708
  };
910
- }
911
-
912
-
913
- /***/ }),
914
-
915
- /***/ 94735:
916
- /***/ ((module) => {
917
-
918
- module.exports = require("events");
919
-
920
- /***/ }),
921
-
922
- /***/ 98671:
923
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
924
-
925
- __webpack_require__.r(__webpack_exports__);
926
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
927
- /* harmony export */ handler: () => (/* binding */ handler),
928
- /* harmony export */ patchFetch: () => (/* binding */ patchFetch),
929
- /* harmony export */ routeModule: () => (/* binding */ routeModule),
930
- /* harmony export */ serverHooks: () => (/* binding */ serverHooks),
931
- /* harmony export */ workAsyncStorage: () => (/* binding */ workAsyncStorage),
932
- /* harmony export */ workUnitAsyncStorage: () => (/* binding */ workUnitAsyncStorage)
933
- /* harmony export */ });
934
- /* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19225);
935
- /* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__);
936
- /* harmony import */ var next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(84006);
937
- /* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8317);
938
- /* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__);
939
- /* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(99373);
940
- /* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__);
941
- /* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34775);
942
- /* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__);
943
- /* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(24235);
944
- /* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__);
945
- /* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(261);
946
- /* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__);
947
- /* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(54365);
948
- /* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__);
949
- /* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(90771);
950
- /* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__);
951
- /* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(73461);
952
- /* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__);
953
- /* harmony import */ var next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(67798);
954
- /* harmony import */ var next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(92280);
955
- /* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(62018);
956
- /* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__);
957
- /* harmony import */ var next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(45696);
958
- /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(47929);
959
- /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__);
960
- /* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(86439);
961
- /* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__);
962
- /* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(10246);
963
- /* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__);
964
- /* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(37527);
965
- /* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__);
966
-
967
-
968
-
969
-
970
-
971
-
709
+ const handleResponse = async (currentSpan, parentSpan)=>{
710
+ try {
711
+ var _cacheEntry_value;
712
+ const cacheEntry = await routeModule.handleResponse({
713
+ req,
714
+ nextConfig,
715
+ cacheKey,
716
+ routeKind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
717
+ isFallback: false,
718
+ previewProps,
719
+ prerenderManifest,
720
+ isRoutePPREnabled: false,
721
+ isOnDemandRevalidate,
722
+ revalidateOnlyGenerated,
723
+ responseGenerator,
724
+ waitUntil: ctx.waitUntil,
725
+ isMinimalMode
726
+ });
727
+ if (cacheEntry !== null && 'error' in cacheEntry) {
728
+ throw cacheEntry.error;
729
+ }
730
+ // we don't create a cacheEntry for ISR
731
+ if (!isIsr) {
732
+ return;
733
+ }
734
+ if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE) {
735
+ var _cacheEntry_value1;
736
+ throw new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`);
737
+ }
738
+ if (!isMinimalMode) {
739
+ res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');
740
+ }
741
+ // Draft mode should never be cached
742
+ if (isDraftMode) {
743
+ res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
744
+ }
745
+ const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.fromNodeOutgoingHttpHeaders)(cacheEntry.value.headers);
746
+ if (!(isMinimalMode && isIsr)) {
747
+ headers.delete(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER);
748
+ }
749
+ // If cache control is already set on the response we don't
750
+ // override it to allow users to customize it via next.config
751
+ if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {
752
+ headers.set('Cache-Control', (0,next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__.getCacheControlHeader)(cacheEntry.cacheControl));
753
+ }
754
+ await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.
755
+ new Response(cacheEntry.value.body, {
756
+ headers,
757
+ status: cacheEntry.value.status || 200
758
+ }));
759
+ return;
760
+ } catch (err) {
761
+ if (!(err instanceof next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError)) {
762
+ const silenceLog = false;
763
+ await routeModule.onRequestError(req, err, {
764
+ routerKind: 'App Router',
765
+ routePath: normalizedSrcPage,
766
+ routeType: 'route',
767
+ revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
768
+ isStaticGeneration: cacheKey !== null,
769
+ isOnDemandRevalidate
770
+ })
771
+ }, silenceLog, routerServerContext);
772
+ }
773
+ // rethrow so that we can handle serving error page
774
+ // If this is during static generation, throw the error again.
775
+ if (isIsr) throw err;
776
+ // Otherwise, send a 500 response unless the original response has
777
+ // already committed. In that case, preserve its status code for
778
+ // telemetry while still recording the failure and terminating a response
779
+ // that the failed pipeline left open.
780
+ if (res.headersSent) {
781
+ if (currentSpan) {
782
+ const error = err instanceof Error ? err : new Error('Unknown app route error');
783
+ currentSpan.recordException(error);
784
+ currentSpan.setStatus({
785
+ code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
786
+ message: error.message
787
+ });
788
+ currentSpan.setAttribute('error.type', error.name);
789
+ }
790
+ if (!res.writableEnded && !res.destroyed) {
791
+ res.end();
792
+ }
793
+ } else {
794
+ await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, new Response(null, {
795
+ status: 500
796
+ }));
797
+ }
798
+ return;
799
+ } finally{
800
+ ;
801
+ (()=>{
802
+ if (!currentSpan) {
803
+ return;
804
+ }
805
+ let statusCode = res.statusCode;
806
+ currentSpan.setAttributes({
807
+ 'http.status_code': statusCode,
808
+ 'next.rsc': false
809
+ });
810
+ if (statusCode && statusCode >= 500) {
811
+ // For 5xx status codes: SHOULD be set to 'Error' span status.
812
+ // x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
813
+ currentSpan.setStatus({
814
+ code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR
815
+ });
816
+ // For span status 'Error', SHOULD set 'error.type' attribute.
817
+ currentSpan.setAttribute('error.type', statusCode.toString());
818
+ }
819
+ const rootSpanAttributes = tracer.getRootSpanAttributes();
820
+ // We were unable to get attributes, probably OTEL is not enabled
821
+ if (!rootSpanAttributes) {
822
+ return;
823
+ }
824
+ if (rootSpanAttributes.get('next.span_type') !== next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest) {
825
+ console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
826
+ return;
827
+ }
828
+ const route = rootSpanAttributes.get('next.route') || normalizedSrcPage;
829
+ const name = `${method} ${route}`;
830
+ currentSpan.setAttributes({
831
+ 'next.route': route,
832
+ 'http.route': route,
833
+ 'next.span_name': name
834
+ });
835
+ currentSpan.updateName(name);
836
+ // Propagate http.route to the parent span if one exists (e.g.
837
+ // a platform-created HTTP span in adapter deployments).
838
+ if (parentSpan && parentSpan !== currentSpan) {
839
+ parentSpan.setAttribute('http.route', route);
840
+ parentSpan.updateName(name);
841
+ }
842
+ })();
843
+ }
844
+ };
845
+ // TODO: activeSpan code path is for when wrapped by
846
+ // next-server can be removed when this is no longer used
847
+ if (isWrappedByNextServer && activeSpan) {
848
+ await handleResponse(activeSpan, undefined);
849
+ } else {
850
+ let parentSpan = tracer.getActiveScopeSpan();
851
+ await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest, {
852
+ spanName: `${method} ${srcPage}`,
853
+ kind: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanKind.SERVER,
854
+ attributes: {
855
+ 'http.method': method,
856
+ 'http.target': req.url
857
+ }
858
+ }, (span)=>handleResponse(span, parentSpan)), undefined, !isWrappedByNextServer);
859
+ }
860
+ }
972
861
 
862
+ //# sourceMappingURL=app-route.js.map
973
863
 
974
864
 
865
+ /***/ }),
975
866
 
867
+ /***/ 86439:
868
+ /***/ ((module) => {
976
869
 
870
+ module.exports = require("next/dist/shared/lib/no-fallback-error.external");
977
871
 
872
+ /***/ }),
978
873
 
874
+ /***/ 89052:
875
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
979
876
 
877
+ __webpack_require__.r(__webpack_exports__);
878
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
879
+ /* harmony export */ GET: () => (/* binding */ GET)
880
+ /* harmony export */ });
881
+ /* harmony import */ var _lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(89080);
882
+ /* harmony import */ var _lib_stores_integrations__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(78228);
883
+ /* harmony import */ var _lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67637);
884
+ /* harmony import */ var _app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(41044);
885
+ /* harmony import */ var _lib_utils_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(22032);
980
886
 
981
887
 
982
888
 
983
889
 
984
- // We inject the nextConfigOutput here so that we can use them in the route
985
- // module.
986
- const nextConfigOutput = "standalone"
987
- const routeModule = new next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__.AppRouteRouteModule({
988
- definition: {
989
- kind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
990
- page: "/api/v1/integrations/outlook/oauth/callback/route",
991
- pathname: "/api/v1/integrations/outlook/oauth/callback",
992
- filename: "route",
993
- bundlePath: "app/api/v1/integrations/outlook/oauth/callback/route"
994
- },
995
- distDir: ".next" || 0,
996
- relativeProjectDir: false || '',
997
- resolvedPagePath: "/home/runner/work/jarela/jarela/app/api/v1/integrations/outlook/oauth/callback/route.ts",
998
- nextConfigOutput,
999
- // The lazy require factory ensures that:
1000
- // - In dev: devRequestTimingInternalsEnd is set before userland executes,
1001
- // correctly attributing module load time to application-code rather than
1002
- // framework internals.
1003
- // - In all modes: async modules (route files with top-level await) are
1004
- // handled correctly — require() returns a Promise for such modules, which
1005
- // ensureUserland() awaits before the first request is handled.
1006
- userland: ()=>__webpack_require__(89052),
1007
- // In Turbopack dev mode, also provide a synchronous per-request getter so
1008
- // server HMR updates are picked up without re-executing the entry chunk.
1009
- // Using require() (synchronous) avoids adding async overhead that would be
1010
- // incorrectly attributed to application-code time in devRequestTiming.
1011
- ... false ? 0 : {}
1012
- });
1013
- // Pull out the exports that we need to expose from the module. This should
1014
- // be eliminated when we've moved the other routes to the new format. These
1015
- // are used to hook into the route.
1016
- const { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;
1017
- function patchFetch() {
1018
- return (0,next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__.patchFetch)({
1019
- workAsyncStorage,
1020
- workUnitAsyncStorage
1021
- });
1022
- }
1023
890
 
1024
- async function handler(req, res, ctx) {
1025
- if (ctx.requestMeta) {
1026
- (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.setRequestMeta)(req, ctx.requestMeta);
891
+ // GET /api/v1/integrations/outlook/oauth/callback?code=…&state=…
892
+ //
893
+ // Microsoft redirects the user's browser here after consent. We look up the
894
+ // pending flow by `state`, exchange the auth code for a refresh_token,
895
+ // persist the integration, and return a small HTML page telling the user
896
+ // they can close the tab. The Integrations panel polls /oauth/status.
897
+ async function GET(req) {
898
+ const url = req.nextUrl;
899
+ const state = url.searchParams.get("state") ?? "";
900
+ const code = url.searchParams.get("code") ?? "";
901
+ const errParam = url.searchParams.get("error");
902
+ const errDesc = url.searchParams.get("error_description");
903
+ const flow = state ? (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .getFlow */ .lv)(state) : undefined;
904
+ if (!flow) {
905
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)("Authorization session not found or expired. Please retry from Jarela.", true);
1027
906
  }
1028
- if (routeModule.isDev) {
1029
- (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.addRequestMeta)(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());
907
+ if (errParam) {
908
+ const msg = errDesc ? `${errParam}: ${errDesc}` : errParam;
909
+ (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
910
+ status: "error",
911
+ error: msg
912
+ });
913
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(`Microsoft reported an error: ${(0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .escapeHtml */ .Z)(msg)}. You can close this tab.`, true);
1030
914
  }
1031
- let srcPage = "/api/v1/integrations/outlook/oauth/callback/route";
1032
- // turbopack doesn't normalize `/index` in the page name
1033
- // so we need to to process dynamic routes properly
1034
- // TODO: fix turbopack providing differing value from webpack
1035
- if (false) {} else if (srcPage === '/index') {
1036
- // we always normalize /index specifically
1037
- srcPage = '/';
915
+ if (!code) {
916
+ (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
917
+ status: "error",
918
+ error: "no code returned"
919
+ });
920
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)("Microsoft did not return an authorization code.", true);
1038
921
  }
1039
- const multiZoneDraftMode = false;
1040
- const prepareResult = await routeModule.prepare(req, res, {
1041
- srcPage,
1042
- multiZoneDraftMode
1043
- });
1044
- if (!prepareResult) {
1045
- res.statusCode = 400;
1046
- res.end('Bad Request');
1047
- ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
1048
- return null;
1049
- }
1050
- const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest, previewProps } = prepareResult;
1051
- const normalizedSrcPage = (0,next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__.normalizeAppPath)(srcPage);
1052
- // Only this route's prerenders can establish ISR or admit generated params.
1053
- const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]) && (routeModule.isDev || (0,next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__.isRouteCacheOwner)(resolvedPathname, routeModule.cacheOwner, prerenderManifest.routes[resolvedPathname]));
1054
- let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || isPrerendered);
1055
- const render404 = async ()=>{
1056
- // TODO: should route-module itself handle rendering the 404
1057
- if (routerServerContext == null ? void 0 : routerServerContext.render404) {
1058
- await routerServerContext.render404(req, res, parsedUrl, false);
1059
- } else {
1060
- res.end('This page could not be found');
922
+ try {
923
+ const tok = await (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .exchangeCode */ .Dd)({
924
+ code,
925
+ clientId: flow.clientId,
926
+ clientSecret: flow.clientSecret,
927
+ redirectUri: flow.redirectUri
928
+ });
929
+ if (!tok.refresh_token) {
930
+ const msg = "Microsoft did not return a refresh_token. Make sure your Azure app " + "registration includes the offline_access scope and that the consent " + "screen approves it.";
931
+ (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
932
+ status: "error",
933
+ error: msg
934
+ });
935
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(msg, true);
1061
936
  }
1062
- return null;
1063
- };
1064
- if (isIsr && !isDraftMode) {
1065
- const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];
1066
- if (prerenderInfo) {
1067
- if (prerenderInfo.fallback === false && !isPrerendered) {
1068
- if (nextConfig.adapterPath) {
1069
- return await render404();
1070
- }
1071
- throw new next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError();
1072
- }
937
+ const saved = persistRefreshToken({
938
+ credentialId: flow.credentialId,
939
+ clientId: flow.clientId,
940
+ clientSecret: flow.clientSecret,
941
+ refreshToken: tok.refresh_token
942
+ });
943
+ if ("error" in saved) {
944
+ (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
945
+ status: "error",
946
+ error: saved.error
947
+ });
948
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(`Failed to save: ${(0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .escapeHtml */ .Z)(saved.error)}`, true);
1073
949
  }
950
+ (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
951
+ status: "done"
952
+ });
953
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)("Outlook connected. You can close this tab and return to Jarela.", false);
954
+ } catch (e) {
955
+ const msg = (0,_lib_utils_error__WEBPACK_IMPORTED_MODULE_4__/* .errorMessage */ .g)(e);
956
+ (0,_lib_integrations_microsoft_oauth__WEBPACK_IMPORTED_MODULE_0__/* .updateFlow */ .Ah)(state, {
957
+ status: "error",
958
+ error: msg
959
+ });
960
+ return (0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .oauthHtmlResponse */ .m)(`Token exchange failed: ${(0,_app_api_v1_integrations_oauth_callback__WEBPACK_IMPORTED_MODULE_3__/* .escapeHtml */ .Z)(msg)}`, true);
1074
961
  }
1075
- let cacheKey = null;
1076
- if (isIsr && !routeModule.isDev && !isDraftMode) {
1077
- cacheKey = resolvedPathname;
1078
- // ensure /index and / is normalized to one key
1079
- cacheKey = cacheKey === '/index' ? '/' : cacheKey;
1080
- }
1081
- // Before rendering (which initializes component tree modules), we have to
1082
- // set the reference manifests to our global store so Server Action's
1083
- // encryption util can access to them at the top level of the page module.
1084
- if (serverActionsManifest && clientReferenceManifest) {
1085
- (0,next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__.setManifestsSingleton)({
1086
- page: srcPage,
1087
- clientReferenceManifest,
1088
- serverActionsManifest
962
+ }
963
+ function persistRefreshToken(input) {
964
+ if (input.credentialId) {
965
+ const cred = (0,_lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__/* .getCredential */ .w_)(input.credentialId);
966
+ if (!cred || cred.provider !== "outlook") {
967
+ return {
968
+ error: "credential not found"
969
+ };
970
+ }
971
+ const merged = {
972
+ ...(0,_lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__/* .getCredentialParams */ .WY)(cred),
973
+ client_id: input.clientId,
974
+ client_secret: input.clientSecret,
975
+ refresh_token: input.refreshToken
976
+ };
977
+ (0,_lib_stores_credentials__WEBPACK_IMPORTED_MODULE_2__/* .updateCredential */ .nZ)(input.credentialId, {
978
+ auth_method: "oauth",
979
+ params: merged
1089
980
  });
981
+ return {
982
+ ok: true
983
+ };
1090
984
  }
1091
- const method = req.method || 'GET';
1092
- const tracer = (0,next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.getTracer)();
1093
- const activeSpan = tracer.getActiveScopeSpan();
1094
- const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);
1095
- const isMinimalMode = Boolean((0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'minimalMode'));
1096
- const incrementalCache = (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, previewProps, prerenderManifest, isMinimalMode);
1097
- incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();
1098
- globalThis.__incrementalCache = incrementalCache;
1099
- const context = {
1100
- params,
1101
- previewProps,
1102
- renderOpts: {
1103
- experimental: {
1104
- authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
1105
- useCacheTimeout: nextConfig.experimental.useCacheTimeout,
1106
- durableUseCacheEntries: Boolean(nextConfig.experimental.durableUseCacheEntries)
1107
- },
1108
- cacheComponents: Boolean(nextConfig.cacheComponents),
1109
- validationLevel: nextConfig.experimental.instantInsights.validationLevel,
1110
- isDraftMode,
1111
- incrementalCache,
1112
- hmrRefreshHash: (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'hmrRefreshHash'),
1113
- cacheLifeProfiles: nextConfig.cacheLife,
1114
- staticPageGenerationTimeout: nextConfig.staticPageGenerationTimeout,
1115
- waitUntil: ctx.waitUntil,
1116
- onClose: (cb)=>{
1117
- res.on('close', cb);
1118
- },
1119
- onAfterTaskError: undefined
985
+ const saved = (0,_lib_stores_integrations__WEBPACK_IMPORTED_MODULE_1__/* .saveIntegration */ .oO)("outlook", {
986
+ client_id: input.clientId,
987
+ client_secret: input.clientSecret,
988
+ refresh_token: input.refreshToken
989
+ });
990
+ if ("error" in saved) return saved;
991
+ return {
992
+ ok: true
993
+ };
994
+ }
995
+
996
+
997
+ /***/ }),
998
+
999
+ /***/ 89080:
1000
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1001
+
1002
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1003
+ /* harmony export */ Ah: () => (/* binding */ updateFlow),
1004
+ /* harmony export */ Dd: () => (/* binding */ exchangeCode),
1005
+ /* harmony export */ F8: () => (/* binding */ createFlow),
1006
+ /* harmony export */ i8: () => (/* binding */ getMicrosoftAccessToken),
1007
+ /* harmony export */ jG: () => (/* binding */ resolveMicrosoftAuth),
1008
+ /* harmony export */ lv: () => (/* binding */ getFlow),
1009
+ /* harmony export */ op: () => (/* binding */ graphPaged),
1010
+ /* harmony export */ xj: () => (/* binding */ buildAuthorizeUrl),
1011
+ /* harmony export */ z$: () => (/* binding */ graphFetch)
1012
+ /* harmony export */ });
1013
+ /* unused harmony export MICROSOFT_SCOPES */
1014
+ /* harmony import */ var _lib_stores_integrations__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(78228);
1015
+ /* harmony import */ var _lib_utils_oauth_flow_store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(56362);
1016
+ /* harmony import */ var _lib_utils_json__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(53638);
1017
+ /* harmony import */ var _lib_utils_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(22032);
1018
+ /* harmony import */ var _lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(22632);
1019
+ // Ephemeral state store + shared auth helpers for the in-app Microsoft OAuth
1020
+ // flow. Mirrors lib/integrations/gmail-oauth.ts but targets the Microsoft
1021
+ // identity platform (v2.0 endpoint, common tenant by default) and Microsoft
1022
+ // Graph as the downstream API surface (Outlook Mail + Calendar in v1).
1023
+ //
1024
+ // The user types client_id + client_secret in the Integrations panel and
1025
+ // clicks "Connect Outlook". We POST those to /oauth/start, which stashes
1026
+ // them here keyed by a random `state` token and returns the Microsoft
1027
+ // authorize URL. The browser opens that URL; MS bounces back to
1028
+ // /oauth/callback with `?code&state`, which exchanges the code for a
1029
+ // refresh_token (granted because we asked for `offline_access`) and
1030
+ // persists the integration. The panel polls /oauth/status separately.
1031
+ //
1032
+ // Pinned to globalThis so HMR in dev doesn't lose pending flows.
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+ const flowStore = (0,_lib_utils_oauth_flow_store__WEBPACK_IMPORTED_MODULE_1__/* .createOAuthFlowStore */ .R)({
1039
+ globalKey: "__msOauthFlows"
1040
+ });
1041
+ const createFlow = flowStore.create;
1042
+ const getFlow = flowStore.get;
1043
+ const updateFlow = flowStore.update;
1044
+ // Tenant selector. `common` accepts both personal Microsoft accounts
1045
+ // (@outlook.com, @hotmail.com, @live.com) and work/school M365 accounts.
1046
+ // Switch to `consumers` to lock to personal only, or `organizations` for
1047
+ // work/school only. We expose this as an env override for power users but
1048
+ // don't surface it in the UI yet.
1049
+ const TENANT = process.env.OUTLOOK_TENANT?.trim() || "common";
1050
+ // Delegated Graph scopes the agent needs. Keep narrow:
1051
+ // - offline_access → required for a refresh_token (MS counterpart of
1052
+ // Google's access_type=offline).
1053
+ // - User.Read → used by the test endpoint to call /me.
1054
+ // - Mail.ReadWrite → search/read mail, create drafts, mark read,
1055
+ // move to folders (incl. DeletedItems).
1056
+ // - Mail.Send → send mail when the user explicitly asks for it.
1057
+ // - Calendars.ReadWrite → list/get/create/update/delete events on the
1058
+ // user's existing calendars.
1059
+ // - Tasks.ReadWrite → list/get/create/update/complete/delete Microsoft
1060
+ // To Do tasks and lists (ms_todo_* tools).
1061
+ // - People.Read → resolve "who is X" / frequent contacts via
1062
+ // /me/people (ms_people_resolve tool).
1063
+ const MICROSOFT_SCOPES = [
1064
+ "offline_access",
1065
+ "User.Read",
1066
+ "Mail.ReadWrite",
1067
+ "Mail.Send",
1068
+ "Calendars.ReadWrite",
1069
+ "Tasks.ReadWrite",
1070
+ "People.Read"
1071
+ ];
1072
+ function buildAuthorizeUrl(opts) {
1073
+ const p = new URLSearchParams({
1074
+ client_id: opts.clientId,
1075
+ redirect_uri: opts.redirectUri,
1076
+ response_type: "code",
1077
+ response_mode: "query",
1078
+ scope: MICROSOFT_SCOPES.join(" "),
1079
+ // Force consent so a returning user actually re-grants any newly-added
1080
+ // scope (otherwise MS silently reuses the prior grant minus the new bit).
1081
+ prompt: "consent",
1082
+ state: opts.state
1083
+ });
1084
+ return `https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/authorize?${p.toString()}`;
1085
+ }
1086
+ // NOTE: Unlike Google, MS v2 endpoint **requires** the `scope` parameter on
1087
+ // every grant_type call (both authorization_code and refresh_token). Leaving
1088
+ // it out yields `AADSTS900144: The request body must contain the following
1089
+ // parameter: 'scope'.`. We always pass the full scope set.
1090
+ async function exchangeCode(opts) {
1091
+ const clientId = (0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .sanitizeOAuthInput */ .d)(opts.clientId) ?? "";
1092
+ const clientSecret = (0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .sanitizeOAuthInput */ .d)(opts.clientSecret) ?? "";
1093
+ const body = new URLSearchParams({
1094
+ code: opts.code,
1095
+ client_id: clientId,
1096
+ client_secret: clientSecret,
1097
+ redirect_uri: opts.redirectUri,
1098
+ grant_type: "authorization_code",
1099
+ scope: MICROSOFT_SCOPES.join(" ")
1100
+ });
1101
+ const res = await fetch(`https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/token`, {
1102
+ method: "POST",
1103
+ headers: {
1104
+ "Content-Type": "application/x-www-form-urlencoded"
1120
1105
  },
1121
- sharedContext: {
1122
- buildId,
1123
- deploymentId
1124
- }
1106
+ body: body.toString(),
1107
+ signal: AbortSignal.timeout(30000)
1108
+ });
1109
+ const text = await res.text();
1110
+ const parsed = (0,_lib_utils_json__WEBPACK_IMPORTED_MODULE_3__/* .parseJsonSafe */ .p)(text, {});
1111
+ if (!res.ok) {
1112
+ const err = parsed["error_description"] || parsed["error"] || text || `HTTP ${res.status}`;
1113
+ console.error(`[microsoft-oauth] token exchange rejected (${res.status}): ${err} | client_id ${(0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .secretFingerprint */ .n)(clientId)} | client_secret ${(0,_lib_utils_oauth_input__WEBPACK_IMPORTED_MODULE_2__/* .secretFingerprint */ .n)(clientSecret)}`);
1114
+ throw new Error(err);
1115
+ }
1116
+ return parsed;
1117
+ }
1118
+ function resolveMicrosoftAuth() {
1119
+ const envId = process.env.OUTLOOK_CLIENT_ID;
1120
+ const envSecret = process.env.OUTLOOK_CLIENT_SECRET;
1121
+ const envRefresh = process.env.OUTLOOK_REFRESH_TOKEN;
1122
+ if (envId && envSecret && envRefresh) {
1123
+ return {
1124
+ client_id: envId,
1125
+ client_secret: envSecret,
1126
+ refresh_token: envRefresh
1127
+ };
1128
+ }
1129
+ const saved = (0,_lib_stores_integrations__WEBPACK_IMPORTED_MODULE_0__/* .getIntegrationRaw */ .$G)("outlook");
1130
+ if (saved?.client_id && saved.client_secret && saved.refresh_token) {
1131
+ return {
1132
+ client_id: saved.client_id,
1133
+ client_secret: saved.client_secret,
1134
+ refresh_token: saved.refresh_token
1135
+ };
1136
+ }
1137
+ return {
1138
+ error: "Microsoft account not connected. Open the gear menu → Integrations tab → " + "Outlook card and click Connect Outlook to authorize Mail, Mail.Send, Calendar, Tasks, and People access."
1125
1139
  };
1126
- const nodeNextReq = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextRequest(req);
1127
- const nodeNextRes = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextResponse(res);
1128
- const nextReq = next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__.NextRequestAdapter.fromNodeNextRequest(nodeNextReq, (0,next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__.signalFromNodeResponse)(res));
1129
- const responseGenerator = async ({ previousCacheEntry })=>{
1130
- try {
1131
- if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {
1132
- res.statusCode = 404;
1133
- // on-demand revalidate always sets this header
1134
- res.setHeader('x-nextjs-cache', 'REVALIDATED');
1135
- res.end('This page could not be found');
1136
- return null;
1137
- }
1138
- const response = cacheKey === null ? await routeModule.handle(nextReq, context) : await routeModule.prerender(nextReq, context);
1139
- req.fetchMetrics = context.renderOpts.fetchMetrics;
1140
- let pendingWaitUntil = context.renderOpts.pendingWaitUntil;
1141
- // Attempt using provided waitUntil if available
1142
- // if it's not we fallback to sendResponse's handling
1143
- if (pendingWaitUntil) {
1144
- if (ctx.waitUntil) {
1145
- ctx.waitUntil(pendingWaitUntil);
1146
- pendingWaitUntil = undefined;
1147
- }
1148
- }
1149
- const cacheTags = context.renderOpts.collectedTags;
1150
- // If the request is for a static response, we can cache it so long
1151
- // as it's not edge.
1152
- if (isIsr) {
1153
- const blob = await response.blob();
1154
- // Copy the headers from the response.
1155
- const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.toNodeOutgoingHttpHeaders)(response.headers);
1156
- if (cacheTags) {
1157
- headers[next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER] = cacheTags;
1158
- }
1159
- if (!headers['content-type'] && blob.type) {
1160
- headers['content-type'] = blob.type;
1161
- }
1162
- const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;
1163
- const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? // route has a numeric `revalidate` but didn't declare an
1164
- // explicit `expire` (e.g. via `cacheLife`). This mirrors the
1165
- // build-time fallback in `build/index.ts` so cache entries
1166
- // and the response Cache-Control header agree on the route's
1167
- // effective expire. Routes that opt out of revalidation
1168
- // (`revalidate: false`) or that are dynamic (`revalidate: 0`)
1169
- // keep `expire: undefined`.
1170
- revalidate !== false && revalidate > 0 ? nextConfig.expireTime : undefined : context.renderOpts.collectedExpire;
1171
- // Create the cache entry for the response.
1172
- const cacheEntry = {
1173
- value: {
1174
- kind: next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE,
1175
- status: response.status,
1176
- body: Buffer.from(await blob.arrayBuffer()),
1177
- headers
1178
- },
1179
- cacheControl: {
1180
- revalidate,
1181
- expire
1182
- }
1183
- };
1184
- return cacheEntry;
1185
- } else {
1186
- // send response without caching if not ISR
1187
- await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, response, pendingWaitUntil);
1188
- return null;
1189
- }
1190
- } catch (err) {
1191
- // if this is a background revalidate we need to report
1192
- // the request error here as it won't be bubbled
1193
- if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {
1194
- const silenceLog = false;
1195
- await routeModule.onRequestError(req, err, {
1196
- routerKind: 'App Router',
1197
- routePath: srcPage,
1198
- routeType: 'route',
1199
- revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
1200
- isStaticGeneration: cacheKey !== null,
1201
- isOnDemandRevalidate
1202
- })
1203
- }, silenceLog, routerServerContext);
1204
- }
1205
- throw err;
1140
+ }
1141
+ const accessTokenCache = new Map();
1142
+ function cacheKey(auth) {
1143
+ return auth.refresh_token.slice(0, 20);
1144
+ }
1145
+ // Force-evict a cached access token (e.g. after a 401). The next call to
1146
+ // getMicrosoftAccessToken will refresh against the v2 token endpoint.
1147
+ function bustAccessToken(auth) {
1148
+ accessTokenCache.delete(cacheKey(auth));
1149
+ }
1150
+ async function getMicrosoftAccessToken(auth) {
1151
+ const key = cacheKey(auth);
1152
+ const cached = accessTokenCache.get(key);
1153
+ if (cached && cached.expires_at > Date.now() + 60000) return cached.token;
1154
+ const body = new URLSearchParams({
1155
+ client_id: auth.client_id,
1156
+ client_secret: auth.client_secret,
1157
+ refresh_token: auth.refresh_token,
1158
+ grant_type: "refresh_token",
1159
+ // Required on the v2 endpoint even for refresh_token grants.
1160
+ scope: MICROSOFT_SCOPES.join(" ")
1161
+ });
1162
+ try {
1163
+ const res = await fetch(`https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/token`, {
1164
+ method: "POST",
1165
+ headers: {
1166
+ "Content-Type": "application/x-www-form-urlencoded"
1167
+ },
1168
+ body: body.toString(),
1169
+ signal: AbortSignal.timeout(30000)
1170
+ });
1171
+ const text = await res.text();
1172
+ if (!res.ok) {
1173
+ accessTokenCache.delete(key);
1174
+ return {
1175
+ error: `Microsoft OAuth refresh failed (${res.status}): ${text.slice(0, 300)}`
1176
+ };
1206
1177
  }
1207
- };
1208
- const handleResponse = async (currentSpan, parentSpan)=>{
1178
+ const parsed = JSON.parse(text);
1179
+ if (!parsed.access_token) return {
1180
+ error: "OAuth response missing access_token"
1181
+ };
1182
+ const expires_at = Date.now() + (parsed.expires_in ?? 3000) * 1000;
1183
+ accessTokenCache.set(key, {
1184
+ token: parsed.access_token,
1185
+ expires_at
1186
+ });
1187
+ return parsed.access_token;
1188
+ } catch (err) {
1189
+ return {
1190
+ error: `Microsoft OAuth refresh threw: ${(0,_lib_utils_error__WEBPACK_IMPORTED_MODULE_4__/* .errorMessage */ .g)(err)}`
1191
+ };
1192
+ }
1193
+ }
1194
+ // Path-prefix → required Graph scope. Used to render helpful 403 messages
1195
+ // pointing the user at the exact scope they need to reconnect with.
1196
+ const SCOPE_HINTS = [
1197
+ {
1198
+ prefix: "/me/messages",
1199
+ scope: "Mail.ReadWrite"
1200
+ },
1201
+ {
1202
+ prefix: "/me/mailFolders",
1203
+ scope: "Mail.ReadWrite"
1204
+ },
1205
+ {
1206
+ prefix: "/me/sendMail",
1207
+ scope: "Mail.Send"
1208
+ },
1209
+ {
1210
+ prefix: "/me/events",
1211
+ scope: "Calendars.ReadWrite"
1212
+ },
1213
+ {
1214
+ prefix: "/me/calendar",
1215
+ scope: "Calendars.ReadWrite"
1216
+ },
1217
+ {
1218
+ prefix: "/me/calendars",
1219
+ scope: "Calendars.ReadWrite"
1220
+ },
1221
+ {
1222
+ prefix: "/me/todo",
1223
+ scope: "Tasks.ReadWrite"
1224
+ },
1225
+ {
1226
+ prefix: "/me/people",
1227
+ scope: "People.Read"
1228
+ },
1229
+ {
1230
+ prefix: "/me/contacts",
1231
+ scope: "Contacts.Read"
1232
+ },
1233
+ {
1234
+ prefix: "/me/drive",
1235
+ scope: "Files.Read"
1236
+ },
1237
+ {
1238
+ prefix: "/me/insights",
1239
+ scope: "Sites.Read.All"
1240
+ },
1241
+ {
1242
+ prefix: "/search/query",
1243
+ scope: "Mail.Read Files.Read.All"
1244
+ },
1245
+ {
1246
+ prefix: "/me",
1247
+ scope: "User.Read"
1248
+ }
1249
+ ];
1250
+ function scopeHintFor(path) {
1251
+ const p = path.startsWith("http") ? new URL(path).pathname.replace(/^\/v1\.0/, "") : path;
1252
+ for (const { prefix, scope } of SCOPE_HINTS){
1253
+ if (p.startsWith(prefix)) return scope;
1254
+ }
1255
+ return null;
1256
+ }
1257
+ function parseRetryAfter(headerVal) {
1258
+ if (!headerVal) return 0;
1259
+ const secs = Number.parseInt(headerVal, 10);
1260
+ if (Number.isFinite(secs) && secs >= 0) return Math.min(secs, 30) * 1000;
1261
+ const ts = Date.parse(headerVal);
1262
+ if (!Number.isNaN(ts)) return Math.max(0, Math.min(ts - Date.now(), 30000));
1263
+ return 0;
1264
+ }
1265
+ function backoffFor(attempt) {
1266
+ return Math.min(500 * 2 ** attempt, 4000);
1267
+ }
1268
+ // Shared Graph fetch helper. Used by lib/tools/outlook.ts,
1269
+ // lib/tools/outlook-calendar.ts, lib/tools/ms-todo.ts, lib/tools/ms-graph.ts.
1270
+ // Returns parsed JSON or { error: string, url? }. 204 No Content returns
1271
+ // { ok: true }.
1272
+ //
1273
+ // Built-in resilience:
1274
+ // - 401 Unauthorized → drop the cached access token and retry once with a
1275
+ // freshly refreshed one (covers token-revoked-mid-cache edge cases).
1276
+ // - 429 / 503 → honour the `Retry-After` header (capped at 30s) or fall
1277
+ // back to exponential backoff. Retries up to 3 times.
1278
+ // - 403 Forbidden → surface a scope hint ("reconnect with X") so the
1279
+ // operator knows what to grant.
1280
+ async function graphFetch(auth, path, init) {
1281
+ const url = path.startsWith("http") ? path : `https://graph.microsoft.com/v1.0${path}`;
1282
+ let attempt = 0;
1283
+ let triedReauth = false;
1284
+ while(true){
1285
+ const token = await getMicrosoftAccessToken(auth);
1286
+ if (typeof token !== "string") return token;
1287
+ let res;
1209
1288
  try {
1210
- var _cacheEntry_value;
1211
- const cacheEntry = await routeModule.handleResponse({
1212
- req,
1213
- nextConfig,
1214
- cacheKey,
1215
- routeKind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
1216
- isFallback: false,
1217
- previewProps,
1218
- prerenderManifest,
1219
- isRoutePPREnabled: false,
1220
- isOnDemandRevalidate,
1221
- revalidateOnlyGenerated,
1222
- responseGenerator,
1223
- waitUntil: ctx.waitUntil,
1224
- isMinimalMode
1289
+ res = await fetch(url, {
1290
+ ...init,
1291
+ headers: {
1292
+ Authorization: `Bearer ${token}`,
1293
+ Accept: "application/json",
1294
+ "Content-Type": "application/json",
1295
+ ...init?.headers ?? {}
1296
+ },
1297
+ signal: AbortSignal.timeout(30000)
1225
1298
  });
1226
- if (cacheEntry !== null && 'error' in cacheEntry) {
1227
- throw cacheEntry.error;
1228
- }
1229
- // we don't create a cacheEntry for ISR
1230
- if (!isIsr) {
1231
- return;
1232
- }
1233
- if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE) {
1234
- var _cacheEntry_value1;
1235
- throw new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`);
1236
- }
1237
- if (!isMinimalMode) {
1238
- res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');
1239
- }
1240
- // Draft mode should never be cached
1241
- if (isDraftMode) {
1242
- res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
1243
- }
1244
- const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.fromNodeOutgoingHttpHeaders)(cacheEntry.value.headers);
1245
- if (!(isMinimalMode && isIsr)) {
1246
- headers.delete(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER);
1247
- }
1248
- // If cache control is already set on the response we don't
1249
- // override it to allow users to customize it via next.config
1250
- if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {
1251
- headers.set('Cache-Control', (0,next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__.getCacheControlHeader)(cacheEntry.cacheControl));
1252
- }
1253
- await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.
1254
- new Response(cacheEntry.value.body, {
1255
- headers,
1256
- status: cacheEntry.value.status || 200
1257
- }));
1258
- return;
1259
1299
  } catch (err) {
1260
- if (!(err instanceof next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError)) {
1261
- const silenceLog = false;
1262
- await routeModule.onRequestError(req, err, {
1263
- routerKind: 'App Router',
1264
- routePath: normalizedSrcPage,
1265
- routeType: 'route',
1266
- revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
1267
- isStaticGeneration: cacheKey !== null,
1268
- isOnDemandRevalidate
1269
- })
1270
- }, silenceLog, routerServerContext);
1271
- }
1272
- // rethrow so that we can handle serving error page
1273
- // If this is during static generation, throw the error again.
1274
- if (isIsr) throw err;
1275
- // Otherwise, send a 500 response unless the original response has
1276
- // already committed. In that case, preserve its status code for
1277
- // telemetry while still recording the failure and terminating a response
1278
- // that the failed pipeline left open.
1279
- if (res.headersSent) {
1280
- if (currentSpan) {
1281
- const error = err instanceof Error ? err : new Error('Unknown app route error');
1282
- currentSpan.recordException(error);
1283
- currentSpan.setStatus({
1284
- code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
1285
- message: error.message
1286
- });
1287
- currentSpan.setAttribute('error.type', error.name);
1288
- }
1289
- if (!res.writableEnded && !res.destroyed) {
1290
- res.end();
1300
+ return {
1301
+ error: `Graph fetch threw: ${(0,_lib_utils_error__WEBPACK_IMPORTED_MODULE_4__/* .errorMessage */ .g)(err)}`,
1302
+ url
1303
+ };
1304
+ }
1305
+ if (res.status === 204) return {
1306
+ ok: true
1307
+ };
1308
+ if (res.status === 401 && !triedReauth) {
1309
+ triedReauth = true;
1310
+ bustAccessToken(auth);
1311
+ continue;
1312
+ }
1313
+ if ((res.status === 429 || res.status === 503) && attempt < 3) {
1314
+ const waitMs = parseRetryAfter(res.headers.get("Retry-After")) ?? backoffFor(attempt);
1315
+ attempt += 1;
1316
+ await new Promise((r)=>setTimeout(r, waitMs));
1317
+ continue;
1318
+ }
1319
+ const text = await res.text();
1320
+ if (!res.ok) {
1321
+ let msg = `Graph ${res.status}: ${text.slice(0, 500)}`;
1322
+ if (res.status === 403) {
1323
+ const hint = scopeHintFor(path);
1324
+ if (hint) {
1325
+ msg += ` — reconnect the Microsoft integration with scope: ${hint}`;
1291
1326
  }
1292
- } else {
1293
- await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, new Response(null, {
1294
- status: 500
1295
- }));
1296
1327
  }
1297
- return;
1298
- } finally{
1299
- ;
1300
- (()=>{
1301
- if (!currentSpan) {
1302
- return;
1303
- }
1304
- let statusCode = res.statusCode;
1305
- currentSpan.setAttributes({
1306
- 'http.status_code': statusCode,
1307
- 'next.rsc': false
1308
- });
1309
- if (statusCode && statusCode >= 500) {
1310
- // For 5xx status codes: SHOULD be set to 'Error' span status.
1311
- // x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
1312
- currentSpan.setStatus({
1313
- code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR
1314
- });
1315
- // For span status 'Error', SHOULD set 'error.type' attribute.
1316
- currentSpan.setAttribute('error.type', statusCode.toString());
1317
- }
1318
- const rootSpanAttributes = tracer.getRootSpanAttributes();
1319
- // We were unable to get attributes, probably OTEL is not enabled
1320
- if (!rootSpanAttributes) {
1321
- return;
1322
- }
1323
- if (rootSpanAttributes.get('next.span_type') !== next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest) {
1324
- console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
1325
- return;
1326
- }
1327
- const route = rootSpanAttributes.get('next.route') || normalizedSrcPage;
1328
- const name = `${method} ${route}`;
1329
- currentSpan.setAttributes({
1330
- 'next.route': route,
1331
- 'http.route': route,
1332
- 'next.span_name': name
1333
- });
1334
- currentSpan.updateName(name);
1335
- // Propagate http.route to the parent span if one exists (e.g.
1336
- // a platform-created HTTP span in adapter deployments).
1337
- if (parentSpan && parentSpan !== currentSpan) {
1338
- parentSpan.setAttribute('http.route', route);
1339
- parentSpan.updateName(name);
1340
- }
1341
- })();
1328
+ return {
1329
+ error: msg,
1330
+ url
1331
+ };
1342
1332
  }
1343
- };
1344
- // TODO: activeSpan code path is for when wrapped by
1345
- // next-server can be removed when this is no longer used
1346
- if (isWrappedByNextServer && activeSpan) {
1347
- await handleResponse(activeSpan, undefined);
1348
- } else {
1349
- let parentSpan = tracer.getActiveScopeSpan();
1350
- await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest, {
1351
- spanName: `${method} ${srcPage}`,
1352
- kind: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanKind.SERVER,
1353
- attributes: {
1354
- 'http.method': method,
1355
- 'http.target': req.url
1356
- }
1357
- }, (span)=>handleResponse(span, parentSpan)), undefined, !isWrappedByNextServer);
1333
+ try {
1334
+ return JSON.parse(text);
1335
+ } catch {
1336
+ return text;
1337
+ }
1338
+ }
1339
+ }
1340
+ // Follow @odata.nextLink across pages and concatenate `value` arrays.
1341
+ // Stops at `maxPages` (default 5) to bound context cost. Returns the same
1342
+ // shape as graphFetch (object with `.value`) but with the merged array, or
1343
+ // the original error shape if any page errored.
1344
+ async function graphPaged(auth, path, opts) {
1345
+ const maxPages = opts?.maxPages ?? 5;
1346
+ let current = path;
1347
+ const merged = [];
1348
+ let pages = 0;
1349
+ while(current && pages < maxPages){
1350
+ const page = await graphFetch(auth, current, opts?.init);
1351
+ if (page && typeof page === "object" && "error" in page) return page;
1352
+ const body = page;
1353
+ if (Array.isArray(body.value)) merged.push(...body.value);
1354
+ current = typeof body["@odata.nextLink"] === "string" ? body["@odata.nextLink"] : null;
1355
+ pages += 1;
1358
1356
  }
1357
+ return {
1358
+ value: merged,
1359
+ pages
1360
+ };
1359
1361
  }
1360
1362
 
1361
- //# sourceMappingURL=app-route.js.map
1362
1363
 
1364
+ /***/ }),
1365
+
1366
+ /***/ 94735:
1367
+ /***/ ((module) => {
1368
+
1369
+ module.exports = require("events");
1363
1370
 
1364
1371
  /***/ }),
1365
1372
 
@@ -1377,7 +1384,7 @@ module.exports = import("@huggingface/transformers");;
1377
1384
  var __webpack_require__ = require("../../../../../../../webpack-runtime.js");
1378
1385
  __webpack_require__.C(exports);
1379
1386
  var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
1380
- var __webpack_exports__ = __webpack_require__.X(0, [2970,7377,1813,7981,4992,46], () => (__webpack_exec__(98671)));
1387
+ var __webpack_exports__ = __webpack_require__.X(0, [2970,7377,1813,7981,4992,46], () => (__webpack_exec__(82637)));
1381
1388
  module.exports = __webpack_exports__;
1382
1389
 
1383
1390
  })();