@circuitwall/jarela 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (703) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +2 -1
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/routes-manifest.json +8 -0
  6. package/.next/standalone/.next/server/app/_global-error/page.js +68 -68
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page.js +76 -76
  14. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  16. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/.next/standalone/.next/server/app/api/v1/access/[identity]/route.js +100 -93
  22. package/.next/standalone/.next/server/app/api/v1/access/route.js +176 -169
  23. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js +89 -56
  24. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/v1/agents/[id]/display-filters/route.js +139 -127
  26. package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +107 -100
  27. package/.next/standalone/.next/server/app/api/v1/agents/[id]/thread/route.js +765 -753
  28. package/.next/standalone/.next/server/app/api/v1/agents/route.js +72 -65
  29. package/.next/standalone/.next/server/app/api/v1/allowed-sites/[hostname]/route.js +371 -364
  30. package/.next/standalone/.next/server/app/api/v1/allowed-sites/route.js +809 -802
  31. package/.next/standalone/.next/server/app/api/v1/artifacts/lifecycle/route.js +9 -2
  32. package/.next/standalone/.next/server/app/api/v1/attachments/files/route.js +49 -49
  33. package/.next/standalone/.next/server/app/api/v1/attachments/images/route.js +910 -910
  34. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +583 -16
  35. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/[remote_jid]/route.js +41 -30
  37. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/route.js +48 -37
  38. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +697 -130
  39. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +703 -136
  41. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +796 -229
  43. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/[route_id]/route.js +762 -746
  45. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/route.js +1050 -1034
  46. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +673 -106
  47. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js +811 -804
  49. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/v1/bridges/route.js +718 -706
  51. package/.next/standalone/.next/server/app/api/v1/bridges/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +9 -9
  53. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/v1/config/route.js +85 -85
  55. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +709 -709
  56. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/v1/credentials/route.js +2 -2
  58. package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/v1/dashboard/currency/route.js +10 -10
  60. package/.next/standalone/.next/server/app/api/v1/dashboard/metrics/route.js +796 -784
  61. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing/route.js +30 -23
  62. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +86 -86
  63. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +57 -57
  65. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
  66. package/.next/standalone/.next/server/app/api/v1/documents/search/route.js +385 -378
  67. package/.next/standalone/.next/server/app/api/v1/documents/settings/route.js +51 -44
  68. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +65 -65
  69. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
  70. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +122 -122
  71. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
  72. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +37 -37
  73. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
  74. package/.next/standalone/.next/server/app/api/v1/env/route.js +9 -9
  75. package/.next/standalone/.next/server/app/api/v1/env-sync/allowlist/route.js +375 -368
  76. package/.next/standalone/.next/server/app/api/v1/env-sync/route.js +51 -44
  77. package/.next/standalone/.next/server/app/api/v1/events/route.js +745 -178
  78. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/api/v1/events/test/route.js +77 -77
  80. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +763 -763
  81. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
  82. package/.next/standalone/.next/server/app/api/v1/extension/browser/activate/route.js +51 -44
  83. package/.next/standalone/.next/server/app/api/v1/extension/browser/foreground/route.js +16 -9
  84. package/.next/standalone/.next/server/app/api/v1/extension/browser/history/route.js +72 -65
  85. package/.next/standalone/.next/server/app/api/v1/extension/browser/poll/route.js +41 -34
  86. package/.next/standalone/.next/server/app/api/v1/extension/browser/progress/route.js +211 -204
  87. package/.next/standalone/.next/server/app/api/v1/extension/browser/result/route.js +140 -133
  88. package/.next/standalone/.next/server/app/api/v1/extension/browser/retry/route.js +113 -106
  89. package/.next/standalone/.next/server/app/api/v1/extension/browser/status/route.js +121 -114
  90. package/.next/standalone/.next/server/app/api/v1/extension/browser/tabs/route.js +141 -134
  91. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +690 -690
  92. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +93 -93
  94. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +9 -9
  96. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
  97. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +185 -185
  98. package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
  99. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +171 -171
  100. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
  101. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +396 -396
  102. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
  103. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +212 -212
  104. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
  105. package/.next/standalone/.next/server/app/api/v1/files/[name]/route.js +235 -235
  106. package/.next/standalone/.next/server/app/api/v1/fs/browse/route.js +26 -26
  107. package/.next/standalone/.next/server/app/api/v1/harnesses/[id]/route.js +228 -221
  108. package/.next/standalone/.next/server/app/api/v1/harnesses/default/route.js +65 -58
  109. package/.next/standalone/.next/server/app/api/v1/harnesses/route.js +79 -72
  110. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +9 -9
  111. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
  112. package/.next/standalone/.next/server/app/api/v1/health/route.js +783 -771
  113. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/route.js +140 -133
  114. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +9 -9
  115. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
  116. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +370 -363
  117. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +240 -233
  118. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +689 -682
  119. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +886 -879
  120. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +115 -108
  121. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +955 -948
  122. package/.next/standalone/.next/server/app/api/v1/integrations/route.js +223 -216
  123. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js +876 -847
  124. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js.nft.json +1 -1
  125. package/.next/standalone/.next/server/app/api/v1/local-file/route.js +26 -26
  126. package/.next/standalone/.next/server/app/api/v1/logs/route.js +70 -70
  127. package/.next/standalone/.next/server/app/api/v1/maps/embed/route.js +79 -72
  128. package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +991 -979
  129. package/.next/standalone/.next/server/app/api/v1/mcp-servers/registry/route.js +196 -196
  130. package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +19 -7
  131. package/.next/standalone/.next/server/app/api/v1/memory/[namespace]/[key]/route.js +539 -532
  132. package/.next/standalone/.next/server/app/api/v1/memory/policy/route.js +86 -79
  133. package/.next/standalone/.next/server/app/api/v1/memory/route.js +58 -51
  134. package/.next/standalone/.next/server/app/api/v1/memory/search/route.js +138 -131
  135. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js +381 -369
  136. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js.nft.json +1 -1
  137. package/.next/standalone/.next/server/app/api/v1/models/[name]/route.js +150 -143
  138. package/.next/standalone/.next/server/app/api/v1/models/route.js +634 -627
  139. package/.next/standalone/.next/server/app/api/v1/packages/catalog/route.js +445 -445
  140. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +120 -120
  141. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
  142. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +234 -234
  143. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
  144. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +407 -407
  145. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
  146. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +37 -37
  147. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
  148. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +107 -107
  149. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
  150. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +228 -228
  151. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
  152. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +9 -9
  153. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
  154. package/.next/standalone/.next/server/app/api/v1/packages/route.js +148 -148
  155. package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
  156. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +787 -787
  157. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
  158. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +529 -514
  159. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
  160. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +181 -181
  161. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
  162. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +258 -258
  163. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
  164. package/.next/standalone/.next/server/app/api/v1/profile/location/route.js +37 -30
  165. package/.next/standalone/.next/server/app/api/v1/profile/route.js +171 -164
  166. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +51 -44
  167. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/probe/route.js +15 -8
  168. package/.next/standalone/.next/server/app/api/v1/providers/github-copilot/auth/route.js +171 -164
  169. package/.next/standalone/.next/server/app/api/v1/providers/route.js +101 -94
  170. package/.next/standalone/.next/server/app/api/v1/proxy-config/route.js +457 -450
  171. package/.next/standalone/.next/server/app/api/v1/redaction/init/route.js +44 -37
  172. package/.next/standalone/.next/server/app/api/v1/redaction/route.js +65 -58
  173. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/route.js +617 -605
  174. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +44 -44
  175. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
  176. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/route.js +739 -732
  177. package/.next/standalone/.next/server/app/api/v1/security/idle-timeout/route.js +329 -322
  178. package/.next/standalone/.next/server/app/api/v1/security/pin/route.js +204 -197
  179. package/.next/standalone/.next/server/app/api/v1/security/state/route.js +58 -51
  180. package/.next/standalone/.next/server/app/api/v1/security/unlock/route.js +183 -176
  181. package/.next/standalone/.next/server/app/api/v1/security/verify-pin/route.js +194 -187
  182. package/.next/standalone/.next/server/app/api/v1/setup/test-key/route.js +26 -26
  183. package/.next/standalone/.next/server/app/api/v1/skills/[id]/route.js +776 -769
  184. package/.next/standalone/.next/server/app/api/v1/skills/repos/[id]/route.js +122 -115
  185. package/.next/standalone/.next/server/app/api/v1/skills/repos/route.js +334 -327
  186. package/.next/standalone/.next/server/app/api/v1/skills/route.js +873 -866
  187. package/.next/standalone/.next/server/app/api/v1/system/abort/route.js +838 -808
  188. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +177 -177
  189. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
  190. package/.next/standalone/.next/server/app/api/v1/tailscale/route.js +164 -164
  191. package/.next/standalone/.next/server/app/api/v1/tasks/[agent_id]/route.js +122 -115
  192. package/.next/standalone/.next/server/app/api/v1/tasks/route.js +30 -23
  193. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js +1436 -0
  194. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js.nft.json +1 -0
  195. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route_client-reference-manifest.js +1 -0
  196. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js +638 -631
  197. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js.nft.json +1 -1
  198. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +60 -439
  199. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js.nft.json +1 -1
  200. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +172 -173
  201. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
  202. package/.next/standalone/.next/server/app/api/v1/threads/route.js +925 -913
  203. package/.next/standalone/.next/server/app/api/v1/tools/route.js +2 -2
  204. package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
  205. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js +17 -17
  206. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
  207. package/.next/standalone/.next/server/app/api/v1/update/route.js +570 -570
  208. package/.next/standalone/.next/server/app/api/v1/voice/transcribe/route.js +241 -229
  209. package/.next/standalone/.next/server/app/api/v1/voice/tts/route.js +989 -977
  210. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/route.js +40 -28
  211. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +72 -72
  212. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
  213. package/.next/standalone/.next/server/app/api/v1/watchers/reaction-scripts/route.js +128 -128
  214. package/.next/standalone/.next/server/app/api/v1/watchers/route.js +164 -164
  215. package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
  216. package/.next/standalone/.next/server/app/icon.svg/route.js +62 -62
  217. package/.next/standalone/.next/server/app/manifest.webmanifest/route.js +436 -436
  218. package/.next/standalone/.next/server/app/page.js +1179 -743
  219. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  220. package/.next/standalone/.next/server/app/setup/page.js +99 -91
  221. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  222. package/.next/standalone/.next/server/app-paths-manifest.json +2 -1
  223. package/.next/standalone/.next/server/chunks/{424.js → 1388.js} +441 -1022
  224. package/.next/standalone/.next/server/chunks/1433.js +1 -1
  225. package/.next/standalone/.next/server/chunks/1638.js +1 -2
  226. package/.next/standalone/.next/server/chunks/1738.js +1 -1
  227. package/.next/standalone/.next/server/chunks/2068.js +47 -10
  228. package/.next/standalone/.next/server/chunks/210.js +3 -3
  229. package/.next/standalone/.next/server/chunks/2151.js +31 -1
  230. package/.next/standalone/.next/server/chunks/2207.js +1 -0
  231. package/.next/standalone/.next/server/chunks/2447.js +10 -5
  232. package/.next/standalone/.next/server/chunks/2471.js +45 -45
  233. package/.next/standalone/.next/server/chunks/2504.js +1 -1
  234. package/.next/standalone/.next/server/chunks/2695.js +17 -17
  235. package/.next/standalone/.next/server/chunks/3042.js +24 -16
  236. package/.next/standalone/.next/server/chunks/{4540.js → 309.js} +104 -38
  237. package/.next/standalone/.next/server/chunks/{2350.js → 3272.js} +104 -37
  238. package/.next/standalone/.next/server/chunks/3399.js +526 -526
  239. package/.next/standalone/.next/server/chunks/3524.js +150 -67
  240. package/.next/standalone/.next/server/chunks/3566.js +1 -1
  241. package/.next/standalone/.next/server/chunks/4189.js +946 -0
  242. package/.next/standalone/.next/server/chunks/4433.js +146 -146
  243. package/.next/standalone/.next/server/chunks/4508.js +3 -3
  244. package/.next/standalone/.next/server/chunks/4588.js +1 -0
  245. package/.next/standalone/.next/server/chunks/46.js +78 -28
  246. package/.next/standalone/.next/server/chunks/466.js +12 -0
  247. package/.next/standalone/.next/server/chunks/4868.js +206 -206
  248. package/.next/standalone/.next/server/chunks/4992.js +13 -0
  249. package/.next/standalone/.next/server/chunks/5120.js +963 -0
  250. package/.next/standalone/.next/server/chunks/5701.js +1 -1
  251. package/.next/standalone/.next/server/chunks/5900.js +1 -1
  252. package/.next/standalone/.next/server/chunks/5908.js +63 -42
  253. package/.next/standalone/.next/server/chunks/6142.js +10 -2
  254. package/.next/standalone/.next/server/chunks/6210.js +1 -0
  255. package/.next/standalone/.next/server/chunks/6213.js +1 -1
  256. package/.next/standalone/.next/server/chunks/6649.js +3 -3
  257. package/.next/standalone/.next/server/chunks/6703.js +3 -3
  258. package/.next/standalone/.next/server/chunks/7445.js +1 -0
  259. package/.next/standalone/.next/server/chunks/8067.js +12 -0
  260. package/.next/standalone/.next/server/chunks/8461.js +24 -17
  261. package/.next/standalone/.next/server/chunks/8558.js +1 -1
  262. package/.next/standalone/.next/server/chunks/8724.js +1 -1
  263. package/.next/standalone/.next/server/chunks/8849.js +91 -91
  264. package/.next/standalone/.next/server/chunks/9032.js +4 -3
  265. package/.next/standalone/.next/server/chunks/{2563.js → 9164.js} +33389 -31418
  266. package/.next/standalone/.next/server/chunks/9237.js +396 -396
  267. package/.next/standalone/.next/server/chunks/{9640.js → 9304.js} +1672 -575
  268. package/.next/standalone/.next/server/chunks/9406.js +1 -1
  269. package/.next/standalone/.next/server/chunks/9590.js +68 -18
  270. package/.next/standalone/.next/server/chunks/9824.js +98 -98
  271. package/.next/standalone/.next/server/chunks/9826.js +1 -0
  272. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  273. package/.next/standalone/.next/server/middleware.js +486 -415
  274. package/.next/standalone/.next/server/pages/404.html +2 -2
  275. package/.next/standalone/.next/server/pages/500.html +1 -1
  276. package/.next/standalone/.next/server/preview-props.json +3 -3
  277. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  278. package/.next/standalone/.next/static/chunks/{1395-a340fb0a345382a4.js → 1395-e4a99912b8f83044.js} +13 -1
  279. package/.next/standalone/.next/static/chunks/app/_global-error/{page-36cb8b428b38b26a.js → page-6fc5f8e744c81802.js} +1 -1
  280. package/.next/standalone/.next/static/chunks/app/api/v1/access/[identity]/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  281. package/.next/standalone/.next/static/chunks/app/api/v1/access/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  282. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/compact/{route-36cb8b428b38b26a.js → route-6fc5f8e744c81802.js} +1 -1
  283. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-6fc5f8e744c81802.js +17 -0
  284. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-6fc5f8e744c81802.js +17 -0
  285. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-6fc5f8e744c81802.js +17 -0
  286. package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-6fc5f8e744c81802.js +17 -0
  287. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-6fc5f8e744c81802.js +17 -0
  288. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-6fc5f8e744c81802.js +17 -0
  289. package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-6fc5f8e744c81802.js +17 -0
  290. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-6fc5f8e744c81802.js +17 -0
  291. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-6fc5f8e744c81802.js +17 -0
  292. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-6fc5f8e744c81802.js +17 -0
  293. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-6fc5f8e744c81802.js +17 -0
  294. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-6fc5f8e744c81802.js +17 -0
  295. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-6fc5f8e744c81802.js +17 -0
  296. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-6fc5f8e744c81802.js +17 -0
  297. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-6fc5f8e744c81802.js +17 -0
  298. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-6fc5f8e744c81802.js +17 -0
  299. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-6fc5f8e744c81802.js +17 -0
  300. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-6fc5f8e744c81802.js +17 -0
  301. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-6fc5f8e744c81802.js +17 -0
  302. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-6fc5f8e744c81802.js +17 -0
  303. package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-6fc5f8e744c81802.js +17 -0
  304. package/.next/standalone/.next/static/chunks/app/api/v1/config/route-6fc5f8e744c81802.js +17 -0
  305. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-6fc5f8e744c81802.js +17 -0
  306. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-6fc5f8e744c81802.js +17 -0
  307. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-6fc5f8e744c81802.js +17 -0
  308. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-6fc5f8e744c81802.js +17 -0
  309. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-6fc5f8e744c81802.js +17 -0
  310. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-6fc5f8e744c81802.js +17 -0
  311. package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-6fc5f8e744c81802.js +17 -0
  312. package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-6fc5f8e744c81802.js +17 -0
  313. package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-6fc5f8e744c81802.js +17 -0
  314. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-6fc5f8e744c81802.js +17 -0
  315. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-6fc5f8e744c81802.js +17 -0
  316. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-6fc5f8e744c81802.js +17 -0
  317. package/.next/standalone/.next/static/chunks/app/api/v1/env/route-6fc5f8e744c81802.js +17 -0
  318. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-6fc5f8e744c81802.js +17 -0
  319. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-6fc5f8e744c81802.js +17 -0
  320. package/.next/standalone/.next/static/chunks/app/api/v1/events/route-6fc5f8e744c81802.js +17 -0
  321. package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-6fc5f8e744c81802.js +17 -0
  322. package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-6fc5f8e744c81802.js +17 -0
  323. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-6fc5f8e744c81802.js +17 -0
  324. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-6fc5f8e744c81802.js +17 -0
  325. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-6fc5f8e744c81802.js +17 -0
  326. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-6fc5f8e744c81802.js +17 -0
  327. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-6fc5f8e744c81802.js +17 -0
  328. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-6fc5f8e744c81802.js +17 -0
  329. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-6fc5f8e744c81802.js +17 -0
  330. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-6fc5f8e744c81802.js +17 -0
  331. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-6fc5f8e744c81802.js +17 -0
  332. package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-6fc5f8e744c81802.js +17 -0
  333. package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-6fc5f8e744c81802.js +17 -0
  334. package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-6fc5f8e744c81802.js +17 -0
  335. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-6fc5f8e744c81802.js +17 -0
  336. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-6fc5f8e744c81802.js +17 -0
  337. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-6fc5f8e744c81802.js +17 -0
  338. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-6fc5f8e744c81802.js +17 -0
  339. package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-6fc5f8e744c81802.js +17 -0
  340. package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-6fc5f8e744c81802.js +17 -0
  341. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-6fc5f8e744c81802.js +17 -0
  342. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-6fc5f8e744c81802.js +17 -0
  343. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-6fc5f8e744c81802.js +17 -0
  344. package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-6fc5f8e744c81802.js +17 -0
  345. package/.next/standalone/.next/static/chunks/app/api/v1/health/route-6fc5f8e744c81802.js +17 -0
  346. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-6fc5f8e744c81802.js +17 -0
  347. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-6fc5f8e744c81802.js +17 -0
  348. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-6fc5f8e744c81802.js +17 -0
  349. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-6fc5f8e744c81802.js +17 -0
  350. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-6fc5f8e744c81802.js +17 -0
  351. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-6fc5f8e744c81802.js +17 -0
  352. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-6fc5f8e744c81802.js +17 -0
  353. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-6fc5f8e744c81802.js +17 -0
  354. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-6fc5f8e744c81802.js +17 -0
  355. package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-6fc5f8e744c81802.js +17 -0
  356. package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-6fc5f8e744c81802.js +17 -0
  357. package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-6fc5f8e744c81802.js +17 -0
  358. package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-6fc5f8e744c81802.js +17 -0
  359. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-6fc5f8e744c81802.js +17 -0
  360. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-6fc5f8e744c81802.js +17 -0
  361. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-6fc5f8e744c81802.js +17 -0
  362. package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-6fc5f8e744c81802.js +17 -0
  363. package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-6fc5f8e744c81802.js +17 -0
  364. package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-6fc5f8e744c81802.js +17 -0
  365. package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-6fc5f8e744c81802.js +17 -0
  366. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-6fc5f8e744c81802.js +17 -0
  367. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-6fc5f8e744c81802.js +17 -0
  368. package/.next/standalone/.next/static/chunks/app/api/v1/models/route-6fc5f8e744c81802.js +17 -0
  369. package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-6fc5f8e744c81802.js +17 -0
  370. package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-6fc5f8e744c81802.js +17 -0
  371. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-6fc5f8e744c81802.js +17 -0
  372. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-6fc5f8e744c81802.js +17 -0
  373. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-6fc5f8e744c81802.js +17 -0
  374. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-6fc5f8e744c81802.js +17 -0
  375. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-6fc5f8e744c81802.js +17 -0
  376. package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-6fc5f8e744c81802.js +17 -0
  377. package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-6fc5f8e744c81802.js +17 -0
  378. package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-6fc5f8e744c81802.js +17 -0
  379. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-6fc5f8e744c81802.js +17 -0
  380. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-6fc5f8e744c81802.js +17 -0
  381. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-6fc5f8e744c81802.js +17 -0
  382. package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-6fc5f8e744c81802.js +17 -0
  383. package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-6fc5f8e744c81802.js +17 -0
  384. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-6fc5f8e744c81802.js +17 -0
  385. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-6fc5f8e744c81802.js +17 -0
  386. package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-6fc5f8e744c81802.js +17 -0
  387. package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-6fc5f8e744c81802.js +17 -0
  388. package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-6fc5f8e744c81802.js +17 -0
  389. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-6fc5f8e744c81802.js +17 -0
  390. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-6fc5f8e744c81802.js +17 -0
  391. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-6fc5f8e744c81802.js +17 -0
  392. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-6fc5f8e744c81802.js +17 -0
  393. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-6fc5f8e744c81802.js +17 -0
  394. package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-6fc5f8e744c81802.js +17 -0
  395. package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-6fc5f8e744c81802.js +17 -0
  396. package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-6fc5f8e744c81802.js +17 -0
  397. package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-6fc5f8e744c81802.js +17 -0
  398. package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-6fc5f8e744c81802.js +17 -0
  399. package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-6fc5f8e744c81802.js +17 -0
  400. package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-6fc5f8e744c81802.js +17 -0
  401. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-6fc5f8e744c81802.js +17 -0
  402. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-6fc5f8e744c81802.js +17 -0
  403. package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-6fc5f8e744c81802.js +17 -0
  404. package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-6fc5f8e744c81802.js +17 -0
  405. package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-6fc5f8e744c81802.js +17 -0
  406. package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-6fc5f8e744c81802.js +17 -0
  407. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-6fc5f8e744c81802.js +17 -0
  408. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-6fc5f8e744c81802.js +17 -0
  409. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/activity/route-6fc5f8e744c81802.js +17 -0
  410. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-6fc5f8e744c81802.js +17 -0
  411. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-6fc5f8e744c81802.js +17 -0
  412. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-6fc5f8e744c81802.js +17 -0
  413. package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-6fc5f8e744c81802.js +17 -0
  414. package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-6fc5f8e744c81802.js +17 -0
  415. package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-6fc5f8e744c81802.js +17 -0
  416. package/.next/standalone/.next/static/chunks/app/api/v1/update/route-6fc5f8e744c81802.js +17 -0
  417. package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-6fc5f8e744c81802.js +17 -0
  418. package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-6fc5f8e744c81802.js +17 -0
  419. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-6fc5f8e744c81802.js +17 -0
  420. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-6fc5f8e744c81802.js +17 -0
  421. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-6fc5f8e744c81802.js +17 -0
  422. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-6fc5f8e744c81802.js +17 -0
  423. package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-6fc5f8e744c81802.js +17 -0
  424. package/.next/standalone/.next/static/chunks/app/{page-7017f07f8a7a083c.js → page-04748847c6ff866f.js} +1013 -585
  425. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-6fc5f8e744c81802.js +17 -0
  426. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-6fc5f8e744c81802.js +17 -0
  427. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-6fc5f8e744c81802.js +17 -0
  428. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-6fc5f8e744c81802.js +17 -0
  429. package/.next/standalone/.next/static/css/{d80058f0b9b41c09.css → 2669e8744cc8c212.css} +2 -2
  430. package/.next/standalone/docs/adoption/changesets.json +358 -0
  431. package/.next/standalone/lib/skills/builtins/memory-organization/SKILL.md +16 -0
  432. package/.next/standalone/package.json +3 -3
  433. package/CHANGELOG.md +44 -0
  434. package/api/client.ts +9 -0
  435. package/api/types.ts +29 -0
  436. package/app/api/v1/lifecycle/adoption/route.ts +14 -2
  437. package/app/api/v1/models/[name]/compact-threads/route.ts +14 -11
  438. package/app/api/v1/threads/[thread_id]/activity/route.ts +19 -0
  439. package/app/api/v1/threads/[thread_id]/context-pin/route.test.ts +1 -0
  440. package/app/api/v1/threads/[thread_id]/context-pin/route.ts +2 -1
  441. package/app/api/v1/threads/[thread_id]/route.ts +5 -1
  442. package/app/api/v1/threads/[thread_id]/run/route.ts +0 -1
  443. package/components/chat/ChatView.tsx +52 -11
  444. package/components/chat/ContextBoundary.test.tsx +68 -1
  445. package/components/chat/ContextBoundary.tsx +92 -13
  446. package/components/chat/MessageBubble.tsx +12 -0
  447. package/components/chat/MessageList.test.tsx +31 -0
  448. package/components/chat/MessageList.tsx +49 -28
  449. package/components/chat/ToolList.test.tsx +92 -16
  450. package/components/chat/ToolList.tsx +59 -4
  451. package/components/chat/chat-helpers.test.tsx +24 -1
  452. package/components/chat/chat-helpers.ts +47 -4
  453. package/components/chat/useThreadActivity.test.tsx +113 -0
  454. package/components/chat/useThreadActivity.ts +94 -0
  455. package/components/chat/useThreadData.ts +16 -16
  456. package/components/chat/workflow-step-retry.ts +25 -0
  457. package/components/integrations/NetworkSection.tsx +2 -2
  458. package/components/ui/BootScreen.tsx +17 -0
  459. package/components/ui/WorkflowChecklist.tsx +71 -33
  460. package/hooks/useSSE.ts +28 -3
  461. package/lib/agents/citation-checker.test.ts +40 -2
  462. package/lib/agents/citation-checker.ts +56 -11
  463. package/lib/agents/compaction-pipeline.test.ts +202 -0
  464. package/lib/agents/compaction-pipeline.ts +483 -0
  465. package/lib/agents/context-boundary.ts +5 -6
  466. package/lib/agents/conversation-summary.ts +37 -21
  467. package/lib/agents/instruction-edits.test.ts +120 -0
  468. package/lib/agents/instruction-edits.ts +65 -42
  469. package/lib/agents/prepare/history-window.test.ts +18 -0
  470. package/lib/agents/prepare/history-window.ts +11 -2
  471. package/lib/agents/prepare/request.ts +4 -2
  472. package/lib/agents/prepare/system-prompt.test.ts +49 -0
  473. package/lib/agents/prepare/system-prompt.ts +16 -5
  474. package/lib/agents/prompt-registry.test.ts +5 -140
  475. package/lib/agents/prompt-registry.ts +45 -1
  476. package/lib/agents/prompt-variants.ts +146 -0
  477. package/lib/agents/proposals.test.ts +76 -0
  478. package/lib/agents/proposals.ts +13 -5
  479. package/lib/agents/run-registry.test.ts +22 -0
  480. package/lib/agents/run-registry.ts +29 -0
  481. package/lib/agents/run-thread.auto-boundary.test.ts +125 -5
  482. package/lib/agents/run-thread.retry.test.ts +67 -1
  483. package/lib/agents/run-thread.ts +110 -10
  484. package/lib/agents/sqlite-checkpoint-saver.test.ts +91 -0
  485. package/lib/agents/thread-activity.test.ts +31 -0
  486. package/lib/agents/thread-activity.ts +27 -0
  487. package/lib/agents/thread-compaction-state.test.ts +82 -0
  488. package/lib/agents/thread-compaction-state.ts +121 -0
  489. package/lib/agents/thread-compaction.test.ts +83 -4
  490. package/lib/agents/thread-compaction.ts +34 -11
  491. package/lib/agents/warm-summary-background.test.ts +219 -5
  492. package/lib/agents/warm-summary-background.ts +346 -143
  493. package/lib/agents/warm-topics.test.ts +191 -0
  494. package/lib/agents/warm-topics.ts +317 -0
  495. package/lib/agents/workflow-step-retry.test.ts +96 -0
  496. package/lib/agents/workflow-step-retry.ts +216 -0
  497. package/lib/api/browser-control.ts +0 -3
  498. package/lib/bridges/dispatcher.ts +1 -0
  499. package/lib/bridges/message-role.test.ts +81 -0
  500. package/lib/bridges/message-role.ts +23 -10
  501. package/lib/bridges/types.ts +6 -0
  502. package/lib/bridges/whatsapp-link.test.ts +32 -0
  503. package/lib/bridges/whatsapp-link.ts +21 -0
  504. package/lib/bridges/whatsapp.inbound.test.ts +239 -0
  505. package/lib/bridges/whatsapp.sender.test.ts +80 -1
  506. package/lib/bridges/whatsapp.ts +76 -38
  507. package/lib/db/migrations.ts +5 -0
  508. package/lib/env/config.ts +2 -0
  509. package/lib/env/schema.ts +12 -0
  510. package/lib/lifecycle/changeset-build.test.ts +93 -0
  511. package/lib/lifecycle/changeset-build.ts +210 -0
  512. package/lib/lifecycle/changesets.test.ts +101 -0
  513. package/lib/lifecycle/changesets.ts +166 -0
  514. package/lib/lifecycle/surface-collect.test.ts +88 -0
  515. package/lib/lifecycle/surface-collect.ts +64 -0
  516. package/lib/lifecycle/surface-snapshot.test.ts +104 -0
  517. package/lib/lifecycle/surface-snapshot.ts +210 -0
  518. package/lib/memory/record.ts +0 -2
  519. package/lib/pricing/snapshot.test.ts +70 -0
  520. package/lib/pricing/snapshot.ts +10 -2
  521. package/lib/providers/external.ts +0 -2
  522. package/lib/proxy/dispatcher.test.ts +119 -1
  523. package/lib/proxy/dispatcher.ts +22 -9
  524. package/lib/skills/builtins/memory-organization/SKILL.md +16 -0
  525. package/lib/stores/agent-configs.ts +10 -5
  526. package/lib/stores/bridges.test.ts +81 -0
  527. package/lib/stores/bridges.ts +9 -8
  528. package/lib/stores/proxy-config.test.ts +120 -0
  529. package/lib/stores/proxy-config.ts +22 -4
  530. package/lib/stores/threads.test.ts +9 -0
  531. package/lib/stores/threads.ts +33 -19
  532. package/lib/stores/version-adoption.test.ts +96 -0
  533. package/lib/stores/version-adoption.ts +239 -26
  534. package/lib/stores/workflow-progress.ts +3 -0
  535. package/lib/tools/communications/calendar.test.ts +43 -2
  536. package/lib/tools/communications/calendar.ts +2 -0
  537. package/lib/tools/communications/gmail.test.ts +51 -1
  538. package/lib/tools/communications/gmail.ts +44 -2
  539. package/lib/tools/communications/ms-todo.ts +0 -7
  540. package/lib/tools/communications/outlook-calendar.ts +2 -0
  541. package/lib/tools/communications/outlook.test.ts +33 -2
  542. package/lib/tools/communications/outlook.ts +2 -0
  543. package/lib/tools/filesystem/edit-match.test.ts +133 -0
  544. package/lib/tools/filesystem/edit-match.ts +7 -2
  545. package/lib/tools/general/memory.ts +1 -1
  546. package/lib/tools/general/workflow-progress.ts +2 -0
  547. package/lib/tools/runtime/catalog.ts +1 -25
  548. package/lib/tools/support/result-refs.test.ts +131 -0
  549. package/lib/tools/support/result-refs.ts +41 -9
  550. package/lib/triggers/registry.ts +0 -4
  551. package/lib/utils/source-link.test.ts +51 -0
  552. package/lib/utils/source-link.ts +45 -0
  553. package/package.json +3 -3
  554. package/scripts/install-to-system.ps1 +39 -11
  555. package/scripts/install-to-system.sh +37 -3
  556. package/.next/standalone/.next/server/chunks/3979.js +0 -581
  557. package/.next/standalone/.next/server/chunks/5936.js +0 -594
  558. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-36cb8b428b38b26a.js +0 -17
  559. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-36cb8b428b38b26a.js +0 -17
  560. package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-36cb8b428b38b26a.js +0 -17
  561. package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-36cb8b428b38b26a.js +0 -17
  562. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-36cb8b428b38b26a.js +0 -17
  563. package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-36cb8b428b38b26a.js +0 -17
  564. package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-36cb8b428b38b26a.js +0 -17
  565. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-36cb8b428b38b26a.js +0 -17
  566. package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-36cb8b428b38b26a.js +0 -17
  567. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-36cb8b428b38b26a.js +0 -17
  568. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-36cb8b428b38b26a.js +0 -17
  569. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-36cb8b428b38b26a.js +0 -17
  570. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-36cb8b428b38b26a.js +0 -17
  571. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-36cb8b428b38b26a.js +0 -17
  572. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-36cb8b428b38b26a.js +0 -17
  573. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-36cb8b428b38b26a.js +0 -17
  574. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-36cb8b428b38b26a.js +0 -17
  575. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-36cb8b428b38b26a.js +0 -17
  576. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-36cb8b428b38b26a.js +0 -17
  577. package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-36cb8b428b38b26a.js +0 -17
  578. package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-36cb8b428b38b26a.js +0 -17
  579. package/.next/standalone/.next/static/chunks/app/api/v1/config/route-36cb8b428b38b26a.js +0 -17
  580. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-36cb8b428b38b26a.js +0 -17
  581. package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-36cb8b428b38b26a.js +0 -17
  582. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-36cb8b428b38b26a.js +0 -17
  583. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-36cb8b428b38b26a.js +0 -17
  584. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-36cb8b428b38b26a.js +0 -17
  585. package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-36cb8b428b38b26a.js +0 -17
  586. package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-36cb8b428b38b26a.js +0 -17
  587. package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-36cb8b428b38b26a.js +0 -17
  588. package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-36cb8b428b38b26a.js +0 -17
  589. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-36cb8b428b38b26a.js +0 -17
  590. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-36cb8b428b38b26a.js +0 -17
  591. package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-36cb8b428b38b26a.js +0 -17
  592. package/.next/standalone/.next/static/chunks/app/api/v1/env/route-36cb8b428b38b26a.js +0 -17
  593. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-36cb8b428b38b26a.js +0 -17
  594. package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-36cb8b428b38b26a.js +0 -17
  595. package/.next/standalone/.next/static/chunks/app/api/v1/events/route-36cb8b428b38b26a.js +0 -17
  596. package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-36cb8b428b38b26a.js +0 -17
  597. package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-36cb8b428b38b26a.js +0 -17
  598. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-36cb8b428b38b26a.js +0 -17
  599. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-36cb8b428b38b26a.js +0 -17
  600. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-36cb8b428b38b26a.js +0 -17
  601. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-36cb8b428b38b26a.js +0 -17
  602. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-36cb8b428b38b26a.js +0 -17
  603. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-36cb8b428b38b26a.js +0 -17
  604. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-36cb8b428b38b26a.js +0 -17
  605. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-36cb8b428b38b26a.js +0 -17
  606. package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-36cb8b428b38b26a.js +0 -17
  607. package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-36cb8b428b38b26a.js +0 -17
  608. package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-36cb8b428b38b26a.js +0 -17
  609. package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-36cb8b428b38b26a.js +0 -17
  610. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-36cb8b428b38b26a.js +0 -17
  611. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-36cb8b428b38b26a.js +0 -17
  612. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-36cb8b428b38b26a.js +0 -17
  613. package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-36cb8b428b38b26a.js +0 -17
  614. package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-36cb8b428b38b26a.js +0 -17
  615. package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-36cb8b428b38b26a.js +0 -17
  616. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-36cb8b428b38b26a.js +0 -17
  617. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-36cb8b428b38b26a.js +0 -17
  618. package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-36cb8b428b38b26a.js +0 -17
  619. package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-36cb8b428b38b26a.js +0 -17
  620. package/.next/standalone/.next/static/chunks/app/api/v1/health/route-36cb8b428b38b26a.js +0 -17
  621. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-36cb8b428b38b26a.js +0 -17
  622. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-36cb8b428b38b26a.js +0 -17
  623. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-36cb8b428b38b26a.js +0 -17
  624. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-36cb8b428b38b26a.js +0 -17
  625. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-36cb8b428b38b26a.js +0 -17
  626. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-36cb8b428b38b26a.js +0 -17
  627. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-36cb8b428b38b26a.js +0 -17
  628. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-36cb8b428b38b26a.js +0 -17
  629. package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-36cb8b428b38b26a.js +0 -17
  630. package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-36cb8b428b38b26a.js +0 -17
  631. package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-36cb8b428b38b26a.js +0 -17
  632. package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-36cb8b428b38b26a.js +0 -17
  633. package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-36cb8b428b38b26a.js +0 -17
  634. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-36cb8b428b38b26a.js +0 -17
  635. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-36cb8b428b38b26a.js +0 -17
  636. package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-36cb8b428b38b26a.js +0 -17
  637. package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-36cb8b428b38b26a.js +0 -17
  638. package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-36cb8b428b38b26a.js +0 -17
  639. package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-36cb8b428b38b26a.js +0 -17
  640. package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-36cb8b428b38b26a.js +0 -17
  641. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-36cb8b428b38b26a.js +0 -17
  642. package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-36cb8b428b38b26a.js +0 -17
  643. package/.next/standalone/.next/static/chunks/app/api/v1/models/route-36cb8b428b38b26a.js +0 -17
  644. package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-36cb8b428b38b26a.js +0 -17
  645. package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-36cb8b428b38b26a.js +0 -17
  646. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-36cb8b428b38b26a.js +0 -17
  647. package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-36cb8b428b38b26a.js +0 -17
  648. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-36cb8b428b38b26a.js +0 -17
  649. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-36cb8b428b38b26a.js +0 -17
  650. package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-36cb8b428b38b26a.js +0 -17
  651. package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-36cb8b428b38b26a.js +0 -17
  652. package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-36cb8b428b38b26a.js +0 -17
  653. package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-36cb8b428b38b26a.js +0 -17
  654. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-36cb8b428b38b26a.js +0 -17
  655. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-36cb8b428b38b26a.js +0 -17
  656. package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-36cb8b428b38b26a.js +0 -17
  657. package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-36cb8b428b38b26a.js +0 -17
  658. package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-36cb8b428b38b26a.js +0 -17
  659. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-36cb8b428b38b26a.js +0 -17
  660. package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-36cb8b428b38b26a.js +0 -17
  661. package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-36cb8b428b38b26a.js +0 -17
  662. package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-36cb8b428b38b26a.js +0 -17
  663. package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-36cb8b428b38b26a.js +0 -17
  664. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-36cb8b428b38b26a.js +0 -17
  665. package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-36cb8b428b38b26a.js +0 -17
  666. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-36cb8b428b38b26a.js +0 -17
  667. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-36cb8b428b38b26a.js +0 -17
  668. package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-36cb8b428b38b26a.js +0 -17
  669. package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-36cb8b428b38b26a.js +0 -17
  670. package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-36cb8b428b38b26a.js +0 -17
  671. package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-36cb8b428b38b26a.js +0 -17
  672. package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-36cb8b428b38b26a.js +0 -17
  673. package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-36cb8b428b38b26a.js +0 -17
  674. package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-36cb8b428b38b26a.js +0 -17
  675. package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-36cb8b428b38b26a.js +0 -17
  676. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-36cb8b428b38b26a.js +0 -17
  677. package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-36cb8b428b38b26a.js +0 -17
  678. package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-36cb8b428b38b26a.js +0 -17
  679. package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-36cb8b428b38b26a.js +0 -17
  680. package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-36cb8b428b38b26a.js +0 -17
  681. package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-36cb8b428b38b26a.js +0 -17
  682. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-36cb8b428b38b26a.js +0 -17
  683. package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-36cb8b428b38b26a.js +0 -17
  684. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-36cb8b428b38b26a.js +0 -17
  685. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-36cb8b428b38b26a.js +0 -17
  686. package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-36cb8b428b38b26a.js +0 -17
  687. package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-36cb8b428b38b26a.js +0 -17
  688. package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-36cb8b428b38b26a.js +0 -17
  689. package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-36cb8b428b38b26a.js +0 -17
  690. package/.next/standalone/.next/static/chunks/app/api/v1/update/route-36cb8b428b38b26a.js +0 -17
  691. package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-36cb8b428b38b26a.js +0 -17
  692. package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-36cb8b428b38b26a.js +0 -17
  693. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-36cb8b428b38b26a.js +0 -17
  694. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-36cb8b428b38b26a.js +0 -17
  695. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-36cb8b428b38b26a.js +0 -17
  696. package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-36cb8b428b38b26a.js +0 -17
  697. package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-36cb8b428b38b26a.js +0 -17
  698. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-36cb8b428b38b26a.js +0 -17
  699. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-36cb8b428b38b26a.js +0 -17
  700. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-36cb8b428b38b26a.js +0 -17
  701. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-36cb8b428b38b26a.js +0 -17
  702. /package/.next/standalone/.next/static/{NUrC9xax1sp1Q70nlFqS6 → hwujW4hR1b-r3k5WdMxZO}/_buildManifest.js +0 -0
  703. /package/.next/standalone/.next/static/{NUrC9xax1sp1Q70nlFqS6 → hwujW4hR1b-r3k5WdMxZO}/_ssgManifest.js +0 -0
