@castlekit/castle 0.3.1 → 0.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 (571) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -0
  2. package/.next/standalone/.next/app-path-routes-manifest.json +29 -0
  3. package/.next/standalone/.next/build-manifest.json +20 -0
  4. package/.next/standalone/.next/package.json +1 -0
  5. package/.next/standalone/.next/prerender-manifest.json +186 -0
  6. package/.next/standalone/.next/required-server-files.json +322 -0
  7. package/.next/standalone/.next/routes-manifest.json +213 -0
  8. package/.next/standalone/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
  9. package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +17 -0
  10. package/.next/standalone/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
  11. package/.next/standalone/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
  12. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
  13. package/.next/standalone/.next/server/app/_global-error/page.js +10 -0
  14. package/.next/standalone/.next/server/app/_global-error/page.js.map +5 -0
  15. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -0
  16. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +2 -0
  17. package/.next/standalone/.next/server/app/_global-error.html +2 -0
  18. package/.next/standalone/.next/server/app/_global-error.meta +15 -0
  19. package/.next/standalone/.next/server/app/_global-error.rsc +12 -0
  20. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +5 -0
  21. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +12 -0
  22. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
  23. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +4 -0
  24. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
  25. package/.next/standalone/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
  26. package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +17 -0
  27. package/.next/standalone/.next/server/app/_not-found/page/next-font-manifest.json +11 -0
  28. package/.next/standalone/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
  29. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +4 -0
  30. package/.next/standalone/.next/server/app/_not-found/page.js +15 -0
  31. package/.next/standalone/.next/server/app/_not-found/page.js.map +5 -0
  32. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -0
  33. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +2 -0
  34. package/.next/standalone/.next/server/app/_not-found.html +1 -0
  35. package/.next/standalone/.next/server/app/_not-found.meta +16 -0
  36. package/.next/standalone/.next/server/app/_not-found.rsc +17 -0
  37. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +17 -0
  38. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
  39. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +8 -0
  40. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
  41. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +4 -0
  42. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -0
  43. package/.next/standalone/.next/server/app/api/avatars/[id]/route/app-paths-manifest.json +3 -0
  44. package/.next/standalone/.next/server/app/api/avatars/[id]/route/build-manifest.json +11 -0
  45. package/.next/standalone/.next/server/app/api/avatars/[id]/route/server-reference-manifest.json +4 -0
  46. package/.next/standalone/.next/server/app/api/avatars/[id]/route.js +9 -0
  47. package/.next/standalone/.next/server/app/api/avatars/[id]/route.js.map +5 -0
  48. package/.next/standalone/.next/server/app/api/avatars/[id]/route.js.nft.json +1 -0
  49. package/.next/standalone/.next/server/app/api/avatars/[id]/route_client-reference-manifest.js +2 -0
  50. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route/app-paths-manifest.json +3 -0
  51. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route/build-manifest.json +11 -0
  52. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route/server-reference-manifest.json +4 -0
  53. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route.js +9 -0
  54. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route.js.map +5 -0
  55. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route.js.nft.json +1 -0
  56. package/.next/standalone/.next/server/app/api/openclaw/agents/[id]/avatar/route_client-reference-manifest.js +2 -0
  57. package/.next/standalone/.next/server/app/api/openclaw/agents/route/app-paths-manifest.json +3 -0
  58. package/.next/standalone/.next/server/app/api/openclaw/agents/route/build-manifest.json +11 -0
  59. package/.next/standalone/.next/server/app/api/openclaw/agents/route/server-reference-manifest.json +4 -0
  60. package/.next/standalone/.next/server/app/api/openclaw/agents/route.js +9 -0
  61. package/.next/standalone/.next/server/app/api/openclaw/agents/route.js.map +5 -0
  62. package/.next/standalone/.next/server/app/api/openclaw/agents/route.js.nft.json +1 -0
  63. package/.next/standalone/.next/server/app/api/openclaw/agents/route_client-reference-manifest.js +2 -0
  64. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route/app-paths-manifest.json +3 -0
  65. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route/build-manifest.json +11 -0
  66. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route/server-reference-manifest.json +4 -0
  67. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route.js +13 -0
  68. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route.js.map +5 -0
  69. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route.js.nft.json +1 -0
  70. package/.next/standalone/.next/server/app/api/openclaw/agents/status/route_client-reference-manifest.js +2 -0
  71. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route/app-paths-manifest.json +3 -0
  72. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route/build-manifest.json +11 -0
  73. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route/server-reference-manifest.json +4 -0
  74. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route.js +13 -0
  75. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route.js.map +5 -0
  76. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route.js.nft.json +1 -0
  77. package/.next/standalone/.next/server/app/api/openclaw/chat/attachments/route_client-reference-manifest.js +2 -0
  78. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route/app-paths-manifest.json +3 -0
  79. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route/build-manifest.json +11 -0
  80. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route/server-reference-manifest.json +4 -0
  81. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route.js +13 -0
  82. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route.js.map +5 -0
  83. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route.js.nft.json +1 -0
  84. package/.next/standalone/.next/server/app/api/openclaw/chat/channels/route_client-reference-manifest.js +2 -0
  85. package/.next/standalone/.next/server/app/api/openclaw/chat/route/app-paths-manifest.json +3 -0
  86. package/.next/standalone/.next/server/app/api/openclaw/chat/route/build-manifest.json +11 -0
  87. package/.next/standalone/.next/server/app/api/openclaw/chat/route/server-reference-manifest.json +4 -0
  88. package/.next/standalone/.next/server/app/api/openclaw/chat/route.js +14 -0
  89. package/.next/standalone/.next/server/app/api/openclaw/chat/route.js.map +5 -0
  90. package/.next/standalone/.next/server/app/api/openclaw/chat/route.js.nft.json +1 -0
  91. package/.next/standalone/.next/server/app/api/openclaw/chat/route_client-reference-manifest.js +2 -0
  92. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route/app-paths-manifest.json +3 -0
  93. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route/build-manifest.json +11 -0
  94. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route/server-reference-manifest.json +4 -0
  95. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route.js +13 -0
  96. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route.js.map +5 -0
  97. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route.js.nft.json +1 -0
  98. package/.next/standalone/.next/server/app/api/openclaw/chat/search/route_client-reference-manifest.js +2 -0
  99. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route/app-paths-manifest.json +3 -0
  100. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route/build-manifest.json +11 -0
  101. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route/server-reference-manifest.json +4 -0
  102. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route.js +13 -0
  103. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route.js.map +5 -0
  104. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route.js.nft.json +1 -0
  105. package/.next/standalone/.next/server/app/api/openclaw/chat/storage/route_client-reference-manifest.js +2 -0
  106. package/.next/standalone/.next/server/app/api/openclaw/config/route/app-paths-manifest.json +3 -0
  107. package/.next/standalone/.next/server/app/api/openclaw/config/route/build-manifest.json +11 -0
  108. package/.next/standalone/.next/server/app/api/openclaw/config/route/server-reference-manifest.json +4 -0
  109. package/.next/standalone/.next/server/app/api/openclaw/config/route.js +9 -0
  110. package/.next/standalone/.next/server/app/api/openclaw/config/route.js.map +5 -0
  111. package/.next/standalone/.next/server/app/api/openclaw/config/route.js.nft.json +1 -0
  112. package/.next/standalone/.next/server/app/api/openclaw/config/route_client-reference-manifest.js +2 -0
  113. package/.next/standalone/.next/server/app/api/openclaw/events/route/app-paths-manifest.json +3 -0
  114. package/.next/standalone/.next/server/app/api/openclaw/events/route/build-manifest.json +11 -0
  115. package/.next/standalone/.next/server/app/api/openclaw/events/route/server-reference-manifest.json +4 -0
  116. package/.next/standalone/.next/server/app/api/openclaw/events/route.js +8 -0
  117. package/.next/standalone/.next/server/app/api/openclaw/events/route.js.map +5 -0
  118. package/.next/standalone/.next/server/app/api/openclaw/events/route.js.nft.json +1 -0
  119. package/.next/standalone/.next/server/app/api/openclaw/events/route_client-reference-manifest.js +2 -0
  120. package/.next/standalone/.next/server/app/api/openclaw/logs/route/app-paths-manifest.json +3 -0
  121. package/.next/standalone/.next/server/app/api/openclaw/logs/route/build-manifest.json +11 -0
  122. package/.next/standalone/.next/server/app/api/openclaw/logs/route/server-reference-manifest.json +4 -0
  123. package/.next/standalone/.next/server/app/api/openclaw/logs/route.js +8 -0
  124. package/.next/standalone/.next/server/app/api/openclaw/logs/route.js.map +5 -0
  125. package/.next/standalone/.next/server/app/api/openclaw/logs/route.js.nft.json +1 -0
  126. package/.next/standalone/.next/server/app/api/openclaw/logs/route_client-reference-manifest.js +2 -0
  127. package/.next/standalone/.next/server/app/api/openclaw/ping/route/app-paths-manifest.json +3 -0
  128. package/.next/standalone/.next/server/app/api/openclaw/ping/route/build-manifest.json +11 -0
  129. package/.next/standalone/.next/server/app/api/openclaw/ping/route/server-reference-manifest.json +4 -0
  130. package/.next/standalone/.next/server/app/api/openclaw/ping/route.js +9 -0
  131. package/.next/standalone/.next/server/app/api/openclaw/ping/route.js.map +5 -0
  132. package/.next/standalone/.next/server/app/api/openclaw/ping/route.js.nft.json +1 -0
  133. package/.next/standalone/.next/server/app/api/openclaw/ping/route_client-reference-manifest.js +2 -0
  134. package/.next/standalone/.next/server/app/api/openclaw/restart/route/app-paths-manifest.json +3 -0
  135. package/.next/standalone/.next/server/app/api/openclaw/restart/route/build-manifest.json +11 -0
  136. package/.next/standalone/.next/server/app/api/openclaw/restart/route/server-reference-manifest.json +4 -0
  137. package/.next/standalone/.next/server/app/api/openclaw/restart/route.js +7 -0
  138. package/.next/standalone/.next/server/app/api/openclaw/restart/route.js.map +5 -0
  139. package/.next/standalone/.next/server/app/api/openclaw/restart/route.js.nft.json +1 -0
  140. package/.next/standalone/.next/server/app/api/openclaw/restart/route_client-reference-manifest.js +2 -0
  141. package/.next/standalone/.next/server/app/api/openclaw/session/context/route/app-paths-manifest.json +3 -0
  142. package/.next/standalone/.next/server/app/api/openclaw/session/context/route/build-manifest.json +11 -0
  143. package/.next/standalone/.next/server/app/api/openclaw/session/context/route/server-reference-manifest.json +4 -0
  144. package/.next/standalone/.next/server/app/api/openclaw/session/context/route.js +14 -0
  145. package/.next/standalone/.next/server/app/api/openclaw/session/context/route.js.map +5 -0
  146. package/.next/standalone/.next/server/app/api/openclaw/session/context/route.js.nft.json +1 -0
  147. package/.next/standalone/.next/server/app/api/openclaw/session/context/route_client-reference-manifest.js +2 -0
  148. package/.next/standalone/.next/server/app/api/openclaw/session/status/route/app-paths-manifest.json +3 -0
  149. package/.next/standalone/.next/server/app/api/openclaw/session/status/route/build-manifest.json +11 -0
  150. package/.next/standalone/.next/server/app/api/openclaw/session/status/route/server-reference-manifest.json +4 -0
  151. package/.next/standalone/.next/server/app/api/openclaw/session/status/route.js +8 -0
  152. package/.next/standalone/.next/server/app/api/openclaw/session/status/route.js.map +5 -0
  153. package/.next/standalone/.next/server/app/api/openclaw/session/status/route.js.nft.json +1 -0
  154. package/.next/standalone/.next/server/app/api/openclaw/session/status/route_client-reference-manifest.js +2 -0
  155. package/.next/standalone/.next/server/app/api/openclaw/sessions/route/app-paths-manifest.json +3 -0
  156. package/.next/standalone/.next/server/app/api/openclaw/sessions/route/build-manifest.json +11 -0
  157. package/.next/standalone/.next/server/app/api/openclaw/sessions/route/server-reference-manifest.json +4 -0
  158. package/.next/standalone/.next/server/app/api/openclaw/sessions/route.js +8 -0
  159. package/.next/standalone/.next/server/app/api/openclaw/sessions/route.js.map +5 -0
  160. package/.next/standalone/.next/server/app/api/openclaw/sessions/route.js.nft.json +1 -0
  161. package/.next/standalone/.next/server/app/api/openclaw/sessions/route_client-reference-manifest.js +2 -0
  162. package/.next/standalone/.next/server/app/api/settings/avatar/route/app-paths-manifest.json +3 -0
  163. package/.next/standalone/.next/server/app/api/settings/avatar/route/build-manifest.json +11 -0
  164. package/.next/standalone/.next/server/app/api/settings/avatar/route/server-reference-manifest.json +4 -0
  165. package/.next/standalone/.next/server/app/api/settings/avatar/route.js +13 -0
  166. package/.next/standalone/.next/server/app/api/settings/avatar/route.js.map +5 -0
  167. package/.next/standalone/.next/server/app/api/settings/avatar/route.js.nft.json +1 -0
  168. package/.next/standalone/.next/server/app/api/settings/avatar/route_client-reference-manifest.js +2 -0
  169. package/.next/standalone/.next/server/app/api/settings/route/app-paths-manifest.json +3 -0
  170. package/.next/standalone/.next/server/app/api/settings/route/build-manifest.json +11 -0
  171. package/.next/standalone/.next/server/app/api/settings/route/server-reference-manifest.json +4 -0
  172. package/.next/standalone/.next/server/app/api/settings/route.js +13 -0
  173. package/.next/standalone/.next/server/app/api/settings/route.js.map +5 -0
  174. package/.next/standalone/.next/server/app/api/settings/route.js.nft.json +1 -0
  175. package/.next/standalone/.next/server/app/api/settings/route_client-reference-manifest.js +2 -0
  176. package/.next/standalone/.next/server/app/chat/[channelId]/page/app-paths-manifest.json +3 -0
  177. package/.next/standalone/.next/server/app/chat/[channelId]/page/build-manifest.json +17 -0
  178. package/.next/standalone/.next/server/app/chat/[channelId]/page/next-font-manifest.json +11 -0
  179. package/.next/standalone/.next/server/app/chat/[channelId]/page/react-loadable-manifest.json +1 -0
  180. package/.next/standalone/.next/server/app/chat/[channelId]/page/server-reference-manifest.json +4 -0
  181. package/.next/standalone/.next/server/app/chat/[channelId]/page.js +18 -0
  182. package/.next/standalone/.next/server/app/chat/[channelId]/page.js.map +5 -0
  183. package/.next/standalone/.next/server/app/chat/[channelId]/page.js.nft.json +1 -0
  184. package/.next/standalone/.next/server/app/chat/[channelId]/page_client-reference-manifest.js +2 -0
  185. package/.next/standalone/.next/server/app/chat/page/app-paths-manifest.json +3 -0
  186. package/.next/standalone/.next/server/app/chat/page/build-manifest.json +17 -0
  187. package/.next/standalone/.next/server/app/chat/page/next-font-manifest.json +11 -0
  188. package/.next/standalone/.next/server/app/chat/page/react-loadable-manifest.json +1 -0
  189. package/.next/standalone/.next/server/app/chat/page/server-reference-manifest.json +4 -0
  190. package/.next/standalone/.next/server/app/chat/page.js +18 -0
  191. package/.next/standalone/.next/server/app/chat/page.js.map +5 -0
  192. package/.next/standalone/.next/server/app/chat/page.js.nft.json +1 -0
  193. package/.next/standalone/.next/server/app/chat/page_client-reference-manifest.js +2 -0
  194. package/.next/standalone/.next/server/app/chat.html +1 -0
  195. package/.next/standalone/.next/server/app/chat.meta +15 -0
  196. package/.next/standalone/.next/server/app/chat.rsc +26 -0
  197. package/.next/standalone/.next/server/app/chat.segments/_full.segment.rsc +26 -0
  198. package/.next/standalone/.next/server/app/chat.segments/_head.segment.rsc +6 -0
  199. package/.next/standalone/.next/server/app/chat.segments/_index.segment.rsc +8 -0
  200. package/.next/standalone/.next/server/app/chat.segments/_tree.segment.rsc +4 -0
  201. package/.next/standalone/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +9 -0
  202. package/.next/standalone/.next/server/app/chat.segments/chat.segment.rsc +7 -0
  203. package/.next/standalone/.next/server/app/icon.png/route/app-paths-manifest.json +3 -0
  204. package/.next/standalone/.next/server/app/icon.png/route/build-manifest.json +11 -0
  205. package/.next/standalone/.next/server/app/icon.png/route.js +8 -0
  206. package/.next/standalone/.next/server/app/icon.png/route.js.map +5 -0
  207. package/.next/standalone/.next/server/app/icon.png/route.js.nft.json +1 -0
  208. package/.next/standalone/.next/server/app/icon.png.body +0 -0
  209. package/.next/standalone/.next/server/app/icon.png.meta +1 -0
  210. package/.next/standalone/.next/server/app/index.html +1 -0
  211. package/.next/standalone/.next/server/app/index.meta +14 -0
  212. package/.next/standalone/.next/server/app/index.rsc +23 -0
  213. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +9 -0
  214. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +23 -0
  215. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +6 -0
  216. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +8 -0
  217. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +4 -0
  218. package/.next/standalone/.next/server/app/page/app-paths-manifest.json +3 -0
  219. package/.next/standalone/.next/server/app/page/build-manifest.json +17 -0
  220. package/.next/standalone/.next/server/app/page/next-font-manifest.json +11 -0
  221. package/.next/standalone/.next/server/app/page/react-loadable-manifest.json +1 -0
  222. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +4 -0
  223. package/.next/standalone/.next/server/app/page.js +17 -0
  224. package/.next/standalone/.next/server/app/page.js.map +5 -0
  225. package/.next/standalone/.next/server/app/page.js.nft.json +1 -0
  226. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +2 -0
  227. package/.next/standalone/.next/server/app/settings/page/app-paths-manifest.json +3 -0
  228. package/.next/standalone/.next/server/app/settings/page/build-manifest.json +17 -0
  229. package/.next/standalone/.next/server/app/settings/page/next-font-manifest.json +11 -0
  230. package/.next/standalone/.next/server/app/settings/page/react-loadable-manifest.json +1 -0
  231. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -0
  232. package/.next/standalone/.next/server/app/settings/page.js +17 -0
  233. package/.next/standalone/.next/server/app/settings/page.js.map +5 -0
  234. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -0
  235. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +2 -0
  236. package/.next/standalone/.next/server/app/settings.html +1 -0
  237. package/.next/standalone/.next/server/app/settings.meta +15 -0
  238. package/.next/standalone/.next/server/app/settings.rsc +23 -0
  239. package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +23 -0
  240. package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +6 -0
  241. package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +8 -0
  242. package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +4 -0
  243. package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +9 -0
  244. package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +4 -0
  245. package/.next/standalone/.next/server/app/ui-kit/page/app-paths-manifest.json +3 -0
  246. package/.next/standalone/.next/server/app/ui-kit/page/build-manifest.json +17 -0
  247. package/.next/standalone/.next/server/app/ui-kit/page/next-font-manifest.json +11 -0
  248. package/.next/standalone/.next/server/app/ui-kit/page/react-loadable-manifest.json +1 -0
  249. package/.next/standalone/.next/server/app/ui-kit/page/server-reference-manifest.json +4 -0
  250. package/.next/standalone/.next/server/app/ui-kit/page.js +17 -0
  251. package/.next/standalone/.next/server/app/ui-kit/page.js.map +5 -0
  252. package/.next/standalone/.next/server/app/ui-kit/page.js.nft.json +1 -0
  253. package/.next/standalone/.next/server/app/ui-kit/page_client-reference-manifest.js +2 -0
  254. package/.next/standalone/.next/server/app/ui-kit.html +1 -0
  255. package/.next/standalone/.next/server/app/ui-kit.meta +15 -0
  256. package/.next/standalone/.next/server/app/ui-kit.rsc +23 -0
  257. package/.next/standalone/.next/server/app/ui-kit.segments/_full.segment.rsc +23 -0
  258. package/.next/standalone/.next/server/app/ui-kit.segments/_head.segment.rsc +6 -0
  259. package/.next/standalone/.next/server/app/ui-kit.segments/_index.segment.rsc +8 -0
  260. package/.next/standalone/.next/server/app/ui-kit.segments/_tree.segment.rsc +4 -0
  261. package/.next/standalone/.next/server/app/ui-kit.segments/ui-kit/__PAGE__.segment.rsc +9 -0
  262. package/.next/standalone/.next/server/app/ui-kit.segments/ui-kit.segment.rsc +4 -0
  263. package/.next/standalone/.next/server/app-paths-manifest.json +29 -0
  264. package/.next/standalone/.next/server/chunks/[externals]_next_dist_a6d89067._.js +3 -0
  265. package/.next/standalone/.next/server/chunks/[root-of-the-server]__2824c41d._.js +3 -0
  266. package/.next/standalone/.next/server/chunks/[root-of-the-server]__28c35c7d._.js +11 -0
  267. package/.next/standalone/.next/server/chunks/[root-of-the-server]__2aa60cfc._.js +3 -0
  268. package/.next/standalone/.next/server/chunks/[root-of-the-server]__2e91224f._.js +3 -0
  269. package/.next/standalone/.next/server/chunks/[root-of-the-server]__361bce14._.js +3 -0
  270. package/.next/standalone/.next/server/chunks/[root-of-the-server]__36b434e7._.js +3 -0
  271. package/.next/standalone/.next/server/chunks/[root-of-the-server]__47efedcd._.js +3 -0
  272. package/.next/standalone/.next/server/chunks/[root-of-the-server]__4b157e5a._.js +3 -0
  273. package/.next/standalone/.next/server/chunks/[root-of-the-server]__56815e49._.js +3 -0
  274. package/.next/standalone/.next/server/chunks/[root-of-the-server]__5ef29d48._.js +3 -0
  275. package/.next/standalone/.next/server/chunks/[root-of-the-server]__5f6aa90c._.js +3 -0
  276. package/.next/standalone/.next/server/chunks/[root-of-the-server]__7114163c._.js +3 -0
  277. package/.next/standalone/.next/server/chunks/[root-of-the-server]__8f5ebbc3._.js +7 -0
  278. package/.next/standalone/.next/server/chunks/[root-of-the-server]__93758a40._.js +3 -0
  279. package/.next/standalone/.next/server/chunks/[root-of-the-server]__a80a1099._.js +31 -0
  280. package/.next/standalone/.next/server/chunks/[root-of-the-server]__af3cebf7._.js +138 -0
  281. package/.next/standalone/.next/server/chunks/[root-of-the-server]__b3182da1._.js +4 -0
  282. package/.next/standalone/.next/server/chunks/[root-of-the-server]__b39f673e._.js +3 -0
  283. package/.next/standalone/.next/server/chunks/[root-of-the-server]__bbd3b47c._.js +3 -0
  284. package/.next/standalone/.next/server/chunks/[root-of-the-server]__c223b7d3._.js +3 -0
  285. package/.next/standalone/.next/server/chunks/[root-of-the-server]__c7ce1c43._.js +4 -0
  286. package/.next/standalone/.next/server/chunks/[root-of-the-server]__e50da949._.js +3 -0
  287. package/.next/standalone/.next/server/chunks/[root-of-the-server]__f41df55c._.js +3 -0
  288. package/.next/standalone/.next/server/chunks/[root-of-the-server]__faf9ad2e._.js +3 -0
  289. package/.next/standalone/.next/server/chunks/[root-of-the-server]__fe76fb40._.js +3 -0
  290. package/.next/standalone/.next/server/chunks/[turbopack]_runtime.js +795 -0
  291. package/.next/standalone/.next/server/chunks/_b137597c._.js +3 -0
  292. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_avatars_[id]_route_actions_21e11acd.js +3 -0
  293. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_agents_[id]_avatar_route_actions_1cb9863b.js +3 -0
  294. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_agents_route_actions_82d135b1.js +3 -0
  295. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_agents_status_route_actions_0b88c8a6.js +3 -0
  296. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_chat_attachments_route_actions_07ce0270.js +3 -0
  297. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_chat_channels_route_actions_945f54a8.js +3 -0
  298. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_chat_route_actions_cd398c8d.js +3 -0
  299. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_chat_search_route_actions_d1599780.js +3 -0
  300. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_chat_storage_route_actions_fd3e7369.js +3 -0
  301. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_config_route_actions_3c2a30de.js +3 -0
  302. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_events_route_actions_24b1acfe.js +3 -0
  303. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_logs_route_actions_151f8335.js +3 -0
  304. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_ping_route_actions_3079a70c.js +3 -0
  305. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_restart_route_actions_25b671bb.js +3 -0
  306. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_session_context_route_actions_14ebc427.js +3 -0
  307. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_session_status_route_actions_060ba4f4.js +3 -0
  308. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_openclaw_sessions_route_actions_0c00f4a9.js +3 -0
  309. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_settings_avatar_route_actions_e222d284.js +3 -0
  310. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_settings_route_actions_a476013b.js +3 -0
  311. package/.next/standalone/.next/server/chunks/_next-internal_server_app_icon_png_route_actions_fa3562e2.js +3 -0
  312. package/.next/standalone/.next/server/chunks/node_modules_drizzle-orm_a549359e._.js +3 -0
  313. package/.next/standalone/.next/server/chunks/node_modules_drizzle-orm_f8415f57._.js +4 -0
  314. package/.next/standalone/.next/server/chunks/node_modules_drizzle-orm_index_d5f6a514.js +3 -0
  315. package/.next/standalone/.next/server/chunks/node_modules_next_1402a1da._.js +17 -0
  316. package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_97dac613.js +3 -0
  317. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__03219135._.js +3 -0
  318. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0f7b131d._.js +3 -0
  319. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1690ee0d._.js +10 -0
  320. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__31de57f6._.js +3 -0
  321. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__4e637dc9._.js +3 -0
  322. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__55ece10e._.js +3 -0
  323. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__69f5a83d._.js +3 -0
  324. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__a457c799._.js +3 -0
  325. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__a5ce2f72._.js +3 -0
  326. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__aecdcbb6._.js +3 -0
  327. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__b4ed2322._.js +3 -0
  328. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__ca05f4a0._.js +4 -0
  329. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__e2f86be8._.js +3 -0
  330. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__e375a3a7._.js +3 -0
  331. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__ea12eca9._.js +3 -0
  332. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__ed06de41._.js +3 -0
  333. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__f907a2ce._.js +3 -0
  334. package/.next/standalone/.next/server/chunks/ssr/[turbopack]_runtime.js +795 -0
  335. package/.next/standalone/.next/server/chunks/ssr/_0bb5ce6a._.js +3 -0
  336. package/.next/standalone/.next/server/chunks/ssr/_30d6fdaa._.js +3 -0
  337. package/.next/standalone/.next/server/chunks/ssr/_3b2b917b._.js +4 -0
  338. package/.next/standalone/.next/server/chunks/ssr/_3bf0a72b._.js +4 -0
  339. package/.next/standalone/.next/server/chunks/ssr/_539da066._.js +4 -0
  340. package/.next/standalone/.next/server/chunks/ssr/_6caa74c9._.js +3 -0
  341. package/.next/standalone/.next/server/chunks/ssr/_7a67de23._.js +3 -0
  342. package/.next/standalone/.next/server/chunks/ssr/_7b52fbee._.js +3 -0
  343. package/.next/standalone/.next/server/chunks/ssr/_84fe35ec._.js +3 -0
  344. package/.next/standalone/.next/server/chunks/ssr/_ac1c4494._.js +3 -0
  345. package/.next/standalone/.next/server/chunks/ssr/_ca23d3b0._.js +4 -0
  346. package/.next/standalone/.next/server/chunks/ssr/_d04daf62._.js +3 -0
  347. package/.next/standalone/.next/server/chunks/ssr/_e6db8164._.js +4 -0
  348. package/.next/standalone/.next/server/chunks/ssr/_ef4d503b._.js +3 -0
  349. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_75761787.js +3 -0
  350. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_554ec2bf.js +3 -0
  351. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_chat_[channelId]_page_actions_6220414d.js +3 -0
  352. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_chat_page_actions_c92d15a6.js +3 -0
  353. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_page_actions_39d4fc33.js +3 -0
  354. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_settings_page_actions_840229cd.js +3 -0
  355. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_ui-kit_page_actions_8486bfbd.js +3 -0
  356. package/.next/standalone/.next/server/chunks/ssr/node_modules_45598cbe._.js +6 -0
  357. package/.next/standalone/.next/server/chunks/ssr/node_modules_d3586d0c._.js +3 -0
  358. package/.next/standalone/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_95f27697._.js +3 -0
  359. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_08570d7f._.js +4 -0
  360. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_65e60196._.js +3 -0
  361. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_681edc0a._.js +6 -0
  362. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_client_components_9774470f._.js +3 -0
  363. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_45780354.js +3 -0
  364. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_ece394eb.js +3 -0
  365. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_15817684.js +3 -0
  366. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_02f39477.js +4 -0
  367. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_f9713a08._.js +3 -0
  368. package/.next/standalone/.next/server/chunks/ssr/src_app_0c8a77b8._.js +3 -0
  369. package/.next/standalone/.next/server/chunks/ssr/src_app_chat_layout_tsx_31cd0231._.js +3 -0
  370. package/.next/standalone/.next/server/chunks/ssr/src_app_chat_layout_tsx_be09920b._.js +3 -0
  371. package/.next/standalone/.next/server/chunks/ssr/src_app_chat_page_tsx_2a0793ad._.js +3 -0
  372. package/.next/standalone/.next/server/edge/chunks/[root-of-the-server]__25fe7590._.js +15 -0
  373. package/.next/standalone/.next/server/edge/chunks/node_modules_next_dist_esm_build_templates_edge-wrapper_78fa9d6a.js +3 -0
  374. package/.next/standalone/.next/server/edge/chunks/turbopack-node_modules_next_dist_esm_build_templates_edge-wrapper_99e3e1b8.js +6 -0
  375. package/.next/standalone/.next/server/functions-config-manifest.json +6 -0
  376. package/.next/standalone/.next/server/middleware-build-manifest.js +21 -0
  377. package/.next/standalone/.next/server/middleware-manifest.json +33 -0
  378. package/.next/standalone/.next/server/next-font-manifest.js +1 -0
  379. package/.next/standalone/.next/server/next-font-manifest.json +31 -0
  380. package/.next/standalone/.next/server/pages/404.html +1 -0
  381. package/.next/standalone/.next/server/pages/500.html +2 -0
  382. package/.next/standalone/.next/server/pages-manifest.json +4 -0
  383. package/.next/standalone/.next/server/server-reference-manifest.js +1 -0
  384. package/.next/standalone/.next/server/server-reference-manifest.json +5 -0
  385. package/.next/standalone/.next/static/R01Vc6rRTS_XwAg0Y8ERm/_buildManifest.js +11 -0
  386. package/.next/standalone/.next/static/R01Vc6rRTS_XwAg0Y8ERm/_clientMiddlewareManifest.json +6 -0
  387. package/.next/standalone/.next/static/R01Vc6rRTS_XwAg0Y8ERm/_ssgManifest.js +1 -0
  388. package/.next/standalone/.next/static/chunks/1c362778d42e76b0.js +1 -0
  389. package/.next/standalone/.next/static/chunks/2b48886a383c2e37.js +1 -0
  390. package/.next/standalone/.next/static/chunks/3c2b51fd3ab2ac34.css +3 -0
  391. package/.next/standalone/.next/static/chunks/3fef23e63934711e.js +1 -0
  392. package/.next/standalone/.next/static/chunks/5781c606560d6f13.js +1 -0
  393. package/.next/standalone/.next/static/chunks/5a1105a61e9390f8.js +1 -0
  394. package/.next/standalone/.next/static/chunks/6468938847443ae8.js +1 -0
  395. package/.next/standalone/.next/static/chunks/76c064224d953678.js +4 -0
  396. package/.next/standalone/.next/static/chunks/77868ed664ba62d2.js +1 -0
  397. package/.next/standalone/.next/static/chunks/7de9141b1af425c3.js +1 -0
  398. package/.next/standalone/.next/static/chunks/868f09ea8b0a7649.js +1 -0
  399. package/.next/standalone/.next/static/chunks/97d384ea34b6283a.js +1 -0
  400. package/.next/standalone/.next/static/chunks/a6dad97d9634a72d.js +1 -0
  401. package/.next/standalone/.next/static/chunks/a6dad97d9634a72d.js.map +1 -0
  402. package/.next/standalone/.next/static/chunks/afd967a636289a73.js +1 -0
  403. package/.next/standalone/.next/static/chunks/bffbc071b1075ac3.js +1 -0
  404. package/.next/standalone/.next/static/chunks/d11263c7e8894d27.js +1 -0
  405. package/.next/standalone/.next/static/chunks/f1f489dad7e35d90.js +2 -0
  406. package/.next/standalone/.next/static/chunks/turbopack-1da073e19f58dee0.js +4 -0
  407. package/.next/standalone/.next/static/media/4fa387ec64143e14-s.c1fdd6c2.woff2 +0 -0
  408. package/.next/standalone/.next/static/media/7178b3e590c64307-s.b97b3418.woff2 +0 -0
  409. package/.next/standalone/.next/static/media/797e433ab948586e-s.p.dbea232f.woff2 +0 -0
  410. package/.next/standalone/.next/static/media/8a480f0b521d4e75-s.8e0177b5.woff2 +0 -0
  411. package/.next/standalone/.next/static/media/bbc41e54d2fcbd21-s.799d8ef8.woff2 +0 -0
  412. package/.next/standalone/.next/static/media/caa3a2e1cccd8315-s.p.853070df.woff2 +0 -0
  413. package/.next/standalone/.next/static/media/icon.4cc5e0bd.png +0 -0
  414. package/.next/standalone/CHANGELOG.md +182 -0
  415. package/.next/standalone/CONTRIBUTING.md +46 -0
  416. package/.next/standalone/LICENSE +21 -0
  417. package/.next/standalone/README.md +54 -0
  418. package/.next/standalone/SECURITY.md +80 -0
  419. package/.next/standalone/bin/castle.js +193 -0
  420. package/.next/standalone/castle_secrets.py +29 -0
  421. package/.next/standalone/drizzle.config.ts +7 -0
  422. package/.next/standalone/index.js +1 -0
  423. package/.next/standalone/install.sh +776 -0
  424. package/.next/standalone/next.config.ts +9 -0
  425. package/.next/standalone/package-lock.json +8115 -0
  426. package/.next/standalone/package.json +105 -0
  427. package/.next/standalone/postcss.config.mjs +7 -0
  428. package/.next/standalone/server.js +44 -0
  429. package/.next/standalone/src/app/api/avatars/[id]/route.ts +172 -0
  430. package/.next/standalone/src/app/api/openclaw/agents/[id]/avatar/route.ts +216 -0
  431. package/.next/standalone/src/app/api/openclaw/agents/route.ts +149 -0
  432. package/.next/standalone/src/app/api/openclaw/agents/status/route.ts +55 -0
  433. package/.next/standalone/src/app/api/openclaw/chat/attachments/route.ts +230 -0
  434. package/.next/standalone/src/app/api/openclaw/chat/channels/route.ts +217 -0
  435. package/.next/standalone/src/app/api/openclaw/chat/route.ts +283 -0
  436. package/.next/standalone/src/app/api/openclaw/chat/search/route.ts +150 -0
  437. package/.next/standalone/src/app/api/openclaw/chat/storage/route.ts +75 -0
  438. package/.next/standalone/src/app/api/openclaw/config/route.ts +137 -0
  439. package/.next/standalone/src/app/api/openclaw/events/route.ts +140 -0
  440. package/.next/standalone/src/app/api/openclaw/logs/route.ts +74 -0
  441. package/.next/standalone/src/app/api/openclaw/ping/route.ts +73 -0
  442. package/.next/standalone/src/app/api/openclaw/restart/route.ts +73 -0
  443. package/.next/standalone/src/app/api/openclaw/session/context/route.ts +163 -0
  444. package/.next/standalone/src/app/api/openclaw/session/status/route.ts +210 -0
  445. package/.next/standalone/src/app/api/openclaw/sessions/route.ts +64 -0
  446. package/.next/standalone/src/app/api/settings/avatar/route.ts +190 -0
  447. package/.next/standalone/src/app/api/settings/route.ts +88 -0
  448. package/.next/standalone/src/app/chat/[channelId]/error-boundary.tsx +64 -0
  449. package/.next/standalone/src/app/chat/[channelId]/page.tsx +385 -0
  450. package/.next/standalone/src/app/chat/layout.tsx +96 -0
  451. package/.next/standalone/src/app/chat/page.tsx +52 -0
  452. package/.next/standalone/src/app/globals.css +383 -0
  453. package/.next/standalone/src/app/icon.png +0 -0
  454. package/.next/standalone/src/app/layout.tsx +48 -0
  455. package/.next/standalone/src/app/page.tsx +390 -0
  456. package/.next/standalone/src/app/settings/page.tsx +300 -0
  457. package/.next/standalone/src/app/ui-kit/page.tsx +684 -0
  458. package/.next/standalone/src/cli/onboarding.ts +810 -0
  459. package/.next/standalone/src/components/chat/agent-mention-popup.tsx +89 -0
  460. package/.next/standalone/src/components/chat/archived-channels.tsx +190 -0
  461. package/.next/standalone/src/components/chat/channel-list.tsx +140 -0
  462. package/.next/standalone/src/components/chat/chat-input.tsx +328 -0
  463. package/.next/standalone/src/components/chat/create-channel-dialog.tsx +171 -0
  464. package/.next/standalone/src/components/chat/markdown-content.tsx +205 -0
  465. package/.next/standalone/src/components/chat/message-bubble.tsx +168 -0
  466. package/.next/standalone/src/components/chat/message-list.tsx +666 -0
  467. package/.next/standalone/src/components/chat/message-queue.tsx +68 -0
  468. package/.next/standalone/src/components/chat/session-divider.tsx +61 -0
  469. package/.next/standalone/src/components/chat/session-stats-panel.tsx +444 -0
  470. package/.next/standalone/src/components/chat/storage-indicator.tsx +76 -0
  471. package/.next/standalone/src/components/dashboard/agent-status.tsx +107 -0
  472. package/.next/standalone/src/components/dashboard/glass-card.tsx +28 -0
  473. package/.next/standalone/src/components/dashboard/goal-widget.tsx +174 -0
  474. package/.next/standalone/src/components/dashboard/greeting-widget.tsx +78 -0
  475. package/.next/standalone/src/components/dashboard/index.ts +7 -0
  476. package/.next/standalone/src/components/dashboard/stat-widget.tsx +61 -0
  477. package/.next/standalone/src/components/dashboard/stock-widget.tsx +164 -0
  478. package/.next/standalone/src/components/dashboard/weather-widget.tsx +68 -0
  479. package/.next/standalone/src/components/icons/castle-icon.tsx +21 -0
  480. package/.next/standalone/src/components/kanban/index.ts +3 -0
  481. package/.next/standalone/src/components/kanban/kanban-board.tsx +391 -0
  482. package/.next/standalone/src/components/kanban/kanban-card.tsx +137 -0
  483. package/.next/standalone/src/components/kanban/kanban-column.tsx +98 -0
  484. package/.next/standalone/src/components/layout/index.ts +4 -0
  485. package/.next/standalone/src/components/layout/page-header.tsx +20 -0
  486. package/.next/standalone/src/components/layout/sidebar.tsx +209 -0
  487. package/.next/standalone/src/components/layout/theme-toggle.tsx +59 -0
  488. package/.next/standalone/src/components/layout/user-menu.tsx +97 -0
  489. package/.next/standalone/src/components/providers/presence-provider.tsx +8 -0
  490. package/.next/standalone/src/components/providers/search-provider.tsx +110 -0
  491. package/.next/standalone/src/components/search/search-dialog.tsx +269 -0
  492. package/.next/standalone/src/components/ui/alert.tsx +72 -0
  493. package/.next/standalone/src/components/ui/avatar.tsx +89 -0
  494. package/.next/standalone/src/components/ui/badge.tsx +39 -0
  495. package/.next/standalone/src/components/ui/button.tsx +43 -0
  496. package/.next/standalone/src/components/ui/card.tsx +107 -0
  497. package/.next/standalone/src/components/ui/checkbox.tsx +56 -0
  498. package/.next/standalone/src/components/ui/clock.tsx +171 -0
  499. package/.next/standalone/src/components/ui/dialog.tsx +111 -0
  500. package/.next/standalone/src/components/ui/index.ts +34 -0
  501. package/.next/standalone/src/components/ui/input.tsx +112 -0
  502. package/.next/standalone/src/components/ui/option-card.tsx +151 -0
  503. package/.next/standalone/src/components/ui/progress.tsx +103 -0
  504. package/.next/standalone/src/components/ui/radio.tsx +109 -0
  505. package/.next/standalone/src/components/ui/select.tsx +46 -0
  506. package/.next/standalone/src/components/ui/slider.tsx +62 -0
  507. package/.next/standalone/src/components/ui/tabs.tsx +132 -0
  508. package/.next/standalone/src/components/ui/toggle-group.tsx +85 -0
  509. package/.next/standalone/src/components/ui/toggle.tsx +78 -0
  510. package/.next/standalone/src/components/ui/tooltip.tsx +162 -0
  511. package/.next/standalone/src/components/ui/twemoji-text.tsx +37 -0
  512. package/.next/standalone/src/components/ui/uptime.tsx +106 -0
  513. package/.next/standalone/src/lib/api-security.ts +188 -0
  514. package/.next/standalone/src/lib/config.ts +227 -0
  515. package/.next/standalone/src/lib/date-utils.ts +79 -0
  516. package/.next/standalone/src/lib/db/index.ts +652 -0
  517. package/.next/standalone/src/lib/db/queries.ts +1144 -0
  518. package/.next/standalone/src/lib/db/schema.ts +164 -0
  519. package/.next/standalone/src/lib/device-identity.ts +303 -0
  520. package/.next/standalone/src/lib/gateway-connection.ts +649 -0
  521. package/.next/standalone/src/lib/hooks/use-agent-status.ts +251 -0
  522. package/.next/standalone/src/lib/hooks/use-chat.ts +753 -0
  523. package/.next/standalone/src/lib/hooks/use-compaction-events.ts +132 -0
  524. package/.next/standalone/src/lib/hooks/use-context-boundary.ts +82 -0
  525. package/.next/standalone/src/lib/hooks/use-openclaw.ts +185 -0
  526. package/.next/standalone/src/lib/hooks/use-search.ts +114 -0
  527. package/.next/standalone/src/lib/hooks/use-session-stats.ts +60 -0
  528. package/.next/standalone/src/lib/hooks/use-user-settings.ts +46 -0
  529. package/.next/standalone/src/lib/sse-singleton.ts +184 -0
  530. package/.next/standalone/src/lib/types/chat.ts +202 -0
  531. package/.next/standalone/src/lib/types/search.ts +60 -0
  532. package/.next/standalone/src/lib/utils.ts +6 -0
  533. package/.next/standalone/src/middleware.ts +52 -0
  534. package/.next/standalone/tsconfig.json +34 -0
  535. package/.next/standalone/vitest.config.ts +14 -0
  536. package/.next/standalone/vitest.stress.config.ts +14 -0
  537. package/.next/standalone/zizmor.yml +17 -0
  538. package/.next/static/R01Vc6rRTS_XwAg0Y8ERm/_buildManifest.js +11 -0
  539. package/.next/static/R01Vc6rRTS_XwAg0Y8ERm/_clientMiddlewareManifest.json +6 -0
  540. package/.next/static/R01Vc6rRTS_XwAg0Y8ERm/_ssgManifest.js +1 -0
  541. package/.next/static/chunks/1c362778d42e76b0.js +1 -0
  542. package/.next/static/chunks/2b48886a383c2e37.js +1 -0
  543. package/.next/static/chunks/3c2b51fd3ab2ac34.css +3 -0
  544. package/.next/static/chunks/3fef23e63934711e.js +1 -0
  545. package/.next/static/chunks/5781c606560d6f13.js +1 -0
  546. package/.next/static/chunks/5a1105a61e9390f8.js +1 -0
  547. package/.next/static/chunks/6468938847443ae8.js +1 -0
  548. package/.next/static/chunks/76c064224d953678.js +4 -0
  549. package/.next/static/chunks/77868ed664ba62d2.js +1 -0
  550. package/.next/static/chunks/7de9141b1af425c3.js +1 -0
  551. package/.next/static/chunks/868f09ea8b0a7649.js +1 -0
  552. package/.next/static/chunks/97d384ea34b6283a.js +1 -0
  553. package/.next/static/chunks/a6dad97d9634a72d.js +1 -0
  554. package/.next/static/chunks/a6dad97d9634a72d.js.map +1 -0
  555. package/.next/static/chunks/afd967a636289a73.js +1 -0
  556. package/.next/static/chunks/bffbc071b1075ac3.js +1 -0
  557. package/.next/static/chunks/d11263c7e8894d27.js +1 -0
  558. package/.next/static/chunks/f1f489dad7e35d90.js +2 -0
  559. package/.next/static/chunks/turbopack-1da073e19f58dee0.js +4 -0
  560. package/.next/static/media/4fa387ec64143e14-s.c1fdd6c2.woff2 +0 -0
  561. package/.next/static/media/7178b3e590c64307-s.b97b3418.woff2 +0 -0
  562. package/.next/static/media/797e433ab948586e-s.p.dbea232f.woff2 +0 -0
  563. package/.next/static/media/8a480f0b521d4e75-s.8e0177b5.woff2 +0 -0
  564. package/.next/static/media/bbc41e54d2fcbd21-s.799d8ef8.woff2 +0 -0
  565. package/.next/static/media/caa3a2e1cccd8315-s.p.853070df.woff2 +0 -0
  566. package/.next/static/media/icon.4cc5e0bd.png +0 -0
  567. package/LICENSE +1 -1
  568. package/bin/castle.js +17 -0
  569. package/next.config.ts +1 -0
  570. package/package.json +6 -1
  571. package/src/cli/onboarding.ts +102 -28
