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