@@ -172,1201 +172,1217 @@ module.exports = require("next/dist/server/app-render/action-async-storage.exter
172
172
 
173
173
  /***/ }),
174
174
 
175
- /***/ 27910:
176
- /***/ ((module) => {
177
-
178
- module.exports = require("stream");
179
-
180
- /***/ }),
181
-
182
- /***/ 28354:
183
- /***/ ((module) => {
184
-
185
- module.exports = require("util");
186
-
187
- /***/ }),
188
-
189
- /***/ 29021:
190
- /***/ ((module) => {
191
-
192
- module.exports = require("fs");
175
+ /***/ 19517:
176
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
193
177
 
194
- /***/ }),
178
+ __webpack_require__.r(__webpack_exports__);
179
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
180
+ /* harmony export */ handler: () => (/* binding */ handler),
181
+ /* harmony export */ patchFetch: () => (/* binding */ patchFetch),
182
+ /* harmony export */ routeModule: () => (/* binding */ routeModule),
183
+ /* harmony export */ serverHooks: () => (/* binding */ serverHooks),
184
+ /* harmony export */ workAsyncStorage: () => (/* binding */ workAsyncStorage),
185
+ /* harmony export */ workUnitAsyncStorage: () => (/* binding */ workUnitAsyncStorage)
186
+ /* harmony export */ });
187
+ /* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19225);
188
+ /* 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__);
189
+ /* harmony import */ var next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(84006);
190
+ /* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8317);
191
+ /* 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__);
192
+ /* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(99373);
193
+ /* 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__);
194
+ /* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34775);
195
+ /* 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__);
196
+ /* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(24235);
197
+ /* 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__);
198
+ /* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(261);
199
+ /* 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__);
200
+ /* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(54365);
201
+ /* 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__);
202
+ /* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(90771);
203
+ /* 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__);
204
+ /* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(73461);
205
+ /* 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__);
206
+ /* harmony import */ var next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(67798);
207
+ /* harmony import */ var next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(92280);
208
+ /* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(62018);
209
+ /* 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__);
210
+ /* harmony import */ var next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(45696);
211
+ /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(47929);
212
+ /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__);
213
+ /* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(86439);
214
+ /* 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__);
215
+ /* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(10246);
216
+ /* 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__);
217
+ /* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(37527);
218
+ /* 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__);
195
219
 
196
- /***/ 29294:
197
- /***/ ((module) => {
198
220
 
199
- module.exports = require("next/dist/server/app-render/work-async-storage.external.js");
200
221
 
201
- /***/ }),
202
222
 