@@ -0,0 +1,1144 @@
1
+ import { eq, desc, asc, and, lt, gt, sql, inArray } from "drizzle-orm";
2
+ import { v4 as uuid } from "uuid";
3
+ import { getDb } from "./index";
4
+ import {
5
+ channels,
6
+ channelAgents,
7
+ sessions,
8
+ messages,
9
+ messageAttachments,
10
+ messageReactions,
11
+ recentSearches,
12
+ settings,
13
+ agentStatuses,
14
+ } from "./schema";
15
+ import type {
16
+ Channel,
17
+ ChatMessage,
18
+ ChannelSession,
19
+ MessageAttachment,
20
+ MessageReaction,
21
+ } from "@/lib/types/chat";
22
+
23
+ // ============================================================================
24
+ // Channels
25
+ // ============================================================================
26
+
27
+ export function createChannel(
28
+ name: string,
29
+ defaultAgentId: string,
30
+ agentIds: string[] = []
31
+ ): Channel {
32
+ const db = getDb();
33
+ const id = uuid();
34
+ const now = Date.now();
35
+
36
+ db.insert(channels).values({
37
+ id,
38
+ name,
39
+ defaultAgentId,
40
+ createdAt: now,
41
+ updatedAt: now,
42
+ }).run();
43
+
44
+ // Add agents to junction table
45
+ const agents = agentIds.length > 0 ? agentIds : [defaultAgentId];
46
+ for (const agentId of agents) {
47
+ db.insert(channelAgents)
48
+ .values({ channelId: id, agentId })
49
+ .run();
50
+ }
51
+
52
+ return {
53
+ id,
54
+ name,
55
+ defaultAgentId,
56
+ agents,
57
+ createdAt: now,
58
+ };
59
+ }
60
+
61
+ export function getChannels(includeArchived = false): Channel[] {
62
+ const db = getDb();
63
+
64
+ const query = includeArchived
65
+ ? db.select().from(channels).where(sql`${channels.archivedAt} IS NOT NULL`).orderBy(desc(channels.archivedAt))
66
+ : db.select().from(channels).where(sql`${channels.archivedAt} IS NULL`).orderBy(desc(channels.createdAt));
67
+
68
+ const rows = query.all();
69
+ if (rows.length === 0) return [];
70
+
71
+ // Batch-load all channel agents in one query (avoids N+1)
72
+ const channelIds = rows.map((r) => r.id);
73
+ const allAgentRows = db
74
+ .select()
75
+ .from(channelAgents)
76
+ .where(inArray(channelAgents.channelId, channelIds))
77
+ .all();
78
+
79
+ const agentsByChannel = new Map<string, string[]>();
80
+ for (const a of allAgentRows) {
81
+ const list = agentsByChannel.get(a.channelId) || [];
82
+ list.push(a.agentId);
83
+ agentsByChannel.set(a.channelId, list);
84
+ }
85
+
86
+ return rows.map((row) => ({
87
+ id: row.id,
88
+ name: row.name,
89
+ defaultAgentId: row.defaultAgentId,
90
+ agents: agentsByChannel.get(row.id) || [],
91
+ createdAt: row.createdAt,
92
+ archivedAt: row.archivedAt ?? null,
93
+ }));
94
+ }
95
+
96
+ export function getChannel(id: string): Channel | null {
97
+ const db = getDb();
98
+ const row = db.select().from(channels).where(eq(channels.id, id)).get();
99
+ if (!row) return null;
100
+
101
+ const agentRows = db
102
+ .select()
103
+ .from(channelAgents)
104
+ .where(eq(channelAgents.channelId, id))
105
+ .all();
106
+
107
+ return {
108
+ id: row.id,
109
+ name: row.name,
110
+ defaultAgentId: row.defaultAgentId,
111
+ agents: agentRows.map((a) => a.agentId),
112
+ createdAt: row.createdAt,
113
+ archivedAt: row.archivedAt ?? null,
114
+ };
115
+ }
116
+
117
+ export function updateChannel(
118
+ id: string,
119
+ updates: { name?: string; defaultAgentId?: string }
120
+ ): boolean {
121
+ const db = getDb();
122
+ const result = db
123
+ .update(channels)
124
+ .set({ ...updates, updatedAt: Date.now() })
125
+ .where(eq(channels.id, id))
126
+ .run();
127
+ return result.changes > 0;
128
+ }
129
+
130
+ export function deleteChannel(id: string): boolean {
131
+ const db = getDb();
132
+
133
+ // Access underlying better-sqlite3 for raw SQL operations
134
+ type SqliteClient = {
135
+ prepare: (sql: string) => { run: (...params: unknown[]) => { changes: number }; all: (...params: unknown[]) => Record<string, unknown>[] };
136
+ exec: (sql: string) => void;
137
+ };
138
+ type DrizzleDb = { session: { client: SqliteClient } };
139
+ const sqlite = (db as unknown as DrizzleDb).session.client;
140
+
141
+ // Delete dependent records: attachments/reactions → messages → sessions → agents → channel.
142
+ // The FTS5 delete trigger fires for each message deletion to keep FTS in sync.
143
+ // If the trigger fails (FTS out of sync), we catch and rebuild FTS afterwards.
144
+ let needsFtsRebuild = false;
145
+
146
+ try {
147
+ const msgIds = db
148
+ .select({ id: messages.id })
149
+ .from(messages)
150
+ .where(eq(messages.channelId, id))
151
+ .all()
152
+ .map((r) => r.id);
153
+
154
+ if (msgIds.length > 0) {
155
+ db.delete(messageAttachments)
156
+ .where(inArray(messageAttachments.messageId, msgIds))
157
+ .run();
158
+ db.delete(messageReactions)
159
+ .where(inArray(messageReactions.messageId, msgIds))
160
+ .run();
161
+ }
162
+
163
+ try {
164
+ db.delete(messages).where(eq(messages.channelId, id)).run();
165
+ } catch (err) {
166
+ // FTS trigger failed — likely FTS out of sync. Delete messages without trigger,
167
+ // then rebuild FTS from scratch.
168
+ console.warn("[deleteChannel] FTS trigger failed during message deletion, will rebuild:", (err as Error).message);
169
+ sqlite.exec("DROP TRIGGER IF EXISTS messages_fts_delete");
170
+ db.delete(messages).where(eq(messages.channelId, id)).run();
171
+ needsFtsRebuild = true;
172
+ }
173
+
174
+ db.delete(sessions).where(eq(sessions.channelId, id)).run();
175
+ db.delete(channelAgents).where(eq(channelAgents.channelId, id)).run();
176
+
177
+ const result = db.delete(channels).where(eq(channels.id, id)).run();
178
+ return result.changes > 0;
179
+ } finally {
180
+ if (needsFtsRebuild) {
181
+ // Recreate the trigger and fully resync FTS from the messages table
182
+ sqlite.exec(`
183
+ CREATE TRIGGER IF NOT EXISTS messages_fts_delete AFTER DELETE ON messages BEGIN
184
+ INSERT INTO messages_fts(messages_fts, rowid, content) VALUES ('delete', OLD.rowid, OLD.content);
185
+ END;
186
+ `);
187
+ sqlite.exec("DELETE FROM messages_fts");
188
+ sqlite.exec(
189
+ "INSERT INTO messages_fts(rowid, content) SELECT rowid, content FROM messages"
190
+ );
191
+ console.log("[deleteChannel] FTS5 index rebuilt successfully.");
192
+ }
193
+ }
194
+ }
195
+
196
+ export function archiveChannel(id: string): boolean {
197
+ const db = getDb();
198
+ const result = db
199
+ .update(channels)
200
+ .set({ archivedAt: Date.now() })
201
+ .where(eq(channels.id, id))
202
+ .run();
203
+ return result.changes > 0;
204
+ }
205
+
206
+ export function restoreChannel(id: string): boolean {
207
+ const db = getDb();
208
+ const result = db
209
+ .update(channels)
210
+ .set({ archivedAt: null })
211
+ .where(eq(channels.id, id))
212
+ .run();
213
+ return result.changes > 0;
214
+ }
215
+
216
+ /**
217
+ * Mark a channel as accessed (updates last_accessed_at to now).
218
+ */
219
+ export function touchChannel(id: string): void {
220
+ const db = getDb();
221
+ db.update(channels)
222
+ .set({ lastAccessedAt: Date.now() })
223
+ .where(eq(channels.id, id))
224
+ .run();
225
+ }
226
+
227
+ /**
228
+ * Get the most recently accessed channel ID, or null if none.
229
+ */
230
+ export function getLastAccessedChannelId(): string | null {
231
+ const db = getDb();
232
+ const row = db
233
+ .select({ id: channels.id })
234
+ .from(channels)
235
+ .where(and(
236
+ sql`${channels.lastAccessedAt} IS NOT NULL`,
237
+ sql`${channels.archivedAt} IS NULL`
238
+ ))
239
+ .orderBy(desc(channels.lastAccessedAt))
240
+ .limit(1)
241
+ .get();
242
+ return row?.id ?? null;
243
+ }
244
+
245
+ // ============================================================================
246
+ // Messages
247
+ // ============================================================================
248
+
249
+ export function createMessage(params: {
250
+ channelId: string;
251
+ sessionId?: string;
252
+ senderType: "user" | "agent";
253
+ senderId: string;
254
+ senderName?: string;
255
+ content: string;
256
+ status?: "complete" | "interrupted" | "aborted";
257
+ mentionedAgentId?: string;
258
+ runId?: string;
259
+ sessionKey?: string;
260
+ inputTokens?: number;
261
+ outputTokens?: number;
262
+ }): ChatMessage {
263
+ const db = getDb();
264
+ const id = uuid();
265
+ const now = Date.now();
266
+
267
+ const insertValues = {
268
+ id,
269
+ channelId: params.channelId,
270
+ sessionId: params.sessionId ?? null,
271
+ senderType: params.senderType,
272
+ senderId: params.senderId,
273
+ senderName: params.senderName ?? null,
274
+ content: params.content,
275
+ status: params.status ?? "complete",
276
+ mentionedAgentId: params.mentionedAgentId ?? null,
277
+ runId: params.runId ?? null,
278
+ sessionKey: params.sessionKey ?? null,
279
+ inputTokens: params.inputTokens ?? null,
280
+ outputTokens: params.outputTokens ?? null,
281
+ createdAt: now,
282
+ };
283
+
284
+ try {
285
+ db.insert(messages).values(insertValues).run();
286
+ } catch (err) {
287
+ const code = (err as { code?: string }).code;
288
+
289
+ // FTS5 trigger can fail with SQLITE_CONSTRAINT_PRIMARYKEY if the FTS index
290
+ // has orphaned entries from a previous bug. Auto-repair: rebuild FTS and retry.
291
+ if (code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
292
+ console.warn(
293
+ `[createMessage] FTS constraint error — rebuilding FTS index and retrying (id=${id}, channelId=${params.channelId})`
294
+ );
295
+ type SqliteClient = { exec: (sql: string) => void };
296
+ type DrizzleDb = { session: { client: SqliteClient } };
297
+ const sqlite = (db as unknown as DrizzleDb).session.client;
298
+ sqlite.exec("DELETE FROM messages_fts");
299
+ sqlite.exec(
300
+ "INSERT INTO messages_fts(rowid, content) SELECT rowid, content FROM messages"
301
+ );
302
+ // Retry the insert — FTS is now clean
303
+ db.insert(messages).values(insertValues).run();
304
+ console.log("[createMessage] Retry succeeded after FTS rebuild.");
305
+ } else {
306
+ throw err;
307
+ }
308
+ }
309
+
310
+ return {
311
+ id,
312
+ channelId: params.channelId,
313
+ sessionId: params.sessionId ?? null,
314
+ senderType: params.senderType,
315
+ senderId: params.senderId,
316
+ senderName: params.senderName ?? null,
317
+ content: params.content,
318
+ status: params.status ?? "complete",
319
+ mentionedAgentId: params.mentionedAgentId ?? null,
320
+ runId: params.runId ?? null,
321
+ sessionKey: params.sessionKey ?? null,
322
+ inputTokens: params.inputTokens ?? null,
323
+ outputTokens: params.outputTokens ?? null,
324
+ createdAt: now,
325
+ attachments: [],
326
+ reactions: [],
327
+ };
328
+ }
329
+
330
+ export function updateMessage(
331
+ id: string,
332
+ updates: {
333
+ content?: string;
334
+ status?: "complete" | "interrupted" | "aborted";
335
+ runId?: string;
336
+ sessionKey?: string;
337
+ inputTokens?: number;
338
+ outputTokens?: number;
339
+ }
340
+ ): boolean {
341
+ const db = getDb();
342
+ try {
343
+ const result = db
344
+ .update(messages)
345
+ .set(updates)
346
+ .where(eq(messages.id, id))
347
+ .run();
348
+ return result.changes > 0;
349
+ } catch (err) {
350
+ const code = (err as { code?: string }).code;
351
+ // FTS5 update trigger can fail if the index is out of sync.
352
+ // Auto-repair: drop trigger, update, rebuild FTS, recreate trigger.
353
+ if (code === "SQLITE_ERROR" && updates.content !== undefined) {
354
+ console.warn(`[DB] updateMessage FTS error — dropping trigger, retrying, rebuilding (id=${id})`);
355
+ type SqliteClient = { exec: (sql: string) => void };
356
+ type DrizzleDb = { session: { client: SqliteClient } };
357
+ const sqlite = (db as unknown as DrizzleDb).session.client;
358
+ sqlite.exec("DROP TRIGGER IF EXISTS messages_fts_update");
359
+ const result = db.update(messages).set(updates).where(eq(messages.id, id)).run();
360
+ sqlite.exec(`
361
+ CREATE TRIGGER IF NOT EXISTS messages_fts_update AFTER UPDATE OF content ON messages BEGIN
362
+ INSERT INTO messages_fts(messages_fts, rowid, content) VALUES ('delete', OLD.rowid, OLD.content);
363
+ INSERT INTO messages_fts(rowid, content) VALUES (NEW.rowid, NEW.content);
364
+ END;
365
+ `);
366
+ sqlite.exec("DELETE FROM messages_fts");
367
+ sqlite.exec("INSERT INTO messages_fts(rowid, content) SELECT rowid, content FROM messages");
368
+ console.log("[DB] updateMessage retry succeeded after FTS rebuild.");
369
+ return result.changes > 0;
370
+ }
371
+ console.error(`[DB] updateMessage FAILED — id=${id} keys=${Object.keys(updates).join(",")}:`, (err as Error).message);
372
+ throw err;
373
+ }
374
+ }
375
+
376
+ export function deleteMessage(id: string): boolean {
377
+ const db = getDb();
378
+ try {
379
+ const result = db.delete(messages).where(eq(messages.id, id)).run();
380
+ return result.changes > 0;
381
+ } catch (err) {
382
+ const code = (err as { code?: string }).code;
383
+ // FTS5 delete trigger can fail if the index is out of sync.
384
+ // Auto-repair: drop trigger, delete, rebuild FTS, recreate trigger.
385
+ if (code === "SQLITE_ERROR") {
386
+ console.warn(`[DB] deleteMessage FTS error — dropping trigger, retrying, rebuilding (id=${id})`);
387
+ type SqliteClient = { exec: (sql: string) => void };
388
+ type DrizzleDb = { session: { client: SqliteClient } };
389
+ const sqlite = (db as unknown as DrizzleDb).session.client;
390
+ sqlite.exec("DROP TRIGGER IF EXISTS messages_fts_delete");
391
+ const result = db.delete(messages).where(eq(messages.id, id)).run();
392
+ sqlite.exec(`
393
+ CREATE TRIGGER IF NOT EXISTS messages_fts_delete AFTER DELETE ON messages BEGIN
394
+ INSERT INTO messages_fts(messages_fts, rowid, content) VALUES ('delete', OLD.rowid, OLD.content);
395
+ END;
396
+ `);
397
+ sqlite.exec("DELETE FROM messages_fts");
398
+ sqlite.exec("INSERT INTO messages_fts(rowid, content) SELECT rowid, content FROM messages");
399
+ console.log("[DB] deleteMessage retry succeeded after FTS rebuild.");
400
+ return result.changes > 0;
401
+ }
402
+ console.error(`[DB] deleteMessage FAILED — id=${id}:`, (err as Error).message);
403
+ throw err;
404
+ }
405
+ }
406
+
407
+ /**
408
+ * Hydrate raw message rows with attachments and reactions.
409
+ * Shared by getMessagesByChannel, getMessagesAfter, and getMessagesAround.
410
+ */
411
+ function hydrateMessages(rows: typeof messages.$inferSelect[]): ChatMessage[] {
412
+ const db = getDb();
413
+ const messageIds = rows.map((r) => r.id);
414
+
415
+ const attachmentRows = messageIds.length > 0
416
+ ? db.select().from(messageAttachments).where(inArray(messageAttachments.messageId, messageIds)).all()
417
+ : [];
418
+ const reactionRows = messageIds.length > 0
419
+ ? db.select().from(messageReactions).where(inArray(messageReactions.messageId, messageIds)).all()
420
+ : [];
421
+
422
+ const attachmentsByMsg = new Map<string, MessageAttachment[]>();
423
+ for (const a of attachmentRows) {
424
+ const list = attachmentsByMsg.get(a.messageId) || [];
425
+ list.push({
426
+ id: a.id,
427
+ messageId: a.messageId,
428
+ attachmentType: a.attachmentType as "image" | "audio",
429
+ filePath: a.filePath,
430
+ mimeType: a.mimeType,
431
+ fileSize: a.fileSize,
432
+ originalName: a.originalName,
433
+ createdAt: a.createdAt,
434
+ });
435
+ attachmentsByMsg.set(a.messageId, list);
436
+ }
437
+
438
+ const reactionsByMsg = new Map<string, MessageReaction[]>();
439
+ for (const r of reactionRows) {
440
+ const list = reactionsByMsg.get(r.messageId) || [];
441
+ list.push({
442
+ id: r.id,
443
+ messageId: r.messageId,
444
+ agentId: r.agentId,
445
+ emoji: r.emoji,
446
+ emojiChar: r.emojiChar,
447
+ createdAt: r.createdAt,
448
+ });
449
+ reactionsByMsg.set(r.messageId, list);
450
+ }
451
+
452
+ return rows.map((row) => ({
453
+ id: row.id,
454
+ channelId: row.channelId,
455
+ sessionId: row.sessionId,
456
+ senderType: row.senderType as "user" | "agent",
457
+ senderId: row.senderId,
458
+ senderName: row.senderName,
459
+ content: row.content,
460
+ status: row.status as "complete" | "interrupted" | "aborted",
461
+ mentionedAgentId: row.mentionedAgentId,
462
+ runId: row.runId,
463
+ sessionKey: row.sessionKey,
464
+ inputTokens: row.inputTokens,
465
+ outputTokens: row.outputTokens,
466
+ createdAt: row.createdAt,
467
+ attachments: attachmentsByMsg.get(row.id) || [],
468
+ reactions: reactionsByMsg.get(row.id) || [],
469
+ }));
470
+ }
471
+
472
+ /**
473
+ * Get messages for a channel with cursor-based pagination.
474
+ * @param channelId - Channel to load messages for
475
+ * @param limit - Max messages to return (default 50)
476
+ * @param before - Message ID cursor — returns messages older than this
477
+ */
478
+ export function getMessagesByChannel(
479
+ channelId: string,
480
+ limit = 50,
481
+ before?: string
482
+ ): ChatMessage[] {
483
+ const db = getDb();
484
+
485
+ let query;
486
+ if (before) {
487
+ const cursor = db
488
+ .select({ createdAt: messages.createdAt, id: messages.id })
489
+ .from(messages)
490
+ .where(eq(messages.id, before))
491
+ .get();
492
+
493
+ if (!cursor) return [];
494
+
495
+ // Composite cursor (createdAt, id) to avoid skipping messages with identical timestamps
496
+ query = db
497
+ .select()
498
+ .from(messages)
499
+ .where(
500
+ and(
501
+ eq(messages.channelId, channelId),
502
+ sql`(${messages.createdAt}, ${messages.id}) < (${cursor.createdAt}, ${cursor.id})`
503
+ )
504
+ )
505
+ .orderBy(desc(messages.createdAt))
506
+ .limit(limit)
507
+ .all();
508
+ } else {
509
+ query = db
510
+ .select()
511
+ .from(messages)
512
+ .where(eq(messages.channelId, channelId))
513
+ .orderBy(desc(messages.createdAt))
514
+ .limit(limit)
515
+ .all();
516
+ }
517
+
518
+ // Reverse to chronological order
519
+ return hydrateMessages(query.reverse());
520
+ }
521
+
522
+ /**
523
+ * Get messages for a channel AFTER a cursor (forward pagination).
524
+ * Returns messages newer than the cursor, in chronological order.
525
+ */
526
+ export function getMessagesAfter(
527
+ channelId: string,
528
+ afterId: string,
529
+ limit = 50
530
+ ): ChatMessage[] {
531
+ const db = getDb();
532
+
533
+ const cursor = db
534
+ .select({ createdAt: messages.createdAt, id: messages.id })
535
+ .from(messages)
536
+ .where(eq(messages.id, afterId))
537
+ .get();
538
+
539
+ if (!cursor) return [];
540
+
541
+ // Composite cursor (createdAt, id) to avoid skipping messages with identical timestamps
542
+ const rows = db
543
+ .select()
544
+ .from(messages)
545
+ .where(
546
+ and(
547
+ eq(messages.channelId, channelId),
548
+ sql`(${messages.createdAt}, ${messages.id}) > (${cursor.createdAt}, ${cursor.id})`
549
+ )
550
+ )
551
+ .orderBy(asc(messages.createdAt))
552
+ .limit(limit)
553
+ .all();
554
+
555
+ return hydrateMessages(rows);
556
+ }
557
+
558
+ /**
559
+ * Get a window of messages around an anchor message.
560
+ * Returns ~limit messages centered on the anchor, plus hasMoreBefore/hasMoreAfter flags.
561
+ */
562
+ export function getMessagesAround(
563
+ channelId: string,
564
+ anchorMessageId: string,
565
+ limit = 50
566
+ ): { messages: ChatMessage[]; hasMoreBefore: boolean; hasMoreAfter: boolean } | null {
567
+ const db = getDb();
568
+
569
+ // Look up the anchor message
570
+ const anchor = db
571
+ .select()
572
+ .from(messages)
573
+ .where(and(eq(messages.id, anchorMessageId), eq(messages.channelId, channelId)))
574
+ .get();
575
+
576
+ if (!anchor) return null;
577
+
578
+ const half = Math.floor(limit / 2);
579
+
580
+ // Messages before the anchor (composite cursor, DESC then reverse)
581
+ const beforeRows = db
582
+ .select()
583
+ .from(messages)
584
+ .where(
585
+ and(
586
+ eq(messages.channelId, channelId),
587
+ sql`(${messages.createdAt}, ${messages.id}) < (${anchor.createdAt}, ${anchor.id})`
588
+ )
589
+ )
590
+ .orderBy(desc(messages.createdAt))
591
+ .limit(half)
592
+ .all()
593
+ .reverse();
594
+
595
+ // Messages after the anchor (composite cursor, ASC)
596
+ const afterRows = db
597
+ .select()
598
+ .from(messages)
599
+ .where(
600
+ and(
601
+ eq(messages.channelId, channelId),
602
+ sql`(${messages.createdAt}, ${messages.id}) > (${anchor.createdAt}, ${anchor.id})`
603
+ )
604
+ )
605
+ .orderBy(asc(messages.createdAt))
606
+ .limit(half)
607
+ .all();
608
+
609
+ // Combine: before + anchor + after (chronological order)
610
+ const allRows = [...beforeRows, anchor, ...afterRows];
611
+
612
+ return {
613
+ messages: hydrateMessages(allRows),
614
+ hasMoreBefore: beforeRows.length === half,
615
+ hasMoreAfter: afterRows.length === half,
616
+ };
617
+ }
618
+
619
+ /**
620
+ * Find an agent message by runId (for updating partial saves).
621
+ * Only matches agent messages — user messages also carry the runId as a reference
622
+ * to the run they triggered, but should never be overwritten with agent content.
623
+ */
624
+ export function getMessageByRunId(runId: string) {
625
+ const db = getDb();
626
+ return db
627
+ .select()
628
+ .from(messages)
629
+ .where(and(eq(messages.runId, runId), eq(messages.senderType, "agent")))
630
+ .get() ?? null;
631
+ }
632
+
633
+ // ============================================================================
634
+ // Sessions
635
+ // ============================================================================
636
+
637
+ export function createSession(params: {
638
+ channelId: string;
639
+ sessionKey?: string;
640
+ }): ChannelSession {
641
+ const db = getDb();
642
+ const id = uuid();
643
+ const now = Date.now();
644
+
645
+ try {
646
+ db.insert(sessions)
647
+ .values({
648
+ id,
649
+ channelId: params.channelId,
650
+ sessionKey: params.sessionKey ?? null,
651
+ startedAt: now,
652
+ })
653
+ .run();
654
+ } catch (err) {
655
+ console.error(`[DB] createSession FAILED — channelId=${params.channelId} sessionKey=${params.sessionKey}:`, (err as Error).message);
656
+ throw err;
657
+ }
658
+
659
+ return {
660
+ id,
661
+ channelId: params.channelId,
662
+ sessionKey: params.sessionKey ?? null,
663
+ startedAt: now,
664
+ endedAt: null,
665
+ summary: null,
666
+ totalInputTokens: 0,
667
+ totalOutputTokens: 0,
668
+ };
669
+ }
670
+
671
+ export function updateSession(
672
+ id: string,
673
+ updates: {
674
+ sessionKey?: string;
675
+ endedAt?: number;
676
+ summary?: string;
677
+ totalInputTokens?: number;
678
+ totalOutputTokens?: number;
679
+ }
680
+ ): boolean {
681
+ const db = getDb();
682
+ const result = db
683
+ .update(sessions)
684
+ .set(updates)
685
+ .where(eq(sessions.id, id))
686
+ .run();
687
+ return result.changes > 0;
688
+ }
689
+
690
+ export function getSessionsByChannel(channelId: string): ChannelSession[] {
691
+ const db = getDb();
692
+ return db
693
+ .select()
694
+ .from(sessions)
695
+ .where(eq(sessions.channelId, channelId))
696
+ .orderBy(desc(sessions.startedAt))
697
+ .all()
698
+ .map((row) => ({
699
+ id: row.id,
700
+ channelId: row.channelId,
701
+ sessionKey: row.sessionKey,
702
+ startedAt: row.startedAt,
703
+ endedAt: row.endedAt,
704
+ summary: row.summary,
705
+ totalInputTokens: row.totalInputTokens ?? 0,
706
+ totalOutputTokens: row.totalOutputTokens ?? 0,
707
+ }));
708
+ }
709
+
710
+ export function getLatestSessionKey(channelId: string): string | null {
711
+ const db = getDb();
712
+ const row = db
713
+ .select({ sessionKey: sessions.sessionKey })
714
+ .from(sessions)
715
+ .where(eq(sessions.channelId, channelId))
716
+ .orderBy(desc(sessions.startedAt))
717
+ .limit(1)
718
+ .get();
719
+ return row?.sessionKey ?? null;
720
+ }
721
+
722
+ /**
723
+ * Update the compaction boundary for a session (by session key).
724
+ * The boundary message ID is the oldest message still in the agent's context.
725
+ */
726
+ export function setCompactionBoundary(
727
+ sessionKey: string,
728
+ boundaryMessageId: string
729
+ ): boolean {
730
+ const db = getDb();
731
+ const result = db
732
+ .update(sessions)
733
+ .set({ compactionBoundaryMessageId: boundaryMessageId })
734
+ .where(eq(sessions.sessionKey, sessionKey))
735
+ .run();
736
+ return result.changes > 0;
737
+ }
738
+
739
+ /**
740
+ * Get the compaction boundary message ID for a session (by session key).
741
+ */
742
+ export function getCompactionBoundary(sessionKey: string): string | null {
743
+ const db = getDb();
744
+ const row = db
745
+ .select({ boundaryId: sessions.compactionBoundaryMessageId })
746
+ .from(sessions)
747
+ .where(eq(sessions.sessionKey, sessionKey))
748
+ .limit(1)
749
+ .get();
750
+ return row?.boundaryId ?? null;
751
+ }
752
+
753
+ // ============================================================================
754
+ // Attachments
755
+ // ============================================================================
756
+
757
+ export function createAttachment(params: {
758
+ messageId: string;
759
+ attachmentType: "image" | "audio";
760
+ filePath: string;
761
+ mimeType?: string;
762
+ fileSize?: number;
763
+ originalName?: string;
764
+ }): MessageAttachment {
765
+ const db = getDb();
766
+ const id = uuid();
767
+ const now = Date.now();
768
+
769
+ db.insert(messageAttachments)
770
+ .values({
771
+ id,
772
+ messageId: params.messageId,
773
+ attachmentType: params.attachmentType,
774
+ filePath: params.filePath,
775
+ mimeType: params.mimeType ?? null,
776
+ fileSize: params.fileSize ?? null,
777
+ originalName: params.originalName ?? null,
778
+ createdAt: now,
779
+ })
780
+ .run();
781
+
782
+ return {
783
+ id,
784
+ messageId: params.messageId,
785
+ attachmentType: params.attachmentType,
786
+ filePath: params.filePath,
787
+ mimeType: params.mimeType ?? null,
788
+ fileSize: params.fileSize ?? null,
789
+ originalName: params.originalName ?? null,
790
+ createdAt: now,
791
+ };
792
+ }
793
+
794
+ export function getAttachmentsByMessage(messageId: string): MessageAttachment[] {
795
+ const db = getDb();
796
+ return db
797
+ .select()
798
+ .from(messageAttachments)
799
+ .where(eq(messageAttachments.messageId, messageId))
800
+ .all()
801
+ .map((row) => ({
802
+ id: row.id,
803
+ messageId: row.messageId,
804
+ attachmentType: row.attachmentType as "image" | "audio",
805
+ filePath: row.filePath,
806
+ mimeType: row.mimeType,
807
+ fileSize: row.fileSize,
808
+ originalName: row.originalName,
809
+ createdAt: row.createdAt,
810
+ }));
811
+ }
812
+
813
+ // ============================================================================
814
+ // Reactions
815
+ // ============================================================================
816
+
817
+ export function createReaction(params: {
818
+ messageId: string;
819
+ agentId?: string;
820
+ emoji: string;
821
+ emojiChar: string;
822
+ }): MessageReaction {
823
+ const db = getDb();
824
+ const id = uuid();
825
+ const now = Date.now();
826
+
827
+ db.insert(messageReactions)
828
+ .values({
829
+ id,
830
+ messageId: params.messageId,
831
+ agentId: params.agentId ?? null,
832
+ emoji: params.emoji,
833
+ emojiChar: params.emojiChar,
834
+ createdAt: now,
835
+ })
836
+ .run();
837
+
838
+ return {
839
+ id,
840
+ messageId: params.messageId,
841
+ agentId: params.agentId ?? null,
842
+ emoji: params.emoji,
843
+ emojiChar: params.emojiChar,
844
+ createdAt: now,
845
+ };
846
+ }
847
+
848
+ export function getReactionsByMessage(messageId: string): MessageReaction[] {
849
+ const db = getDb();
850
+ return db
851
+ .select()
852
+ .from(messageReactions)
853
+ .where(eq(messageReactions.messageId, messageId))
854
+ .all()
855
+ .map((row) => ({
856
+ id: row.id,
857
+ messageId: row.messageId,
858
+ agentId: row.agentId,
859
+ emoji: row.emoji,
860
+ emojiChar: row.emojiChar,
861
+ createdAt: row.createdAt,
862
+ }));
863
+ }
864
+
865
+ // ============================================================================
866
+ // Search (FTS5)
867
+ // ============================================================================
868
+
869
+ /**
870
+ * Full-text search across messages using FTS5.
871
+ * Uses parameterized MATCH queries for safety.
872
+ */
873
+ export function searchMessages(
874
+ query: string,
875
+ channelId?: string,
876
+ limit = 30
877
+ ): ChatMessage[] {
878
+ const db = getDb();
879
+
880
+ // Safety: reject overly long queries
881
+ if (!query || query.length > 500) return [];
882
+
883
+ // Sanitize FTS5 query: wrap each word in double quotes to prevent FTS5 operator injection.
884
+ // FTS5 supports operators like AND, OR, NOT, NEAR, and column filters — quoting each
885
+ // term treats them as literal strings instead of operators.
886
+ const sanitizedQuery = query
887
+ .replace(/"/g, "") // Remove existing quotes to prevent breaking out
888
+ .split(/\s+/)
889
+ .filter(Boolean)
890
+ .map((term) => `"${term}"`)
891
+ .join(" ");
892
+
893
+ if (!sanitizedQuery) return [];
894
+
895
+ // Use raw SQL for FTS5 MATCH — Drizzle doesn't support virtual tables
896
+ const dbInstance = db as unknown as { all: (query: unknown) => unknown[] };
897
+
898
+ // Access the underlying better-sqlite3 instance
899
+ type DrizzleInternals = { session: { client: { prepare: (sql: string) => { all: (...params: unknown[]) => Record<string, unknown>[] } } } };
900
+ const sqlite = (db as unknown as DrizzleInternals).session.client;
901
+
902
+ let rows: Record<string, unknown>[];
903
+
904
+ try {
905
+ if (channelId) {
906
+ const stmt = sqlite.prepare(`
907
+ SELECT m.*
908
+ FROM messages m
909
+ JOIN messages_fts fts ON m.rowid = fts.rowid
910
+ WHERE messages_fts MATCH ?
911
+ AND m.channel_id = ?
912
+ ORDER BY m.created_at DESC
913
+ LIMIT ?
914
+ `);
915
+ rows = stmt.all(sanitizedQuery, channelId, limit);
916
+ } else {
917
+ const stmt = sqlite.prepare(`
918
+ SELECT m.*
919
+ FROM messages m
920
+ JOIN messages_fts fts ON m.rowid = fts.rowid
921
+ WHERE messages_fts MATCH ?
922
+ ORDER BY m.created_at DESC
923
+ LIMIT ?
924
+ `);
925
+ rows = stmt.all(sanitizedQuery, limit);
926
+ }
927
+ } catch (err) {
928
+ console.error(`[DB] searchMessages FTS FAILED — query="${sanitizedQuery}" channelId=${channelId}:`, (err as Error).message);
929
+ return [];
930
+ }
931
+
932
+ return rows.map((row) => ({
933
+ id: row.id as string,
934
+ channelId: row.channel_id as string,
935
+ sessionId: (row.session_id as string) ?? null,
936
+ senderType: row.sender_type as "user" | "agent",
937
+ senderId: row.sender_id as string,
938
+ senderName: (row.sender_name as string) ?? null,
939
+ content: row.content as string,
940
+ status: (row.status as "complete" | "interrupted" | "aborted") ?? "complete",
941
+ mentionedAgentId: (row.mentioned_agent_id as string) ?? null,
942
+ runId: (row.run_id as string) ?? null,
943
+ sessionKey: (row.session_key as string) ?? null,
944
+ inputTokens: (row.input_tokens as number) ?? null,
945
+ outputTokens: (row.output_tokens as number) ?? null,
946
+ createdAt: row.created_at as number,
947
+ attachments: [],
948
+ reactions: [],
949
+ }));
950
+ }
951
+
952
+ // ============================================================================
953
+ // Storage Stats
954
+ // ============================================================================
955
+
956
+ export function getStorageStats() {
957
+ const db = getDb();
958
+
959
+ const messageCount = db
960
+ .select({ count: sql<number>`count(*)` })
961
+ .from(messages)
962
+ .get();
963
+
964
+ const channelCount = db
965
+ .select({ count: sql<number>`count(*)` })
966
+ .from(channels)
967
+ .get();
968
+
969
+ const attachmentCount = db
970
+ .select({ count: sql<number>`count(*)` })
971
+ .from(messageAttachments)
972
+ .get();
973
+
974
+ // Total attachment size from DB metadata
975
+ const totalAttachmentSize = db
976
+ .select({ total: sql<number>`COALESCE(SUM(file_size), 0)` })
977
+ .from(messageAttachments)
978
+ .get();
979
+
980
+ return {
981
+ messages: messageCount?.count ?? 0,
982
+ channels: channelCount?.count ?? 0,
983
+ attachments: attachmentCount?.count ?? 0,
984
+ totalAttachmentBytes: totalAttachmentSize?.total ?? 0,
985
+ };
986
+ }
987
+
988
+ // ============================================================================
989
+ // Settings
990
+ // ============================================================================
991
+
992
+ /**
993
+ * Get a setting value by key. Returns null if not set.
994
+ */
995
+ export function getSetting(key: string): string | null {
996
+ const db = getDb();
997
+ const row = db
998
+ .select({ value: settings.value })
999
+ .from(settings)
1000
+ .where(eq(settings.key, key))
1001
+ .get();
1002
+ return row?.value ?? null;
1003
+ }
1004
+
1005
+ /**
1006
+ * Get all settings as a key-value record.
1007
+ */
1008
+ export function getAllSettings(): Record<string, string> {
1009
+ const db = getDb();
1010
+ const rows = db.select().from(settings).all();
1011
+ const result: Record<string, string> = {};
1012
+ for (const row of rows) {
1013
+ result[row.key] = row.value;
1014
+ }
1015
+ return result;
1016
+ }
1017
+
1018
+ /**
1019
+ * Set a setting value (upsert).
1020
+ */
1021
+ export function setSetting(key: string, value: string): void {
1022
+ const db = getDb();
1023
+ const existing = db
1024
+ .select({ key: settings.key })
1025
+ .from(settings)
1026
+ .where(eq(settings.key, key))
1027
+ .get();
1028
+
1029
+ if (existing) {
1030
+ db.update(settings)
1031
+ .set({ value, updatedAt: Date.now() })
1032
+ .where(eq(settings.key, key))
1033
+ .run();
1034
+ } else {
1035
+ db.insert(settings)
1036
+ .values({ key, value, updatedAt: Date.now() })
1037
+ .run();
1038
+ }
1039
+ }
1040
+
1041
+ // ============================================================================
1042
+ // Agent Statuses
1043
+ // ============================================================================
1044
+
1045
+ const ACTIVE_DURATION_MS = 2 * 60 * 1000; // 2 minutes
1046
+
1047
+ export type AgentStatusValue = "idle" | "thinking" | "active";
1048
+
1049
+ export interface AgentStatusRow {
1050
+ agentId: string;
1051
+ status: AgentStatusValue;
1052
+ updatedAt: number;
1053
+ }
1054
+
1055
+ /**
1056
+ * Get all agent statuses. If an agent's status is "active" but updated_at
1057
+ * is more than 2 minutes ago, it's returned as "idle" instead.
1058
+ */
1059
+ export function getAgentStatuses(): AgentStatusRow[] {
1060
+ const db = getDb();
1061
+ const rows = db.select().from(agentStatuses).all();
1062
+ const now = Date.now();
1063
+
1064
+ return rows.map((row) => {
1065
+ const status = row.status as AgentStatusValue;
1066
+ // Auto-expire "active" status after 2 minutes
1067
+ if (status === "active" && now - row.updatedAt > ACTIVE_DURATION_MS) {
1068
+ return { agentId: row.agentId, status: "idle" as AgentStatusValue, updatedAt: row.updatedAt };
1069
+ }
1070
+ return { agentId: row.agentId, status, updatedAt: row.updatedAt };
1071
+ });
1072
+ }
1073
+
1074
+ /**
1075
+ * Set an agent's status. Upserts the row.
1076
+ */
1077
+ export function setAgentStatus(agentId: string, status: AgentStatusValue): void {
1078
+ const db = getDb();
1079
+ const now = Date.now();
1080
+
1081
+ const existing = db.select().from(agentStatuses).where(eq(agentStatuses.agentId, agentId)).get();
1082
+ if (existing) {
1083
+ db.update(agentStatuses)
1084
+ .set({ status, updatedAt: now })
1085
+ .where(eq(agentStatuses.agentId, agentId))
1086
+ .run();
1087
+ } else {
1088
+ db.insert(agentStatuses)
1089
+ .values({ agentId, status, updatedAt: now })
1090
+ .run();
1091
+ }
1092
+ }
1093
+
1094
+ // ============================================================================
1095
+ // Recent Searches
1096
+ // ============================================================================
1097
+
1098
+ const MAX_RECENT_SEARCHES = 15;
1099
+
1100
+ export function getRecentSearches(): string[] {
1101
+ const db = getDb();
1102
+ const rows = db
1103
+ .select({ query: recentSearches.query })
1104
+ .from(recentSearches)
1105
+ .orderBy(desc(recentSearches.createdAt))
1106
+ .limit(MAX_RECENT_SEARCHES)
1107
+ .all();
1108
+ return rows.map((r) => r.query);
1109
+ }
1110
+
1111
+ export function addRecentSearch(query: string): void {
1112
+ const db = getDb();
1113
+ const trimmed = query.trim();
1114
+ if (!trimmed) return;
1115
+
1116
+ // Remove duplicate if it already exists
1117
+ db.delete(recentSearches)
1118
+ .where(eq(recentSearches.query, trimmed))
1119
+ .run();
1120
+
1121
+ // Insert as most recent
1122
+ db.insert(recentSearches)
1123
+ .values({ query: trimmed, createdAt: Date.now() })
1124
+ .run();
1125
+
1126
+ // Prune old entries beyond the limit
1127
+ const all = db
1128
+ .select({ id: recentSearches.id })
1129
+ .from(recentSearches)
1130
+ .orderBy(desc(recentSearches.createdAt))
1131
+ .all();
1132
+
1133
+ if (all.length > MAX_RECENT_SEARCHES) {
1134
+ const toDelete = all.slice(MAX_RECENT_SEARCHES).map((r) => r.id);
1135
+ db.delete(recentSearches)
1136
+ .where(inArray(recentSearches.id, toDelete))
1137
+ .run();
1138
+ }
1139
+ }
1140
+
1141
+ export function clearRecentSearches(): void {
1142
+ const db = getDb();
1143
+ db.delete(recentSearches).run();
1144
+ }