botmancers 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1525) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +214 -19
  3. package/app/.next/BUILD_ID +1 -0
  4. package/app/.next/app-path-routes-manifest.json +40 -0
  5. package/app/.next/build-manifest.json +24 -0
  6. package/app/.next/node_modules/better-sqlite3-90e2652d1716b047/index.js +1 -0
  7. package/app/.next/node_modules/better-sqlite3-90e2652d1716b047/package.json +1 -0
  8. package/app/.next/package.json +1 -0
  9. package/app/.next/prerender-manifest.json +125 -0
  10. package/app/.next/required-server-files.json +365 -0
  11. package/app/.next/routes-manifest.json +317 -0
  12. package/app/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
  13. package/app/.next/server/app/_global-error/page/build-manifest.json +20 -0
  14. package/app/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
  15. package/app/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
  16. package/app/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
  17. package/app/.next/server/app/_global-error/page.js +9 -0
  18. package/app/.next/server/app/_global-error/page.js.nft.json +1 -0
  19. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +3 -0
  20. package/app/.next/server/app/_global-error.html +1 -0
  21. package/app/.next/server/app/_global-error.meta +30 -0
  22. package/app/.next/server/app/_global-error.rsc +14 -0
  23. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +19 -0
  24. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
  25. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
  26. package/app/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
  27. package/app/.next/server/app/_not-found/page/build-manifest.json +20 -0
  28. package/app/.next/server/app/_not-found/page/next-font-manifest.json +11 -0
  29. package/app/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
  30. package/app/.next/server/app/_not-found/page/server-reference-manifest.json +4 -0
  31. package/app/.next/server/app/_not-found/page.js +12 -0
  32. package/app/.next/server/app/_not-found/page.js.nft.json +1 -0
  33. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +3 -0
  34. package/app/.next/server/app/_not-found.html +1 -0
  35. package/app/.next/server/app/_not-found.meta +35 -0
  36. package/app/.next/server/app/_not-found.rsc +16 -0
  37. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +16 -0
  38. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +22 -0
  39. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -0
  40. package/app/.next/server/app/api/agent-deck/decks/route/app-paths-manifest.json +3 -0
  41. package/app/.next/server/app/api/agent-deck/decks/route/build-manifest.json +12 -0
  42. package/app/.next/server/app/api/agent-deck/decks/route/server-reference-manifest.json +4 -0
  43. package/app/.next/server/app/api/agent-deck/decks/route.js +9 -0
  44. package/app/.next/server/app/api/agent-deck/decks/route.js.nft.json +1 -0
  45. package/app/.next/server/app/api/agent-deck/decks/route_client-reference-manifest.js +3 -0
  46. package/app/.next/server/app/api/agent-deck/settings/route/app-paths-manifest.json +3 -0
  47. package/app/.next/server/app/api/agent-deck/settings/route/build-manifest.json +12 -0
  48. package/app/.next/server/app/api/agent-deck/settings/route/server-reference-manifest.json +4 -0
  49. package/app/.next/server/app/api/agent-deck/settings/route.js +9 -0
  50. package/app/.next/server/app/api/agent-deck/settings/route.js.nft.json +1 -0
  51. package/app/.next/server/app/api/agent-deck/settings/route_client-reference-manifest.js +3 -0
  52. package/app/.next/server/app/api/bots/[id]/config/route/app-paths-manifest.json +3 -0
  53. package/app/.next/server/app/api/bots/[id]/config/route/build-manifest.json +12 -0
  54. package/app/.next/server/app/api/bots/[id]/config/route/server-reference-manifest.json +4 -0
  55. package/app/.next/server/app/api/bots/[id]/config/route.js +9 -0
  56. package/app/.next/server/app/api/bots/[id]/config/route.js.nft.json +1 -0
  57. package/app/.next/server/app/api/bots/[id]/config/route_client-reference-manifest.js +3 -0
  58. package/app/.next/server/app/api/bots/[id]/skill/route/app-paths-manifest.json +3 -0
  59. package/app/.next/server/app/api/bots/[id]/skill/route/build-manifest.json +12 -0
  60. package/app/.next/server/app/api/bots/[id]/skill/route/server-reference-manifest.json +4 -0
  61. package/app/.next/server/app/api/bots/[id]/skill/route.js +9 -0
  62. package/app/.next/server/app/api/bots/[id]/skill/route.js.nft.json +1 -0
  63. package/app/.next/server/app/api/bots/[id]/skill/route_client-reference-manifest.js +3 -0
  64. package/app/.next/server/app/api/bots/availability/route/app-paths-manifest.json +3 -0
  65. package/app/.next/server/app/api/bots/availability/route/build-manifest.json +12 -0
  66. package/app/.next/server/app/api/bots/availability/route/server-reference-manifest.json +4 -0
  67. package/app/.next/server/app/api/bots/availability/route.js +8 -0
  68. package/app/.next/server/app/api/bots/availability/route.js.nft.json +1 -0
  69. package/app/.next/server/app/api/bots/availability/route_client-reference-manifest.js +3 -0
  70. package/app/.next/server/app/api/bots/delete-preview/route/app-paths-manifest.json +3 -0
  71. package/app/.next/server/app/api/bots/delete-preview/route/build-manifest.json +12 -0
  72. package/app/.next/server/app/api/bots/delete-preview/route/server-reference-manifest.json +4 -0
  73. package/app/.next/server/app/api/bots/delete-preview/route.js +9 -0
  74. package/app/.next/server/app/api/bots/delete-preview/route.js.nft.json +1 -0
  75. package/app/.next/server/app/api/bots/delete-preview/route_client-reference-manifest.js +3 -0
  76. package/app/.next/server/app/api/bots/import/route/app-paths-manifest.json +3 -0
  77. package/app/.next/server/app/api/bots/import/route/build-manifest.json +12 -0
  78. package/app/.next/server/app/api/bots/import/route/server-reference-manifest.json +4 -0
  79. package/app/.next/server/app/api/bots/import/route.js +10 -0
  80. package/app/.next/server/app/api/bots/import/route.js.nft.json +1 -0
  81. package/app/.next/server/app/api/bots/import/route_client-reference-manifest.js +3 -0
  82. package/app/.next/server/app/api/bots/manage/route/app-paths-manifest.json +3 -0
  83. package/app/.next/server/app/api/bots/manage/route/build-manifest.json +12 -0
  84. package/app/.next/server/app/api/bots/manage/route/server-reference-manifest.json +4 -0
  85. package/app/.next/server/app/api/bots/manage/route.js +9 -0
  86. package/app/.next/server/app/api/bots/manage/route.js.nft.json +1 -0
  87. package/app/.next/server/app/api/bots/manage/route_client-reference-manifest.js +3 -0
  88. package/app/.next/server/app/api/bots/name-migrations/route/app-paths-manifest.json +3 -0
  89. package/app/.next/server/app/api/bots/name-migrations/route/build-manifest.json +12 -0
  90. package/app/.next/server/app/api/bots/name-migrations/route/server-reference-manifest.json +4 -0
  91. package/app/.next/server/app/api/bots/name-migrations/route.js +9 -0
  92. package/app/.next/server/app/api/bots/name-migrations/route.js.nft.json +1 -0
  93. package/app/.next/server/app/api/bots/name-migrations/route_client-reference-manifest.js +3 -0
  94. package/app/.next/server/app/api/bots/route/app-paths-manifest.json +3 -0
  95. package/app/.next/server/app/api/bots/route/build-manifest.json +12 -0
  96. package/app/.next/server/app/api/bots/route/server-reference-manifest.json +4 -0
  97. package/app/.next/server/app/api/bots/route.js +15 -0
  98. package/app/.next/server/app/api/bots/route.js.nft.json +1 -0
  99. package/app/.next/server/app/api/bots/route_client-reference-manifest.js +3 -0
  100. package/app/.next/server/app/api/conversations/[id]/approve/route/app-paths-manifest.json +3 -0
  101. package/app/.next/server/app/api/conversations/[id]/approve/route/build-manifest.json +12 -0
  102. package/app/.next/server/app/api/conversations/[id]/approve/route/server-reference-manifest.json +4 -0
  103. package/app/.next/server/app/api/conversations/[id]/approve/route.js +10 -0
  104. package/app/.next/server/app/api/conversations/[id]/approve/route.js.nft.json +1 -0
  105. package/app/.next/server/app/api/conversations/[id]/approve/route_client-reference-manifest.js +3 -0
  106. package/app/.next/server/app/api/conversations/[id]/deny/route/app-paths-manifest.json +3 -0
  107. package/app/.next/server/app/api/conversations/[id]/deny/route/build-manifest.json +12 -0
  108. package/app/.next/server/app/api/conversations/[id]/deny/route/server-reference-manifest.json +4 -0
  109. package/app/.next/server/app/api/conversations/[id]/deny/route.js +10 -0
  110. package/app/.next/server/app/api/conversations/[id]/deny/route.js.nft.json +1 -0
  111. package/app/.next/server/app/api/conversations/[id]/deny/route_client-reference-manifest.js +3 -0
  112. package/app/.next/server/app/api/conversations/[id]/draft/route/app-paths-manifest.json +3 -0
  113. package/app/.next/server/app/api/conversations/[id]/draft/route/build-manifest.json +12 -0
  114. package/app/.next/server/app/api/conversations/[id]/draft/route/server-reference-manifest.json +4 -0
  115. package/app/.next/server/app/api/conversations/[id]/draft/route.js +10 -0
  116. package/app/.next/server/app/api/conversations/[id]/draft/route.js.nft.json +1 -0
  117. package/app/.next/server/app/api/conversations/[id]/draft/route_client-reference-manifest.js +3 -0
  118. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route/app-paths-manifest.json +3 -0
  119. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route/build-manifest.json +12 -0
  120. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route/server-reference-manifest.json +4 -0
  121. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js +10 -0
  122. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js.nft.json +1 -0
  123. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route_client-reference-manifest.js +3 -0
  124. package/app/.next/server/app/api/conversations/[id]/messages/route/app-paths-manifest.json +3 -0
  125. package/app/.next/server/app/api/conversations/[id]/messages/route/build-manifest.json +12 -0
  126. package/app/.next/server/app/api/conversations/[id]/messages/route/server-reference-manifest.json +4 -0
  127. package/app/.next/server/app/api/conversations/[id]/messages/route.js +14 -0
  128. package/app/.next/server/app/api/conversations/[id]/messages/route.js.nft.json +1 -0
  129. package/app/.next/server/app/api/conversations/[id]/messages/route_client-reference-manifest.js +3 -0
  130. package/app/.next/server/app/api/conversations/[id]/route/app-paths-manifest.json +3 -0
  131. package/app/.next/server/app/api/conversations/[id]/route/build-manifest.json +12 -0
  132. package/app/.next/server/app/api/conversations/[id]/route/server-reference-manifest.json +4 -0
  133. package/app/.next/server/app/api/conversations/[id]/route.js +9 -0
  134. package/app/.next/server/app/api/conversations/[id]/route.js.nft.json +1 -0
  135. package/app/.next/server/app/api/conversations/[id]/route_client-reference-manifest.js +3 -0
  136. package/app/.next/server/app/api/conversations/[id]/stop/route/app-paths-manifest.json +3 -0
  137. package/app/.next/server/app/api/conversations/[id]/stop/route/build-manifest.json +12 -0
  138. package/app/.next/server/app/api/conversations/[id]/stop/route/server-reference-manifest.json +4 -0
  139. package/app/.next/server/app/api/conversations/[id]/stop/route.js +14 -0
  140. package/app/.next/server/app/api/conversations/[id]/stop/route.js.nft.json +1 -0
  141. package/app/.next/server/app/api/conversations/[id]/stop/route_client-reference-manifest.js +3 -0
  142. package/app/.next/server/app/api/conversations/route/app-paths-manifest.json +3 -0
  143. package/app/.next/server/app/api/conversations/route/build-manifest.json +12 -0
  144. package/app/.next/server/app/api/conversations/route/server-reference-manifest.json +4 -0
  145. package/app/.next/server/app/api/conversations/route.js +9 -0
  146. package/app/.next/server/app/api/conversations/route.js.nft.json +1 -0
  147. package/app/.next/server/app/api/conversations/route_client-reference-manifest.js +3 -0
  148. package/app/.next/server/app/api/files/[name]/route/app-paths-manifest.json +3 -0
  149. package/app/.next/server/app/api/files/[name]/route/build-manifest.json +12 -0
  150. package/app/.next/server/app/api/files/[name]/route/server-reference-manifest.json +4 -0
  151. package/app/.next/server/app/api/files/[name]/route.js +7 -0
  152. package/app/.next/server/app/api/files/[name]/route.js.nft.json +1 -0
  153. package/app/.next/server/app/api/files/[name]/route_client-reference-manifest.js +3 -0
  154. package/app/.next/server/app/api/groups/route/app-paths-manifest.json +3 -0
  155. package/app/.next/server/app/api/groups/route/build-manifest.json +12 -0
  156. package/app/.next/server/app/api/groups/route/server-reference-manifest.json +4 -0
  157. package/app/.next/server/app/api/groups/route.js +9 -0
  158. package/app/.next/server/app/api/groups/route.js.nft.json +1 -0
  159. package/app/.next/server/app/api/groups/route_client-reference-manifest.js +3 -0
  160. package/app/.next/server/app/api/health/route/app-paths-manifest.json +3 -0
  161. package/app/.next/server/app/api/health/route/build-manifest.json +12 -0
  162. package/app/.next/server/app/api/health/route/server-reference-manifest.json +4 -0
  163. package/app/.next/server/app/api/health/route.js +7 -0
  164. package/app/.next/server/app/api/health/route.js.nft.json +1 -0
  165. package/app/.next/server/app/api/health/route_client-reference-manifest.js +3 -0
  166. package/app/.next/server/app/api/import-capabilities/route/app-paths-manifest.json +3 -0
  167. package/app/.next/server/app/api/import-capabilities/route/build-manifest.json +12 -0
  168. package/app/.next/server/app/api/import-capabilities/route/server-reference-manifest.json +4 -0
  169. package/app/.next/server/app/api/import-capabilities/route.js +7 -0
  170. package/app/.next/server/app/api/import-capabilities/route.js.nft.json +1 -0
  171. package/app/.next/server/app/api/import-capabilities/route_client-reference-manifest.js +3 -0
  172. package/app/.next/server/app/api/marketplace-handoff/route/app-paths-manifest.json +3 -0
  173. package/app/.next/server/app/api/marketplace-handoff/route/build-manifest.json +12 -0
  174. package/app/.next/server/app/api/marketplace-handoff/route/server-reference-manifest.json +4 -0
  175. package/app/.next/server/app/api/marketplace-handoff/route.js +7 -0
  176. package/app/.next/server/app/api/marketplace-handoff/route.js.nft.json +1 -0
  177. package/app/.next/server/app/api/marketplace-handoff/route_client-reference-manifest.js +3 -0
  178. package/app/.next/server/app/api/marketplace-handoff/status/route/app-paths-manifest.json +3 -0
  179. package/app/.next/server/app/api/marketplace-handoff/status/route/build-manifest.json +12 -0
  180. package/app/.next/server/app/api/marketplace-handoff/status/route/server-reference-manifest.json +4 -0
  181. package/app/.next/server/app/api/marketplace-handoff/status/route.js +7 -0
  182. package/app/.next/server/app/api/marketplace-handoff/status/route.js.nft.json +1 -0
  183. package/app/.next/server/app/api/marketplace-handoff/status/route_client-reference-manifest.js +3 -0
  184. package/app/.next/server/app/api/mcp/route/app-paths-manifest.json +3 -0
  185. package/app/.next/server/app/api/mcp/route/build-manifest.json +12 -0
  186. package/app/.next/server/app/api/mcp/route/server-reference-manifest.json +4 -0
  187. package/app/.next/server/app/api/mcp/route.js +9 -0
  188. package/app/.next/server/app/api/mcp/route.js.nft.json +1 -0
  189. package/app/.next/server/app/api/mcp/route_client-reference-manifest.js +3 -0
  190. package/app/.next/server/app/api/messages/[id]/between/route/app-paths-manifest.json +3 -0
  191. package/app/.next/server/app/api/messages/[id]/between/route/build-manifest.json +12 -0
  192. package/app/.next/server/app/api/messages/[id]/between/route/server-reference-manifest.json +4 -0
  193. package/app/.next/server/app/api/messages/[id]/between/route.js +9 -0
  194. package/app/.next/server/app/api/messages/[id]/between/route.js.nft.json +1 -0
  195. package/app/.next/server/app/api/messages/[id]/between/route_client-reference-manifest.js +3 -0
  196. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route/app-paths-manifest.json +3 -0
  197. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route/build-manifest.json +12 -0
  198. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route/server-reference-manifest.json +4 -0
  199. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js +9 -0
  200. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js.nft.json +1 -0
  201. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route_client-reference-manifest.js +3 -0
  202. package/app/.next/server/app/api/v0/conversations/[id]/route/app-paths-manifest.json +3 -0
  203. package/app/.next/server/app/api/v0/conversations/[id]/route/build-manifest.json +12 -0
  204. package/app/.next/server/app/api/v0/conversations/[id]/route/server-reference-manifest.json +4 -0
  205. package/app/.next/server/app/api/v0/conversations/[id]/route.js +9 -0
  206. package/app/.next/server/app/api/v0/conversations/[id]/route.js.nft.json +1 -0
  207. package/app/.next/server/app/api/v0/conversations/[id]/route_client-reference-manifest.js +3 -0
  208. package/app/.next/server/app/api/v0/mcp/route/app-paths-manifest.json +3 -0
  209. package/app/.next/server/app/api/v0/mcp/route/build-manifest.json +12 -0
  210. package/app/.next/server/app/api/v0/mcp/route/server-reference-manifest.json +4 -0
  211. package/app/.next/server/app/api/v0/mcp/route.js +10 -0
  212. package/app/.next/server/app/api/v0/mcp/route.js.nft.json +1 -0
  213. package/app/.next/server/app/api/v0/mcp/route_client-reference-manifest.js +3 -0
  214. package/app/.next/server/app/api/v0/requests/[id]/route/app-paths-manifest.json +3 -0
  215. package/app/.next/server/app/api/v0/requests/[id]/route/build-manifest.json +12 -0
  216. package/app/.next/server/app/api/v0/requests/[id]/route/server-reference-manifest.json +4 -0
  217. package/app/.next/server/app/api/v0/requests/[id]/route.js +9 -0
  218. package/app/.next/server/app/api/v0/requests/[id]/route.js.nft.json +1 -0
  219. package/app/.next/server/app/api/v0/requests/[id]/route_client-reference-manifest.js +3 -0
  220. package/app/.next/server/app/api/wake-grants/[id]/revoke/route/app-paths-manifest.json +3 -0
  221. package/app/.next/server/app/api/wake-grants/[id]/revoke/route/build-manifest.json +12 -0
  222. package/app/.next/server/app/api/wake-grants/[id]/revoke/route/server-reference-manifest.json +4 -0
  223. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js +11 -0
  224. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js.nft.json +1 -0
  225. package/app/.next/server/app/api/wake-grants/[id]/revoke/route_client-reference-manifest.js +3 -0
  226. package/app/.next/server/app/api/wakes/[id]/decision/route/app-paths-manifest.json +3 -0
  227. package/app/.next/server/app/api/wakes/[id]/decision/route/build-manifest.json +12 -0
  228. package/app/.next/server/app/api/wakes/[id]/decision/route/server-reference-manifest.json +4 -0
  229. package/app/.next/server/app/api/wakes/[id]/decision/route.js +11 -0
  230. package/app/.next/server/app/api/wakes/[id]/decision/route.js.nft.json +1 -0
  231. package/app/.next/server/app/api/wakes/[id]/decision/route_client-reference-manifest.js +3 -0
  232. package/app/.next/server/app/api/wakes/[id]/retry/route/app-paths-manifest.json +3 -0
  233. package/app/.next/server/app/api/wakes/[id]/retry/route/build-manifest.json +12 -0
  234. package/app/.next/server/app/api/wakes/[id]/retry/route/server-reference-manifest.json +4 -0
  235. package/app/.next/server/app/api/wakes/[id]/retry/route.js +11 -0
  236. package/app/.next/server/app/api/wakes/[id]/retry/route.js.nft.json +1 -0
  237. package/app/.next/server/app/api/wakes/[id]/retry/route_client-reference-manifest.js +3 -0
  238. package/app/.next/server/app/bots/[id]/config/page/app-paths-manifest.json +3 -0
  239. package/app/.next/server/app/bots/[id]/config/page/build-manifest.json +20 -0
  240. package/app/.next/server/app/bots/[id]/config/page/next-font-manifest.json +11 -0
  241. package/app/.next/server/app/bots/[id]/config/page/react-loadable-manifest.json +1 -0
  242. package/app/.next/server/app/bots/[id]/config/page/server-reference-manifest.json +4 -0
  243. package/app/.next/server/app/bots/[id]/config/page.js +13 -0
  244. package/app/.next/server/app/bots/[id]/config/page.js.nft.json +1 -0
  245. package/app/.next/server/app/bots/[id]/config/page_client-reference-manifest.js +3 -0
  246. package/app/.next/server/app/index.html +1 -0
  247. package/app/.next/server/app/index.meta +29 -0
  248. package/app/.next/server/app/index.rsc +20 -0
  249. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +23 -0
  250. package/app/.next/server/app/index.segments/_full.segment.rsc +20 -0
  251. package/app/.next/server/app/index.segments/_tree.segment.rsc +4 -0
  252. package/app/.next/server/app/page/app-paths-manifest.json +3 -0
  253. package/app/.next/server/app/page/build-manifest.json +20 -0
  254. package/app/.next/server/app/page/next-font-manifest.json +11 -0
  255. package/app/.next/server/app/page/react-loadable-manifest.json +1 -0
  256. package/app/.next/server/app/page/server-reference-manifest.json +4 -0
  257. package/app/.next/server/app/page.js +13 -0
  258. package/app/.next/server/app/page.js.nft.json +1 -0
  259. package/app/.next/server/app/page_client-reference-manifest.js +3 -0
  260. package/app/.next/server/app/settings/page/app-paths-manifest.json +3 -0
  261. package/app/.next/server/app/settings/page/build-manifest.json +20 -0
  262. package/app/.next/server/app/settings/page/next-font-manifest.json +11 -0
  263. package/app/.next/server/app/settings/page/react-loadable-manifest.json +1 -0
  264. package/app/.next/server/app/settings/page/server-reference-manifest.json +4 -0
  265. package/app/.next/server/app/settings/page.js +13 -0
  266. package/app/.next/server/app/settings/page.js.nft.json +1 -0
  267. package/app/.next/server/app/settings/page_client-reference-manifest.js +3 -0
  268. package/app/.next/server/app/settings.html +1 -0
  269. package/app/.next/server/app/settings.meta +34 -0
  270. package/app/.next/server/app/settings.rsc +22 -0
  271. package/app/.next/server/app/settings.segments/_full.segment.rsc +22 -0
  272. package/app/.next/server/app/settings.segments/_tree.segment.rsc +4 -0
  273. package/app/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +26 -0
  274. package/app/.next/server/app-paths-manifest.json +40 -0
  275. package/app/.next/server/chunks/1jng_app_api_conversations_[id]_messages_[messageId]_stop_route_actions_1qahzxv.js +3 -0
  276. package/app/.next/server/chunks/[externals]__18bqksw._.js +3 -0
  277. package/app/.next/server/chunks/[root-of-the-server]__00ntari._.js +165 -0
  278. package/app/.next/server/chunks/[root-of-the-server]__07l_rgn._.js +3 -0
  279. package/app/.next/server/chunks/[root-of-the-server]__08i4wq6._.js +3 -0
  280. package/app/.next/server/chunks/[root-of-the-server]__09d-yrq._.js +3 -0
  281. package/app/.next/server/chunks/[root-of-the-server]__0ab4e_k._.js +3 -0
  282. package/app/.next/server/chunks/[root-of-the-server]__0d3fjix._.js +3 -0
  283. package/app/.next/server/chunks/[root-of-the-server]__0izjfmr._.js +1424 -0
  284. package/app/.next/server/chunks/[root-of-the-server]__0qozubc._.js +3 -0
  285. package/app/.next/server/chunks/[root-of-the-server]__0za34e1._.js +7 -0
  286. package/app/.next/server/chunks/[root-of-the-server]__10m3szc._.js +3 -0
  287. package/app/.next/server/chunks/[root-of-the-server]__15bjnu5._.js +5 -0
  288. package/app/.next/server/chunks/[root-of-the-server]__17oz13o._.js +5 -0
  289. package/app/.next/server/chunks/[root-of-the-server]__19hjzs0._.js +3 -0
  290. package/app/.next/server/chunks/[root-of-the-server]__1afl75n._.js +3 -0
  291. package/app/.next/server/chunks/[root-of-the-server]__1fjpie4._.js +3 -0
  292. package/app/.next/server/chunks/[root-of-the-server]__1khwkvb._.js +3 -0
  293. package/app/.next/server/chunks/[root-of-the-server]__1kvvdpx._.js +7 -0
  294. package/app/.next/server/chunks/[root-of-the-server]__1qanlbg._.js +3 -0
  295. package/app/.next/server/chunks/[root-of-the-server]__1qoa704._.js +7 -0
  296. package/app/.next/server/chunks/[root-of-the-server]__1vxmbdl._.js +3 -0
  297. package/app/.next/server/chunks/[root-of-the-server]__20wve4_._.js +3 -0
  298. package/app/.next/server/chunks/[turbopack]_runtime.js +807 -0
  299. package/app/.next/server/chunks/_001yhxu._.js +3 -0
  300. package/app/.next/server/chunks/_09vfvrb._.js +4 -0
  301. package/app/.next/server/chunks/_0a2do3x._.js +3 -0
  302. package/app/.next/server/chunks/_0dc333_._.js +3 -0
  303. package/app/.next/server/chunks/_0ggf7vy._.js +3 -0
  304. package/app/.next/server/chunks/_0gtqbub._.js +3 -0
  305. package/app/.next/server/chunks/_0i7ga8c._.js +3 -0
  306. package/app/.next/server/chunks/_0orubev._.js +3 -0
  307. package/app/.next/server/chunks/_0sfpe9z._.js +3 -0
  308. package/app/.next/server/chunks/_0th2j4w._.js +3 -0
  309. package/app/.next/server/chunks/_0unhh2a._.js +3 -0
  310. package/app/.next/server/chunks/_1-5mthb._.js +3 -0
  311. package/app/.next/server/chunks/_199jbje._.js +3 -0
  312. package/app/.next/server/chunks/_1ee4ej2._.js +3 -0
  313. package/app/.next/server/chunks/_1esxu1s._.js +3 -0
  314. package/app/.next/server/chunks/_1gn7eh7._.js +3 -0
  315. package/app/.next/server/chunks/_1gw7qwf._.js +3 -0
  316. package/app/.next/server/chunks/_1ho6alp._.js +3 -0
  317. package/app/.next/server/chunks/_1inyx08._.js +3 -0
  318. package/app/.next/server/chunks/_1kjsnlr._.js +3 -0
  319. package/app/.next/server/chunks/_1p8rola._.js +3 -0
  320. package/app/.next/server/chunks/_1t5yl-5._.js +3 -0
  321. package/app/.next/server/chunks/_next-internal_server_app_api_agent-deck_decks_route_actions_0yguyfv.js +3 -0
  322. package/app/.next/server/chunks/_next-internal_server_app_api_agent-deck_settings_route_actions_0z_nbkb.js +3 -0
  323. package/app/.next/server/chunks/_next-internal_server_app_api_bots_[id]_config_route_actions_0ze4d5o.js +3 -0
  324. package/app/.next/server/chunks/_next-internal_server_app_api_bots_[id]_skill_route_actions_0g0-9mf.js +3 -0
  325. package/app/.next/server/chunks/_next-internal_server_app_api_bots_availability_route_actions_1i4p_al.js +3 -0
  326. package/app/.next/server/chunks/_next-internal_server_app_api_bots_delete-preview_route_actions_1_i3b_g.js +3 -0
  327. package/app/.next/server/chunks/_next-internal_server_app_api_bots_import_route_actions_1rvqr5o.js +3 -0
  328. package/app/.next/server/chunks/_next-internal_server_app_api_bots_manage_route_actions_1w4bk3a.js +3 -0
  329. package/app/.next/server/chunks/_next-internal_server_app_api_bots_name-migrations_route_actions_1pbn_xd.js +3 -0
  330. package/app/.next/server/chunks/_next-internal_server_app_api_bots_route_actions_0nc-7_e.js +3 -0
  331. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_[id]_approve_route_actions_0bn9gyy.js +3 -0
  332. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_[id]_deny_route_actions_0028jzm.js +3 -0
  333. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_[id]_draft_route_actions_0-i84n9.js +3 -0
  334. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_[id]_messages_route_actions_18znalg.js +3 -0
  335. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_[id]_route_actions_1d9cstb.js +3 -0
  336. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_[id]_stop_route_actions_01th9do.js +3 -0
  337. package/app/.next/server/chunks/_next-internal_server_app_api_conversations_route_actions_1-pu7gs.js +3 -0
  338. package/app/.next/server/chunks/_next-internal_server_app_api_files_[name]_route_actions_0_4hwjw.js +3 -0
  339. package/app/.next/server/chunks/_next-internal_server_app_api_groups_route_actions_1g3bvao.js +3 -0
  340. package/app/.next/server/chunks/_next-internal_server_app_api_health_route_actions_1ryftkb.js +3 -0
  341. package/app/.next/server/chunks/_next-internal_server_app_api_import-capabilities_route_actions_0ojiaoa.js +3 -0
  342. package/app/.next/server/chunks/_next-internal_server_app_api_marketplace-handoff_route_actions_06sqt8e.js +3 -0
  343. package/app/.next/server/chunks/_next-internal_server_app_api_marketplace-handoff_status_route_actions_1wspmjr.js +3 -0
  344. package/app/.next/server/chunks/_next-internal_server_app_api_mcp_route_actions_1thtluk.js +3 -0
  345. package/app/.next/server/chunks/_next-internal_server_app_api_messages_[id]_between_route_actions_1fh_y5e.js +3 -0
  346. package/app/.next/server/chunks/_next-internal_server_app_api_v0_agents_[agentId]_messages_route_actions_04p39zy.js +3 -0
  347. package/app/.next/server/chunks/_next-internal_server_app_api_v0_conversations_[id]_route_actions_1p4d001.js +3 -0
  348. package/app/.next/server/chunks/_next-internal_server_app_api_v0_mcp_route_actions_0rqg06l.js +3 -0
  349. package/app/.next/server/chunks/_next-internal_server_app_api_v0_requests_[id]_route_actions_0goo151.js +3 -0
  350. package/app/.next/server/chunks/_next-internal_server_app_api_wake-grants_[id]_revoke_route_actions_0esbzxd.js +3 -0
  351. package/app/.next/server/chunks/_next-internal_server_app_api_wakes_[id]_decision_route_actions_0torew3.js +3 -0
  352. package/app/.next/server/chunks/_next-internal_server_app_api_wakes_[id]_retry_route_actions_0hrpzfl.js +3 -0
  353. package/app/.next/server/chunks/app_api_import-capabilities_route_ts_013w1kt._.js +3 -0
  354. package/app/.next/server/chunks/lib_051fv4x._.js +111 -0
  355. package/app/.next/server/chunks/lib_07adeq3._.js +111 -0
  356. package/app/.next/server/chunks/lib_0kik6bx._.js +59 -0
  357. package/app/.next/server/chunks/lib_0pe3tiv._.js +59 -0
  358. package/app/.next/server/chunks/lib_0v6lblw._.js +5 -0
  359. package/app/.next/server/chunks/lib_bot-deletion_ts_0zx9yv7._.js +3 -0
  360. package/app/.next/server/chunks/lib_draft_ts_1atoius._.js +3 -0
  361. package/app/.next/server/chunks/node_modules_next_1zc5q0a._.js +158 -0
  362. package/app/.next/server/chunks/ssr/[root-of-the-server]__029oxo_._.js +3 -0
  363. package/app/.next/server/chunks/ssr/[root-of-the-server]__07-2zug._.js +3 -0
  364. package/app/.next/server/chunks/ssr/[root-of-the-server]__0_wvthf._.js +3 -0
  365. package/app/.next/server/chunks/ssr/[root-of-the-server]__0gz0l81._.js +14 -0
  366. package/app/.next/server/chunks/ssr/[root-of-the-server]__0sq4frf._.js +3 -0
  367. package/app/.next/server/chunks/ssr/[root-of-the-server]__194qvx8._.js +3 -0
  368. package/app/.next/server/chunks/ssr/[root-of-the-server]__1aesokn._.js +3 -0
  369. package/app/.next/server/chunks/ssr/[root-of-the-server]__1io3bae._.js +33 -0
  370. package/app/.next/server/chunks/ssr/[root-of-the-server]__1x7o-fe._.js +33 -0
  371. package/app/.next/server/chunks/ssr/[root-of-the-server]__1ypl2q0._.js +3 -0
  372. package/app/.next/server/chunks/ssr/[turbopack]_runtime.js +807 -0
  373. package/app/.next/server/chunks/ssr/_0k_7i66._.js +131 -0
  374. package/app/.next/server/chunks/ssr/_1flnty7._.js +23 -0
  375. package/app/.next/server/chunks/ssr/_1o94bnv._.js +5 -0
  376. package/app/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0zi5s8-.js +3 -0
  377. package/app/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0pt47yr.js +3 -0
  378. package/app/.next/server/chunks/ssr/_next-internal_server_app_bots_[id]_config_page_actions_0lfijvr.js +3 -0
  379. package/app/.next/server/chunks/ssr/_next-internal_server_app_page_actions_0hhsz1j.js +3 -0
  380. package/app/.next/server/chunks/ssr/_next-internal_server_app_settings_page_actions_11x4dq5.js +3 -0
  381. package/app/.next/server/chunks/ssr/app_components_0bhuhd-._.js +3 -0
  382. package/app/.next/server/chunks/ssr/app_components_0w2_b3t._.js +3 -0
  383. package/app/.next/server/chunks/ssr/app_settings_page_tsx_1t-rdz-._.js +3 -0
  384. package/app/.next/server/chunks/ssr/node_modules_1wax83z._.js +33 -0
  385. package/app/.next/server/chunks/ssr/node_modules_@swc_helpers_cjs__interop_require_default_cjs_1ztp13a._.js +3 -0
  386. package/app/.next/server/chunks/ssr/node_modules_next_dist_0nkkbfv._.js +6 -0
  387. package/app/.next/server/chunks/ssr/node_modules_next_dist_1v8aef8._.js +3 -0
  388. package/app/.next/server/chunks/ssr/node_modules_next_dist_client_components_0wpq8j3._.js +3 -0
  389. package/app/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0symwr9.js +3 -0
  390. package/app/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0q-w892.js +3 -0
  391. package/app/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_0l_sp0x.js +3 -0
  392. package/app/.next/server/chunks/ssr/node_modules_next_dist_client_components_server-async-storage_0t1dato.js +3 -0
  393. package/app/.next/server/functions-config-manifest.json +14 -0
  394. package/app/.next/server/middleware-build-manifest.js +24 -0
  395. package/app/.next/server/middleware-manifest.json +6 -0
  396. package/app/.next/server/middleware.js +5 -0
  397. package/app/.next/server/next-font-manifest.js +1 -0
  398. package/app/.next/server/next-font-manifest.json +23 -0
  399. package/app/.next/server/pages/404.html +1 -0
  400. package/app/.next/server/pages/500.html +1 -0
  401. package/app/.next/server/pages-manifest.json +4 -0
  402. package/app/.next/server/prefetch-hints.json +48 -0
  403. package/app/.next/server/server-reference-manifest.js +1 -0
  404. package/app/.next/server/server-reference-manifest.json +5 -0
  405. package/app/.next/static/chunks/0774d7ob6aze_.js +1 -0
  406. package/app/.next/static/chunks/0cz1d0mv5g_q7.js +1 -0
  407. package/app/.next/static/chunks/0d3ein53nlgja.js +1 -0
  408. package/app/.next/static/chunks/0qbtymorcz-l9.js +3 -0
  409. package/app/.next/static/chunks/19mx3mg6lkumu.js +1 -0
  410. package/app/.next/static/chunks/2z-e6jheq0ftu.js +22 -0
  411. package/app/.next/static/chunks/3fntmmi971322.js +1 -0
  412. package/app/.next/static/chunks/3g4px251sg85e.js +1 -0
  413. package/app/.next/static/chunks/3s6nzrbk-8mnv.js +31 -0
  414. package/app/.next/static/chunks/3wdlh25l1vww9.js +1 -0
  415. package/app/.next/static/chunks/3zqbpbm93yqzh.css +3 -0
  416. package/app/.next/static/chunks/turbopack-03rfayxv7ep_b.js +1 -0
  417. package/app/.next/static/media/4fa387ec64143e14-s.2tuy5pz7dlieh.woff2 +0 -0
  418. package/app/.next/static/media/53b9e256198e5412-s.390ncx5urfkfu.woff2 +0 -0
  419. package/app/.next/static/media/5ce348bf30bf5439-s.31988l_ccedte.woff2 +0 -0
  420. package/app/.next/static/media/6306c77e7c8268e4-s.2dbetqa9o8jxf.woff2 +0 -0
  421. package/app/.next/static/media/7178b3e590c64307-s.21jp631_3pja2.woff2 +0 -0
  422. package/app/.next/static/media/797e433ab948586e-s.p.0r6juujl39pe6.woff2 +0 -0
  423. package/app/.next/static/media/7d817b4c03b0c5f1-s.1uyisp29ctx0d.woff2 +0 -0
  424. package/app/.next/static/media/8a480f0b521d4e75-s.1qq4vpdcun5oj.woff2 +0 -0
  425. package/app/.next/static/media/bbc41e54d2fcbd21-s.1rgnod-3esatf.woff2 +0 -0
  426. package/app/.next/static/media/caa3a2e1cccd8315-s.p.0wgildi0cnwt9.woff2 +0 -0
  427. package/app/.next/static/media/fef07dbb0973bf53-s.3p2_lha1f2xer.woff2 +0 -0
  428. package/app/.next/static/u4r8RPgEfpxk-DGXeKV6g/_buildManifest.js +16 -0
  429. package/app/.next/static/u4r8RPgEfpxk-DGXeKV6g/_clientMiddlewareManifest.js +6 -0
  430. package/app/.next/static/u4r8RPgEfpxk-DGXeKV6g/_ssgManifest.js +1 -0
  431. package/app/BUILD_INFO.json +7 -0
  432. package/app/node_modules/@next/env/dist/index.js +1 -0
  433. package/app/node_modules/@next/env/package.json +36 -0
  434. package/app/node_modules/@swc/helpers/cjs/_interop_require_default.cjs +6 -0
  435. package/app/node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs +38 -0
  436. package/app/node_modules/@swc/helpers/esm/_interop_require_default.js +4 -0
  437. package/app/node_modules/@swc/helpers/esm/_interop_require_wildcard.js +36 -0
  438. package/app/node_modules/@swc/helpers/package.json +705 -0
  439. package/app/node_modules/better-sqlite3/LICENSE +21 -0
  440. package/app/node_modules/better-sqlite3/lib/binding.js +62 -0
  441. package/app/node_modules/better-sqlite3/lib/darwin-arm64.js +3 -0
  442. package/app/node_modules/better-sqlite3/lib/darwin-x64.js +3 -0
  443. package/app/node_modules/better-sqlite3/lib/database.js +109 -0
  444. package/app/node_modules/better-sqlite3/lib/index.js +3 -0
  445. package/app/node_modules/better-sqlite3/lib/linux-arm64.js +3 -0
  446. package/app/node_modules/better-sqlite3/lib/linux-x64.js +3 -0
  447. package/app/node_modules/better-sqlite3/lib/linuxmusl-arm64.js +4 -0
  448. package/app/node_modules/better-sqlite3/lib/linuxmusl-x64.js +4 -0
  449. package/app/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
  450. package/app/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
  451. package/app/node_modules/better-sqlite3/lib/methods/explain.js +9 -0
  452. package/app/node_modules/better-sqlite3/lib/methods/function.js +31 -0
  453. package/app/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
  454. package/app/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
  455. package/app/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
  456. package/app/node_modules/better-sqlite3/lib/methods/table.js +195 -0
  457. package/app/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
  458. package/app/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
  459. package/app/node_modules/better-sqlite3/lib/sqlite-error.js +25 -0
  460. package/app/node_modules/better-sqlite3/lib/util.js +12 -0
  461. package/app/node_modules/better-sqlite3/lib/win32-arm64.js +3 -0
  462. package/app/node_modules/better-sqlite3/lib/win32-x64.js +3 -0
  463. package/app/node_modules/better-sqlite3/package.json +67 -0
  464. package/app/node_modules/better-sqlite3/prebuilds/darwin-arm64.node +0 -0
  465. package/app/node_modules/better-sqlite3/prebuilds/darwin-x64.node +0 -0
  466. package/app/node_modules/better-sqlite3/prebuilds/linux-arm64.node +0 -0
  467. package/app/node_modules/better-sqlite3/prebuilds/linux-x64.node +0 -0
  468. package/app/node_modules/better-sqlite3/prebuilds/linuxmusl-arm64.node +0 -0
  469. package/app/node_modules/better-sqlite3/prebuilds/linuxmusl-x64.node +0 -0
  470. package/app/node_modules/better-sqlite3/prebuilds/win32-arm64.node +0 -0
  471. package/app/node_modules/better-sqlite3/prebuilds/win32-x64.node +0 -0
  472. package/app/node_modules/client-only/index.js +0 -0
  473. package/app/node_modules/client-only/package.json +19 -0
  474. package/app/node_modules/next/dist/build/adapter/setup-node-env.external.js +15 -0
  475. package/app/node_modules/next/dist/build/define-env.js +263 -0
  476. package/app/node_modules/next/dist/build/duration-to-string.js +98 -0
  477. package/app/node_modules/next/dist/build/get-supported-browsers.js +38 -0
  478. package/app/node_modules/next/dist/build/next-config-ts/require-hook.js +85 -0
  479. package/app/node_modules/next/dist/build/next-config-ts/transpile-config.js +140 -0
  480. package/app/node_modules/next/dist/build/output/format.js +84 -0
  481. package/app/node_modules/next/dist/build/output/log.js +135 -0
  482. package/app/node_modules/next/dist/build/segment-config/app/app-segment-config.js +178 -0
  483. package/app/node_modules/next/dist/build/segment-config/app/app-segments.js +147 -0
  484. package/app/node_modules/next/dist/build/segment-config/app/collect-root-param-keys.js +52 -0
  485. package/app/node_modules/next/dist/build/static-paths/app/extract-pathname-route-param-segments-from-loader-tree.js +137 -0
  486. package/app/node_modules/next/dist/build/static-paths/app.js +783 -0
  487. package/app/node_modules/next/dist/build/static-paths/pages.js +169 -0
  488. package/app/node_modules/next/dist/build/static-paths/utils.js +119 -0
  489. package/app/node_modules/next/dist/build/swc/helpers.js +15 -0
  490. package/app/node_modules/next/dist/build/swc/index.js +1409 -0
  491. package/app/node_modules/next/dist/build/swc/install-bindings.js +30 -0
  492. package/app/node_modules/next/dist/build/swc/jest-transformer.js +77 -0
  493. package/app/node_modules/next/dist/build/swc/loaderWorkerPool.js +40 -0
  494. package/app/node_modules/next/dist/build/swc/options.js +411 -0
  495. package/app/node_modules/next/dist/build/swc/types.js +6 -0
  496. package/app/node_modules/next/dist/build/utils.js +1258 -0
  497. package/app/node_modules/next/dist/cli/next-test.js +171 -0
  498. package/app/node_modules/next/dist/client/add-base-path.js +24 -0
  499. package/app/node_modules/next/dist/client/app-call-server.js +34 -0
  500. package/app/node_modules/next/dist/client/app-find-source-map-url.js +39 -0
  501. package/app/node_modules/next/dist/client/assign-location.js +29 -0
  502. package/app/node_modules/next/dist/client/components/app-router-announcer.js +78 -0
  503. package/app/node_modules/next/dist/client/components/app-router-headers.js +128 -0
  504. package/app/node_modules/next/dist/client/components/app-router-instance.js +407 -0
  505. package/app/node_modules/next/dist/client/components/app-router-utils.js +62 -0
  506. package/app/node_modules/next/dist/client/components/app-router.js +522 -0
  507. package/app/node_modules/next/dist/client/components/builtin/default.js +35 -0
  508. package/app/node_modules/next/dist/client/components/builtin/error-styles.js +165 -0
  509. package/app/node_modules/next/dist/client/components/builtin/global-error.js +100 -0
  510. package/app/node_modules/next/dist/client/components/dev-root-http-access-fallback-boundary.js +52 -0
  511. package/app/node_modules/next/dist/client/components/error-boundary.js +148 -0
  512. package/app/node_modules/next/dist/client/components/errors/graceful-degrade-boundary.js +86 -0
  513. package/app/node_modules/next/dist/client/components/errors/root-error-boundary.js +41 -0
  514. package/app/node_modules/next/dist/client/components/forbidden.js +48 -0
  515. package/app/node_modules/next/dist/client/components/handle-isr-error.js +30 -0
  516. package/app/node_modules/next/dist/client/components/hooks-server-context.js +42 -0
  517. package/app/node_modules/next/dist/client/components/http-access-fallback/error-boundary.js +125 -0
  518. package/app/node_modules/next/dist/client/components/http-access-fallback/http-access-fallback.js +72 -0
  519. package/app/node_modules/next/dist/client/components/instant-samples.js +134 -0
  520. package/app/node_modules/next/dist/client/components/is-next-router-error.js +23 -0
  521. package/app/node_modules/next/dist/client/components/links.js +316 -0
  522. package/app/node_modules/next/dist/client/components/match-segments.js +32 -0
  523. package/app/node_modules/next/dist/client/components/nav-failure-handler.js +61 -0
  524. package/app/node_modules/next/dist/client/components/navigation-devtools.js +126 -0
  525. package/app/node_modules/next/dist/client/components/navigation-dynamic-rendering.js +38 -0
  526. package/app/node_modules/next/dist/client/components/navigation-untracked.js +69 -0
  527. package/app/node_modules/next/dist/client/components/navigation.js +246 -0
  528. package/app/node_modules/next/dist/client/components/navigation.react-server.js +75 -0
  529. package/app/node_modules/next/dist/client/components/not-found.js +42 -0
  530. package/app/node_modules/next/dist/client/components/offline.js +172 -0
  531. package/app/node_modules/next/dist/client/components/readonly-url-search-params.js +46 -0
  532. package/app/node_modules/next/dist/client/components/redirect-boundary.js +107 -0
  533. package/app/node_modules/next/dist/client/components/redirect-error.js +43 -0
  534. package/app/node_modules/next/dist/client/components/redirect-status-code.js +24 -0
  535. package/app/node_modules/next/dist/client/components/redirect.js +91 -0
  536. package/app/node_modules/next/dist/client/components/router-reducer/compute-changed-path.js +205 -0
  537. package/app/node_modules/next/dist/client/components/router-reducer/create-href-from-url.js +21 -0
  538. package/app/node_modules/next/dist/client/components/router-reducer/create-initial-router-state.js +161 -0
  539. package/app/node_modules/next/dist/client/components/router-reducer/create-router-cache-key.js +32 -0
  540. package/app/node_modules/next/dist/client/components/router-reducer/fetch-server-response.js +603 -0
  541. package/app/node_modules/next/dist/client/components/router-reducer/is-navigating-to-new-root-layout.js +70 -0
  542. package/app/node_modules/next/dist/client/components/router-reducer/ppr-navigations.js +1474 -0
  543. package/app/node_modules/next/dist/client/components/router-reducer/reducers/committed-state.js +49 -0
  544. package/app/node_modules/next/dist/client/components/router-reducer/reducers/find-head-in-cache.js +63 -0
  545. package/app/node_modules/next/dist/client/components/router-reducer/reducers/has-interception-route-in-current-tree.js +38 -0
  546. package/app/node_modules/next/dist/client/components/router-reducer/reducers/hmr-refresh-reducer.js +29 -0
  547. package/app/node_modules/next/dist/client/components/router-reducer/reducers/navigate-reducer.js +56 -0
  548. package/app/node_modules/next/dist/client/components/router-reducer/reducers/refresh-reducer.js +90 -0
  549. package/app/node_modules/next/dist/client/components/router-reducer/reducers/restore-reducer.js +75 -0
  550. package/app/node_modules/next/dist/client/components/router-reducer/reducers/server-action-reducer.js +349 -0
  551. package/app/node_modules/next/dist/client/components/router-reducer/reducers/server-patch-reducer.js +67 -0
  552. package/app/node_modules/next/dist/client/components/router-reducer/router-reducer-types.js +70 -0
  553. package/app/node_modules/next/dist/client/components/router-reducer/router-reducer.js +74 -0
  554. package/app/node_modules/next/dist/client/components/router-reducer/set-cache-busting-search-param.js +66 -0
  555. package/app/node_modules/next/dist/client/components/router-transition.js +135 -0
  556. package/app/node_modules/next/dist/client/components/segment-cache/bfcache.js +130 -0
  557. package/app/node_modules/next/dist/client/components/segment-cache/cache-key.js +56 -0
  558. package/app/node_modules/next/dist/client/components/segment-cache/cache-map.js +326 -0
  559. package/app/node_modules/next/dist/client/components/segment-cache/cache.js +2684 -0
  560. package/app/node_modules/next/dist/client/components/segment-cache/fetch.js +37 -0
  561. package/app/node_modules/next/dist/client/components/segment-cache/lru.js +152 -0
  562. package/app/node_modules/next/dist/client/components/segment-cache/navigation-testing-lock.js +415 -0
  563. package/app/node_modules/next/dist/client/components/segment-cache/navigation.js +773 -0
  564. package/app/node_modules/next/dist/client/components/segment-cache/optimistic-routes.js +648 -0
  565. package/app/node_modules/next/dist/client/components/segment-cache/prefetch.js +32 -0
  566. package/app/node_modules/next/dist/client/components/segment-cache/scheduler.js +1770 -0
  567. package/app/node_modules/next/dist/client/components/segment-cache/types.js +84 -0
  568. package/app/node_modules/next/dist/client/components/segment-cache/vary-path.js +326 -0
  569. package/app/node_modules/next/dist/client/components/server-async-storage.js +43 -0
  570. package/app/node_modules/next/dist/client/components/static-generation-bailout.js +42 -0
  571. package/app/node_modules/next/dist/client/components/unauthorized.js +49 -0
  572. package/app/node_modules/next/dist/client/components/unrecognized-action-error.js +39 -0
  573. package/app/node_modules/next/dist/client/components/unresolved-thenable.js +23 -0
  574. package/app/node_modules/next/dist/client/components/unstable-rethrow.js +32 -0
  575. package/app/node_modules/next/dist/client/components/use-action-queue.js +148 -0
  576. package/app/node_modules/next/dist/client/components/use-offline.js +68 -0
  577. package/app/node_modules/next/dist/client/dev/debug-channel.js +428 -0
  578. package/app/node_modules/next/dist/client/flight-data-helpers.js +235 -0
  579. package/app/node_modules/next/dist/client/has-base-path.js +23 -0
  580. package/app/node_modules/next/dist/client/lib/console.js +177 -0
  581. package/app/node_modules/next/dist/client/lib/javascript-url.js +32 -0
  582. package/app/node_modules/next/dist/client/navigation-build-id.js +53 -0
  583. package/app/node_modules/next/dist/client/normalize-trailing-slash.js +37 -0
  584. package/app/node_modules/next/dist/client/remove-base-path.js +32 -0
  585. package/app/node_modules/next/dist/client/route-params.js +249 -0
  586. package/app/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js +339 -0
  587. package/app/node_modules/next/dist/compiled/@edge-runtime/cookies/package.json +1 -0
  588. package/app/node_modules/next/dist/compiled/@edge-runtime/ponyfill/index.js +46 -0
  589. package/app/node_modules/next/dist/compiled/@edge-runtime/ponyfill/package.json +1 -0
  590. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/abort-controller.js.text.js +1 -0
  591. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/console.js.text.js +1 -0
  592. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/events.js.text.js +1 -0
  593. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/index.js +5 -0
  594. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/load.js +18713 -0
  595. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/package.json +1 -0
  596. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/stream.js +44 -0
  597. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/timers.js.text.js +1 -0
  598. package/app/node_modules/next/dist/compiled/@edge-runtime/primitives/url.js.text.js +1 -0
  599. package/app/node_modules/next/dist/compiled/@hapi/accept/index.js +1 -0
  600. package/app/node_modules/next/dist/compiled/@hapi/accept/package.json +1 -0
  601. package/app/node_modules/next/dist/compiled/@mswjs/interceptors/ClientRequest/index.js +1 -0
  602. package/app/node_modules/next/dist/compiled/@mswjs/interceptors/ClientRequest/package.json +1 -0
  603. package/app/node_modules/next/dist/compiled/@napi-rs/triples/index.js +1 -0
  604. package/app/node_modules/next/dist/compiled/@napi-rs/triples/package.json +1 -0
  605. package/app/node_modules/next/dist/compiled/@opentelemetry/api/index.js +1 -0
  606. package/app/node_modules/next/dist/compiled/@opentelemetry/api/package.json +1 -0
  607. package/app/node_modules/next/dist/compiled/@vercel/detect-agent/index.js +1 -0
  608. package/app/node_modules/next/dist/compiled/@vercel/detect-agent/package.json +1 -0
  609. package/app/node_modules/next/dist/compiled/async-retry/index.js +1 -0
  610. package/app/node_modules/next/dist/compiled/async-retry/package.json +1 -0
  611. package/app/node_modules/next/dist/compiled/async-sema/index.js +1 -0
  612. package/app/node_modules/next/dist/compiled/async-sema/package.json +1 -0
  613. package/app/node_modules/next/dist/compiled/busboy/index.js +1 -0
  614. package/app/node_modules/next/dist/compiled/busboy/package.json +1 -0
  615. package/app/node_modules/next/dist/compiled/bytes/index.js +8 -0
  616. package/app/node_modules/next/dist/compiled/bytes/package.json +1 -0
  617. package/app/node_modules/next/dist/compiled/ci-info/index.js +1 -0
  618. package/app/node_modules/next/dist/compiled/ci-info/package.json +1 -0
  619. package/app/node_modules/next/dist/compiled/commander/index.js +1 -0
  620. package/app/node_modules/next/dist/compiled/commander/package.json +1 -0
  621. package/app/node_modules/next/dist/compiled/comment-json/index.js +7 -0
  622. package/app/node_modules/next/dist/compiled/comment-json/package.json +1 -0
  623. package/app/node_modules/next/dist/compiled/compression/index.js +58 -0
  624. package/app/node_modules/next/dist/compiled/compression/package.json +1 -0
  625. package/app/node_modules/next/dist/compiled/conf/index.js +3 -0
  626. package/app/node_modules/next/dist/compiled/conf/package.json +1 -0
  627. package/app/node_modules/next/dist/compiled/content-disposition/index.js +6 -0
  628. package/app/node_modules/next/dist/compiled/content-disposition/package.json +1 -0
  629. package/app/node_modules/next/dist/compiled/cookie/index.js +7 -0
  630. package/app/node_modules/next/dist/compiled/cookie/package.json +1 -0
  631. package/app/node_modules/next/dist/compiled/cross-spawn/index.js +1 -0
  632. package/app/node_modules/next/dist/compiled/cross-spawn/package.json +1 -0
  633. package/app/node_modules/next/dist/compiled/debug/index.js +1 -0
  634. package/app/node_modules/next/dist/compiled/debug/package.json +1 -0
  635. package/app/node_modules/next/dist/compiled/edge-runtime/index.js +1 -0
  636. package/app/node_modules/next/dist/compiled/edge-runtime/package.json +1 -0
  637. package/app/node_modules/next/dist/compiled/find-up/index.js +1 -0
  638. package/app/node_modules/next/dist/compiled/find-up/package.json +1 -0
  639. package/app/node_modules/next/dist/compiled/fresh/index.js +8 -0
  640. package/app/node_modules/next/dist/compiled/fresh/package.json +1 -0
  641. package/app/node_modules/next/dist/compiled/hash.js/sha256/256.js +1 -0
  642. package/app/node_modules/next/dist/compiled/hash.js/sha256/package.json +1 -0
  643. package/app/node_modules/next/dist/compiled/httpxy/index.js +1 -0
  644. package/app/node_modules/next/dist/compiled/httpxy/package.json +1 -0
  645. package/app/node_modules/next/dist/compiled/image-detector/detector.js +1 -0
  646. package/app/node_modules/next/dist/compiled/image-size/index.js +1 -0
  647. package/app/node_modules/next/dist/compiled/image-size/package.json +1 -0
  648. package/app/node_modules/next/dist/compiled/ipaddr.js/ipaddr.js +1 -0
  649. package/app/node_modules/next/dist/compiled/ipaddr.js/package.json +1 -0
  650. package/app/node_modules/next/dist/compiled/is-animated/index.js +1 -0
  651. package/app/node_modules/next/dist/compiled/is-animated/package.json +1 -0
  652. package/app/node_modules/next/dist/compiled/is-docker/index.js +1 -0
  653. package/app/node_modules/next/dist/compiled/is-docker/package.json +1 -0
  654. package/app/node_modules/next/dist/compiled/is-wsl/index.js +1 -0
  655. package/app/node_modules/next/dist/compiled/is-wsl/package.json +1 -0
  656. package/app/node_modules/next/dist/compiled/jsonwebtoken/index.js +11 -0
  657. package/app/node_modules/next/dist/compiled/jsonwebtoken/package.json +1 -0
  658. package/app/node_modules/next/dist/compiled/nanoid/index.cjs +1 -0
  659. package/app/node_modules/next/dist/compiled/nanoid/package.json +1 -0
  660. package/app/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +183 -0
  661. package/app/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +183 -0
  662. package/app/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +6 -0
  663. package/app/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +20 -0
  664. package/app/node_modules/next/dist/compiled/p-limit/index.js +1 -0
  665. package/app/node_modules/next/dist/compiled/p-limit/package.json +1 -0
  666. package/app/node_modules/next/dist/compiled/p-queue/index.js +1 -0
  667. package/app/node_modules/next/dist/compiled/p-queue/package.json +1 -0
  668. package/app/node_modules/next/dist/compiled/path-browserify/index.js +1 -0
  669. package/app/node_modules/next/dist/compiled/path-browserify/package.json +1 -0
  670. package/app/node_modules/next/dist/compiled/path-to-regexp/index.js +1 -0
  671. package/app/node_modules/next/dist/compiled/path-to-regexp/package.json +1 -0
  672. package/app/node_modules/next/dist/compiled/picomatch/index.js +1 -0
  673. package/app/node_modules/next/dist/compiled/picomatch/package.json +1 -0
  674. package/app/node_modules/next/dist/compiled/react-is/cjs/react-is.development.js +133 -0
  675. package/app/node_modules/next/dist/compiled/react-is/cjs/react-is.production.js +130 -0
  676. package/app/node_modules/next/dist/compiled/react-is/index.js +7 -0
  677. package/app/node_modules/next/dist/compiled/react-is/package.json +26 -0
  678. package/app/node_modules/next/dist/compiled/regenerator-runtime/package.json +19 -0
  679. package/app/node_modules/next/dist/compiled/regenerator-runtime/runtime.js +729 -0
  680. package/app/node_modules/next/dist/compiled/semver/index.js +1 -0
  681. package/app/node_modules/next/dist/compiled/semver/package.json +1 -0
  682. package/app/node_modules/next/dist/compiled/send/index.js +70 -0
  683. package/app/node_modules/next/dist/compiled/send/package.json +1 -0
  684. package/app/node_modules/next/dist/compiled/source-map/package.json +1 -0
  685. package/app/node_modules/next/dist/compiled/source-map/source-map.js +1 -0
  686. package/app/node_modules/next/dist/compiled/stacktrace-parser/package.json +1 -0
  687. package/app/node_modules/next/dist/compiled/stacktrace-parser/stack-trace-parser.cjs.js +1 -0
  688. package/app/node_modules/next/dist/compiled/string-hash/index.js +1 -0
  689. package/app/node_modules/next/dist/compiled/string-hash/package.json +1 -0
  690. package/app/node_modules/next/dist/compiled/strip-ansi/index.js +1 -0
  691. package/app/node_modules/next/dist/compiled/strip-ansi/package.json +1 -0
  692. package/app/node_modules/next/dist/compiled/superstruct/index.cjs +1 -0
  693. package/app/node_modules/next/dist/compiled/superstruct/package.json +1 -0
  694. package/app/node_modules/next/dist/compiled/tar/index.min.js +1 -0
  695. package/app/node_modules/next/dist/compiled/tar/package.json +1 -0
  696. package/app/node_modules/next/dist/compiled/text-table/index.js +1 -0
  697. package/app/node_modules/next/dist/compiled/text-table/package.json +1 -0
  698. package/app/node_modules/next/dist/compiled/watchpack/package.json +1 -0
  699. package/app/node_modules/next/dist/compiled/watchpack/watchpack.js +1 -0
  700. package/app/node_modules/next/dist/compiled/write-file-atomic/index.js +1 -0
  701. package/app/node_modules/next/dist/compiled/write-file-atomic/package.json +1 -0
  702. package/app/node_modules/next/dist/compiled/ws/index.js +1 -0
  703. package/app/node_modules/next/dist/compiled/ws/package.json +1 -0
  704. package/app/node_modules/next/dist/compiled/zod/index.cjs +1 -0
  705. package/app/node_modules/next/dist/compiled/zod/package.json +1 -0
  706. package/app/node_modules/next/dist/compiled/zod-validation-error/index.js +1 -0
  707. package/app/node_modules/next/dist/compiled/zod-validation-error/package.json +1 -0
  708. package/app/node_modules/next/dist/experimental/testmode/context.js +57 -0
  709. package/app/node_modules/next/dist/experimental/testmode/fetch.js +158 -0
  710. package/app/node_modules/next/dist/experimental/testmode/httpget.js +33 -0
  711. package/app/node_modules/next/dist/experimental/testmode/server-edge.js +32 -0
  712. package/app/node_modules/next/dist/experimental/testmode/server.js +73 -0
  713. package/app/node_modules/next/dist/export/helpers/create-incremental-cache.js +61 -0
  714. package/app/node_modules/next/dist/lib/batcher.js +65 -0
  715. package/app/node_modules/next/dist/lib/build-custom-route.js +46 -0
  716. package/app/node_modules/next/dist/lib/bundler.js +168 -0
  717. package/app/node_modules/next/dist/lib/client-and-server-references.js +54 -0
  718. package/app/node_modules/next/dist/lib/coalesced-function.js +39 -0
  719. package/app/node_modules/next/dist/lib/compile-error.js +14 -0
  720. package/app/node_modules/next/dist/lib/constants.js +420 -0
  721. package/app/node_modules/next/dist/lib/create-client-router-filter.js +83 -0
  722. package/app/node_modules/next/dist/lib/default-transpiled-packages.json +1 -0
  723. package/app/node_modules/next/dist/lib/detached-promise.js +32 -0
  724. package/app/node_modules/next/dist/lib/detect-typo.js +51 -0
  725. package/app/node_modules/next/dist/lib/download-swc.js +183 -0
  726. package/app/node_modules/next/dist/lib/error-telemetry-utils.js +42 -0
  727. package/app/node_modules/next/dist/lib/fallback.js +100 -0
  728. package/app/node_modules/next/dist/lib/file-exists.js +53 -0
  729. package/app/node_modules/next/dist/lib/find-config.js +102 -0
  730. package/app/node_modules/next/dist/lib/find-pages-dir.js +65 -0
  731. package/app/node_modules/next/dist/lib/find-root.js +280 -0
  732. package/app/node_modules/next/dist/lib/format-cli-help-output.js +84 -0
  733. package/app/node_modules/next/dist/lib/format-dynamic-import-path.js +43 -0
  734. package/app/node_modules/next/dist/lib/format-server-error.js +75 -0
  735. package/app/node_modules/next/dist/lib/framework/boundary-components.js +62 -0
  736. package/app/node_modules/next/dist/lib/framework/boundary-constants.js +36 -0
  737. package/app/node_modules/next/dist/lib/fs/rename.js +87 -0
  738. package/app/node_modules/next/dist/lib/fs/write-atomic.js +28 -0
  739. package/app/node_modules/next/dist/lib/generate-interception-routes-rewrites.js +52 -0
  740. package/app/node_modules/next/dist/lib/get-files-in-dir.js +33 -0
  741. package/app/node_modules/next/dist/lib/get-network-host.js +44 -0
  742. package/app/node_modules/next/dist/lib/get-package-version.js +118 -0
  743. package/app/node_modules/next/dist/lib/get-project-dir.js +51 -0
  744. package/app/node_modules/next/dist/lib/git-worktree.js +74 -0
  745. package/app/node_modules/next/dist/lib/has-necessary-dependencies.js +49 -0
  746. package/app/node_modules/next/dist/lib/helpers/get-cache-directory.js +66 -0
  747. package/app/node_modules/next/dist/lib/helpers/get-npx-command.js +29 -0
  748. package/app/node_modules/next/dist/lib/helpers/get-online.js +50 -0
  749. package/app/node_modules/next/dist/lib/helpers/get-pkg-manager.js +65 -0
  750. package/app/node_modules/next/dist/lib/helpers/get-registry.js +45 -0
  751. package/app/node_modules/next/dist/lib/helpers/get-reserved-port.js +116 -0
  752. package/app/node_modules/next/dist/lib/helpers/git.js +59 -0
  753. package/app/node_modules/next/dist/lib/helpers/install.js +83 -0
  754. package/app/node_modules/next/dist/lib/import-next-warning.js +50 -0
  755. package/app/node_modules/next/dist/lib/inline-static-env.js +112 -0
  756. package/app/node_modules/next/dist/lib/install-dependencies.js +40 -0
  757. package/app/node_modules/next/dist/lib/interop-default.js +16 -0
  758. package/app/node_modules/next/dist/lib/is-api-route.js +15 -0
  759. package/app/node_modules/next/dist/lib/is-app-page-route.js +15 -0
  760. package/app/node_modules/next/dist/lib/is-app-route-route.js +15 -0
  761. package/app/node_modules/next/dist/lib/is-edge-runtime.js +16 -0
  762. package/app/node_modules/next/dist/lib/is-error.js +78 -0
  763. package/app/node_modules/next/dist/lib/is-interception-route-rewrite.js +18 -0
  764. package/app/node_modules/next/dist/lib/is-internal-component.js +36 -0
  765. package/app/node_modules/next/dist/lib/is-serializable-props.js +111 -0
  766. package/app/node_modules/next/dist/lib/known-edge-safe-packages.json +1 -0
  767. package/app/node_modules/next/dist/lib/load-custom-routes.js +594 -0
  768. package/app/node_modules/next/dist/lib/memory/gc-observer.js +53 -0
  769. package/app/node_modules/next/dist/lib/memory/shutdown.js +29 -0
  770. package/app/node_modules/next/dist/lib/memory/startup.js +47 -0
  771. package/app/node_modules/next/dist/lib/memory/trace.js +109 -0
  772. package/app/node_modules/next/dist/lib/metadata/constants.js +40 -0
  773. package/app/node_modules/next/dist/lib/metadata/default-metadata.js +82 -0
  774. package/app/node_modules/next/dist/lib/metadata/generate/icon-mark.js +22 -0
  775. package/app/node_modules/next/dist/lib/metadata/generate/utils.js +52 -0
  776. package/app/node_modules/next/dist/lib/metadata/get-metadata-route.js +162 -0
  777. package/app/node_modules/next/dist/lib/metadata/is-metadata-route.js +221 -0
  778. package/app/node_modules/next/dist/lib/metadata/metadata-context.js +18 -0
  779. package/app/node_modules/next/dist/lib/metadata/metadata.js +1660 -0
  780. package/app/node_modules/next/dist/lib/metadata/resolve-metadata.js +884 -0
  781. package/app/node_modules/next/dist/lib/metadata/resolvers/resolve-basics.js +232 -0
  782. package/app/node_modules/next/dist/lib/metadata/resolvers/resolve-icons.js +56 -0
  783. package/app/node_modules/next/dist/lib/metadata/resolvers/resolve-opengraph.js +199 -0
  784. package/app/node_modules/next/dist/lib/metadata/resolvers/resolve-title.js +40 -0
  785. package/app/node_modules/next/dist/lib/metadata/resolvers/resolve-url.js +135 -0
  786. package/app/node_modules/next/dist/lib/metadata/types/alternative-urls-types.js +7 -0
  787. package/app/node_modules/next/dist/lib/metadata/types/extra-types.js +9 -0
  788. package/app/node_modules/next/dist/lib/metadata/types/icons.js +6 -0
  789. package/app/node_modules/next/dist/lib/metadata/types/manifest-types.js +6 -0
  790. package/app/node_modules/next/dist/lib/metadata/types/metadata-interface.js +18 -0
  791. package/app/node_modules/next/dist/lib/metadata/types/metadata-types.js +10 -0
  792. package/app/node_modules/next/dist/lib/metadata/types/opengraph-types.js +6 -0
  793. package/app/node_modules/next/dist/lib/metadata/types/resolvers.js +6 -0
  794. package/app/node_modules/next/dist/lib/metadata/types/twitter-types.js +7 -0
  795. package/app/node_modules/next/dist/lib/mime-type.js +20 -0
  796. package/app/node_modules/next/dist/lib/mkcert.js +204 -0
  797. package/app/node_modules/next/dist/lib/multi-file-writer.js +75 -0
  798. package/app/node_modules/next/dist/lib/needs-experimental-react.js +16 -0
  799. package/app/node_modules/next/dist/lib/non-nullable.js +15 -0
  800. package/app/node_modules/next/dist/lib/normalize-path.js +21 -0
  801. package/app/node_modules/next/dist/lib/oxford-comma-list.js +15 -0
  802. package/app/node_modules/next/dist/lib/page-types.js +18 -0
  803. package/app/node_modules/next/dist/lib/patch-incorrect-lockfile.js +185 -0
  804. package/app/node_modules/next/dist/lib/pick.js +19 -0
  805. package/app/node_modules/next/dist/lib/picocolors.js +177 -0
  806. package/app/node_modules/next/dist/lib/pretty-bytes.js +74 -0
  807. package/app/node_modules/next/dist/lib/profiles-dir.js +45 -0
  808. package/app/node_modules/next/dist/lib/realpath.js +20 -0
  809. package/app/node_modules/next/dist/lib/recursive-copy.js +76 -0
  810. package/app/node_modules/next/dist/lib/recursive-delete.js +137 -0
  811. package/app/node_modules/next/dist/lib/recursive-readdir.js +124 -0
  812. package/app/node_modules/next/dist/lib/redirect-status.js +46 -0
  813. package/app/node_modules/next/dist/lib/require-instrumentation-client.js +32 -0
  814. package/app/node_modules/next/dist/lib/resolve-build-paths.js +182 -0
  815. package/app/node_modules/next/dist/lib/resolve-from.js +65 -0
  816. package/app/node_modules/next/dist/lib/route-pattern-normalizer.js +107 -0
  817. package/app/node_modules/next/dist/lib/scheduler.js +64 -0
  818. package/app/node_modules/next/dist/lib/semver-noop.js +18 -0
  819. package/app/node_modules/next/dist/lib/server-external-packages.jsonc +103 -0
  820. package/app/node_modules/next/dist/lib/setup-exception-listeners.js +11 -0
  821. package/app/node_modules/next/dist/lib/static-env.js +92 -0
  822. package/app/node_modules/next/dist/lib/try-to-parse-path.js +67 -0
  823. package/app/node_modules/next/dist/lib/turbopack-cache-seed.js +171 -0
  824. package/app/node_modules/next/dist/lib/turbopack-warning.js +185 -0
  825. package/app/node_modules/next/dist/lib/typescript/diagnosticFormatter.js +243 -0
  826. package/app/node_modules/next/dist/lib/typescript/getTypeScriptConfiguration.js +73 -0
  827. package/app/node_modules/next/dist/lib/typescript/getTypeScriptIntent.js +52 -0
  828. package/app/node_modules/next/dist/lib/typescript/loadTsConfig.js +181 -0
  829. package/app/node_modules/next/dist/lib/typescript/missingDependencyError.js +26 -0
  830. package/app/node_modules/next/dist/lib/typescript/runTypeCheck.js +149 -0
  831. package/app/node_modules/next/dist/lib/typescript/runTypeCheckCli.js +53 -0
  832. package/app/node_modules/next/dist/lib/typescript/runTypeScriptCli.js +256 -0
  833. package/app/node_modules/next/dist/lib/typescript/type-paths.js +51 -0
  834. package/app/node_modules/next/dist/lib/typescript/writeAppTypeDeclarations.js +77 -0
  835. package/app/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js +395 -0
  836. package/app/node_modules/next/dist/lib/url.js +75 -0
  837. package/app/node_modules/next/dist/lib/verify-partytown-setup.js +104 -0
  838. package/app/node_modules/next/dist/lib/verify-root-layout.js +165 -0
  839. package/app/node_modules/next/dist/lib/verify-typescript-setup.js +271 -0
  840. package/app/node_modules/next/dist/lib/wait.js +19 -0
  841. package/app/node_modules/next/dist/lib/with-promise-cache.js +24 -0
  842. package/app/node_modules/next/dist/lib/worker.js +234 -0
  843. package/app/node_modules/next/dist/server/ReactDOMServerPages.js +16 -0
  844. package/app/node_modules/next/dist/server/accept-header.js +132 -0
  845. package/app/node_modules/next/dist/server/after/after-context.js +178 -0
  846. package/app/node_modules/next/dist/server/after/after.js +28 -0
  847. package/app/node_modules/next/dist/server/after/awaiter.js +74 -0
  848. package/app/node_modules/next/dist/server/after/builtin-request-context.js +38 -0
  849. package/app/node_modules/next/dist/server/after/index.js +21 -0
  850. package/app/node_modules/next/dist/server/after/run-with-after.js +35 -0
  851. package/app/node_modules/next/dist/server/api-utils/get-cookie-parser.js +22 -0
  852. package/app/node_modules/next/dist/server/api-utils/index.js +217 -0
  853. package/app/node_modules/next/dist/server/api-utils/node/api-resolver.js +395 -0
  854. package/app/node_modules/next/dist/server/api-utils/node/parse-body.js +79 -0
  855. package/app/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js +89 -0
  856. package/app/node_modules/next/dist/server/api-utils/web.js +17 -0
  857. package/app/node_modules/next/dist/server/app-render/action-async-storage-instance.js +14 -0
  858. package/app/node_modules/next/dist/server/app-render/action-async-storage.external.js +13 -0
  859. package/app/node_modules/next/dist/server/app-render/action-handler.js +1125 -0
  860. package/app/node_modules/next/dist/server/app-render/after-task-async-storage-instance.js +14 -0
  861. package/app/node_modules/next/dist/server/app-render/after-task-async-storage.external.js +13 -0
  862. package/app/node_modules/next/dist/server/app-render/app-render-prerender-utils.js +332 -0
  863. package/app/node_modules/next/dist/server/app-render/app-render-render-utils.js +76 -0
  864. package/app/node_modules/next/dist/server/app-render/app-render-scheduling.js +188 -0
  865. package/app/node_modules/next/dist/server/app-render/app-render.js +6496 -0
  866. package/app/node_modules/next/dist/server/app-render/async-local-storage.js +76 -0
  867. package/app/node_modules/next/dist/server/app-render/blocking-route-messages.js +181 -0
  868. package/app/node_modules/next/dist/server/app-render/cache-signal.js +181 -0
  869. package/app/node_modules/next/dist/server/app-render/collect-segment-data.js +937 -0
  870. package/app/node_modules/next/dist/server/app-render/console-async-storage-instance.js +14 -0
  871. package/app/node_modules/next/dist/server/app-render/console-async-storage.external.js +13 -0
  872. package/app/node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js +39 -0
  873. package/app/node_modules/next/dist/server/app-render/create-component-tree.js +806 -0
  874. package/app/node_modules/next/dist/server/app-render/create-error-handler.js +190 -0
  875. package/app/node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js +154 -0
  876. package/app/node_modules/next/dist/server/app-render/csrf-protection.js +86 -0
  877. package/app/node_modules/next/dist/server/app-render/debug-channel-server.js +47 -0
  878. package/app/node_modules/next/dist/server/app-render/debug-channel-server.node.js +60 -0
  879. package/app/node_modules/next/dist/server/app-render/debug-channel-server.web.js +60 -0
  880. package/app/node_modules/next/dist/server/app-render/dev-validation-error-delivery.js +37 -0
  881. package/app/node_modules/next/dist/server/app-render/dev-validation-events.js +26 -0
  882. package/app/node_modules/next/dist/server/app-render/dev-validation-scheduler.js +87 -0
  883. package/app/node_modules/next/dist/server/app-render/dev-validation-worker-globals.js +41 -0
  884. package/app/node_modules/next/dist/server/app-render/dev-validation-worker-snapshot.js +79 -0
  885. package/app/node_modules/next/dist/server/app-render/dynamic-access-async-storage-instance.js +14 -0
  886. package/app/node_modules/next/dist/server/app-render/dynamic-access-async-storage.external.js +13 -0
  887. package/app/node_modules/next/dist/server/app-render/dynamic-rendering.js +1201 -0
  888. package/app/node_modules/next/dist/server/app-render/encryption-utils-server.js +114 -0
  889. package/app/node_modules/next/dist/server/app-render/encryption-utils.js +93 -0
  890. package/app/node_modules/next/dist/server/app-render/encryption.js +261 -0
  891. package/app/node_modules/next/dist/server/app-render/entry-base.js +265 -0
  892. package/app/node_modules/next/dist/server/app-render/flight-render-result.js +28 -0
  893. package/app/node_modules/next/dist/server/app-render/get-asset-query-string.js +29 -0
  894. package/app/node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js +45 -0
  895. package/app/node_modules/next/dist/server/app-render/get-layer-assets.js +69 -0
  896. package/app/node_modules/next/dist/server/app-render/get-preloadable-fonts.js +39 -0
  897. package/app/node_modules/next/dist/server/app-render/get-script-nonce-from-header.js +32 -0
  898. package/app/node_modules/next/dist/server/app-render/get-short-dynamic-param-type.js +25 -0
  899. package/app/node_modules/next/dist/server/app-render/has-loading-component-in-tree.js +19 -0
  900. package/app/node_modules/next/dist/server/app-render/instant-test-bootstrap.js +20 -0
  901. package/app/node_modules/next/dist/server/app-render/instant-validation/boundary-constants.js +31 -0
  902. package/app/node_modules/next/dist/server/app-render/instant-validation/boundary-impl.js +127 -0
  903. package/app/node_modules/next/dist/server/app-render/instant-validation/boundary-tracking.js +38 -0
  904. package/app/node_modules/next/dist/server/app-render/instant-validation/instant-config.js +241 -0
  905. package/app/node_modules/next/dist/server/app-render/instant-validation/instant-samples.js +432 -0
  906. package/app/node_modules/next/dist/server/app-render/instant-validation/instant-validation-error.js +33 -0
  907. package/app/node_modules/next/dist/server/app-render/instant-validation/instant-validation.js +934 -0
  908. package/app/node_modules/next/dist/server/app-render/instant-validation/stream-utils.js +96 -0
  909. package/app/node_modules/next/dist/server/app-render/interop-default.js +17 -0
  910. package/app/node_modules/next/dist/server/app-render/make-get-server-inserted-html.js +91 -0
  911. package/app/node_modules/next/dist/server/app-render/manifests-singleton.js +327 -0
  912. package/app/node_modules/next/dist/server/app-render/metadata-insertion/create-server-inserted-metadata.js +29 -0
  913. package/app/node_modules/next/dist/server/app-render/module-loading/instrument-module-getter.js +32 -0
  914. package/app/node_modules/next/dist/server/app-render/module-loading/track-dynamic-import.js +57 -0
  915. package/app/node_modules/next/dist/server/app-render/module-loading/track-module-loading.external.js +32 -0
  916. package/app/node_modules/next/dist/server/app-render/module-loading/track-module-loading.instance.js +62 -0
  917. package/app/node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js +49 -0
  918. package/app/node_modules/next/dist/server/app-render/postponed-state.js +230 -0
  919. package/app/node_modules/next/dist/server/app-render/prospective-render-utils.js +74 -0
  920. package/app/node_modules/next/dist/server/app-render/react-large-shell-error.js +17 -0
  921. package/app/node_modules/next/dist/server/app-render/react-server.node.js +39 -0
  922. package/app/node_modules/next/dist/server/app-render/render-css-resource.js +57 -0
  923. package/app/node_modules/next/dist/server/app-render/required-scripts.js +76 -0
  924. package/app/node_modules/next/dist/server/app-render/rsc/postpone.js +18 -0
  925. package/app/node_modules/next/dist/server/app-render/rsc/preloads.js +74 -0
  926. package/app/node_modules/next/dist/server/app-render/rsc/taint.js +79 -0
  927. package/app/node_modules/next/dist/server/app-render/segment-explorer-path.js +128 -0
  928. package/app/node_modules/next/dist/server/app-render/server-inserted-html.js +77 -0
  929. package/app/node_modules/next/dist/server/app-render/staged-rendering.js +324 -0
  930. package/app/node_modules/next/dist/server/app-render/stale-time.js +101 -0
  931. package/app/node_modules/next/dist/server/app-render/stream-ops.js +155 -0
  932. package/app/node_modules/next/dist/server/app-render/stream-ops.node.js +842 -0
  933. package/app/node_modules/next/dist/server/app-render/stream-ops.web.js +249 -0
  934. package/app/node_modules/next/dist/server/app-render/strip-flight-headers.js +18 -0
  935. package/app/node_modules/next/dist/server/app-render/sync-io-messages.js +67 -0
  936. package/app/node_modules/next/dist/server/app-render/types.js +65 -0
  937. package/app/node_modules/next/dist/server/app-render/use-flight-response.js +217 -0
  938. package/app/node_modules/next/dist/server/app-render/vary-params.js +261 -0
  939. package/app/node_modules/next/dist/server/app-render/wait-for-response.js +36 -0
  940. package/app/node_modules/next/dist/server/app-render/walk-tree-with-flight-router-state.js +237 -0
  941. package/app/node_modules/next/dist/server/app-render/work-async-storage-instance.js +14 -0
  942. package/app/node_modules/next/dist/server/app-render/work-async-storage.external.js +13 -0
  943. package/app/node_modules/next/dist/server/app-render/work-unit-async-storage-instance.js +14 -0
  944. package/app/node_modules/next/dist/server/app-render/work-unit-async-storage.external.js +250 -0
  945. package/app/node_modules/next/dist/server/async-storage/draft-mode-provider.js +62 -0
  946. package/app/node_modules/next/dist/server/async-storage/request-store.js +201 -0
  947. package/app/node_modules/next/dist/server/async-storage/with-store.js +6 -0
  948. package/app/node_modules/next/dist/server/async-storage/work-store.js +98 -0
  949. package/app/node_modules/next/dist/server/base-http/helpers.js +36 -0
  950. package/app/node_modules/next/dist/server/base-http/index.js +54 -0
  951. package/app/node_modules/next/dist/server/base-http/node.js +147 -0
  952. package/app/node_modules/next/dist/server/base-http/web.js +124 -0
  953. package/app/node_modules/next/dist/server/base-server.js +1956 -0
  954. package/app/node_modules/next/dist/server/body-streams.js +122 -0
  955. package/app/node_modules/next/dist/server/cache-dir.js +26 -0
  956. package/app/node_modules/next/dist/server/capsize-font-metrics.json +181516 -0
  957. package/app/node_modules/next/dist/server/ci-info.js +41 -0
  958. package/app/node_modules/next/dist/server/client-component-renderer-logger.js +70 -0
  959. package/app/node_modules/next/dist/server/config-schema.js +800 -0
  960. package/app/node_modules/next/dist/server/config-shared.js +395 -0
  961. package/app/node_modules/next/dist/server/config-utils.js +185 -0
  962. package/app/node_modules/next/dist/server/config.js +1836 -0
  963. package/app/node_modules/next/dist/server/create-deduped-by-callsite-server-error-logger.js +96 -0
  964. package/app/node_modules/next/dist/server/crypto-utils.js +70 -0
  965. package/app/node_modules/next/dist/server/dev/browser-logs/file-logger.js +186 -0
  966. package/app/node_modules/next/dist/server/dev/browser-logs/receive-logs.js +610 -0
  967. package/app/node_modules/next/dist/server/dev/browser-logs/source-map.js +222 -0
  968. package/app/node_modules/next/dist/server/dev/debug-channel.js +112 -0
  969. package/app/node_modules/next/dist/server/dev/dev-indicator-server-state.js +15 -0
  970. package/app/node_modules/next/dist/server/dev/dev-validation-worker-pool.js +232 -0
  971. package/app/node_modules/next/dist/server/dev/dev-validation-worker.js +308 -0
  972. package/app/node_modules/next/dist/server/dev/get-source-map-from-file.js +100 -0
  973. package/app/node_modules/next/dist/server/dev/hot-middleware.js +276 -0
  974. package/app/node_modules/next/dist/server/dev/hot-reloader-rspack.js +171 -0
  975. package/app/node_modules/next/dist/server/dev/hot-reloader-shared-utils.js +56 -0
  976. package/app/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +1756 -0
  977. package/app/node_modules/next/dist/server/dev/hot-reloader-types.js +60 -0
  978. package/app/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1380 -0
  979. package/app/node_modules/next/dist/server/dev/log-requests.js +152 -0
  980. package/app/node_modules/next/dist/server/dev/messages.js +74 -0
  981. package/app/node_modules/next/dist/server/dev/middleware-turbopack.js +422 -0
  982. package/app/node_modules/next/dist/server/dev/middleware-webpack.js +495 -0
  983. package/app/node_modules/next/dist/server/dev/node-stack-frames.js +81 -0
  984. package/app/node_modules/next/dist/server/dev/on-demand-entry-handler.js +773 -0
  985. package/app/node_modules/next/dist/server/dev/parse-version-info.js +108 -0
  986. package/app/node_modules/next/dist/server/dev/require-cache.js +109 -0
  987. package/app/node_modules/next/dist/server/dev/serialized-errors.js +67 -0
  988. package/app/node_modules/next/dist/server/dev/server-action-logger.js +37 -0
  989. package/app/node_modules/next/dist/server/dev/static-paths-worker.js +106 -0
  990. package/app/node_modules/next/dist/server/dev/turbopack-utils.js +727 -0
  991. package/app/node_modules/next/dist/server/dev/use-cache-probe-pool.js +177 -0
  992. package/app/node_modules/next/dist/server/dev/use-cache-probe-worker.js +180 -0
  993. package/app/node_modules/next/dist/server/dynamic-rendering-utils.js +285 -0
  994. package/app/node_modules/next/dist/server/font-utils.js +43 -0
  995. package/app/node_modules/next/dist/server/get-app-route-from-entrypoint.js +30 -0
  996. package/app/node_modules/next/dist/server/get-page-files.js +40 -0
  997. package/app/node_modules/next/dist/server/get-route-from-entrypoint.js +35 -0
  998. package/app/node_modules/next/dist/server/image-optimizer.js +1474 -0
  999. package/app/node_modules/next/dist/server/instrumentation/types.js +6 -0
  1000. package/app/node_modules/next/dist/server/instrumentation/utils.js +21 -0
  1001. package/app/node_modules/next/dist/server/internal-utils.js +39 -0
  1002. package/app/node_modules/next/dist/server/is-private-ip.js +36 -0
  1003. package/app/node_modules/next/dist/server/lib/app-dir-module.js +59 -0
  1004. package/app/node_modules/next/dist/server/lib/app-info-log.js +135 -0
  1005. package/app/node_modules/next/dist/server/lib/async-callback-set.js +29 -0
  1006. package/app/node_modules/next/dist/server/lib/cache-control.js +22 -0
  1007. package/app/node_modules/next/dist/server/lib/cache-handlers/default.external.js +18 -0
  1008. package/app/node_modules/next/dist/server/lib/cache-handlers/default.js +196 -0
  1009. package/app/node_modules/next/dist/server/lib/cache-handlers/types.js +8 -0
  1010. package/app/node_modules/next/dist/server/lib/chrome-devtools-workspace.js +116 -0
  1011. package/app/node_modules/next/dist/server/lib/clone-response.js +77 -0
  1012. package/app/node_modules/next/dist/server/lib/cpu-profile.js +56 -0
  1013. package/app/node_modules/next/dist/server/lib/decode-query-path-parameter.js +26 -0
  1014. package/app/node_modules/next/dist/server/lib/dedupe-fetch.js +163 -0
  1015. package/app/node_modules/next/dist/server/lib/dev-bundler-service.js +110 -0
  1016. package/app/node_modules/next/dist/server/lib/disk-lru-cache.external.js +63 -0
  1017. package/app/node_modules/next/dist/server/lib/encode-header-safe.js +44 -0
  1018. package/app/node_modules/next/dist/server/lib/etag.js +56 -0
  1019. package/app/node_modules/next/dist/server/lib/experimental/create-env-definitions.js +48 -0
  1020. package/app/node_modules/next/dist/server/lib/experimental/ppr.js +47 -0
  1021. package/app/node_modules/next/dist/server/lib/find-page-file.js +147 -0
  1022. package/app/node_modules/next/dist/server/lib/fix-mojibake.js +25 -0
  1023. package/app/node_modules/next/dist/server/lib/format-hostname.js +16 -0
  1024. package/app/node_modules/next/dist/server/lib/generate-agent-files.js +180 -0
  1025. package/app/node_modules/next/dist/server/lib/i18n-provider.js +129 -0
  1026. package/app/node_modules/next/dist/server/lib/implicit-tags.js +87 -0
  1027. package/app/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +506 -0
  1028. package/app/node_modules/next/dist/server/lib/incremental-cache/index.js +566 -0
  1029. package/app/node_modules/next/dist/server/lib/incremental-cache/memory-cache.external.js +59 -0
  1030. package/app/node_modules/next/dist/server/lib/incremental-cache/shared-cache-controls.external.js +81 -0
  1031. package/app/node_modules/next/dist/server/lib/incremental-cache/tags-manifest.external.js +55 -0
  1032. package/app/node_modules/next/dist/server/lib/install-code-frame.js +22 -0
  1033. package/app/node_modules/next/dist/server/lib/is-ipv6.js +41 -0
  1034. package/app/node_modules/next/dist/server/lib/is-non-html-sec-fetch-dest.js +38 -0
  1035. package/app/node_modules/next/dist/server/lib/is-rsc-request.js +18 -0
  1036. package/app/node_modules/next/dist/server/lib/lazy-module.js +80 -0
  1037. package/app/node_modules/next/dist/server/lib/lazy-result.js +46 -0
  1038. package/app/node_modules/next/dist/server/lib/lru-cache.js +191 -0
  1039. package/app/node_modules/next/dist/server/lib/match-next-data-pathname.js +20 -0
  1040. package/app/node_modules/next/dist/server/lib/mock-request.js +441 -0
  1041. package/app/node_modules/next/dist/server/lib/module-loader/module-loader.js +8 -0
  1042. package/app/node_modules/next/dist/server/lib/module-loader/node-module-loader.js +25 -0
  1043. package/app/node_modules/next/dist/server/lib/module-loader/route-module-loader.js +26 -0
  1044. package/app/node_modules/next/dist/server/lib/node-fs-methods.js +42 -0
  1045. package/app/node_modules/next/dist/server/lib/params-utils.js +70 -0
  1046. package/app/node_modules/next/dist/server/lib/parse-stack.js +46 -0
  1047. package/app/node_modules/next/dist/server/lib/patch-fetch.js +1027 -0
  1048. package/app/node_modules/next/dist/server/lib/patch-set-header.js +45 -0
  1049. package/app/node_modules/next/dist/server/lib/postponed-request-body.js +64 -0
  1050. package/app/node_modules/next/dist/server/lib/release-compression-stream.js +24 -0
  1051. package/app/node_modules/next/dist/server/lib/render-server.js +157 -0
  1052. package/app/node_modules/next/dist/server/lib/route-cache-key.js +77 -0
  1053. package/app/node_modules/next/dist/server/lib/router-server.js +756 -0
  1054. package/app/node_modules/next/dist/server/lib/router-utils/block-cross-site-dev.js +108 -0
  1055. package/app/node_modules/next/dist/server/lib/router-utils/build-data-route.js +48 -0
  1056. package/app/node_modules/next/dist/server/lib/router-utils/build-prefetch-segment-data-route.js +50 -0
  1057. package/app/node_modules/next/dist/server/lib/router-utils/cache-life-type-utils.js +212 -0
  1058. package/app/node_modules/next/dist/server/lib/router-utils/decode-path-params.js +42 -0
  1059. package/app/node_modules/next/dist/server/lib/router-utils/filesystem.js +612 -0
  1060. package/app/node_modules/next/dist/server/lib/router-utils/instrumentation-globals.external.js +89 -0
  1061. package/app/node_modules/next/dist/server/lib/router-utils/instrumentation-node-extensions.js +114 -0
  1062. package/app/node_modules/next/dist/server/lib/router-utils/is-postpone.js +16 -0
  1063. package/app/node_modules/next/dist/server/lib/router-utils/proxy-request.js +128 -0
  1064. package/app/node_modules/next/dist/server/lib/router-utils/resolve-routes.js +646 -0
  1065. package/app/node_modules/next/dist/server/lib/router-utils/root-params-type-utils.js +61 -0
  1066. package/app/node_modules/next/dist/server/lib/router-utils/route-types-utils.js +326 -0
  1067. package/app/node_modules/next/dist/server/lib/router-utils/router-server-context.js +26 -0
  1068. package/app/node_modules/next/dist/server/lib/router-utils/typegen.js +892 -0
  1069. package/app/node_modules/next/dist/server/lib/router-utils/types.js +6 -0
  1070. package/app/node_modules/next/dist/server/lib/server-action-request-meta.js +53 -0
  1071. package/app/node_modules/next/dist/server/lib/server-ipc/utils.js +83 -0
  1072. package/app/node_modules/next/dist/server/lib/source-maps.js +241 -0
  1073. package/app/node_modules/next/dist/server/lib/start-server.js +540 -0
  1074. package/app/node_modules/next/dist/server/lib/streaming-metadata.js +27 -0
  1075. package/app/node_modules/next/dist/server/lib/to-route.js +37 -0
  1076. package/app/node_modules/next/dist/server/lib/trace/constants.js +208 -0
  1077. package/app/node_modules/next/dist/server/lib/trace/local-span-recorder.js +385 -0
  1078. package/app/node_modules/next/dist/server/lib/trace/request-insights-identity.js +39 -0
  1079. package/app/node_modules/next/dist/server/lib/trace/request-insights.js +308 -0
  1080. package/app/node_modules/next/dist/server/lib/trace/span-store.js +69 -0
  1081. package/app/node_modules/next/dist/server/lib/trace/tracer.js +392 -0
  1082. package/app/node_modules/next/dist/server/lib/trace/utils.js +16 -0
  1083. package/app/node_modules/next/dist/server/lib/types.js +6 -0
  1084. package/app/node_modules/next/dist/server/lib/utils.js +292 -0
  1085. package/app/node_modules/next/dist/server/lib/worker-utils.js +36 -0
  1086. package/app/node_modules/next/dist/server/load-components.js +185 -0
  1087. package/app/node_modules/next/dist/server/load-default-error-components.js +41 -0
  1088. package/app/node_modules/next/dist/server/load-manifest.external.js +117 -0
  1089. package/app/node_modules/next/dist/server/match-bundle.js +25 -0
  1090. package/app/node_modules/next/dist/server/mcp/get-mcp-middleware.js +51 -0
  1091. package/app/node_modules/next/dist/server/mcp/get-or-create-mcp-server.js +51 -0
  1092. package/app/node_modules/next/dist/server/mcp/mcp-telemetry-tracker.js +82 -0
  1093. package/app/node_modules/next/dist/server/mcp/tools/compile-route.js +86 -0
  1094. package/app/node_modules/next/dist/server/mcp/tools/get-compilation-issues.js +68 -0
  1095. package/app/node_modules/next/dist/server/mcp/tools/get-errors.js +114 -0
  1096. package/app/node_modules/next/dist/server/mcp/tools/get-logs.js +67 -0
  1097. package/app/node_modules/next/dist/server/mcp/tools/get-page-metadata.js +188 -0
  1098. package/app/node_modules/next/dist/server/mcp/tools/get-project-metadata.js +59 -0
  1099. package/app/node_modules/next/dist/server/mcp/tools/get-request-insights.js +57 -0
  1100. package/app/node_modules/next/dist/server/mcp/tools/get-routes.js +136 -0
  1101. package/app/node_modules/next/dist/server/mcp/tools/get-server-action-by-id.js +121 -0
  1102. package/app/node_modules/next/dist/server/mcp/tools/next-instance-error-state.js +31 -0
  1103. package/app/node_modules/next/dist/server/mcp/tools/utils/browser-communication.js +90 -0
  1104. package/app/node_modules/next/dist/server/mcp/tools/utils/format-compilation-issues.js +72 -0
  1105. package/app/node_modules/next/dist/server/mcp/tools/utils/format-errors.js +137 -0
  1106. package/app/node_modules/next/dist/server/mcp/tools/utils/resolve-path-to-route.js +49 -0
  1107. package/app/node_modules/next/dist/server/next-server.js +1447 -0
  1108. package/app/node_modules/next/dist/server/next-typescript.js +13 -0
  1109. package/app/node_modules/next/dist/server/next.js +485 -0
  1110. package/app/node_modules/next/dist/server/node-environment-baseline.js +25 -0
  1111. package/app/node_modules/next/dist/server/node-environment-extensions/console-dim.external.js +301 -0
  1112. package/app/node_modules/next/dist/server/node-environment-extensions/console-exit.js +49 -0
  1113. package/app/node_modules/next/dist/server/node-environment-extensions/console-file.js +56 -0
  1114. package/app/node_modules/next/dist/server/node-environment-extensions/date.js +52 -0
  1115. package/app/node_modules/next/dist/server/node-environment-extensions/error-inspect.js +8 -0
  1116. package/app/node_modules/next/dist/server/node-environment-extensions/fast-set-immediate.external.js +577 -0
  1117. package/app/node_modules/next/dist/server/node-environment-extensions/global-behaviors.js +33 -0
  1118. package/app/node_modules/next/dist/server/node-environment-extensions/io-utils.js +102 -0
  1119. package/app/node_modules/next/dist/server/node-environment-extensions/node-crypto.js +103 -0
  1120. package/app/node_modules/next/dist/server/node-environment-extensions/process-error-handlers.js +170 -0
  1121. package/app/node_modules/next/dist/server/node-environment-extensions/random.js +28 -0
  1122. package/app/node_modules/next/dist/server/node-environment-extensions/unhandled-rejection.external.js +518 -0
  1123. package/app/node_modules/next/dist/server/node-environment-extensions/web-crypto.js +45 -0
  1124. package/app/node_modules/next/dist/server/node-environment.js +19 -0
  1125. package/app/node_modules/next/dist/server/node-polyfill-crypto.js +21 -0
  1126. package/app/node_modules/next/dist/server/normalizers/absolute-filename-normalizer.js +33 -0
  1127. package/app/node_modules/next/dist/server/normalizers/built/app/app-bundle-path-normalizer.js +54 -0
  1128. package/app/node_modules/next/dist/server/normalizers/built/app/app-filename-normalizer.js +22 -0
  1129. package/app/node_modules/next/dist/server/normalizers/built/app/app-page-normalizer.js +40 -0
  1130. package/app/node_modules/next/dist/server/normalizers/built/app/app-pathname-normalizer.js +55 -0
  1131. package/app/node_modules/next/dist/server/normalizers/built/app/index.js +42 -0
  1132. package/app/node_modules/next/dist/server/normalizers/built/pages/index.js +44 -0
  1133. package/app/node_modules/next/dist/server/normalizers/built/pages/pages-bundle-path-normalizer.js +55 -0
  1134. package/app/node_modules/next/dist/server/normalizers/built/pages/pages-filename-normalizer.js +22 -0
  1135. package/app/node_modules/next/dist/server/normalizers/built/pages/pages-page-normalizer.js +19 -0
  1136. package/app/node_modules/next/dist/server/normalizers/built/pages/pages-pathname-normalizer.js +19 -0
  1137. package/app/node_modules/next/dist/server/normalizers/locale-route-normalizer.js +26 -0
  1138. package/app/node_modules/next/dist/server/normalizers/normalizer.js +6 -0
  1139. package/app/node_modules/next/dist/server/normalizers/normalizers.js +23 -0
  1140. package/app/node_modules/next/dist/server/normalizers/prefixing-normalizer.js +26 -0
  1141. package/app/node_modules/next/dist/server/normalizers/request/base-path.js +25 -0
  1142. package/app/node_modules/next/dist/server/normalizers/request/next-data.js +38 -0
  1143. package/app/node_modules/next/dist/server/normalizers/request/pathname-normalizer.js +6 -0
  1144. package/app/node_modules/next/dist/server/normalizers/request/prefix.js +39 -0
  1145. package/app/node_modules/next/dist/server/normalizers/request/rsc.js +19 -0
  1146. package/app/node_modules/next/dist/server/normalizers/request/segment-prefix-rsc.js +33 -0
  1147. package/app/node_modules/next/dist/server/normalizers/request/suffix.js +27 -0
  1148. package/app/node_modules/next/dist/server/normalizers/underscore-normalizer.js +17 -0
  1149. package/app/node_modules/next/dist/server/normalizers/wrap-normalizer-fn.js +17 -0
  1150. package/app/node_modules/next/dist/server/og/cache-image-response.js +341 -0
  1151. package/app/node_modules/next/dist/server/og/image-response.js +72 -0
  1152. package/app/node_modules/next/dist/server/patch-error-inspect.js +507 -0
  1153. package/app/node_modules/next/dist/server/pipe-readable.js +212 -0
  1154. package/app/node_modules/next/dist/server/post-process.js +39 -0
  1155. package/app/node_modules/next/dist/server/render-result.js +246 -0
  1156. package/app/node_modules/next/dist/server/render.js +1150 -0
  1157. package/app/node_modules/next/dist/server/request/connection.js +135 -0
  1158. package/app/node_modules/next/dist/server/request/cookies.js +239 -0
  1159. package/app/node_modules/next/dist/server/request/draft-mode.js +238 -0
  1160. package/app/node_modules/next/dist/server/request/fallback-params.js +95 -0
  1161. package/app/node_modules/next/dist/server/request/headers.js +235 -0
  1162. package/app/node_modules/next/dist/server/request/io.js +96 -0
  1163. package/app/node_modules/next/dist/server/request/params.js +634 -0
  1164. package/app/node_modules/next/dist/server/request/pathname.js +141 -0
  1165. package/app/node_modules/next/dist/server/request/root-params.js +202 -0
  1166. package/app/node_modules/next/dist/server/request/search-params.js +582 -0
  1167. package/app/node_modules/next/dist/server/request/utils.js +84 -0
  1168. package/app/node_modules/next/dist/server/request-meta.js +55 -0
  1169. package/app/node_modules/next/dist/server/require-hook.js +82 -0
  1170. package/app/node_modules/next/dist/server/require.js +109 -0
  1171. package/app/node_modules/next/dist/server/response-cache/index.js +339 -0
  1172. package/app/node_modules/next/dist/server/response-cache/types.js +41 -0
  1173. package/app/node_modules/next/dist/server/response-cache/utils.js +104 -0
  1174. package/app/node_modules/next/dist/server/response-cache/web.js +101 -0
  1175. package/app/node_modules/next/dist/server/resume-data-cache/cache-store.js +101 -0
  1176. package/app/node_modules/next/dist/server/resume-data-cache/resume-data-cache.js +142 -0
  1177. package/app/node_modules/next/dist/server/revalidation-utils.js +156 -0
  1178. package/app/node_modules/next/dist/server/route-definitions/app-page-route-definition.js +16 -0
  1179. package/app/node_modules/next/dist/server/route-definitions/app-route-route-definition.js +6 -0
  1180. package/app/node_modules/next/dist/server/route-definitions/locale-route-definition.js +6 -0
  1181. package/app/node_modules/next/dist/server/route-definitions/pages-api-route-definition.js +6 -0
  1182. package/app/node_modules/next/dist/server/route-definitions/pages-route-definition.js +6 -0
  1183. package/app/node_modules/next/dist/server/route-definitions/route-definition.js +6 -0
  1184. package/app/node_modules/next/dist/server/route-kind.js +32 -0
  1185. package/app/node_modules/next/dist/server/route-matcher-managers/default-route-matcher-manager.js +239 -0
  1186. package/app/node_modules/next/dist/server/route-matcher-managers/dev-route-matcher-manager.js +120 -0
  1187. package/app/node_modules/next/dist/server/route-matcher-managers/route-matcher-manager.js +6 -0
  1188. package/app/node_modules/next/dist/server/route-matcher-providers/app-page-route-matcher-provider.js +55 -0
  1189. package/app/node_modules/next/dist/server/route-matcher-providers/app-route-route-matcher-provider.js +43 -0
  1190. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.js +91 -0
  1191. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-app-route-route-matcher-provider.js +112 -0
  1192. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.js +77 -0
  1193. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-pages-route-matcher-provider.js +77 -0
  1194. package/app/node_modules/next/dist/server/route-matcher-providers/dev/file-cache-route-matcher-provider.js +28 -0
  1195. package/app/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.js +106 -0
  1196. package/app/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.js +42 -0
  1197. package/app/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/file-reader.js +6 -0
  1198. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/cached-route-matcher-provider.js +30 -0
  1199. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/manifest-loader.js +6 -0
  1200. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.js +34 -0
  1201. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.js +20 -0
  1202. package/app/node_modules/next/dist/server/route-matcher-providers/manifest-route-matcher-provider.js +21 -0
  1203. package/app/node_modules/next/dist/server/route-matcher-providers/pages-api-route-matcher-provider.js +55 -0
  1204. package/app/node_modules/next/dist/server/route-matcher-providers/pages-route-matcher-provider.js +64 -0
  1205. package/app/node_modules/next/dist/server/route-matcher-providers/route-matcher-provider.js +6 -0
  1206. package/app/node_modules/next/dist/server/route-matchers/app-page-route-matcher.js +18 -0
  1207. package/app/node_modules/next/dist/server/route-matchers/app-route-route-matcher.js +15 -0
  1208. package/app/node_modules/next/dist/server/route-matchers/locale-route-matcher.js +68 -0
  1209. package/app/node_modules/next/dist/server/route-matchers/pages-api-route-matcher.js +30 -0
  1210. package/app/node_modules/next/dist/server/route-matchers/pages-route-matcher.js +30 -0
  1211. package/app/node_modules/next/dist/server/route-matchers/route-matcher.js +54 -0
  1212. package/app/node_modules/next/dist/server/route-matches/app-page-route-match.js +6 -0
  1213. package/app/node_modules/next/dist/server/route-matches/app-route-route-match.js +6 -0
  1214. package/app/node_modules/next/dist/server/route-matches/locale-route-match.js +6 -0
  1215. package/app/node_modules/next/dist/server/route-matches/pages-api-route-match.js +16 -0
  1216. package/app/node_modules/next/dist/server/route-matches/pages-route-match.js +6 -0
  1217. package/app/node_modules/next/dist/server/route-matches/route-match.js +6 -0
  1218. package/app/node_modules/next/dist/server/route-modules/app-page/helpers/prerender-manifest-matcher.js +51 -0
  1219. package/app/node_modules/next/dist/server/route-modules/app-page/module.compiled.js +36 -0
  1220. package/app/node_modules/next/dist/server/route-modules/app-page/module.js +176 -0
  1221. package/app/node_modules/next/dist/server/route-modules/app-page/module.render.js +24 -0
  1222. package/app/node_modules/next/dist/server/route-modules/app-page/normalize-request-url.js +62 -0
  1223. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/app-router-context.js +4 -0
  1224. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/entrypoints.js +87 -0
  1225. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/head-manager-context.js +4 -0
  1226. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/hooks-client-context.js +4 -0
  1227. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/image-config-context.js +4 -0
  1228. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/router-context.js +4 -0
  1229. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/server-inserted-html.js +4 -0
  1230. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/entrypoints.js +140 -0
  1231. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-compiler-runtime.js +4 -0
  1232. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-dom.js +4 -0
  1233. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-jsx-dev-runtime.js +4 -0
  1234. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-jsx-runtime.js +4 -0
  1235. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server.js +4 -0
  1236. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-static.js +4 -0
  1237. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-webpack-server.js +4 -0
  1238. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-webpack-static.js +4 -0
  1239. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react.js +4 -0
  1240. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/entrypoints.js +125 -0
  1241. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-compiler-runtime.js +4 -0
  1242. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-dom-server.js +4 -0
  1243. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-dom.js +4 -0
  1244. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime.js +4 -0
  1245. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-runtime.js +4 -0
  1246. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client.js +4 -0
  1247. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-server-dom-webpack-client.js +4 -0
  1248. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js +4 -0
  1249. package/app/node_modules/next/dist/server/route-modules/app-route/helpers/auto-implement-methods.js +85 -0
  1250. package/app/node_modules/next/dist/server/route-modules/app-route/helpers/clean-url.js +24 -0
  1251. package/app/node_modules/next/dist/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.js +29 -0
  1252. package/app/node_modules/next/dist/server/route-modules/app-route/helpers/is-static-gen-enabled.js +15 -0
  1253. package/app/node_modules/next/dist/server/route-modules/app-route/helpers/parsed-url-query-to-params.js +20 -0
  1254. package/app/node_modules/next/dist/server/route-modules/app-route/module.compiled.js +36 -0
  1255. package/app/node_modules/next/dist/server/route-modules/app-route/module.js +948 -0
  1256. package/app/node_modules/next/dist/server/route-modules/app-route/shared-modules.js +56 -0
  1257. package/app/node_modules/next/dist/server/route-modules/checks.js +45 -0
  1258. package/app/node_modules/next/dist/server/route-modules/pages/builtin/_error.js +100 -0
  1259. package/app/node_modules/next/dist/server/route-modules/pages/module.compiled.js +20 -0
  1260. package/app/node_modules/next/dist/server/route-modules/pages/module.js +92 -0
  1261. package/app/node_modules/next/dist/server/route-modules/pages/module.render.js +24 -0
  1262. package/app/node_modules/next/dist/server/route-modules/pages/pages-handler.js +572 -0
  1263. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/app-router-context.js +4 -0
  1264. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/entrypoints.js +102 -0
  1265. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/head-manager-context.js +4 -0
  1266. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/hooks-client-context.js +4 -0
  1267. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/html-context.js +4 -0
  1268. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/image-config-context.js +4 -0
  1269. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/loadable-context.js +4 -0
  1270. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/loadable.js +4 -0
  1271. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/router-context.js +4 -0
  1272. package/app/node_modules/next/dist/server/route-modules/pages/vendored/contexts/server-inserted-html.js +4 -0
  1273. package/app/node_modules/next/dist/server/route-modules/pages-api/module.compiled.js +20 -0
  1274. package/app/node_modules/next/dist/server/route-modules/pages-api/module.js +58 -0
  1275. package/app/node_modules/next/dist/server/route-modules/route-module.js +704 -0
  1276. package/app/node_modules/next/dist/server/runtime-reacts.external.js +46 -0
  1277. package/app/node_modules/next/dist/server/send-payload.js +88 -0
  1278. package/app/node_modules/next/dist/server/send-response.js +70 -0
  1279. package/app/node_modules/next/dist/server/serve-static.js +66 -0
  1280. package/app/node_modules/next/dist/server/server-route-utils.js +30 -0
  1281. package/app/node_modules/next/dist/server/server-utils.js +340 -0
  1282. package/app/node_modules/next/dist/server/setup-http-agent-env.js +31 -0
  1283. package/app/node_modules/next/dist/server/stream-utils/encoded-tags.js +122 -0
  1284. package/app/node_modules/next/dist/server/stream-utils/node-buffered-transform-stream.js +51 -0
  1285. package/app/node_modules/next/dist/server/stream-utils/node-web-streams-helper.js +939 -0
  1286. package/app/node_modules/next/dist/server/stream-utils/uint8array-helpers.js +74 -0
  1287. package/app/node_modules/next/dist/server/typescript/constant.js +98 -0
  1288. package/app/node_modules/next/dist/server/typescript/index.js +199 -0
  1289. package/app/node_modules/next/dist/server/typescript/rules/client-boundary.js +100 -0
  1290. package/app/node_modules/next/dist/server/typescript/rules/config.js +534 -0
  1291. package/app/node_modules/next/dist/server/typescript/rules/entry.js +149 -0
  1292. package/app/node_modules/next/dist/server/typescript/rules/error.js +38 -0
  1293. package/app/node_modules/next/dist/server/typescript/rules/metadata.js +234 -0
  1294. package/app/node_modules/next/dist/server/typescript/rules/server-boundary.js +115 -0
  1295. package/app/node_modules/next/dist/server/typescript/rules/server.js +79 -0
  1296. package/app/node_modules/next/dist/server/typescript/utils.js +212 -0
  1297. package/app/node_modules/next/dist/server/use-cache/cache-life-profile.js +84 -0
  1298. package/app/node_modules/next/dist/server/use-cache/cache-life.js +102 -0
  1299. package/app/node_modules/next/dist/server/use-cache/cache-tag.js +52 -0
  1300. package/app/node_modules/next/dist/server/use-cache/clone-cache-entry.js +28 -0
  1301. package/app/node_modules/next/dist/server/use-cache/constants.js +44 -0
  1302. package/app/node_modules/next/dist/server/use-cache/handlers.js +274 -0
  1303. package/app/node_modules/next/dist/server/use-cache/tiered-cache-handler.js +145 -0
  1304. package/app/node_modules/next/dist/server/use-cache/use-cache-errors.js +59 -0
  1305. package/app/node_modules/next/dist/server/use-cache/use-cache-probe-globals.js +39 -0
  1306. package/app/node_modules/next/dist/server/use-cache/use-cache-probe-scheduler.js +117 -0
  1307. package/app/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +2611 -0
  1308. package/app/node_modules/next/dist/server/utils.js +73 -0
  1309. package/app/node_modules/next/dist/server/web/adapter.js +428 -0
  1310. package/app/node_modules/next/dist/server/web/edge-route-module-wrapper.js +136 -0
  1311. package/app/node_modules/next/dist/server/web/error.js +69 -0
  1312. package/app/node_modules/next/dist/server/web/exports/index.js +56 -0
  1313. package/app/node_modules/next/dist/server/web/get-edge-preview-props.js +23 -0
  1314. package/app/node_modules/next/dist/server/web/globals.js +128 -0
  1315. package/app/node_modules/next/dist/server/web/http.js +39 -0
  1316. package/app/node_modules/next/dist/server/web/internal-edge-wait-until.js +64 -0
  1317. package/app/node_modules/next/dist/server/web/next-url.js +199 -0
  1318. package/app/node_modules/next/dist/server/web/sandbox/context.js +468 -0
  1319. package/app/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.js +35 -0
  1320. package/app/node_modules/next/dist/server/web/sandbox/index.js +28 -0
  1321. package/app/node_modules/next/dist/server/web/sandbox/resource-managers.js +123 -0
  1322. package/app/node_modules/next/dist/server/web/sandbox/sandbox.js +137 -0
  1323. package/app/node_modules/next/dist/server/web/spec-extension/adapters/headers.js +293 -0
  1324. package/app/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js +142 -0
  1325. package/app/node_modules/next/dist/server/web/spec-extension/adapters/reflect.js +30 -0
  1326. package/app/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js +226 -0
  1327. package/app/node_modules/next/dist/server/web/spec-extension/cookies.js +29 -0
  1328. package/app/node_modules/next/dist/server/web/spec-extension/fetch-event.js +98 -0
  1329. package/app/node_modules/next/dist/server/web/spec-extension/image-response.js +22 -0
  1330. package/app/node_modules/next/dist/server/web/spec-extension/request.js +99 -0
  1331. package/app/node_modules/next/dist/server/web/spec-extension/response.js +136 -0
  1332. package/app/node_modules/next/dist/server/web/spec-extension/revalidate.js +226 -0
  1333. package/app/node_modules/next/dist/server/web/spec-extension/unstable-cache.js +307 -0
  1334. package/app/node_modules/next/dist/server/web/spec-extension/unstable-no-store.js +51 -0
  1335. package/app/node_modules/next/dist/server/web/spec-extension/url-pattern.js +13 -0
  1336. package/app/node_modules/next/dist/server/web/spec-extension/user-agent.js +46 -0
  1337. package/app/node_modules/next/dist/server/web/types.js +6 -0
  1338. package/app/node_modules/next/dist/server/web/utils.js +151 -0
  1339. package/app/node_modules/next/dist/server/web/web-on-close.js +87 -0
  1340. package/app/node_modules/next/dist/shared/lib/action-revalidation-kind.js +31 -0
  1341. package/app/node_modules/next/dist/shared/lib/app-router-context.shared-runtime.js +50 -0
  1342. package/app/node_modules/next/dist/shared/lib/app-router-types.js +159 -0
  1343. package/app/node_modules/next/dist/shared/lib/constants.js +453 -0
  1344. package/app/node_modules/next/dist/shared/lib/deep-freeze.js +30 -0
  1345. package/app/node_modules/next/dist/shared/lib/deployment-id.js +63 -0
  1346. package/app/node_modules/next/dist/shared/lib/dset.js +34 -0
  1347. package/app/node_modules/next/dist/shared/lib/encode-uri-path.js +15 -0
  1348. package/app/node_modules/next/dist/shared/lib/entry-constants.js +36 -0
  1349. package/app/node_modules/next/dist/shared/lib/error-source.js +36 -0
  1350. package/app/node_modules/next/dist/shared/lib/errors/code-frame.js +20 -0
  1351. package/app/node_modules/next/dist/shared/lib/errors/constants.js +19 -0
  1352. package/app/node_modules/next/dist/shared/lib/errors/empty-generate-static-params-error.js +31 -0
  1353. package/app/node_modules/next/dist/shared/lib/errors/hard-deprecated-config-error.js +25 -0
  1354. package/app/node_modules/next/dist/shared/lib/escape-regexp.js +22 -0
  1355. package/app/node_modules/next/dist/shared/lib/get-hostname.js +23 -0
  1356. package/app/node_modules/next/dist/shared/lib/hash.js +42 -0
  1357. package/app/node_modules/next/dist/shared/lib/head-manager-context.shared-runtime.js +18 -0
  1358. package/app/node_modules/next/dist/shared/lib/head.js +164 -0
  1359. package/app/node_modules/next/dist/shared/lib/hooks-client-context.shared-runtime.js +60 -0
  1360. package/app/node_modules/next/dist/shared/lib/html-context.shared-runtime.js +40 -0
  1361. package/app/node_modules/next/dist/shared/lib/htmlescape.js +52 -0
  1362. package/app/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js +25 -0
  1363. package/app/node_modules/next/dist/shared/lib/i18n/get-locale-redirect.js +59 -0
  1364. package/app/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js +54 -0
  1365. package/app/node_modules/next/dist/shared/lib/image-blur-svg.js +22 -0
  1366. package/app/node_modules/next/dist/shared/lib/image-config-context.shared-runtime.js +19 -0
  1367. package/app/node_modules/next/dist/shared/lib/image-config.js +77 -0
  1368. package/app/node_modules/next/dist/shared/lib/instant-messages.js +43 -0
  1369. package/app/node_modules/next/dist/shared/lib/invariant-error.js +23 -0
  1370. package/app/node_modules/next/dist/shared/lib/is-plain-object.js +42 -0
  1371. package/app/node_modules/next/dist/shared/lib/is-thenable.js +20 -0
  1372. package/app/node_modules/next/dist/shared/lib/isomorphic/path.js +14 -0
  1373. package/app/node_modules/next/dist/shared/lib/lazy-dynamic/bailout-to-csr.js +37 -0
  1374. package/app/node_modules/next/dist/shared/lib/loadable-context.shared-runtime.js +19 -0
  1375. package/app/node_modules/next/dist/shared/lib/loadable.shared-runtime.js +246 -0
  1376. package/app/node_modules/next/dist/shared/lib/match-local-pattern.js +46 -0
  1377. package/app/node_modules/next/dist/shared/lib/match-remote-pattern.js +63 -0
  1378. package/app/node_modules/next/dist/shared/lib/modern-browserslist-target.js +15 -0
  1379. package/app/node_modules/next/dist/shared/lib/no-fallback-error.external.js +18 -0
  1380. package/app/node_modules/next/dist/shared/lib/normalized-asset-prefix.js +28 -0
  1381. package/app/node_modules/next/dist/shared/lib/page-path/absolute-path-to-page.js +26 -0
  1382. package/app/node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js +18 -0
  1383. package/app/node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js +18 -0
  1384. package/app/node_modules/next/dist/shared/lib/page-path/get-page-paths.js +40 -0
  1385. package/app/node_modules/next/dist/shared/lib/page-path/normalize-data-path.js +23 -0
  1386. package/app/node_modules/next/dist/shared/lib/page-path/normalize-page-path.js +26 -0
  1387. package/app/node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js +19 -0
  1388. package/app/node_modules/next/dist/shared/lib/page-path/remove-page-path-tail.js +20 -0
  1389. package/app/node_modules/next/dist/shared/lib/promise-with-resolvers.js +26 -0
  1390. package/app/node_modules/next/dist/shared/lib/request-insights.js +30 -0
  1391. package/app/node_modules/next/dist/shared/lib/router/adapters.js +139 -0
  1392. package/app/node_modules/next/dist/shared/lib/router/routes/app.js +158 -0
  1393. package/app/node_modules/next/dist/shared/lib/router/utils/add-locale.js +28 -0
  1394. package/app/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js +20 -0
  1395. package/app/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js +20 -0
  1396. package/app/node_modules/next/dist/shared/lib/router/utils/app-paths.js +79 -0
  1397. package/app/node_modules/next/dist/shared/lib/router/utils/as-path-to-search-params.js +17 -0
  1398. package/app/node_modules/next/dist/shared/lib/router/utils/cache-busting-search-param.js +70 -0
  1399. package/app/node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js +16 -0
  1400. package/app/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js +27 -0
  1401. package/app/node_modules/next/dist/shared/lib/router/utils/format-url.js +111 -0
  1402. package/app/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.js +174 -0
  1403. package/app/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js +52 -0
  1404. package/app/node_modules/next/dist/shared/lib/router/utils/get-route-from-asset-path.js +25 -0
  1405. package/app/node_modules/next/dist/shared/lib/router/utils/get-segment-param.js +90 -0
  1406. package/app/node_modules/next/dist/shared/lib/router/utils/html-bots.js +17 -0
  1407. package/app/node_modules/next/dist/shared/lib/router/utils/index.js +30 -0
  1408. package/app/node_modules/next/dist/shared/lib/router/utils/interception-prefix-from-param-type.js +33 -0
  1409. package/app/node_modules/next/dist/shared/lib/router/utils/interception-routes.js +108 -0
  1410. package/app/node_modules/next/dist/shared/lib/router/utils/is-bot.js +57 -0
  1411. package/app/node_modules/next/dist/shared/lib/router/utils/is-dynamic.js +26 -0
  1412. package/app/node_modules/next/dist/shared/lib/router/utils/middleware-route-matcher.js +31 -0
  1413. package/app/node_modules/next/dist/shared/lib/router/utils/parse-loader-tree.js +30 -0
  1414. package/app/node_modules/next/dist/shared/lib/router/utils/parse-path.js +33 -0
  1415. package/app/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js +43 -0
  1416. package/app/node_modules/next/dist/shared/lib/router/utils/parse-url.js +38 -0
  1417. package/app/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js +20 -0
  1418. package/app/node_modules/next/dist/shared/lib/router/utils/path-match.js +49 -0
  1419. package/app/node_modules/next/dist/shared/lib/router/utils/prepare-destination.js +293 -0
  1420. package/app/node_modules/next/dist/shared/lib/router/utils/querystring.js +79 -0
  1421. package/app/node_modules/next/dist/shared/lib/router/utils/relativize-url.js +40 -0
  1422. package/app/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js +39 -0
  1423. package/app/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js +22 -0
  1424. package/app/node_modules/next/dist/shared/lib/router/utils/resolve-param-value.js +116 -0
  1425. package/app/node_modules/next/dist/shared/lib/router/utils/route-match-utils.js +113 -0
  1426. package/app/node_modules/next/dist/shared/lib/router/utils/route-matcher.js +45 -0
  1427. package/app/node_modules/next/dist/shared/lib/router/utils/route-regex.js +256 -0
  1428. package/app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js +244 -0
  1429. package/app/node_modules/next/dist/shared/lib/router-context.shared-runtime.js +18 -0
  1430. package/app/node_modules/next/dist/shared/lib/segment-cache/segment-value-encoding.js +99 -0
  1431. package/app/node_modules/next/dist/shared/lib/segment-cache/vary-params-decoding.js +66 -0
  1432. package/app/node_modules/next/dist/shared/lib/segment.js +102 -0
  1433. package/app/node_modules/next/dist/shared/lib/server-inserted-html.shared-runtime.js +35 -0
  1434. package/app/node_modules/next/dist/shared/lib/server-reference-info.js +68 -0
  1435. package/app/node_modules/next/dist/shared/lib/side-effect.js +63 -0
  1436. package/app/node_modules/next/dist/shared/lib/size-limit.js +40 -0
  1437. package/app/node_modules/next/dist/shared/lib/turbopack/internal-error.js +53 -0
  1438. package/app/node_modules/next/dist/shared/lib/utils/reflect-utils.js +69 -0
  1439. package/app/node_modules/next/dist/shared/lib/utils/warn-once.js +22 -0
  1440. package/app/node_modules/next/dist/shared/lib/utils.js +216 -0
  1441. package/app/node_modules/next/dist/shared/lib/zod.js +101 -0
  1442. package/app/node_modules/next/dist/telemetry/agent-name.js +20 -0
  1443. package/app/node_modules/next/dist/telemetry/anonymous-meta.js +91 -0
  1444. package/app/node_modules/next/dist/telemetry/detached-flush.js +56 -0
  1445. package/app/node_modules/next/dist/telemetry/events/build.js +187 -0
  1446. package/app/node_modules/next/dist/telemetry/events/index.js +41 -0
  1447. package/app/node_modules/next/dist/telemetry/events/plugins.js +51 -0
  1448. package/app/node_modules/next/dist/telemetry/events/swc-load-failure.js +55 -0
  1449. package/app/node_modules/next/dist/telemetry/events/version.js +68 -0
  1450. package/app/node_modules/next/dist/telemetry/flush-telemetry.js +19 -0
  1451. package/app/node_modules/next/dist/telemetry/post-telemetry-payload.js +48 -0
  1452. package/app/node_modules/next/dist/telemetry/project-id.js +48 -0
  1453. package/app/node_modules/next/dist/telemetry/storage.js +305 -0
  1454. package/app/node_modules/next/dist/trace/index.js +58 -0
  1455. package/app/node_modules/next/dist/trace/report/index.js +37 -0
  1456. package/app/node_modules/next/dist/trace/report/to-json-build.js +40 -0
  1457. package/app/node_modules/next/dist/trace/report/to-json.js +171 -0
  1458. package/app/node_modules/next/dist/trace/report/to-telemetry.js +36 -0
  1459. package/app/node_modules/next/dist/trace/shared.js +39 -0
  1460. package/app/node_modules/next/dist/trace/trace.js +211 -0
  1461. package/app/node_modules/next/package.json +139 -0
  1462. package/app/node_modules/react/cjs/react-compiler-runtime.production.js +16 -0
  1463. package/app/node_modules/react/cjs/react-jsx-dev-runtime.production.js +14 -0
  1464. package/app/node_modules/react/cjs/react-jsx-runtime.production.js +34 -0
  1465. package/app/node_modules/react/cjs/react.development.js +1284 -0
  1466. package/app/node_modules/react/cjs/react.production.js +542 -0
  1467. package/app/node_modules/react/compiler-runtime.js +14 -0
  1468. package/app/node_modules/react/index.js +7 -0
  1469. package/app/node_modules/react/jsx-dev-runtime.js +7 -0
  1470. package/app/node_modules/react/jsx-runtime.js +7 -0
  1471. package/app/node_modules/react/package.json +51 -0
  1472. package/app/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +6603 -0
  1473. package/app/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js +6692 -0
  1474. package/app/node_modules/react-dom/cjs/react-dom-server.browser.production.js +7410 -0
  1475. package/app/node_modules/react-dom/cjs/react-dom-server.edge.production.js +7512 -0
  1476. package/app/node_modules/react-dom/cjs/react-dom-server.node.production.js +7707 -0
  1477. package/app/node_modules/react-dom/cjs/react-dom.production.js +210 -0
  1478. package/app/node_modules/react-dom/index.js +38 -0
  1479. package/app/node_modules/react-dom/package.json +117 -0
  1480. package/app/node_modules/react-dom/server.browser.js +16 -0
  1481. package/app/node_modules/react-dom/server.edge.js +17 -0
  1482. package/app/node_modules/react-dom/server.node.js +18 -0
  1483. package/app/node_modules/react-dom/static.node.js +14 -0
  1484. package/app/node_modules/semver/package.json +38 -0
  1485. package/app/node_modules/styled-jsx/dist/index/index.js +499 -0
  1486. package/app/node_modules/styled-jsx/index.js +1 -0
  1487. package/app/node_modules/styled-jsx/package.json +132 -0
  1488. package/app/node_modules/styled-jsx/style.js +1 -0
  1489. package/app/package.json +6 -0
  1490. package/app/public/brand/botmancers-logo-filled-1024.png +0 -0
  1491. package/app/public/brand/botmancers-logo-filled-256.png +0 -0
  1492. package/app/public/brand/botmancers-logo-filled-512.png +0 -0
  1493. package/app/public/brand/botmancers-logo-filled-64.png +0 -0
  1494. package/app/public/brand/botmancers-logo-outline-1024.png +0 -0
  1495. package/app/public/brand/botmancers-logo-outline-256.png +0 -0
  1496. package/app/public/brand/botmancers-logo-outline-512.png +0 -0
  1497. package/app/public/brand/botmancers-logo-outline-64.png +0 -0
  1498. package/app/public/computer/dock-chrome.png +0 -0
  1499. package/app/public/computer/dock-gray.png +0 -0
  1500. package/app/public/computer/dock-terminal.png +0 -0
  1501. package/app/public/computer/wallpaper.png +0 -0
  1502. package/app/public/dock-chrome_c5c1.png +0 -0
  1503. package/app/public/dock-gray_6226.png +0 -0
  1504. package/app/public/dock-terminal_166d.png +0 -0
  1505. package/app/public/file.svg +1 -0
  1506. package/app/public/globe.svg +1 -0
  1507. package/app/public/next.svg +1 -0
  1508. package/app/public/vercel.svg +1 -0
  1509. package/app/public/wallpaper_1c49.png +0 -0
  1510. package/app/public/window.svg +1 -0
  1511. package/app/server.js +38 -0
  1512. package/dist/cli.d.ts +6 -0
  1513. package/dist/cli.js +110 -2
  1514. package/dist/config.js +4 -0
  1515. package/dist/home.d.ts +39 -0
  1516. package/dist/home.js +131 -0
  1517. package/dist/managed.d.ts +145 -0
  1518. package/dist/managed.js +749 -0
  1519. package/dist/product.d.ts +113 -0
  1520. package/dist/product.js +1015 -0
  1521. package/dist/setup.d.ts +20 -0
  1522. package/dist/setup.js +136 -0
  1523. package/dist/upgrade.d.ts +15 -0
  1524. package/dist/upgrade.js +275 -0
  1525. package/package.json +11 -5