203
- /***/ 31421:
204
- /***/ ((module) => {
205
223
 
206
- module.exports = require("node:child_process");
207
224
 
208
- /***/ }),
209
225
 
210
- /***/ 33873:
211
- /***/ ((module) => {
212
226
 
213
- module.exports = require("path");
214
227
 
215
- /***/ }),
216
228
 
217
- /***/ 37067:
218
- /***/ ((module) => {
219
229
 
220
- module.exports = require("node:http");
221
230
 
222
- /***/ }),
223
231
 
224
- /***/ 38522:
225
- /***/ ((module) => {
226
232
 
227
- module.exports = require("node:zlib");
228
233
 
229
- /***/ }),
230
234
 
231
- /***/ 39947:
232
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
233
235
 
234
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
235
- /* harmony export */ Bm: () => (/* binding */ cachedJson),
236
- /* harmony export */ HN: () => (/* binding */ notFoundResponse),
237
- /* harmony export */ Jb: () => (/* binding */ validateBody),
238
- /* harmony export */ K2: () => (/* binding */ createdResponse),
239
- /* harmony export */ Ng: () => (/* binding */ noStoreJson),
240
- /* harmony export */ yj: () => (/* binding */ errorResponse)
241
- /* harmony export */ });
242
- /* harmony import */ var next_server__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(23211);
243
- // Shared HTTP response builders for app/api/v1/** route handlers.
244
- //
245
- // Goal: every error/success payload across the v1 surface has the same
246
- // shape. Before this lived inline, response bodies drifted —
247
- // `{error: "x"}` vs `{message: "x"}`, 400 vs 422 for the same condition,
248
- // some routes returned Zod's raw issue array, others stringified it.
249
236
 
250
- function errorResponse(message, status = 400) {
251
- return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
252
- error: message
253
- }, {
254
- status
237
+ // We inject the nextConfigOutput here so that we can use them in the route
238
+ // module.
239
+ const nextConfigOutput = "standalone"
240
+ const routeModule = new next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__.AppRouteRouteModule({
241
+ definition: {
242
+ kind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
243
+ page: "/api/v1/bridges/[id]/routes/route",
244
+ pathname: "/api/v1/bridges/[id]/routes",
245
+ filename: "route",
246
+ bundlePath: "app/api/v1/bridges/[id]/routes/route"
247
+ },
248
+ distDir: ".next" || 0,
249
+ relativeProjectDir: false || '',
250
+ resolvedPagePath: "/home/runner/work/jarela/jarela/app/api/v1/bridges/[id]/routes/route.ts",
251
+ nextConfigOutput,
252
+ // The lazy require factory ensures that:
253
+ // - In dev: devRequestTimingInternalsEnd is set before userland executes,
254
+ // correctly attributing module load time to application-code rather than
255
+ // framework internals.
256
+ // - In all modes: async modules (route files with top-level await) are
257
+ // handled correctly — require() returns a Promise for such modules, which
258
+ // ensureUserland() awaits before the first request is handled.
259
+ userland: ()=>__webpack_require__(440),
260
+ // In Turbopack dev mode, also provide a synchronous per-request getter so
261
+ // server HMR updates are picked up without re-executing the entry chunk.
262
+ // Using require() (synchronous) avoids adding async overhead that would be
263
+ // incorrectly attributed to application-code time in devRequestTiming.
264
+ ... false ? 0 : {}
265
+ });
266
+ // Pull out the exports that we need to expose from the module. This should
267
+ // be eliminated when we've moved the other routes to the new format. These
268
+ // are used to hook into the route.
269
+ const { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;
270
+ function patchFetch() {
271
+ return (0,next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__.patchFetch)({
272
+ workAsyncStorage,
273
+ workUnitAsyncStorage
255
274
  });
256
275
  }
257
- function notFoundResponse(message = "Not found") {
258
- return errorResponse(message, 404);
259
- }
260
- function createdResponse(data) {
261
- return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json(data, {
262
- status: 201
276
+
277
+ async function handler(req, res, ctx) {
278
+ if (ctx.requestMeta) {
279
+ (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.setRequestMeta)(req, ctx.requestMeta);
280
+ }
281
+ if (routeModule.isDev) {
282
+ (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.addRequestMeta)(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());
283
+ }
284
+ let srcPage = "/api/v1/bridges/[id]/routes/route";
285
+ // turbopack doesn't normalize `/index` in the page name
286
+ // so we need to to process dynamic routes properly
287
+ // TODO: fix turbopack providing differing value from webpack
288
+ if (false) {} else if (srcPage === '/index') {
289
+ // we always normalize /index specifically
290
+ srcPage = '/';
291
+ }
292
+ const multiZoneDraftMode = false;
293
+ const prepareResult = await routeModule.prepare(req, res, {
294
+ srcPage,
295
+ multiZoneDraftMode
263
296
  });
264
- }
265
- // Wrap a 200 JSON response with a private Cache-Control header. Use on safe
266
- // GET endpoints that serve user-scoped data the client refetches often (panel
267
- // mounts, navigation back/forward) but mutates rarely. The TTL is short
268
- // enough that explicit mutations — which patch the client-side ApiClient
269
- // cache in place — stay observably consistent without an extra roundtrip.
270
- //
271
- // swrSeconds (optional): stale-while-revalidate window. When set, the browser
272
- // serves the cached response immediately and refreshes in the background,
273
- // making navigation feel instant. Use for data that can tolerate brief
274
- // staleness (tool list, agent configs, model list). Omit for real-time data
275
- // (dashboard metrics, credential state).
276
- function cachedJson(data, maxAgeSeconds, swrSeconds) {
277
- const swr = swrSeconds ? `, stale-while-revalidate=${swrSeconds}` : "";
278
- return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json(data, {
279
- headers: {
280
- "Cache-Control": `private, max-age=${maxAgeSeconds}${swr}`
297
+ if (!prepareResult) {
298
+ res.statusCode = 400;
299
+ res.end('Bad Request');
300
+ ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
301
+ return null;
302
+ }
303
+ const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest, previewProps } = prepareResult;
304
+ const normalizedSrcPage = (0,next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__.normalizeAppPath)(srcPage);
305
+ // Only this route's prerenders can establish ISR or admit generated params.
306
+ 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]));
307
+ let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || isPrerendered);
308
+ const render404 = async ()=>{
309
+ // TODO: should route-module itself handle rendering the 404
310
+ if (routerServerContext == null ? void 0 : routerServerContext.render404) {
311
+ await routerServerContext.render404(req, res, parsedUrl, false);
312
+ } else {
313
+ res.end('This page could not be found');
281
314
  }
282
- });
283
- }
284
- // Use for endpoints whose response contains live state that must never be
285
- // served from cache — credentials, connection status, live config values.
286
- function noStoreJson(data) {
287
- return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json(data, {
288
- headers: {
289
- "Cache-Control": "no-store"
315
+ return null;
316
+ };
317
+ if (isIsr && !isDraftMode) {
318
+ const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];
319
+ if (prerenderInfo) {
320
+ if (prerenderInfo.fallback === false && !isPrerendered) {
321
+ if (nextConfig.adapterPath) {
322
+ return await render404();
323
+ }
324
+ throw new next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError();
325
+ }
290
326
  }
291
- });
292
- }
293
- // Validate a JSON request body against a zod schema.
294
- // Returns either the parsed data or a 400 NextResponse explaining the issue.
295
- // Caller pattern:
296
- // const parsed = await validateBody(req, Schema);
297
- // if (parsed instanceof NextResponse) return parsed;
298
- // // use parsed.field
299
- async function validateBody(req, schema) {
300
- let raw;
301
- try {
302
- raw = await req.json();
303
- } catch {
304
- return errorResponse("Request body must be valid JSON", 400);
305
327
  }
306
- const parsed = schema.safeParse(raw);
307
- if (!parsed.success) {
308
- return errorResponse(parsed.error.issues[0]?.message ?? "invalid body", 400);
328
+ let cacheKey = null;
329
+ if (isIsr && !routeModule.isDev && !isDraftMode) {
330
+ cacheKey = resolvedPathname;
331
+ // ensure /index and / is normalized to one key
332
+ cacheKey = cacheKey === '/index' ? '/' : cacheKey;
309
333
  }
310
- return parsed.data;
311
- }
312
-
313
-
314
- /***/ }),
315
-
316
- /***/ 41720:
317
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
318
-
319
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
320
- /* harmony export */ BM: () => (/* binding */ upsertAgentConfig),
321
- /* harmony export */ E1: () => (/* binding */ updateAgentDisplayFilters),
322
- /* harmony export */ P2: () => (/* binding */ parseCitationStrictness),
323
- /* harmony export */ S2: () => (/* binding */ getAgentToolCredentials),
324
- /* harmony export */ SJ: () => (/* binding */ generateAgentId),
325
- /* harmony export */ TG: () => (/* binding */ getAgentTools),
326
- /* harmony export */ bg: () => (/* binding */ parseDelegateTargets),
327
- /* harmony export */ d2: () => (/* binding */ DISPLAY_FILTER_KEYS),
328
- /* harmony export */ fg: () => (/* binding */ getAgentTierProportions),
329
- /* harmony export */ mJ: () => (/* binding */ getAgentConfig),
330
- /* harmony export */ nV: () => (/* binding */ getAgentDisplayFilters),
331
- /* harmony export */ vU: () => (/* binding */ getDefaultAgentConfig),
332
- /* harmony export */ vi: () => (/* binding */ DISPLAY_FILTER_DEFAULTS),
333
- /* harmony export */ xi: () => (/* binding */ deleteAgentConfig),
334
- /* harmony export */ zb: () => (/* binding */ listAgentConfigs)
335
- /* harmony export */ });
336
- /* harmony import */ var _lib_db__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(46);
337
- /* harmony import */ var _lib_db_transaction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99043);
338
- /* harmony import */ var _lib_agents_adaptive_persona_presets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(66849);
339
-
340
-
341
-
342
- const now = ()=>new Date().toISOString();
343
- /** Coerce arbitrary input (DB row TEXT, API body, undefined) to the enum.
344
- * Returns `null` for null/undefined/unknown values so callers can default. */ function parseCitationStrictness(value) {
345
- if (value === "off" || value === "informational" || value === "standard" || value === "strict") {
346
- return value;
347
- }
348
- return null;
349
- }
350
- /**
351
- * Parse the JSON-encoded per-agent override of context tier proportions.
352
- * Returns `null` for NULL, blank, malformed JSON, or any payload that
353
- * doesn't have three finite non-negative numeric fields. Callers fall
354
- * back to the model config's value (or built-in defaults) on null.
355
- */ function getAgentTierProportions(row) {
356
- const raw = row.context_tier_proportions;
357
- if (!raw) return null;
358
- try {
359
- const parsed = JSON.parse(raw);
360
- const hot = Number(parsed.hot);
361
- const warm = Number(parsed.warm);
362
- const facts = Number(parsed.facts);
363
- if (![
364
- hot,
365
- warm,
366
- facts
367
- ].every((n)=>Number.isFinite(n) && n >= 0)) return null;
368
- if (hot + warm + facts <= 0) return null;
369
- return {
370
- hot,
371
- warm,
372
- facts
373
- };
374
- } catch {
375
- return null;
376
- }
377
- }
378
- function listAgentConfigs() {
379
- // Default agent always first; then by the timestamp of each agent's latest message.
380
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare(`SELECT a.*
381
- FROM agent_configs a
382
- LEFT JOIN (
383
- SELECT t.agent_id, MAX(m.created_at) AS last_message_at
384
- FROM threads t
385
- JOIN messages m ON m.thread_id = t.thread_id
386
- GROUP BY t.agent_id
387
- ) latest ON latest.agent_id = a.id
388
- ORDER BY a.is_default DESC, COALESCE(latest.last_message_at, a.created_at) DESC, a.id ASC`).all();
389
- }
390
- function getDefaultAgentConfig() {
391
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("SELECT * FROM agent_configs WHERE is_default=1 LIMIT 1").get() ?? null;
392
- }
393
- function getAgentConfig(id) {
394
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("SELECT * FROM agent_configs WHERE id=?").get(id) ?? null;
395
- }
396
- /**
397
- * Parse the JSON-encoded delegate whitelist into a deduped string[]. Returns
398
- * an empty array for NULL, blank, or malformed JSON (delegation is opt-in).
399
- */ /**
400
- * Parse the agent's tool allowlist (`tools` column, stored as a JSON string).
401
- * Returns an empty array on NULL/blank/malformed JSON — same defensive shape
402
- * as parseDelegateTargets. Callers that previously did `JSON.parse(cfg.tools)`
403
- * inline should switch to this getter so the serialization contract stays
404
- * owned by this store.
405
- */ function getAgentTools(cfg) {
406
- if (!cfg?.tools) return [];
407
- try {
408
- const parsed = JSON.parse(cfg.tools);
409
- if (!Array.isArray(parsed)) return [];
410
- return parsed.filter((x)=>typeof x === "string" && x.length > 0);
411
- } catch {
412
- return [];
413
- }
414
- }
415
- function parseDelegateTargets(raw) {
416
- if (!raw) return [];
417
- try {
418
- const parsed = JSON.parse(raw);
419
- if (!Array.isArray(parsed)) return [];
420
- const ids = parsed.filter((x)=>typeof x === "string" && x.length > 0);
421
- return Array.from(new Set(ids));
422
- } catch {
423
- return [];
334
+ // Before rendering (which initializes component tree modules), we have to
335
+ // set the reference manifests to our global store so Server Action's
336
+ // encryption util can access to them at the top level of the page module.
337
+ if (serverActionsManifest && clientReferenceManifest) {
338
+ (0,next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__.setManifestsSingleton)({
339
+ page: srcPage,
340
+ clientReferenceManifest,
341
+ serverActionsManifest
342
+ });
424
343
  }
425
- }
426
- /**
427
- * Parse the per-agent `{ toolName: credentialId }` override map stored in
428
- * the `tool_credentials` column. Returns an empty record on NULL / blank /
429
- * malformed JSON / non-string entries so downstream code can treat the
430
- * result as a plain lookup without further validation.
431
- */ function getAgentToolCredentials(cfg) {
432
- if (!cfg?.tool_credentials) return {};
433
- try {
434
- const parsed = JSON.parse(cfg.tool_credentials);
435
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
436
- const out = {};
437
- for (const [k, v] of Object.entries(parsed)){
438
- if (typeof v === "string" && v.length > 0) out[k] = v;
344
+ const method = req.method || 'GET';
345
+ const tracer = (0,next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.getTracer)();
346
+ const activeSpan = tracer.getActiveScopeSpan();
347
+ const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);
348
+ const isMinimalMode = Boolean((0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'minimalMode'));
349
+ const incrementalCache = (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, previewProps, prerenderManifest, isMinimalMode);
350
+ incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();
351
+ globalThis.__incrementalCache = incrementalCache;
352
+ const context = {
353
+ params,
354
+ previewProps,
355
+ renderOpts: {
356
+ experimental: {
357
+ authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
358
+ useCacheTimeout: nextConfig.experimental.useCacheTimeout,
359
+ durableUseCacheEntries: Boolean(nextConfig.experimental.durableUseCacheEntries)
360
+ },
361
+ cacheComponents: Boolean(nextConfig.cacheComponents),
362
+ validationLevel: nextConfig.experimental.instantInsights.validationLevel,
363
+ isDraftMode,
364
+ incrementalCache,
365
+ hmrRefreshHash: (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'hmrRefreshHash'),
366
+ cacheLifeProfiles: nextConfig.cacheLife,
367
+ staticPageGenerationTimeout: nextConfig.staticPageGenerationTimeout,
368
+ waitUntil: ctx.waitUntil,
369
+ onClose: (cb)=>{
370
+ res.on('close', cb);
371
+ },
372
+ onAfterTaskError: undefined
373
+ },
374
+ sharedContext: {
375
+ buildId,
376
+ deploymentId
439
377
  }
440
- return out;
441
- } catch {
442
- return {};
443
- }
444
- }
445
- function upsertAgentConfig(input) {
446
- return (0,_lib_db_transaction__WEBPACK_IMPORTED_MODULE_1__/* .withDbTransaction */ .J)(()=>upsertAgentConfigTransaction(input));
447
- }
448
- function upsertAgentConfigTransaction(input) {
449
- const t = now();
450
- const db = (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)();
451
- const existing = getAgentConfig(input.id);
452
- const created_at = existing?.created_at ?? t;
453
- const mbti = input.adaptive_mbti ?? toMbti(existing?.adaptive_mbti) ?? "INTJ";
454
- const preset = _lib_agents_adaptive_persona_presets__WEBPACK_IMPORTED_MODULE_2__/* .MBTI_PRESETS */ .e[mbti];
455
- const strength = input.adaptive_persona_strength ?? preset.strength;
456
- const empathy = input.adaptive_empathy ?? preset.empathy;
457
- const expressiveness = input.adaptive_expressiveness ?? preset.expressiveness;
458
- const verbosity = input.adaptive_verbosity ?? preset.verbosity;
459
- if (input.is_default) db.prepare("UPDATE agent_configs SET is_default=0").run();
460
- // harness_id: explicit `undefined` means "keep existing"; explicit `null`
461
- // means "use the global default". Empty string is normalised to null too,
462
- // matching how the AgentEditor sends "" for the inherit option.
463
- const harnessId = input.harness_id === undefined ? existing?.harness_id ?? null : input.harness_id && input.harness_id.length > 0 ? input.harness_id : null;
464
- // delegate_targets: undefined = keep existing; explicit empty array clears.
465
- const delegateTargets = input.delegate_targets === undefined ? existing?.delegate_targets ?? null : JSON.stringify(Array.from(new Set(input.delegate_targets.filter((id)=>id && id !== input.id))));
466
- // context_tier_proportions: undefined = keep existing; null = clear and
467
- // inherit from the model; object = serialise as JSON. Negative values are
468
- // clamped to 0 so the upsert can't poison the column with bad data.
469
- const tierProportions = input.context_tier_proportions === undefined ? existing?.context_tier_proportions ?? null : input.context_tier_proportions === null ? null : JSON.stringify({
470
- hot: Math.max(0, Number(input.context_tier_proportions.hot) || 0),
471
- warm: Math.max(0, Number(input.context_tier_proportions.warm) || 0),
472
- facts: Math.max(0, Number(input.context_tier_proportions.facts) || 0)
473
- });
474
- // Anti-hallucination override: `undefined` keeps existing; `null` clears
475
- // the override (inherits env). Empty-string model is normalised to null
476
- // so the editor can ship "" for the inherit option.
477
- const antiHallucMode = input.anti_hallucination_mode === undefined ? existing?.anti_hallucination_mode ?? null : input.anti_hallucination_mode === null ? null : input.anti_hallucination_mode === "off" || input.anti_hallucination_mode === "regex" || input.anti_hallucination_mode === "model" ? input.anti_hallucination_mode : null;
478
- const antiHallucModel = input.anti_hallucination_model_config === undefined ? existing?.anti_hallucination_model_config ?? null : input.anti_hallucination_model_config && input.anti_hallucination_model_config.trim().length > 0 ? input.anti_hallucination_model_config.trim() : null;
479
- const citationStrictness = input.citation_strictness === undefined ? parseCitationStrictness(existing?.citation_strictness) ?? "off" : parseCitationStrictness(input.citation_strictness) ?? "off";
480
- const toolCredentials = serialiseToolCredentials(input.tool_credentials, existing?.tool_credentials ?? null);
481
- const VALID_ROUTER_POLICIES = new Set([
482
- "cheap",
483
- "fast",
484
- "balanced",
485
- "quality"
486
- ]);
487
- const routerPolicy = input.router_policy === undefined ? existing?.router_policy ?? null : input.router_policy !== null && VALID_ROUTER_POLICIES.has(input.router_policy) ? input.router_policy : null;
488
- const routerEnabled = input.router_enabled === undefined ? existing?.router_enabled ?? null : input.router_enabled === null ? null : input.router_enabled ? 1 : 0;
489
- const VALID_USAGE_STRATEGIES = new Set([
490
- "cost_saving",
491
- "fast",
492
- "balanced",
493
- "high_reasoning"
494
- ]);
495
- const usageStrategy = input.usage_strategy === undefined ? existing?.usage_strategy ?? null : input.usage_strategy !== null && VALID_USAGE_STRATEGIES.has(input.usage_strategy) ? input.usage_strategy : null;
496
- const requestedWarmSummaryLimit = input.warm_summary_limit ?? existing?.warm_summary_limit ?? 50;
497
- const warmSummaryLimit = Number.isFinite(requestedWarmSummaryLimit) ? Math.max(0, Math.floor(requestedWarmSummaryLimit)) : existing?.warm_summary_limit ?? 50;
498
- db.prepare(`INSERT OR REPLACE INTO agent_configs
499
- (id, name, icon, identity, instructions, tools, model_config_name, is_default,
500
- history_limit, history_window_hours, warm_summary_limit, never_reply,
501
- hot_turn_limit,
502
- adaptive_persona_enabled, adaptive_persona_strength, adaptive_empathy, adaptive_expressiveness, adaptive_verbosity, adaptive_mbti,
503
- voice_enabled, voice_model, voice_name, voice_stt_model, voice_auto_speak,
504
- harness_id, delegate_targets, context_tier_proportions,
505
- anti_hallucination_mode, anti_hallucination_model_config, citation_strictness,
506
- tool_credentials, router_policy, router_enabled, usage_strategy,
507
- created_at, updated_at)
508
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.id, input.name, input.icon ?? null, input.identity, input.instructions, JSON.stringify(input.tools), input.model_config_name ?? null, input.is_default ? 1 : existing?.is_default ?? 0, input.history_limit ?? existing?.history_limit ?? 50, input.history_window_hours ?? existing?.history_window_hours ?? 8, warmSummaryLimit, // never_reply is a boolean toggle — explicit `undefined` means "keep existing"
509
- // (important for PATCH-style updates that omit the field).
510
- input.never_reply === undefined ? existing?.never_reply ?? 0 : input.never_reply ? 1 : 0, Math.max(0, Math.floor(input.hot_turn_limit ?? existing?.hot_turn_limit ?? 12)), input.adaptive_persona_enabled === undefined ? existing?.adaptive_persona_enabled ?? 0 : input.adaptive_persona_enabled ? 1 : 0, clampPercent(strength, existing?.adaptive_persona_strength ?? 50), clampPercent(empathy, existing?.adaptive_empathy ?? 50), clampPercent(expressiveness, existing?.adaptive_expressiveness ?? 50), clampPercent(verbosity, existing?.adaptive_verbosity ?? 50), mbti, input.voice_enabled === undefined ? existing?.voice_enabled ?? 0 : input.voice_enabled ? 1 : 0, (input.voice_model ?? existing?.voice_model ?? "gemini-2.5-flash-preview-tts").trim() || "gemini-2.5-flash-preview-tts", (input.voice_name ?? existing?.voice_name ?? "Kore").trim() || "Kore", (input.voice_stt_model ?? existing?.voice_stt_model ?? "gemini-2.5-flash").trim() || "gemini-2.5-flash", input.voice_auto_speak === undefined ? existing?.voice_auto_speak ?? 1 : input.voice_auto_speak ? 1 : 0, harnessId, delegateTargets, tierProportions, antiHallucMode, antiHallucModel, citationStrictness, toolCredentials, routerPolicy, routerEnabled, usageStrategy, created_at, t);
511
- return getAgentConfig(input.id);
512
- }
513
- function clampPercent(next, fallback) {
514
- const n = Number.isFinite(next) ? Number(next) : fallback;
515
- return Math.max(0, Math.min(100, Math.round(n)));
516
- }
517
- function serialiseToolCredentials(input, existing) {
518
- if (input === undefined) return existing;
519
- const cleaned = {};
520
- for (const [k, v] of Object.entries(input)){
521
- if (typeof k === "string" && k.length > 0 && typeof v === "string" && v.length > 0) {
522
- cleaned[k] = v;
378
+ };
379
+ const nodeNextReq = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextRequest(req);
380
+ const nodeNextRes = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextResponse(res);
381
+ 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));
382
+ const responseGenerator = async ({ previousCacheEntry })=>{
383
+ try {
384
+ if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {
385
+ res.statusCode = 404;
386
+ // on-demand revalidate always sets this header
387
+ res.setHeader('x-nextjs-cache', 'REVALIDATED');
388
+ res.end('This page could not be found');
389
+ return null;
390
+ }
391
+ const response = cacheKey === null ? await routeModule.handle(nextReq, context) : await routeModule.prerender(nextReq, context);
392
+ req.fetchMetrics = context.renderOpts.fetchMetrics;
393
+ let pendingWaitUntil = context.renderOpts.pendingWaitUntil;
394
+ // Attempt using provided waitUntil if available
395
+ // if it's not we fallback to sendResponse's handling
396
+ if (pendingWaitUntil) {
397
+ if (ctx.waitUntil) {
398
+ ctx.waitUntil(pendingWaitUntil);
399
+ pendingWaitUntil = undefined;
400
+ }
401
+ }
402
+ const cacheTags = context.renderOpts.collectedTags;
403
+ // If the request is for a static response, we can cache it so long
404
+ // as it's not edge.
405
+ if (isIsr) {
406
+ const blob = await response.blob();
407
+ // Copy the headers from the response.
408
+ const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.toNodeOutgoingHttpHeaders)(response.headers);
409
+ if (cacheTags) {
410
+ headers[next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER] = cacheTags;
411
+ }
412
+ if (!headers['content-type'] && blob.type) {
413
+ headers['content-type'] = blob.type;
414
+ }
415
+ const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;
416
+ 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
417
+ // explicit `expire` (e.g. via `cacheLife`). This mirrors the
418
+ // build-time fallback in `build/index.ts` so cache entries
419
+ // and the response Cache-Control header agree on the route's
420
+ // effective expire. Routes that opt out of revalidation
421
+ // (`revalidate: false`) or that are dynamic (`revalidate: 0`)
422
+ // keep `expire: undefined`.
423
+ revalidate !== false && revalidate > 0 ? nextConfig.expireTime : undefined : context.renderOpts.collectedExpire;
424
+ // Create the cache entry for the response.
425
+ const cacheEntry = {
426
+ value: {
427
+ kind: next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE,
428
+ status: response.status,
429
+ body: Buffer.from(await blob.arrayBuffer()),
430
+ headers
431
+ },
432
+ cacheControl: {
433
+ revalidate,
434
+ expire
435
+ }
436
+ };
437
+ return cacheEntry;
438
+ } else {
439
+ // send response without caching if not ISR
440
+ await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, response, pendingWaitUntil);
441
+ return null;
442
+ }
443
+ } catch (err) {
444
+ // if this is a background revalidate we need to report
445
+ // the request error here as it won't be bubbled
446
+ if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {
447
+ const silenceLog = false;
448
+ await routeModule.onRequestError(req, err, {
449
+ routerKind: 'App Router',
450
+ routePath: srcPage,
451
+ routeType: 'route',
452
+ revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
453
+ isStaticGeneration: cacheKey !== null,
454
+ isOnDemandRevalidate
455
+ })
456
+ }, silenceLog, routerServerContext);
457
+ }
458
+ throw err;
523
459
  }
524
- }
525
- if (Object.keys(cleaned).length === 0) return null;
526
- return JSON.stringify(cleaned);
527
- }
528
- function toMbti(v) {
529
- if (!v) return null;
530
- return v in _lib_agents_adaptive_persona_presets__WEBPACK_IMPORTED_MODULE_2__/* .MBTI_PRESETS */ .e ? v : null;
531
- }
532
- function deleteAgentConfig(id) {
533
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("DELETE FROM agent_configs WHERE id=?").run(id).changes > 0;
534
- }
535
- function generateAgentId(name) {
536
- const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
537
- const suffix = Math.random().toString(36).slice(2, 6);
538
- return slug ? `${slug}-${suffix}` : `agent-${suffix}`;
539
- }
540
- // ── ADR-0022: per-agent message-channel display filters ─────────────────
541
- // Canonical channel keys mirrored in `hooks/useMessageFilters.ts`. Kept
542
- // in sync there by importing this constant — single source of truth.
543
- const DISPLAY_FILTER_KEYS = [
544
- "scheduled_task",
545
- "watcher",
546
- "bridge",
547
- "extension",
548
- "page_capture",
549
- "synthetic",
550
- "tool_use",
551
- "thinking"
552
- ];
553
- const DISPLAY_FILTER_DEFAULTS = {
554
- scheduled_task: true,
555
- watcher: true,
556
- bridge: true,
557
- extension: true,
558
- page_capture: true,
559
- synthetic: true,
560
- tool_use: true,
561
- thinking: true
562
- };
563
- function parseDisplayFilters(raw) {
564
- if (!raw) return {
565
- ...DISPLAY_FILTER_DEFAULTS
566
460
  };
567
- try {
568
- const parsed = JSON.parse(raw);
569
- // Merge over defaults so newly-added channels stay visible on old rows.
570
- return {
571
- ...DISPLAY_FILTER_DEFAULTS,
572
- ...parsed
573
- };
574
- } catch {
575
- return {
576
- ...DISPLAY_FILTER_DEFAULTS
577
- };
578
- }
579
- }
580
- function getAgentDisplayFilters(id) {
581
- const row = getAgentConfig(id);
582
- if (!row) return null;
583
- return parseDisplayFilters(row.display_filters);
584
- }
585
- /**
586
- * Merge a partial filter map into the agent's stored prefs. Pass `null` to
587
- * reset to defaults (clears the column). Safe against concurrent toggles
588
- * from multiple browser tabs because the merge happens server-side.
589
- */ function updateAgentDisplayFilters(id, patch) {
590
- const row = getAgentConfig(id);
591
- if (!row) return null;
592
- if (patch === null) {
593
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("UPDATE agent_configs SET display_filters=NULL, updated_at=? WHERE id=?").run(now(), id);
594
- return {
595
- ...DISPLAY_FILTER_DEFAULTS
596
- };
597
- }
598
- const current = parseDisplayFilters(row.display_filters);
599
- const next = {
600
- ...current
461
+ const handleResponse = async (currentSpan, parentSpan)=>{
462
+ try {
463
+ var _cacheEntry_value;
464
+ const cacheEntry = await routeModule.handleResponse({
465
+ req,
466
+ nextConfig,
467
+ cacheKey,
468
+ routeKind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
469
+ isFallback: false,
470
+ previewProps,
471
+ prerenderManifest,
472
+ isRoutePPREnabled: false,
473
+ isOnDemandRevalidate,
474
+ revalidateOnlyGenerated,
475
+ responseGenerator,
476
+ waitUntil: ctx.waitUntil,
477
+ isMinimalMode
478
+ });
479
+ if (cacheEntry !== null && 'error' in cacheEntry) {
480
+ throw cacheEntry.error;
481
+ }
482
+ // we don't create a cacheEntry for ISR
483
+ if (!isIsr) {
484
+ return;
485
+ }
486
+ 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) {
487
+ var _cacheEntry_value1;
488
+ throw new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`);
489
+ }
490
+ if (!isMinimalMode) {
491
+ res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');
492
+ }
493
+ // Draft mode should never be cached
494
+ if (isDraftMode) {
495
+ res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
496
+ }
497
+ const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.fromNodeOutgoingHttpHeaders)(cacheEntry.value.headers);
498
+ if (!(isMinimalMode && isIsr)) {
499
+ headers.delete(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER);
500
+ }
501
+ // If cache control is already set on the response we don't
502
+ // override it to allow users to customize it via next.config
503
+ if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {
504
+ headers.set('Cache-Control', (0,next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__.getCacheControlHeader)(cacheEntry.cacheControl));
505
+ }
506
+ 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'.
507
+ new Response(cacheEntry.value.body, {
508
+ headers,
509
+ status: cacheEntry.value.status || 200
510
+ }));
511
+ return;
512
+ } catch (err) {
513
+ if (!(err instanceof next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError)) {
514
+ const silenceLog = false;
515
+ await routeModule.onRequestError(req, err, {
516
+ routerKind: 'App Router',
517
+ routePath: normalizedSrcPage,
518
+ routeType: 'route',
519
+ revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
520
+ isStaticGeneration: cacheKey !== null,
521
+ isOnDemandRevalidate
522
+ })
523
+ }, silenceLog, routerServerContext);
524
+ }
525
+ // rethrow so that we can handle serving error page
526
+ // If this is during static generation, throw the error again.
527
+ if (isIsr) throw err;
528
+ // Otherwise, send a 500 response unless the original response has
529
+ // already committed. In that case, preserve its status code for
530
+ // telemetry while still recording the failure and terminating a response
531
+ // that the failed pipeline left open.
532
+ if (res.headersSent) {
533
+ if (currentSpan) {
534
+ const error = err instanceof Error ? err : new Error('Unknown app route error');
535
+ currentSpan.recordException(error);
536
+ currentSpan.setStatus({
537
+ code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
538
+ message: error.message
539
+ });
540
+ currentSpan.setAttribute('error.type', error.name);
541
+ }
542
+ if (!res.writableEnded && !res.destroyed) {
543
+ res.end();
544
+ }
545
+ } else {
546
+ await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, new Response(null, {
547
+ status: 500
548
+ }));
549
+ }
550
+ return;
551
+ } finally{
552
+ ;
553
+ (()=>{
554
+ if (!currentSpan) {
555
+ return;
556
+ }
557
+ let statusCode = res.statusCode;
558
+ currentSpan.setAttributes({
559
+ 'http.status_code': statusCode,
560
+ 'next.rsc': false
561
+ });
562
+ if (statusCode && statusCode >= 500) {
563
+ // For 5xx status codes: SHOULD be set to 'Error' span status.
564
+ // x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
565
+ currentSpan.setStatus({
566
+ code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR
567
+ });
568
+ // For span status 'Error', SHOULD set 'error.type' attribute.
569
+ currentSpan.setAttribute('error.type', statusCode.toString());
570
+ }
571
+ const rootSpanAttributes = tracer.getRootSpanAttributes();
572
+ // We were unable to get attributes, probably OTEL is not enabled
573
+ if (!rootSpanAttributes) {
574
+ return;
575
+ }
576
+ if (rootSpanAttributes.get('next.span_type') !== next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest) {
577
+ console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
578
+ return;
579
+ }
580
+ const route = rootSpanAttributes.get('next.route') || normalizedSrcPage;
581
+ const name = `${method} ${route}`;
582
+ currentSpan.setAttributes({
583
+ 'next.route': route,
584
+ 'http.route': route,
585
+ 'next.span_name': name
586
+ });
587
+ currentSpan.updateName(name);
588
+ // Propagate http.route to the parent span if one exists (e.g.
589
+ // a platform-created HTTP span in adapter deployments).
590
+ if (parentSpan && parentSpan !== currentSpan) {
591
+ parentSpan.setAttribute('http.route', route);
592
+ parentSpan.updateName(name);
593
+ }
594
+ })();
595
+ }
601
596
  };