@@ -0,0 +1,1424 @@
1
+ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",()=>require("better-sqlite3-90e2652d1716b047"))},62294,64974,11626,35613,30098,e=>{"use strict";var t=e.i(85148),n=e.i(22734),r=e.i(14747),i=e.i(54799),a=e.i(62349),s=e.i(16979);let o=Object.freeze(["conversation","implementation","review","revision"]),d=Object.freeze(["readonly","edit"]);Object.freeze(["ui","api","wake","continuation"]);let _=Object.freeze({conversation:"readonly",implementation:"edit",review:"readonly",revision:"edit"});function E(e){return"string"==typeof e&&o.includes(e)}function u(e,t){return{ok:!1,code:e,reason:t}}function c(e){var t,n,r,i;if(!E(e.executionKind))return u("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.executionKind))}.`);let a=e.executionKind,s=(t=e.entryPoint,n=a,r=e.wakeSyntax,i=!0===e.resumesWorkRequest,"ui"===t||"api"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A direct message runs as a read-only conversation turn, not ${n}.`}:"direct_message_conversation":"continuation"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A coordinator continuation runs as a read-only conversation turn, not ${n}.`}:"coordinator_continuation":"wake"!==t?{code:"unsupported_authority",reason:"Unknown policy entry point."}:"legacy"===r?"conversation"!==n?{code:"unsupported_authority",reason:`A legacy WAKE directive runs as a conversation turn, not ${n}.`}:"legacy_wake_conversation":"structured"!==r?{code:"unsupported_authority",reason:"Unknown Wake syntax."}:"revision"===n!==i?{code:"unsupported_authority",reason:"revision"===n?"A revision names the Work Request it resumes.":"Only a revision resumes a Work Request."}:"structured_wake");return"string"!=typeof s?u(s.code,s.reason):{ok:!0,policy:Object.freeze({policy_version:1,execution_kind:a,tool_profile:_[a],entry_point:e.entryPoint,rule:s})}}let T=new Set(["policy_version","execution_kind","tool_profile","entry_point","rule"]);function l(e){if(!e||"object"!=typeof e||Array.isArray(e))return u("malformed_policy","The execution policy snapshot is missing.");let t=Object.keys(e);if(t.length!==T.size||t.some(e=>!T.has(e)))return u("malformed_policy","The execution policy snapshot has unexpected fields.");if(1!==e.policy_version)return u("malformed_policy","Unsupported execution policy version.");if(!E(e.execution_kind))return u("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.execution_kind))}.`);if(!d.includes(e.tool_profile))return u("unsupported_authority",`Unsupported tool profile ${JSON.stringify(String(e.tool_profile))}.`);if(_[e.execution_kind]!==e.tool_profile)return u("unsupported_authority",`Execution kind ${e.execution_kind} requires the ${_[e.execution_kind]} tool profile.`);let n={direct_message_conversation:{entry:["ui","api"],kinds:["conversation"]},legacy_wake_conversation:{entry:["wake"],kinds:["conversation"]},coordinator_continuation:{entry:["continuation"],kinds:["conversation"]},structured_wake:{entry:["wake"],kinds:[...o]}},r="string"==typeof e.rule?n[e.rule]:void 0;return r&&r.entry.includes(e.entry_point)?r.kinds.includes(e.execution_kind)?{ok:!0,policy:Object.freeze({...e})}:u("unsupported_authority",`Rule ${e.rule} does not grant ${e.execution_kind}.`):u("malformed_policy","The execution policy rule does not match its entry point.")}e.s(["TOOL_PROFILE_FOR_KIND",0,_,"authorizeWorkRequest",0,function(e){let t;if(!E(e.execution_kind))return u("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.execution_kind))}.`);try{t="string"==typeof e.policy_snapshot?JSON.parse(e.policy_snapshot):null}catch{return u("malformed_policy","The policy snapshot is not valid JSON.")}let n=l(t&&"object"==typeof t&&!Array.isArray(t)?t.execution_policy:void 0);return n.ok?n.policy.execution_kind!==e.execution_kind||n.policy.tool_profile!==e.tool_profile?u("unsupported_authority","The Work Request authority does not match its policy snapshot."):t.tool_profile!==e.tool_profile?u("malformed_policy","The policy snapshot tool profile does not match the Work Request."):n:n},"isExecutionKind",0,E,"selectExecutionPolicy",0,c,"validateExecutionPolicy",0,l],64974);let p=Object.freeze({max_attempts:1,base_delay_ms:1e3,max_delay_ms:6e4,attempt_timeout_ms:null});function N(e){if(void 0===e||!/^\d+$/.test(e.trim()))return null;let t=Number(e.trim());return Number.isSafeInteger(t)&&t>0?t:null}function R(e=process.env){let t=N(e.BOTMANCERS_RETRY_MAX_ATTEMPTS),n=N(e.BOTMANCERS_RETRY_BASE_DELAY_MS)??p.base_delay_ms,r=N(e.BOTMANCERS_RETRY_MAX_DELAY_MS)??p.max_delay_ms,i=m({max_attempts:null===t?p.max_attempts:Math.min(t,10),base_delay_ms:n,max_delay_ms:Math.max(r,n),attempt_timeout_ms:N(e.BOTMANCERS_ATTEMPT_TIMEOUT_MS)});return{deadlineMs:N(e.BOTMANCERS_REQUEST_DEADLINE_MS),retryPolicy:i.ok?i.policy:{...p}}}function m(e){if(!e||"object"!=typeof e||Array.isArray(e))return{ok:!1,reason:"A retry policy is an object."};let t=e=>"number"==typeof e&&Number.isSafeInteger(e);if(!t(e.max_attempts)||e.max_attempts<1||e.max_attempts>10)return{ok:!1,reason:"max_attempts must be an integer from 1 to 10."};if(!t(e.base_delay_ms)||e.base_delay_ms<0)return{ok:!1,reason:"base_delay_ms must be a non-negative integer."};if(!t(e.max_delay_ms)||e.max_delay_ms<e.base_delay_ms)return{ok:!1,reason:"max_delay_ms must be an integer no smaller than base_delay_ms."};let n=e.attempt_timeout_ms??null;return null!==n&&(!t(n)||n<1)?{ok:!1,reason:"attempt_timeout_ms must be a positive integer or null."}:{ok:!0,policy:{max_attempts:e.max_attempts,base_delay_ms:e.base_delay_ms,max_delay_ms:e.max_delay_ms,attempt_timeout_ms:n}}}let L=["agent_deck_token_missing","agent_deck_unauthorized","agent_deck_forbidden"],O={unavailable:"retryable",runtime_failed:"retryable",timed_out:"retryable",launch_failed:"terminal",unsupported_authority:"terminal",result_contract:"terminal",cancelled:"terminal",session_mismatch:"manual_attention"};e.s(["attemptDeadline",0,function(e,t,n){let r=null===e.attempt_timeout_ms?null:n+e.attempt_timeout_ms;return null===r?t:null===t?r:Math.min(r,t)},"classifyFailure",0,function(e,t=null){return t&&L.includes(t)?"manual_attention":O[e??"runtime_failed"]??"terminal"},"decideRetry",0,function(e){var t;let n;if("terminal"===e.disposition)return{action:"fail",disposition:"terminal"};let r=e.attemptCount<e.policy.max_attempts;if("manual_attention"===e.disposition)return r?{action:"attention"}:{action:"fail",disposition:"terminal"};if(!r)return{action:"exhausted"};let i=e.attemptCount,a=(t=e.policy,n=Math.max(0,i-1),Math.min(t.max_delay_ms,t.base_delay_ms*2**Math.min(n,30))),s=e.now+a;return null!==e.deadlineAt&&s>=e.deadlineAt?{action:"deadline"}:{action:"retry",nextEligibleAt:s,delayMs:a,retry:i}},"requestControlDefaultsFromEnv",0,R,"storedRetryPolicy",0,function(e){if(!e)return{...p};try{let t=m(JSON.parse(e));return t.ok?t.policy:{...p}}catch{return{...p}}},"validateRetryPolicy",0,m],11626);let g=["queued","blocked","running","waiting","completed","failed","cancelled"],I=["completed","failed","cancelled"],A={queued:["running","blocked","cancelled","failed"],blocked:["queued","cancelled","failed"],running:["waiting","queued","completed","failed","cancelled"],waiting:["running","queued","cancelled","failed"],completed:[],failed:[],cancelled:[]},S=["dispatcher","ui_message","ui_continuation"];class k extends Error{code;constructor(e,t){super(t),this.code=e}}let v=I.map(e=>`'${e}'`).join(", "),f=g.map(e=>`'${e}'`).join(", "),q=[{version:1,name:"core_engine_tables",up:e=>{e.exec(`
2
+ CREATE TABLE work_request_transitions (
3
+ from_state TEXT NOT NULL,
4
+ to_state TEXT NOT NULL,
5
+ PRIMARY KEY (from_state, to_state)
6
+ );
7
+
8
+ CREATE TABLE work_requests (
9
+ id TEXT PRIMARY KEY,
10
+ source_conversation_id TEXT NOT NULL,
11
+ source_event_id TEXT NOT NULL,
12
+ requester_kind TEXT NOT NULL CHECK (requester_kind IN ('person', 'bot', 'service')),
13
+ requester_id TEXT NOT NULL,
14
+ target_agent_id TEXT NOT NULL,
15
+ intent TEXT NOT NULL,
16
+ execution_kind TEXT NOT NULL CHECK (execution_kind IN ('conversation', 'implementation', 'review', 'revision')),
17
+ tool_profile TEXT NOT NULL CHECK (tool_profile IN ('readonly', 'edit')),
18
+ parent_request_id TEXT,
19
+ root_request_id TEXT NOT NULL,
20
+ wake_event_id TEXT,
21
+ depth INTEGER NOT NULL DEFAULT 0 CHECK (depth >= 0),
22
+ idempotency_key TEXT NOT NULL CHECK (length(idempotency_key) > 0),
23
+ request_hash TEXT NOT NULL,
24
+ policy_snapshot TEXT NOT NULL,
25
+ state TEXT NOT NULL CHECK (state IN (${f})),
26
+ state_reason TEXT,
27
+ result TEXT,
28
+ error_code TEXT,
29
+ error_message TEXT,
30
+ version INTEGER NOT NULL DEFAULT 0,
31
+ legacy_agent_request_id TEXT UNIQUE,
32
+ created_at INTEGER NOT NULL,
33
+ updated_at INTEGER NOT NULL,
34
+ terminal_at INTEGER,
35
+ CHECK ((state IN (${v})) = (terminal_at IS NOT NULL)),
36
+ FOREIGN KEY (source_conversation_id) REFERENCES conversations(id),
37
+ FOREIGN KEY (target_agent_id) REFERENCES bots(id),
38
+ FOREIGN KEY (parent_request_id) REFERENCES work_requests(id),
39
+ FOREIGN KEY (root_request_id) REFERENCES work_requests(id)
40
+ );
41
+
42
+ CREATE UNIQUE INDEX idx_work_requests_idempotency
43
+ ON work_requests(requester_kind, requester_id, idempotency_key);
44
+ CREATE INDEX idx_work_requests_conversation
45
+ ON work_requests(source_conversation_id, created_at);
46
+ CREATE INDEX idx_work_requests_state
47
+ ON work_requests(state, created_at);
48
+ CREATE INDEX idx_work_requests_parent
49
+ ON work_requests(parent_request_id) WHERE parent_request_id IS NOT NULL;
50
+
51
+ CREATE TABLE session_bindings (
52
+ id TEXT PRIMARY KEY,
53
+ agent_id TEXT NOT NULL,
54
+ adapter TEXT NOT NULL,
55
+ conversation_id TEXT,
56
+ request_id TEXT,
57
+ external_session_id TEXT NOT NULL,
58
+ source_attempt_id TEXT,
59
+ created_at INTEGER NOT NULL,
60
+ released_at INTEGER,
61
+ CHECK (conversation_id IS NOT NULL OR request_id IS NOT NULL),
62
+ FOREIGN KEY (agent_id) REFERENCES bots(id),
63
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
64
+ FOREIGN KEY (request_id) REFERENCES work_requests(id),
65
+ FOREIGN KEY (source_attempt_id) REFERENCES work_attempts(id)
66
+ );
67
+
68
+ CREATE UNIQUE INDEX idx_session_bindings_active
69
+ ON session_bindings(agent_id, adapter, IFNULL(conversation_id, ''), IFNULL(request_id, ''))
70
+ WHERE released_at IS NULL;
71
+
72
+ CREATE TABLE work_attempts (
73
+ id TEXT PRIMARY KEY,
74
+ request_id TEXT NOT NULL,
75
+ attempt_number INTEGER NOT NULL CHECK (attempt_number >= 1),
76
+ kind TEXT NOT NULL CHECK (kind IN ('launch', 'resume')),
77
+ adapter TEXT NOT NULL CHECK (length(adapter) > 0),
78
+ tool_profile TEXT NOT NULL CHECK (tool_profile IN ('readonly', 'edit')),
79
+ launch_snapshot TEXT NOT NULL,
80
+ launch_snapshot_hash TEXT NOT NULL,
81
+ resumed_session_binding_id TEXT,
82
+ external_run_id TEXT,
83
+ external_session_id TEXT,
84
+ outcome TEXT CHECK (outcome IN ('succeeded', 'failed', 'cancelled', 'interrupted', 'timed_out')),
85
+ error_category TEXT,
86
+ error_message TEXT,
87
+ artifacts TEXT NOT NULL DEFAULT '[]',
88
+ started_at INTEGER NOT NULL,
89
+ finished_at INTEGER,
90
+ CHECK ((outcome IS NULL) = (finished_at IS NULL)),
91
+ CHECK ((kind = 'resume') = (resumed_session_binding_id IS NOT NULL)),
92
+ UNIQUE (request_id, attempt_number),
93
+ FOREIGN KEY (request_id) REFERENCES work_requests(id),
94
+ FOREIGN KEY (resumed_session_binding_id) REFERENCES session_bindings(id)
95
+ );
96
+
97
+ CREATE UNIQUE INDEX idx_work_attempts_open
98
+ ON work_attempts(request_id) WHERE finished_at IS NULL;
99
+
100
+ CREATE TABLE engine_events (
101
+ id TEXT PRIMARY KEY,
102
+ request_id TEXT NOT NULL,
103
+ sequence INTEGER NOT NULL CHECK (sequence >= 1),
104
+ attempt_id TEXT,
105
+ type TEXT NOT NULL CHECK (length(type) > 0),
106
+ data TEXT,
107
+ created_at INTEGER NOT NULL,
108
+ UNIQUE (request_id, sequence),
109
+ FOREIGN KEY (request_id) REFERENCES work_requests(id),
110
+ FOREIGN KEY (attempt_id) REFERENCES work_attempts(id)
111
+ );
112
+
113
+ -- Foreign keys (insert/update side).
114
+ CREATE TRIGGER trg_work_requests_fk_insert BEFORE INSERT ON work_requests
115
+ BEGIN
116
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.source_conversation_id')
117
+ WHERE NOT EXISTS (SELECT 1 FROM conversations WHERE id = NEW.source_conversation_id);
118
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.target_agent_id')
119
+ WHERE NOT EXISTS (SELECT 1 FROM bots WHERE id = NEW.target_agent_id);
120
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.parent_request_id')
121
+ WHERE NEW.parent_request_id IS NOT NULL
122
+ AND NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.parent_request_id);
123
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.root_request_id')
124
+ WHERE NEW.root_request_id <> NEW.id
125
+ AND NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.root_request_id);
126
+ END;
127
+
128
+ -- Identity, lineage, and policy are fixed at intake.
129
+ CREATE TRIGGER trg_work_requests_immutable BEFORE UPDATE OF
130
+ id, source_conversation_id, source_event_id, requester_kind, requester_id,
131
+ target_agent_id, intent, execution_kind, tool_profile, parent_request_id,
132
+ root_request_id, wake_event_id, depth, idempotency_key, request_hash,
133
+ policy_snapshot, legacy_agent_request_id, created_at
134
+ ON work_requests
135
+ BEGIN
136
+ SELECT RAISE(ABORT, 'work_requests identity, lineage, and policy are immutable');
137
+ END;
138
+
139
+ CREATE TRIGGER trg_work_requests_transition BEFORE UPDATE OF state ON work_requests
140
+ WHEN NEW.state <> OLD.state
141
+ BEGIN
142
+ SELECT RAISE(ABORT, 'invalid work_requests state transition')
143
+ WHERE NOT EXISTS (
144
+ SELECT 1 FROM work_request_transitions WHERE from_state = OLD.state AND to_state = NEW.state
145
+ );
146
+ END;
147
+
148
+ CREATE TRIGGER trg_work_requests_terminal BEFORE UPDATE ON work_requests
149
+ WHEN OLD.state IN (${v})
150
+ BEGIN
151
+ SELECT RAISE(ABORT, 'terminal work_requests are immutable');
152
+ END;
153
+
154
+ CREATE TRIGGER trg_session_bindings_fk BEFORE INSERT ON session_bindings
155
+ BEGIN
156
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.conversation_id')
157
+ WHERE NEW.conversation_id IS NOT NULL
158
+ AND NOT EXISTS (SELECT 1 FROM conversations WHERE id = NEW.conversation_id);
159
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.request_id')
160
+ WHERE NEW.request_id IS NOT NULL
161
+ AND NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.request_id);
162
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.source_attempt_id')
163
+ WHERE NEW.source_attempt_id IS NOT NULL
164
+ AND NOT EXISTS (SELECT 1 FROM work_attempts WHERE id = NEW.source_attempt_id);
165
+ END;
166
+
167
+ -- A binding's session value is opaque and never rewritten; only
168
+ -- release (supersession) may change.
169
+ CREATE TRIGGER trg_session_bindings_immutable BEFORE UPDATE OF
170
+ id, agent_id, adapter, conversation_id, request_id, external_session_id, source_attempt_id, created_at
171
+ ON session_bindings
172
+ BEGIN
173
+ SELECT RAISE(ABORT, 'session_bindings are immutable');
174
+ END;
175
+
176
+ CREATE TRIGGER trg_work_attempts_fk BEFORE INSERT ON work_attempts
177
+ BEGIN
178
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_attempts.request_id')
179
+ WHERE NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.request_id);
180
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_attempts.resumed_session_binding_id')
181
+ WHERE NEW.resumed_session_binding_id IS NOT NULL
182
+ AND NOT EXISTS (SELECT 1 FROM session_bindings WHERE id = NEW.resumed_session_binding_id);
183
+ END;
184
+
185
+ -- Launch snapshot and authority never change after insert.
186
+ CREATE TRIGGER trg_work_attempts_immutable BEFORE UPDATE OF
187
+ id, request_id, attempt_number, kind, adapter, tool_profile,
188
+ launch_snapshot, launch_snapshot_hash, resumed_session_binding_id, started_at
189
+ ON work_attempts
190
+ BEGIN
191
+ SELECT RAISE(ABORT, 'work_attempts launch fields are immutable');
192
+ END;
193
+
194
+ -- External identifiers are recorded once, never rewritten.
195
+ CREATE TRIGGER trg_work_attempts_external_ids BEFORE UPDATE OF external_run_id, external_session_id ON work_attempts
196
+ WHEN (OLD.external_run_id IS NOT NULL AND NEW.external_run_id IS NOT OLD.external_run_id)
197
+ OR (OLD.external_session_id IS NOT NULL AND NEW.external_session_id IS NOT OLD.external_session_id)
198
+ BEGIN
199
+ SELECT RAISE(ABORT, 'work_attempts external identifiers are set once');
200
+ END;
201
+
202
+ CREATE TRIGGER trg_work_attempts_finished BEFORE UPDATE ON work_attempts
203
+ WHEN OLD.finished_at IS NOT NULL
204
+ BEGIN
205
+ SELECT RAISE(ABORT, 'finished work_attempts are immutable');
206
+ END;
207
+
208
+ CREATE TRIGGER trg_engine_events_fk BEFORE INSERT ON engine_events
209
+ BEGIN
210
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: engine_events.request_id')
211
+ WHERE NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.request_id);
212
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: engine_events.attempt_id')
213
+ WHERE NEW.attempt_id IS NOT NULL
214
+ AND NOT EXISTS (SELECT 1 FROM work_attempts WHERE id = NEW.attempt_id AND request_id = NEW.request_id);
215
+ END;
216
+
217
+ CREATE TRIGGER trg_engine_events_append_only BEFORE UPDATE ON engine_events
218
+ BEGIN
219
+ SELECT RAISE(ABORT, 'engine_events are append-only');
220
+ END;
221
+ `);let t=e.prepare("INSERT INTO work_request_transitions (from_state, to_state) VALUES (?, ?)");for(let e of g)for(let n of A[e])t.run(e,n)}},{version:2,name:"core_engine_referential_integrity",up:e=>{e.exec(`
222
+ -- Foreign keys (delete side): RESTRICT. A referenced row cannot be
223
+ -- deleted while anything still points at it; deleteEngineRecords
224
+ -- removes dependants first, in one transaction.
225
+ CREATE TRIGGER trg_conversations_engine_restrict BEFORE DELETE ON conversations
226
+ BEGIN
227
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.source_conversation_id')
228
+ WHERE EXISTS (SELECT 1 FROM work_requests WHERE source_conversation_id = OLD.id);
229
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.conversation_id')
230
+ WHERE EXISTS (SELECT 1 FROM session_bindings WHERE conversation_id = OLD.id);
231
+ END;
232
+
233
+ CREATE TRIGGER trg_bots_engine_restrict BEFORE DELETE ON bots
234
+ BEGIN
235
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.target_agent_id')
236
+ WHERE EXISTS (SELECT 1 FROM work_requests WHERE target_agent_id = OLD.id);
237
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.agent_id')
238
+ WHERE EXISTS (SELECT 1 FROM session_bindings WHERE agent_id = OLD.id);
239
+ END;
240
+
241
+ CREATE TRIGGER trg_work_requests_restrict BEFORE DELETE ON work_requests
242
+ BEGIN
243
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.parent_request_id')
244
+ WHERE EXISTS (
245
+ SELECT 1 FROM work_requests
246
+ WHERE id <> OLD.id AND (parent_request_id = OLD.id OR root_request_id = OLD.id)
247
+ );
248
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_attempts.request_id')
249
+ WHERE EXISTS (SELECT 1 FROM work_attempts WHERE request_id = OLD.id);
250
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: engine_events.request_id')
251
+ WHERE EXISTS (SELECT 1 FROM engine_events WHERE request_id = OLD.id);
252
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.request_id')
253
+ WHERE EXISTS (SELECT 1 FROM session_bindings WHERE request_id = OLD.id);
254
+ END;
255
+
256
+ CREATE TRIGGER trg_work_attempts_restrict BEFORE DELETE ON work_attempts
257
+ BEGIN
258
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: engine_events.attempt_id')
259
+ WHERE EXISTS (SELECT 1 FROM engine_events WHERE attempt_id = OLD.id);
260
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.source_attempt_id')
261
+ WHERE EXISTS (SELECT 1 FROM session_bindings WHERE source_attempt_id = OLD.id);
262
+ END;
263
+
264
+ CREATE TRIGGER trg_session_bindings_restrict BEFORE DELETE ON session_bindings
265
+ BEGIN
266
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_attempts.resumed_session_binding_id')
267
+ WHERE EXISTS (SELECT 1 FROM work_attempts WHERE resumed_session_binding_id = OLD.id);
268
+ END;
269
+
270
+ -- Session continuity: a binding belongs to one Agent and adapter in
271
+ -- one scope, and its source attempt must come from that scope.
272
+ CREATE TRIGGER trg_session_bindings_scope BEFORE INSERT ON session_bindings
273
+ BEGIN
274
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.agent_id')
275
+ WHERE NOT EXISTS (SELECT 1 FROM bots WHERE id = NEW.agent_id);
276
+ SELECT RAISE(ABORT, 'session binding does not match its work request')
277
+ WHERE NEW.request_id IS NOT NULL AND NOT EXISTS (
278
+ SELECT 1 FROM work_requests r
279
+ WHERE r.id = NEW.request_id AND r.target_agent_id = NEW.agent_id
280
+ AND (NEW.conversation_id IS NULL OR r.source_conversation_id = NEW.conversation_id)
281
+ );
282
+ SELECT RAISE(ABORT, 'session binding does not match its source attempt')
283
+ WHERE NEW.source_attempt_id IS NOT NULL AND NOT EXISTS (
284
+ SELECT 1 FROM work_attempts a JOIN work_requests r ON r.id = a.request_id
285
+ WHERE a.id = NEW.source_attempt_id AND a.adapter = NEW.adapter AND r.target_agent_id = NEW.agent_id
286
+ AND (NEW.request_id IS NULL OR a.request_id = NEW.request_id)
287
+ AND (NEW.conversation_id IS NULL OR r.source_conversation_id = NEW.conversation_id)
288
+ );
289
+ END;
290
+
291
+ -- A resume continues an active binding of the same Agent and
292
+ -- adapter, from the same conversation and request lineage.
293
+ CREATE TRIGGER trg_work_attempts_resume_scope BEFORE INSERT ON work_attempts
294
+ WHEN NEW.resumed_session_binding_id IS NOT NULL
295
+ BEGIN
296
+ SELECT RAISE(ABORT, 'resumed session binding does not match the work request')
297
+ WHERE NOT EXISTS (
298
+ SELECT 1 FROM session_bindings b
299
+ JOIN work_requests r ON r.id = NEW.request_id
300
+ LEFT JOIN work_requests br ON br.id = b.request_id
301
+ WHERE b.id = NEW.resumed_session_binding_id AND b.released_at IS NULL
302
+ AND b.agent_id = r.target_agent_id AND b.adapter = NEW.adapter
303
+ AND (b.conversation_id IS NULL OR b.conversation_id = r.source_conversation_id)
304
+ AND (b.request_id IS NULL OR br.root_request_id = r.root_request_id)
305
+ );
306
+ END;
307
+ `)}},{version:3,name:"core_engine_hardening",up:e=>{let t=g.flatMap(e=>A[e].map(t=>`'${e}>${t}'`)).join(", ");e.exec(`
308
+ -- The lifecycle allowlist lives in the trigger itself, so no data
309
+ -- write can widen or break it. work_request_transitions stays as a
310
+ -- readable copy and is locked against writes.
311
+ DROP TRIGGER trg_work_requests_transition;
312
+ CREATE TRIGGER trg_work_requests_transition BEFORE UPDATE OF state ON work_requests
313
+ WHEN NEW.state <> OLD.state
314
+ BEGIN
315
+ SELECT RAISE(ABORT, 'invalid work_requests state transition')
316
+ WHERE (OLD.state || '>' || NEW.state) NOT IN (${t});
317
+ END;
318
+
319
+ CREATE TRIGGER trg_work_request_transitions_insert BEFORE INSERT ON work_request_transitions
320
+ BEGIN
321
+ SELECT RAISE(ABORT, 'work_request_transitions is read-only');
322
+ END;
323
+ CREATE TRIGGER trg_work_request_transitions_update BEFORE UPDATE ON work_request_transitions
324
+ BEGIN
325
+ SELECT RAISE(ABORT, 'work_request_transitions is read-only');
326
+ END;
327
+ CREATE TRIGGER trg_work_request_transitions_delete BEFORE DELETE ON work_request_transitions
328
+ BEGIN
329
+ SELECT RAISE(ABORT, 'work_request_transitions is read-only');
330
+ END;
331
+
332
+ -- Engine events are never deleted one by one. Aggregate cleanup
333
+ -- (deleteEngineRecords) first marks the requests it removes in
334
+ -- engine_event_purges; only events of a marked request may go.
335
+ CREATE TABLE engine_event_purges (
336
+ request_id TEXT PRIMARY KEY
337
+ );
338
+ CREATE TRIGGER trg_engine_events_no_delete BEFORE DELETE ON engine_events
339
+ BEGIN
340
+ SELECT RAISE(ABORT, 'engine_events are append-only')
341
+ WHERE NOT EXISTS (SELECT 1 FROM engine_event_purges WHERE request_id = OLD.request_id);
342
+ END;
343
+
344
+ -- Foreign keys (parent-key update side): RESTRICT.
345
+ CREATE TRIGGER trg_conversations_engine_restrict_update BEFORE UPDATE OF id ON conversations
346
+ WHEN NEW.id IS NOT OLD.id
347
+ BEGIN
348
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.source_conversation_id')
349
+ WHERE EXISTS (SELECT 1 FROM work_requests WHERE source_conversation_id = OLD.id);
350
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.conversation_id')
351
+ WHERE EXISTS (SELECT 1 FROM session_bindings WHERE conversation_id = OLD.id);
352
+ END;
353
+
354
+ CREATE TRIGGER trg_bots_engine_restrict_update BEFORE UPDATE OF id ON bots
355
+ WHEN NEW.id IS NOT OLD.id
356
+ BEGIN
357
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: work_requests.target_agent_id')
358
+ WHERE EXISTS (SELECT 1 FROM work_requests WHERE target_agent_id = OLD.id);
359
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: session_bindings.agent_id')
360
+ WHERE EXISTS (SELECT 1 FROM session_bindings WHERE agent_id = OLD.id);
361
+ END;
362
+
363
+ -- Attempt kind and continuity agree: only a resume names a binding.
364
+ -- (Fresh schemas also carry this as a CHECK.)
365
+ CREATE TRIGGER trg_work_attempts_kind BEFORE INSERT ON work_attempts
366
+ WHEN (NEW.kind = 'resume') <> (NEW.resumed_session_binding_id IS NOT NULL)
367
+ BEGIN
368
+ SELECT RAISE(ABORT, 'work_attempts kind does not match resumed_session_binding_id');
369
+ END;
370
+ `)}},{version:4,name:"engine_event_purge_authority",up:e=>{e.exec(`
371
+ -- Purge authority no longer lives in data: any writer could insert
372
+ -- an engine_event_purges row and then delete single events. The
373
+ -- guard now asks engine_event_purge_authorized(), a connection
374
+ -- function that is true only while deleteEngineRecords removes that
375
+ -- request whole. Connections without it cannot delete events.
376
+ DROP TRIGGER trg_engine_events_no_delete;
377
+ DROP TABLE engine_event_purges;
378
+ CREATE TRIGGER trg_engine_events_no_delete BEFORE DELETE ON engine_events
379
+ BEGIN
380
+ SELECT RAISE(ABORT, 'engine_events are append-only')
381
+ WHERE NOT engine_event_purge_authorized(OLD.request_id);
382
+ END;
383
+ `)}},{version:5,name:"conversation_intakes",up:e=>{e.exec(`
384
+ -- NOT-465: one row per accepted conversation message, keyed by the
385
+ -- requester's idempotency key. It names the source event (message)
386
+ -- and the Work Requests created from it, so an exact retry replays
387
+ -- the original identifiers whether or not any request was created.
388
+ CREATE TABLE conversation_intakes (
389
+ requester_kind TEXT NOT NULL CHECK (requester_kind IN ('person', 'bot', 'service')),
390
+ requester_id TEXT NOT NULL,
391
+ idempotency_key TEXT NOT NULL CHECK (length(idempotency_key) > 0),
392
+ request_hash TEXT NOT NULL,
393
+ surface TEXT NOT NULL CHECK (surface IN ('ui', 'api')),
394
+ conversation_id TEXT NOT NULL,
395
+ source_event_id TEXT NOT NULL,
396
+ work_request_ids TEXT NOT NULL DEFAULT '[]',
397
+ created_at INTEGER NOT NULL,
398
+ PRIMARY KEY (requester_kind, requester_id, idempotency_key)
399
+ );
400
+ CREATE INDEX idx_conversation_intakes_conversation ON conversation_intakes(conversation_id);
401
+ `)}},{version:6,name:"attempt_output",up:e=>{e.exec(`
402
+ -- NOT-467: the runtime output an Attempt returned, recorded with
403
+ -- its terminal outcome (null while open or when none was returned).
404
+ ALTER TABLE work_attempts ADD COLUMN output TEXT;
405
+ `)}},{version:7,name:"wakes",up:e=>{e.exec(`
406
+ -- NOT-466: one row per Wake found in an Agent reply (lib/wake-router).
407
+ -- Every Wake is kept, including ones whose target is missing or
408
+ -- whose envelope is invalid, so nothing is silently dropped. An
409
+ -- accepted or blocked Wake names its one Work Request. Lineage is
410
+ -- durable: parent/root request and root Wake, never process memory.
411
+ CREATE TABLE wakes (
412
+ id TEXT PRIMARY KEY,
413
+ idempotency_key TEXT NOT NULL UNIQUE CHECK (length(idempotency_key) > 0),
414
+ source_conversation_id TEXT NOT NULL,
415
+ source_event_id TEXT NOT NULL,
416
+ position INTEGER NOT NULL CHECK (position >= 0),
417
+ syntax TEXT NOT NULL CHECK (syntax IN ('structured', 'legacy')),
418
+ payload TEXT NOT NULL,
419
+ requester_agent_id TEXT NOT NULL,
420
+ requested_target TEXT,
421
+ target_agent_id TEXT,
422
+ target_name_snapshot TEXT,
423
+ execution_kind TEXT CHECK (execution_kind IN ('conversation', 'implementation', 'review', 'revision')),
424
+ parent_request_id TEXT,
425
+ root_request_id TEXT,
426
+ root_wake_id TEXT NOT NULL,
427
+ depth INTEGER NOT NULL CHECK (depth >= 0),
428
+ status TEXT NOT NULL CHECK (status IN ('accepted', 'blocked', 'unavailable', 'rejected')),
429
+ reason_code TEXT,
430
+ reason TEXT,
431
+ work_request_id TEXT UNIQUE,
432
+ created_at INTEGER NOT NULL,
433
+ updated_at INTEGER NOT NULL,
434
+ UNIQUE (source_event_id, position),
435
+ CHECK ((status IN ('accepted', 'blocked')) = (work_request_id IS NOT NULL)),
436
+ CHECK (status = 'accepted' OR reason_code IS NOT NULL),
437
+ FOREIGN KEY (source_conversation_id) REFERENCES conversations(id),
438
+ FOREIGN KEY (work_request_id) REFERENCES work_requests(id),
439
+ FOREIGN KEY (parent_request_id) REFERENCES work_requests(id)
440
+ );
441
+ CREATE INDEX idx_wakes_conversation ON wakes(source_conversation_id, created_at);
442
+ CREATE INDEX idx_wakes_status ON wakes(status, created_at);
443
+
444
+ CREATE TRIGGER trg_wakes_fk BEFORE INSERT ON wakes
445
+ BEGIN
446
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: wakes.source_conversation_id')
447
+ WHERE NOT EXISTS (SELECT 1 FROM conversations WHERE id = NEW.source_conversation_id);
448
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: wakes.parent_request_id')
449
+ WHERE NEW.parent_request_id IS NOT NULL
450
+ AND NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.parent_request_id);
451
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: wakes.work_request_id')
452
+ WHERE NEW.work_request_id IS NOT NULL
453
+ AND NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.work_request_id);
454
+ END;
455
+
456
+ -- Source, payload, and lineage are fixed when the Wake is recorded.
457
+ CREATE TRIGGER trg_wakes_immutable BEFORE UPDATE OF
458
+ id, idempotency_key, source_conversation_id, source_event_id, position, syntax, payload,
459
+ requester_agent_id, requested_target, execution_kind, parent_request_id,
460
+ root_wake_id, depth, created_at
461
+ ON wakes
462
+ BEGIN
463
+ SELECT RAISE(ABORT, 'wakes source, payload, and lineage are immutable');
464
+ END;
465
+
466
+ -- Recovery only moves forward: an unavailable target may resolve
467
+ -- or turn out unroutable (rejected), a blocked request may become
468
+ -- accepted. The resolved target, Work
469
+ -- Request, and root request (for a Wake without a parent, its own
470
+ -- request) are set once.
471
+ CREATE TRIGGER trg_wakes_recovery BEFORE UPDATE ON wakes
472
+ BEGIN
473
+ SELECT RAISE(ABORT, 'invalid wakes status change')
474
+ WHERE NEW.status <> OLD.status
475
+ AND (OLD.status || '>' || NEW.status) NOT IN ('unavailable>accepted', 'unavailable>blocked', 'unavailable>rejected', 'blocked>accepted');
476
+ SELECT RAISE(ABORT, 'wakes target and work request are set once')
477
+ WHERE (OLD.target_agent_id IS NOT NULL AND NEW.target_agent_id IS NOT OLD.target_agent_id)
478
+ OR (OLD.target_name_snapshot IS NOT NULL AND NEW.target_name_snapshot IS NOT OLD.target_name_snapshot)
479
+ OR (OLD.work_request_id IS NOT NULL AND NEW.work_request_id IS NOT OLD.work_request_id)
480
+ OR (OLD.root_request_id IS NOT NULL AND NEW.root_request_id IS NOT OLD.root_request_id);
481
+ END;
482
+ `)}},{version:8,name:"conversation_events",up:e=>{e.exec(`
483
+ -- NOT-470: typed conversation projection of Wake and Work Request
484
+ -- lifecycle events (lib/conversation-projection). One row per
485
+ -- projected part of one engine event; the id is derived from the
486
+ -- engine event id and part, so replay and redelivery never add a
487
+ -- row. text is the human-facing line, data the machine-readable
488
+ -- meaning. sort_at never decreases within a request, so ordering
489
+ -- by (sort_at, request_created_at, request_id, request_sequence,
490
+ -- part) keeps each request's own order while requests interleave.
491
+ CREATE TABLE conversation_events (
492
+ id TEXT PRIMARY KEY,
493
+ conversation_id TEXT NOT NULL,
494
+ engine_event_id TEXT NOT NULL,
495
+ part INTEGER NOT NULL CHECK (part >= 0),
496
+ request_id TEXT NOT NULL,
497
+ request_sequence INTEGER NOT NULL,
498
+ attempt_id TEXT,
499
+ wake_id TEXT,
500
+ kind TEXT NOT NULL CHECK (kind IN (
501
+ 'wake_accepted', 'wake_blocked', 'request_queued', 'request_blocked', 'request_running',
502
+ 'request_waiting', 'request_completed', 'request_failed', 'request_cancelled',
503
+ 'question', 'result', 'artifact'
504
+ )),
505
+ state TEXT CHECK (state IN (${f})),
506
+ text TEXT NOT NULL,
507
+ data TEXT NOT NULL,
508
+ sort_at INTEGER NOT NULL,
509
+ request_created_at INTEGER NOT NULL,
510
+ created_at INTEGER NOT NULL,
511
+ UNIQUE (engine_event_id, part),
512
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
513
+ FOREIGN KEY (engine_event_id) REFERENCES engine_events(id),
514
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
515
+ );
516
+ CREATE INDEX idx_conversation_events_order
517
+ ON conversation_events(conversation_id, sort_at, request_created_at, request_id, request_sequence, part);
518
+ CREATE INDEX idx_conversation_events_request ON conversation_events(request_id);
519
+
520
+ -- Last engine event sequence the projector has read per request,
521
+ -- including events that project to nothing.
522
+ CREATE TABLE conversation_projection_cursors (
523
+ request_id TEXT PRIMARY KEY,
524
+ sequence INTEGER NOT NULL CHECK (sequence >= 0),
525
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
526
+ );
527
+
528
+ CREATE TRIGGER trg_conversation_events_immutable BEFORE UPDATE ON conversation_events
529
+ BEGIN
530
+ SELECT RAISE(ABORT, 'conversation_events are immutable');
531
+ END;
532
+ `)}},{version:9,name:"terminal_followups",up:e=>{e.exec(`
533
+ -- NOT-472: one row per canonical request that became terminal on
534
+ -- this schema, written in the same transaction as the terminal
535
+ -- transition. lib/coordinator-loop runs the follow-up (Wake
536
+ -- routing, coordinator continuation) and sets done_at; restart
537
+ -- recovery only replays rows still open. Requests that ended
538
+ -- before this migration get no row, so their replies are never
539
+ -- routed retroactively.
540
+ CREATE TABLE terminal_followups (
541
+ request_id TEXT PRIMARY KEY,
542
+ created_at INTEGER NOT NULL,
543
+ done_at INTEGER,
544
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
545
+ );
546
+ CREATE INDEX idx_terminal_followups_open ON terminal_followups(created_at) WHERE done_at IS NULL;
547
+ `)}},{version:10,name:"reviewed_git_finalization",up:e=>{e.exec(`
548
+ -- NOT-487: reviewed Git finalization through Agent Deck
549
+ -- (docs/design/2026-10-13-git-finalization-contract.md). Rows hold
550
+ -- only public Agent Deck identifiers, repository-relative paths,
551
+ -- digests, and modes: never file contents, host paths, or the
552
+ -- Agent Deck bearer.
553
+ --
554
+ -- Public baseline of a prepared edit Attempt, captured before model
555
+ -- work. Set once.
556
+ CREATE TABLE attempt_finalization_baselines (
557
+ attempt_id TEXT PRIMARY KEY,
558
+ request_id TEXT NOT NULL,
559
+ external_run_id TEXT NOT NULL,
560
+ baseline_ref TEXT NOT NULL,
561
+ baseline_digest TEXT NOT NULL,
562
+ created_at INTEGER NOT NULL,
563
+ FOREIGN KEY (attempt_id) REFERENCES work_attempts(id),
564
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
565
+ );
566
+
567
+ -- The ordered candidate manifest Agent Deck reported once the
568
+ -- prepared run was terminal: the immutable review evidence that a
569
+ -- finalization submits unchanged.
570
+ CREATE TABLE candidate_manifests (
571
+ id TEXT PRIMARY KEY,
572
+ attempt_id TEXT NOT NULL UNIQUE,
573
+ request_id TEXT NOT NULL,
574
+ conversation_id TEXT NOT NULL,
575
+ external_run_id TEXT NOT NULL,
576
+ baseline_ref TEXT NOT NULL,
577
+ baseline_digest TEXT NOT NULL,
578
+ base_commit TEXT NOT NULL,
579
+ manifest_digest TEXT NOT NULL,
580
+ files TEXT NOT NULL,
581
+ file_count INTEGER NOT NULL CHECK (file_count >= 0),
582
+ created_at INTEGER NOT NULL,
583
+ FOREIGN KEY (attempt_id) REFERENCES work_attempts(id),
584
+ FOREIGN KEY (request_id) REFERENCES work_requests(id),
585
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id)
586
+ );
587
+
588
+ -- One accepted finalization decision and its outcome. The request
589
+ -- body is exactly what was (or will be) submitted; the idempotency
590
+ -- key is derived from the explicit acceptance event, implementation
591
+ -- Attempt, review, and manifest. Replay and restart submit the same
592
+ -- request, while a later acceptance can retry a terminal non-commit.
593
+ CREATE TABLE finalizations (
594
+ id TEXT PRIMARY KEY,
595
+ idempotency_key TEXT NOT NULL UNIQUE CHECK (length(idempotency_key) > 0),
596
+ conversation_id TEXT NOT NULL,
597
+ decision_event_id TEXT NOT NULL,
598
+ decision_request_id TEXT NOT NULL,
599
+ coordinator_agent_id TEXT NOT NULL,
600
+ implementation_request_id TEXT NOT NULL,
601
+ implementation_attempt_id TEXT NOT NULL,
602
+ review_request_id TEXT NOT NULL,
603
+ review_attempt_id TEXT NOT NULL,
604
+ manifest_id TEXT NOT NULL,
605
+ external_run_id TEXT NOT NULL,
606
+ request_body TEXT NOT NULL,
607
+ request_hash TEXT NOT NULL,
608
+ state TEXT NOT NULL CHECK (state IN ('preparing', 'committed', 'blocked', 'failed', 'canceled')),
609
+ submitted_at INTEGER,
610
+ reason_code TEXT,
611
+ reason TEXT,
612
+ commit_id TEXT,
613
+ tree_id TEXT,
614
+ parent_commit TEXT,
615
+ result_manifest_digest TEXT,
616
+ file_count INTEGER,
617
+ created_at INTEGER NOT NULL,
618
+ updated_at INTEGER NOT NULL,
619
+ finished_at INTEGER,
620
+ CHECK ((state = 'preparing') = (finished_at IS NULL)),
621
+ CHECK (state <> 'committed' OR commit_id IS NOT NULL),
622
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
623
+ FOREIGN KEY (implementation_request_id) REFERENCES work_requests(id),
624
+ FOREIGN KEY (implementation_attempt_id) REFERENCES work_attempts(id),
625
+ FOREIGN KEY (review_request_id) REFERENCES work_requests(id),
626
+ FOREIGN KEY (manifest_id) REFERENCES candidate_manifests(id)
627
+ );
628
+ CREATE INDEX idx_finalizations_open ON finalizations(created_at) WHERE finished_at IS NULL;
629
+ CREATE INDEX idx_finalizations_attempt ON finalizations(implementation_attempt_id);
630
+
631
+ CREATE TRIGGER trg_attempt_finalization_baselines_fk BEFORE INSERT ON attempt_finalization_baselines
632
+ BEGIN
633
+ SELECT RAISE(ABORT, 'attempt finalization baseline does not match its Attempt')
634
+ WHERE NOT EXISTS (
635
+ SELECT 1 FROM work_attempts
636
+ WHERE id = NEW.attempt_id AND request_id = NEW.request_id AND external_run_id = NEW.external_run_id
637
+ );
638
+ END;
639
+ CREATE TRIGGER trg_attempt_finalization_baselines_immutable BEFORE UPDATE ON attempt_finalization_baselines
640
+ BEGIN
641
+ SELECT RAISE(ABORT, 'attempt_finalization_baselines are immutable');
642
+ END;
643
+ CREATE TRIGGER trg_candidate_manifests_fk BEFORE INSERT ON candidate_manifests
644
+ BEGIN
645
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: candidate_manifests.attempt_id')
646
+ WHERE NOT EXISTS (
647
+ SELECT 1 FROM work_attempts a
648
+ JOIN work_requests r ON r.id = a.request_id
649
+ JOIN attempt_finalization_baselines b ON b.attempt_id = a.id
650
+ WHERE a.id = NEW.attempt_id AND a.request_id = NEW.request_id
651
+ AND a.external_run_id = NEW.external_run_id
652
+ AND r.source_conversation_id = NEW.conversation_id
653
+ AND b.external_run_id = NEW.external_run_id
654
+ AND b.baseline_ref = NEW.baseline_ref AND b.baseline_digest = NEW.baseline_digest
655
+ );
656
+ END;
657
+ CREATE TRIGGER trg_candidate_manifests_immutable BEFORE UPDATE ON candidate_manifests
658
+ BEGIN
659
+ SELECT RAISE(ABORT, 'candidate_manifests are immutable');
660
+ END;
661
+ CREATE TRIGGER trg_finalizations_fk BEFORE INSERT ON finalizations
662
+ BEGIN
663
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: finalizations.manifest_id')
664
+ WHERE NOT EXISTS (
665
+ SELECT 1 FROM candidate_manifests m
666
+ JOIN work_attempts ia ON ia.id = NEW.implementation_attempt_id
667
+ JOIN work_attempts ra ON ra.id = NEW.review_attempt_id
668
+ JOIN work_requests ir ON ir.id = NEW.implementation_request_id
669
+ JOIN work_requests rr ON rr.id = NEW.review_request_id
670
+ JOIN work_requests dr ON dr.id = NEW.decision_request_id
671
+ WHERE m.id = NEW.manifest_id AND m.attempt_id = ia.id AND m.request_id = ir.id
672
+ AND m.external_run_id = NEW.external_run_id
673
+ AND ia.request_id = ir.id AND ra.request_id = rr.id
674
+ AND ir.source_conversation_id = NEW.conversation_id
675
+ AND rr.source_conversation_id = NEW.conversation_id
676
+ AND dr.source_conversation_id = NEW.conversation_id
677
+ AND dr.target_agent_id = NEW.coordinator_agent_id
678
+ );
679
+ END;
680
+ CREATE TRIGGER trg_finalizations_immutable BEFORE UPDATE OF
681
+ id, idempotency_key, conversation_id, decision_event_id, decision_request_id, coordinator_agent_id,
682
+ implementation_request_id, implementation_attempt_id, review_request_id, review_attempt_id,
683
+ manifest_id, external_run_id, request_body, request_hash, created_at
684
+ ON finalizations
685
+ BEGIN
686
+ SELECT RAISE(ABORT, 'finalizations decision and request are immutable');
687
+ END;
688
+ CREATE TRIGGER trg_finalizations_terminal BEFORE UPDATE ON finalizations
689
+ WHEN OLD.finished_at IS NOT NULL
690
+ BEGIN
691
+ SELECT RAISE(ABORT, 'finished finalizations are immutable');
692
+ END;
693
+ CREATE TRIGGER trg_finalizations_submitted BEFORE UPDATE OF submitted_at ON finalizations
694
+ WHEN OLD.submitted_at IS NOT NULL AND NEW.submitted_at IS NOT OLD.submitted_at
695
+ BEGIN
696
+ SELECT RAISE(ABORT, 'finalizations submitted_at is set once');
697
+ END;
698
+
699
+ -- Conversation projection gains the finalization lifecycle kinds.
700
+ -- SQLite cannot widen a CHECK in place, so the table is rebuilt
701
+ -- with every row kept.
702
+ CREATE TABLE conversation_events_v10 (
703
+ id TEXT PRIMARY KEY,
704
+ conversation_id TEXT NOT NULL,
705
+ engine_event_id TEXT NOT NULL,
706
+ part INTEGER NOT NULL CHECK (part >= 0),
707
+ request_id TEXT NOT NULL,
708
+ request_sequence INTEGER NOT NULL,
709
+ attempt_id TEXT,
710
+ wake_id TEXT,
711
+ kind TEXT NOT NULL CHECK (kind IN (
712
+ 'wake_accepted', 'wake_blocked', 'request_queued', 'request_blocked', 'request_running',
713
+ 'request_waiting', 'request_completed', 'request_failed', 'request_cancelled',
714
+ 'question', 'result', 'artifact',
715
+ 'finalization_preparing', 'finalization_committed', 'finalization_blocked',
716
+ 'finalization_failed', 'finalization_canceled', 'finalization_rejected'
717
+ )),
718
+ state TEXT CHECK (state IN (${f})),
719
+ text TEXT NOT NULL,
720
+ data TEXT NOT NULL,
721
+ sort_at INTEGER NOT NULL,
722
+ request_created_at INTEGER NOT NULL,
723
+ created_at INTEGER NOT NULL,
724
+ UNIQUE (engine_event_id, part),
725
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
726
+ FOREIGN KEY (engine_event_id) REFERENCES engine_events(id),
727
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
728
+ );
729
+ INSERT INTO conversation_events_v10 SELECT
730
+ id, conversation_id, engine_event_id, part, request_id, request_sequence, attempt_id, wake_id,
731
+ kind, state, text, data, sort_at, request_created_at, created_at
732
+ FROM conversation_events;
733
+ DROP TABLE conversation_events;
734
+ ALTER TABLE conversation_events_v10 RENAME TO conversation_events;
735
+ CREATE INDEX idx_conversation_events_order
736
+ ON conversation_events(conversation_id, sort_at, request_created_at, request_id, request_sequence, part);
737
+ CREATE INDEX idx_conversation_events_request ON conversation_events(request_id);
738
+ CREATE TRIGGER trg_conversation_events_immutable BEFORE UPDATE ON conversation_events
739
+ BEGIN
740
+ SELECT RAISE(ABORT, 'conversation_events are immutable');
741
+ END;
742
+ `)}},{version:11,name:"leased_dispatch",up:e=>{e.exec(`
743
+ -- NOT-469: leased dispatcher (lib/dispatcher). One row per request a
744
+ -- worker owns. The token is a fencing value: heartbeat, release, and
745
+ -- every fenced commit match it, so a worker whose lease was taken
746
+ -- over can no longer write. An expired row is not free: its run may
747
+ -- still be live, so it counts toward concurrency until a worker
748
+ -- takes it over and reconciles it.
749
+ CREATE TABLE dispatch_leases (
750
+ request_id TEXT PRIMARY KEY,
751
+ target_agent_id TEXT NOT NULL,
752
+ owner TEXT NOT NULL CHECK (length(owner) > 0),
753
+ token TEXT NOT NULL UNIQUE CHECK (length(token) > 0),
754
+ acquired_at INTEGER NOT NULL,
755
+ heartbeat_at INTEGER NOT NULL,
756
+ expires_at INTEGER NOT NULL,
757
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
758
+ );
759
+ CREATE INDEX idx_dispatch_leases_target ON dispatch_leases(target_agent_id);
760
+ CREATE INDEX idx_dispatch_leases_expiry ON dispatch_leases(expires_at);
761
+
762
+ -- Launch intent, written with the Attempt before any adapter call:
763
+ -- the exact start body (or null for a transport without external
764
+ -- runs), its idempotency key, and a non-secret fingerprint of the
765
+ -- launching grant. Reconciliation re-POSTs only this body, under
766
+ -- this key, with this grant (NOT-468 decision table A).
767
+ CREATE TABLE attempt_launch_intents (
768
+ attempt_id TEXT PRIMARY KEY,
769
+ request_id TEXT NOT NULL,
770
+ transport TEXT NOT NULL CHECK (length(transport) > 0),
771
+ idempotency_key TEXT,
772
+ body TEXT,
773
+ body_hash TEXT,
774
+ grant_fingerprint TEXT,
775
+ owner TEXT NOT NULL,
776
+ created_at INTEGER NOT NULL,
777
+ CHECK ((body IS NULL) = (body_hash IS NULL)),
778
+ CHECK (body IS NULL OR idempotency_key IS NOT NULL),
779
+ FOREIGN KEY (attempt_id) REFERENCES work_attempts(id),
780
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
781
+ );
782
+ CREATE TRIGGER trg_attempt_launch_intents_fk BEFORE INSERT ON attempt_launch_intents
783
+ BEGIN
784
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: attempt_launch_intents.attempt_id')
785
+ WHERE NOT EXISTS (SELECT 1 FROM work_attempts WHERE id = NEW.attempt_id AND request_id = NEW.request_id);
786
+ END;
787
+ CREATE TRIGGER trg_attempt_launch_intents_immutable BEFORE UPDATE ON attempt_launch_intents
788
+ BEGIN
789
+ SELECT RAISE(ABORT, 'attempt_launch_intents are immutable');
790
+ END;
791
+
792
+ -- Operator-attention flag, separate from the Attempt lifecycle. While
793
+ -- one is open for a request the dispatcher makes no automatic
794
+ -- launch, re-POST, retry, or resume for it. Only an operator clears
795
+ -- it (cleared_at).
796
+ CREATE TABLE dispatch_attention (
797
+ id TEXT PRIMARY KEY,
798
+ request_id TEXT NOT NULL,
799
+ attempt_id TEXT,
800
+ reason TEXT NOT NULL CHECK (length(reason) > 0),
801
+ detail TEXT,
802
+ created_at INTEGER NOT NULL,
803
+ cleared_at INTEGER,
804
+ FOREIGN KEY (request_id) REFERENCES work_requests(id),
805
+ FOREIGN KEY (attempt_id) REFERENCES work_attempts(id)
806
+ );
807
+ CREATE UNIQUE INDEX idx_dispatch_attention_open ON dispatch_attention(request_id) WHERE cleared_at IS NULL;
808
+ `)}},{version:12,name:"request_control",up:e=>{e.exec(`
809
+ -- NOT-473: cancellation, deadlines, and bounded retries
810
+ -- (lib/work-request-control, lib/request-policy). The deadline and
811
+ -- retry policy are fixed at intake; null on older rows means no
812
+ -- deadline and one Attempt. attempt_count counts claimed Attempts
813
+ -- and never decreases; a queued retry is not claimable before
814
+ -- next_eligible_at. The cancellation intent is recorded once.
815
+ ALTER TABLE work_requests ADD COLUMN deadline_at INTEGER;
816
+ ALTER TABLE work_requests ADD COLUMN retry_policy TEXT;
817
+ ALTER TABLE work_requests ADD COLUMN attempt_count INTEGER NOT NULL DEFAULT 0 CHECK (attempt_count >= 0);
818
+ ALTER TABLE work_requests ADD COLUMN next_eligible_at INTEGER;
819
+ ALTER TABLE work_requests ADD COLUMN cancel_requested_at INTEGER;
820
+ ALTER TABLE work_requests ADD COLUMN cancel_requested_by TEXT;
821
+ ALTER TABLE work_requests ADD COLUMN cancel_reason TEXT;
822
+ CREATE INDEX idx_work_requests_deadline ON work_requests(deadline_at) WHERE deadline_at IS NOT NULL;
823
+
824
+ CREATE TRIGGER trg_work_requests_control_immutable BEFORE UPDATE OF deadline_at, retry_policy ON work_requests
825
+ WHEN NEW.deadline_at IS NOT OLD.deadline_at OR NEW.retry_policy IS NOT OLD.retry_policy
826
+ BEGIN
827
+ SELECT RAISE(ABORT, 'work_requests deadline and retry policy are immutable');
828
+ END;
829
+ CREATE TRIGGER trg_work_requests_attempt_count BEFORE UPDATE OF attempt_count ON work_requests
830
+ WHEN NEW.attempt_count < OLD.attempt_count
831
+ BEGIN
832
+ SELECT RAISE(ABORT, 'work_requests attempt_count never decreases');
833
+ END;
834
+ CREATE TRIGGER trg_work_requests_cancel_once BEFORE UPDATE OF cancel_requested_at, cancel_requested_by, cancel_reason ON work_requests
835
+ WHEN OLD.cancel_requested_at IS NOT NULL AND (
836
+ NEW.cancel_requested_at IS NOT OLD.cancel_requested_at
837
+ OR NEW.cancel_requested_by IS NOT OLD.cancel_requested_by
838
+ OR NEW.cancel_reason IS NOT OLD.cancel_reason
839
+ )
840
+ BEGIN
841
+ SELECT RAISE(ABORT, 'work_requests cancellation intent is recorded once');
842
+ END;
843
+
844
+ -- Conversation projection gains the cancellation, timeout, and
845
+ -- retry kinds (rebuilt with every row kept, as in version 10).
846
+ CREATE TABLE conversation_events_v12 (
847
+ id TEXT PRIMARY KEY,
848
+ conversation_id TEXT NOT NULL,
849
+ engine_event_id TEXT NOT NULL,
850
+ part INTEGER NOT NULL CHECK (part >= 0),
851
+ request_id TEXT NOT NULL,
852
+ request_sequence INTEGER NOT NULL,
853
+ attempt_id TEXT,
854
+ wake_id TEXT,
855
+ kind TEXT NOT NULL CHECK (kind IN (
856
+ 'wake_accepted', 'wake_blocked', 'request_queued', 'request_blocked', 'request_running',
857
+ 'request_waiting', 'request_completed', 'request_failed', 'request_cancelled',
858
+ 'question', 'result', 'artifact',
859
+ 'finalization_preparing', 'finalization_committed', 'finalization_blocked',
860
+ 'finalization_failed', 'finalization_canceled', 'finalization_rejected',
861
+ 'request_cancel_requested', 'request_timed_out', 'request_retry_scheduled', 'request_retries_exhausted'
862
+ )),
863
+ state TEXT CHECK (state IN (${f})),
864
+ text TEXT NOT NULL,
865
+ data TEXT NOT NULL,
866
+ sort_at INTEGER NOT NULL,
867
+ request_created_at INTEGER NOT NULL,
868
+ created_at INTEGER NOT NULL,
869
+ UNIQUE (engine_event_id, part),
870
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
871
+ FOREIGN KEY (engine_event_id) REFERENCES engine_events(id),
872
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
873
+ );
874
+ INSERT INTO conversation_events_v12 SELECT
875
+ id, conversation_id, engine_event_id, part, request_id, request_sequence, attempt_id, wake_id,
876
+ kind, state, text, data, sort_at, request_created_at, created_at
877
+ FROM conversation_events;
878
+ DROP TABLE conversation_events;
879
+ ALTER TABLE conversation_events_v12 RENAME TO conversation_events;
880
+ CREATE INDEX idx_conversation_events_order
881
+ ON conversation_events(conversation_id, sort_at, request_created_at, request_id, request_sequence, part);
882
+ CREATE INDEX idx_conversation_events_request ON conversation_events(request_id);
883
+ CREATE TRIGGER trg_conversation_events_immutable BEFORE UPDATE ON conversation_events
884
+ BEGIN
885
+ SELECT RAISE(ABORT, 'conversation_events are immutable');
886
+ END;
887
+ `)}},{version:13,name:"wake_safety",up:e=>{e.exec(`
888
+ -- NOT-475: Wake safety (docs/design/2026-10-14-wake-safety-contract.md,
889
+ -- lib/wake-safety). Lineage columns: wake_depth counts Agent-to-Agent
890
+ -- hops from the root (a continuation runs at the depth of the Agent it
891
+ -- continues) and the root principal is whoever started the lineage.
892
+ -- Both are fixed at intake.
893
+ ALTER TABLE work_requests ADD COLUMN wake_depth INTEGER NOT NULL DEFAULT 0 CHECK (wake_depth >= 0);
894
+ ALTER TABLE work_requests ADD COLUMN root_principal_kind TEXT;
895
+ ALTER TABLE work_requests ADD COLUMN root_principal_id TEXT;
896
+
897
+ -- Owner-approved edit grants for one (caller Agent, target Agent)
898
+ -- pair. Never seeded; revoked once, never rewritten or reused.
899
+ CREATE TABLE wake_grants (
900
+ id TEXT PRIMARY KEY,
901
+ caller_agent_id TEXT NOT NULL,
902
+ target_agent_id TEXT NOT NULL,
903
+ authority TEXT NOT NULL CHECK (authority = 'edit'),
904
+ granted_by_kind TEXT NOT NULL,
905
+ granted_by_id TEXT NOT NULL,
906
+ source_wake_id TEXT,
907
+ created_at INTEGER NOT NULL,
908
+ revoked_at INTEGER,
909
+ revoked_by_kind TEXT,
910
+ revoked_by_id TEXT,
911
+ CHECK ((revoked_at IS NULL) = (revoked_by_kind IS NULL) AND (revoked_at IS NULL) = (revoked_by_id IS NULL))
912
+ );
913
+ CREATE UNIQUE INDEX idx_wake_grants_active ON wake_grants(caller_agent_id, target_agent_id, authority) WHERE revoked_at IS NULL;
914
+ CREATE TRIGGER trg_wake_grants_immutable BEFORE UPDATE ON wake_grants
915
+ BEGIN
916
+ SELECT RAISE(ABORT, 'wake_grants are immutable except for one revocation')
917
+ WHERE OLD.revoked_at IS NOT NULL
918
+ OR NEW.id IS NOT OLD.id OR NEW.caller_agent_id IS NOT OLD.caller_agent_id
919
+ OR NEW.target_agent_id IS NOT OLD.target_agent_id OR NEW.authority IS NOT OLD.authority
920
+ OR NEW.granted_by_kind IS NOT OLD.granted_by_kind OR NEW.granted_by_id IS NOT OLD.granted_by_id
921
+ OR NEW.source_wake_id IS NOT OLD.source_wake_id OR NEW.created_at IS NOT OLD.created_at;
922
+ END;
923
+
924
+ -- One append-only row per safety evaluation of a Work Request: the
925
+ -- categorized caller principal, target, decision, matched grant rule
926
+ -- and grant, and the policy snapshot used. A request is runnable
927
+ -- only while its latest decision is allowed (lib/dispatcher). A
928
+ -- later policy change (a revoked grant, new limits) adds rows for
929
+ -- later evaluations and never rewrites these.
930
+ CREATE TABLE wake_safety_decisions (
931
+ id TEXT PRIMARY KEY,
932
+ request_id TEXT NOT NULL,
933
+ sequence INTEGER NOT NULL CHECK (sequence > 0),
934
+ wake_id TEXT,
935
+ principal_type TEXT NOT NULL CHECK (principal_type IN ('human_owner', 'api_principal', 'agent_principal', 'engine')),
936
+ principal_kind TEXT NOT NULL,
937
+ principal_id TEXT NOT NULL,
938
+ target_agent_id TEXT NOT NULL,
939
+ execution_kind TEXT NOT NULL,
940
+ decision TEXT NOT NULL CHECK (decision IN ('allowed', 'blocked', 'denied')),
941
+ reason_code TEXT,
942
+ grant_rule TEXT,
943
+ grant_id TEXT,
944
+ policy_snapshot TEXT NOT NULL,
945
+ created_at INTEGER NOT NULL,
946
+ UNIQUE (request_id, sequence),
947
+ CHECK (decision <> 'allowed' OR grant_rule IS NOT NULL),
948
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
949
+ );
950
+ CREATE TRIGGER trg_wake_safety_decisions_fk BEFORE INSERT ON wake_safety_decisions
951
+ BEGIN
952
+ SELECT RAISE(ABORT, 'FOREIGN KEY constraint failed: wake_safety_decisions.request_id')
953
+ WHERE NOT EXISTS (SELECT 1 FROM work_requests WHERE id = NEW.request_id);
954
+ END;
955
+ CREATE TRIGGER trg_wake_safety_decisions_immutable BEFORE UPDATE ON wake_safety_decisions
956
+ BEGIN
957
+ SELECT RAISE(ABORT, 'wake_safety_decisions are append-only');
958
+ END;
959
+
960
+ -- Depth and root-budget refusals name the limit and what was seen.
961
+ ALTER TABLE wakes ADD COLUMN limit_value INTEGER;
962
+ ALTER TABLE wakes ADD COLUMN observed_value INTEGER;
963
+
964
+ -- Rejected Wakes project from the Wake row (no Work Request, no
965
+ -- engine event), and a stopped lineage projects as its own kind.
966
+ CREATE TABLE conversation_events_v13 (
967
+ id TEXT PRIMARY KEY,
968
+ conversation_id TEXT NOT NULL,
969
+ engine_event_id TEXT,
970
+ part INTEGER NOT NULL CHECK (part >= 0),
971
+ request_id TEXT,
972
+ request_sequence INTEGER NOT NULL,
973
+ attempt_id TEXT,
974
+ wake_id TEXT,
975
+ kind TEXT NOT NULL CHECK (kind IN (
976
+ 'wake_accepted', 'wake_blocked', 'request_queued', 'request_blocked', 'request_running',
977
+ 'request_waiting', 'request_completed', 'request_failed', 'request_cancelled',
978
+ 'question', 'result', 'artifact',
979
+ 'finalization_preparing', 'finalization_committed', 'finalization_blocked',
980
+ 'finalization_failed', 'finalization_canceled', 'finalization_rejected',
981
+ 'request_cancel_requested', 'request_timed_out', 'request_retry_scheduled', 'request_retries_exhausted',
982
+ 'wake_rejected', 'lineage_stopped'
983
+ )),
984
+ state TEXT CHECK (state IN (${f})),
985
+ text TEXT NOT NULL,
986
+ data TEXT NOT NULL,
987
+ sort_at INTEGER NOT NULL,
988
+ request_created_at INTEGER NOT NULL,
989
+ created_at INTEGER NOT NULL,
990
+ UNIQUE (engine_event_id, part),
991
+ CHECK ((engine_event_id IS NULL) = (request_id IS NULL)),
992
+ CHECK (request_id IS NOT NULL OR wake_id IS NOT NULL),
993
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
994
+ FOREIGN KEY (engine_event_id) REFERENCES engine_events(id),
995
+ FOREIGN KEY (request_id) REFERENCES work_requests(id)
996
+ );
997
+ INSERT INTO conversation_events_v13 SELECT
998
+ id, conversation_id, engine_event_id, part, request_id, request_sequence, attempt_id, wake_id,
999
+ kind, state, text, data, sort_at, request_created_at, created_at
1000
+ FROM conversation_events;
1001
+ DROP TABLE conversation_events;
1002
+ ALTER TABLE conversation_events_v13 RENAME TO conversation_events;
1003
+ CREATE INDEX idx_conversation_events_order
1004
+ ON conversation_events(conversation_id, sort_at, request_created_at, request_id, request_sequence, part);
1005
+ CREATE INDEX idx_conversation_events_request ON conversation_events(request_id);
1006
+ CREATE INDEX idx_conversation_events_wake ON conversation_events(wake_id);
1007
+ CREATE TRIGGER trg_conversation_events_immutable BEFORE UPDATE ON conversation_events
1008
+ BEGIN
1009
+ SELECT RAISE(ABORT, 'conversation_events are immutable');
1010
+ END;
1011
+ `),function(e){let t=e.prepare(`
1012
+ SELECT id, parent_request_id, root_request_id, wake_event_id, requester_kind, requester_id, policy_snapshot, state,
1013
+ target_agent_id, execution_kind, legacy_agent_request_id, created_at
1014
+ FROM work_requests ORDER BY created_at ASC, rowid ASC
1015
+ `).all(),n=new Map(t.map(e=>[e.id,e])),r=e=>{try{let t=JSON.parse(e.policy_snapshot);return t&&"object"==typeof t&&!Array.isArray(t)?t:{}}catch{return{}}},a=new Map,s=e=>{let t=a.get(e.id);if(void 0!==t)return t;let r=[],i=new Set,s=e,o=!1;for(;s&&!i.has(s.id)&&s.root_request_id===e.root_request_id;){let t=a.get(s.id);if(void 0!==t){o=t;break}if(i.add(s.id),r.push(s),null===s.parent_request_id){o=s.id===e.root_request_id;break}s=n.get(s.parent_request_id)}for(let e of r)a.set(e.id,o);return o},o=new Map,d=e=>{let t=o.get(e.id);if(void 0!==t)return t;let i=0,a=e.parent_request_id?n.get(e.parent_request_id):void 0;if(a){let t=d(a),n=r(e);i=e.wake_event_id?t+1:"coordinator_continuation"===n.source&&"result"===n.continues?Math.max(t-1,0):t}return o.set(e.id,i),i},_=e.prepare("UPDATE work_requests SET wake_depth = ?, root_principal_kind = ?, root_principal_id = ? WHERE id = ?"),E=e.prepare(`
1016
+ INSERT INTO wake_safety_decisions (
1017
+ id, request_id, sequence, wake_id, principal_type, principal_kind, principal_id, target_agent_id, execution_kind,
1018
+ decision, reason_code, grant_rule, grant_id, policy_snapshot, created_at
1019
+ ) VALUES (?, ?, 1, ?, ?, ?, ?, ?, ?, 'allowed', NULL, 'pre_safety_migration', NULL, ?, ?)
1020
+ `);for(let a of(e.exec("DROP TRIGGER trg_work_requests_terminal"),t)){let e=n.get(a.root_request_id),t=!!e&&s(a),o=t?d(a):0,u=t&&e?{kind:e.requester_kind,id:e.requester_id}:{kind:"unknown",id:"unknown"};if(_.run(o,u.kind,u.id,a.id),null===a.legacy_agent_request_id&&["queued","running","waiting"].includes(a.state)){let e=r(a),t="wake"===e.source?"agent_principal":"coordinator_continuation"===e.source?"engine":"api"===e.surface?"api_principal":"human_owner";E.run((0,i.randomUUID)(),a.id,a.wake_event_id,t,a.requester_kind,a.requester_id,a.target_agent_id,a.execution_kind,JSON.stringify({safety_version:1,migrated:!0,root_principal:u,wake_depth:o,grant_rule:"pre_safety_migration"}),a.created_at)}}e.exec(`
1021
+ CREATE TRIGGER trg_work_requests_terminal BEFORE UPDATE ON work_requests
1022
+ WHEN OLD.state IN (${v})
1023
+ BEGIN
1024
+ SELECT RAISE(ABORT, 'terminal work_requests are immutable');
1025
+ END;
1026
+ `)}(e),e.exec(`
1027
+ CREATE TRIGGER trg_work_requests_safety_immutable BEFORE UPDATE OF wake_depth, root_principal_kind, root_principal_id ON work_requests
1028
+ WHEN NEW.wake_depth IS NOT OLD.wake_depth
1029
+ OR NEW.root_principal_kind IS NOT OLD.root_principal_kind
1030
+ OR NEW.root_principal_id IS NOT OLD.root_principal_id
1031
+ BEGIN
1032
+ SELECT RAISE(ABORT, 'work_requests wake depth and root principal are immutable');
1033
+ END;
1034
+ `)}},{version:14,name:"retire_legacy_agent_requests",up:e=>{!function(e){let t=t=>!!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(t);if(!t("agent_requests"))return;let n=t("agent_request_events"),r=e.prepare(`
1035
+ SELECT r.*, m.content AS content FROM agent_requests r
1036
+ JOIN conversations c ON c.id = r.conversation_id
1037
+ JOIN bots b ON b.id = r.target_bot_id
1038
+ JOIN messages m ON m.id = r.accepted_message_id AND m.conversation_id = r.conversation_id
1039
+ WHERE r.state IN ('completed', 'failed', 'accepted', 'dispatched')
1040
+ AND r.principal_kind IN ('person', 'bot', 'service')
1041
+ AND NOT EXISTS (SELECT 1 FROM work_requests w WHERE w.legacy_agent_request_id = r.id)
1042
+ ORDER BY r.created_at ASC, r.rowid ASC
1043
+ `).all(),a=e.prepare("SELECT 1 FROM work_requests WHERE requester_kind = ? AND requester_id = ? AND idempotency_key = ?"),s=n?e.prepare("SELECT type, data, created_at FROM agent_request_events WHERE request_id = ? ORDER BY created_at ASC, rowid ASC"):null,o=e.prepare(`
1044
+ INSERT INTO work_requests (
1045
+ id, source_conversation_id, source_event_id, requester_kind, requester_id, target_agent_id,
1046
+ intent, execution_kind, tool_profile, parent_request_id, root_request_id, wake_event_id, depth,
1047
+ idempotency_key, request_hash, policy_snapshot, state, state_reason, result, error_code, error_message,
1048
+ version, legacy_agent_request_id, created_at, updated_at, terminal_at, root_principal_kind, root_principal_id
1049
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, 'conversation', 'readonly', NULL, ?, NULL, 0, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?)
1050
+ `),d=e.prepare("INSERT INTO engine_events (id, request_id, sequence, attempt_id, type, data, created_at) VALUES (?, ?, ?, NULL, ?, ?, ?)"),_=Date.now();for(let e of r){if(a.get(e.principal_kind,e.principal_id,e.idempotency_key))continue;let t=(0,i.randomUUID)(),n=y({sourceConversationId:e.conversation_id,sourceEventId:e.accepted_message_id,targetAgentId:e.target_bot_id,intent:e.content,executionKind:"conversation",toolProfile:"readonly"}),r="accepted"===e.state||"dispatched"===e.state,E=JSON.stringify({tool_profile:"readonly",source:"legacy_agent_requests",legacy_operation:e.operation,legacy_runtime:e.runtime,...r?{legacy_state:e.state}:{}}),u=r?Math.max(_,e.updated_at):e.updated_at;o.run(t,e.conversation_id,e.accepted_message_id,e.principal_kind,e.principal_id,e.target_bot_id,e.content,t,e.idempotency_key,n,E,r?"failed":e.state,r?D:null,"completed"===e.state?JSON.stringify({reply_message_id:e.reply_message_id}):null,r?D:"failed"===e.state?e.failure_code:null,r?b:"failed"===e.state?e.failure_message:null,e.id,e.created_at,u,u,e.principal_kind,e.principal_id);let c=0;for(let n of s?.all(e.id)??[])d.run((0,i.randomUUID)(),t,++c,n.type,n.data,n.created_at);r&&d.run((0,i.randomUUID)(),t,++c,"state_changed",JSON.stringify({from:"accepted"===e.state?"queued":"running",to:"failed",reason:D}),u),d.run((0,i.randomUUID)(),t,++c,"backfilled",JSON.stringify({legacy_agent_request_id:e.id}),u)}(function(e){let t=e.prepare(`
1051
+ SELECT w.id AS request_id, r.principal_kind, r.principal_id, r.idempotency_key, r.payload_hash,
1052
+ r.conversation_id, r.target_bot_id, r.accepted_message_id, r.created_at, m.content AS content
1053
+ FROM work_requests w
1054
+ JOIN agent_requests r ON r.id = w.legacy_agent_request_id
1055
+ JOIN messages m ON m.id = r.accepted_message_id
1056
+ WHERE r.operation = 'send_message'
1057
+ AND NOT EXISTS (
1058
+ SELECT 1 FROM conversation_intakes i
1059
+ WHERE i.requester_kind = r.principal_kind AND i.requester_id = r.principal_id AND i.idempotency_key = r.idempotency_key
1060
+ )
1061
+ `).all(),n=e.prepare(`
1062
+ INSERT INTO conversation_intakes (
1063
+ requester_kind, requester_id, idempotency_key, request_hash, surface,
1064
+ conversation_id, source_event_id, work_request_ids, created_at
1065
+ ) VALUES (?, ?, ?, ?, 'api', ?, ?, ?, ?)
1066
+ `);for(let e of t){let t=[e.conversation_id,null].map(t=>[e.target_bot_id,t,e.content]).find(t=>G(JSON.stringify(t))===e.payload_hash);t&&n.run(e.principal_kind,e.principal_id,e.idempotency_key,G(JSON.stringify(["api",t])),e.conversation_id,e.accepted_message_id,JSON.stringify([e.request_id]),e.created_at)}})(e),t("legacy_agent_requests_archive")?e.exec("INSERT INTO legacy_agent_requests_archive SELECT * FROM agent_requests; DROP TABLE agent_requests;"):e.exec("ALTER TABLE agent_requests RENAME TO legacy_agent_requests_archive"),n&&(t("legacy_agent_request_events_archive")?e.exec("INSERT INTO legacy_agent_request_events_archive SELECT * FROM agent_request_events; DROP TABLE agent_request_events;"):e.exec("ALTER TABLE agent_request_events RENAME TO legacy_agent_request_events_archive"))}(e)}},{version:15,name:"ui_turns_on_work_requests",up:e=>{e.exec(`
1067
+ ALTER TABLE work_requests ADD COLUMN executor TEXT NOT NULL DEFAULT 'dispatcher'
1068
+ CHECK (executor IN ('dispatcher', 'ui_message', 'ui_continuation'));
1069
+ CREATE INDEX idx_work_requests_executor ON work_requests(executor, state, created_at);
1070
+
1071
+ -- Delegation accounting for one user message in one UI thread:
1072
+ -- handoffs (depth), delegated turns (budget), Stop, and the
1073
+ -- caller frames a delegate's reply returns to. One row per
1074
+ -- (conversation, user message); a later user message starts a
1075
+ -- fresh row.
1076
+ CREATE TABLE delegation_chains (
1077
+ conversation_id TEXT NOT NULL,
1078
+ user_message_id TEXT NOT NULL,
1079
+ handoffs INTEGER NOT NULL DEFAULT 0 CHECK (handoffs >= 0),
1080
+ turns INTEGER NOT NULL DEFAULT 0 CHECK (turns >= 0),
1081
+ stopped INTEGER NOT NULL DEFAULT 0 CHECK (stopped IN (0, 1)),
1082
+ frames TEXT NOT NULL DEFAULT '[]',
1083
+ created_at INTEGER NOT NULL,
1084
+ updated_at INTEGER NOT NULL,
1085
+ PRIMARY KEY (conversation_id, user_message_id),
1086
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id)
1087
+ );
1088
+ `),function(e){let t=t=>!!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(t);if(!t("processing_queue"))return;let n=new Set(e.prepare("PRAGMA table_info(processing_queue)").all().map(e=>e.name)).has("work_request_id")?"q.work_request_id":"NULL",r=e.prepare(`
1089
+ SELECT q.id, q.conversation_id, q.bot_id, q.status, ${n} AS work_request_id, q.created_at, q.started_at, q.completed_at
1090
+ FROM processing_queue q
1091
+ JOIN conversations c ON c.id = q.conversation_id
1092
+ JOIN bots b ON b.id = q.bot_id
1093
+ ORDER BY q.created_at ASC, q.rowid ASC
1094
+ `).all(),a=e.prepare("SELECT * FROM work_requests WHERE id = ?"),s=e.prepare(`
1095
+ UPDATE work_requests SET state = ?, state_reason = ?, version = version + 1, updated_at = ?,
1096
+ error_code = ?, error_message = ?, terminal_at = ?, executor = 'ui_message'
1097
+ WHERE id = ?
1098
+ `),o=e.prepare(`
1099
+ INSERT INTO engine_events (id, request_id, sequence, attempt_id, type, data, created_at)
1100
+ SELECT ?, ?, COALESCE(MAX(sequence), 0) + 1, NULL, ?, ?, ? FROM engine_events WHERE request_id = ?
1101
+ `),d=(e,t,n,r)=>o.run((0,i.randomUUID)(),e,t,JSON.stringify(n),r,e),_=e.prepare("SELECT id FROM messages WHERE conversation_id = ? AND created_at <= ? ORDER BY created_at DESC, rowid DESC LIMIT 1"),E=e.prepare(`
1102
+ INSERT INTO work_requests (
1103
+ id, source_conversation_id, source_event_id, requester_kind, requester_id, target_agent_id,
1104
+ intent, execution_kind, tool_profile, parent_request_id, root_request_id, wake_event_id, depth,
1105
+ idempotency_key, request_hash, policy_snapshot, state, version, created_at, updated_at,
1106
+ wake_depth, root_principal_kind, root_principal_id, executor
1107
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, 'conversation', 'readonly', NULL, ?, NULL, 0, ?, ?, ?, 'queued', 0, ?, ?, 0, ?, ?, 'ui_continuation')
1108
+ `),u=F(!1),c=0;for(let t of r){if(t.work_request_id){let n=a.get(t.work_request_id);if(!n||"queued"!==n.state)continue;let r=t.started_at??t.created_at,i=Math.max(t.completed_at??r,r);if("pending"===t.status)e.prepare("UPDATE work_requests SET executor = 'ui_message' WHERE id = ?").run(n.id);else if("completed"===t.status||"failed"===t.status)s.run("running",null,r,null,null,null,n.id),d(n.id,"state_changed",{from:"queued",to:"running",reason:null,legacy_queue_id:t.id},r),s.run(t.status,"legacy_queue_turn",i,"failed"===t.status?"ui_turn_failed":null,"failed"===t.status?"The UI turn failed in the retired processing queue.":null,i,n.id),d(n.id,"state_changed",{from:"running",to:t.status,reason:"legacy_queue_turn",legacy_queue_id:t.id},i);else{let e=Math.max(Date.now(),r);s.run("running",null,r,null,null,null,n.id),d(n.id,"state_changed",{from:"queued",to:"running",reason:null,legacy_queue_id:t.id},r),s.run("failed",W,e,W,X,e,n.id),d(n.id,"state_changed",{from:"running",to:"failed",reason:W,error_code:W,legacy_queue_id:t.id},e)}c++;continue}if("pending"!==t.status)continue;let n=(0,i.randomUUID)(),r=_.get(t.conversation_id,t.created_at)?.id??t.conversation_id,o={source:"legacy_processing_queue",legacy_queue_id:t.id},T=y({sourceConversationId:t.conversation_id,sourceEventId:r,targetAgentId:t.bot_id,intent:"turn",executionKind:"conversation",toolProfile:"readonly",policy:{...o,execution_policy:u}});E.run(n,t.conversation_id,r,U.kind,U.id,t.bot_id,"turn",n,`legacy-queue:${t.id}`,T,JSON.stringify({...o,execution_policy:u,tool_profile:"readonly"}),t.created_at,t.created_at,U.kind,U.id),d(n,"accepted",{state:"queued",execution_kind:"conversation",tool_profile:"readonly"},t.created_at),d(n,"backfilled",{legacy_queue_id:t.id},t.created_at),c++}c+=e.prepare(`
1109
+ UPDATE work_requests SET executor = 'ui_message'
1110
+ WHERE state = 'queued' AND executor = 'dispatcher' AND legacy_agent_request_id IS NULL
1111
+ AND parent_request_id IS NULL AND wake_event_id IS NULL
1112
+ AND (
1113
+ (json_extract(policy_snapshot, '$.source') = 'conversation_intake' AND json_extract(policy_snapshot, '$.surface') = 'ui')
1114
+ OR EXISTS (
1115
+ SELECT 1 FROM conversation_intakes i, json_each(i.work_request_ids) r
1116
+ WHERE i.surface = 'ui' AND r.value = work_requests.id
1117
+ )
1118
+ )
1119
+ `).run().changes,t("legacy_processing_queue_archive")?e.exec("INSERT INTO legacy_processing_queue_archive SELECT * FROM processing_queue; DROP TABLE processing_queue;"):e.exec("ALTER TABLE processing_queue RENAME TO legacy_processing_queue_archive")}(e)}}],w=new WeakMap;function h(e){let t=w.get(e);if(!t){t=new Set,w.set(e,t);let n=t;e.function("engine_event_purge_authorized",{deterministic:!1},e=>"string"==typeof e&&n.has(e)?1:0)}return t}function C(e,t={}){h(e),e.exec(`
1120
+ CREATE TABLE IF NOT EXISTS schema_migrations (
1121
+ version INTEGER PRIMARY KEY,
1122
+ name TEXT NOT NULL,
1123
+ applied_at INTEGER NOT NULL
1124
+ );
1125
+ `);let n=e.prepare("SELECT 1 FROM schema_migrations WHERE version = ?"),r=e.prepare("INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)");for(let i of q){if(void 0!==t.through&&i.version>t.through)return;e.transaction(()=>{n.get(i.version)||(i.up(e),r.run(i.version,i.name,Date.now()))}).immediate()}}function y(e){return G(JSON.stringify([e.sourceConversationId,e.sourceEventId,e.targetAgentId,e.intent,e.executionKind,e.toolProfile,e.parentRequestId??null,e.wakeEventId??null,e.policy??null]))}q[q.length-1].version;let D="legacy_interrupted",b="Accepted before NOT-465 by the retired agent_requests dispatcher; it never reached a terminal state.",U=Object.freeze({kind:"service",id:"botmancers-ui-turns"});function F(e){let t=c(e?{entryPoint:"wake",executionKind:"conversation",wakeSyntax:"legacy"}:{entryPoint:"ui",executionKind:"conversation"});if(!t.ok)throw new k("invalid_input",t.reason);return t.policy}let W="ui_turn_interrupted",X="The UI turn was interrupted before it finished; it is not run again.";function x(e){return"string"==typeof e&&e.trim().length>0}function G(e){return(0,i.createHash)("sha256").update(e).digest("hex")}function M(e){return null==e?null:JSON.stringify(e)}function H(e){h(e);let t=e.prepare("SELECT * FROM work_requests WHERE id = ?"),n=e.prepare("SELECT * FROM work_requests WHERE requester_kind = ? AND requester_id = ? AND idempotency_key = ?"),r=e.prepare("SELECT * FROM work_attempts WHERE id = ?"),a=e.prepare(`
1126
+ INSERT INTO engine_events (id, request_id, sequence, attempt_id, type, data, created_at)
1127
+ SELECT ?, ?, COALESCE(MAX(sequence), 0) + 1, ?, ?, ?, ? FROM engine_events WHERE request_id = ?
1128
+ `),s=e.prepare("SELECT * FROM engine_events WHERE id = ?"),o=e.prepare("SELECT * FROM session_bindings WHERE id = ?");function d(e){let n=t.get(e);if(!n)throw new k("not_found",`No work request ${e}.`);return n}function u(e){let t=r.get(e);if(!t)throw new k("not_found",`No attempt ${e}.`);return t}function c(e,t,n,r,o){let d=(0,i.randomUUID)();return a.run(d,e,r,t,M(n),o,e),s.get(d)}let T={transaction:t=>e.transaction(t).immediate(),createOrGetWorkRequest(r){if(!x(r.sourceConversationId))throw new k("invalid_input","sourceConversationId is required.");if(!x(r.sourceEventId))throw new k("invalid_input","sourceEventId is required.");if(!r.requester||!["person","bot","service"].includes(r.requester.kind)||!x(r.requester.id))throw new k("invalid_input","A requester principal is required.");if(!x(r.targetAgentId))throw new k("invalid_input","targetAgentId is required.");if("string"!=typeof r.intent)throw new k("invalid_input","intent is required.");if(!E(r.executionKind))throw new k("invalid_input","Unknown execution kind.");if(_[r.executionKind]!==r.toolProfile)throw new k("invalid_input",`Execution kind ${r.executionKind} requires the ${_[r.executionKind]} tool profile.`);if(r.policy&&Object.prototype.hasOwnProperty.call(r.policy,"execution_policy"))throw new k("invalid_input","The execution policy is passed as executionPolicy, never inside policy.");if(void 0!==r.executionPolicy){let e=l(r.executionPolicy);if(!e.ok)throw new k("invalid_input",e.reason);if(e.policy.execution_kind!==r.executionKind||e.policy.tool_profile!==r.toolProfile)throw new k("invalid_input","The execution policy does not match the requested execution kind and tool profile.")}if(!x(r.idempotencyKey))throw new k("invalid_input","idempotencyKey is required.");if(void 0!==r.executor&&!S.includes(r.executor))throw new k("invalid_input","Unknown request executor.");if(r.initialState&&"queued"!==r.initialState&&"blocked"!==r.initialState)throw new k("invalid_input","A work request starts queued or blocked.");if(void 0!==r.deadlineAt&&null!==r.deadlineAt&&!Number.isSafeInteger(r.deadlineAt))throw new k("invalid_input","deadlineAt must be an epoch millisecond integer.");if(void 0!==r.retryPolicy){let e=m(r.retryPolicy);if(!e.ok)throw new k("invalid_input",e.reason)}let a=r.executionPolicy?{...r.policy??{},execution_policy:r.executionPolicy}:r.policy,s=y({...r,policy:a});return e.transaction(()=>{let o=n.get(r.requester.kind,r.requester.id,r.idempotencyKey);if(o){if(o.request_hash!==s)throw new k("idempotency_conflict","The idempotency key was already used with a different request.");return{request:o,created:!1}}let _=r.now??Date.now(),E=(0,i.randomUUID)(),u=E,l=0,p=0,N=r.rootPrincipal??r.requester;if(r.parentRequestId){let e=t.get(r.parentRequestId);if(!e)throw new k("not_found","Parent work request not found.");u=e.root_request_id,l=e.depth+1,p=r.wakeEventId?e.wake_depth+1:e.wake_depth,N={kind:e.root_principal_kind??"unknown",id:e.root_principal_id??"unknown"}}void 0!==r.wakeDepth&&(p=r.wakeDepth);let m=r.initialState??"queued",L=JSON.stringify({...a??{},...r.safetySnapshot??{},tool_profile:r.toolProfile}),O=R(),g=r.retryPolicy??O.retryPolicy,I=void 0!==r.deadlineAt?r.deadlineAt:null===O.deadlineMs?null:_+O.deadlineMs;return e.prepare(`
1129
+ INSERT INTO work_requests (
1130
+ id, source_conversation_id, source_event_id, requester_kind, requester_id, target_agent_id,
1131
+ intent, execution_kind, tool_profile, parent_request_id, root_request_id, wake_event_id, depth,
1132
+ idempotency_key, request_hash, policy_snapshot, state, state_reason, version, created_at, updated_at,
1133
+ deadline_at, retry_policy, wake_depth, root_principal_kind, root_principal_id, executor
1134
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?, ?, ?)
1135
+ `).run(E,r.sourceConversationId,r.sourceEventId,r.requester.kind,r.requester.id,r.targetAgentId,r.intent,r.executionKind,r.toolProfile,r.parentRequestId??null,u,r.wakeEventId??null,l,r.idempotencyKey,s,L,m,r.stateReason??null,_,_,I,JSON.stringify(g),p,N.kind,N.id,r.executor??"dispatcher"),c(E,"accepted",{state:m,execution_kind:r.executionKind,tool_profile:r.toolProfile,deadline_at:I,retry_policy:g},null,_),r.executionPolicy&&c(E,"policy_selected",{...r.executionPolicy},null,_),"blocked"===m&&c(E,"state_changed",{from:"queued",to:"blocked",reason:r.stateReason??null},null,_),r.safety&&T.recordSafetyDecision(E,{...r.safety,now:r.safety.now??_}),{request:d(E),created:!0}}).immediate()},getWorkRequest:e=>t.get(e),recordSafetyDecision(t,n){if(!["human_owner","api_principal","agent_principal","engine"].includes(n.principalType))throw new k("invalid_input","A categorized principal is required.");if(!x(n.principal?.kind)||!x(n.principal?.id))throw new k("invalid_input","A principal is required.");if(!["allowed","blocked","denied"].includes(n.decision))throw new k("invalid_input","Unknown safety decision.");if("allowed"===n.decision&&!x(n.grantRule))throw new k("invalid_input","An allowed decision names its grant rule.");return e.transaction(()=>{let r=d(t),a=(0,i.randomUUID)();return e.prepare(`
1136
+ INSERT INTO wake_safety_decisions (
1137
+ id, request_id, sequence, wake_id, principal_type, principal_kind, principal_id, target_agent_id, execution_kind,
1138
+ decision, reason_code, grant_rule, grant_id, policy_snapshot, created_at
1139
+ ) SELECT ?, ?, COALESCE(MAX(sequence), 0) + 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? FROM wake_safety_decisions WHERE request_id = ?
1140
+ `).run(a,t,n.wakeId??null,n.principalType,n.principal.kind,n.principal.id,r.target_agent_id,r.execution_kind,n.decision,n.reasonCode??null,n.grantRule??null,n.grantId??null,JSON.stringify(n.snapshot),n.now??Date.now(),t),e.prepare("SELECT * FROM wake_safety_decisions WHERE id = ?").get(a)}).immediate()},listSafetyDecisions:t=>e.prepare("SELECT * FROM wake_safety_decisions WHERE request_id = ? ORDER BY sequence ASC").all(t),latestSafetyDecision:t=>e.prepare("SELECT * FROM wake_safety_decisions WHERE request_id = ? ORDER BY sequence DESC LIMIT 1").get(t),transitionWorkRequest(t,n){if(!A[n.from]?.includes(n.to))throw new k("invalid_transition",`Cannot move a work request from ${n.from} to ${n.to}.`);let r=I.includes(n.to);return e.transaction(()=>{let i=d(t),a=n.now??Date.now();if(1!==e.prepare(`
1141
+ UPDATE work_requests SET
1142
+ state = ?, state_reason = ?, version = version + 1, updated_at = ?,
1143
+ result = ?, error_code = ?, error_message = ?, terminal_at = ?
1144
+ WHERE id = ? AND state = ? AND (? IS NULL OR version = ?)
1145
+ `).run(n.to,n.reason??null,a,r?M(n.result):null,r?n.errorCode??null:null,r?n.errorMessage??null:null,r?a:null,t,n.from,n.expectedVersion??null,n.expectedVersion??null).changes)throw new k("stale_state",`Work request ${t} is ${i.state} at version ${i.version}, not ${n.from}${void 0===n.expectedVersion?"":` at version ${n.expectedVersion}`}.`);return c(t,"state_changed",{...n.data??{},from:n.from,to:n.to,reason:n.reason??null,...n.errorCode?{error_code:n.errorCode}:{}},null,a),r&&null===i.legacy_agent_request_id&&"dispatcher"===i.executor&&e.prepare("INSERT OR IGNORE INTO terminal_followups (request_id, created_at) VALUES (?, ?)").run(t,a),d(t)}).immediate()},reblockWorkRequest:(t,n)=>e.transaction(()=>{let r=n.now??Date.now();if(1!==e.prepare("UPDATE work_requests SET state_reason = ?, version = version + 1, updated_at = ? WHERE id = ? AND state = 'blocked'").run(n.reason,r,t).changes)throw new k("stale_state",`Work request ${t} is not blocked.`);return c(t,n.type,n.data??{},null,r),d(t)}).immediate(),appendEvent(t,n){if(!x(n.type))throw new k("invalid_input","Event type is required.");return e.transaction(()=>{if(d(t),n.attemptId&&u(n.attemptId).request_id!==t)throw new k("invalid_input","The attempt belongs to another request.");return c(t,n.type,n.data,n.attemptId??null,n.now??Date.now())}).immediate()},listEvents:t=>e.prepare("SELECT * FROM engine_events WHERE request_id = ? ORDER BY sequence ASC").all(t),createAttempt(t,n){if("launch"!==n.kind&&"resume"!==n.kind)throw new k("invalid_input","Unknown attempt kind.");if(!x(n.adapter))throw new k("invalid_input","adapter is required.");if("resume"===n.kind&&!n.resumedSessionBindingId)throw new k("invalid_input","A resume attempt names the session binding it resumes.");if("launch"===n.kind&&n.resumedSessionBindingId)throw new k("invalid_input","A launch attempt does not resume a session binding.");let r="string"==typeof n.launchSnapshot?n.launchSnapshot:JSON.stringify(n.launchSnapshot);if("string"!=typeof r||0===r.length)throw new k("invalid_input","A launch snapshot is required.");return e.transaction(()=>{let a=d(t);if("running"!==a.state)throw new k("attempt_conflict",`Attempts start only on running requests (request is ${a.state}).`);if(n.toolProfile!==a.tool_profile)throw new k("invalid_input",`The attempt tool profile must be ${a.tool_profile}.`);if(e.prepare("SELECT id FROM work_attempts WHERE request_id = ? AND finished_at IS NULL").get(t))throw new k("attempt_conflict","The request already has an open attempt.");if(n.resumedSessionBindingId){let e=o.get(n.resumedSessionBindingId);if(!e)throw new k("not_found","Session binding not found.");if(null!==e.released_at)throw new k("session_mismatch","The session binding was released.");if(e.agent_id!==a.target_agent_id||e.adapter!==n.adapter)throw new k("session_mismatch","The session binding belongs to another Agent or adapter.");if(null!==e.conversation_id&&e.conversation_id!==a.source_conversation_id)throw new k("session_mismatch","The session binding belongs to another conversation.");if(null!==e.request_id&&d(e.request_id).root_request_id!==a.root_request_id)throw new k("session_mismatch","The session binding belongs to an unrelated work request.")}let s=n.now??Date.now(),_=(0,i.randomUUID)(),E=e.prepare("SELECT COALESCE(MAX(attempt_number), 0) + 1 AS n FROM work_attempts WHERE request_id = ?").get(t);return e.prepare(`
1146
+ INSERT INTO work_attempts (
1147
+ id, request_id, attempt_number, kind, adapter, tool_profile, launch_snapshot, launch_snapshot_hash,
1148
+ resumed_session_binding_id, external_run_id, external_session_id, started_at
1149
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1150
+ `).run(_,t,E.n,n.kind,n.adapter,n.toolProfile,r,G(r),n.resumedSessionBindingId??null,n.externalRunId??null,n.externalSessionId??null,s),c(t,"attempt_started",{attempt_number:E.n,kind:n.kind,adapter:n.adapter},_,s),u(_)}).immediate()},recordAttemptExternalIds:(t,n)=>e.transaction(()=>{let r=u(t);if(null!==r.finished_at)throw new k("attempt_conflict","The attempt is already finished.");return e.prepare("UPDATE work_attempts SET external_run_id = ?, external_session_id = ? WHERE id = ?").run(void 0===n.externalRunId?r.external_run_id:n.externalRunId,void 0===n.externalSessionId?r.external_session_id:n.externalSessionId,t),u(t)}).immediate(),finishAttempt(t,n){if(!["succeeded","failed","cancelled","interrupted","timed_out"].includes(n.outcome))throw new k("invalid_input","Unknown attempt outcome.");return e.transaction(()=>{let r=u(t);if(null!==r.finished_at)throw new k("attempt_conflict","The attempt is already finished.");let i=n.now??Date.now();return e.prepare(`
1151
+ UPDATE work_attempts SET outcome = ?, output = ?, error_category = ?, error_message = ?, artifacts = ?,
1152
+ external_run_id = ?, external_session_id = ?, finished_at = ?
1153
+ WHERE id = ? AND finished_at IS NULL
1154
+ `).run(n.outcome,n.output??null,n.errorCategory??null,n.errorMessage??null,JSON.stringify(n.artifacts??[]),void 0===n.externalRunId?r.external_run_id:n.externalRunId,void 0===n.externalSessionId?r.external_session_id:n.externalSessionId,i,t),c(r.request_id,"attempt_finished",{attempt_number:r.attempt_number,outcome:n.outcome,error_category:n.errorCategory??null},t,i),u(t)}).immediate()},getAttempt:e=>r.get(e),listAttempts:t=>e.prepare("SELECT * FROM work_attempts WHERE request_id = ? ORDER BY attempt_number ASC").all(t),bindSession(t){if(!x(t.agentId))throw new k("invalid_input","agentId is required.");if(!x(t.adapter))throw new k("invalid_input","adapter is required.");if(!x(t.externalSessionId))throw new k("invalid_input","externalSessionId is required.");if(!t.conversationId&&!t.requestId)throw new k("invalid_input","A session binding is scoped to a conversation or work request.");return e.transaction(()=>{let n=t.now??Date.now();if(!e.prepare("SELECT 1 FROM bots WHERE id = ?").get(t.agentId))throw new k("not_found",`No agent ${t.agentId}.`);if(t.requestId){let e=d(t.requestId);if(e.target_agent_id!==t.agentId)throw new k("session_mismatch","The work request targets another Agent.");if(t.conversationId&&e.source_conversation_id!==t.conversationId)throw new k("session_mismatch","The work request belongs to another conversation.")}if(t.sourceAttemptId){let e=u(t.sourceAttemptId),n=d(e.request_id);if(e.adapter!==t.adapter||n.target_agent_id!==t.agentId)throw new k("session_mismatch","The source attempt ran another Agent or adapter.");if(t.requestId&&e.request_id!==t.requestId)throw new k("session_mismatch","The source attempt belongs to another work request.");if(t.conversationId&&n.source_conversation_id!==t.conversationId)throw new k("session_mismatch","The source attempt belongs to another conversation.")}e.prepare(`
1155
+ UPDATE session_bindings SET released_at = ?
1156
+ WHERE agent_id = ? AND adapter = ? AND IFNULL(conversation_id, '') = ? AND IFNULL(request_id, '') = ?
1157
+ AND released_at IS NULL
1158
+ `).run(n,t.agentId,t.adapter,t.conversationId??"",t.requestId??"");let r=(0,i.randomUUID)();return e.prepare(`
1159
+ INSERT INTO session_bindings (id, agent_id, adapter, conversation_id, request_id, external_session_id, source_attempt_id, created_at)
1160
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
1161
+ `).run(r,t.agentId,t.adapter,t.conversationId??null,t.requestId??null,t.externalSessionId,t.sourceAttemptId??null,n),t.requestId&&c(t.requestId,"session_bound",{binding_id:r,adapter:t.adapter},t.sourceAttemptId??null,n),o.get(r)}).immediate()},getActiveSessionBinding:t=>e.prepare(`
1162
+ SELECT * FROM session_bindings
1163
+ WHERE agent_id = ? AND adapter = ? AND IFNULL(conversation_id, '') = ? AND IFNULL(request_id, '') = ?
1164
+ AND released_at IS NULL
1165
+ `).get(t.agentId,t.adapter,t.conversationId??"",t.requestId??"")};return T}function B(e,t){let n=(t,...n)=>e.prepare(t).all(...n).map(e=>e.id),r=new Set(n(t.requests,t.arg)),i=new Set(n(t.bindings,t.arg)),a=new Set,s=(e,t)=>{let n=!1;for(let r of t)e.has(r)||(e.add(r),n=!0);return n},o=e=>JSON.stringify([...e]),d="(SELECT value FROM json_each(?))";for(;;){let e=s(r,n(`SELECT id FROM work_requests WHERE parent_request_id IN ${d} OR root_request_id IN ${d}`,o(r),o(r))),t=s(r,n(`SELECT request_id AS id FROM work_attempts WHERE id IN ${d}`,o(a))),_=s(a,n(`SELECT id FROM work_attempts WHERE request_id IN ${d} OR resumed_session_binding_id IN ${d}`,o(r),o(i))),E=s(i,n(`SELECT id FROM session_bindings WHERE request_id IN ${d} OR source_attempt_id IN ${d}`,o(r),o(a)));if(!e&&!t&&!_&&!E)break}e.prepare(`DELETE FROM conversation_events WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM finalizations WHERE implementation_request_id IN ${d} OR review_request_id IN ${d} OR decision_request_id IN ${d}`).run(o(r),o(r),o(r)),e.prepare(`DELETE FROM candidate_manifests WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM attempt_finalization_baselines WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM conversation_projection_cursors WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM wake_safety_decisions WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM dispatch_leases WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM attempt_launch_intents WHERE request_id IN ${d}`).run(o(r)),e.prepare(`DELETE FROM dispatch_attention WHERE request_id IN ${d}`).run(o(r));let _=h(e);for(let e of r)_.add(e);try{e.prepare(`DELETE FROM engine_events WHERE request_id IN ${d}`).run(o(r))}finally{_.clear()}for(;a.size>0||i.size>0;){let t=n(`SELECT id FROM session_bindings WHERE id IN ${d}
1166
+ AND NOT EXISTS (SELECT 1 FROM work_attempts a WHERE a.resumed_session_binding_id = session_bindings.id)`,o(i));for(let n of t)e.prepare("DELETE FROM session_bindings WHERE id = ?").run(n),i.delete(n);let r=n(`SELECT id FROM work_attempts WHERE id IN ${d}
1167
+ AND NOT EXISTS (SELECT 1 FROM session_bindings b WHERE b.source_attempt_id = work_attempts.id)`,o(a));for(let t of r)e.prepare("DELETE FROM work_attempts WHERE id = ?").run(t),a.delete(t);if(0===t.length&&0===r.length)throw Error("Engine records could not be removed: unexpected attempt/binding reference cycle.")}for(let t of(e.prepare(`DELETE FROM conversation_events WHERE request_id IS NULL AND wake_id IN (SELECT id FROM wakes WHERE work_request_id IN ${d} OR parent_request_id IN ${d} OR root_request_id IN ${d})`).run(o(r),o(r),o(r)),e.prepare(`DELETE FROM wakes WHERE work_request_id IN ${d} OR parent_request_id IN ${d} OR root_request_id IN ${d}`).run(o(r),o(r),o(r)),e.prepare(`DELETE FROM terminal_followups WHERE request_id IN ${d}`).run(o(r)),n(`SELECT id FROM work_requests WHERE id IN ${d} ORDER BY depth DESC`,o(r))))e.prepare("DELETE FROM work_requests WHERE id = ?").run(t)}function K(e,t){e.prepare("DELETE FROM conversation_intakes WHERE conversation_id = ?").run(t),e.prepare("DELETE FROM delegation_chains WHERE conversation_id = ?").run(t),e.prepare("DELETE FROM conversation_events WHERE conversation_id = ? AND request_id IS NULL").run(t),e.prepare("DELETE FROM wakes WHERE source_conversation_id = ?").run(t),B(e,{requests:"SELECT id FROM work_requests WHERE source_conversation_id = ?",bindings:"SELECT id FROM session_bindings WHERE conversation_id = ?",arg:t})}function Y(e,t){e.prepare(`DELETE FROM conversation_events WHERE request_id IS NULL AND wake_id IN (
1168
+ SELECT id FROM wakes WHERE target_agent_id = ? OR (requester_agent_id = ? AND work_request_id IS NULL))`).run(t,t),e.prepare("DELETE FROM wakes WHERE target_agent_id = ? OR (requester_agent_id = ? AND work_request_id IS NULL)").run(t,t),e.prepare("DELETE FROM wake_grants WHERE caller_agent_id = ? OR target_agent_id = ?").run(t,t),B(e,{requests:"SELECT id FROM work_requests WHERE target_agent_id = ?",bindings:"SELECT id FROM session_bindings WHERE agent_id = ?",arg:t})}function P(e){if(!e)return{};try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:{}}catch{return{}}}function $(e){return"string"==typeof e&&e.length>0?e:null}function z(e,t){return t?`${e}: ${t}`:e}function j(e,t,n,r){let i="grant_required"===t,a=i?"needs your approval for edit work":n;return{kind:"wake_blocked",attemptId:null,text:a?`Wake blocked: ${e} — ${a}`:`Wake blocked: ${e}`,data:{...r,target_name:e,reason_code:t,reason:n,actions:i?["allow","deny"]:[]}}}e.s(["EngineStoreError",0,k,"TERMINAL_STATES",0,I,"UI_TURN_INTERRUPTED",0,W,"UI_TURN_INTERRUPTED_MESSAGE",0,X,"UI_TURN_REQUESTER",0,U,"createEngineStore",0,H,"deleteEngineRecordsForAgent",0,Y,"deleteEngineRecordsForConversation",0,K,"migrateEngineSchema",0,C,"uiTurnExecutionPolicy",0,F],35613);let J="agent_name_conflict";function V(e){return String(e??"").trim()}function Q(e){return V(e).normalize("NFC").toLowerCase().normalize("NFC")}function Z(e){return`An Agent named "${V(e)}" already exists. Agent names must be unique, ignoring case and surrounding spaces.`}class ee extends Error{code=J;requestedName;conflictingAgentId;constructor(e,t){super(Z(e)),this.name="AgentNameConflictError",this.requestedName=V(e),this.conflictingAgentId=t}}function et(e){let t=[...e].sort((e,t)=>e.created_at-t.created_at||(e.id<t.id?-1:+(e.id>t.id))),n=new Map,r=[],i=[];for(let e of t){let t=Q(e.name);if(n.has(t)){r.push(e);continue}n.set(t,e.id),e.name_key!==t&&i.push({id:e.id,name:e.name,name_key:t})}let a=[];for(let e of r){let t=Q(e.name),r=V(e.name)||"Agent",s=2;for(;n.has(Q(`${r}-${s}`));)s++;let o=`${r}-${s}`,d=Q(o);n.set(d,e.id),i.push({id:e.id,name:o,name_key:d}),a.push({bot_id:e.id,previous_name:e.name,new_name:o,name_key:t,kept_bot_id:n.get(t)})}return{updates:i,renames:a}}e.s(["AgentNameConflictError",0,ee,"agentDisplayName",0,V,"agentNameConflictBody",0,function(e,t="name"){return{error:e.message,code:J,field:t,name:e.requestedName,conflicting_agent_id:e.conflictingAgentId}},"agentNameConflictMessage",0,Z,"agentNameKey",0,Q,"planNameMigration",0,et],30098);let en=(0,e.i(52036).dbPath)();":memory:"!==en&&n.default.mkdirSync(r.default.dirname(r.default.resolve(en)),{recursive:!0});let er=new t.default(en);er.pragma("journal_mode = WAL"),er.exec(`
1169
+ CREATE TABLE IF NOT EXISTS bots (
1170
+ id TEXT PRIMARY KEY,
1171
+ name TEXT NOT NULL,
1172
+ title TEXT NOT NULL,
1173
+ description TEXT NOT NULL,
1174
+ avatar TEXT,
1175
+ created_at INTEGER NOT NULL
1176
+ );
1177
+
1178
+ CREATE TABLE IF NOT EXISTS groups (
1179
+ id TEXT PRIMARY KEY,
1180
+ name TEXT NOT NULL,
1181
+ created_at INTEGER NOT NULL
1182
+ );
1183
+
1184
+ CREATE TABLE IF NOT EXISTS group_members (
1185
+ group_id TEXT NOT NULL,
1186
+ bot_id TEXT NOT NULL,
1187
+ PRIMARY KEY (group_id, bot_id),
1188
+ FOREIGN KEY (group_id) REFERENCES groups(id),
1189
+ FOREIGN KEY (bot_id) REFERENCES bots(id)
1190
+ );
1191
+
1192
+ CREATE TABLE IF NOT EXISTS conversations (
1193
+ id TEXT PRIMARY KEY,
1194
+ type TEXT NOT NULL,
1195
+ bot_id TEXT,
1196
+ group_id TEXT,
1197
+ created_at INTEGER NOT NULL,
1198
+ FOREIGN KEY (bot_id) REFERENCES bots(id),
1199
+ FOREIGN KEY (group_id) REFERENCES groups(id)
1200
+ );
1201
+
1202
+ CREATE TABLE IF NOT EXISTS messages (
1203
+ id TEXT PRIMARY KEY,
1204
+ conversation_id TEXT NOT NULL,
1205
+ sender_type TEXT NOT NULL,
1206
+ sender_id TEXT,
1207
+ content TEXT NOT NULL,
1208
+ created_at INTEGER NOT NULL,
1209
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id)
1210
+ );
1211
+
1212
+ CREATE TABLE IF NOT EXISTS launch_snapshots (
1213
+ id TEXT PRIMARY KEY,
1214
+ bot_id TEXT NOT NULL,
1215
+ created_at INTEGER NOT NULL,
1216
+ hash TEXT NOT NULL,
1217
+ snapshot TEXT NOT NULL,
1218
+ FOREIGN KEY (bot_id) REFERENCES bots(id)
1219
+ );
1220
+
1221
+ CREATE INDEX IF NOT EXISTS idx_messages_conversation ON messages(conversation_id, created_at);
1222
+ CREATE INDEX IF NOT EXISTS idx_snapshots_bot ON launch_snapshots(bot_id, created_at DESC);
1223
+
1224
+ CREATE TABLE IF NOT EXISTS mcp_servers (
1225
+ id TEXT PRIMARY KEY,
1226
+ name TEXT NOT NULL,
1227
+ command TEXT NOT NULL,
1228
+ args TEXT NOT NULL,
1229
+ created_at INTEGER NOT NULL
1230
+ );
1231
+
1232
+ CREATE TABLE IF NOT EXISTS draft_actions (
1233
+ message_id TEXT PRIMARY KEY,
1234
+ status TEXT NOT NULL,
1235
+ recipient TEXT,
1236
+ acted_at INTEGER NOT NULL
1237
+ );
1238
+
1239
+ CREATE TABLE IF NOT EXISTS approvals (
1240
+ conversation_id TEXT NOT NULL,
1241
+ code TEXT NOT NULL,
1242
+ message_id TEXT,
1243
+ status TEXT NOT NULL DEFAULT 'pending',
1244
+ created_at INTEGER NOT NULL,
1245
+ resolved_at INTEGER,
1246
+ PRIMARY KEY (conversation_id, code)
1247
+ );
1248
+
1249
+ CREATE TABLE IF NOT EXISTS memories (
1250
+ id TEXT PRIMARY KEY,
1251
+ bot_id TEXT NOT NULL,
1252
+ fact TEXT NOT NULL,
1253
+ created_at INTEGER NOT NULL,
1254
+ FOREIGN KEY (bot_id) REFERENCES bots(id)
1255
+ );
1256
+
1257
+ CREATE INDEX IF NOT EXISTS idx_memories_bot ON memories(bot_id, created_at);
1258
+
1259
+ CREATE TABLE IF NOT EXISTS one_shots (
1260
+ id TEXT PRIMARY KEY,
1261
+ conversation_id TEXT NOT NULL,
1262
+ bot_id TEXT NOT NULL,
1263
+ due_at INTEGER NOT NULL,
1264
+ fired INTEGER NOT NULL DEFAULT 0,
1265
+ created_at INTEGER NOT NULL
1266
+ );
1267
+
1268
+ CREATE TABLE IF NOT EXISTS routines (
1269
+ id TEXT PRIMARY KEY,
1270
+ conversation_id TEXT NOT NULL,
1271
+ bot_id TEXT NOT NULL,
1272
+ word TEXT NOT NULL,
1273
+ next_due_at INTEGER NOT NULL,
1274
+ every_ms INTEGER NOT NULL,
1275
+ created_at INTEGER NOT NULL
1276
+ );
1277
+
1278
+ CREATE TABLE IF NOT EXISTS pending_questions (
1279
+ id TEXT PRIMARY KEY,
1280
+ conversation_id TEXT NOT NULL,
1281
+ bot_id TEXT NOT NULL,
1282
+ question TEXT NOT NULL,
1283
+ task_message_id TEXT,
1284
+ task_content TEXT,
1285
+ question_message_id TEXT,
1286
+ answer_message_id TEXT,
1287
+ answer TEXT,
1288
+ status TEXT NOT NULL DEFAULT 'asked',
1289
+ created_at INTEGER NOT NULL,
1290
+ resolved_at INTEGER,
1291
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
1292
+ FOREIGN KEY (bot_id) REFERENCES bots(id)
1293
+ );
1294
+
1295
+ CREATE INDEX IF NOT EXISTS idx_pending_questions_conversation
1296
+ ON pending_questions(conversation_id, status, created_at);
1297
+
1298
+ CREATE TABLE IF NOT EXISTS approval_requests (
1299
+ id TEXT PRIMARY KEY,
1300
+ conversation_id TEXT NOT NULL,
1301
+ bot_id TEXT,
1302
+ code TEXT NOT NULL,
1303
+ action_type TEXT,
1304
+ action_args TEXT,
1305
+ message_id TEXT,
1306
+ status TEXT NOT NULL DEFAULT 'pending',
1307
+ result TEXT,
1308
+ created_at INTEGER NOT NULL,
1309
+ resolved_at INTEGER,
1310
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
1311
+ FOREIGN KEY (bot_id) REFERENCES bots(id)
1312
+ );
1313
+
1314
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_approval_requests_conversation_code
1315
+ ON approval_requests(conversation_id, code);
1316
+ CREATE INDEX IF NOT EXISTS idx_approval_requests_conversation
1317
+ ON approval_requests(conversation_id, status, created_at);
1318
+ `);let ei=["#C6F54A","#F0A05A","#E85D75","#C9A0FF","#F2E36B"],ea="9e363764-e0d5-4fff-8ebd-ccbc46ba0ba5",es="5fbe32c2-79cb-452e-9d9b-f8c9eb63b99b",eo=er.prepare("PRAGMA table_info(bots)").all();eo.some(e=>"color"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN color TEXT"),eo.some(e=>"pinned"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0"),eo.some(e=>"last_seen"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN last_seen INTEGER"),eo.some(e=>"unread"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN unread INTEGER NOT NULL DEFAULT 0"),eo.some(e=>"hidden"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0"),eo.some(e=>"source_provider"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN source_provider TEXT"),eo.some(e=>"template_id"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN template_id TEXT"),eo.some(e=>"template_url"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN template_url TEXT"),eo.some(e=>"import_schema_version"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN import_schema_version TEXT"),eo.some(e=>"import_operation_id"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN import_operation_id TEXT"),eo.some(e=>"import_timestamp"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN import_timestamp INTEGER"),eo.some(e=>"hermes_profile"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN hermes_profile TEXT"),eo.some(e=>"persistent_runtime"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN persistent_runtime TEXT NOT NULL DEFAULT 'hermes'"),eo.some(e=>"coding_runtime"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN coding_runtime TEXT"),eo.some(e=>"deck_name"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN deck_name TEXT"),eo.some(e=>"working_directory"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN working_directory TEXT"),eo.some(e=>"runtime"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN runtime TEXT"),eo.some(e=>"agent_client"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN agent_client TEXT"),eo.some(e=>"deck_id"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN deck_id TEXT"),eo.some(e=>"needs_deck_reselection"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN needs_deck_reselection INTEGER NOT NULL DEFAULT 0"),eo.some(e=>"agent"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN agent TEXT"),eo.some(e=>"needs_deck_selection"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN needs_deck_selection INTEGER NOT NULL DEFAULT 0");{let e=er.prepare("SELECT id, agent, runtime, agent_client, persistent_runtime, coding_runtime, deck_id, deck_name, working_directory, needs_deck_reselection, needs_deck_selection FROM bots WHERE agent IS NULL").all(),t=er.prepare("UPDATE bots SET agent = ?, deck_id = ?, deck_name = ?, working_directory = ?, needs_deck_selection = ? WHERE id = ?");er.transaction(e=>{for(let n of e){let e=(0,a.migrateLegacyAgentFields)(n);t.run(e.agent,e.deck_id,e.deck_name,e.working_directory,+!!e.needs_deck_selection,n.id)}})(e)}eo.some(e=>"avatar_color"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN avatar_color TEXT"),eo.some(e=>"avatar_eyes"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN avatar_eyes TEXT"),eo.some(e=>"avatar_hands"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN avatar_hands TEXT"),eo.some(e=>"avatar_accessory"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN avatar_accessory TEXT"),eo.some(e=>"name_key"===e.name)||er.exec("ALTER TABLE bots ADD COLUMN name_key TEXT"),er.exec(`
1319
+ CREATE TABLE IF NOT EXISTS agent_name_migrations (
1320
+ id TEXT PRIMARY KEY,
1321
+ bot_id TEXT NOT NULL,
1322
+ previous_name TEXT NOT NULL,
1323
+ new_name TEXT NOT NULL,
1324
+ name_key TEXT NOT NULL,
1325
+ kept_bot_id TEXT NOT NULL,
1326
+ reason TEXT NOT NULL,
1327
+ created_at INTEGER NOT NULL
1328
+ );
1329
+ `),er.transaction(()=>{let e=et(er.prepare("SELECT id, name, created_at, name_key FROM bots").all());if(0===e.updates.length)return;let t=er.prepare("UPDATE bots SET name_key = NULL WHERE id = ?");for(let n of e.updates)t.run(n.id);let n=er.prepare("UPDATE bots SET name = ?, name_key = ? WHERE id = ?");for(let t of e.updates)n.run(t.name,t.name_key,t.id);let r=er.prepare("INSERT INTO agent_name_migrations (id, bot_id, previous_name, new_name, name_key, kept_bot_id, reason, created_at) VALUES (?, ?, ?, ?, ?, ?, 'duplicate_name', ?)"),a=Date.now();for(let t of e.renames)r.run((0,i.randomUUID)(),t.bot_id,t.previous_name,t.new_name,t.name_key,t.kept_bot_id,a),console.warn(`[botmancers] Agent ${t.bot_id} renamed "${t.previous_name}" -> "${t.new_name}": name already used by Agent ${t.kept_bot_id}.`)})(),er.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_bots_name_key ON bots(name_key)"),er.exec(`
1330
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_bots_import_operation
1331
+ ON bots(import_operation_id) WHERE import_operation_id IS NOT NULL
1332
+ `),er.prepare("UPDATE bots SET color = ? WHERE id = ?").run(ei[0],ea),er.prepare("UPDATE bots SET color = ? WHERE id = ?").run(ei[1],es);let ed=er.prepare("SELECT id FROM bots WHERE id NOT IN (?, ?) ORDER BY created_at ASC").all(ea,es),e_=er.prepare("UPDATE bots SET color = ? WHERE id = ?");function eE(e,t){let n=V(e),r=Q(n),i=er.prepare("SELECT id FROM bots WHERE name_key = ?").get(r);if(i&&i.id!==t)throw new ee(n,i.id);return{name:n,name_key:r}}function eu(e,t){try{return t()}catch(t){if(t instanceof Error&&/UNIQUE constraint failed: bots\.name_key/.test(t.message)){let t=er.prepare("SELECT id FROM bots WHERE name_key = ?").get(Q(e));throw new ee(e,t?.id??null)}throw t}}function ec(){return ei[er.prepare("SELECT COUNT(*) AS n FROM bots").get().n%ei.length]}ed.forEach((e,t)=>{e_.run(ei[(t+2)%ei.length],e.id)});let eT=er.prepare("PRAGMA table_info(messages)").all();eT.some(e=>"handoff_targets"===e.name)||er.exec("ALTER TABLE messages ADD COLUMN handoff_targets TEXT"),er.prepare("PRAGMA table_info(groups)").all().some(e=>"owner_bot_id"===e.name)||er.exec("ALTER TABLE groups ADD COLUMN owner_bot_id TEXT"),er.prepare("PRAGMA table_info(launch_snapshots)").all().some(e=>"transport"===e.name)||er.exec("ALTER TABLE launch_snapshots ADD COLUMN transport TEXT NOT NULL DEFAULT 'hermes-gateway'");let el=er.prepare("PRAGMA table_info(conversations)").all();el.some(e=>"origin_kind"===e.name)||er.exec("ALTER TABLE conversations ADD COLUMN origin_kind TEXT"),el.some(e=>"origin_id"===e.name)||er.exec("ALTER TABLE conversations ADD COLUMN origin_id TEXT"),eT.some(e=>"sender_kind"===e.name)||er.exec("ALTER TABLE messages ADD COLUMN sender_kind TEXT"),eT.some(e=>"request_id"===e.name)||er.exec("ALTER TABLE messages ADD COLUMN request_id TEXT"),er.exec(`
1333
+ CREATE TABLE IF NOT EXISTS conversation_participants (
1334
+ conversation_id TEXT NOT NULL,
1335
+ participant_kind TEXT NOT NULL,
1336
+ participant_id TEXT NOT NULL,
1337
+ joined_at INTEGER NOT NULL,
1338
+ PRIMARY KEY (conversation_id, participant_kind, participant_id),
1339
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id)
1340
+ );
1341
+ `),C(er);let ep=H(er),eN=function(e){let t=e.prepare("SELECT * FROM work_requests WHERE id = ?"),n=e.prepare("SELECT * FROM work_attempts WHERE id = ?"),r=e.prepare("SELECT * FROM engine_events WHERE request_id = ? ORDER BY sequence ASC"),i=e.prepare("SELECT sequence FROM conversation_projection_cursors WHERE request_id = ?"),a=e.prepare(`
1342
+ INSERT INTO conversation_projection_cursors (request_id, sequence) VALUES (?, ?)
1343
+ ON CONFLICT (request_id) DO UPDATE SET sequence = excluded.sequence WHERE excluded.sequence > sequence
1344
+ `),s=e.prepare(`
1345
+ INSERT OR IGNORE INTO conversation_events (
1346
+ id, conversation_id, engine_event_id, part, request_id, request_sequence, attempt_id, wake_id,
1347
+ kind, state, text, data, sort_at, request_created_at, created_at
1348
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1349
+ `);function o(e){return e?n.get(e):void 0}function d(n){return e.transaction(()=>{let e=t.get(n);if(!e)return 0;let d=i.get(n)?.sequence??0,_=r.all(n),E=_.length>0?_[_.length-1].sequence:0;if(E<=d)return 0;let u={state:null,lastFinished:null},c=0,T=0;for(let t of _){c=Math.max(c,t.created_at);let n={...u};!function(e,t){let n=P(t.data);"accepted"===t.type&&$(n.state)&&(e.state=n.state),"state_changed"===t.type&&$(n.to)&&(e.state=n.to),"attempt_finished"===t.type&&t.attempt_id&&(e.lastFinished={attemptId:t.attempt_id,outcome:$(n.outcome)})}(u,t),t.sequence<=d||null!==e.legacy_agent_request_id||(function(e,t,n){let r=P(e.data),i=P(t.policy_snapshot),a=null!==t.wake_event_id,s=$(i.target_name_snapshot)??t.target_agent_id,d={target_agent_id:t.target_agent_id,execution_kind:t.execution_kind,tool_profile:t.tool_profile};switch(e.type){case"accepted":if("blocked"===r.state)return[];if(a)return[{kind:"wake_accepted",attemptId:null,text:`Wake accepted: ${s} (${t.execution_kind})`,data:{...d,target_name:s,requester_kind:t.requester_kind,requester_id:t.requester_id,parent_request_id:t.parent_request_id,depth:t.depth,wake_depth:t.wake_depth,grant_rule:$(i.grant_rule),grant_id:$(i.grant_id)}}];return[{kind:"request_queued",attemptId:null,text:"Queued",data:{...d,requester_kind:t.requester_kind,requester_id:t.requester_id}}];case"state_changed":{let e=$(r.to),i=$(r.from),_=$(r.reason);switch(e){case"blocked":if(a&&"queued"===i&&"blocked"===n.state){let e=function(e){if(!e)return{code:null,reason:null};let t=/^([a-z_]+): ([\s\S]*)$/.exec(e);return t?{code:t[1],reason:t[2]}:{code:null,reason:e}}(_);return[j(s,e.code,e.reason,d)]}return[{kind:"request_blocked",attemptId:null,text:z("Blocked",_),data:{from:i,reason:_}}];case"queued":if("retry_scheduled"===_){let e="number"==typeof r.attempt_count?r.attempt_count:null,t="number"==typeof r.max_attempts?r.max_attempts:null;return[{kind:"request_retry_scheduled",attemptId:n.lastFinished?.attemptId??null,text:!0===r.manual?`Retry requested${null!==e&&null!==t?` (Attempt ${e+1} of ${t})`:""}`:`Retry scheduled${null!==e&&null!==t?` (Attempt ${e+1} of ${t})`:""}${"number"==typeof r.delay_ms?` in ${r.delay_ms} ms`:""}`,data:{from:i,reason:_,manual:!0===r.manual,attempt_count:e,max_attempts:t,next_eligible_at:r.next_eligible_at??null,delay_ms:r.delay_ms??null,category:r.category??null,outcome:n.lastFinished?.outcome??null}}]}if(a&&"blocked"===i&&("grant_approved"===_||"target_available"===_))return[{kind:"wake_accepted",attemptId:null,text:`Wake accepted: ${s} (${t.execution_kind})`,data:{...d,target_name:s,requester_kind:t.requester_kind,requester_id:t.requester_id,parent_request_id:t.parent_request_id,depth:t.depth,wake_depth:t.wake_depth,reason:_,grant_rule:r.grant_rule??null,grant_id:r.grant_id??null}}];return[{kind:"request_queued",attemptId:null,text:z("Queued again",_),data:{from:i,reason:_}}];case"running":return[{kind:"request_running",attemptId:null,text:"Running",data:{phase:"dispatched",from:i}}];case"waiting":return[{kind:"request_waiting",attemptId:null,text:z("Waiting",_),data:{from:i,reason:_}}];case"completed":{let e=n.lastFinished,r=e?.outcome==="succeeded",i=[{kind:"request_completed",attemptId:e?.attemptId??null,text:r?"Completed":"Completed without a successful Attempt outcome",data:{success:r,outcome:e?.outcome??null}}];if(r&&e){let n=o(e.attemptId),r=P(t.result);i.push({kind:"result",attemptId:e.attemptId,text:n?.output??"Result recorded",data:{reply_message_id:$(r.reply_message_id),has_output:"string"==typeof n?.output}})}return i}case"failed":case"cancelled":{let a=n.lastFinished,s=t.error_code??$(r.error_code),o=t.error_message;if("failed"===e&&"timed_out"===_)return[{kind:"request_timed_out",attemptId:a?.attemptId??null,text:"Timed out: the request passed its deadline",data:{success:!1,error_code:s,reason:_,deadline_at:r.deadline_at??null,from:i,outcome:a?.outcome??null}}];if("failed"===e&&"retries_exhausted"===_)return[{kind:"request_retries_exhausted",attemptId:a?.attemptId??null,text:z(`Retries exhausted after ${r.attempt_count??"?"} of ${r.max_attempts??"?"} Attempts`,o??s),data:{success:!1,error_code:s,error_message:o,reason:_,attempt_count:r.attempt_count??null,max_attempts:r.max_attempts??null,outcome:a?.outcome??null}}];return[{kind:"failed"===e?"request_failed":"request_cancelled",attemptId:a?.attemptId??null,text:"failed"===e?z("Failed",o??s):"cancel_requested"===_?z("Cancelled",t.cancel_reason):"grant_denied"===_?"Cancelled: owner denied edit Wake":z("Cancelled",_??o),data:{success:!1,error_code:s,error_message:o,reason:_,outcome:a?.outcome??null}}]}default:return[]}}case"runtime_started":{let t=$(r.adapter);return[{kind:"request_running",attemptId:e.attempt_id,text:t?`Running on ${t}`:"Running",data:{phase:"runtime_started",adapter:t,external_run_id:$(r.external_run_id),success:!1}}]}case"wake_reblocked":return[j(s,$(r.reason_code),$(r.reason),d)];case"dispatch_deferred":return[{kind:"request_queued",attemptId:null,text:"Queued: waiting for capacity",data:{waiting_for:"capacity",limit:$(r.reason),active_global:r.active_global??null,active_target:r.active_target??null,max_global:r.max_global??null,max_per_target:r.max_per_target??null}}];case"lineage_stopped":return[{kind:"lineage_stopped",attemptId:null,text:"continuation_budget_exhausted"===r.reason?`Stopped: coordinator continuation limit ${r.limit??"?"} reached`:z("Stopped",$(r.reason)),data:r}];case"cancel_requested":{let e=$(r.reason);return[{kind:"request_cancel_requested",attemptId:null,text:z("Cancel requested",e),data:{by:$(r.by),reason:e,state:$(r.state)}}]}case"question":{let t=$(r.question)??"";return[{kind:"question",attemptId:e.attempt_id,text:t,data:{question:t}}]}case"attempt_finished":{let t=o(e.attempt_id);if(!t)return[];let n=[];try{let e=JSON.parse(t.artifacts);Array.isArray(e)&&(n=e)}catch{}return n.filter(e=>!(e&&"object"==typeof e&&"candidate_manifest"===e.kind)).map(e=>{let n=e&&"object"==typeof e?e:{ref:String(e)},r=$(n.kind)??"artifact",i=$(n.ref)??"";return{kind:"artifact",attemptId:t.id,text:`Artifact (${r}): ${i}`,data:{artifact_kind:r,ref:i,outcome:t.outcome}}})}case"candidate_manifest_recorded":{let t=$(r.manifest_digest),n="number"==typeof r.file_count?r.file_count:0;return[{kind:"artifact",attemptId:e.attempt_id,text:`Candidate manifest ${t}: ${n} ${1===n?"file":"files"} on base ${$(r.base_commit)}`,data:{artifact_kind:"candidate_manifest",ref:t,...r}}]}case"candidate_manifest_unavailable":return[{kind:"finalization_blocked",attemptId:e.attempt_id,text:z("Not finalizable",$(r.reason_code)),data:{phase:"candidate",...r}}];case"finalization_preparing":return[{kind:"finalization_preparing",attemptId:e.attempt_id,text:`Finalization preparing: manifest ${$(r.manifest_digest)} (${r.file_count??0} files), review ${$(r.review_request_id)}`,data:r}];case"finalization_retry_pending":return[{kind:"finalization_preparing",attemptId:e.attempt_id,text:z("Finalization waiting to retry",$(r.reason_code)),data:{retry:!0,...r}}];case"finalization_committed":return[{kind:"finalization_committed",attemptId:e.attempt_id,text:`Finalization committed: commit ${$(r.commit)} (tree ${$(r.tree)}, manifest ${$(r.result_manifest_digest)??$(r.manifest_digest)})`,data:{success:!0,...r}}];case"finalization_blocked":case"finalization_failed":case"finalization_canceled":{let t="finalization_blocked"===e.type?"blocked":"finalization_failed"===e.type?"failed":"canceled";return[{kind:e.type,attemptId:e.attempt_id,text:z(`Finalization ${t}`,$(r.reason_code)),data:{success:!1,...r}}]}case"finalization_rejected":return[{kind:"finalization_rejected",attemptId:null,text:z("Finalization not started",$(r.reason_code)),data:r}];default:return[]}})(t,e,n).forEach((n,r)=>{T+=s.run(`${t.id}:${r}`,e.source_conversation_id,t.id,r,e.id,t.sequence,n.attemptId,e.wake_event_id,n.kind,u.state,n.text,JSON.stringify(n.data),c,e.created_at,t.created_at).changes})}return a.run(n,E),T}).immediate()}function _(t){return e.transaction(()=>e.prepare("SELECT id FROM work_requests WHERE source_conversation_id = ? ORDER BY created_at ASC, id ASC").all(t).reduce((e,t)=>e+d(t.id),0)+function(t){let n=e.prepare(`
1350
+ SELECT w.* FROM wakes w
1351
+ WHERE w.source_conversation_id = ? AND w.status = 'rejected'
1352
+ AND NOT EXISTS (SELECT 1 FROM conversation_events e WHERE e.id = 'wake:' || w.id || ':0')
1353
+ ORDER BY w.created_at ASC, w.position ASC
1354
+ `).all(t),r=0;for(let e of n){let t={wake_id:e.id,target_name:e.target_name_snapshot??e.requested_target,target_agent_id:e.target_agent_id,execution_kind:e.execution_kind,requester_agent_id:e.requester_agent_id,parent_request_id:e.parent_request_id,reason_code:e.reason_code,reason:e.reason,limit:e.limit_value,observed:e.observed_value,work_request_id:null};r+=s.run(`wake:${e.id}:0`,e.source_conversation_id,null,0,null,0,null,e.id,"wake_rejected",null,function(e){let t=e.target_name_snapshot??e.requested_target??"an unnamed target";switch(e.reason_code){case"untracked_lineage":return"Wake not started: its source turn is not tracked work";case"depth_exceeded":return`Wake not started: ${t} — depth limit ${e.limit_value??"?"} reached`;case"root_budget_exhausted":return`Wake not started: ${t} — this work already used ${e.observed_value??e.limit_value??"?"} Wakes`;default:return e.reason?`Wake not started: ${t} — ${e.reason}`:`Wake not started: ${t}`}}(e),JSON.stringify(t),e.updated_at,e.created_at,e.updated_at).changes}return r}(t)).immediate()}function E(t){return e.prepare(`
1355
+ SELECT * FROM conversation_events WHERE conversation_id = ?
1356
+ ORDER BY sort_at ASC, request_created_at ASC, COALESCE(request_id, wake_id) ASC, request_sequence ASC, part ASC
1357
+ `).all(t)}return{projectRequest:d,projectConversation:_,projectEvent:function(e){return d(e.request_id)},listConversationEventRows:E,listConversationEvents:function(e){return _(e),E(e).map((e,t)=>({eventId:e.id,seq:t+1,kind:e.kind,requestId:e.request_id,requestSequence:e.request_sequence,attemptId:e.attempt_id,wakeId:e.wake_id,engineEventId:e.engine_event_id,state:e.state,text:e.text,data:P(e.data),createdAt:e.created_at}))}}}(er),eR={kind:"person",id:"local-owner"},em=er.prepare("INSERT OR IGNORE INTO conversation_participants (conversation_id, participant_kind, participant_id, joined_at) VALUES (?, ?, ?, ?)");function eL(e,t,n){for(let r of(er.prepare("UPDATE conversations SET origin_kind = ?, origin_id = ? WHERE id = ? AND origin_kind IS NULL").run(eR.kind,eR.id,e),em.run(e,eR.kind,eR.id,n),t))em.run(e,"bot",r,n)}er.transaction(()=>{er.exec("UPDATE messages SET sender_kind = 'person' WHERE sender_kind IS NULL AND sender_type = 'user'"),er.exec("UPDATE messages SET sender_kind = 'bot' WHERE sender_kind IS NULL AND sender_type = 'bot'");let e=er.prepare("SELECT id, type, bot_id, group_id, created_at FROM conversations WHERE origin_kind IS NULL AND type IN ('bot', 'group')").all(),t=er.prepare("SELECT bot_id FROM group_members WHERE group_id = ?");for(let n of e){let e="bot"===n.type?n.bot_id?[n.bot_id]:[]:n.group_id?t.all(n.group_id).map(e=>e.bot_id):[];eL(n.id,e,n.created_at)}})();let eO={create:(e,t)=>{let n=eE(e.name),r={id:t?.id||(0,i.randomUUID)(),...e,...n,color:ec(),created_at:t?.created_at??Date.now()};r.agent=r.agent||a.DEFAULT_AGENT,r.deck_id=r.deck_id||null,r.needs_deck_selection=!r.deck_id||r.needs_deck_selection?1:0,eu(r.name,()=>er.prepare("INSERT INTO bots (id, name, name_key, title, description, avatar, color, hermes_profile, agent, deck_id, deck_name, working_directory, needs_deck_selection, avatar_color, avatar_eyes, avatar_hands, avatar_accessory, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").run(r.id,r.name,r.name_key,r.title,r.description,r.avatar||null,r.color,r.hermes_profile||null,r.agent,r.deck_id,r.deck_name||null,r.working_directory||null,r.needs_deck_selection,r.avatar_color||null,r.avatar_eyes||null,r.avatar_hands||null,r.avatar_accessory||null,r.created_at));let s=(0,i.randomUUID)();return er.prepare("INSERT INTO conversations (id, type, bot_id, created_at) VALUES (?, ?, ?, ?)").run(s,"bot",r.id,r.created_at),eL(s,[r.id],r.created_at),r},createFromImport:(e,t)=>{let n=eE(e.name),r={id:(0,i.randomUUID)(),...e,...n,color:ec(),created_at:Date.now(),agent:a.DEFAULT_AGENT,deck_id:null,deck_name:null,working_directory:null,needs_deck_selection:1,source_provider:t.source_provider,template_id:t.template_id,template_url:t.template_url,import_schema_version:t.import_schema_version,import_operation_id:t.import_operation_id,import_timestamp:t.import_timestamp};eu(r.name,()=>er.prepare(`INSERT INTO bots (
1358
+ id, name, name_key, title, description, avatar, color, created_at,
1359
+ source_provider, template_id, template_url, import_schema_version,
1360
+ import_operation_id, import_timestamp,
1361
+ agent, deck_id, deck_name, working_directory,
1362
+ needs_deck_selection
1363
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(r.id,r.name,r.name_key,r.title,r.description,r.avatar||null,r.color,r.created_at,r.source_provider,r.template_id,r.template_url,r.import_schema_version,r.import_operation_id,r.import_timestamp,r.agent,r.deck_id,r.deck_name,r.working_directory,r.needs_deck_selection));let s=(0,i.randomUUID)();return er.prepare("INSERT INTO conversations (id, type, bot_id, created_at) VALUES (?, ?, ?, ?)").run(s,"bot",r.id,r.created_at),eL(s,[r.id],r.created_at),r},getByImportOperationId:e=>er.prepare("SELECT * FROM bots WHERE import_operation_id = ?").get(e),getAll:()=>er.prepare("SELECT * FROM bots ORDER BY created_at DESC").all(),getById:e=>er.prepare("SELECT * FROM bots WHERE id = ?").get(e),setAvatar:(e,t)=>{er.prepare("UPDATE bots SET avatar = ? WHERE id = ?").run(t,e)},getByName:e=>{let t=Q(e);if(t)return er.prepare("SELECT * FROM bots WHERE name_key = ?").get(t)},updateIdentity:(e,t,n,r)=>{let i=eE(t,e);eu(i.name,()=>er.prepare("UPDATE bots SET name = ?, name_key = ?, title = ?, description = ? WHERE id = ?").run(i.name,i.name_key,n,r,e))},setPinned:(e,t)=>{er.prepare("UPDATE bots SET pinned = ? WHERE id = ?").run(+!!t,e)},setHidden:(e,t)=>{er.prepare("UPDATE bots SET hidden = ? WHERE id = ?").run(+!!t,e)},setHermesProfile:(e,t)=>{let n=t&&t.trim()?t.trim():null;er.prepare("UPDATE bots SET hermes_profile = ? WHERE id = ?").run(n,e)},updateAgentSelection:(e,t)=>{let n=eO.getById(e);if(!n)return;let r=(0,a.applyAgentUpdate)(n,t);er.prepare("UPDATE bots SET agent = ?, deck_id = ?, deck_name = ?, working_directory = ?, needs_deck_selection = ? WHERE id = ?").run(r.agent,r.deck_id,r.deck_name,r.working_directory,+!!r.needs_deck_selection,e)},updateAvatarConfig:(e,t)=>{let n=eO.getById(e);if(!n)return;let r=(e,t)=>void 0===e?t||null:e&&String(e).trim()?String(e).trim():null;er.prepare("UPDATE bots SET avatar_color = ?, avatar_eyes = ?, avatar_hands = ?, avatar_accessory = ? WHERE id = ?").run(r(t.avatar_color,n.avatar_color),r(t.avatar_eyes,n.avatar_eyes),r(t.avatar_hands,n.avatar_hands),r(t.avatar_accessory,n.avatar_accessory),e)},touchSeen:()=>{er.prepare("UPDATE bots SET last_seen = ?").run(Date.now())},markUnread:e=>{er.prepare("UPDATE bots SET unread = 1 WHERE id = ?").run(e)},markRead:e=>{er.prepare("UPDATE bots SET unread = 0 WHERE id = ?").run(e)},remove:e=>{eO.removeMany([e])},deletionPreview:e=>{var t;let n=new Set(e),r=[],i=[],a=[],o=new Set(eI());for(let t of e){let e=eO.getById(t);if(!e){i.push(t);continue}r.push({id:e.id,name:e.name}),(0,s.isChiefOfStaffName)(e.name)?a.push({id:e.id,name:e.name,reason:"chief"}):o.has(e.id)&&a.push({id:e.id,name:e.name,reason:"active"})}return{agents:r,groups:0===(t=n).size?[]:er.prepare(`SELECT DISTINCT g.id, g.name, g.owner_bot_id, g.created_at FROM groups g
1364
+ JOIN group_members gm ON gm.group_id = g.id
1365
+ WHERE gm.bot_id IN (${[...t].map(()=>"?").join(", ")})
1366
+ ORDER BY g.created_at ASC, g.id ASC`).all(...t).map(e=>{let n=er.prepare(`SELECT b.id, b.name FROM bots b JOIN group_members gm ON gm.bot_id = b.id
1367
+ WHERE gm.group_id = ? ORDER BY b.created_at ASC, b.id ASC`).all(e.id).filter(e=>!t.has(e.id));return n.length<2?{id:e.id,name:e.name,outcome:"removed",remaining:n.length,newOwner:null}:e.owner_bot_id&&t.has(e.owner_bot_id)?{id:e.id,name:e.name,outcome:"reassigned",remaining:n.length,newOwner:n[0]}:{id:e.id,name:e.name,outcome:"shrunk",remaining:n.length,newOwner:null}}),missing:i,blocked:a}},removeMany:(e,t)=>er.transaction(()=>{let n=eO.deletionPreview(e);if(n.missing.length>0||n.blocked.length>0)throw new eg(n);let r=new Set(e);for(let e of n.groups){if("removed"===e.outcome){var i=e.id;for(let e of er.prepare("SELECT id FROM conversations WHERE group_id = ?").all(i))ek(e.id);er.prepare("DELETE FROM group_members WHERE group_id = ?").run(i),er.prepare("DELETE FROM groups WHERE id = ?").run(i);continue}let t=er.prepare("SELECT id FROM conversations WHERE group_id = ?").all(e.id).map(e=>e.id);for(let n of r)for(let r of(er.prepare("DELETE FROM group_members WHERE group_id = ? AND bot_id = ?").run(e.id,n),t))er.prepare("DELETE FROM conversation_participants WHERE conversation_id = ? AND participant_kind = 'bot' AND participant_id = ?").run(r,n);e.newOwner&&er.prepare("UPDATE groups SET owner_bot_id = ? WHERE id = ?").run(e.newOwner.id,e.id)}for(let n of e){for(let e of er.prepare("SELECT id FROM conversations WHERE bot_id = ?").all(n))ek(e.id);Y(er,n),eS("bot_id",n),er.prepare("DELETE FROM launch_snapshots WHERE bot_id = ?").run(n),er.prepare("DELETE FROM group_members WHERE bot_id = ?").run(n),er.prepare("DELETE FROM conversation_participants WHERE participant_kind = 'bot' AND participant_id = ? AND conversation_id IN (SELECT id FROM conversations WHERE type = 'group')").run(n),er.prepare("DELETE FROM memories WHERE bot_id = ?").run(n),er.prepare("DELETE FROM one_shots WHERE bot_id = ?").run(n),er.prepare("DELETE FROM routines WHERE bot_id = ?").run(n),er.prepare("DELETE FROM pending_questions WHERE bot_id = ?").run(n),er.prepare("DELETE FROM approval_requests WHERE bot_id = ?").run(n),er.prepare("DELETE FROM wake_targets WHERE target_bot_id = ?").run(n),er.prepare("DELETE FROM bots WHERE id = ?").run(n),t?.onAgentDeleted?.(n)}return n})(),managementRows:()=>{let e=er.prepare("SELECT * FROM bots ORDER BY created_at DESC, id ASC").all(),t=new Set(eI()),n=new Map,r=e=>{for(let t of e)t.id&&t.at&&(n.get(t.id)??0)<t.at&&n.set(t.id,t.at)};return r(er.prepare("SELECT c.bot_id AS id, MAX(m.created_at) AS at FROM messages m JOIN conversations c ON c.id = m.conversation_id WHERE c.type = 'bot' GROUP BY c.bot_id").all()),r(er.prepare("SELECT sender_id AS id, MAX(created_at) AS at FROM messages WHERE sender_type = 'bot' AND sender_id IS NOT NULL GROUP BY sender_id").all()),e.map(e=>({bot:e,last_activity:n.get(e.id)??null,blocked:(0,s.isChiefOfStaffName)(e.name)?"chief":t.has(e.id)?"active":null}))}};class eg extends Error{preview;constructor(e){super(e.missing.length>0?"Agent not found":"Some agents cannot be deleted"),this.preview=e}}function eI(){return er.prepare(`
1368
+ SELECT DISTINCT target_agent_id AS bot_id FROM work_requests
1369
+ WHERE (executor <> 'dispatcher' AND state IN ('queued', 'running'))
1370
+ OR (executor = 'dispatcher' AND state = 'running' AND json_extract(policy_snapshot, '$.surface') = 'ui')
1371
+ `).all().map(e=>e.bot_id)}function eA(){return new Set(er.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('legacy_agent_requests_archive', 'legacy_agent_request_events_archive', 'legacy_processing_queue_archive')").all().map(e=>e.name))}function eS(e,t){eA().has("legacy_processing_queue_archive")&&er.prepare(`DELETE FROM legacy_processing_queue_archive WHERE ${e} = ?`).run(t)}function ek(e){let t;K(er,e),er.prepare("DELETE FROM draft_actions WHERE message_id IN (SELECT id FROM messages WHERE conversation_id = ?)").run(e),t=eA(),eS("conversation_id",e),t.has("legacy_agent_request_events_archive")&&t.has("legacy_agent_requests_archive")&&er.prepare("DELETE FROM legacy_agent_request_events_archive WHERE request_id IN (SELECT id FROM legacy_agent_requests_archive WHERE conversation_id = ?)").run(e),t.has("legacy_agent_requests_archive")&&er.prepare("DELETE FROM legacy_agent_requests_archive WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM messages WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM pending_questions WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM approvals WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM approval_requests WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM one_shots WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM routines WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM wake_targets WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM conversation_participants WHERE conversation_id = ?").run(e),er.prepare("DELETE FROM conversations WHERE id = ?").run(e)}let ev={getByBotId:e=>er.prepare("SELECT * FROM conversations WHERE bot_id = ?").get(e),getByGroupId:e=>er.prepare("SELECT * FROM conversations WHERE group_id = ?").get(e),getById:e=>er.prepare("SELECT * FROM conversations WHERE id = ?").get(e),getUiById:e=>er.prepare("SELECT * FROM conversations WHERE id = ? AND type != 'agent'").get(e)},ef={create:(e,t,n,r,a)=>{let s={id:(0,i.randomUUID)(),conversation_id:e,sender_type:t,sender_id:r,sender_kind:"bot"===t?"bot":eR.kind,content:n,handoff_targets:a&&a.length>0?JSON.stringify(a):null,created_at:Date.now()};if(er.prepare("INSERT INTO messages (id, conversation_id, sender_type, sender_id, sender_kind, content, handoff_targets, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(s.id,s.conversation_id,s.sender_type,s.sender_id||null,s.sender_kind,s.content,s.handoff_targets||null,s.created_at),"bot"===t){r&&eO.markUnread(r);let t=er.prepare("SELECT bot_id FROM conversations WHERE id = ? AND type = ?").get(e,"bot");t?.bot_id&&t.bot_id!==r&&eO.markUnread(t.bot_id)}return s},getById:e=>er.prepare("SELECT * FROM messages WHERE id = ?").get(e),replaceContent:(e,t)=>{er.prepare("UPDATE messages SET content = ? WHERE id = ?").run(t,e)},getByConversation:e=>er.prepare("SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at ASC").all(e),getBetween:(e,t)=>{let n=ef.getById(e),r=ef.getById(t);if(!n||!r||n.conversation_id!==r.conversation_id)return null;let i=er.prepare("SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at ASC, rowid ASC").all(n.conversation_id),a=i.findIndex(t=>t.id===e),s=i.findIndex(e=>e.id===t);if(a<0||s<0)return null;let[o,d]=a<s?[a,s]:[s,a];return i.slice(o+1,d)},latestFromBot:e=>{let t=ev.getByBotId(e);for(let n of er.prepare(`SELECT content, conversation_id, created_at FROM messages
1372
+ WHERE sender_type = 'bot' AND sender_id = ?
1373
+ ORDER BY created_at DESC, rowid DESC
1374
+ LIMIT 20`).all(e)){if(t&&n.conversation_id!==t.id)continue;let e=er.prepare(`SELECT content FROM messages
1375
+ WHERE conversation_id = ? AND created_at < ?
1376
+ ORDER BY created_at DESC, rowid DESC
1377
+ LIMIT 1`).get(n.conversation_id,n.created_at);if(!(e&&e.content.startsWith("[From ")))return n.content}return""},priorSentenceForHandoff:e=>{if(!e.handoff_targets)return null;let t=[];try{let n=JSON.parse(e.handoff_targets);if(!Array.isArray(n))return null;t=n.map(e=>String(e))}catch{return null}let n=er.prepare(`
1378
+ SELECT m.conversation_id AS conversation_id, c.type AS type, c.bot_id AS bot_id
1379
+ FROM messages m
1380
+ JOIN conversations c ON c.id = m.conversation_id
1381
+ WHERE m.content = ? AND m.handoff_targets = ?
1382
+ ORDER BY m.created_at ASC
1383
+ `).all(e.content,e.handoff_targets).find(e=>"group"===e.type||!e.bot_id||!t.includes(e.bot_id)),r=n?.conversation_id||e.conversation_id,i=ef.getByConversation(r),a=[...i].reverse().find(t=>"user"===t.sender_type&&t.content===e.content&&t.handoff_targets===e.handoff_targets),s=a?a.created_at:e.created_at;for(let e=i.length-1;e>=0;e--){let t=i[e];if(a&&t.id===a.id||t.created_at>s||"bot"!==t.sender_type)continue;let n=(t.content||"").trim();if(n)return n}return null}},eq={get:(e,t)=>er.prepare("SELECT * FROM approvals WHERE conversation_id = ? AND code = ?").get(e,t),recordPending:(e,t,n)=>(er.prepare("INSERT OR IGNORE INTO approvals (conversation_id, code, message_id, status, created_at) VALUES (?, ?, ?, ?, ?)").run(e,t,n||null,"pending",Date.now()),eq.get(e,t)),resolve:(e,t,n)=>Number(er.prepare("UPDATE approvals SET status = ?, resolved_at = ? WHERE conversation_id = ? AND code = ? AND status = 'pending'").run(n,Date.now(),e,t).changes)>0},ew=20;function eh(e){let t=Q(e);if(!t)return{ok:!1,reason:"not_found",requested:String(e??"")};let n=er.prepare("SELECT id, name FROM bots WHERE name_key = ? LIMIT 2").all(t);return 0===n.length?{ok:!1,reason:"not_found",requested:e}:n.length>1?{ok:!1,reason:"ambiguous",requested:e}:{ok:!0,agentId:n[0].id,displayName:n[0].name}}er.exec(`
1384
+ CREATE TABLE IF NOT EXISTS wake_targets (
1385
+ id TEXT PRIMARY KEY,
1386
+ conversation_id TEXT NOT NULL,
1387
+ source_bot_id TEXT,
1388
+ source_message_id TEXT,
1389
+ requested_target TEXT NOT NULL,
1390
+ target_bot_id TEXT NOT NULL,
1391
+ target_name_snapshot TEXT NOT NULL,
1392
+ created_at INTEGER NOT NULL,
1393
+ FOREIGN KEY (conversation_id) REFERENCES conversations(id),
1394
+ FOREIGN KEY (target_bot_id) REFERENCES bots(id)
1395
+ );
1396
+
1397
+ CREATE INDEX IF NOT EXISTS idx_wake_targets_conversation
1398
+ ON wake_targets(conversation_id, created_at);
1399
+ CREATE INDEX IF NOT EXISTS idx_wake_targets_target
1400
+ ON wake_targets(target_bot_id, created_at);
1401
+ `),er.exec(`
1402
+ CREATE TABLE IF NOT EXISTS workspace_settings (
1403
+ key TEXT PRIMARY KEY,
1404
+ value TEXT NOT NULL,
1405
+ updated_at INTEGER NOT NULL
1406
+ );
1407
+ `),e.s(["BotDeletionError",0,eg,"UI_OWNER_PRINCIPAL",0,eR,"agentNameMigrations",0,{list:()=>er.prepare("SELECT * FROM agent_name_migrations ORDER BY created_at ASC, rowid ASC").all()},"approvals",0,eq,"bots",0,eO,"conversations",0,ev,"default",0,er,"draftActions",0,{get:e=>er.prepare("SELECT * FROM draft_actions WHERE message_id = ?").get(e),record:(e,t,n)=>Number(er.prepare("INSERT OR IGNORE INTO draft_actions (message_id, status, recipient, acted_at) VALUES (?, ?, ?, ?)").run(e,t,n||null,Date.now()).changes)>0},"engine",0,ep,"groups",0,{create:(e,t,n,r)=>{let a=n&&t.includes(n)?n:t[0],s={id:(0,i.randomUUID)(),name:e,owner_bot_id:a,created_at:r?.created_at??Date.now()},o=er.prepare("INSERT INTO groups (id, name, owner_bot_id, created_at) VALUES (?, ?, ?, ?)"),d=er.prepare("INSERT INTO group_members (group_id, bot_id) VALUES (?, ?)"),_=er.prepare("INSERT INTO conversations (id, type, group_id, created_at) VALUES (?, ?, ?, ?)");return er.transaction(()=>{for(let e of(o.run(s.id,s.name,s.owner_bot_id||null,s.created_at),t))d.run(s.id,e);let e=(0,i.randomUUID)();_.run(e,"group",s.id,s.created_at),eL(e,t,s.created_at)})(),s},getAll:()=>er.prepare("SELECT * FROM groups ORDER BY created_at DESC").all(),getById:e=>er.prepare("SELECT * FROM groups WHERE id = ?").get(e),rename:(e,t)=>{er.prepare("UPDATE groups SET name = ? WHERE id = ?").run(t,e)},getMembers:e=>er.prepare(`
1408
+ SELECT b.* FROM bots b
1409
+ JOIN group_members gm ON b.id = gm.bot_id
1410
+ WHERE gm.group_id = ?
1411
+ `).all(e)},"launchSnapshots",0,{record:(e,t,n,r,i="hermes-gateway")=>{er.prepare("INSERT OR IGNORE INTO launch_snapshots (id, bot_id, created_at, hash, snapshot, transport) VALUES (?, ?, ?, ?, ?, ?)").run(e,t,Date.now(),n,r,i)},listByBot:e=>er.prepare("SELECT * FROM launch_snapshots WHERE bot_id = ? ORDER BY created_at DESC, rowid DESC").all(e)},"mcpServers",0,{create:(e,t,n)=>{let r={id:(0,i.randomUUID)(),name:e,command:t,args:JSON.stringify(n),created_at:Date.now()};return er.prepare("INSERT INTO mcp_servers (id, name, command, args, created_at) VALUES (?, ?, ?, ?, ?)").run(r.id,r.name,r.command,r.args,r.created_at),r},list:()=>er.prepare("SELECT * FROM mcp_servers ORDER BY created_at ASC").all()},"memories",0,{rememberStatement:(e,t)=>{var n;let r;if(!e||!(r=t.trim())||/[??]\s*$/.test(r)||/^\[mcp\]/i.test(r)||/^\[tool (?:call|result)\]/i.test(r)||/^\[Handing off to\b/i.test(r)||/^\[From [^\]]+\]/i.test(r)||/^Peer handoff:/i.test(r)||/reply with exactly\b/i.test(r)||(n=r,/^(who|what|when|where|why|how|which|whose|whom)\b/i.test(n)?!/^(what|how|why|where|when|who)\s+i\b/i.test(n):!!(/^(do|does|did|can|could|would|will|should|shall|is|are|am|was|were|have|has)\s+(you|i|we|they|he|she|it|there|the|a|an|my|your|our)\b/i.test(n)||/^(tell me|please tell)\b/i.test(n))))return;let a=t.trim();er.prepare("INSERT INTO memories (id, bot_id, fact, created_at) VALUES (?, ?, ?, ?)").run((0,i.randomUUID)(),e,a,Date.now()),er.prepare(`
1412
+ DELETE FROM memories
1413
+ WHERE bot_id = ?
1414
+ AND id NOT IN (
1415
+ SELECT id FROM (
1416
+ SELECT id FROM memories
1417
+ WHERE bot_id = ?
1418
+ ORDER BY created_at DESC, rowid DESC
1419
+ LIMIT ?
1420
+ )
1421
+ )
1422
+ `).run(e,e,ew)},latestFacts:(e,t=ew)=>{let n=t>0?Math.min(t,ew):ew;return er.prepare("SELECT fact FROM memories WHERE bot_id = ? ORDER BY created_at DESC, rowid DESC LIMIT ?").all(e,n).map(e=>e.fact).reverse()}},"messages",0,ef,"oneShots",0,{create:(e,t,n)=>{let r={id:(0,i.randomUUID)(),conversation_id:e,bot_id:t,due_at:n,fired:0,created_at:Date.now()};return er.prepare("INSERT INTO one_shots (id, conversation_id, bot_id, due_at, fired, created_at) VALUES (?, ?, ?, ?, 0, ?)").run(r.id,r.conversation_id,r.bot_id,r.due_at,r.created_at),r},pending:e=>er.prepare("SELECT * FROM one_shots WHERE conversation_id = ? AND fired = 0 ORDER BY due_at ASC LIMIT 1").get(e),unfired:()=>er.prepare("SELECT * FROM one_shots WHERE fired = 0 ORDER BY due_at ASC").all(),claim:e=>1===er.prepare("UPDATE one_shots SET fired = 1 WHERE id = ? AND fired = 0").run(e).changes},"projector",0,eN,"resolveWakeTarget",0,eh,"routines",0,{create:(e,t,n,r,a)=>{let s={id:(0,i.randomUUID)(),conversation_id:e,bot_id:t,word:n,next_due_at:r,every_ms:a,created_at:Date.now()};return er.prepare("INSERT INTO routines (id, conversation_id, bot_id, word, next_due_at, every_ms, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)").run(s.id,s.conversation_id,s.bot_id,s.word,s.next_due_at,s.every_ms,s.created_at),s},forConversation:e=>er.prepare("SELECT * FROM routines WHERE conversation_id = ? ORDER BY created_at ASC LIMIT 1").get(e),all:()=>er.prepare("SELECT * FROM routines ORDER BY next_due_at ASC").all(),postIfDue:(e,t)=>er.transaction(()=>{let n=er.prepare("SELECT * FROM routines WHERE id = ?").get(e);return!!n&&!(n.next_due_at>t)&&1===er.prepare("UPDATE routines SET next_due_at = next_due_at + every_ms WHERE id = ? AND next_due_at = ?").run(e,n.next_due_at).changes&&(ef.create(n.conversation_id,"bot","[routine]\n"+n.word,n.bot_id),!0)})()},"wakeTargets",0,{accept:e=>{let t=eh(e.requestedTarget);if(!t.ok)return t;let n={id:(0,i.randomUUID)(),conversation_id:e.conversationId,source_bot_id:e.sourceBotId??null,source_message_id:e.sourceMessageId??null,requested_target:e.requestedTarget,target_bot_id:t.agentId,target_name_snapshot:t.displayName,created_at:Date.now()};return er.prepare("INSERT INTO wake_targets (id, conversation_id, source_bot_id, source_message_id, requested_target, target_bot_id, target_name_snapshot, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(n.id,n.conversation_id,n.source_bot_id,n.source_message_id,n.requested_target,n.target_bot_id,n.target_name_snapshot,n.created_at),{ok:!0,wake:n}},listByConversation:e=>er.prepare("SELECT * FROM wake_targets WHERE conversation_id = ? ORDER BY created_at ASC, rowid ASC").all(e)},"workspaceSettings",0,{get:e=>{let t=er.prepare("SELECT value FROM workspace_settings WHERE key = ?").get(e);return t?t.value:null},set:(e,t)=>{er.prepare("INSERT INTO workspace_settings (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at").run(e,t,Date.now())},clearForTests:()=>{er.prepare("DELETE FROM workspace_settings").run()}}],62294)}];
1423
+
1424
+ //# sourceMappingURL=%5Broot-of-the-server%5D__0izjfmr._.js.map