602
- for (const k of DISPLAY_FILTER_KEYS){
603
- if (k in patch && typeof patch[k] === "boolean") next[k] = patch[k];
597
+ // TODO: activeSpan code path is for when wrapped by
598
+ // next-server can be removed when this is no longer used
599
+ if (isWrappedByNextServer && activeSpan) {
600
+ await handleResponse(activeSpan, undefined);
601
+ } else {
602
+ let parentSpan = tracer.getActiveScopeSpan();
603
+ await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest, {
604
+ spanName: `${method} ${srcPage}`,
605
+ kind: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanKind.SERVER,
606
+ attributes: {
607
+ 'http.method': method,
608
+ 'http.target': req.url
609
+ }
610
+ }, (span)=>handleResponse(span, parentSpan)), undefined, !isWrappedByNextServer);
604
611
  }
605
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("UPDATE agent_configs SET display_filters=?, updated_at=? WHERE id=?").run(JSON.stringify(next), now(), id);
606
- return next;
607
612
  }
608
613
 
614
+ //# sourceMappingURL=app-route.js.map
609
615
 
610
- /***/ }),
611
-
612
- /***/ 44708:
613
- /***/ ((module) => {
614
-
615
- module.exports = require("node:https");
616
-
617
- /***/ }),
618
-
619
- /***/ 44870:
620
- /***/ ((module) => {
621
-
622
- module.exports = require("next/dist/compiled/next-server/app-route.runtime.prod.js");
623
-
624
- /***/ }),
625
-
626
- /***/ 48161:
627
- /***/ ((module) => {
628
-
629
- module.exports = require("node:os");
630
616
 
631
617
  /***/ }),
632
618
 
633
- /***/ 51455:
619
+ /***/ 27910:
634
620
  /***/ ((module) => {
635
621
 
636
- module.exports = require("node:fs/promises");
622
+ module.exports = require("stream");
637
623
 
638
624
  /***/ }),
639
625
 
640
- /***/ 55511:
626
+ /***/ 28354:
641
627
  /***/ ((module) => {
642
628
 
643
- module.exports = require("crypto");
629
+ module.exports = require("util");
644
630
 
645
631
  /***/ }),
646
632
 
647
- /***/ 55591:
633
+ /***/ 29021:
648
634
  /***/ ((module) => {
649
635
 
650
- module.exports = require("https");
636
+ module.exports = require("fs");
651
637
 
652
638
  /***/ }),
653
639
 
654
- /***/ 57075:
640
+ /***/ 29294:
655
641
  /***/ ((module) => {
656
642
 
657
- module.exports = require("node:stream");
643
+ module.exports = require("next/dist/server/app-render/work-async-storage.external.js");
658
644
 
659
645
  /***/ }),
660
646
 
661
- /***/ 57975:
647
+ /***/ 31421:
662
648
  /***/ ((module) => {
663
649
 
664
- module.exports = require("node:util");
650
+ module.exports = require("node:child_process");
665
651
 
666
652
  /***/ }),
667
653
 
668
- /***/ 63033:
654
+ /***/ 33873:
669
655
  /***/ ((module) => {
670
656
 
671
- module.exports = require("next/dist/server/app-render/work-unit-async-storage.external.js");
657
+ module.exports = require("path");
672
658
 
673
659
  /***/ }),
674
660
 
675
- /***/ 73024:
661
+ /***/ 37067:
676
662
  /***/ ((module) => {
677
663
 
678
- module.exports = require("node:fs");
664
+ module.exports = require("node:http");
679
665
 
680
666
  /***/ }),
681
667
 
682
- /***/ 75919:
668
+ /***/ 38522:
683
669
  /***/ ((module) => {
684
670
 
685
- module.exports = require("node:worker_threads");
671
+ module.exports = require("node:zlib");
686
672
 
687
673
  /***/ }),
688
674
 
689
- /***/ 76760:
690
- /***/ ((module) => {
691
-
692
- module.exports = require("node:path");
675
+ /***/ 39947:
676
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
693
677
 
694
- /***/ }),
678
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
679
+ /* harmony export */ Bm: () => (/* binding */ cachedJson),
680
+ /* harmony export */ HN: () => (/* binding */ notFoundResponse),
681
+ /* harmony export */ Jb: () => (/* binding */ validateBody),
682
+ /* harmony export */ K2: () => (/* binding */ createdResponse),
683
+ /* harmony export */ Ng: () => (/* binding */ noStoreJson),
684
+ /* harmony export */ yj: () => (/* binding */ errorResponse)
685
+ /* harmony export */ });
686
+ /* harmony import */ var next_server__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(23211);
687
+ // Shared HTTP response builders for app/api/v1/** route handlers.
688
+ //
689
+ // Goal: every error/success payload across the v1 surface has the same
690
+ // shape. Before this lived inline, response bodies drifted —
691
+ // `{error: "x"}` vs `{message: "x"}`, 400 vs 422 for the same condition,
692
+ // some routes returned Zod's raw issue array, others stringified it.
695
693
 
696
- /***/ 77598:
697
- /***/ ((module) => {
694
+ function errorResponse(message, status = 400) {
695
+ return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
696
+ error: message
697
+ }, {
698
+ status
699
+ });
700
+ }
701
+ function notFoundResponse(message = "Not found") {
702
+ return errorResponse(message, 404);
703
+ }
704
+ function createdResponse(data) {
705
+ return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json(data, {
706
+ status: 201
707
+ });
708
+ }
709
+ // Wrap a 200 JSON response with a private Cache-Control header. Use on safe
710
+ // GET endpoints that serve user-scoped data the client refetches often (panel
711
+ // mounts, navigation back/forward) but mutates rarely. The TTL is short
712
+ // enough that explicit mutations — which patch the client-side ApiClient
713
+ // cache in place — stay observably consistent without an extra roundtrip.
714
+ //
715
+ // swrSeconds (optional): stale-while-revalidate window. When set, the browser
716
+ // serves the cached response immediately and refreshes in the background,
717
+ // making navigation feel instant. Use for data that can tolerate brief
718
+ // staleness (tool list, agent configs, model list). Omit for real-time data
719
+ // (dashboard metrics, credential state).
720
+ function cachedJson(data, maxAgeSeconds, swrSeconds) {
721
+ const swr = swrSeconds ? `, stale-while-revalidate=${swrSeconds}` : "";
722
+ return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json(data, {
723
+ headers: {
724
+ "Cache-Control": `private, max-age=${maxAgeSeconds}${swr}`
725
+ }
726
+ });
727
+ }
728
+ // Use for endpoints whose response contains live state that must never be
729
+ // served from cache — credentials, connection status, live config values.
730
+ function noStoreJson(data) {
731
+ return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json(data, {
732
+ headers: {
733
+ "Cache-Control": "no-store"
734
+ }
735
+ });
736
+ }
737
+ // Validate a JSON request body against a zod schema.
738
+ // Returns either the parsed data or a 400 NextResponse explaining the issue.
739
+ // Caller pattern:
740
+ // const parsed = await validateBody(req, Schema);
741
+ // if (parsed instanceof NextResponse) return parsed;
742
+ // // use parsed.field
743
+ async function validateBody(req, schema) {
744
+ let raw;
745
+ try {
746
+ raw = await req.json();
747
+ } catch {
748
+ return errorResponse("Request body must be valid JSON", 400);
749
+ }
750
+ const parsed = schema.safeParse(raw);
751
+ if (!parsed.success) {
752
+ return errorResponse(parsed.error.issues[0]?.message ?? "invalid body", 400);
753
+ }
754
+ return parsed.data;
755
+ }
698
756
 
699
- module.exports = require("node:crypto");
700
757
 
701
758
  /***/ }),
702
759
 
703
- /***/ 78361:
760
+ /***/ 41720:
704
761
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
705
762
 
706
763
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
707
- /* harmony export */ $6: () => (/* binding */ findRoute),
708
- /* harmony export */ Bn: () => (/* binding */ listRoutes),
709
- /* harmony export */ DL: () => (/* binding */ updateRoute),
710
- /* harmony export */ GB: () => (/* binding */ addIgnore),
711
- /* harmony export */ KC: () => (/* binding */ bumpRouteLastSeenTs),
712
- /* harmony export */ OO: () => (/* binding */ createBridge),
713
- /* harmony export */ Pu: () => (/* binding */ deleteBridge),
714
- /* harmony export */ V7: () => (/* binding */ deleteRoute),
715
- /* harmony export */ X9: () => (/* binding */ listBridges),
716
- /* harmony export */ aM: () => (/* binding */ getRoute),
717
- /* harmony export */ e1: () => (/* binding */ getBridge),
718
- /* harmony export */ kZ: () => (/* binding */ listIgnores),
719
- /* harmony export */ mp: () => (/* binding */ getMaxRouteLastSeenTs),
720
- /* harmony export */ nE: () => (/* binding */ removeIgnore),
721
- /* harmony export */ pi: () => (/* binding */ isIgnored),
722
- /* harmony export */ po: () => (/* binding */ updateBridge),
723
- /* harmony export */ un: () => (/* binding */ createRoute)
764
+ /* harmony export */ BM: () => (/* binding */ upsertAgentConfig),
765
+ /* harmony export */ E1: () => (/* binding */ updateAgentDisplayFilters),
766
+ /* harmony export */ P2: () => (/* binding */ parseCitationStrictness),
767
+ /* harmony export */ S2: () => (/* binding */ getAgentToolCredentials),
768
+ /* harmony export */ SJ: () => (/* binding */ generateAgentId),
769
+ /* harmony export */ TG: () => (/* binding */ getAgentTools),
770
+ /* harmony export */ bg: () => (/* binding */ parseDelegateTargets),
771
+ /* harmony export */ d2: () => (/* binding */ DISPLAY_FILTER_KEYS),
772
+ /* harmony export */ fg: () => (/* binding */ getAgentTierProportions),
773
+ /* harmony export */ mJ: () => (/* binding */ getAgentConfig),
774
+ /* harmony export */ nV: () => (/* binding */ getAgentDisplayFilters),
775
+ /* harmony export */ vU: () => (/* binding */ getDefaultAgentConfig),
776
+ /* harmony export */ vi: () => (/* binding */ DISPLAY_FILTER_DEFAULTS),
777
+ /* harmony export */ xi: () => (/* binding */ deleteAgentConfig),
778
+ /* harmony export */ zb: () => (/* binding */ listAgentConfigs)
724
779
  /* harmony export */ });
725
- /* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77598);
726
- /* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(node_crypto__WEBPACK_IMPORTED_MODULE_0__);
727
- /* harmony import */ var _lib_db__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(46);
728
- /* harmony import */ var _lib_db_transaction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(99043);
780
+ /* harmony import */ var _lib_db__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(46);
781
+ /* harmony import */ var _lib_db_transaction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99043);
782
+ /* harmony import */ var _lib_agents_adaptive_persona_presets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(66849);
729
783
 
730
784
 
731
785
 
732
786
  const now = ()=>new Date().toISOString();
733
- // ---------------------------------------------------------------------------
734
- // Bridge CRUD
735
- // ---------------------------------------------------------------------------
736
- function listBridges() {
737
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridges ORDER BY created_at ASC").all();
787
+ /** Coerce arbitrary input (DB row TEXT, API body, undefined) to the enum.
788
+ * Returns `null` for null/undefined/unknown values so callers can default. */ function parseCitationStrictness(value) {
789
+ if (value === "off" || value === "informational" || value === "standard" || value === "strict") {
790
+ return value;
791
+ }
792
+ return null;
738
793
  }
739
- function getBridge(id) {
740
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridges WHERE id=?").get(id) ?? null;
794
+ /**
795
+ * Parse the JSON-encoded per-agent override of context tier proportions.
796
+ * Returns `null` for NULL, blank, malformed JSON, or any payload that
797
+ * doesn't have three finite non-negative numeric fields. Callers fall
798
+ * back to the model config's value (or built-in defaults) on null.
799
+ */ function getAgentTierProportions(row) {
800
+ const raw = row.context_tier_proportions;
801
+ if (!raw) return null;
802
+ try {
803
+ const parsed = JSON.parse(raw);
804
+ const hot = Number(parsed.hot);
805
+ const warm = Number(parsed.warm);
806
+ const facts = Number(parsed.facts);
807
+ if (![
808
+ hot,
809
+ warm,
810
+ facts
811
+ ].every((n)=>Number.isFinite(n) && n >= 0)) return null;
812
+ if (hot + warm + facts <= 0) return null;
813
+ return {
814
+ hot,
815
+ warm,
816
+ facts
817
+ };
818
+ } catch {
819
+ return null;
820
+ }
821
+ }
822
+ function listAgentConfigs() {
823
+ // Default agent always first; then by the timestamp of each agent's latest message.
824
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare(`SELECT a.*
825
+ FROM agent_configs a
826
+ LEFT JOIN (
827
+ SELECT t.agent_id, MAX(m.created_at) AS last_message_at
828
+ FROM threads t
829
+ JOIN messages m ON m.thread_id = t.thread_id
830
+ GROUP BY t.agent_id
831
+ ) latest ON latest.agent_id = a.id
832
+ ORDER BY a.is_default DESC, COALESCE(latest.last_message_at, a.created_at) DESC, a.id ASC`).all();
741
833
  }
742
- function createBridge(input) {
743
- const id = (0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomUUID)();
744
- const t = now();
745
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`INSERT INTO bridges (id, kind, name, status, qr, last_error, paired_id, enabled, forward_group_profile_updates, forward_group_participants_updates, created_at, updated_at)
746
- VALUES (?, ?, ?, 'disconnected', NULL, NULL, NULL, 0, 1, 1, ?, ?)`).run(id, input.kind, input.name, t, t);
747
- return {
748
- id,
749
- kind: input.kind,
750
- name: input.name,
751
- status: "disconnected",
752
- qr: null,
753
- last_error: null,
754
- paired_id: null,
755
- enabled: 0,
756
- forward_group_profile_updates: 1,
757
- forward_group_participants_updates: 1,
758
- created_at: t,
759
- updated_at: t
760
- };
834
+ function getDefaultAgentConfig() {
835
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("SELECT * FROM agent_configs WHERE is_default=1 LIMIT 1").get() ?? null;
761
836
  }
762
- function updateBridge(id, patch) {
763
- const existing = getBridge(id);
764
- if (!existing) return null;
765
- const merged = {
766
- ...existing,
767
- name: patch.name ?? existing.name,
768
- enabled: patch.enabled ?? existing.enabled,
769
- status: patch.status ?? existing.status,
770
- qr: patch.qr !== undefined ? patch.qr : existing.qr,
771
- last_error: patch.last_error !== undefined ? patch.last_error : existing.last_error,
772
- paired_id: patch.paired_id !== undefined ? patch.paired_id : existing.paired_id,
773
- forward_group_profile_updates: patch.forward_group_profile_updates !== undefined ? patch.forward_group_profile_updates : existing.forward_group_profile_updates,
774
- forward_group_participants_updates: patch.forward_group_participants_updates !== undefined ? patch.forward_group_participants_updates : existing.forward_group_participants_updates,
775
- updated_at: now()
776
- };
777
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`UPDATE bridges
778
- SET name=?, enabled=?, status=?, qr=?, last_error=?, paired_id=?, forward_group_profile_updates=?, forward_group_participants_updates=?, updated_at=?
779
- WHERE id=?`).run(merged.name, merged.enabled, merged.status, merged.qr, merged.last_error, merged.paired_id, merged.forward_group_profile_updates, merged.forward_group_participants_updates, merged.updated_at, id);
780
- return merged;
837
+ function getAgentConfig(id) {
838
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("SELECT * FROM agent_configs WHERE id=?").get(id) ?? null;
781
839
  }
782
- function deleteBridge(id) {
783
- return (0,_lib_db_transaction__WEBPACK_IMPORTED_MODULE_2__/* .withDbTransaction */ .J)(()=>{
784
- const db = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)();
785
- db.prepare("DELETE FROM bridge_routes WHERE bridge_id=?").run(id);
786
- db.prepare("DELETE FROM bridge_ignores WHERE bridge_id=?").run(id);
787
- const r = db.prepare("DELETE FROM bridges WHERE id=?").run(id);
788
- return r.changes > 0;
789
- });
840
+ /**
841
+ * Parse the JSON-encoded delegate whitelist into a deduped string[]. Returns
842
+ * an empty array for NULL, blank, or malformed JSON (delegation is opt-in).
843
+ */ /**
844
+ * Parse the agent's tool allowlist (`tools` column, stored as a JSON string).
845
+ * Returns an empty array on NULL/blank/malformed JSON — same defensive shape
846
+ * as parseDelegateTargets. Callers that previously did `JSON.parse(cfg.tools)`
847
+ * inline should switch to this getter so the serialization contract stays
848
+ * owned by this store.
849
+ */ function getAgentTools(cfg) {
850
+ if (!cfg?.tools) return [];
851
+ try {
852
+ const parsed = JSON.parse(cfg.tools);
853
+ if (!Array.isArray(parsed)) return [];
854
+ return parsed.filter((x)=>typeof x === "string" && x.length > 0);
855
+ } catch {
856
+ return [];
857
+ }
790
858
  }
791
- // ---------------------------------------------------------------------------
792
- // Route CRUD
793
- // ---------------------------------------------------------------------------
794
- function listRoutes(bridgeId) {
795
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_routes WHERE bridge_id=? ORDER BY created_at ASC").all(bridgeId);
859
+ function parseDelegateTargets(raw) {
860
+ if (!raw) return [];
861
+ try {
862
+ const parsed = JSON.parse(raw);
863
+ if (!Array.isArray(parsed)) return [];
864
+ const ids = parsed.filter((x)=>typeof x === "string" && x.length > 0);
865
+ return Array.from(new Set(ids));
866
+ } catch {
867
+ return [];
868
+ }
796
869
  }
797
- function getRoute(id) {
798
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_routes WHERE id=?").get(id) ?? null;
870
+ /**
871
+ * Parse the per-agent `{ toolName: credentialId }` override map stored in
872
+ * the `tool_credentials` column. Returns an empty record on NULL / blank /
873
+ * malformed JSON / non-string entries so downstream code can treat the
874
+ * result as a plain lookup without further validation.
875
+ */ function getAgentToolCredentials(cfg) {
876
+ if (!cfg?.tool_credentials) return {};
877
+ try {
878
+ const parsed = JSON.parse(cfg.tool_credentials);
879
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
880
+ const out = {};
881
+ for (const [k, v] of Object.entries(parsed)){
882
+ if (typeof v === "string" && v.length > 0) out[k] = v;
883
+ }
884
+ return out;
885
+ } catch {
886
+ return {};
887
+ }
799
888
  }
800
- function findRoute(bridgeId, remoteJid) {
801
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_routes WHERE bridge_id=? AND remote_jid=?").get(bridgeId, remoteJid) ?? null;
889
+ function upsertAgentConfig(input) {
890
+ return (0,_lib_db_transaction__WEBPACK_IMPORTED_MODULE_1__/* .withDbTransaction */ .J)(()=>upsertAgentConfigTransaction(input));
802
891
  }
803
- function createRoute(input) {
804
- const id = (0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomUUID)();
892
+ function upsertAgentConfigTransaction(input) {
805
893
  const t = now();
806
- const silent = input.silent_mode ? 1 : 0;
807
- const respondTo = input.respond_to ?? "counterpart";
808
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`INSERT INTO bridge_routes (id, bridge_id, remote_jid, agent_id, label, silent_mode, respond_to, created_at, updated_at)
809
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, input.bridge_id, input.remote_jid, input.agent_id, input.label ?? null, silent, respondTo, t, t);
810
- return {
811
- id,
812
- bridge_id: input.bridge_id,
813
- remote_jid: input.remote_jid,
814
- agent_id: input.agent_id,
815
- label: input.label ?? null,
816
- silent_mode: silent,
817
- respond_to: respondTo,
818
- last_seen_ts: null,
819
- created_at: t,
820
- updated_at: t
821
- };
894
+ const db = (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)();
895
+ const existing = getAgentConfig(input.id);
896
+ const created_at = existing?.created_at ?? t;
897
+ const existingMbti = toMbti(existing?.adaptive_mbti);
898
+ const mbti = input.adaptive_mbti ?? existingMbti ?? "INTJ";
899
+ const preset = _lib_agents_adaptive_persona_presets__WEBPACK_IMPORTED_MODULE_2__/* .MBTI_PRESETS */ .e[mbti];
900
+ // Omitted sliders keep their tuned values; they only fall back to the
901
+ // preset when the type changes or the agent is new. Otherwise every
902
+ // partial update (approved proposals, tool edits) reset them.
903
+ const keepTuned = existing !== null && existing !== undefined && mbti === existingMbti;
904
+ const strength = input.adaptive_persona_strength ?? (keepTuned ? existing.adaptive_persona_strength : preset.strength);
905
+ const empathy = input.adaptive_empathy ?? (keepTuned ? existing.adaptive_empathy : preset.empathy);
906
+ const expressiveness = input.adaptive_expressiveness ?? (keepTuned ? existing.adaptive_expressiveness : preset.expressiveness);
907
+ const verbosity = input.adaptive_verbosity ?? (keepTuned ? existing.adaptive_verbosity : preset.verbosity);
908
+ if (input.is_default) db.prepare("UPDATE agent_configs SET is_default=0").run();
909
+ // harness_id: explicit `undefined` means "keep existing"; explicit `null`
910
+ // means "use the global default". Empty string is normalised to null too,
911
+ // matching how the AgentEditor sends "" for the inherit option.
912
+ const harnessId = input.harness_id === undefined ? existing?.harness_id ?? null : input.harness_id && input.harness_id.length > 0 ? input.harness_id : null;
913
+ // delegate_targets: undefined = keep existing; explicit empty array clears.
914
+ const delegateTargets = input.delegate_targets === undefined ? existing?.delegate_targets ?? null : JSON.stringify(Array.from(new Set(input.delegate_targets.filter((id)=>id && id !== input.id))));
915
+ // context_tier_proportions: undefined = keep existing; null = clear and
916
+ // inherit from the model; object = serialise as JSON. Negative values are
917
+ // clamped to 0 so the upsert can't poison the column with bad data.
918
+ const tierProportions = input.context_tier_proportions === undefined ? existing?.context_tier_proportions ?? null : input.context_tier_proportions === null ? null : JSON.stringify({
919
+ hot: Math.max(0, Number(input.context_tier_proportions.hot) || 0),
920
+ warm: Math.max(0, Number(input.context_tier_proportions.warm) || 0),
921
+ facts: Math.max(0, Number(input.context_tier_proportions.facts) || 0)
922
+ });
923
+ // Anti-hallucination override: `undefined` keeps existing; `null` clears
924
+ // the override (inherits env). Empty-string model is normalised to null
925
+ // so the editor can ship "" for the inherit option.
926
+ const antiHallucMode = input.anti_hallucination_mode === undefined ? existing?.anti_hallucination_mode ?? null : input.anti_hallucination_mode === null ? null : input.anti_hallucination_mode === "off" || input.anti_hallucination_mode === "regex" || input.anti_hallucination_mode === "model" ? input.anti_hallucination_mode : null;
927
+ const antiHallucModel = input.anti_hallucination_model_config === undefined ? existing?.anti_hallucination_model_config ?? null : input.anti_hallucination_model_config && input.anti_hallucination_model_config.trim().length > 0 ? input.anti_hallucination_model_config.trim() : null;
928
+ const citationStrictness = input.citation_strictness === undefined ? parseCitationStrictness(existing?.citation_strictness) ?? "off" : parseCitationStrictness(input.citation_strictness) ?? "off";
929
+ const toolCredentials = serialiseToolCredentials(input.tool_credentials, existing?.tool_credentials ?? null);
930
+ const VALID_ROUTER_POLICIES = new Set([
931
+ "cheap",
932
+ "fast",
933
+ "balanced",
934
+ "quality"
935
+ ]);
936
+ const routerPolicy = input.router_policy === undefined ? existing?.router_policy ?? null : input.router_policy !== null && VALID_ROUTER_POLICIES.has(input.router_policy) ? input.router_policy : null;
937
+ const routerEnabled = input.router_enabled === undefined ? existing?.router_enabled ?? null : input.router_enabled === null ? null : input.router_enabled ? 1 : 0;
938
+ const VALID_USAGE_STRATEGIES = new Set([
939
+ "cost_saving",
940
+ "fast",
941
+ "balanced",
942
+ "high_reasoning"
943
+ ]);
944
+ const usageStrategy = input.usage_strategy === undefined ? existing?.usage_strategy ?? null : input.usage_strategy !== null && VALID_USAGE_STRATEGIES.has(input.usage_strategy) ? input.usage_strategy : null;
945
+ const requestedWarmSummaryLimit = input.warm_summary_limit ?? existing?.warm_summary_limit ?? 50;
946
+ const warmSummaryLimit = Number.isFinite(requestedWarmSummaryLimit) ? Math.max(0, Math.floor(requestedWarmSummaryLimit)) : existing?.warm_summary_limit ?? 50;
947
+ db.prepare(`INSERT OR REPLACE INTO agent_configs
948
+ (id, name, icon, identity, instructions, tools, model_config_name, is_default,
949
+ history_limit, history_window_hours, warm_summary_limit, never_reply,
950
+ hot_turn_limit,
951
+ adaptive_persona_enabled, adaptive_persona_strength, adaptive_empathy, adaptive_expressiveness, adaptive_verbosity, adaptive_mbti,
952
+ voice_enabled, voice_model, voice_name, voice_stt_model, voice_auto_speak,
953
+ harness_id, delegate_targets, context_tier_proportions,
954
+ anti_hallucination_mode, anti_hallucination_model_config, citation_strictness,
955
+ tool_credentials, router_policy, router_enabled, usage_strategy,
956
+ created_at, updated_at)
957
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.id, input.name, input.icon ?? null, input.identity, input.instructions, JSON.stringify(input.tools), input.model_config_name ?? null, input.is_default ? 1 : existing?.is_default ?? 0, input.history_limit ?? existing?.history_limit ?? 50, input.history_window_hours ?? existing?.history_window_hours ?? 8, warmSummaryLimit, // never_reply is a boolean toggle — explicit `undefined` means "keep existing"
958
+ // (important for PATCH-style updates that omit the field).
959
+ input.never_reply === undefined ? existing?.never_reply ?? 0 : input.never_reply ? 1 : 0, Math.max(0, Math.floor(input.hot_turn_limit ?? existing?.hot_turn_limit ?? 12)), input.adaptive_persona_enabled === undefined ? existing?.adaptive_persona_enabled ?? 0 : input.adaptive_persona_enabled ? 1 : 0, clampPercent(strength, existing?.adaptive_persona_strength ?? 50), clampPercent(empathy, existing?.adaptive_empathy ?? 50), clampPercent(expressiveness, existing?.adaptive_expressiveness ?? 50), clampPercent(verbosity, existing?.adaptive_verbosity ?? 50), mbti, input.voice_enabled === undefined ? existing?.voice_enabled ?? 0 : input.voice_enabled ? 1 : 0, (input.voice_model ?? existing?.voice_model ?? "gemini-2.5-flash-preview-tts").trim() || "gemini-2.5-flash-preview-tts", (input.voice_name ?? existing?.voice_name ?? "Kore").trim() || "Kore", (input.voice_stt_model ?? existing?.voice_stt_model ?? "gemini-2.5-flash").trim() || "gemini-2.5-flash", input.voice_auto_speak === undefined ? existing?.voice_auto_speak ?? 1 : input.voice_auto_speak ? 1 : 0, harnessId, delegateTargets, tierProportions, antiHallucMode, antiHallucModel, citationStrictness, toolCredentials, routerPolicy, routerEnabled, usageStrategy, created_at, t);
960
+ return getAgentConfig(input.id);
822
961
  }
823
- function updateRoute(id, patch) {
824
- const existing = getRoute(id);
825
- if (!existing) return null;
826
- const merged = {
827
- ...existing,
828
- remote_jid: patch.remote_jid ?? existing.remote_jid,
829
- agent_id: patch.agent_id ?? existing.agent_id,
830
- label: patch.label !== undefined ? patch.label : existing.label,
831
- silent_mode: patch.silent_mode !== undefined ? patch.silent_mode ? 1 : 0 : existing.silent_mode,
832
- respond_to: patch.respond_to ?? existing.respond_to,
833
- updated_at: now()
834
- };
835
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE bridge_routes SET remote_jid=?, agent_id=?, label=?, silent_mode=?, respond_to=?, updated_at=? WHERE id=?").run(merged.remote_jid, merged.agent_id, merged.label, merged.silent_mode, merged.respond_to, merged.updated_at, id);
836
- return merged;
962
+ function clampPercent(next, fallback) {
963
+ const n = Number.isFinite(next) ? Number(next) : fallback;
964
+ return Math.max(0, Math.min(100, Math.round(n)));
837
965
  }
838
- function deleteRoute(id) {
839
- const r = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("DELETE FROM bridge_routes WHERE id=?").run(id);
840
- return r.changes > 0;
966
+ function serialiseToolCredentials(input, existing) {
967
+ if (input === undefined) return existing;
968
+ const cleaned = {};
969
+ for (const [k, v] of Object.entries(input)){
970
+ if (typeof k === "string" && k.length > 0 && typeof v === "string" && v.length > 0) {
971
+ cleaned[k] = v;
972
+ }
973
+ }
974
+ if (Object.keys(cleaned).length === 0) return null;
975
+ return JSON.stringify(cleaned);
841
976
  }
842
- // Catch-up watermark. The WhatsApp adapter calls this with the
843
- // messageTimestamp (epoch ms) of the most recent inbound that reached the
844
- // agent. Only writes when `ts` is strictly greater than the persisted
845
- // value so out-of-order replays from the server-side backlog can't roll
846
- // the watermark backward. No-op when no route exists for the pair
847
- // (catch-all routing handles those at the dispatcher layer).
848
- function bumpRouteLastSeenTs(bridgeId, remoteJid, ts) {
849
- if (!Number.isFinite(ts) || ts <= 0) return;
850
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE bridge_routes SET last_seen_ts=? WHERE bridge_id=? AND remote_jid=? AND (last_seen_ts IS NULL OR last_seen_ts < ?)").run(ts, bridgeId, remoteJid, ts);
977
+ function toMbti(v) {
978
+ if (!v) return null;
979
+ return v in _lib_agents_adaptive_persona_presets__WEBPACK_IMPORTED_MODULE_2__/* .MBTI_PRESETS */ .e ? v : null;
851
980
  }
852
- // Snapshot the highest watermark across every route on a bridge. The
853
- // adapter uses this on reconnect to short-circuit very-old appends before
854
- // it has loaded individual route rows.
855
- function getMaxRouteLastSeenTs(bridgeId) {
856
- const row = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT MAX(last_seen_ts) AS m FROM bridge_routes WHERE bridge_id=?").get(bridgeId);
857
- return row?.m ?? 0;
981
+ function deleteAgentConfig(id) {
982
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("DELETE FROM agent_configs WHERE id=?").run(id).changes > 0;
858
983
  }
859
- // ---------------------------------------------------------------------------
860
- // Ignore-list CRUD (per-bridge chat blocklist)
861
- //
862
- // Independent from routes: an ignore entry short-circuits the router even
863
- // when an explicit route or catch-all would otherwise match. The intent
864
- // is "listen to everything EXCEPT these chats" — messages from ignored
865
- // chats are dropped before any agent runs, so no history, no memory, no
866
- // tools. Delete the entry to resume forwarding.
867
- // ---------------------------------------------------------------------------
868
- function listIgnores(bridgeId) {
869
- return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_ignores WHERE bridge_id=? ORDER BY created_at ASC").all(bridgeId);
984
+ function generateAgentId(name) {
985
+ const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
986
+ const suffix = Math.random().toString(36).slice(2, 6);
987
+ return slug ? `${slug}-${suffix}` : `agent-${suffix}`;
988
+ }
989
+ // ── ADR-0022: per-agent message-channel display filters ─────────────────
990
+ // Canonical channel keys mirrored in `hooks/useMessageFilters.ts`. Kept
991
+ // in sync there by importing this constant — single source of truth.
992
+ const DISPLAY_FILTER_KEYS = [
993
+ "scheduled_task",
994
+ "watcher",
995
+ "bridge",
996
+ "extension",
997
+ "page_capture",
998
+ "synthetic",
999
+ "tool_use",
1000
+ "thinking"
1001
+ ];
1002
+ const DISPLAY_FILTER_DEFAULTS = {
1003
+ scheduled_task: true,
1004
+ watcher: true,
1005
+ bridge: true,
1006
+ extension: true,
1007
+ page_capture: true,
1008
+ synthetic: true,
1009
+ tool_use: true,
1010
+ thinking: true
1011
+ };
1012
+ function parseDisplayFilters(raw) {
1013
+ if (!raw) return {
1014
+ ...DISPLAY_FILTER_DEFAULTS
1015
+ };
1016
+ try {
1017
+ const parsed = JSON.parse(raw);
1018
+ // Merge over defaults so newly-added channels stay visible on old rows.
1019
+ return {
1020
+ ...DISPLAY_FILTER_DEFAULTS,
1021
+ ...parsed
1022
+ };
1023
+ } catch {
1024
+ return {
1025
+ ...DISPLAY_FILTER_DEFAULTS
1026
+ };
1027
+ }
870
1028
  }
871
- function isIgnored(bridgeId, remoteJid) {
872
- const row = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT 1 FROM bridge_ignores WHERE bridge_id=? AND remote_jid=? LIMIT 1").get(bridgeId, remoteJid);
873
- return !!row;
1029
+ function getAgentDisplayFilters(id) {
1030
+ const row = getAgentConfig(id);
1031
+ if (!row) return null;
1032
+ return parseDisplayFilters(row.display_filters);
874
1033
  }
875
1034
  /**
876
- * Add a chat to the bridge's ignore list. Idempotent — re-adding the
877
- * same (bridge_id, remote_jid) throws a SQLite UNIQUE violation which
878
- * the caller can surface as a 409. Callers who want upsert semantics
879
- * should catch and update the label separately.
880
- */ function addIgnore(input) {
881
- const id = (0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomUUID)();
882
- const t = now();
883
- (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`INSERT INTO bridge_ignores (id, bridge_id, remote_jid, label, created_at)
884
- VALUES (?, ?, ?, ?, ?)`).run(id, input.bridge_id, input.remote_jid, input.label ?? null, t);
885
- return {
886
- id,
887
- bridge_id: input.bridge_id,
888
- remote_jid: input.remote_jid,
889
- label: input.label ?? null,
890
- created_at: t
1035
+ * Merge a partial filter map into the agent's stored prefs. Pass `null` to
1036
+ * reset to defaults (clears the column). Safe against concurrent toggles
1037
+ * from multiple browser tabs because the merge happens server-side.
1038
+ */ function updateAgentDisplayFilters(id, patch) {
1039
+ const row = getAgentConfig(id);
1040
+ if (!row) return null;
1041
+ if (patch === null) {
1042
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("UPDATE agent_configs SET display_filters=NULL, updated_at=? WHERE id=?").run(now(), id);
1043
+ return {
1044
+ ...DISPLAY_FILTER_DEFAULTS
1045
+ };
1046
+ }
1047
+ const current = parseDisplayFilters(row.display_filters);
1048
+ const next = {
1049
+ ...current
891
1050
  };
892
- }
893
- function removeIgnore(bridgeId, remoteJid) {
894
- const r = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("DELETE FROM bridge_ignores WHERE bridge_id=? AND remote_jid=?").run(bridgeId, remoteJid);
895
- return r.changes > 0;
1051
+ for (const k of DISPLAY_FILTER_KEYS){
1052
+ if (k in patch && typeof patch[k] === "boolean") next[k] = patch[k];
1053
+ }
1054
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_0__/* .getDb */ .Lf)().prepare("UPDATE agent_configs SET display_filters=?, updated_at=? WHERE id=?").run(JSON.stringify(next), now(), id);
1055
+ return next;
896
1056
  }
897
1057
 
898
1058
 
899
1059
  /***/ }),
900
1060
 
901
- /***/ 79428:
1061
+ /***/ 44708:
902
1062
  /***/ ((module) => {
903
1063
 
904
- module.exports = require("buffer");
1064
+ module.exports = require("node:https");
905
1065
 
906
1066
  /***/ }),
907
1067
 
908
- /***/ 80099:
1068
+ /***/ 44870:
909
1069
  /***/ ((module) => {
910
1070
 
911
- module.exports = require("node:sqlite");
1071
+ module.exports = require("next/dist/compiled/next-server/app-route.runtime.prod.js");
912
1072
 
913
1073
  /***/ }),
914
1074
 
915
- /***/ 80481:
1075
+ /***/ 48161:
916
1076
  /***/ ((module) => {
917
1077
 
918
- module.exports = require("node:readline");
1078
+ module.exports = require("node:os");
919
1079
 
920
1080
  /***/ }),
921
1081
 
922
- /***/ 81630:
1082
+ /***/ 51455:
923
1083
  /***/ ((module) => {
924
1084
 
925
- module.exports = require("http");
1085
+ module.exports = require("node:fs/promises");
926
1086
 
927
1087
  /***/ }),
928
1088
 
929
- /***/ 83327:
930
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1089
+ /***/ 55511:
1090
+ /***/ ((module) => {
931
1091
 
932
- __webpack_require__.r(__webpack_exports__);
933
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
934
- /* harmony export */ handler: () => (/* binding */ handler),
935
- /* harmony export */ patchFetch: () => (/* binding */ patchFetch),
936
- /* harmony export */ routeModule: () => (/* binding */ routeModule),
937
- /* harmony export */ serverHooks: () => (/* binding */ serverHooks),
938
- /* harmony export */ workAsyncStorage: () => (/* binding */ workAsyncStorage),
939
- /* harmony export */ workUnitAsyncStorage: () => (/* binding */ workUnitAsyncStorage)
940
- /* harmony export */ });
941
- /* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19225);
942
- /* 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__);
943
- /* harmony import */ var next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(84006);
944
- /* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8317);
945
- /* 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__);
946
- /* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(99373);
947
- /* 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__);
948
- /* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34775);
949
- /* 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__);
950
- /* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(24235);
951
- /* 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__);
952
- /* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(261);
953
- /* 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__);
954
- /* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(54365);
955
- /* 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__);
956
- /* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(90771);
957
- /* 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__);
958
- /* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(73461);
959
- /* 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__);
960
- /* harmony import */ var next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(67798);
961
- /* harmony import */ var next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(92280);
962
- /* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(62018);
963
- /* 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__);
964
- /* harmony import */ var next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(45696);
965
- /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(47929);
966
- /* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__);
967
- /* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(86439);
968
- /* 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__);
969
- /* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(10246);
970
- /* 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__);
971
- /* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(37527);
972
- /* 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__);
1092
+ module.exports = require("crypto");
973
1093
 
1094
+ /***/ }),
974
1095
 
1096
+ /***/ 55591:
1097
+ /***/ ((module) => {
975
1098
 
1099
+ module.exports = require("https");
976
1100
 
1101
+ /***/ }),
977
1102
 
1103
+ /***/ 57075:
1104
+ /***/ ((module) => {
978
1105
 
1106
+ module.exports = require("node:stream");
979
1107
 
1108
+ /***/ }),
980
1109
 
1110
+ /***/ 57975:
1111
+ /***/ ((module) => {
981
1112
 
1113
+ module.exports = require("node:util");
982
1114
 
1115
+ /***/ }),
983
1116
 
1117
+ /***/ 63033:
1118
+ /***/ ((module) => {
984
1119
 
1120
+ module.exports = require("next/dist/server/app-render/work-unit-async-storage.external.js");
985
1121
 
1122
+ /***/ }),
986
1123
 
1124
+ /***/ 73024:
1125
+ /***/ ((module) => {
987
1126
 
1127
+ module.exports = require("node:fs");
988
1128
 
1129
+ /***/ }),
989
1130
 
1131
+ /***/ 75919:
1132
+ /***/ ((module) => {
990
1133
 
991
- // We inject the nextConfigOutput here so that we can use them in the route
992
- // module.
993
- const nextConfigOutput = "standalone"
994
- const routeModule = new next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__.AppRouteRouteModule({
995
- definition: {
996
- kind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
997
- page: "/api/v1/bridges/[id]/routes/route",
998
- pathname: "/api/v1/bridges/[id]/routes",
999
- filename: "route",
1000
- bundlePath: "app/api/v1/bridges/[id]/routes/route"
1001
- },
1002
- distDir: ".next" || 0,
1003
- relativeProjectDir: false || '',
1004
- resolvedPagePath: "/home/runner/work/jarela/jarela/app/api/v1/bridges/[id]/routes/route.ts",
1005
- nextConfigOutput,
1006
- // The lazy require factory ensures that:
1007
- // - In dev: devRequestTimingInternalsEnd is set before userland executes,
1008
- // correctly attributing module load time to application-code rather than
1009
- // framework internals.
1010
- // - In all modes: async modules (route files with top-level await) are
1011
- // handled correctly — require() returns a Promise for such modules, which
1012
- // ensureUserland() awaits before the first request is handled.
1013
- userland: ()=>__webpack_require__(440),
1014
- // In Turbopack dev mode, also provide a synchronous per-request getter so
1015
- // server HMR updates are picked up without re-executing the entry chunk.
1016
- // Using require() (synchronous) avoids adding async overhead that would be
1017
- // incorrectly attributed to application-code time in devRequestTiming.
1018
- ... false ? 0 : {}
1019
- });
1020
- // Pull out the exports that we need to expose from the module. This should
1021
- // be eliminated when we've moved the other routes to the new format. These
1022
- // are used to hook into the route.
1023
- const { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;
1024
- function patchFetch() {
1025
- return (0,next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__.patchFetch)({
1026
- workAsyncStorage,
1027
- workUnitAsyncStorage
1028
- });
1134
+ module.exports = require("node:worker_threads");
1135
+
1136
+ /***/ }),
1137
+
1138
+ /***/ 76760:
1139
+ /***/ ((module) => {
1140
+
1141
+ module.exports = require("node:path");
1142
+
1143
+ /***/ }),
1144
+
1145
+ /***/ 77030:
1146
+ /***/ ((module) => {
1147
+
1148
+ module.exports = require("node:net");
1149
+
1150
+ /***/ }),
1151
+
1152
+ /***/ 77598:
1153
+ /***/ ((module) => {
1154
+
1155
+ module.exports = require("node:crypto");
1156
+
1157
+ /***/ }),
1158
+
1159
+ /***/ 78361:
1160
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1161
+
1162
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1163
+ /* harmony export */ $6: () => (/* binding */ findRoute),
1164
+ /* harmony export */ Bn: () => (/* binding */ listRoutes),
1165
+ /* harmony export */ DL: () => (/* binding */ updateRoute),
1166
+ /* harmony export */ GB: () => (/* binding */ addIgnore),
1167
+ /* harmony export */ KC: () => (/* binding */ bumpRouteLastSeenTs),
1168
+ /* harmony export */ OO: () => (/* binding */ createBridge),
1169
+ /* harmony export */ Pu: () => (/* binding */ deleteBridge),
1170
+ /* harmony export */ V7: () => (/* binding */ deleteRoute),
1171
+ /* harmony export */ X9: () => (/* binding */ listBridges),
1172
+ /* harmony export */ aM: () => (/* binding */ getRoute),
1173
+ /* harmony export */ e1: () => (/* binding */ getBridge),
1174
+ /* harmony export */ gH: () => (/* binding */ getRouteLastSeenTsMap),
1175
+ /* harmony export */ kZ: () => (/* binding */ listIgnores),
1176
+ /* harmony export */ nE: () => (/* binding */ removeIgnore),
1177
+ /* harmony export */ pi: () => (/* binding */ isIgnored),
1178
+ /* harmony export */ po: () => (/* binding */ updateBridge),
1179
+ /* harmony export */ un: () => (/* binding */ createRoute)
1180
+ /* harmony export */ });
1181
+ /* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77598);
1182
+ /* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(node_crypto__WEBPACK_IMPORTED_MODULE_0__);
1183
+ /* harmony import */ var _lib_db__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(46);
1184
+ /* harmony import */ var _lib_db_transaction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(99043);
1185
+
1186
+
1187
+
1188
+ const now = ()=>new Date().toISOString();
1189
+ // ---------------------------------------------------------------------------
1190
+ // Bridge CRUD
1191
+ // ---------------------------------------------------------------------------
1192
+ function listBridges() {
1193
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridges ORDER BY created_at ASC").all();
1029
1194
  }
1030
-
1031
- async function handler(req, res, ctx) {
1032
- if (ctx.requestMeta) {
1033
- (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.setRequestMeta)(req, ctx.requestMeta);
1034
- }
1035
- if (routeModule.isDev) {
1036
- (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.addRequestMeta)(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());
1037
- }
1038
- let srcPage = "/api/v1/bridges/[id]/routes/route";
1039
- // turbopack doesn't normalize `/index` in the page name
1040
- // so we need to to process dynamic routes properly
1041
- // TODO: fix turbopack providing differing value from webpack
1042
- if (false) {} else if (srcPage === '/index') {
1043
- // we always normalize /index specifically
1044
- srcPage = '/';
1045
- }
1046
- const multiZoneDraftMode = false;
1047
- const prepareResult = await routeModule.prepare(req, res, {
1048
- srcPage,
1049
- multiZoneDraftMode
1050
- });
1051
- if (!prepareResult) {
1052
- res.statusCode = 400;
1053
- res.end('Bad Request');
1054
- ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
1055
- return null;
1056
- }
1057
- const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest, previewProps } = prepareResult;
1058
- const normalizedSrcPage = (0,next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__.normalizeAppPath)(srcPage);
1059
- // Only this route's prerenders can establish ISR or admit generated params.
1060
- 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]));
1061
- let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || isPrerendered);
1062
- const render404 = async ()=>{
1063
- // TODO: should route-module itself handle rendering the 404
1064
- if (routerServerContext == null ? void 0 : routerServerContext.render404) {
1065
- await routerServerContext.render404(req, res, parsedUrl, false);
1066
- } else {
1067
- res.end('This page could not be found');
1068
- }
1069
- return null;
1195
+ function getBridge(id) {
1196
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridges WHERE id=?").get(id) ?? null;
1197
+ }
1198
+ function createBridge(input) {
1199
+ const id = (0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomUUID)();
1200
+ const t = now();
1201
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`INSERT INTO bridges (id, kind, name, status, qr, last_error, paired_id, enabled, forward_group_profile_updates, forward_group_participants_updates, created_at, updated_at)
1202
+ VALUES (?, ?, ?, 'disconnected', NULL, NULL, NULL, 0, 1, 1, ?, ?)`).run(id, input.kind, input.name, t, t);
1203
+ return {
1204
+ id,
1205
+ kind: input.kind,
1206
+ name: input.name,
1207
+ status: "disconnected",
1208
+ qr: null,
1209
+ last_error: null,
1210
+ paired_id: null,
1211
+ enabled: 0,
1212
+ forward_group_profile_updates: 1,
1213
+ forward_group_participants_updates: 1,
1214
+ created_at: t,
1215
+ updated_at: t
1070
1216
  };
1071
- if (isIsr && !isDraftMode) {
1072
- const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];
1073
- if (prerenderInfo) {
1074
- if (prerenderInfo.fallback === false && !isPrerendered) {
1075
- if (nextConfig.adapterPath) {
1076
- return await render404();
1077
- }
1078
- throw new next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError();
1079
- }
1080
- }
1081
- }
1082
- let cacheKey = null;
1083
- if (isIsr && !routeModule.isDev && !isDraftMode) {
1084
- cacheKey = resolvedPathname;
1085
- // ensure /index and / is normalized to one key
1086
- cacheKey = cacheKey === '/index' ? '/' : cacheKey;
1087
- }
1088
- // Before rendering (which initializes component tree modules), we have to
1089
- // set the reference manifests to our global store so Server Action's
1090
- // encryption util can access to them at the top level of the page module.
1091
- if (serverActionsManifest && clientReferenceManifest) {
1092
- (0,next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__.setManifestsSingleton)({
1093
- page: srcPage,
1094
- clientReferenceManifest,
1095
- serverActionsManifest
1096
- });
1097
- }
1098
- const method = req.method || 'GET';
1099
- const tracer = (0,next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.getTracer)();
1100
- const activeSpan = tracer.getActiveScopeSpan();
1101
- const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);
1102
- const isMinimalMode = Boolean((0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'minimalMode'));
1103
- const incrementalCache = (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, previewProps, prerenderManifest, isMinimalMode);
1104
- incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();
1105
- globalThis.__incrementalCache = incrementalCache;
1106
- const context = {
1107
- params,
1108
- previewProps,
1109
- renderOpts: {
1110
- experimental: {
1111
- authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
1112
- useCacheTimeout: nextConfig.experimental.useCacheTimeout,
1113
- durableUseCacheEntries: Boolean(nextConfig.experimental.durableUseCacheEntries)
1114
- },
1115
- cacheComponents: Boolean(nextConfig.cacheComponents),
1116
- validationLevel: nextConfig.experimental.instantInsights.validationLevel,
1117
- isDraftMode,
1118
- incrementalCache,
1119
- hmrRefreshHash: (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'hmrRefreshHash'),
1120
- cacheLifeProfiles: nextConfig.cacheLife,
1121
- staticPageGenerationTimeout: nextConfig.staticPageGenerationTimeout,
1122
- waitUntil: ctx.waitUntil,
1123
- onClose: (cb)=>{
1124
- res.on('close', cb);
1125
- },
1126
- onAfterTaskError: undefined
1127
- },
1128
- sharedContext: {
1129
- buildId,
1130
- deploymentId
1131
- }
1217
+ }
1218
+ function updateBridge(id, patch) {
1219
+ const existing = getBridge(id);
1220
+ if (!existing) return null;
1221
+ const merged = {
1222
+ ...existing,
1223
+ name: patch.name ?? existing.name,
1224
+ enabled: patch.enabled ?? existing.enabled,
1225
+ status: patch.status ?? existing.status,
1226
+ qr: patch.qr !== undefined ? patch.qr : existing.qr,
1227
+ last_error: patch.last_error !== undefined ? patch.last_error : existing.last_error,
1228
+ paired_id: patch.paired_id !== undefined ? patch.paired_id : existing.paired_id,
1229
+ forward_group_profile_updates: patch.forward_group_profile_updates !== undefined ? patch.forward_group_profile_updates : existing.forward_group_profile_updates,
1230
+ forward_group_participants_updates: patch.forward_group_participants_updates !== undefined ? patch.forward_group_participants_updates : existing.forward_group_participants_updates,
1231
+ updated_at: now()
1132
1232
  };
1133
- const nodeNextReq = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextRequest(req);
1134
- const nodeNextRes = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextResponse(res);
1135
- 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));
1136
- const responseGenerator = async ({ previousCacheEntry })=>{
1137
- try {
1138
- if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {
1139
- res.statusCode = 404;
1140
- // on-demand revalidate always sets this header
1141
- res.setHeader('x-nextjs-cache', 'REVALIDATED');
1142
- res.end('This page could not be found');
1143
- return null;
1144
- }
1145
- const response = cacheKey === null ? await routeModule.handle(nextReq, context) : await routeModule.prerender(nextReq, context);
1146
- req.fetchMetrics = context.renderOpts.fetchMetrics;
1147
- let pendingWaitUntil = context.renderOpts.pendingWaitUntil;
1148
- // Attempt using provided waitUntil if available
1149
- // if it's not we fallback to sendResponse's handling
1150
- if (pendingWaitUntil) {
1151
- if (ctx.waitUntil) {
1152
- ctx.waitUntil(pendingWaitUntil);
1153
- pendingWaitUntil = undefined;
1154
- }
1155
- }
1156
- const cacheTags = context.renderOpts.collectedTags;
1157
- // If the request is for a static response, we can cache it so long
1158
- // as it's not edge.
1159
- if (isIsr) {
1160
- const blob = await response.blob();
1161
- // Copy the headers from the response.
1162
- const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.toNodeOutgoingHttpHeaders)(response.headers);
1163
- if (cacheTags) {
1164
- headers[next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER] = cacheTags;
1165
- }
1166
- if (!headers['content-type'] && blob.type) {
1167
- headers['content-type'] = blob.type;
1168
- }
1169
- const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;
1170
- 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
1171
- // explicit `expire` (e.g. via `cacheLife`). This mirrors the
1172
- // build-time fallback in `build/index.ts` so cache entries
1173
- // and the response Cache-Control header agree on the route's
1174
- // effective expire. Routes that opt out of revalidation
1175
- // (`revalidate: false`) or that are dynamic (`revalidate: 0`)
1176
- // keep `expire: undefined`.
1177
- revalidate !== false && revalidate > 0 ? nextConfig.expireTime : undefined : context.renderOpts.collectedExpire;
1178
- // Create the cache entry for the response.
1179
- const cacheEntry = {
1180
- value: {
1181
- kind: next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE,
1182
- status: response.status,
1183
- body: Buffer.from(await blob.arrayBuffer()),
1184
- headers
1185
- },
1186
- cacheControl: {
1187
- revalidate,
1188
- expire
1189
- }
1190
- };
1191
- return cacheEntry;
1192
- } else {
1193
- // send response without caching if not ISR
1194
- await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, response, pendingWaitUntil);
1195
- return null;
1196
- }
1197
- } catch (err) {
1198
- // if this is a background revalidate we need to report
1199
- // the request error here as it won't be bubbled
1200
- if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {
1201
- const silenceLog = false;
1202
- await routeModule.onRequestError(req, err, {
1203
- routerKind: 'App Router',
1204
- routePath: srcPage,
1205
- routeType: 'route',
1206
- revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
1207
- isStaticGeneration: cacheKey !== null,
1208
- isOnDemandRevalidate
1209
- })
1210
- }, silenceLog, routerServerContext);
1211
- }
1212
- throw err;
1213
- }
1233
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`UPDATE bridges
1234
+ SET name=?, enabled=?, status=?, qr=?, last_error=?, paired_id=?, forward_group_profile_updates=?, forward_group_participants_updates=?, updated_at=?
1235
+ WHERE id=?`).run(merged.name, merged.enabled, merged.status, merged.qr, merged.last_error, merged.paired_id, merged.forward_group_profile_updates, merged.forward_group_participants_updates, merged.updated_at, id);
1236
+ return merged;
1237
+ }
1238
+ function deleteBridge(id) {
1239
+ return (0,_lib_db_transaction__WEBPACK_IMPORTED_MODULE_2__/* .withDbTransaction */ .J)(()=>{
1240
+ const db = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)();
1241
+ db.prepare("DELETE FROM bridge_routes WHERE bridge_id=?").run(id);
1242
+ db.prepare("DELETE FROM bridge_ignores WHERE bridge_id=?").run(id);
1243
+ const r = db.prepare("DELETE FROM bridges WHERE id=?").run(id);
1244
+ return r.changes > 0;
1245
+ });
1246
+ }
1247
+ // ---------------------------------------------------------------------------
1248
+ // Route CRUD
1249
+ // ---------------------------------------------------------------------------
1250
+ function listRoutes(bridgeId) {
1251
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_routes WHERE bridge_id=? ORDER BY created_at ASC").all(bridgeId);
1252
+ }
1253
+ function getRoute(id) {
1254
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_routes WHERE id=?").get(id) ?? null;
1255
+ }
1256
+ function findRoute(bridgeId, remoteJid) {
1257
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_routes WHERE bridge_id=? AND remote_jid=?").get(bridgeId, remoteJid) ?? null;
1258
+ }
1259
+ function createRoute(input) {
1260
+ const id = (0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomUUID)();
1261
+ const t = now();
1262
+ const silent = input.silent_mode ? 1 : 0;
1263
+ const respondTo = input.respond_to ?? "counterpart";
1264
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`INSERT INTO bridge_routes (id, bridge_id, remote_jid, agent_id, label, silent_mode, respond_to, created_at, updated_at)
1265
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, input.bridge_id, input.remote_jid, input.agent_id, input.label ?? null, silent, respondTo, t, t);
1266
+ return {
1267
+ id,
1268
+ bridge_id: input.bridge_id,
1269
+ remote_jid: input.remote_jid,
1270
+ agent_id: input.agent_id,
1271
+ label: input.label ?? null,
1272
+ silent_mode: silent,
1273
+ respond_to: respondTo,
1274
+ last_seen_ts: null,
1275
+ created_at: t,
1276
+ updated_at: t
1214
1277
  };
1215
- const handleResponse = async (currentSpan, parentSpan)=>{
1216
- try {
1217
- var _cacheEntry_value;
1218
- const cacheEntry = await routeModule.handleResponse({
1219
- req,
1220
- nextConfig,
1221
- cacheKey,
1222
- routeKind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
1223
- isFallback: false,
1224
- previewProps,
1225
- prerenderManifest,
1226
- isRoutePPREnabled: false,
1227
- isOnDemandRevalidate,
1228
- revalidateOnlyGenerated,
1229
- responseGenerator,
1230
- waitUntil: ctx.waitUntil,
1231
- isMinimalMode
1232
- });
1233
- if (cacheEntry !== null && 'error' in cacheEntry) {
1234
- throw cacheEntry.error;
1235
- }
1236
- // we don't create a cacheEntry for ISR
1237
- if (!isIsr) {
1238
- return;
1239
- }
1240
- 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) {
1241
- var _cacheEntry_value1;
1242
- throw new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`);
1243
- }
1244
- if (!isMinimalMode) {
1245
- res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');
1246
- }
1247
- // Draft mode should never be cached
1248
- if (isDraftMode) {
1249
- res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
1250
- }
1251
- const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.fromNodeOutgoingHttpHeaders)(cacheEntry.value.headers);
1252
- if (!(isMinimalMode && isIsr)) {
1253
- headers.delete(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER);
1254
- }
1255
- // If cache control is already set on the response we don't
1256
- // override it to allow users to customize it via next.config
1257
- if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {
1258
- headers.set('Cache-Control', (0,next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__.getCacheControlHeader)(cacheEntry.cacheControl));
1259
- }
1260
- 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'.
1261
- new Response(cacheEntry.value.body, {
1262
- headers,
1263
- status: cacheEntry.value.status || 200
1264
- }));
1265
- return;
1266
- } catch (err) {
1267
- if (!(err instanceof next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError)) {
1268
- const silenceLog = false;
1269
- await routeModule.onRequestError(req, err, {
1270
- routerKind: 'App Router',
1271
- routePath: normalizedSrcPage,
1272
- routeType: 'route',
1273
- revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
1274
- isStaticGeneration: cacheKey !== null,
1275
- isOnDemandRevalidate
1276
- })
1277
- }, silenceLog, routerServerContext);
1278
- }
1279
- // rethrow so that we can handle serving error page
1280
- // If this is during static generation, throw the error again.
1281
- if (isIsr) throw err;
1282
- // Otherwise, send a 500 response unless the original response has
1283
- // already committed. In that case, preserve its status code for
1284
- // telemetry while still recording the failure and terminating a response
1285
- // that the failed pipeline left open.
1286
- if (res.headersSent) {
1287
- if (currentSpan) {
1288
- const error = err instanceof Error ? err : new Error('Unknown app route error');
1289
- currentSpan.recordException(error);
1290
- currentSpan.setStatus({
1291
- code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
1292
- message: error.message
1293
- });
1294
- currentSpan.setAttribute('error.type', error.name);
1295
- }
1296
- if (!res.writableEnded && !res.destroyed) {
1297
- res.end();
1298
- }
1299
- } else {
1300
- await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, new Response(null, {
1301
- status: 500
1302
- }));
1303
- }
1304
- return;
1305
- } finally{
1306
- ;
1307
- (()=>{
1308
- if (!currentSpan) {
1309
- return;
1310
- }
1311
- let statusCode = res.statusCode;
1312
- currentSpan.setAttributes({
1313
- 'http.status_code': statusCode,
1314
- 'next.rsc': false
1315
- });
1316
- if (statusCode && statusCode >= 500) {
1317
- // For 5xx status codes: SHOULD be set to 'Error' span status.
1318
- // x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
1319
- currentSpan.setStatus({
1320
- code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR
1321
- });
1322
- // For span status 'Error', SHOULD set 'error.type' attribute.
1323
- currentSpan.setAttribute('error.type', statusCode.toString());
1324
- }
1325
- const rootSpanAttributes = tracer.getRootSpanAttributes();
1326
- // We were unable to get attributes, probably OTEL is not enabled
1327
- if (!rootSpanAttributes) {
1328
- return;
1329
- }
1330
- if (rootSpanAttributes.get('next.span_type') !== next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest) {
1331
- console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
1332
- return;
1333
- }
1334
- const route = rootSpanAttributes.get('next.route') || normalizedSrcPage;
1335
- const name = `${method} ${route}`;
1336
- currentSpan.setAttributes({
1337
- 'next.route': route,
1338
- 'http.route': route,
1339
- 'next.span_name': name
1340
- });
1341
- currentSpan.updateName(name);
1342
- // Propagate http.route to the parent span if one exists (e.g.
1343
- // a platform-created HTTP span in adapter deployments).
1344
- if (parentSpan && parentSpan !== currentSpan) {
1345
- parentSpan.setAttribute('http.route', route);
1346
- parentSpan.updateName(name);
1347
- }
1348
- })();
1349
- }
1278
+ }
1279
+ function updateRoute(id, patch) {
1280
+ const existing = getRoute(id);
1281
+ if (!existing) return null;
1282
+ const merged = {
1283
+ ...existing,
1284
+ remote_jid: patch.remote_jid ?? existing.remote_jid,
1285
+ agent_id: patch.agent_id ?? existing.agent_id,
1286
+ label: patch.label !== undefined ? patch.label : existing.label,
1287
+ silent_mode: patch.silent_mode !== undefined ? patch.silent_mode ? 1 : 0 : existing.silent_mode,
1288
+ respond_to: patch.respond_to ?? existing.respond_to,
1289
+ updated_at: now()
1290
+ };
1291
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE bridge_routes SET remote_jid=?, agent_id=?, label=?, silent_mode=?, respond_to=?, updated_at=? WHERE id=?").run(merged.remote_jid, merged.agent_id, merged.label, merged.silent_mode, merged.respond_to, merged.updated_at, id);
1292
+ return merged;
1293
+ }
1294
+ function deleteRoute(id) {
1295
+ const r = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("DELETE FROM bridge_routes WHERE id=?").run(id);
1296
+ return r.changes > 0;
1297
+ }
1298
+ // Catch-up watermark. The WhatsApp adapter calls this with the
1299
+ // messageTimestamp (epoch ms) of the most recent inbound that reached the
1300
+ // agent. Only writes when `ts` is strictly greater than the persisted
1301
+ // value so out-of-order replays from the server-side backlog can't roll
1302
+ // the watermark backward. No-op when no route exists for the pair
1303
+ // (catch-all routing handles those at the dispatcher layer).
1304
+ function bumpRouteLastSeenTs(bridgeId, remoteJid, ts) {
1305
+ if (!Number.isFinite(ts) || ts <= 0) return;
1306
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE bridge_routes SET last_seen_ts=? WHERE bridge_id=? AND remote_jid=? AND (last_seen_ts IS NULL OR last_seen_ts < ?)").run(ts, bridgeId, remoteJid, ts);
1307
+ }
1308
+ // Per-chat watermarks for every explicitly routed chat on a bridge, loaded
1309
+ // once per upsert batch. Each chat is gated only by its own progress: a
1310
+ // bridge-wide maximum would drop chat B's offline backlog as soon as a newer
1311
+ // message from chat A had been delivered.
1312
+ function getRouteLastSeenTsMap(bridgeId) {
1313
+ const rows = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT remote_jid, last_seen_ts FROM bridge_routes WHERE bridge_id=? AND last_seen_ts IS NOT NULL").all(bridgeId);
1314
+ return new Map(rows.map((r)=>[
1315
+ r.remote_jid,
1316
+ r.last_seen_ts
1317
+ ]));
1318
+ }
1319
+ // ---------------------------------------------------------------------------
1320
+ // Ignore-list CRUD (per-bridge chat blocklist)
1321
+ //
1322
+ // Independent from routes: an ignore entry short-circuits the router even
1323
+ // when an explicit route or catch-all would otherwise match. The intent
1324
+ // is "listen to everything EXCEPT these chats" — messages from ignored
1325
+ // chats are dropped before any agent runs, so no history, no memory, no
1326
+ // tools. Delete the entry to resume forwarding.
1327
+ // ---------------------------------------------------------------------------
1328
+ function listIgnores(bridgeId) {
1329
+ return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT * FROM bridge_ignores WHERE bridge_id=? ORDER BY created_at ASC").all(bridgeId);
1330
+ }
1331
+ function isIgnored(bridgeId, remoteJid) {
1332
+ const row = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT 1 FROM bridge_ignores WHERE bridge_id=? AND remote_jid=? LIMIT 1").get(bridgeId, remoteJid);
1333
+ return !!row;
1334
+ }
1335
+ /**
1336
+ * Add a chat to the bridge's ignore list. Idempotent — re-adding the
1337
+ * same (bridge_id, remote_jid) throws a SQLite UNIQUE violation which
1338
+ * the caller can surface as a 409. Callers who want upsert semantics
1339
+ * should catch and update the label separately.
1340
+ */ function addIgnore(input) {
1341
+ const id = (0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomUUID)();
1342
+ const t = now();
1343
+ (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(`INSERT INTO bridge_ignores (id, bridge_id, remote_jid, label, created_at)
1344
+ VALUES (?, ?, ?, ?, ?)`).run(id, input.bridge_id, input.remote_jid, input.label ?? null, t);
1345
+ return {
1346
+ id,
1347
+ bridge_id: input.bridge_id,
1348
+ remote_jid: input.remote_jid,
1349
+ label: input.label ?? null,
1350
+ created_at: t
1350
1351
  };
1351
- // TODO: activeSpan code path is for when wrapped by
1352
- // next-server can be removed when this is no longer used
1353
- if (isWrappedByNextServer && activeSpan) {
1354
- await handleResponse(activeSpan, undefined);
1355
- } else {
1356
- let parentSpan = tracer.getActiveScopeSpan();
1357
- await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest, {
1358
- spanName: `${method} ${srcPage}`,
1359
- kind: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanKind.SERVER,
1360
- attributes: {
1361
- 'http.method': method,
1362
- 'http.target': req.url
1363
- }
1364
- }, (span)=>handleResponse(span, parentSpan)), undefined, !isWrappedByNextServer);
1365
- }
1352
+ }
1353
+ function removeIgnore(bridgeId, remoteJid) {
1354
+ const r = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("DELETE FROM bridge_ignores WHERE bridge_id=? AND remote_jid=?").run(bridgeId, remoteJid);
1355
+ return r.changes > 0;
1366
1356
  }
1367
1357
 
1368
- //# sourceMappingURL=app-route.js.map
1369
1358
 
1359
+ /***/ }),
1360
+
1361
+ /***/ 79428:
1362
+ /***/ ((module) => {
1363
+
1364
+ module.exports = require("buffer");
1365
+
1366
+ /***/ }),
1367
+
1368
+ /***/ 80099:
1369
+ /***/ ((module) => {
1370
+
1371
+ module.exports = require("node:sqlite");
1372
+
1373
+ /***/ }),
1374
+
1375
+ /***/ 80481:
1376
+ /***/ ((module) => {
1377
+
1378
+ module.exports = require("node:readline");
1379
+
1380
+ /***/ }),
1381
+
1382
+ /***/ 81630:
1383
+ /***/ ((module) => {
1384
+
1385
+ module.exports = require("http");
1370
1386
 
1371
1387
  /***/ }),
1372
1388
 
@@ -1398,7 +1414,7 @@ module.exports = import("@huggingface/transformers");;
1398
1414
  var __webpack_require__ = require("../../../../../../webpack-runtime.js");
1399
1415
  __webpack_require__.C(exports);
1400
1416
  var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
1401
- var __webpack_exports__ = __webpack_require__.X(0, [2970,7377,1813,7981,4992,46], () => (__webpack_exec__(83327)));
1417
+ var __webpack_exports__ = __webpack_require__.X(0, [2970,7377,1813,7981,4992,46], () => (__webpack_exec__(19517)));
1402
1418
  module.exports = __webpack_exports__;
1403
1419
 
1404
1420
  })();