nolune 0.4.2 → 0.6.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 (937) hide show
  1. package/DESIGN.md +850 -40
  2. package/README.md +21 -11
  3. package/dist/chunks/chunk-2Z3QOLXA.js +19934 -0
  4. package/dist/chunks/chunk-YK5257ON.js +116 -0
  5. package/dist/chunks/run-UUFOUO2T.js +44529 -0
  6. package/dist/chunks/zod-EQ7NYDR4.js +524 -0
  7. package/dist/cli.js +2 -2
  8. package/package.json +1 -1
  9. package/packages/core/drizzle/0022_push_devices.sql +12 -0
  10. package/packages/core/drizzle/0023_background_command_pid.sql +2 -0
  11. package/packages/core/drizzle/meta/0022_snapshot.json +2509 -0
  12. package/packages/core/drizzle/meta/0023_snapshot.json +2523 -0
  13. package/packages/core/drizzle/meta/_journal.json +14 -0
  14. package/packages/core/skills/generate-images/SKILL.md +7 -2
  15. package/packages/core/skills/nolune/SKILL.md +41 -8
  16. package/packages/core/skills/subagents/SKILL.md +3 -1
  17. package/packages/web/build/client/_app/immutable/assets/0.DTPxyIYr.css +2 -0
  18. package/packages/web/build/client/_app/immutable/assets/0.DTPxyIYr.css.br +0 -0
  19. package/packages/web/build/client/_app/immutable/assets/0.DTPxyIYr.css.gz +0 -0
  20. package/packages/web/build/client/_app/immutable/assets/13.BMz9yqHy.css +1 -0
  21. package/packages/web/build/client/_app/immutable/assets/13.BMz9yqHy.css.br +0 -0
  22. package/packages/web/build/client/_app/immutable/assets/13.BMz9yqHy.css.gz +0 -0
  23. package/packages/web/build/client/_app/immutable/assets/KaTeX_AMS-Regular.BQhdFMY1.woff2 +0 -0
  24. package/packages/web/build/client/_app/immutable/assets/KaTeX_AMS-Regular.DMm9YOAa.woff +0 -0
  25. package/packages/web/build/client/_app/immutable/assets/KaTeX_AMS-Regular.DRggAlZN.ttf +0 -0
  26. package/packages/web/build/client/_app/immutable/assets/KaTeX_Caligraphic-Bold.ATXxdsX0.ttf +0 -0
  27. package/packages/web/build/client/_app/immutable/assets/KaTeX_Caligraphic-Bold.BEiXGLvX.woff +0 -0
  28. package/packages/web/build/client/_app/immutable/assets/KaTeX_Caligraphic-Bold.Dq_IR9rO.woff2 +0 -0
  29. package/packages/web/build/client/_app/immutable/assets/KaTeX_Caligraphic-Regular.CTRA-rTL.woff +0 -0
  30. package/packages/web/build/client/_app/immutable/assets/KaTeX_Caligraphic-Regular.Di6jR-x-.woff2 +0 -0
  31. package/packages/web/build/client/_app/immutable/assets/KaTeX_Caligraphic-Regular.wX97UBjC.ttf +0 -0
  32. package/packages/web/build/client/_app/immutable/assets/KaTeX_Fraktur-Bold.BdnERNNW.ttf +0 -0
  33. package/packages/web/build/client/_app/immutable/assets/KaTeX_Fraktur-Bold.BsDP51OF.woff +0 -0
  34. package/packages/web/build/client/_app/immutable/assets/KaTeX_Fraktur-Bold.CL6g_b3V.woff2 +0 -0
  35. package/packages/web/build/client/_app/immutable/assets/KaTeX_Fraktur-Regular.CB_wures.ttf +0 -0
  36. package/packages/web/build/client/_app/immutable/assets/KaTeX_Fraktur-Regular.CTYiF6lA.woff2 +0 -0
  37. package/packages/web/build/client/_app/immutable/assets/KaTeX_Fraktur-Regular.Dxdc4cR9.woff +0 -0
  38. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Bold.Cx986IdX.woff2 +0 -0
  39. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Bold.Jm3AIy58.woff +0 -0
  40. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Bold.waoOVXN0.ttf +0 -0
  41. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-BoldItalic.DxDJ3AOS.woff2 +0 -0
  42. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-BoldItalic.DzxPMmG6.ttf +0 -0
  43. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-BoldItalic.SpSLRI95.woff +0 -0
  44. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Italic.3WenGoN9.ttf +0 -0
  45. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Italic.BMLOBm91.woff +0 -0
  46. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Italic.NWA7e6Wa.woff2 +0 -0
  47. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Regular.B22Nviop.woff2 +0 -0
  48. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Regular.Dr94JaBh.woff +0 -0
  49. package/packages/web/build/client/_app/immutable/assets/KaTeX_Main-Regular.ypZvNtVU.ttf +0 -0
  50. package/packages/web/build/client/_app/immutable/assets/KaTeX_Math-BoldItalic.B3XSjfu4.ttf +0 -0
  51. package/packages/web/build/client/_app/immutable/assets/KaTeX_Math-BoldItalic.CZnvNsCZ.woff2 +0 -0
  52. package/packages/web/build/client/_app/immutable/assets/KaTeX_Math-BoldItalic.iY-2wyZ7.woff +0 -0
  53. package/packages/web/build/client/_app/immutable/assets/KaTeX_Math-Italic.DA0__PXp.woff +0 -0
  54. package/packages/web/build/client/_app/immutable/assets/KaTeX_Math-Italic.flOr_0UB.ttf +0 -0
  55. package/packages/web/build/client/_app/immutable/assets/KaTeX_Math-Italic.t53AETM-.woff2 +0 -0
  56. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Bold.CFMepnvq.ttf +0 -0
  57. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Bold.D1sUS0GD.woff2 +0 -0
  58. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Bold.DbIhKOiC.woff +0 -0
  59. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Italic.C3H0VqGB.woff2 +0 -0
  60. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Italic.DN2j7dab.woff +0 -0
  61. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Italic.YYjJ1zSn.ttf +0 -0
  62. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Regular.BNo7hRIc.ttf +0 -0
  63. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Regular.CS6fqUqJ.woff +0 -0
  64. package/packages/web/build/client/_app/immutable/assets/KaTeX_SansSerif-Regular.DDBCnlJ7.woff2 +0 -0
  65. package/packages/web/build/client/_app/immutable/assets/KaTeX_Script-Regular.C5JkGWo-.ttf +0 -0
  66. package/packages/web/build/client/_app/immutable/assets/KaTeX_Script-Regular.D3wIWfF6.woff2 +0 -0
  67. package/packages/web/build/client/_app/immutable/assets/KaTeX_Script-Regular.D5yQViql.woff +0 -0
  68. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size1-Regular.C195tn64.woff +0 -0
  69. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size1-Regular.Dbsnue_I.ttf +0 -0
  70. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size1-Regular.mCD8mA8B.woff2 +0 -0
  71. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size2-Regular.B7gKUWhC.ttf +0 -0
  72. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size2-Regular.Dy4dx90m.woff2 +0 -0
  73. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size2-Regular.oD1tc_U0.woff +0 -0
  74. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size3-Regular.CTq5MqoE.woff +0 -0
  75. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size3-Regular.DgpXs0kz.ttf +0 -0
  76. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size4-Regular.BF-4gkZK.woff +0 -0
  77. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size4-Regular.DWFBv043.ttf +0 -0
  78. package/packages/web/build/client/_app/immutable/assets/KaTeX_Size4-Regular.Dl5lxZxV.woff2 +0 -0
  79. package/packages/web/build/client/_app/immutable/assets/KaTeX_Typewriter-Regular.C0xS9mPB.woff +0 -0
  80. package/packages/web/build/client/_app/immutable/assets/KaTeX_Typewriter-Regular.CO6r4hn1.woff2 +0 -0
  81. package/packages/web/build/client/_app/immutable/assets/KaTeX_Typewriter-Regular.D3Ib7_Hf.ttf +0 -0
  82. package/packages/web/build/client/_app/immutable/assets/MemoryChangeItem.BWIhbozZ.css +1 -0
  83. package/packages/web/build/client/_app/immutable/assets/MemoryChangeItem.BWIhbozZ.css.br +0 -0
  84. package/packages/web/build/client/_app/immutable/assets/MemoryChangeItem.BWIhbozZ.css.gz +0 -0
  85. package/packages/web/build/client/_app/immutable/chunks/4PUAD6Hn.js +1 -0
  86. package/packages/web/build/client/_app/immutable/chunks/4PUAD6Hn.js.br +0 -0
  87. package/packages/web/build/client/_app/immutable/chunks/4PUAD6Hn.js.gz +0 -0
  88. package/packages/web/build/client/_app/immutable/chunks/5DnhI3WV.js +1 -0
  89. package/packages/web/build/client/_app/immutable/chunks/5DnhI3WV.js.br +0 -0
  90. package/packages/web/build/client/_app/immutable/chunks/5DnhI3WV.js.gz +0 -0
  91. package/packages/web/build/client/_app/immutable/chunks/9KY5PuID.js +1 -0
  92. package/packages/web/build/client/_app/immutable/chunks/9KY5PuID.js.br +0 -0
  93. package/packages/web/build/client/_app/immutable/chunks/9KY5PuID.js.gz +0 -0
  94. package/packages/web/build/client/_app/immutable/chunks/B3B6Llhi.js +1 -0
  95. package/packages/web/build/client/_app/immutable/chunks/B3B6Llhi.js.br +0 -0
  96. package/packages/web/build/client/_app/immutable/chunks/B3B6Llhi.js.gz +0 -0
  97. package/packages/web/build/client/_app/immutable/chunks/BEiyvTDv.js +2 -0
  98. package/packages/web/build/client/_app/immutable/chunks/BEiyvTDv.js.br +0 -0
  99. package/packages/web/build/client/_app/immutable/chunks/BEiyvTDv.js.gz +0 -0
  100. package/packages/web/build/client/_app/immutable/chunks/BEuWFR46.js +1 -0
  101. package/packages/web/build/client/_app/immutable/chunks/BEuWFR46.js.br +0 -0
  102. package/packages/web/build/client/_app/immutable/chunks/BEuWFR46.js.gz +0 -0
  103. package/packages/web/build/client/_app/immutable/chunks/BFs5OywM.js +1 -0
  104. package/packages/web/build/client/_app/immutable/chunks/BFs5OywM.js.br +2 -0
  105. package/packages/web/build/client/_app/immutable/chunks/BFs5OywM.js.gz +0 -0
  106. package/packages/web/build/client/_app/immutable/chunks/BHlj8PXn.js +1 -0
  107. package/packages/web/build/client/_app/immutable/chunks/BHlj8PXn.js.br +0 -0
  108. package/packages/web/build/client/_app/immutable/chunks/BHlj8PXn.js.gz +0 -0
  109. package/packages/web/build/client/_app/immutable/chunks/BNRbPhhf.js +1 -0
  110. package/packages/web/build/client/_app/immutable/chunks/BNRbPhhf.js.br +0 -0
  111. package/packages/web/build/client/_app/immutable/chunks/BNRbPhhf.js.gz +0 -0
  112. package/packages/web/build/client/_app/immutable/chunks/BOat6vK8.js +1 -0
  113. package/packages/web/build/client/_app/immutable/chunks/BOat6vK8.js.br +0 -0
  114. package/packages/web/build/client/_app/immutable/chunks/BOat6vK8.js.gz +0 -0
  115. package/packages/web/build/client/_app/immutable/chunks/BV31-W0q.js +1 -0
  116. package/packages/web/build/client/_app/immutable/chunks/BV31-W0q.js.br +0 -0
  117. package/packages/web/build/client/_app/immutable/chunks/BV31-W0q.js.gz +0 -0
  118. package/packages/web/build/client/_app/immutable/chunks/BX510Kfl.js +1 -0
  119. package/packages/web/build/client/_app/immutable/chunks/BX510Kfl.js.br +0 -0
  120. package/packages/web/build/client/_app/immutable/chunks/BX510Kfl.js.gz +0 -0
  121. package/packages/web/build/client/_app/immutable/chunks/BiJmfCpk.js +5 -0
  122. package/packages/web/build/client/_app/immutable/chunks/BiJmfCpk.js.br +0 -0
  123. package/packages/web/build/client/_app/immutable/chunks/BiJmfCpk.js.gz +0 -0
  124. package/packages/web/build/client/_app/immutable/chunks/Bj1mFvu3.js +1 -0
  125. package/packages/web/build/client/_app/immutable/chunks/Bj1mFvu3.js.br +0 -0
  126. package/packages/web/build/client/_app/immutable/chunks/Bj1mFvu3.js.gz +0 -0
  127. package/packages/web/build/client/_app/immutable/chunks/Bm7dan1t.js +31 -0
  128. package/packages/web/build/client/_app/immutable/chunks/Bm7dan1t.js.br +0 -0
  129. package/packages/web/build/client/_app/immutable/chunks/Bm7dan1t.js.gz +0 -0
  130. package/packages/web/build/client/_app/immutable/chunks/Bo_rsWL9.js +1 -0
  131. package/packages/web/build/client/_app/immutable/chunks/Bo_rsWL9.js.br +0 -0
  132. package/packages/web/build/client/_app/immutable/chunks/Bo_rsWL9.js.gz +0 -0
  133. package/packages/web/build/client/_app/immutable/chunks/BqRUHvKF.js +1 -0
  134. package/packages/web/build/client/_app/immutable/chunks/BqRUHvKF.js.br +0 -0
  135. package/packages/web/build/client/_app/immutable/chunks/BqRUHvKF.js.gz +0 -0
  136. package/packages/web/build/client/_app/immutable/chunks/BvYIXZ8H.js +1 -0
  137. package/packages/web/build/client/_app/immutable/chunks/BvYIXZ8H.js.br +0 -0
  138. package/packages/web/build/client/_app/immutable/chunks/BvYIXZ8H.js.gz +0 -0
  139. package/packages/web/build/client/_app/immutable/chunks/BxvcrS4t.js +1 -0
  140. package/packages/web/build/client/_app/immutable/chunks/BxvcrS4t.js.br +0 -0
  141. package/packages/web/build/client/_app/immutable/chunks/BxvcrS4t.js.gz +0 -0
  142. package/packages/web/build/client/_app/immutable/chunks/CDTqLtoU.js +1 -0
  143. package/packages/web/build/client/_app/immutable/chunks/CDTqLtoU.js.br +0 -0
  144. package/packages/web/build/client/_app/immutable/chunks/CDTqLtoU.js.gz +0 -0
  145. package/packages/web/build/client/_app/immutable/chunks/CGBW4BXA.js +1 -0
  146. package/packages/web/build/client/_app/immutable/chunks/CGBW4BXA.js.br +0 -0
  147. package/packages/web/build/client/_app/immutable/chunks/CGBW4BXA.js.gz +0 -0
  148. package/packages/web/build/client/_app/immutable/chunks/CGQ98Bzn.js +1 -0
  149. package/packages/web/build/client/_app/immutable/chunks/CGQ98Bzn.js.br +0 -0
  150. package/packages/web/build/client/_app/immutable/chunks/CGQ98Bzn.js.gz +0 -0
  151. package/packages/web/build/client/_app/immutable/chunks/CZifjVB9.js +67 -0
  152. package/packages/web/build/client/_app/immutable/chunks/CZifjVB9.js.br +0 -0
  153. package/packages/web/build/client/_app/immutable/chunks/CZifjVB9.js.gz +0 -0
  154. package/packages/web/build/client/_app/immutable/chunks/CcGIu5Vq.js +1 -0
  155. package/packages/web/build/client/_app/immutable/chunks/CcGIu5Vq.js.br +0 -0
  156. package/packages/web/build/client/_app/immutable/chunks/CcGIu5Vq.js.gz +0 -0
  157. package/packages/web/build/client/_app/immutable/chunks/Ck2bNKM1.js +1 -0
  158. package/packages/web/build/client/_app/immutable/chunks/Ck2bNKM1.js.br +0 -0
  159. package/packages/web/build/client/_app/immutable/chunks/Ck2bNKM1.js.gz +0 -0
  160. package/packages/web/build/client/_app/immutable/chunks/Cke9De8L.js +9 -0
  161. package/packages/web/build/client/_app/immutable/chunks/Cke9De8L.js.br +0 -0
  162. package/packages/web/build/client/_app/immutable/chunks/Cke9De8L.js.gz +0 -0
  163. package/packages/web/build/client/_app/immutable/chunks/CokZjUvP.js +327 -0
  164. package/packages/web/build/client/_app/immutable/chunks/CokZjUvP.js.br +0 -0
  165. package/packages/web/build/client/_app/immutable/chunks/CokZjUvP.js.gz +0 -0
  166. package/packages/web/build/client/_app/immutable/chunks/Cq-Be9D4.js +1 -0
  167. package/packages/web/build/client/_app/immutable/chunks/Cq-Be9D4.js.br +0 -0
  168. package/packages/web/build/client/_app/immutable/chunks/Cq-Be9D4.js.gz +0 -0
  169. package/packages/web/build/client/_app/immutable/chunks/CwTujmI2.js +1 -0
  170. package/packages/web/build/client/_app/immutable/chunks/CwTujmI2.js.br +0 -0
  171. package/packages/web/build/client/_app/immutable/chunks/CwTujmI2.js.gz +0 -0
  172. package/packages/web/build/client/_app/immutable/chunks/D-qajCIk.js +1 -0
  173. package/packages/web/build/client/_app/immutable/chunks/D-qajCIk.js.br +0 -0
  174. package/packages/web/build/client/_app/immutable/chunks/D-qajCIk.js.gz +0 -0
  175. package/packages/web/build/client/_app/immutable/chunks/D0gG26QQ.js +1 -0
  176. package/packages/web/build/client/_app/immutable/chunks/D0gG26QQ.js.br +0 -0
  177. package/packages/web/build/client/_app/immutable/chunks/D0gG26QQ.js.gz +0 -0
  178. package/packages/web/build/client/_app/immutable/chunks/D6PEWnLY.js +1 -0
  179. package/packages/web/build/client/_app/immutable/chunks/D6PEWnLY.js.br +0 -0
  180. package/packages/web/build/client/_app/immutable/chunks/D6PEWnLY.js.gz +0 -0
  181. package/packages/web/build/client/_app/immutable/chunks/D6S7I_wu.js +1 -0
  182. package/packages/web/build/client/_app/immutable/chunks/D6S7I_wu.js.br +0 -0
  183. package/packages/web/build/client/_app/immutable/chunks/D6S7I_wu.js.gz +0 -0
  184. package/packages/web/build/client/_app/immutable/chunks/DC4U80pb.js +1 -0
  185. package/packages/web/build/client/_app/immutable/chunks/DC4U80pb.js.br +3 -0
  186. package/packages/web/build/client/_app/immutable/chunks/DC4U80pb.js.gz +0 -0
  187. package/packages/web/build/client/_app/immutable/chunks/DIcXkfTb.js +1 -0
  188. package/packages/web/build/client/_app/immutable/chunks/DIcXkfTb.js.br +1 -0
  189. package/packages/web/build/client/_app/immutable/chunks/DIcXkfTb.js.gz +0 -0
  190. package/packages/web/build/client/_app/immutable/chunks/DJaeCx-L.js +1 -0
  191. package/packages/web/build/client/_app/immutable/chunks/DJaeCx-L.js.br +4 -0
  192. package/packages/web/build/client/_app/immutable/chunks/DJaeCx-L.js.gz +0 -0
  193. package/packages/web/build/client/_app/immutable/chunks/DMj7Nf4H.js +1 -0
  194. package/packages/web/build/client/_app/immutable/chunks/DMj7Nf4H.js.br +0 -0
  195. package/packages/web/build/client/_app/immutable/chunks/DMj7Nf4H.js.gz +0 -0
  196. package/packages/web/build/client/_app/immutable/chunks/DOvq77PD.js +1 -0
  197. package/packages/web/build/client/_app/immutable/chunks/DOvq77PD.js.br +0 -0
  198. package/packages/web/build/client/_app/immutable/chunks/DOvq77PD.js.gz +0 -0
  199. package/packages/web/build/client/_app/immutable/chunks/DTFYOzqo.js +1 -0
  200. package/packages/web/build/client/_app/immutable/chunks/DTFYOzqo.js.br +0 -0
  201. package/packages/web/build/client/_app/immutable/chunks/DTFYOzqo.js.gz +0 -0
  202. package/packages/web/build/client/_app/immutable/chunks/DcDwQDix.js +1 -0
  203. package/packages/web/build/client/_app/immutable/chunks/DcDwQDix.js.br +0 -0
  204. package/packages/web/build/client/_app/immutable/chunks/DcDwQDix.js.gz +0 -0
  205. package/packages/web/build/client/_app/immutable/chunks/DgZpnHfl.js +1 -0
  206. package/packages/web/build/client/_app/immutable/chunks/DgZpnHfl.js.br +0 -0
  207. package/packages/web/build/client/_app/immutable/chunks/DgZpnHfl.js.gz +0 -0
  208. package/packages/web/build/client/_app/immutable/chunks/DhgCoR6K.js +261 -0
  209. package/packages/web/build/client/_app/immutable/chunks/DhgCoR6K.js.br +0 -0
  210. package/packages/web/build/client/_app/immutable/chunks/DhgCoR6K.js.gz +0 -0
  211. package/packages/web/build/client/_app/immutable/chunks/DlQYf8zG.js +1 -0
  212. package/packages/web/build/client/_app/immutable/chunks/DlQYf8zG.js.br +0 -0
  213. package/packages/web/build/client/_app/immutable/chunks/DlQYf8zG.js.gz +0 -0
  214. package/packages/web/build/client/_app/immutable/chunks/Doe9BmDt.js +1 -0
  215. package/packages/web/build/client/_app/immutable/chunks/Doe9BmDt.js.br +0 -0
  216. package/packages/web/build/client/_app/immutable/chunks/Doe9BmDt.js.gz +0 -0
  217. package/packages/web/build/client/_app/immutable/chunks/Dtntqkaz.js +1 -0
  218. package/packages/web/build/client/_app/immutable/chunks/Dtntqkaz.js.br +0 -0
  219. package/packages/web/build/client/_app/immutable/chunks/Dtntqkaz.js.gz +0 -0
  220. package/packages/web/build/client/_app/immutable/chunks/DvW6dDDr.js +1 -0
  221. package/packages/web/build/client/_app/immutable/chunks/DvW6dDDr.js.br +0 -0
  222. package/packages/web/build/client/_app/immutable/chunks/DvW6dDDr.js.gz +0 -0
  223. package/packages/web/build/client/_app/immutable/chunks/DvwwtGJX.js +1 -0
  224. package/packages/web/build/client/_app/immutable/chunks/DvwwtGJX.js.br +0 -0
  225. package/packages/web/build/client/_app/immutable/chunks/DvwwtGJX.js.gz +0 -0
  226. package/packages/web/build/client/_app/immutable/chunks/GB5YcQWH.js +1 -0
  227. package/packages/web/build/client/_app/immutable/chunks/GB5YcQWH.js.br +0 -0
  228. package/packages/web/build/client/_app/immutable/chunks/GB5YcQWH.js.gz +0 -0
  229. package/packages/web/build/client/_app/immutable/chunks/N5ZTPF8d.js +1 -0
  230. package/packages/web/build/client/_app/immutable/chunks/N5ZTPF8d.js.br +0 -0
  231. package/packages/web/build/client/_app/immutable/chunks/N5ZTPF8d.js.gz +0 -0
  232. package/packages/web/build/client/_app/immutable/chunks/OszGRQS8.js +1 -0
  233. package/packages/web/build/client/_app/immutable/chunks/OszGRQS8.js.br +5 -0
  234. package/packages/web/build/client/_app/immutable/chunks/OszGRQS8.js.gz +0 -0
  235. package/packages/web/build/client/_app/immutable/chunks/PbrvVWdR.js +1 -0
  236. package/packages/web/build/client/_app/immutable/chunks/PbrvVWdR.js.br +0 -0
  237. package/packages/web/build/client/_app/immutable/chunks/PbrvVWdR.js.gz +0 -0
  238. package/packages/web/build/client/_app/immutable/chunks/crM_JIeq.js +1 -0
  239. package/packages/web/build/client/_app/immutable/chunks/crM_JIeq.js.br +0 -0
  240. package/packages/web/build/client/_app/immutable/chunks/crM_JIeq.js.gz +0 -0
  241. package/packages/web/build/client/_app/immutable/chunks/dJUISQ0D.js +1 -0
  242. package/packages/web/build/client/_app/immutable/chunks/dJUISQ0D.js.br +0 -0
  243. package/packages/web/build/client/_app/immutable/chunks/dJUISQ0D.js.gz +0 -0
  244. package/packages/web/build/client/_app/immutable/chunks/dp9f0HTI.js +1 -0
  245. package/packages/web/build/client/_app/immutable/chunks/dp9f0HTI.js.br +0 -0
  246. package/packages/web/build/client/_app/immutable/chunks/dp9f0HTI.js.gz +0 -0
  247. package/packages/web/build/client/_app/immutable/chunks/eVN8j5Zj.js +1 -0
  248. package/packages/web/build/client/_app/immutable/chunks/eVN8j5Zj.js.br +0 -0
  249. package/packages/web/build/client/_app/immutable/chunks/eVN8j5Zj.js.gz +0 -0
  250. package/packages/web/build/client/_app/immutable/chunks/m-CsyuMo.js +1 -0
  251. package/packages/web/build/client/_app/immutable/chunks/m-CsyuMo.js.br +0 -0
  252. package/packages/web/build/client/_app/immutable/chunks/m-CsyuMo.js.gz +0 -0
  253. package/packages/web/build/client/_app/immutable/chunks/nCUftdRl.js +1 -0
  254. package/packages/web/build/client/_app/immutable/chunks/nCUftdRl.js.br +0 -0
  255. package/packages/web/build/client/_app/immutable/chunks/nCUftdRl.js.gz +0 -0
  256. package/packages/web/build/client/_app/immutable/chunks/xWImVVsw.js +1 -0
  257. package/packages/web/build/client/_app/immutable/chunks/xWImVVsw.js.br +0 -0
  258. package/packages/web/build/client/_app/immutable/chunks/xWImVVsw.js.gz +0 -0
  259. package/packages/web/build/client/_app/immutable/chunks/zo8EncEu.js +1 -0
  260. package/packages/web/build/client/_app/immutable/chunks/zo8EncEu.js.br +0 -0
  261. package/packages/web/build/client/_app/immutable/chunks/zo8EncEu.js.gz +0 -0
  262. package/packages/web/build/client/_app/immutable/chunks/zuA9NU4f.js +1 -0
  263. package/packages/web/build/client/_app/immutable/chunks/zuA9NU4f.js.br +0 -0
  264. package/packages/web/build/client/_app/immutable/chunks/zuA9NU4f.js.gz +0 -0
  265. package/packages/web/build/client/_app/immutable/entry/app.D-KOuAJD.js +2 -0
  266. package/packages/web/build/client/_app/immutable/entry/app.D-KOuAJD.js.br +0 -0
  267. package/packages/web/build/client/_app/immutable/entry/app.D-KOuAJD.js.gz +0 -0
  268. package/packages/web/build/client/_app/immutable/entry/start.IVIfXqZa.js +1 -0
  269. package/packages/web/build/client/_app/immutable/entry/start.IVIfXqZa.js.br +0 -0
  270. package/packages/web/build/client/_app/immutable/entry/start.IVIfXqZa.js.gz +0 -0
  271. package/packages/web/build/client/_app/immutable/nodes/0.Dl7QTsEW.js +1 -0
  272. package/packages/web/build/client/_app/immutable/nodes/0.Dl7QTsEW.js.br +0 -0
  273. package/packages/web/build/client/_app/immutable/nodes/0.Dl7QTsEW.js.gz +0 -0
  274. package/packages/web/build/client/_app/immutable/nodes/1.C3FY3xx7.js +1 -0
  275. package/packages/web/build/client/_app/immutable/nodes/1.C3FY3xx7.js.br +3 -0
  276. package/packages/web/build/client/_app/immutable/nodes/1.C3FY3xx7.js.gz +0 -0
  277. package/packages/web/build/client/_app/immutable/nodes/10.DU8uzpk3.js +2 -0
  278. package/packages/web/build/client/_app/immutable/nodes/10.DU8uzpk3.js.br +0 -0
  279. package/packages/web/build/client/_app/immutable/nodes/10.DU8uzpk3.js.gz +0 -0
  280. package/packages/web/build/client/_app/immutable/nodes/11.CWXGNZsH.js +1 -0
  281. package/packages/web/build/client/_app/immutable/nodes/11.CWXGNZsH.js.br +0 -0
  282. package/packages/web/build/client/_app/immutable/nodes/11.CWXGNZsH.js.gz +0 -0
  283. package/packages/web/build/client/_app/immutable/nodes/12.D8oPN9It.js +1 -0
  284. package/packages/web/build/client/_app/immutable/nodes/12.D8oPN9It.js.br +0 -0
  285. package/packages/web/build/client/_app/immutable/nodes/12.D8oPN9It.js.gz +0 -0
  286. package/packages/web/build/client/_app/immutable/nodes/13.DlmupEgK.js +4 -0
  287. package/packages/web/build/client/_app/immutable/nodes/13.DlmupEgK.js.br +0 -0
  288. package/packages/web/build/client/_app/immutable/nodes/13.DlmupEgK.js.gz +0 -0
  289. package/packages/web/build/client/_app/immutable/nodes/14.DYXttXGs.js +1 -0
  290. package/packages/web/build/client/_app/immutable/nodes/14.DYXttXGs.js.br +0 -0
  291. package/packages/web/build/client/_app/immutable/nodes/14.DYXttXGs.js.gz +0 -0
  292. package/packages/web/build/client/_app/immutable/nodes/15.EZnTFds4.js +1 -0
  293. package/packages/web/build/client/_app/immutable/nodes/15.EZnTFds4.js.br +0 -0
  294. package/packages/web/build/client/_app/immutable/nodes/15.EZnTFds4.js.gz +0 -0
  295. package/packages/web/build/client/_app/immutable/nodes/16.DAKM59ho.js +2 -0
  296. package/packages/web/build/client/_app/immutable/nodes/16.DAKM59ho.js.br +0 -0
  297. package/packages/web/build/client/_app/immutable/nodes/16.DAKM59ho.js.gz +0 -0
  298. package/packages/web/build/client/_app/immutable/nodes/17.PkgTK81g.js +1 -0
  299. package/packages/web/build/client/_app/immutable/nodes/17.PkgTK81g.js.br +0 -0
  300. package/packages/web/build/client/_app/immutable/nodes/17.PkgTK81g.js.gz +0 -0
  301. package/packages/web/build/client/_app/immutable/nodes/18.vRqsEe52.js +1 -0
  302. package/packages/web/build/client/_app/immutable/nodes/18.vRqsEe52.js.br +0 -0
  303. package/packages/web/build/client/_app/immutable/nodes/18.vRqsEe52.js.gz +0 -0
  304. package/packages/web/build/client/_app/immutable/nodes/19.DBdb0Lg_.js +46 -0
  305. package/packages/web/build/client/_app/immutable/nodes/19.DBdb0Lg_.js.br +0 -0
  306. package/packages/web/build/client/_app/immutable/nodes/19.DBdb0Lg_.js.gz +0 -0
  307. package/packages/web/build/client/_app/immutable/nodes/2.DPQ3zIod.js +1 -0
  308. package/packages/web/build/client/_app/immutable/nodes/2.DPQ3zIod.js.br +0 -0
  309. package/packages/web/build/client/_app/immutable/nodes/2.DPQ3zIod.js.gz +0 -0
  310. package/packages/web/build/client/_app/immutable/nodes/20.BCcqHCci.js +1 -0
  311. package/packages/web/build/client/_app/immutable/nodes/20.BCcqHCci.js.br +0 -0
  312. package/packages/web/build/client/_app/immutable/nodes/20.BCcqHCci.js.gz +0 -0
  313. package/packages/web/build/client/_app/immutable/nodes/4.Gll3vIPZ.js +2 -0
  314. package/packages/web/build/client/_app/immutable/nodes/4.Gll3vIPZ.js.br +0 -0
  315. package/packages/web/build/client/_app/immutable/nodes/4.Gll3vIPZ.js.gz +0 -0
  316. package/packages/web/build/client/_app/immutable/nodes/5.CKcOR7bM.js +1 -0
  317. package/packages/web/build/client/_app/immutable/nodes/5.CKcOR7bM.js.br +0 -0
  318. package/packages/web/build/client/_app/immutable/nodes/5.CKcOR7bM.js.gz +0 -0
  319. package/packages/web/build/client/_app/immutable/nodes/6.BEyvFFIp.js +1 -0
  320. package/packages/web/build/client/_app/immutable/nodes/6.BEyvFFIp.js.br +0 -0
  321. package/packages/web/build/client/_app/immutable/nodes/6.BEyvFFIp.js.gz +0 -0
  322. package/packages/web/build/client/_app/immutable/nodes/7.B-JUQ_Vr.js +2 -0
  323. package/packages/web/build/client/_app/immutable/nodes/7.B-JUQ_Vr.js.br +0 -0
  324. package/packages/web/build/client/_app/immutable/nodes/7.B-JUQ_Vr.js.gz +0 -0
  325. package/packages/web/build/client/_app/immutable/nodes/8.DhFg-aY8.js +1 -0
  326. package/packages/web/build/client/_app/immutable/nodes/8.DhFg-aY8.js.br +0 -0
  327. package/packages/web/build/client/_app/immutable/nodes/8.DhFg-aY8.js.gz +0 -0
  328. package/packages/web/build/client/_app/immutable/nodes/9.DjKCQ1l3.js +1 -0
  329. package/packages/web/build/client/_app/immutable/nodes/9.DjKCQ1l3.js.br +0 -0
  330. package/packages/web/build/client/_app/immutable/nodes/9.DjKCQ1l3.js.gz +0 -0
  331. package/packages/web/build/client/_app/version.json +1 -1
  332. package/packages/web/build/client/_app/version.json.br +0 -0
  333. package/packages/web/build/client/_app/version.json.gz +0 -0
  334. package/packages/web/build/handler.js +4 -4
  335. package/packages/web/build/index.js +4 -4
  336. package/packages/web/build/server/chunks/chunks/AssistantAvatar.js-DiCVVVOX.js +293 -0
  337. package/packages/web/build/server/chunks/chunks/AvatarPicker.js-DfQIN8YI.js +135 -0
  338. package/packages/web/build/server/chunks/chunks/Composer.js-BD9XUuTX.js +332 -0
  339. package/packages/web/build/server/chunks/chunks/ComposerDock.js-DTvu7Y-J.js +58 -0
  340. package/packages/web/build/server/chunks/chunks/CopyButton.js-3lPgmWGZ.js +81 -0
  341. package/packages/web/build/server/chunks/chunks/DotGrid.js-DhkaOwvR.js +108 -0
  342. package/packages/web/build/server/chunks/chunks/MemoryChangeItem.js-CszZww43.js +15975 -0
  343. package/packages/web/build/server/chunks/chunks/ModelMenu.js--hauzhKu.js +684 -0
  344. package/packages/web/build/server/chunks/chunks/MoveToFolderMenu.js-C3-ONxWK.js +289 -0
  345. package/packages/web/build/server/chunks/chunks/NewChatForm.js-41aer8-y.js +306 -0
  346. package/packages/web/build/server/chunks/chunks/NewFolderDialog.js-BLDWgamm.js +193 -0
  347. package/packages/web/build/server/chunks/chunks/Notifications.js-D2m19ylY.js +763 -0
  348. package/packages/web/build/server/chunks/chunks/PageHeader.js-BTQt3nN6.js +70 -0
  349. package/packages/web/build/server/chunks/chunks/PlanUsageBars.js-Bjg4JeO1.js +111 -0
  350. package/packages/web/build/server/chunks/chunks/RenameFolderDialog.js-C4A6RwYh.js +259 -0
  351. package/packages/web/build/server/chunks/chunks/StepIcon.js-B1rGP1yW.js +38 -0
  352. package/packages/web/build/server/chunks/chunks/TopBar.js-iFEw-ZP1.js +37 -0
  353. package/packages/web/build/server/chunks/chunks/TypedText.js-CBDH4RYQ.js +62 -0
  354. package/packages/web/build/server/chunks/chunks/UserAvatar.js-DY0XLih9.js +23 -0
  355. package/packages/web/build/server/chunks/chunks/UserMenu.js-D2M71Qwt.js +1539 -0
  356. package/packages/web/build/server/chunks/chunks/access.js-BLcZsmEF.js +40 -0
  357. package/packages/web/build/server/chunks/chunks/accounts.js-7I_MmVRG.js +26 -0
  358. package/packages/web/build/server/chunks/chunks/alert-dialog.js-dXbEUmyf.js +504 -0
  359. package/packages/web/build/server/chunks/chunks/api.js-b7cn5PbW.js +40 -0
  360. package/packages/web/build/server/chunks/chunks/auth.js-D3TBJ-bo.js +20064 -0
  361. package/packages/web/build/server/chunks/chunks/automations.js-PTpqQWo0.js +198 -0
  362. package/packages/web/build/server/chunks/chunks/avatars.js-C3tB5SlK.js +506 -0
  363. package/packages/web/build/server/chunks/chunks/badge.js-CV8ujLk7.js +37 -0
  364. package/packages/web/build/server/chunks/chunks/button.js-DgaDzlsw.js +4025 -0
  365. package/packages/web/build/server/chunks/chunks/camera.js-D9wejCUZ.js +19 -0
  366. package/packages/web/build/server/chunks/chunks/chats.js-C_ParQQi.js +62 -0
  367. package/packages/web/build/server/chunks/chunks/check.js-CWziLHT9.js +15 -0
  368. package/packages/web/build/server/chunks/chunks/chevron-left.js-C0GGjrDT.js +15 -0
  369. package/packages/web/build/server/chunks/chunks/chevron-right.js-DAWR16mM.js +15 -0
  370. package/packages/web/build/server/chunks/chunks/chevrons-up-down.js-DEP-qqg4.js +15 -0
  371. package/packages/web/build/server/chunks/chunks/client.js-UAJMOZ3E.js +120 -0
  372. package/packages/web/build/server/chunks/chunks/clock.js-DoLCyX6L.js +19 -0
  373. package/packages/web/build/server/chunks/chunks/coerce.js-DyM7nUNl.js +8477 -0
  374. package/packages/web/build/server/chunks/chunks/collapsible.js-CWSyjrbz.js +410 -0
  375. package/packages/web/build/server/chunks/chunks/command.js-CIlfdltM.js +2231 -0
  376. package/packages/web/build/server/chunks/chunks/dialog.js-CuTPiEih.js +543 -0
  377. package/packages/web/build/server/chunks/chunks/dist.js-BmWeTHnS.js +600 -0
  378. package/packages/web/build/server/chunks/chunks/dist2.js-BbxQLlSx.js +347 -0
  379. package/packages/web/build/server/chunks/chunks/dist3.js-GCNglsxk.js +19547 -0
  380. package/packages/web/build/server/chunks/chunks/download.js-Dw_s_V8T.js +19 -0
  381. package/packages/web/build/server/chunks/chunks/dropdown-menu.js-klnL3AVI.js +2395 -0
  382. package/packages/web/build/server/chunks/chunks/eraser.js-B8-m3VQ3.js +15 -0
  383. package/packages/web/build/server/chunks/chunks/factory.js-DwhAilJf.js +2344 -0
  384. package/packages/web/build/server/chunks/chunks/folder-input.js-xU4i7Wj1.js +19 -0
  385. package/packages/web/build/server/chunks/chunks/forms.js-0RsYOm25.js +32 -0
  386. package/packages/web/build/server/chunks/chunks/hidden-input.js-DQrYkjSR.js +47 -0
  387. package/packages/web/build/server/chunks/chunks/i18n.js-DOMtD7OV.js +7498 -0
  388. package/packages/web/build/server/chunks/chunks/images.js-Cw521alT.js +124 -0
  389. package/packages/web/build/server/chunks/chunks/internal2.js-BmQF3qCw.js +1135 -0
  390. package/packages/web/build/server/chunks/chunks/ios.js-Dc1DLp61.js +12 -0
  391. package/packages/web/build/server/chunks/chunks/list-collapse.js-BHdkhU7D.js +21 -0
  392. package/packages/web/build/server/chunks/chunks/memory.js-cU4wowLn.js +42 -0
  393. package/packages/web/build/server/chunks/chunks/memory2.js-B4MEEi_Z.js +26 -0
  394. package/packages/web/build/server/chunks/chunks/message-circle.js-BZjpL54j.js +15 -0
  395. package/packages/web/build/server/chunks/chunks/moon-star.js-DATlVG-W.js +34 -0
  396. package/packages/web/build/server/chunks/chunks/motion.js-CtOKcu-x.js +224 -0
  397. package/packages/web/build/server/chunks/chunks/navigation.js-BgKL4O5J.js +2 -0
  398. package/packages/web/build/server/chunks/chunks/paths.js-CSblJkdx.js +19 -0
  399. package/packages/web/build/server/chunks/chunks/pencil.js-BBP970JE.js +15 -0
  400. package/packages/web/build/server/chunks/chunks/plan-usage.svelte.js-CuVZYFIH.js +27 -0
  401. package/packages/web/build/server/chunks/chunks/plus.js-AAFvEbhZ.js +15 -0
  402. package/packages/web/build/server/chunks/chunks/sdk.js-Jx-nl9-6.js +42918 -0
  403. package/packages/web/build/server/chunks/chunks/select.js-Cy8QwqOr.js +1964 -0
  404. package/packages/web/build/server/chunks/chunks/sidebar.js-f3cS5ugL.js +1498 -0
  405. package/packages/web/build/server/chunks/chunks/square-pen.js-BiHIfF48.js +20 -0
  406. package/packages/web/build/server/chunks/chunks/src.js-OCqmpAMD.js +43095 -0
  407. package/packages/web/build/server/chunks/chunks/state.js-DWKXB_zq.js +67 -0
  408. package/packages/web/build/server/chunks/chunks/switch.js-BO_aEltM.js +282 -0
  409. package/packages/web/build/server/chunks/chunks/terminal.js-W_lgKCde.js +15 -0
  410. package/packages/web/build/server/chunks/chunks/textarea.js-G8C1SPzx.js +24 -0
  411. package/packages/web/build/server/chunks/chunks/tint.js-CQnYLySf.js +146 -0
  412. package/packages/web/build/server/chunks/chunks/tooltip.js-CNshopM4.js +5862 -0
  413. package/packages/web/build/server/chunks/chunks/transcript.js-BZDJbNRI.js +267 -0
  414. package/packages/web/build/server/chunks/chunks/utils2.js-7mvaj0Jt.js +1165 -0
  415. package/packages/web/build/server/chunks/chunks/zod.js-CKsfx39Z.js +10352 -0
  416. package/packages/web/build/server/chunks/chunks/zod2.js-Ccq3O23H.js +5 -0
  417. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/_server.ts.js-BDDKHG1l.js +60 -0
  418. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/activity/_server.ts.js-GDXhPCE8.js +62 -0
  419. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/commands/_server.ts.js-Dw4dM1cn.js +56 -0
  420. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/compact/_server.ts.js-DIlzvAaT.js +54 -0
  421. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/continue/_server.ts.js-ClVUaSCp.js +47 -0
  422. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/effort/_server.ts.js-vchFw6_5.js +48 -0
  423. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/events/_server.ts.js-BD_hfnT_.js +75 -0
  424. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/folder/_server.ts.js-Hg5sAdUd.js +56 -0
  425. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/media/_mediaId_/_server.ts.js-BltgwP2L.js +53 -0
  426. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/messages/_server.ts.js-CcH8Kxjp.js +59 -0
  427. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/preset/_server.ts.js-DUVNriIz.js +52 -0
  428. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/stop/_server.ts.js--3yx-DoO.js +45 -0
  429. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/tools/_server.ts.js-6-x8ZmEo.js +53 -0
  430. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/transcript/_server.ts.js-DAu9zOJy.js +74 -0
  431. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/typing/_server.ts.js-BRyNNa9m.js +51 -0
  432. package/packages/web/build/server/chunks/entries/endpoints/api/card/changes/_id_/keep/_server.ts.js-CB_T-S_a.js +60 -0
  433. package/packages/web/build/server/chunks/entries/endpoints/api/chatgpt/sign-in/_server.ts.js-BxvRvNbI.js +75 -0
  434. package/packages/web/build/server/chunks/entries/endpoints/api/events/_server.ts.js-DUNvDYk9.js +89 -0
  435. package/packages/web/build/server/chunks/entries/endpoints/api/hooks/_token_/_server.ts.js-hZxLZWb8.js +51 -0
  436. package/packages/web/build/server/chunks/entries/endpoints/api/me/_server.ts.js-Dqb5Fu2v.js +66 -0
  437. package/packages/web/build/server/chunks/entries/endpoints/api/me/picture/_server.ts.js--PNClZau.js +62 -0
  438. package/packages/web/build/server/chunks/entries/endpoints/api/models/_server.ts.js-DOZpKrMU.js +58 -0
  439. package/packages/web/build/server/chunks/entries/endpoints/api/nolune-plan/sign-in/_server.ts.js-BmoDszdu.js +78 -0
  440. package/packages/web/build/server/chunks/entries/endpoints/api/nolune-plan/usage/_server.ts.js-BA1Jw8lm.js +49 -0
  441. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/_id_/continue/_server.ts.js-DEIKGp_x.js +52 -0
  442. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/_id_/dismiss/_server.ts.js-rdqvWXF-.js +44 -0
  443. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/_server.ts.js-ElmEZbXP.js +42 -0
  444. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/clear/_server.ts.js-B2WJwUC1.js +45 -0
  445. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/seen/_server.ts.js-eo_dP1CX.js +45 -0
  446. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/_server.ts.js-Ddx3D0-M.js +46 -0
  447. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/automations/_id_/_server.ts.js-DO-1Nz4W.js +85 -0
  448. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/automations/_id_/run/_server.ts.js-C9HdWdoG.js +60 -0
  449. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/automations/_server.ts.js-CXt08BQW.js +49 -0
  450. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/chats/_server.ts.js-Cg31SY8j.js +91 -0
  451. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/folders/_folder_/_server.ts.js-Apm3R_Oc.js +96 -0
  452. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/folders/_folder_/files/_file_/_server.ts.js-DFvf5pAy.js +64 -0
  453. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/folders/_folder_/files/_server.ts.js-CvJ1he2a.js +69 -0
  454. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/folders/_server.ts.js-epz6RwOJ.js +67 -0
  455. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/images/_server.ts.js-6IqNsR8x.js +74 -0
  456. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/members/_server.ts.js-BD5lTTiu.js +62 -0
  457. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/members/_user_/_server.ts.js-BixJY3H5.js +67 -0
  458. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/memory/_id_/undo/_server.ts.js-c82dPky5.js +60 -0
  459. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/memory/_server.ts.js-y_nNK3OY.js +49 -0
  460. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/memory/learning/_server.ts.js-B1tP4nh8.js +48 -0
  461. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/memory/moves/_server.ts.js-CeRKDlWx.js +62 -0
  462. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/memory/notes/_server.ts.js-CJ1evniS.js +72 -0
  463. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/new-chat/_server.ts.js-CWoRuJ_a.js +67 -0
  464. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/running/_server.ts.js-Bh_cQWoi.js +81 -0
  465. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/settings/_server.ts.js-BqbDWift.js +79 -0
  466. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/skills/_server.ts.js-Bzr7Ln8I.js +66 -0
  467. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/suggestions/_server.ts.js-CebVSt0Y.js +55 -0
  468. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/templates/_id_/cover/_server.ts.js-OzVH7VFf.js +61 -0
  469. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/uploads/_id_/_server.ts.js-CMxAdbsX.js +46 -0
  470. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/uploads/_server.ts.js-CXouE2I7.js +73 -0
  471. package/packages/web/build/server/chunks/entries/endpoints/api/pictures/_sha256_/_server.ts.js-B2XdyrbF.js +56 -0
  472. package/packages/web/build/server/chunks/entries/endpoints/api/profiles/_server.ts.js-Dt2xMSgK.js +55 -0
  473. package/packages/web/build/server/chunks/entries/endpoints/api/push/_server.ts.js-c2JeodvM.js +63 -0
  474. package/packages/web/build/server/chunks/entries/endpoints/api/version/_server.ts.js-Begjkqmv.js +47 -0
  475. package/packages/web/build/server/chunks/entries/endpoints/logout/_server.ts.js-idjrT7dp.js +47 -0
  476. package/packages/web/build/server/chunks/entries/fallbacks/error.svelte.js-DlgTQda6.js +22 -0
  477. package/packages/web/build/server/chunks/entries/hooks.server.js-DGIhty0N.js +3463 -0
  478. package/packages/web/build/server/chunks/entries/pages/_layout.server.ts.js-CaMWskO2.js +45 -0
  479. package/packages/web/build/server/chunks/entries/pages/_layout.svelte.js-CInBfTlO.js +92 -0
  480. package/packages/web/build/server/chunks/entries/pages/_page.server.ts.js-hcuICfdX.js +27 -0
  481. package/packages/web/build/server/chunks/entries/pages/admin/_page.server.ts.js-BdH0Fb0C.js +414 -0
  482. package/packages/web/build/server/chunks/entries/pages/admin/_page.svelte.js-C-LvOC0D.js +2723 -0
  483. package/packages/web/build/server/chunks/entries/pages/admin/people/_page.server.ts.js-D3x7CWA2.js +130 -0
  484. package/packages/web/build/server/chunks/entries/pages/admin/people/_page.svelte.js-C-JgZqfh.js +575 -0
  485. package/packages/web/build/server/chunks/entries/pages/admin/services/_page.server.ts.js-DByyMwVK.js +223 -0
  486. package/packages/web/build/server/chunks/entries/pages/admin/services/_page.svelte.js-CkWT7WWB.js +745 -0
  487. package/packages/web/build/server/chunks/entries/pages/card/_page.server.ts.js-CSM5MY1g.js +75 -0
  488. package/packages/web/build/server/chunks/entries/pages/card/_page.svelte.js-DEUN4aif.js +373 -0
  489. package/packages/web/build/server/chunks/entries/pages/invite/_token_/_page.server.ts.js-Hg8pdoM0.js +63 -0
  490. package/packages/web/build/server/chunks/entries/pages/invite/_token_/_page.svelte.js-CdBKzpks.js +126 -0
  491. package/packages/web/build/server/chunks/entries/pages/login/_page.server.ts.js-BBCDF3vx.js +42 -0
  492. package/packages/web/build/server/chunks/entries/pages/login/_page.svelte.js-Rz05sb7N.js +77 -0
  493. package/packages/web/build/server/chunks/entries/pages/mcp/oauth/callback/_page.server.ts.js-DH5rfB74.js +59 -0
  494. package/packages/web/build/server/chunks/entries/pages/mcp/oauth/callback/_page.svelte.js-DIU0dKwJ.js +41 -0
  495. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_layout.server.ts.js-D4_Irj4x.js +53 -0
  496. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_layout.svelte.js-Bt_yKsQy.js +1901 -0
  497. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_page.server.ts.js-WsLnbCGo.js +58 -0
  498. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_page.svelte.js-BPNqXA7_.js +154 -0
  499. package/packages/web/build/server/chunks/entries/pages/p/_slug_/automations/_page.server.ts.js-BBByFA1j.js +85 -0
  500. package/packages/web/build/server/chunks/entries/pages/p/_slug_/automations/_page.svelte.js-V4mkZPcq.js +414 -0
  501. package/packages/web/build/server/chunks/entries/pages/p/_slug_/c/_id_/_page.server.ts.js-DU5DMrJo.js +73 -0
  502. package/packages/web/build/server/chunks/entries/pages/p/_slug_/c/_id_/_page.svelte.js-Dy4VZ3vg.js +2545 -0
  503. package/packages/web/build/server/chunks/entries/pages/p/_slug_/f/_folder_/_page.server.ts.js-Cxg3_T_H.js +103 -0
  504. package/packages/web/build/server/chunks/entries/pages/p/_slug_/f/_folder_/_page.svelte.js-7cnMQFtg.js +325 -0
  505. package/packages/web/build/server/chunks/entries/pages/p/_slug_/images/_page.server.ts.js-6r7H1qwP.js +45 -0
  506. package/packages/web/build/server/chunks/entries/pages/p/_slug_/images/_page.svelte.js-9Y_iZaMK.js +513 -0
  507. package/packages/web/build/server/chunks/entries/pages/p/_slug_/memory/_page.server.ts.js-DlMyiCYF.js +85 -0
  508. package/packages/web/build/server/chunks/entries/pages/p/_slug_/memory/_page.svelte.js-DawB9d5u.js +969 -0
  509. package/packages/web/build/server/chunks/entries/pages/p/_slug_/settings/_page.server.ts.js-CGL1lDNf.js +106 -0
  510. package/packages/web/build/server/chunks/entries/pages/p/_slug_/settings/_page.svelte.js-BXmRl2tD.js +585 -0
  511. package/packages/web/build/server/chunks/entries/pages/p/_slug_/skills/_page.server.ts.js-BOvkYTur.js +45 -0
  512. package/packages/web/build/server/chunks/entries/pages/p/_slug_/skills/_page.svelte.js-D1DRakEJ.js +132 -0
  513. package/packages/web/build/server/chunks/entries/pages/p/_slug_/welcome/_page.server.ts.js-C6gnoXOT.js +142 -0
  514. package/packages/web/build/server/chunks/entries/pages/p/_slug_/welcome/_page@.svelte.js-BG65rcFm.js +223 -0
  515. package/packages/web/build/server/chunks/entries/pages/profiles/_page.server.ts.js-DmWovIst.js +47 -0
  516. package/packages/web/build/server/chunks/entries/pages/profiles/_page.svelte.js-DVKymUZe.js +241 -0
  517. package/packages/web/build/server/chunks/handler-DYe7c_gy.js +1735 -0
  518. package/packages/web/build/server/chunks/index.js-jS0dbO4t.js +3700 -0
  519. package/packages/web/build/server/chunks/manifest.js-BgqcFT5h.js +599 -0
  520. package/packages/web/build/server/chunks/nodes/0.js-CX9FLBmF.js +46 -0
  521. package/packages/web/build/server/chunks/nodes/1.js-DRqBnMU0.js +9 -0
  522. package/packages/web/build/server/chunks/nodes/10.js-BVWgcD9i.js +44 -0
  523. package/packages/web/build/server/chunks/nodes/11.js-DwelFuZ4.js +50 -0
  524. package/packages/web/build/server/chunks/nodes/12.js-BJfkvADe.js +48 -0
  525. package/packages/web/build/server/chunks/nodes/13.js-CoDVyc7U.js +48 -0
  526. package/packages/web/build/server/chunks/nodes/14.js-D1QRfYIT.js +47 -0
  527. package/packages/web/build/server/chunks/nodes/15.js-CCAQV2IA.js +48 -0
  528. package/packages/web/build/server/chunks/nodes/16.js-CV5zTaaO.js +48 -0
  529. package/packages/web/build/server/chunks/nodes/17.js-9iB6Scpy.js +47 -0
  530. package/packages/web/build/server/chunks/nodes/18.js-CwnmxqR9.js +47 -0
  531. package/packages/web/build/server/chunks/nodes/19.js-ROtMXSrs.js +47 -0
  532. package/packages/web/build/server/chunks/nodes/2.js-Crv2kihA.js +49 -0
  533. package/packages/web/build/server/chunks/nodes/20.js-C25dCNsU.js +47 -0
  534. package/packages/web/build/server/chunks/nodes/3.js-BMHnrrJk.js +48 -0
  535. package/packages/web/build/server/chunks/nodes/4.js-CL0tEcdg.js +48 -0
  536. package/packages/web/build/server/chunks/nodes/5.js-CbwL2pfa.js +49 -0
  537. package/packages/web/build/server/chunks/nodes/6.js-DY4caScP.js +47 -0
  538. package/packages/web/build/server/chunks/nodes/7.js-BQpO5-aZ.js +47 -0
  539. package/packages/web/build/server/chunks/nodes/8.js-DNN_HejS.js +52 -0
  540. package/packages/web/build/server/chunks/nodes/9.js-DiPBM89-.js +51 -0
  541. package/dist/chunks/chunk-SAHRBQRY.js +0 -110
  542. package/dist/chunks/run-XM7YIEAW.js +0 -24454
  543. package/dist/chunks/zod-H7KMPIPH.js +0 -19934
  544. package/packages/web/build/client/_app/immutable/assets/0.DTnuPoms.css +0 -2
  545. package/packages/web/build/client/_app/immutable/assets/0.DTnuPoms.css.br +0 -0
  546. package/packages/web/build/client/_app/immutable/assets/0.DTnuPoms.css.gz +0 -0
  547. package/packages/web/build/client/_app/immutable/assets/11.DZmZHLub.css +0 -1
  548. package/packages/web/build/client/_app/immutable/assets/11.DZmZHLub.css.br +0 -6
  549. package/packages/web/build/client/_app/immutable/assets/11.DZmZHLub.css.gz +0 -0
  550. package/packages/web/build/client/_app/immutable/chunks/AwlnAPt_.js +0 -31
  551. package/packages/web/build/client/_app/immutable/chunks/AwlnAPt_.js.br +0 -0
  552. package/packages/web/build/client/_app/immutable/chunks/AwlnAPt_.js.gz +0 -0
  553. package/packages/web/build/client/_app/immutable/chunks/B0psERp-.js +0 -1
  554. package/packages/web/build/client/_app/immutable/chunks/B0psERp-.js.br +0 -0
  555. package/packages/web/build/client/_app/immutable/chunks/B0psERp-.js.gz +0 -0
  556. package/packages/web/build/client/_app/immutable/chunks/B4dOTQGI.js +0 -1
  557. package/packages/web/build/client/_app/immutable/chunks/B4dOTQGI.js.br +0 -3
  558. package/packages/web/build/client/_app/immutable/chunks/B4dOTQGI.js.gz +0 -0
  559. package/packages/web/build/client/_app/immutable/chunks/B6dKebLF.js +0 -1
  560. package/packages/web/build/client/_app/immutable/chunks/B6dKebLF.js.br +0 -0
  561. package/packages/web/build/client/_app/immutable/chunks/B6dKebLF.js.gz +0 -0
  562. package/packages/web/build/client/_app/immutable/chunks/B7tXsaud.js +0 -1
  563. package/packages/web/build/client/_app/immutable/chunks/B7tXsaud.js.br +0 -0
  564. package/packages/web/build/client/_app/immutable/chunks/B7tXsaud.js.gz +0 -0
  565. package/packages/web/build/client/_app/immutable/chunks/BCb2FcX-.js +0 -1
  566. package/packages/web/build/client/_app/immutable/chunks/BCb2FcX-.js.br +0 -0
  567. package/packages/web/build/client/_app/immutable/chunks/BCb2FcX-.js.gz +0 -0
  568. package/packages/web/build/client/_app/immutable/chunks/BEHPE67f.js +0 -1
  569. package/packages/web/build/client/_app/immutable/chunks/BEHPE67f.js.br +0 -4
  570. package/packages/web/build/client/_app/immutable/chunks/BEHPE67f.js.gz +0 -0
  571. package/packages/web/build/client/_app/immutable/chunks/BGRx4LH4.js +0 -1
  572. package/packages/web/build/client/_app/immutable/chunks/BGRx4LH4.js.br +0 -2
  573. package/packages/web/build/client/_app/immutable/chunks/BGRx4LH4.js.gz +0 -0
  574. package/packages/web/build/client/_app/immutable/chunks/BQcXnbnC.js +0 -1
  575. package/packages/web/build/client/_app/immutable/chunks/BQcXnbnC.js.br +0 -0
  576. package/packages/web/build/client/_app/immutable/chunks/BQcXnbnC.js.gz +0 -0
  577. package/packages/web/build/client/_app/immutable/chunks/BU1lfrAt.js +0 -1
  578. package/packages/web/build/client/_app/immutable/chunks/BU1lfrAt.js.br +0 -0
  579. package/packages/web/build/client/_app/immutable/chunks/BU1lfrAt.js.gz +0 -0
  580. package/packages/web/build/client/_app/immutable/chunks/BUCG0TDu.js +0 -1
  581. package/packages/web/build/client/_app/immutable/chunks/BUCG0TDu.js.br +0 -0
  582. package/packages/web/build/client/_app/immutable/chunks/BUCG0TDu.js.gz +0 -0
  583. package/packages/web/build/client/_app/immutable/chunks/BVy43h-D.js +0 -1
  584. package/packages/web/build/client/_app/immutable/chunks/BVy43h-D.js.br +0 -0
  585. package/packages/web/build/client/_app/immutable/chunks/BVy43h-D.js.gz +0 -0
  586. package/packages/web/build/client/_app/immutable/chunks/BhOcmMP6.js +0 -67
  587. package/packages/web/build/client/_app/immutable/chunks/BhOcmMP6.js.br +0 -0
  588. package/packages/web/build/client/_app/immutable/chunks/BhOcmMP6.js.gz +0 -0
  589. package/packages/web/build/client/_app/immutable/chunks/BnPnx1BS.js +0 -1
  590. package/packages/web/build/client/_app/immutable/chunks/BnPnx1BS.js.br +0 -0
  591. package/packages/web/build/client/_app/immutable/chunks/BnPnx1BS.js.gz +0 -0
  592. package/packages/web/build/client/_app/immutable/chunks/BtJh6BW0.js +0 -1
  593. package/packages/web/build/client/_app/immutable/chunks/BtJh6BW0.js.br +0 -0
  594. package/packages/web/build/client/_app/immutable/chunks/BtJh6BW0.js.gz +0 -0
  595. package/packages/web/build/client/_app/immutable/chunks/C238of6k.js +0 -1
  596. package/packages/web/build/client/_app/immutable/chunks/C238of6k.js.br +0 -0
  597. package/packages/web/build/client/_app/immutable/chunks/C238of6k.js.gz +0 -0
  598. package/packages/web/build/client/_app/immutable/chunks/C3AiOJdj.js +0 -5
  599. package/packages/web/build/client/_app/immutable/chunks/C3AiOJdj.js.br +0 -0
  600. package/packages/web/build/client/_app/immutable/chunks/C3AiOJdj.js.gz +0 -0
  601. package/packages/web/build/client/_app/immutable/chunks/C4Xqr7Fj.js +0 -1
  602. package/packages/web/build/client/_app/immutable/chunks/C4Xqr7Fj.js.br +0 -0
  603. package/packages/web/build/client/_app/immutable/chunks/C4Xqr7Fj.js.gz +0 -0
  604. package/packages/web/build/client/_app/immutable/chunks/C5iI_OsH.js +0 -1
  605. package/packages/web/build/client/_app/immutable/chunks/C5iI_OsH.js.br +0 -0
  606. package/packages/web/build/client/_app/immutable/chunks/C5iI_OsH.js.gz +0 -0
  607. package/packages/web/build/client/_app/immutable/chunks/CA_XVn89.js +0 -1
  608. package/packages/web/build/client/_app/immutable/chunks/CA_XVn89.js.br +0 -2
  609. package/packages/web/build/client/_app/immutable/chunks/CA_XVn89.js.gz +0 -0
  610. package/packages/web/build/client/_app/immutable/chunks/CAz7hU5S.js +0 -1
  611. package/packages/web/build/client/_app/immutable/chunks/CAz7hU5S.js.br +0 -0
  612. package/packages/web/build/client/_app/immutable/chunks/CAz7hU5S.js.gz +0 -0
  613. package/packages/web/build/client/_app/immutable/chunks/CCibcuvE.js +0 -1
  614. package/packages/web/build/client/_app/immutable/chunks/CCibcuvE.js.br +0 -0
  615. package/packages/web/build/client/_app/immutable/chunks/CCibcuvE.js.gz +0 -0
  616. package/packages/web/build/client/_app/immutable/chunks/CE2DpKar.js +0 -2
  617. package/packages/web/build/client/_app/immutable/chunks/CE2DpKar.js.br +0 -0
  618. package/packages/web/build/client/_app/immutable/chunks/CE2DpKar.js.gz +0 -0
  619. package/packages/web/build/client/_app/immutable/chunks/CGiFplSA.js +0 -1
  620. package/packages/web/build/client/_app/immutable/chunks/CGiFplSA.js.br +0 -0
  621. package/packages/web/build/client/_app/immutable/chunks/CGiFplSA.js.gz +0 -0
  622. package/packages/web/build/client/_app/immutable/chunks/CQSR9BkJ.js +0 -1
  623. package/packages/web/build/client/_app/immutable/chunks/CQSR9BkJ.js.br +0 -0
  624. package/packages/web/build/client/_app/immutable/chunks/CQSR9BkJ.js.gz +0 -0
  625. package/packages/web/build/client/_app/immutable/chunks/CXS58JOV.js +0 -1
  626. package/packages/web/build/client/_app/immutable/chunks/CXS58JOV.js.br +0 -0
  627. package/packages/web/build/client/_app/immutable/chunks/CXS58JOV.js.gz +0 -0
  628. package/packages/web/build/client/_app/immutable/chunks/C_rGKciz.js +0 -9
  629. package/packages/web/build/client/_app/immutable/chunks/C_rGKciz.js.br +0 -0
  630. package/packages/web/build/client/_app/immutable/chunks/C_rGKciz.js.gz +0 -0
  631. package/packages/web/build/client/_app/immutable/chunks/CaahyXtC.js +0 -1
  632. package/packages/web/build/client/_app/immutable/chunks/CaahyXtC.js.br +0 -0
  633. package/packages/web/build/client/_app/immutable/chunks/CaahyXtC.js.gz +0 -0
  634. package/packages/web/build/client/_app/immutable/chunks/CfHYzoiD.js +0 -1
  635. package/packages/web/build/client/_app/immutable/chunks/CfHYzoiD.js.br +0 -0
  636. package/packages/web/build/client/_app/immutable/chunks/CfHYzoiD.js.gz +0 -0
  637. package/packages/web/build/client/_app/immutable/chunks/ClEpdm9X.js +0 -1
  638. package/packages/web/build/client/_app/immutable/chunks/ClEpdm9X.js.br +0 -3
  639. package/packages/web/build/client/_app/immutable/chunks/ClEpdm9X.js.gz +0 -0
  640. package/packages/web/build/client/_app/immutable/chunks/ClSwhmjL.js +0 -1
  641. package/packages/web/build/client/_app/immutable/chunks/ClSwhmjL.js.br +0 -0
  642. package/packages/web/build/client/_app/immutable/chunks/ClSwhmjL.js.gz +0 -0
  643. package/packages/web/build/client/_app/immutable/chunks/ClppYdjP.js +0 -1
  644. package/packages/web/build/client/_app/immutable/chunks/ClppYdjP.js.br +0 -0
  645. package/packages/web/build/client/_app/immutable/chunks/ClppYdjP.js.gz +0 -0
  646. package/packages/web/build/client/_app/immutable/chunks/CmM-4RFG.js +0 -1
  647. package/packages/web/build/client/_app/immutable/chunks/CmM-4RFG.js.br +0 -0
  648. package/packages/web/build/client/_app/immutable/chunks/CmM-4RFG.js.gz +0 -0
  649. package/packages/web/build/client/_app/immutable/chunks/CpXfakoi.js +0 -1
  650. package/packages/web/build/client/_app/immutable/chunks/CpXfakoi.js.br +0 -0
  651. package/packages/web/build/client/_app/immutable/chunks/CpXfakoi.js.gz +0 -0
  652. package/packages/web/build/client/_app/immutable/chunks/CrCk-NyX.js +0 -1
  653. package/packages/web/build/client/_app/immutable/chunks/CrCk-NyX.js.br +0 -0
  654. package/packages/web/build/client/_app/immutable/chunks/CrCk-NyX.js.gz +0 -0
  655. package/packages/web/build/client/_app/immutable/chunks/CywApwhc.js +0 -1
  656. package/packages/web/build/client/_app/immutable/chunks/CywApwhc.js.br +0 -0
  657. package/packages/web/build/client/_app/immutable/chunks/CywApwhc.js.gz +0 -0
  658. package/packages/web/build/client/_app/immutable/chunks/D31s_g8n.js +0 -5
  659. package/packages/web/build/client/_app/immutable/chunks/D31s_g8n.js.br +0 -0
  660. package/packages/web/build/client/_app/immutable/chunks/D31s_g8n.js.gz +0 -0
  661. package/packages/web/build/client/_app/immutable/chunks/DDRoGIP9.js +0 -1
  662. package/packages/web/build/client/_app/immutable/chunks/DDRoGIP9.js.br +0 -0
  663. package/packages/web/build/client/_app/immutable/chunks/DDRoGIP9.js.gz +0 -0
  664. package/packages/web/build/client/_app/immutable/chunks/DGcS8KSS.js +0 -1
  665. package/packages/web/build/client/_app/immutable/chunks/DGcS8KSS.js.br +0 -0
  666. package/packages/web/build/client/_app/immutable/chunks/DGcS8KSS.js.gz +0 -0
  667. package/packages/web/build/client/_app/immutable/chunks/DK1UHLR-.js +0 -1
  668. package/packages/web/build/client/_app/immutable/chunks/DK1UHLR-.js.br +0 -0
  669. package/packages/web/build/client/_app/immutable/chunks/DK1UHLR-.js.gz +0 -0
  670. package/packages/web/build/client/_app/immutable/chunks/DZk-gkAU.js +0 -1
  671. package/packages/web/build/client/_app/immutable/chunks/DZk-gkAU.js.br +0 -0
  672. package/packages/web/build/client/_app/immutable/chunks/DZk-gkAU.js.gz +0 -0
  673. package/packages/web/build/client/_app/immutable/chunks/DeP17kbD.js +0 -318
  674. package/packages/web/build/client/_app/immutable/chunks/DeP17kbD.js.br +0 -0
  675. package/packages/web/build/client/_app/immutable/chunks/DeP17kbD.js.gz +0 -0
  676. package/packages/web/build/client/_app/immutable/chunks/DelhG4NG.js +0 -1
  677. package/packages/web/build/client/_app/immutable/chunks/DelhG4NG.js.br +0 -0
  678. package/packages/web/build/client/_app/immutable/chunks/DelhG4NG.js.gz +0 -0
  679. package/packages/web/build/client/_app/immutable/chunks/DmAdEzQs.js +0 -1
  680. package/packages/web/build/client/_app/immutable/chunks/DmAdEzQs.js.br +0 -0
  681. package/packages/web/build/client/_app/immutable/chunks/DmAdEzQs.js.gz +0 -0
  682. package/packages/web/build/client/_app/immutable/chunks/DuG8sfLq.js +0 -1
  683. package/packages/web/build/client/_app/immutable/chunks/DuG8sfLq.js.br +0 -0
  684. package/packages/web/build/client/_app/immutable/chunks/DuG8sfLq.js.gz +0 -0
  685. package/packages/web/build/client/_app/immutable/chunks/GTRzOEzD.js +0 -1
  686. package/packages/web/build/client/_app/immutable/chunks/GTRzOEzD.js.br +0 -0
  687. package/packages/web/build/client/_app/immutable/chunks/GTRzOEzD.js.gz +0 -0
  688. package/packages/web/build/client/_app/immutable/chunks/IjF4KE1B.js +0 -1
  689. package/packages/web/build/client/_app/immutable/chunks/IjF4KE1B.js.br +0 -0
  690. package/packages/web/build/client/_app/immutable/chunks/IjF4KE1B.js.gz +0 -0
  691. package/packages/web/build/client/_app/immutable/chunks/MApZQR0b.js +0 -1
  692. package/packages/web/build/client/_app/immutable/chunks/MApZQR0b.js.br +0 -0
  693. package/packages/web/build/client/_app/immutable/chunks/MApZQR0b.js.gz +0 -0
  694. package/packages/web/build/client/_app/immutable/chunks/N3oV-8Ie.js +0 -1
  695. package/packages/web/build/client/_app/immutable/chunks/N3oV-8Ie.js.br +0 -0
  696. package/packages/web/build/client/_app/immutable/chunks/N3oV-8Ie.js.gz +0 -0
  697. package/packages/web/build/client/_app/immutable/chunks/iiqQqDMt.js +0 -1
  698. package/packages/web/build/client/_app/immutable/chunks/iiqQqDMt.js.br +0 -0
  699. package/packages/web/build/client/_app/immutable/chunks/iiqQqDMt.js.gz +0 -0
  700. package/packages/web/build/client/_app/immutable/chunks/k3ZB4WVm.js +0 -1
  701. package/packages/web/build/client/_app/immutable/chunks/k3ZB4WVm.js.br +0 -0
  702. package/packages/web/build/client/_app/immutable/chunks/k3ZB4WVm.js.gz +0 -0
  703. package/packages/web/build/client/_app/immutable/chunks/pAzEohwE.js +0 -1
  704. package/packages/web/build/client/_app/immutable/chunks/pAzEohwE.js.br +0 -3
  705. package/packages/web/build/client/_app/immutable/chunks/pAzEohwE.js.gz +0 -0
  706. package/packages/web/build/client/_app/immutable/chunks/vmc6srO5.js +0 -1
  707. package/packages/web/build/client/_app/immutable/chunks/vmc6srO5.js.br +0 -4
  708. package/packages/web/build/client/_app/immutable/chunks/vmc6srO5.js.gz +0 -0
  709. package/packages/web/build/client/_app/immutable/chunks/ypBpP4nr.js +0 -1
  710. package/packages/web/build/client/_app/immutable/chunks/ypBpP4nr.js.br +0 -0
  711. package/packages/web/build/client/_app/immutable/chunks/ypBpP4nr.js.gz +0 -0
  712. package/packages/web/build/client/_app/immutable/entry/app.D9io9O7v.js +0 -2
  713. package/packages/web/build/client/_app/immutable/entry/app.D9io9O7v.js.br +0 -0
  714. package/packages/web/build/client/_app/immutable/entry/app.D9io9O7v.js.gz +0 -0
  715. package/packages/web/build/client/_app/immutable/entry/start.BgaOwPMP.js +0 -1
  716. package/packages/web/build/client/_app/immutable/entry/start.BgaOwPMP.js.br +0 -1
  717. package/packages/web/build/client/_app/immutable/entry/start.BgaOwPMP.js.gz +0 -0
  718. package/packages/web/build/client/_app/immutable/nodes/0.C9CR-5kd.js +0 -1
  719. package/packages/web/build/client/_app/immutable/nodes/0.C9CR-5kd.js.br +0 -0
  720. package/packages/web/build/client/_app/immutable/nodes/0.C9CR-5kd.js.gz +0 -0
  721. package/packages/web/build/client/_app/immutable/nodes/1.DikBrROv.js +0 -1
  722. package/packages/web/build/client/_app/immutable/nodes/1.DikBrROv.js.br +0 -0
  723. package/packages/web/build/client/_app/immutable/nodes/1.DikBrROv.js.gz +0 -0
  724. package/packages/web/build/client/_app/immutable/nodes/10.3t9WnHvs.js +0 -1
  725. package/packages/web/build/client/_app/immutable/nodes/10.3t9WnHvs.js.br +0 -0
  726. package/packages/web/build/client/_app/immutable/nodes/10.3t9WnHvs.js.gz +0 -0
  727. package/packages/web/build/client/_app/immutable/nodes/11.Op2wvZXP.js +0 -4
  728. package/packages/web/build/client/_app/immutable/nodes/11.Op2wvZXP.js.br +0 -0
  729. package/packages/web/build/client/_app/immutable/nodes/11.Op2wvZXP.js.gz +0 -0
  730. package/packages/web/build/client/_app/immutable/nodes/12.CjrjNFKj.js +0 -1
  731. package/packages/web/build/client/_app/immutable/nodes/12.CjrjNFKj.js.br +0 -0
  732. package/packages/web/build/client/_app/immutable/nodes/12.CjrjNFKj.js.gz +0 -0
  733. package/packages/web/build/client/_app/immutable/nodes/13.CiddqUIq.js +0 -1
  734. package/packages/web/build/client/_app/immutable/nodes/13.CiddqUIq.js.br +0 -0
  735. package/packages/web/build/client/_app/immutable/nodes/13.CiddqUIq.js.gz +0 -0
  736. package/packages/web/build/client/_app/immutable/nodes/14.D189pX_R.js +0 -2
  737. package/packages/web/build/client/_app/immutable/nodes/14.D189pX_R.js.br +0 -0
  738. package/packages/web/build/client/_app/immutable/nodes/14.D189pX_R.js.gz +0 -0
  739. package/packages/web/build/client/_app/immutable/nodes/15.L9U9QVzo.js +0 -1
  740. package/packages/web/build/client/_app/immutable/nodes/15.L9U9QVzo.js.br +0 -0
  741. package/packages/web/build/client/_app/immutable/nodes/15.L9U9QVzo.js.gz +0 -0
  742. package/packages/web/build/client/_app/immutable/nodes/16.DSMrlY8n.js +0 -1
  743. package/packages/web/build/client/_app/immutable/nodes/16.DSMrlY8n.js.br +0 -0
  744. package/packages/web/build/client/_app/immutable/nodes/16.DSMrlY8n.js.gz +0 -0
  745. package/packages/web/build/client/_app/immutable/nodes/17.Bbk_u6OJ.js +0 -46
  746. package/packages/web/build/client/_app/immutable/nodes/17.Bbk_u6OJ.js.br +0 -0
  747. package/packages/web/build/client/_app/immutable/nodes/17.Bbk_u6OJ.js.gz +0 -0
  748. package/packages/web/build/client/_app/immutable/nodes/18.DV_cA_3-.js +0 -1
  749. package/packages/web/build/client/_app/immutable/nodes/18.DV_cA_3-.js.br +0 -0
  750. package/packages/web/build/client/_app/immutable/nodes/18.DV_cA_3-.js.gz +0 -0
  751. package/packages/web/build/client/_app/immutable/nodes/2.DJvpS8CT.js +0 -1
  752. package/packages/web/build/client/_app/immutable/nodes/2.DJvpS8CT.js.br +0 -0
  753. package/packages/web/build/client/_app/immutable/nodes/2.DJvpS8CT.js.gz +0 -0
  754. package/packages/web/build/client/_app/immutable/nodes/4.v0gFXgkE.js +0 -2
  755. package/packages/web/build/client/_app/immutable/nodes/4.v0gFXgkE.js.br +0 -0
  756. package/packages/web/build/client/_app/immutable/nodes/4.v0gFXgkE.js.gz +0 -0
  757. package/packages/web/build/client/_app/immutable/nodes/5.CvNd-aT1.js +0 -1
  758. package/packages/web/build/client/_app/immutable/nodes/5.CvNd-aT1.js.br +0 -0
  759. package/packages/web/build/client/_app/immutable/nodes/5.CvNd-aT1.js.gz +0 -0
  760. package/packages/web/build/client/_app/immutable/nodes/6.Cwb-H-e-.js +0 -2
  761. package/packages/web/build/client/_app/immutable/nodes/6.Cwb-H-e-.js.br +0 -0
  762. package/packages/web/build/client/_app/immutable/nodes/6.Cwb-H-e-.js.gz +0 -0
  763. package/packages/web/build/client/_app/immutable/nodes/7.BesKsRyM.js +0 -1
  764. package/packages/web/build/client/_app/immutable/nodes/7.BesKsRyM.js.br +0 -0
  765. package/packages/web/build/client/_app/immutable/nodes/7.BesKsRyM.js.gz +0 -0
  766. package/packages/web/build/client/_app/immutable/nodes/8.IWTTmi0T.js +0 -1
  767. package/packages/web/build/client/_app/immutable/nodes/8.IWTTmi0T.js.br +0 -0
  768. package/packages/web/build/client/_app/immutable/nodes/8.IWTTmi0T.js.gz +0 -0
  769. package/packages/web/build/client/_app/immutable/nodes/9.BksbXEiN.js +0 -1
  770. package/packages/web/build/client/_app/immutable/nodes/9.BksbXEiN.js.br +0 -0
  771. package/packages/web/build/client/_app/immutable/nodes/9.BksbXEiN.js.gz +0 -0
  772. package/packages/web/build/server/chunks/chunks/AssistantAvatar.js-BOElnrYl.js +0 -294
  773. package/packages/web/build/server/chunks/chunks/AvatarPicker.js-CLhSkMaB.js +0 -136
  774. package/packages/web/build/server/chunks/chunks/Composer.js-BbcT-FLv.js +0 -333
  775. package/packages/web/build/server/chunks/chunks/ComposerDock.js-B26-qji-.js +0 -58
  776. package/packages/web/build/server/chunks/chunks/CopyButton.js-Bg6aJO9i.js +0 -81
  777. package/packages/web/build/server/chunks/chunks/DotGrid.js-DEty8Ftx.js +0 -108
  778. package/packages/web/build/server/chunks/chunks/MemoryChangeItem.js-XSzCkKCr.js +0 -2588
  779. package/packages/web/build/server/chunks/chunks/ModelMenu.js-DyvxWk4C.js +0 -650
  780. package/packages/web/build/server/chunks/chunks/MoveToFolderMenu.js-BkRCW9eh.js +0 -288
  781. package/packages/web/build/server/chunks/chunks/NewChatForm.js-40tqChFh.js +0 -307
  782. package/packages/web/build/server/chunks/chunks/NewFolderDialog.js-C6CjVSY0.js +0 -192
  783. package/packages/web/build/server/chunks/chunks/Notifications.js-CQqL8zeJ.js +0 -762
  784. package/packages/web/build/server/chunks/chunks/PageHeader.js-BgCv8CGm.js +0 -59
  785. package/packages/web/build/server/chunks/chunks/RenameFolderDialog.js-BgF-2T2D.js +0 -258
  786. package/packages/web/build/server/chunks/chunks/StepIcon.js-ClUo5irL.js +0 -38
  787. package/packages/web/build/server/chunks/chunks/TopBar.js-nYKfnv4T.js +0 -34
  788. package/packages/web/build/server/chunks/chunks/TypedText.js-DM0Ozjdc.js +0 -62
  789. package/packages/web/build/server/chunks/chunks/UserAvatar.js-DKnmWp86.js +0 -24
  790. package/packages/web/build/server/chunks/chunks/UserMenu.js-CLVbCOpM.js +0 -1499
  791. package/packages/web/build/server/chunks/chunks/access.js-CMaS81rW.js +0 -40
  792. package/packages/web/build/server/chunks/chunks/accounts.js--GU4-Jf5.js +0 -26
  793. package/packages/web/build/server/chunks/chunks/alert-dialog.js-CZD6TyzD.js +0 -505
  794. package/packages/web/build/server/chunks/chunks/auth.js-CjtH41kh.js +0 -20064
  795. package/packages/web/build/server/chunks/chunks/avatars.js-qKyBQC6I.js +0 -496
  796. package/packages/web/build/server/chunks/chunks/badge.js-DhrZz9tJ.js +0 -38
  797. package/packages/web/build/server/chunks/chunks/camera.js-DMildJpv.js +0 -19
  798. package/packages/web/build/server/chunks/chunks/check.js-CgqvmEKJ.js +0 -15
  799. package/packages/web/build/server/chunks/chunks/chevron-left.js-DrLivp1c.js +0 -15
  800. package/packages/web/build/server/chunks/chunks/chevron-right.js-BVi8OuAb.js +0 -15
  801. package/packages/web/build/server/chunks/chunks/chevrons-up-down.js-BKkCIwCT.js +0 -15
  802. package/packages/web/build/server/chunks/chunks/client.js-Dg5neIp5.js +0 -120
  803. package/packages/web/build/server/chunks/chunks/clock.js-BK9UDxCS.js +0 -19
  804. package/packages/web/build/server/chunks/chunks/collapsible.js-QcUf1Ekr.js +0 -410
  805. package/packages/web/build/server/chunks/chunks/command.js-qzkTIb4n.js +0 -2231
  806. package/packages/web/build/server/chunks/chunks/dialog.js-DATXmio9.js +0 -544
  807. package/packages/web/build/server/chunks/chunks/dist.js-CHzkIw-w.js +0 -600
  808. package/packages/web/build/server/chunks/chunks/dist2.js-BypRVH9n.js +0 -347
  809. package/packages/web/build/server/chunks/chunks/dist3.js-uSfOYmy-.js +0 -19547
  810. package/packages/web/build/server/chunks/chunks/download.js-CrFy9e4X.js +0 -19
  811. package/packages/web/build/server/chunks/chunks/dropdown-menu.js-BMbh502s.js +0 -2396
  812. package/packages/web/build/server/chunks/chunks/eraser.js-BU4dlvFH.js +0 -15
  813. package/packages/web/build/server/chunks/chunks/factory.js-CQLK42R-.js +0 -2344
  814. package/packages/web/build/server/chunks/chunks/folder-input.js-DkjPvOkW.js +0 -19
  815. package/packages/web/build/server/chunks/chunks/forms.js-JM_GpxQF.js +0 -4052
  816. package/packages/web/build/server/chunks/chunks/hidden-input.js-CIt9W_5y.js +0 -47
  817. package/packages/web/build/server/chunks/chunks/i18n.js-Cakuk6U0.js +0 -6543
  818. package/packages/web/build/server/chunks/chunks/internal2.js-CM6RC5j4.js +0 -1135
  819. package/packages/web/build/server/chunks/chunks/key-round.js-BFVR2_CE.js +0 -20
  820. package/packages/web/build/server/chunks/chunks/memory.js-B4MEEi_Z.js +0 -26
  821. package/packages/web/build/server/chunks/chunks/message-circle.js-D49Sk0Wt.js +0 -15
  822. package/packages/web/build/server/chunks/chunks/motion.js-BGVcte_O.js +0 -224
  823. package/packages/web/build/server/chunks/chunks/paths.js-vTKfgV_W.js +0 -19
  824. package/packages/web/build/server/chunks/chunks/pencil.js-DrsRjIqk.js +0 -15
  825. package/packages/web/build/server/chunks/chunks/plus.js-E-pmHa3v.js +0 -15
  826. package/packages/web/build/server/chunks/chunks/sdk.js-B2ztN1Lk.js +0 -42918
  827. package/packages/web/build/server/chunks/chunks/select.js-CADiX1B7.js +0 -1965
  828. package/packages/web/build/server/chunks/chunks/shield-check.js-CifO8sPn.js +0 -29
  829. package/packages/web/build/server/chunks/chunks/sidebar.js-CjZAbET4.js +0 -1498
  830. package/packages/web/build/server/chunks/chunks/square-pen.js-CMKwoVdr.js +0 -20
  831. package/packages/web/build/server/chunks/chunks/src.js-DlynI0hv.js +0 -27000
  832. package/packages/web/build/server/chunks/chunks/state.js-DjG_xJ6v.js +0 -67
  833. package/packages/web/build/server/chunks/chunks/switch.js-BykxjriZ.js +0 -283
  834. package/packages/web/build/server/chunks/chunks/terminal.js-D6dBIpDn.js +0 -15
  835. package/packages/web/build/server/chunks/chunks/textarea.js-B5-NW0l1.js +0 -25
  836. package/packages/web/build/server/chunks/chunks/tint.js-DjJ-o_oc.js +0 -165
  837. package/packages/web/build/server/chunks/chunks/tooltip.js-CefNT6DH.js +0 -5863
  838. package/packages/web/build/server/chunks/chunks/usage.js-DNQuJpUU.js +0 -27
  839. package/packages/web/build/server/chunks/chunks/utils2.js-D1jvsxxx.js +0 -1167
  840. package/packages/web/build/server/chunks/chunks/zod.js-CWybfdic.js +0 -18824
  841. package/packages/web/build/server/chunks/chunks/zod2.js-D_b3bp3T.js +0 -4
  842. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/commands/_server.ts.js-DkJz0GER.js +0 -53
  843. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/continue/_server.ts.js-DwqrktqL.js +0 -44
  844. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/effort/_server.ts.js-BmjT-Ztn.js +0 -45
  845. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/events/_server.ts.js-B5EB81bi.js +0 -72
  846. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/folder/_server.ts.js-Dw0QpRlp.js +0 -53
  847. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/media/_mediaId_/_server.ts.js-Bx0OedB1.js +0 -51
  848. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/messages/_server.ts.js-DDYKj9gS.js +0 -56
  849. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/preset/_server.ts.js-DEJaoQV0.js +0 -49
  850. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/stop/_server.ts.js-Dw7fPXTJ.js +0 -42
  851. package/packages/web/build/server/chunks/entries/endpoints/api/c/_id_/typing/_server.ts.js-KhlfQb5X.js +0 -48
  852. package/packages/web/build/server/chunks/entries/endpoints/api/card/changes/_id_/keep/_server.ts.js-CpO5Tw0v.js +0 -57
  853. package/packages/web/build/server/chunks/entries/endpoints/api/chatgpt/sign-in/_server.ts.js-CGa-3Tfb.js +0 -72
  854. package/packages/web/build/server/chunks/entries/endpoints/api/events/_server.ts.js-BBNo5Duy.js +0 -83
  855. package/packages/web/build/server/chunks/entries/endpoints/api/hooks/_token_/_server.ts.js-DB0HkrPc.js +0 -48
  856. package/packages/web/build/server/chunks/entries/endpoints/api/me/_server.ts.js-b6-lm_Ed.js +0 -51
  857. package/packages/web/build/server/chunks/entries/endpoints/api/me/picture/_server.ts.js-CXaSRFEH.js +0 -59
  858. package/packages/web/build/server/chunks/entries/endpoints/api/models/_server.ts.js-lvH7AJAs.js +0 -55
  859. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/_id_/continue/_server.ts.js-DApMRDk0.js +0 -49
  860. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/_id_/dismiss/_server.ts.js-CrvUxZUu.js +0 -41
  861. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/clear/_server.ts.js-UXu_qsCl.js +0 -42
  862. package/packages/web/build/server/chunks/entries/endpoints/api/notifications/seen/_server.ts.js-DtA3xn3g.js +0 -42
  863. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/folders/_folder_/files/_file_/_server.ts.js-DysFASqZ.js +0 -55
  864. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/folders/_server.ts.js-BDEdyBpH.js +0 -56
  865. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/memory/_id_/undo/_server.ts.js-BZEyhdCW.js +0 -57
  866. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/running/_server.ts.js-NEH54dIz.js +0 -78
  867. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/suggestions/_server.ts.js-BhqMxAjp.js +0 -52
  868. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/templates/_id_/cover/_server.ts.js-rw9q81We.js +0 -58
  869. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/uploads/_id_/_server.ts.js-B9fQriGr.js +0 -43
  870. package/packages/web/build/server/chunks/entries/endpoints/api/p/_slug_/uploads/_server.ts.js-D4v_ixwU.js +0 -71
  871. package/packages/web/build/server/chunks/entries/endpoints/api/pictures/_sha256_/_server.ts.js-YGGiBW89.js +0 -54
  872. package/packages/web/build/server/chunks/entries/endpoints/logout/_server.ts.js-D85x_95g.js +0 -45
  873. package/packages/web/build/server/chunks/entries/fallbacks/error.svelte.js-Cb-94Mjg.js +0 -22
  874. package/packages/web/build/server/chunks/entries/hooks.server.js-b1SYQXEi.js +0 -2983
  875. package/packages/web/build/server/chunks/entries/pages/_layout.server.ts.js-vgQ7FD_z.js +0 -41
  876. package/packages/web/build/server/chunks/entries/pages/_layout.svelte.js-BhzEqF95.js +0 -77
  877. package/packages/web/build/server/chunks/entries/pages/_page.server.ts.js-BybKXqua.js +0 -27
  878. package/packages/web/build/server/chunks/entries/pages/admin/_page.server.ts.js-Co8N9XsI.js +0 -345
  879. package/packages/web/build/server/chunks/entries/pages/admin/_page.svelte.js-C9m37bww.js +0 -2307
  880. package/packages/web/build/server/chunks/entries/pages/admin/people/_page.server.ts.js-DsxljIFN.js +0 -130
  881. package/packages/web/build/server/chunks/entries/pages/admin/people/_page.svelte.js-CL25VFst.js +0 -574
  882. package/packages/web/build/server/chunks/entries/pages/card/_page.server.ts.js-fZyd9NoG.js +0 -75
  883. package/packages/web/build/server/chunks/entries/pages/card/_page.svelte.js-BtRHLxTx.js +0 -372
  884. package/packages/web/build/server/chunks/entries/pages/invite/_token_/_page.server.ts.js-B8OQFrQp.js +0 -63
  885. package/packages/web/build/server/chunks/entries/pages/invite/_token_/_page.svelte.js-hd2quW3N.js +0 -125
  886. package/packages/web/build/server/chunks/entries/pages/login/_page.server.ts.js-DOcT1tgp.js +0 -42
  887. package/packages/web/build/server/chunks/entries/pages/login/_page.svelte.js-C5Auxspy.js +0 -74
  888. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_layout.server.ts.js-BvbpH7aa.js +0 -53
  889. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_layout.svelte.js-B10sZUKN.js +0 -1900
  890. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_page.server.ts.js-C3Y9wk8O.js +0 -78
  891. package/packages/web/build/server/chunks/entries/pages/p/_slug_/_page.svelte.js-CoRMdrPQ.js +0 -152
  892. package/packages/web/build/server/chunks/entries/pages/p/_slug_/automations/_page.server.ts.js-BbMLCUDA.js +0 -269
  893. package/packages/web/build/server/chunks/entries/pages/p/_slug_/automations/_page.svelte.js-DPU6YXHJ.js +0 -414
  894. package/packages/web/build/server/chunks/entries/pages/p/_slug_/c/_id_/_page.server.ts.js-DRgVXOxV.js +0 -73
  895. package/packages/web/build/server/chunks/entries/pages/p/_slug_/c/_id_/_page.svelte.js-Ck3wDf_F.js +0 -2392
  896. package/packages/web/build/server/chunks/entries/pages/p/_slug_/f/_folder_/_page.server.ts.js-DJVR3n50.js +0 -102
  897. package/packages/web/build/server/chunks/entries/pages/p/_slug_/f/_folder_/_page.svelte.js-CLG-0wVy.js +0 -323
  898. package/packages/web/build/server/chunks/entries/pages/p/_slug_/images/_page.server.ts.js-BbBFc7eX.js +0 -145
  899. package/packages/web/build/server/chunks/entries/pages/p/_slug_/images/_page.svelte.js-Ta37_M_i.js +0 -513
  900. package/packages/web/build/server/chunks/entries/pages/p/_slug_/memory/_page.server.ts.js-CkQszCsV.js +0 -113
  901. package/packages/web/build/server/chunks/entries/pages/p/_slug_/memory/_page.svelte.js-DxgpLCGC.js +0 -968
  902. package/packages/web/build/server/chunks/entries/pages/p/_slug_/settings/_page.server.ts.js-ryYts05B.js +0 -106
  903. package/packages/web/build/server/chunks/entries/pages/p/_slug_/settings/_page.svelte.js-BvTcTRJQ.js +0 -584
  904. package/packages/web/build/server/chunks/entries/pages/p/_slug_/skills/_page.server.ts.js-BzVe8LHd.js +0 -45
  905. package/packages/web/build/server/chunks/entries/pages/p/_slug_/skills/_page.svelte.js-CJHcqQH5.js +0 -132
  906. package/packages/web/build/server/chunks/entries/pages/p/_slug_/welcome/_page.server.ts.js-onzZAX1Z.js +0 -134
  907. package/packages/web/build/server/chunks/entries/pages/p/_slug_/welcome/_page@.svelte.js-BnGdU_h4.js +0 -223
  908. package/packages/web/build/server/chunks/entries/pages/profiles/_page.server.ts.js-hGcjHBhU.js +0 -47
  909. package/packages/web/build/server/chunks/entries/pages/profiles/_page.svelte.js-BzuBRwOF.js +0 -240
  910. package/packages/web/build/server/chunks/handler-D2eW2iLl.js +0 -1735
  911. package/packages/web/build/server/chunks/index.js-DqF1GLH4.js +0 -3700
  912. package/packages/web/build/server/chunks/manifest.js-B7llprKy.js +0 -387
  913. package/packages/web/build/server/chunks/nodes/0.js-CIzCXL5D.js +0 -42
  914. package/packages/web/build/server/chunks/nodes/1.js-DRjbmxYH.js +0 -9
  915. package/packages/web/build/server/chunks/nodes/10.js-CDm72w6Y.js +0 -44
  916. package/packages/web/build/server/chunks/nodes/11.js-OnJr6Cw4.js +0 -44
  917. package/packages/web/build/server/chunks/nodes/12.js-CSZo_AVI.js +0 -44
  918. package/packages/web/build/server/chunks/nodes/13.js-B4R788aB.js +0 -44
  919. package/packages/web/build/server/chunks/nodes/14.js-l-KO8B-h.js +0 -44
  920. package/packages/web/build/server/chunks/nodes/15.js-CAtECzGW.js +0 -44
  921. package/packages/web/build/server/chunks/nodes/16.js-CmTEXhAq.js +0 -44
  922. package/packages/web/build/server/chunks/nodes/17.js-Gg-NPBzB.js +0 -44
  923. package/packages/web/build/server/chunks/nodes/18.js-BLTnO9SS.js +0 -44
  924. package/packages/web/build/server/chunks/nodes/2.js-CDq1qE_r.js +0 -46
  925. package/packages/web/build/server/chunks/nodes/3.js-BVsDtBU2.js +0 -45
  926. package/packages/web/build/server/chunks/nodes/4.js-Cpe8-dWC.js +0 -45
  927. package/packages/web/build/server/chunks/nodes/5.js-DFdbH2Du.js +0 -46
  928. package/packages/web/build/server/chunks/nodes/6.js-yJdLU7lq.js +0 -44
  929. package/packages/web/build/server/chunks/nodes/7.js-BoganRn1.js +0 -50
  930. package/packages/web/build/server/chunks/nodes/8.js-Diubq0AZ.js +0 -49
  931. package/packages/web/build/server/chunks/nodes/9.js-DXoagKbS.js +0 -46
  932. /package/packages/web/build/client/_app/immutable/assets/{13.DiHYpJ-g.css → 15.DiHYpJ-g.css} +0 -0
  933. /package/packages/web/build/client/_app/immutable/assets/{13.DiHYpJ-g.css.br → 15.DiHYpJ-g.css.br} +0 -0
  934. /package/packages/web/build/client/_app/immutable/assets/{13.DiHYpJ-g.css.gz → 15.DiHYpJ-g.css.gz} +0 -0
  935. /package/packages/web/build/client/_app/immutable/assets/{17.D8mCg27h.css → 19.D8mCg27h.css} +0 -0
  936. /package/packages/web/build/client/_app/immutable/assets/{17.D8mCg27h.css.br → 19.D8mCg27h.css.br} +0 -0
  937. /package/packages/web/build/client/_app/immutable/assets/{17.D8mCg27h.css.gz → 19.D8mCg27h.css.gz} +0 -0
@@ -0,0 +1,3463 @@
1
+ import { d as building } from '../chunks/internal.js-BAV8263N.js';
2
+ import { z as installCliShim, A as recoverAfterRestart, B as startScheduler, D as startUpdateChecks, E as holdMcpConnections, F as paths, G as viewImage, V as ViewLimitError, H as profileSkillsDir, I as createSkill, J as getProfileBySlug, K as listProfileSkills, L as scanSkills, M as setSkillsEnabled, N as addPreset, O as effectiveContextWindow, P as isProvider$1, Q as listPresets, R as isCustomProvider, S as splitModel, U as editPreset, W as removePreset, X as setDefaultPreset, Y as getDefaultPreset, Z as generatePassword, _ as createUser, $ as setPassword, a0 as setAdmin, a1 as deleteUser, a2 as createInvite, a3 as publicOrigin, r as readConfig, a4 as listUsers, a5 as userPictureFile, a6 as updateConfig, a7 as findCustomProvider, a8 as removeCustomProvider, a9 as listCustomProviders, aa as API_KEYS, ab as isApiKeyProvider, ac as removeApiKey, ad as apiKeyStatuses, ae as claudeExecutable, af as chatGptPlanStatus, ag as nolunePlanStatus, ah as imageGenerationStatus, ai as embeddingStatus, aj as describeCommandSafety, ak as describeUpdates, al as isCommandMode, am as saveCommandMode, an as findPreset, ao as saveSafetyPreset, ap as forgetRelease, aq as saveIdleCompaction, ar as idleCompactionChanged, as as parseEmbeddingSetting, at as saveEmbeddingSetting, au as embeddingProblem, av as initConfig, g as getDb, aw as configExists, ax as requestBackgroundStop, ay as describeBackground, az as listSubagents, aA as getConversation, aB as subagentLogPath, aC as requestSubagentStop, aD as steerSubagent, aE as subagentResult, aF as EFFORTS, aG as runSubagent, aH as resolvePreset, aI as getTrigger, aJ as queueWake, aK as MAX_SOUL_CHARS, aL as writeSoul, aM as readSoulFile, aN as MAX_CARD_CHARS, aO as cardOf, aP as cardFiles, aQ as findUser, aR as readCard, aS as MAX_PINNED_CHARS, aT as setLearnFromChats, aU as mergeProfileNotes, aV as moveProfileNote, aW as removeMemoryNote, aX as writeMemoryNote, aY as forgetInCard, aZ as forgetMemoryFact, a_ as replaceInCard, a$ as replaceInMemory, b0 as factLines, b1 as addToCard, b2 as addMemoryFact, b3 as profileCard, b4 as readMemoryNote, b5 as profileCards, b6 as searchMemory, b7 as listMemoryFiles, b8 as membersWithNotes, b9 as profileMemoryDir, ba as isPinnedNote, bb as formatLocalTime, bc as updateTrigger, bd as describeWhen, be as deleteTrigger, bf as setTriggerEnabled, bg as queueRun, bh as getPreset, bi as getProfile, bj as listRuns, bk as listProfiles, bl as listTriggers, bm as createTrigger, bn as signOutMcpServer, bo as removeMcpServer, bp as setProfileAvatar, bq as providerFor, br as signOutChatGpt, bs as listChatGptModels, bt as signOutNolunePlan, bu as listModels$1, bv as checkCustomProvider, bw as CustomProviderError, bx as normalizeApiKey, by as checkApiKey, bz as saveApiKey, bA as ApiKeyError, bB as idleCompactionMinutes, bC as claudePlanStatus, bD as claudeSignInCommand, bE as appManaged, bF as MAX_MEDIA_BYTES, bG as WEB_RECENT, bH as searchWeb, bI as readWebPage, bJ as parseImageSize, bK as configuredImageModel, bL as generateImages, bM as inspectImage, bN as findSubagent, bO as checkCardWrite, bP as recordAgentCardChanges, bQ as findTrigger, bR as parseRunAt, bS as isFinished, bT as webhookUrl, bU as callMcpTool, bV as McpServerError, bW as mcpResultText, bX as listMcpTools, bY as listMcpServers, bZ as startMcpSignIn, b_ as signInRedirectUrl, b$ as isMcpAddress, c0 as saveCustomProvider, c1 as isValidName, c2 as IMAGE_BACKGROUNDS, c3 as IMAGE_FORMATS, c4 as mcpServerNameProblem, c5 as parseMcpServer, c6 as checkMcpServer, c7 as describeFromServer, c8 as saveMcpServer, c9 as startChatGptSignIn, ca as startNolunePlanSignIn, cb as GATEWAYS_PATH, cc as CONNECT_PATH, cd as cancelChatGptSignIn, ce as finishChatGptSignIn, cf as chatGptSignInState, cg as cancelNolunePlanSignIn, ch as cliCommand, ci as CLOSE, cj as parseImageModel } from '../chunks/src.js-OCqmpAMD.js';
3
+ import { A as AVATARS } from '../chunks/avatars.js-C3tB5SlK.js';
4
+ import { g as getAuth, s as svelteKitHandler } from '../chunks/auth.js-D3TBJ-bo.js';
5
+ import { i as isCardPath, a as categoryOf, M as MEMORY_CATEGORIES } from '../chunks/memory-categories.js-DDXxnICw.js';
6
+ import { t as translations } from '../chunks/i18n.js-DOMtD7OV.js';
7
+ import { p as parsePreferences, P as PREFERENCES_COOKIE, m as matchLocale } from '../chunks/preferences.svelte.js-B5ab6njf.js';
8
+ import { v as error, A as redirect } from '../chunks/utils.js-CLRDf9Jk.js';
9
+ import { rmSync, mkdirSync, chmodSync, existsSync, writeFileSync, unlinkSync, readFileSync } from 'node:fs';
10
+ import { userInfo, tmpdir, homedir } from 'node:os';
11
+ import { dirname, resolve, join, extname, isAbsolute } from 'node:path';
12
+ import { pathToFileURL } from 'node:url';
13
+ import http from 'node:http';
14
+ import { spawn, spawnSync } from 'node:child_process';
15
+ import { parseArgs, format } from 'node:util';
16
+ import { createServer, connect } from 'node:net';
17
+ import { Duplex } from 'node:stream';
18
+ import { setTimeout as setTimeout$1 } from 'node:timers/promises';
19
+ import { createInterface } from 'node:readline/promises';
20
+ import http2 from 'node:http2';
21
+ import '../chunks/rolldown-runtime.js-DAzahgG2.js';
22
+ import 'node:module';
23
+ import '../chunks/media-refs.js-q0nPxUYL.js';
24
+ import '../chunks/coerce.js-DyM7nUNl.js';
25
+ import '../chunks/transcript.js-BZDJbNRI.js';
26
+ import '../chunks/memory-export.js-JzBYtuXI.js';
27
+ import '../chunks/articles.js-DI9tx0xR.js';
28
+ import '../chunks/schedule.js-CGJAo63f.js';
29
+ import 'node:crypto';
30
+ import 'better-sqlite3';
31
+ import 'node:dns';
32
+ import 'node:https';
33
+ import 'node:stream/promises';
34
+ import 'node:zlib';
35
+ import 'node:process';
36
+ import 'node:string_decoder';
37
+ import 'node:events';
38
+ import '../chunks/shared.js-1MmsW0Qq.js';
39
+ import '../chunks/uneval.js-NmnccxCg.js';
40
+ import '../chunks/internal2.js-BmQF3qCw.js';
41
+ import '../chunks/server.js-BAHAkSRU.js';
42
+ import '../chunks/factory.js-DwhAilJf.js';
43
+ import '../chunks/routing.js-BuS-2pZB.js';
44
+ import 'node:fs/promises';
45
+
46
+ //#region ../cli/src/io.ts
47
+ function createIo(host) {
48
+ return {
49
+ ...host,
50
+ log: (...args) => host.stdout(`${format(...args)}\n`),
51
+ error: (...args) => host.stderr(`${format(...args)}\n`)
52
+ };
53
+ }
54
+ /** A mistake in how the command was called, or something it can't do, in words for the caller. */
55
+ function fail$1(message) {
56
+ throw new Error(message);
57
+ }
58
+ //#endregion
59
+ //#region ../cli/src/protocol.ts
60
+ /**
61
+ * Commands that always run in a process of their own: they prompt at a terminal, run the
62
+ * gateway or manage its service.
63
+ */
64
+ var LOCAL_ONLY = /* @__PURE__ */ new Set([
65
+ "setup",
66
+ "start",
67
+ "service",
68
+ "init"
69
+ ]);
70
+ /** Larger messages end the connection: stdin is the only big one, and notes are far smaller. */
71
+ var MAX_MESSAGE_CHARS = 16777216;
72
+ /** Sends a message, unless the other side has gone. */
73
+ function send(socket, message) {
74
+ if (socket.writable) socket.write(`${JSON.stringify(message)}\n`);
75
+ }
76
+ /** Calls `onMessage` with each message as it arrives. Anything malformed ends the connection. */
77
+ function receive(socket, onMessage) {
78
+ let buffer = "";
79
+ socket.setEncoding("utf8");
80
+ socket.on("data", (chunk) => {
81
+ buffer += chunk;
82
+ for (let end = buffer.indexOf("\n"); end !== -1; end = buffer.indexOf("\n")) {
83
+ if (socket.destroyed) return;
84
+ const line = buffer.slice(0, end);
85
+ buffer = buffer.slice(end + 1);
86
+ let message;
87
+ try {
88
+ message = JSON.parse(line);
89
+ } catch {
90
+ socket.destroy();
91
+ return;
92
+ }
93
+ if (typeof message !== "object" || message === null) {
94
+ socket.destroy();
95
+ return;
96
+ }
97
+ try {
98
+ onMessage(message);
99
+ } catch (err) {
100
+ console.error("[nolune] a malformed message on the nolune command socket:", err);
101
+ socket.destroy();
102
+ return;
103
+ }
104
+ }
105
+ if (buffer.length > MAX_MESSAGE_CHARS) socket.destroy();
106
+ });
107
+ }
108
+ //#endregion
109
+ //#region ../cli/src/agent.ts
110
+ var AGENT_HELP = `Subagents (in agent commands: agents that work on a task in the background, in a
111
+ conversation of their own that starts with only the task)
112
+ nolune agent run [<id>] --prompt "<task>" [--preset NAME] [--effort LEVEL]
113
+ start a subagent, or give one that finished more work;
114
+ prints its id and its log file (--prompt - reads stdin).
115
+ It uses this chat's model and reasoning unless given:
116
+ --preset takes a name from \`nolune preset list\`, --effort
117
+ one of ${EFFORTS.join(", ")}
118
+ nolune agent watch <id> wait until it's done and print its last message; run
119
+ it with run_in_background to be told when it's done
120
+ nolune agent steer <id> --prompt "<message>"
121
+ message a subagent while it works
122
+ nolune agent stop <id>
123
+ nolune agent list`;
124
+ var WATCH_POLL_MS = 1e3;
125
+ function parentId(io) {
126
+ const id = io.env.NOLUNE_CONVERSATION_ID;
127
+ if (!id) throw new Error("`nolune agent` only works in the agent's commands: subagents belong to the conversation that starts them.");
128
+ return id;
129
+ }
130
+ async function promptFrom(io, value, usage) {
131
+ const text = (value === "-" ? await io.readStdin() : value)?.trim();
132
+ if (!text) throw new Error(`usage: ${usage}`);
133
+ return text;
134
+ }
135
+ function name(positionals, usage) {
136
+ const given = positionals[0];
137
+ if (!given) throw new Error(`usage: ${usage}`);
138
+ return given;
139
+ }
140
+ function subagent(parent, id) {
141
+ const found = findSubagent(parent, id);
142
+ if (!found) throw new Error(`this conversation has no subagent "${id}". \`nolune agent list\` shows them.`);
143
+ return found;
144
+ }
145
+ /** The exit code: `watch` fails with 1 when the subagent failed or was stopped. */
146
+ async function agentCommand(io, action, args) {
147
+ const { values, positionals } = parseArgs({
148
+ args,
149
+ allowPositionals: true,
150
+ options: {
151
+ prompt: { type: "string" },
152
+ preset: { type: "string" },
153
+ effort: { type: "string" }
154
+ }
155
+ });
156
+ switch (action) {
157
+ case "run": {
158
+ const prompt = await promptFrom(io, values.prompt, "nolune agent run [<id>] --prompt \"<task>\" [--preset NAME] [--effort LEVEL] (--prompt - reads stdin)");
159
+ if (values.effort !== void 0 && !EFFORTS.includes(values.effort)) throw new Error(`--effort must be one of ${EFFORTS.join(", ")}.`);
160
+ const { subagent: s, conversation, created } = runSubagent({
161
+ parentId: parentId(io),
162
+ name: positionals[0],
163
+ prompt,
164
+ presetId: values.preset ? resolvePreset(values.preset)?.id : void 0,
165
+ effort: values.effort
166
+ });
167
+ const model = `${conversation.presetName}, reasoning ${conversation.effort}`;
168
+ io.log(created ? `Started subagent ${s.name} (${model}).` : `Gave ${s.name} more work (${model}).`);
169
+ const log = subagentLogPath(s);
170
+ if (log) io.log(`Log: ${log} (what it says and runs as it works, without its reasoning; check it with tail)`);
171
+ io.log(`To be told when it's done, run \`nolune agent watch ${s.name}\` with run_in_background: its last message becomes that command's output. Steer it while it works with \`nolune agent steer ${s.name} --prompt "..."\`.`);
172
+ return;
173
+ }
174
+ case "watch": {
175
+ const parent = parentId(io);
176
+ const id = name(positionals, "nolune agent watch <id>");
177
+ for (;;) {
178
+ const result = subagentResult(subagent(parent, id));
179
+ if (result) {
180
+ io.log(result.text);
181
+ return result.ok ? 0 : 1;
182
+ }
183
+ await setTimeout$1(WATCH_POLL_MS, void 0, { signal: io.signal });
184
+ }
185
+ }
186
+ case "steer": {
187
+ const usage = "nolune agent steer <id> --prompt \"<message>\" (or --prompt - to read stdin)";
188
+ const id = name(positionals, usage);
189
+ const text = await promptFrom(io, values.prompt, usage);
190
+ const s = steerSubagent({
191
+ parentId: parentId(io),
192
+ name: id,
193
+ text
194
+ });
195
+ io.log(`Sent ${s.name} your message; it reads it at its next step.`);
196
+ return;
197
+ }
198
+ case "stop": {
199
+ const s = requestSubagentStop({
200
+ parentId: parentId(io),
201
+ name: name(positionals, "nolune agent stop <id>")
202
+ });
203
+ io.log(`Stopping ${s.name}.`);
204
+ return;
205
+ }
206
+ case "list":
207
+ case void 0: {
208
+ const all = listSubagents(parentId(io));
209
+ if (!all.length) {
210
+ io.log("This conversation has no subagents.");
211
+ return;
212
+ }
213
+ for (const s of all) {
214
+ const conv = getConversation(s.conversationId);
215
+ const status = s.error && s.status !== "done" ? `${s.status} (${s.error})` : s.status;
216
+ io.log(`${s.name} ${status}`);
217
+ if (conv?.title) io.log(` ${conv.title}`);
218
+ if (conv) io.log(` ${conv.presetName}, reasoning ${conv.effort}`);
219
+ const log = subagentLogPath(s);
220
+ if (log) io.log(` log: ${log}`);
221
+ }
222
+ return;
223
+ }
224
+ default: throw new Error("usage: nolune agent run|watch|steer|stop|list. See `nolune help`.");
225
+ }
226
+ }
227
+ //#endregion
228
+ //#region ../cli/src/background.ts
229
+ var BACKGROUND_HELP = `Background work (in agent commands: what the conversation's agent has going while it does other
230
+ things)
231
+ nolune background list it: commands started with run_in_background, by
232
+ their process group, and working subagents, by their
233
+ id, with how long each has run
234
+ nolune background stop <id>... | --all stop them within seconds; nothing they would have
235
+ handed over arrives`;
236
+ function conversationId(io) {
237
+ const id = io.env.NOLUNE_CONVERSATION_ID;
238
+ if (!id) throw new Error("`nolune background` only works in the agent's commands: it's about the conversation that runs it.");
239
+ return id;
240
+ }
241
+ async function backgroundCommand(io, action, args) {
242
+ const { values, positionals } = parseArgs({
243
+ args,
244
+ allowPositionals: true,
245
+ options: { all: { type: "boolean" } }
246
+ });
247
+ switch (action) {
248
+ case "list":
249
+ case void 0: {
250
+ const lines = describeBackground(conversationId(io), { withLogs: true });
251
+ if (!lines.length) {
252
+ io.log("Nothing runs in this conversation's background.");
253
+ return;
254
+ }
255
+ for (const line of lines) io.log(line);
256
+ io.log("\nStop one with `nolune background stop <id>`, or all of it with `nolune background stop --all`.");
257
+ return;
258
+ }
259
+ case "stop": {
260
+ if (!values.all && !positionals.length) throw new Error("usage: nolune background stop <id>... | --all");
261
+ const { commands, subagents } = requestBackgroundStop(conversationId(io), values.all ? "all" : positionals, "the agent");
262
+ const stopping = [...commands.map((c) => `${c.pid}${c.summary ? ` (${c.summary})` : ""}`), ...subagents.map((s) => s.name)];
263
+ if (!stopping.length) {
264
+ io.log("Nothing runs in this conversation's background.");
265
+ return;
266
+ }
267
+ io.log(`Stopping ${stopping.join(", ")}. Nothing ${stopping.length > 1 ? "they" : "it"} would have handed over arrives.`);
268
+ return;
269
+ }
270
+ default: throw new Error("usage: nolune background [list] | stop <id>... | --all. See `nolune help`.");
271
+ }
272
+ }
273
+ //#endregion
274
+ //#region ../cli/src/card.ts
275
+ var CARD_HELP = `Cards (a note per user that goes with them into all their profiles; at most ${MAX_CARD_CHARS} characters)
276
+ nolune card [<name|email>] print someone's card, or list everyone's
277
+ People edit their own card on its page in the web app; in a chat, nolune changes one with
278
+ nolune memory, only from what its owner says about themselves.`;
279
+ function cardCommand(io, args) {
280
+ const [who] = args;
281
+ if (who === "help") {
282
+ io.log(CARD_HELP);
283
+ return;
284
+ }
285
+ if (!who) {
286
+ const users = listUsers();
287
+ if (!users.length) {
288
+ io.log("No users yet.");
289
+ return;
290
+ }
291
+ const cards = users.map((u) => cardOf(u.id));
292
+ const files = new Map(cardFiles(cards).map((file) => [file.path, file]));
293
+ const width = Math.max(...cards.map((card) => card.path.length));
294
+ for (const card of cards) {
295
+ const facts = files.get(card.path)?.facts.length ?? 0;
296
+ io.log(` ${card.path.padEnd(width)} ${facts ? `${facts} fact${facts === 1 ? "" : "s"}` : "empty"} (${card.owner})`);
297
+ }
298
+ return;
299
+ }
300
+ const found = findUser(who.trim());
301
+ if (!found) throw new Error(`No user "${who}"`);
302
+ const card = cardOf(found.id);
303
+ const note = readCard(card);
304
+ if (!note?.text.trim()) {
305
+ io.log(`${card.owner}'s card (${card.path}) is empty so far.`);
306
+ return;
307
+ }
308
+ io.stdout(note.text.endsWith("\n") ? note.text : `${note.text}\n`);
309
+ }
310
+ //#endregion
311
+ //#region ../cli/src/generate.ts
312
+ /** Read when shown: the gateway runs for days, and the image model can change meanwhile. */
313
+ function generateHelp() {
314
+ return `Pictures (model ${configuredImageModel()}; change it with \`nolune config set image-model\`)
315
+ nolune generate image <PROMPT | -> [--image FILE]... [--size square|portrait|landscape|auto|WxH]
316
+ [--quality Q] [--background auto|transparent|opaque] [--format png|jpeg|webp]
317
+ [--count N] [--model PROVIDER/MODEL] [--out DIR|FILE] [--dry-run]
318
+ make pictures from a prompt, or change the --image ones; \`-\` reads the prompt from stdin`;
319
+ }
320
+ var OPTIONS$1 = {
321
+ image: {
322
+ type: "string",
323
+ short: "i",
324
+ multiple: true
325
+ },
326
+ size: { type: "string" },
327
+ quality: { type: "string" },
328
+ background: { type: "string" },
329
+ format: { type: "string" },
330
+ count: {
331
+ type: "string",
332
+ short: "n"
333
+ },
334
+ model: { type: "string" },
335
+ out: {
336
+ type: "string",
337
+ short: "o"
338
+ },
339
+ "dry-run": { type: "boolean" }
340
+ };
341
+ function oneOf(value, allowed, flag) {
342
+ if (value === void 0) return void 0;
343
+ const v = value.trim().toLowerCase();
344
+ if (!allowed.includes(v)) throw new Error(`--${flag} is one of ${allowed.join(", ")}.`);
345
+ return v;
346
+ }
347
+ function expandHome$1(path) {
348
+ if (path === "~") return homedir();
349
+ return path.startsWith("~/") ? join(homedir(), path.slice(2)) : path;
350
+ }
351
+ /** The first few words of the prompt, for the file name. */
352
+ function slug(text) {
353
+ return text.toLowerCase().normalize("NFKD").replace(/[^a-z0-9\s-]/g, "").trim().split(/[\s-]+/).slice(0, 5).join("-") || "image";
354
+ }
355
+ function stamp(now) {
356
+ const p = (n) => String(n).padStart(2, "0");
357
+ return `${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())}-${p(now.getHours())}${p(now.getMinutes())}${p(now.getSeconds())}`;
358
+ }
359
+ /** Where each picture goes: `--out` as a file (one picture) or a folder, else `images/`. */
360
+ function outputPaths(io, out, count, base, format) {
361
+ const ext = format === "jpeg" ? "jpg" : format;
362
+ let dir;
363
+ if (out && /\.(png|jpe?g|webp)$/i.test(out)) {
364
+ const file = resolve(io.cwd, expandHome$1(out));
365
+ if (count === 1) return {
366
+ dir: resolve(file, ".."),
367
+ files: [file]
368
+ };
369
+ dir = resolve(file, "..");
370
+ base = file.slice(dir.length + 1, -extname(file).length);
371
+ } else if (out) dir = resolve(io.cwd, expandHome$1(out));
372
+ else {
373
+ const profileDir = io.env.NOLUNE_PROFILE_DIR;
374
+ dir = profileDir && isAbsolute(profileDir) ? join(profileDir, "images") : io.cwd;
375
+ }
376
+ const files = Array.from({ length: count }, (_, i) => join(dir, `${base}${count > 1 ? `-${i + 1}` : ""}.${ext}`));
377
+ return {
378
+ dir,
379
+ files
380
+ };
381
+ }
382
+ function formatBytes(bytes) {
383
+ return bytes >= 1048576 ? `${(bytes / 1048576).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`;
384
+ }
385
+ async function image(io, args) {
386
+ const { values, positionals } = parseArgs({
387
+ args,
388
+ allowPositionals: true,
389
+ options: OPTIONS$1
390
+ });
391
+ let prompt = positionals.join(" ").trim();
392
+ if (prompt === "-") prompt = (await io.readStdin()).trim();
393
+ if (!prompt) throw new Error("say what to make: nolune generate image \"<prompt>\"");
394
+ const inputs = (values.image ?? []).map((path) => resolve(io.cwd, expandHome$1(path)));
395
+ const count = values.count === void 0 ? 1 : Number(values.count);
396
+ if (!Number.isInteger(count) || count < 1 || count > 4) throw new Error(`--count is between 1 and 4.`);
397
+ const background = oneOf(values.background, IMAGE_BACKGROUNDS, "background");
398
+ const format = oneOf(values.format, IMAGE_FORMATS, "format");
399
+ const size = values.size ? parseImageSize(values.size) : "auto";
400
+ const quality = values.quality?.trim().toLowerCase() || void 0;
401
+ if (values["dry-run"]) {
402
+ const sizeText = typeof size === "object" ? `${size.width}x${size.height}` : size;
403
+ io.log(`Model: ${values.model?.trim() || configuredImageModel()}`);
404
+ io.log(`Size: ${sizeText}, quality: ${quality ?? "default"}, background: ${background ?? "default"}, format: ${format ?? "png"}, count: ${count}`);
405
+ if (inputs.length) io.log(`Images: ${inputs.join(", ")}`);
406
+ io.log(`Prompt:\n${prompt}`);
407
+ return;
408
+ }
409
+ const result = await generateImages({
410
+ prompt,
411
+ images: inputs,
412
+ model: values.model,
413
+ size,
414
+ quality,
415
+ background,
416
+ format,
417
+ count,
418
+ signal: io.signal,
419
+ onStart: (model) => {
420
+ const from = inputs.length ? ` from ${inputs.length} image${inputs.length === 1 ? "" : "s"}` : "";
421
+ const what = count === 1 ? "a picture" : `${count} pictures`;
422
+ io.log(`Making ${what} with ${model}${from}. This can take a minute or two.`);
423
+ }
424
+ });
425
+ const base = `${stamp(/* @__PURE__ */ new Date())}-${slug(prompt)}`;
426
+ const { dir, files } = outputPaths(io, values.out, result.images.length, base, result.images[0].format);
427
+ mkdirSync(dir, { recursive: true });
428
+ for (const [i, picture] of result.images.entries()) {
429
+ writeFileSync(files[i], picture.data);
430
+ const info = inspectImage(picture.data);
431
+ const details = [
432
+ info ? `${info.width}×${info.height}` : null,
433
+ picture.format.toUpperCase(),
434
+ formatBytes(picture.data.length)
435
+ ].filter(Boolean);
436
+ io.log(`Saved ${files[i]} (${details.join(", ")})`);
437
+ }
438
+ }
439
+ async function generateCommand(io, action, args) {
440
+ if (action === "image") return image(io, args);
441
+ throw new Error("usage: nolune generate image <prompt> [options]. See `nolune help`.");
442
+ }
443
+ //#endregion
444
+ //#region ../cli/src/input.ts
445
+ async function ask(io, question, defaultValue = "") {
446
+ if (!io.stdinIsTTY) return defaultValue;
447
+ const rl = createInterface({
448
+ input: process.stdin,
449
+ output: process.stdout
450
+ });
451
+ try {
452
+ const suffix = defaultValue ? ` [${defaultValue}]` : "";
453
+ return (await rl.question(`${question}${suffix}: `)).trim() || defaultValue;
454
+ } finally {
455
+ rl.close();
456
+ }
457
+ }
458
+ /** Like ask(), but doesn't echo what's typed or pasted (API keys). */
459
+ async function askHidden(io, question) {
460
+ if (!io.stdinIsTTY) return (await io.readStdin()).trim();
461
+ const stdin = process.stdin;
462
+ return new Promise((resolve, reject) => {
463
+ process.stdout.write(`${question}: `);
464
+ let value = "";
465
+ const cleanup = () => {
466
+ stdin.off("data", onData);
467
+ stdin.setRawMode(false);
468
+ stdin.pause();
469
+ process.stdout.write("\n");
470
+ };
471
+ const onData = (chunk) => {
472
+ for (const ch of chunk) {
473
+ if (ch === "\r" || ch === "\n") {
474
+ cleanup();
475
+ resolve(value.trim());
476
+ return;
477
+ }
478
+ if (ch === "") {
479
+ cleanup();
480
+ reject(/* @__PURE__ */ new Error("Cancelled"));
481
+ return;
482
+ }
483
+ if (ch === "" || ch === "\b") value = value.slice(0, -1);
484
+ else value += ch;
485
+ }
486
+ };
487
+ stdin.setRawMode(true);
488
+ stdin.setEncoding("utf8");
489
+ stdin.resume();
490
+ stdin.on("data", onData);
491
+ });
492
+ }
493
+ //#endregion
494
+ //#region ../cli/src/plans.ts
495
+ async function confirm(io, question) {
496
+ return /^y/i.test(await ask(io, `${question} (yes/no)`, "yes"));
497
+ }
498
+ /** Runs a program on this terminal, for the person at it; returns its exit code. */
499
+ function runOnTerminal(command, args, env = process.env) {
500
+ return spawnSync(command, args, {
501
+ stdio: "inherit",
502
+ env
503
+ }).status ?? 1;
504
+ }
505
+ /**
506
+ * Fails unless Claude Code is here and signed in to a plan; says who it's signed in as. With
507
+ * `guide`, at a terminal, it first offers what's missing: Anthropic's installer, then Claude
508
+ * Code's own sign-in, asking before each. nolune never sees the sign-in: Claude Code keeps it.
509
+ */
510
+ async function requireClaudePlan(io, guide = false) {
511
+ let status = await claudePlanStatus();
512
+ if (guide && io.stdinIsTTY && !status.installed) {
513
+ io.log("Chats on the Claude plan run through Claude Code, which isn't installed here.");
514
+ if (await confirm(io, `Install it with Anthropic's installer (curl -fsSL https://claude.ai/install.sh | bash)?`)) {
515
+ if (runOnTerminal("bash", ["-c", "curl -fsSL https://claude.ai/install.sh | bash"]) !== 0) fail$1("Claude Code's installer failed. See https://code.claude.com/docs/en/setup");
516
+ status = await claudePlanStatus();
517
+ }
518
+ }
519
+ if (guide && io.stdinIsTTY && status.installed && status.account && status.problem) {
520
+ io.log(status.problem.split(". ")[0].replace(/\.?$/, "."));
521
+ if (await confirm(io, "Sign in to your Claude plan now? Claude Code opens its sign-in page")) {
522
+ const { command, args, env } = claudeSignInCommand(status.path ?? "claude");
523
+ runOnTerminal(command, args, env);
524
+ status = await claudePlanStatus();
525
+ }
526
+ }
527
+ if (status.problem || !status.account) fail$1(status.problem ?? "Claude Code didn't answer.");
528
+ io.log(`Claude Code (${status.path}): ${status.signedIn}`);
529
+ }
530
+ /** Opens `url` in this computer's browser, where there's one to open; it's printed either way. */
531
+ function openBrowser(url) {
532
+ const command = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : null;
533
+ if (!command) return;
534
+ try {
535
+ const child = spawn(command, [url], {
536
+ stdio: "ignore",
537
+ detached: true
538
+ });
539
+ child.on("error", () => {});
540
+ child.unref();
541
+ } catch {}
542
+ }
543
+ /** At a terminal, takes the address a sign-in ended on, pasted, until the sign-in is over. */
544
+ async function takePasted(io, signal) {
545
+ const rl = createInterface({
546
+ input: process.stdin,
547
+ output: process.stdout
548
+ });
549
+ try {
550
+ while (!signal.aborted) {
551
+ const address = (await rl.question("", { signal })).trim();
552
+ if (!address) continue;
553
+ try {
554
+ await finishChatGptSignIn(address);
555
+ return;
556
+ } catch (err) {
557
+ if (chatGptSignInState().pending) io.log(err.message);
558
+ }
559
+ }
560
+ } catch {} finally {
561
+ rl.close();
562
+ }
563
+ }
564
+ /**
565
+ * Signs in with ChatGPT: prints OpenAI's sign-in page, opens it in this computer's browser at a
566
+ * terminal, and waits for the browser to come back. A browser on another device ends on an address
567
+ * that doesn't load, which can be pasted here at a terminal, or else under Models & keys, where
568
+ * this sign-in shows too. Stops when the command is stopped.
569
+ */
570
+ async function signInWithChatGpt(io, anotherAccount) {
571
+ io.signal.throwIfAborted();
572
+ const stop = () => cancelChatGptSignIn();
573
+ io.signal.addEventListener("abort", stop, { once: true });
574
+ const reading = new AbortController();
575
+ try {
576
+ const signIn = await startChatGptSignIn({ anotherAccount });
577
+ io.log(`To sign in with ChatGPT, open this in a browser and allow nolune to use your plan:
578
+
579
+ ${signIn.url}
580
+ `);
581
+ if (io.stdinIsTTY) {
582
+ openBrowser(signIn.url);
583
+ io.log("In a browser on another device, the page ChatGPT sends you back to won't load: copy its address and paste it here. Waiting…");
584
+ takePasted(io, reading.signal);
585
+ } else io.log("Open it in a browser on this computer. On another device, the page ChatGPT sends you back to won't load: paste its address under Models & keys on nolune's admin page, where this sign-in shows too. Waiting…");
586
+ await signIn.done;
587
+ } finally {
588
+ reading.abort();
589
+ io.signal.removeEventListener("abort", stop);
590
+ }
591
+ }
592
+ /**
593
+ * Fails unless someone is signed in with ChatGPT and OpenAI takes the sign-in; says who. With
594
+ * `guide`, it first signs in when that's missing or doesn't work, or with `anotherAccount`.
595
+ */
596
+ async function requireChatGptPlan(io, opts = {}) {
597
+ let status = await chatGptPlanStatus({ check: true });
598
+ if (opts.guide && (opts.anotherAccount || status.problem)) {
599
+ if (status.problem) io.log(status.problem.split(". ")[0].replace(/\.?$/, "."));
600
+ await signInWithChatGpt(io, !!opts.anotherAccount);
601
+ status = await chatGptPlanStatus({ check: true });
602
+ }
603
+ if (status.problem || !status.signedIn) fail$1(status.problem ?? "Nobody is signed in with ChatGPT.");
604
+ io.log(`ChatGPT plan: ${status.signedIn}`);
605
+ }
606
+ /** Links nolune to the plan: shows the code and the page to approve it on, and waits. */
607
+ async function linkNolunePlan(io) {
608
+ io.signal.throwIfAborted();
609
+ const stop = () => cancelNolunePlanSignIn();
610
+ io.signal.addEventListener("abort", stop, { once: true });
611
+ try {
612
+ const signIn = await startNolunePlanSignIn();
613
+ io.log(`To link nolune to your nolune plan, open this on any device, sign in, and check the code:
614
+
615
+ ${signIn.url}
616
+
617
+ Code: ${signIn.code}
618
+ `);
619
+ if (io.stdinIsTTY) openBrowser(signIn.url);
620
+ io.log("Waiting…");
621
+ await signIn.done;
622
+ } finally {
623
+ io.signal.removeEventListener("abort", stop);
624
+ }
625
+ }
626
+ /**
627
+ * Fails unless nolune is linked to a nolune plan the API takes; says who as, and where its limits
628
+ * stand. With `guide`, it first links nolune when it isn't, or the link no longer works.
629
+ */
630
+ async function requireNolunePlan(io, guide = false) {
631
+ let status = await nolunePlanStatus({ check: true });
632
+ if (guide && (!status.signedIn || status.problem)) {
633
+ if (status.problem) io.log(status.problem.split(". ")[0].replace(/\.?$/, "."));
634
+ await linkNolunePlan(io);
635
+ status = await nolunePlanStatus({ check: true });
636
+ }
637
+ if (status.problem || !status.signedIn) fail$1(status.problem ?? "nolune isn't linked to a nolune plan.");
638
+ io.log(`nolune plan: ${status.signedIn}`);
639
+ if (status.usage) {
640
+ const { window, week, month, credits } = status.usage;
641
+ const share = (limit) => limit.limit > 0 ? `${Math.min(100, Math.round(limit.spent / limit.limit * 100))}%` : "none";
642
+ const dollars = (micros) => `$${(micros / 1e6).toFixed(2)}`;
643
+ const used = [
644
+ window && `5 hours: ${share(window)}`,
645
+ week && `week: ${share(week)}`,
646
+ month && `month: ${share(month)}`
647
+ ].filter(Boolean);
648
+ const extra = credits.extra > 0 ? ` + ${dollars(credits.extra)} extra` : "";
649
+ io.log(` ${[...used, `credits left: ${dollars(credits.plan)}${extra}`].join(" · ")}`);
650
+ }
651
+ }
652
+ /**
653
+ * `nolune <plan> setup`: installs the plan's agent and signs it in where needed, then says who it's
654
+ * signed in as.
655
+ */
656
+ function setUpPlan(io, plan, args) {
657
+ if (plan === "claude-plan") return requireClaudePlan(io, true);
658
+ if (plan === "nolune-plan") {
659
+ if (args.length) fail$1(`unknown option ${args[0]}. usage: nolune nolune-plan setup`);
660
+ return requireNolunePlan(io, true);
661
+ }
662
+ const anotherAccount = args.includes("--another-account");
663
+ const unknown = args.find((arg) => arg !== "--another-account");
664
+ if (unknown) fail$1(`unknown option ${unknown}. usage: nolune chatgpt-plan setup [--another-account]`);
665
+ return requireChatGptPlan(io, {
666
+ guide: true,
667
+ anotherAccount
668
+ });
669
+ }
670
+ /** `nolune claude-plan …`, `nolune chatgpt-plan …` and `nolune nolune-plan …`. */
671
+ async function planCommand(io, plan, action, args = []) {
672
+ switch (action) {
673
+ case "status": return plan === "claude-plan" ? requireClaudePlan(io) : plan === "chatgpt-plan" ? requireChatGptPlan(io) : requireNolunePlan(io);
674
+ case "setup":
675
+ if (plan === "claude-plan" && !io.stdinIsTTY) fail$1("`nolune claude-plan setup` asks questions: run it in a terminal on this computer.");
676
+ return setUpPlan(io, plan, args);
677
+ }
678
+ if (plan === "chatgpt-plan") {
679
+ if (action === "logout") {
680
+ const { signedIn } = await chatGptPlanStatus();
681
+ const told = await signOutChatGpt();
682
+ io.log(signedIn ? `Signed out (was ${signedIn}).${told ? "" : " OpenAI couldn't be told: to be sure, disconnect nolune in ChatGPT's settings."} Chats on chatgpt-plan presets stop until someone signs in again.` : "Not signed in.");
683
+ return;
684
+ }
685
+ if (action === "models") {
686
+ for (const m of await listChatGptModels()) if (m.listed) io.log(`${m.id}\t${m.name}`);
687
+ return;
688
+ }
689
+ fail$1("usage: nolune chatgpt-plan status|setup [--another-account]|logout|models");
690
+ }
691
+ if (plan === "nolune-plan") {
692
+ if (action === "logout") {
693
+ const { signedIn } = await nolunePlanStatus();
694
+ const told = await signOutNolunePlan();
695
+ io.log(signedIn ? `Unlinked (was ${signedIn}).${told ? "" : " nolune's API couldn't be told; the link ends by itself unused."} Chats on nolune-plan presets stop until nolune is linked again.` : "Not linked.");
696
+ return;
697
+ }
698
+ if (action === "models") {
699
+ for (const m of await listModels$1("nolune-plan")) io.log(`${m.id}\t${m.name ?? ""}`);
700
+ return;
701
+ }
702
+ fail$1("usage: nolune nolune-plan status|setup|logout|models");
703
+ }
704
+ fail$1("usage: nolune claude-plan status|setup");
705
+ }
706
+ //#endregion
707
+ //#region ../cli/src/mcp.ts
708
+ var MCP_HELP = `MCP servers (other apps' and services' tools, which chats get next to run_command)
709
+ nolune mcp add <name> <url> [--transport http|sse] [--header "Name: value"]...
710
+ [--client-id ID [--client-secret S]] [--scope S] [--description D]
711
+ [--profile SLUG]...
712
+ nolune mcp add <name> [--env NAME=value]... [--cwd DIR] [--description D] [--profile SLUG]...
713
+ -- <command> [args...]
714
+ connect a server at an address, or one this computer
715
+ runs (found on the PATH the agent's commands have);
716
+ nolune connects to check it. The same name again
717
+ changes it. --profile: only in those profiles
718
+ (in every profile without it)
719
+ nolune mcp add-json <name> '<json>' the same, as MCP clients' settings write a server:
720
+ {"command": …, "args": […], "env": {…}} or
721
+ {"type": "http", "url": …, "headers": {…}}
722
+ nolune mcp rm <name>
723
+ nolune mcp list the servers (and the names of their keys, never
724
+ the keys), and whether someone signed in to them
725
+ nolune mcp login <name> sign in to a server at an address that wants it
726
+ (OAuth): prints the page to open, which comes back
727
+ to nolune's web address. --client-id: the app the
728
+ service had you register, for one that wants that
729
+ nolune mcp logout <name> forget its sign-in
730
+ nolune mcp tools [<server> [<tool>]] their tools; with a tool, what it does and takes
731
+ nolune mcp call <server> <tool> [<json>|-] call a tool with a JSON object of arguments (- reads
732
+ stdin); pictures it returns are attached for the agent`;
733
+ var USAGE = "usage: nolune mcp add|add-json|rm|list|login|logout|tools|call. See `nolune help`.";
734
+ /** How much of a tool's description the list shows, and of a server's instructions. */
735
+ var SHORT_DESCRIPTION = 200;
736
+ var MAX_INSTRUCTIONS = 4e3;
737
+ /** The profiles a server is for, by slug, each of which must exist. */
738
+ function profiles(given) {
739
+ for (const slug of given ?? []) if (!getProfileBySlug(slug)) fail$1(`no profile with slug "${slug}". See \`nolune profile list\`.`);
740
+ return given?.length ? given : void 0;
741
+ }
742
+ /** `NAME=value` and `Name: value` pairs, as typed. */
743
+ function pairs(given, separator, what) {
744
+ const map = {};
745
+ for (const pair of given ?? []) {
746
+ const at = pair.indexOf(separator);
747
+ if (at <= 0) fail$1(`${what} is given as ${separator === "=" ? "NAME=value" : "\"Name: value\""}, not "${pair}"`);
748
+ map[pair.slice(0, at).trim()] = pair.slice(at + 1).trim();
749
+ }
750
+ return map;
751
+ }
752
+ /**
753
+ * Checks a server by connecting to it, and saves it: a server it can't connect to is saved all
754
+ * the same, with why, since what it needs may come later (a program installed, a server started).
755
+ */
756
+ async function store(io, name, server) {
757
+ const problem = mcpServerNameProblem(name);
758
+ if (problem) fail$1(problem);
759
+ let parsed;
760
+ try {
761
+ parsed = parseMcpServer(server);
762
+ } catch (err) {
763
+ fail$1(err.message);
764
+ }
765
+ let found = null;
766
+ let unreachable = "";
767
+ try {
768
+ found = await checkMcpServer(name, parsed, io.signal);
769
+ } catch (err) {
770
+ if (!(err instanceof McpServerError)) throw err;
771
+ unreachable = err.message;
772
+ }
773
+ if (found && !parsed.description) parsed.description = describeFromServer(found);
774
+ const { replaced } = saveMcpServer(name, parsed);
775
+ const done = replaced ? "Changed" : "Added";
776
+ if (!found && listMcpServers().find((s) => s.name === name)?.signIn === "needed") {
777
+ io.log(`${done} ${name}. It needs someone to sign in: \`nolune mcp login ${name}\`, or Sign in on the Connected services page.`);
778
+ return;
779
+ }
780
+ if (!found) {
781
+ io.log(`${done} ${name}, but couldn't connect to it: ${unreachable}`);
782
+ return;
783
+ }
784
+ const names = found.tools.map((t) => t.name);
785
+ const some = names.slice(0, 8).join(", ");
786
+ const more = names.length > 8 ? ` and ${names.length - 8} more` : "";
787
+ io.log(`${done} ${name}: ${names.length} ${names.length === 1 ? "tool" : "tools"}${names.length ? ` (${some}${more})` : ""}.${parsed.profiles ? ` In ${parsed.profiles.join(", ")} only.` : ""}`);
788
+ }
789
+ async function add(io, args) {
790
+ const split = args.indexOf("--");
791
+ const own = split === -1 ? args : args.slice(0, split);
792
+ let parsed;
793
+ try {
794
+ parsed = parseAdd(own);
795
+ } catch (err) {
796
+ if (err.code !== "ERR_PARSE_ARGS_UNKNOWN_OPTION") throw err;
797
+ fail$1(`put the server's command after --, so its options aren't taken for nolune's: nolune mcp add <name> [options] -- <command> [args...]`);
798
+ }
799
+ const { values, positionals } = parsed;
800
+ const [name, ...rest] = positionals;
801
+ if (!name) fail$1("usage: nolune mcp add <name> <url> | nolune mcp add <name> -- <command> [args...]");
802
+ const words = [...rest, ...split === -1 ? [] : args.slice(split + 1)];
803
+ if (!words.length) fail$1(`what does ${name} run, or where is it? See \`nolune help\`.`);
804
+ const shared = {
805
+ description: values.description,
806
+ profiles: profiles(values.profile)
807
+ };
808
+ const transport = values.transport;
809
+ if (words.length === 1 && isMcpAddress(words[0])) {
810
+ if (values.env || values.cwd) fail$1("--env and --cwd are for a server this computer runs.");
811
+ if (transport !== void 0 && transport !== "http" && transport !== "sse") fail$1("--transport is http (the default) or sse, for older servers.");
812
+ if (values["client-secret"] && !values["client-id"]) fail$1("--client-secret goes with the --client-id it belongs to.");
813
+ const headers = pairs(values.header, ":", "A header");
814
+ const oauth = {
815
+ ...values["client-id"] && { clientId: values["client-id"] },
816
+ ...values["client-secret"] && { clientSecret: values["client-secret"] },
817
+ ...values.scope && { scope: values.scope }
818
+ };
819
+ await store(io, name, {
820
+ type: transport === "sse" ? "sse" : "http",
821
+ url: words[0],
822
+ ...Object.keys(headers).length && { headers },
823
+ ...Object.keys(oauth).length && { oauth },
824
+ ...shared
825
+ });
826
+ return;
827
+ }
828
+ if (values.header) fail$1("--header is for a server at an address (http:// or https://).");
829
+ if (values["client-id"] || values["client-secret"] || values.scope) fail$1("--client-id, --client-secret and --scope are for signing in to a server at an address.");
830
+ if (transport !== void 0 && transport !== "stdio") fail$1(`${words[0]} isn't an address: a server at one starts with http:// or https://.`);
831
+ const env = pairs(values.env, "=", "An environment variable");
832
+ await store(io, name, {
833
+ type: "stdio",
834
+ command: words[0],
835
+ ...words.length > 1 && { args: words.slice(1) },
836
+ ...Object.keys(env).length && { env },
837
+ ...values.cwd && { cwd: values.cwd },
838
+ ...shared
839
+ });
840
+ }
841
+ function parseAdd(args) {
842
+ return parseArgs({
843
+ args,
844
+ allowPositionals: true,
845
+ options: {
846
+ transport: {
847
+ type: "string",
848
+ short: "t"
849
+ },
850
+ header: {
851
+ type: "string",
852
+ short: "H",
853
+ multiple: true
854
+ },
855
+ env: {
856
+ type: "string",
857
+ short: "e",
858
+ multiple: true
859
+ },
860
+ cwd: { type: "string" },
861
+ "client-id": { type: "string" },
862
+ "client-secret": { type: "string" },
863
+ scope: { type: "string" },
864
+ description: {
865
+ type: "string",
866
+ short: "d"
867
+ },
868
+ profile: {
869
+ type: "string",
870
+ multiple: true
871
+ }
872
+ }
873
+ });
874
+ }
875
+ async function addJson(io, args) {
876
+ const [name, json] = args;
877
+ if (!name || !json) fail$1(`usage: nolune mcp add-json <name> '<json>' (- reads stdin)`);
878
+ const text = json === "-" ? await io.readStdin() : json;
879
+ let value;
880
+ try {
881
+ value = JSON.parse(text);
882
+ } catch (err) {
883
+ fail$1(`that isn't JSON: ${err.message}`);
884
+ }
885
+ const wrapped = value?.mcpServers;
886
+ if (wrapped && typeof wrapped === "object") {
887
+ const inside = Object.values(wrapped);
888
+ if (inside.length !== 1) fail$1("give one server: the object inside \"mcpServers\".");
889
+ value = inside[0];
890
+ }
891
+ if (value && typeof value === "object" && "profiles" in value) profiles(value.profiles);
892
+ await store(io, name, value);
893
+ }
894
+ function list(io) {
895
+ const profile = io.env.NOLUNE_PROFILE;
896
+ const servers = listMcpServers(profile);
897
+ if (!servers.length) {
898
+ io.log(`No MCP servers${profile ? " in this profile" : ""}. An admin connects them on the Connected services page, or with \`nolune mcp add\`.`);
899
+ return;
900
+ }
901
+ for (const s of servers) {
902
+ if (s.problem) {
903
+ io.log(`${s.name}\tbroken settings: ${s.problem}`);
904
+ continue;
905
+ }
906
+ const kind = s.type === "stdio" ? "env" : "headers";
907
+ const keys = s.secrets.length ? `${kind}: ${s.secrets.join(", ")}` : `no ${kind}`;
908
+ const where = s.profiles ? `profiles: ${s.profiles.join(", ")}` : "every profile";
909
+ const signIn = s.signIn === "signed-in" ? " signed in" : s.signIn === "needed" ? `\tneeds sign-in (nolune mcp login ${s.name})` : "";
910
+ io.log(`${s.name}\t${s.type}\t${s.target}\t${keys}\t${where}${signIn}`);
911
+ if (s.description) io.log(` ${s.description}`);
912
+ }
913
+ }
914
+ /** `name(a, b?)`: a tool's arguments, the optional ones marked. */
915
+ function signature(tool) {
916
+ const properties = Object.keys(tool.inputSchema.properties ?? {});
917
+ const required = new Set(tool.inputSchema.required ?? []);
918
+ const shown = properties.slice(0, 8).map((p) => required.has(p) ? p : `${p}?`);
919
+ if (properties.length > 8) shown.push("…");
920
+ return `${tool.name}(${shown.join(", ")})`;
921
+ }
922
+ /** What a tool says it does to things, when it says. */
923
+ function tags(tool) {
924
+ const hints = tool.annotations;
925
+ if (hints?.readOnlyHint) return " [reads only]";
926
+ if (hints?.destructiveHint) return " [can delete or overwrite]";
927
+ return "";
928
+ }
929
+ function clip(text, max) {
930
+ return text.length > max ? `${text.slice(0, max).trimEnd()}…` : text;
931
+ }
932
+ function printTools(io, name, found, instructions) {
933
+ const n = found.tools.length;
934
+ const title = found.title && found.title !== name ? `${found.title}, ` : "";
935
+ io.log(`${name}: ${title}${n} ${n === 1 ? "tool" : "tools"}`);
936
+ if (instructions && found.instructions) io.log(clip(found.instructions, MAX_INSTRUCTIONS));
937
+ for (const tool of found.tools) {
938
+ io.log(`\n${signature(tool)}${tags(tool)}`);
939
+ const first = tool.description?.trim().split("\n")[0];
940
+ if (first) io.log(` ${clip(first, SHORT_DESCRIPTION)}`);
941
+ }
942
+ }
943
+ async function tools(io, args) {
944
+ const [server, toolName] = args;
945
+ const options = {
946
+ profile: io.env.NOLUNE_PROFILE,
947
+ signal: io.signal
948
+ };
949
+ if (server) {
950
+ const found = await listMcpTools(server, options);
951
+ if (!toolName) {
952
+ printTools(io, server, found, true);
953
+ return 0;
954
+ }
955
+ const tool = found.tools.find((t) => t.name === toolName);
956
+ if (!tool) fail$1(`${server} has no tool called ${toolName}. \`nolune mcp tools ${server}\` lists them.`);
957
+ const title = tool.title ?? tool.annotations?.title;
958
+ io.log(`${server} ${tool.name}${title ? `: ${title}` : ""}${tags(tool)}`);
959
+ if (tool.description?.trim()) io.log(tool.description.trim());
960
+ io.log(`\nArguments (JSON Schema):\n${JSON.stringify(tool.inputSchema, null, 2)}`);
961
+ if (tool.outputSchema) io.log(`\nIts structured result (JSON Schema):\n${JSON.stringify(tool.outputSchema, null, 2)}`);
962
+ return 0;
963
+ }
964
+ const servers = listMcpServers(options.profile).filter((s) => !s.problem);
965
+ if (!servers.length) {
966
+ list(io);
967
+ return 0;
968
+ }
969
+ const answers = await Promise.allSettled(servers.map((s) => listMcpTools(s.name, options)));
970
+ let failed = false;
971
+ for (const [i, answer] of answers.entries()) {
972
+ if (i) io.log("");
973
+ if (answer.status === "fulfilled") printTools(io, servers[i].name, answer.value, false);
974
+ else {
975
+ failed = true;
976
+ io.error(`nolune: ${answer.reason.message ?? answer.reason}`);
977
+ }
978
+ }
979
+ if (servers.length > 1 && answers.some((a) => a.status === "fulfilled")) io.log("\n`nolune mcp tools <server>` also shows what a server says about using it.");
980
+ return failed ? 1 : 0;
981
+ }
982
+ async function call(io, args) {
983
+ const [server, tool, json, ...extra] = args;
984
+ if (!server || !tool || extra.length) fail$1(`usage: nolune mcp call <server> <tool> ['<json>'|-], the arguments one JSON object`);
985
+ const text = json === "-" ? await io.readStdin() : json ?? "";
986
+ let input = {};
987
+ if (text.trim()) try {
988
+ input = JSON.parse(text);
989
+ } catch (err) {
990
+ fail$1(`the arguments aren't JSON (${err.message}). Give one object, like '{"query": "…"}'.`);
991
+ }
992
+ if (typeof input !== "object" || input === null || Array.isArray(input)) fail$1(`the arguments are one JSON object, like '{"query": "…"}'.`);
993
+ let result;
994
+ try {
995
+ result = await callMcpTool(server, tool, input, {
996
+ profile: io.env.NOLUNE_PROFILE,
997
+ signal: io.signal
998
+ });
999
+ } catch (err) {
1000
+ if (err instanceof McpServerError) throw err;
1001
+ fail$1(`${server} ${tool}: ${err.message}. \`nolune mcp tools ${server} ${tool}\` shows what it takes.`);
1002
+ }
1003
+ const output = await mcpResultText(result, io.env.NOLUNE_VIEW_DIR);
1004
+ if (output) io.log(output);
1005
+ if (result.isError) {
1006
+ io.error(`nolune: ${server} ${tool} reported an error.`);
1007
+ return 1;
1008
+ }
1009
+ return 0;
1010
+ }
1011
+ /**
1012
+ * Starts signing in to a server: the page to open, in a browser that reaches nolune's web
1013
+ * address, which the sign-in comes back to. The agent can pass the link on to someone.
1014
+ */
1015
+ async function login(io, args) {
1016
+ const [name] = args;
1017
+ if (!name) fail$1("usage: nolune mcp login <name>");
1018
+ const page = await startMcpSignIn(name);
1019
+ const back = new URL(signInRedirectUrl()).origin;
1020
+ io.log(`To sign in to ${name}, open this page and sign in:\n${page.href}\n\nIt comes back to nolune at ${back}, so it works in a browser that can open that, within 15 minutes. Then \`nolune mcp tools ${name}\` lists its tools.`);
1021
+ }
1022
+ /** `nolune mcp`: the exit code. */
1023
+ async function mcpCommand(io, action, args) {
1024
+ switch (action) {
1025
+ case "add": return add(io, args);
1026
+ case "add-json": return addJson(io, args);
1027
+ case "rm": {
1028
+ const [name] = args;
1029
+ if (!name) fail$1("usage: nolune mcp rm <name>");
1030
+ removeMcpServer(name);
1031
+ io.log(`Removed ${name}.`);
1032
+ return;
1033
+ }
1034
+ case void 0:
1035
+ case "list": return list(io);
1036
+ case "login": return login(io, args);
1037
+ case "logout": {
1038
+ const [name] = args;
1039
+ if (!name) fail$1("usage: nolune mcp logout <name>");
1040
+ await signOutMcpServer(name);
1041
+ io.log(`Signed out of ${name}: nolune forgot its tokens.`);
1042
+ return;
1043
+ }
1044
+ case "tools": return tools(io, args);
1045
+ case "call": return call(io, args);
1046
+ default: fail$1(USAGE);
1047
+ }
1048
+ }
1049
+ //#endregion
1050
+ //#region ../cli/src/profile.ts
1051
+ var PROFILE_HELP = `Profiles and skills
1052
+ nolune profile list slug, name and avatar of every profile
1053
+ nolune profile avatar [<name>] [--profile SLUG]
1054
+ show or change the assistant's avatar in the web chat:
1055
+ ${AVATARS.join(", ")}`;
1056
+ /** The profile `--profile` names, else the one the agent's command runs in (NOLUNE_PROFILE). */
1057
+ function profileFor(io, flag) {
1058
+ const slug = flag || io.env.NOLUNE_PROFILE;
1059
+ if (!slug) throw new Error("which profile? Pass --profile <slug>. See `nolune profile list`.");
1060
+ const found = getProfileBySlug(slug);
1061
+ if (!found) throw new Error(`no profile with slug "${slug}". See \`nolune profile list\`.`);
1062
+ return found;
1063
+ }
1064
+ function profileCommand(io, action, args) {
1065
+ if (action === "list") {
1066
+ for (const p of listProfiles()) io.log(`${p.slug}\t${p.name}\t${p.avatar}`);
1067
+ return;
1068
+ }
1069
+ if (action !== "avatar") throw new Error("usage: nolune profile list|avatar");
1070
+ const { values, positionals } = parseArgs({
1071
+ args,
1072
+ allowPositionals: true,
1073
+ options: { profile: { type: "string" } }
1074
+ });
1075
+ const profile = profileFor(io, values.profile);
1076
+ const [name] = positionals;
1077
+ if (!name) {
1078
+ io.log(profile.avatar);
1079
+ return;
1080
+ }
1081
+ const avatar = setProfileAvatar(profile.id, name.trim().toLowerCase());
1082
+ io.log(avatar === profile.avatar ? `${profile.name}'s avatar is already the ${avatar}.` : `${profile.name}'s avatar is now the ${avatar}. Open pages show it in a few seconds.`);
1083
+ }
1084
+ //#endregion
1085
+ //#region ../cli/src/memory.ts
1086
+ var MEMORY_HELP = `Memory (short notes in fixed categories; the agent reads the ones it needs)
1087
+ nolune memory [list] [--profile SLUG] the notes, how many facts each holds, and whose they are
1088
+ nolune memory search <words>... find facts in every note, best match first
1089
+ nolune memory show <topic>... print notes (a topic is home, people/anna, …)
1090
+ nolune memory add <topic> <fact> add one fact; the note is created if needed
1091
+ nolune memory replace <topic> <old> <new> change text that appears once in the note
1092
+ nolune memory forget <topic> <text> remove the one line that contains <text>
1093
+ nolune memory write <topic> [text] replace the whole note (the text, or stdin)
1094
+ nolune memory rm <topic>
1095
+ nolune memory mv <topic> <new-topic>
1096
+ nolune memory merge <topic> <into-topic> put one note into another about the same thing
1097
+ nolune memory learning [on|off] whether nolune also saves what it learns by itself,
1098
+ looking over each chat once it goes quiet
1099
+ Categories: ${MEMORY_CATEGORIES.map((c) => c === "people" || c === "projects" ? `${c}/<name>` : c).join(", ")}.
1100
+ Facts go only into these; a note from before them can be read and rewritten until it's moved.
1101
+ The note core is pinned: every new chat starts with it, so it holds at most ${MAX_PINNED_CHARS} characters.
1102
+ Each member also has a card, cards/<name>: a note about them that goes with them into all their
1103
+ profiles (at most ${MAX_CARD_CHARS} characters). show, search, add, replace and forget work on it; a change
1104
+ is refused unless its owner wrote one of the messages the agent is answering.`;
1105
+ /**
1106
+ * `--profile` is picked out by hand: facts are free text and may start with a dash, which an
1107
+ * option parser would take for an option. `nolune soul` does the same.
1108
+ */
1109
+ function splitProfile(args) {
1110
+ let profile;
1111
+ const words = [];
1112
+ for (let i = 0; i < args.length; i++) {
1113
+ const arg = args[i];
1114
+ if (arg === "--") {
1115
+ words.push(...args.slice(i + 1));
1116
+ break;
1117
+ }
1118
+ if (arg === "--profile") profile = args[++i];
1119
+ else if (arg.startsWith("--profile=")) profile = arg.slice(10);
1120
+ else words.push(arg);
1121
+ }
1122
+ return {
1123
+ profile,
1124
+ words
1125
+ };
1126
+ }
1127
+ function need(words, count, usage) {
1128
+ if (words.length < count) throw new Error(`usage: nolune memory ${usage}`);
1129
+ }
1130
+ function plural(n, one, many) {
1131
+ return `${n} ${n === 1 ? one : many}`;
1132
+ }
1133
+ /** Why `nolune memory <action>` doesn't take a card. */
1134
+ function notOnCards(action, topics) {
1135
+ const card = topics.find(isCardPath);
1136
+ if (!card) return;
1137
+ throw new Error(action === "write" ? `${card} is a card: change it a fact at a time with add, replace and forget. Only its owner rewrites it, on its page.` : `${card} is a card, which isn't ${action === "rm" ? "deleted" : "moved or merged"}: change it a fact at a time with add, replace and forget.`);
1138
+ }
1139
+ /** A card of the profile's, after checking the agent of this chat may change it. */
1140
+ function writableCard(io, profile, topic) {
1141
+ const card = profileCard(profile, topic);
1142
+ checkCardWrite(card, {
1143
+ profileId: profile.id,
1144
+ conversationId: io.env.NOLUNE_CONVERSATION_ID
1145
+ });
1146
+ return card;
1147
+ }
1148
+ /** Records the agent's change to a card for its owner, when it runs in a chat. */
1149
+ function recordCardChange(io, profile, change) {
1150
+ const conversationId = io.env.NOLUNE_CONVERSATION_ID;
1151
+ if (conversationId) recordAgentCardChanges({
1152
+ profileId: profile.id,
1153
+ conversationId
1154
+ }, [change]);
1155
+ }
1156
+ async function memoryCommand(io, args) {
1157
+ const { profile: flag, words } = splitProfile(args);
1158
+ const [action = "list", ...rest] = words;
1159
+ if (action === "help") {
1160
+ io.log(MEMORY_HELP);
1161
+ return;
1162
+ }
1163
+ const profile = profileFor(io, flag);
1164
+ const slug = profile.slug;
1165
+ switch (action) {
1166
+ case "list": {
1167
+ const files = listMemoryFiles(slug);
1168
+ if (!files.length) {
1169
+ io.log(`No notes yet for ${profile.name}. Start one with: nolune memory add <topic> "<fact>"`);
1170
+ listCards(io, profileCards(profile.id));
1171
+ return;
1172
+ }
1173
+ const members = membersWithNotes(profile);
1174
+ const whose = new Map(members.flatMap((m) => m.note ? [[m.note, m.name]] : []));
1175
+ io.log(`Notes for ${profile.name} (${profileMemoryDir(slug)}):`);
1176
+ const width = Math.max(...files.map((f) => f.path.length));
1177
+ for (const f of files) {
1178
+ const about = isPinnedNote(f.path) ? " (pinned: in every new chat)" : whose.has(f.path) ? ` (${whose.get(f.path)}'s note)` : categoryOf(f.path) ? "" : " (from before the categories: move it into one)";
1179
+ io.log(` ${f.path.padEnd(width)} ${plural(f.facts.length, "fact", "facts").padEnd(9)} changed ${formatLocalTime(new Date(f.updatedAt))}${about}`);
1180
+ }
1181
+ const waiting = members.filter((m) => !m.note || !files.some((f) => f.path === m.note));
1182
+ for (const m of waiting) io.log(m.note ? ` ${m.name}'s note ${m.note} is started when there is something to write.` : ` Which note is ${m.name}'s isn't known yet: maybe ${m.candidates.map((c) => c.path).join(", ")}. Link it in the profile's settings.`);
1183
+ listCards(io, profileCards(profile.id));
1184
+ return;
1185
+ }
1186
+ case "search": {
1187
+ need(rest, 1, "search <words>...");
1188
+ const query = rest.join(" ");
1189
+ const cards = profileCards(profile.id).map((card) => card.path);
1190
+ const hits = await searchMemory(slug, query, 20, cards);
1191
+ if (!hits.length) {
1192
+ io.log(`Nothing in ${profile.name}'s memory matches "${query}". Try other words (or another language), or read a note with \`nolune memory show <topic>\`.`);
1193
+ return;
1194
+ }
1195
+ for (const hit of hits) io.log(`${hit.path}:${hit.line} ${hit.text}${hit.heading ? ` (${hit.heading})` : ""}`);
1196
+ return;
1197
+ }
1198
+ case "show":
1199
+ need(rest, 1, "show <topic>...");
1200
+ for (const [i, topic] of rest.entries()) {
1201
+ const note = isCardPath(topic) ? cardNote(profileCard(profile, topic)) : readMemoryNote(slug, topic);
1202
+ if (rest.length > 1) io.log(`${i ? "\n" : ""}==> ${note.path} <==`);
1203
+ io.stdout(note.text.endsWith("\n") ? note.text : `${note.text}\n`);
1204
+ }
1205
+ return;
1206
+ case "add": {
1207
+ need(rest, 2, "add <topic> <fact>");
1208
+ const [topic, ...fact] = rest;
1209
+ const card = isCardPath(topic) ? writableCard(io, profile, topic) : null;
1210
+ const lines = factLines(fact.join(" "));
1211
+ const results = (lines.length ? lines : [""]).map((line) => card ? addToCard(card, line) : addMemoryFact(slug, topic, line));
1212
+ if (card) for (const r of results.filter((r) => !r.duplicate)) recordCardChange(io, profile, {
1213
+ op: "add",
1214
+ note: r.path,
1215
+ line: r.line
1216
+ });
1217
+ const { path } = results[0];
1218
+ const saved = results.filter((r) => !r.duplicate).length;
1219
+ const verb = results.some((r) => r.created) ? "Started" : "Saved to";
1220
+ if (!saved) io.log(`${path} already has ${results.length === 1 ? "that" : "those"}.`);
1221
+ else if (results.length === 1) io.log(`${verb} ${path}.`);
1222
+ else {
1223
+ const had = results.length - saved;
1224
+ io.log(`${verb} ${path}: ${plural(saved, "fact", "facts")}${had ? `, and ${had} it already had` : ""}.`);
1225
+ }
1226
+ return;
1227
+ }
1228
+ case "replace": {
1229
+ need(rest, 3, "replace <topic> <old text> <new text>");
1230
+ if (isCardPath(rest[0])) {
1231
+ const card = writableCard(io, profile, rest[0]);
1232
+ const replaced = replaceInCard(card, rest[1], rest[2]);
1233
+ recordCardChange(io, profile, {
1234
+ op: "replace",
1235
+ note: replaced.path,
1236
+ line: replaced.after,
1237
+ before: replaced.before
1238
+ });
1239
+ io.log(`Updated ${replaced.path}, ${card.owner}'s card.`);
1240
+ return;
1241
+ }
1242
+ const { path } = replaceInMemory(slug, rest[0], rest[1], rest[2]);
1243
+ io.log(`Updated ${path}.`);
1244
+ return;
1245
+ }
1246
+ case "forget": {
1247
+ need(rest, 2, "forget <topic> <text>");
1248
+ const [topic, ...text] = rest;
1249
+ const { path, removed } = isCardPath(topic) ? forgetInCard(writableCard(io, profile, topic), text.join(" ")) : forgetMemoryFact(slug, topic, text.join(" "));
1250
+ io.log(`Removed from ${path}: ${removed}`);
1251
+ return;
1252
+ }
1253
+ case "write": {
1254
+ need(rest, 1, "write <topic> [text] (without text, the note is read from stdin)");
1255
+ notOnCards("write", rest.slice(0, 1));
1256
+ const [topic, ...text] = rest;
1257
+ if (!text.length && io.stdinIsTTY) throw new Error("give the note as text, or pipe it in: nolune memory write <topic> < note.md");
1258
+ const { path, created } = writeMemoryNote(slug, topic, text.length ? text.join(" ") : await io.readStdin());
1259
+ io.log(`${created ? "Created" : "Rewrote"} ${path}.`);
1260
+ return;
1261
+ }
1262
+ case "rm":
1263
+ need(rest, 1, "rm <topic>");
1264
+ notOnCards("rm", rest.slice(0, 1));
1265
+ io.log(`Deleted ${removeMemoryNote(slug, rest[0]).path}.`);
1266
+ return;
1267
+ case "mv": {
1268
+ need(rest, 2, "mv <topic> <new topic>");
1269
+ notOnCards("mv", rest.slice(0, 2));
1270
+ const moved = moveProfileNote(profile, rest[0], rest[1]);
1271
+ io.log(`Renamed ${moved.from} to ${moved.to}.`);
1272
+ return;
1273
+ }
1274
+ case "merge": {
1275
+ need(rest, 2, "merge <topic> <into topic>");
1276
+ notOnCards("merge", rest.slice(0, 2));
1277
+ const merged = mergeProfileNotes(profile, rest[0], rest[1]);
1278
+ io.log(merged.merged ? `Merged ${merged.from} into ${merged.into}: ${plural(merged.added, "part", "parts")} it didn't have.` : `There was no ${merged.into} yet, so ${merged.from} was renamed to it.`);
1279
+ return;
1280
+ }
1281
+ case "learning": {
1282
+ const [value] = rest;
1283
+ if (value !== void 0 && value !== "on" && value !== "off") throw new Error("usage: nolune memory learning [on|off]");
1284
+ const on = value === void 0 ? profile.learnFromChats : value === "on";
1285
+ if (value !== void 0) setLearnFromChats(profile.id, on);
1286
+ io.log(on ? `nolune looks over ${profile.name}'s chats once they go quiet and saves what's worth remembering.` : `nolune saves to ${profile.name}'s memory only when it thinks of it in a chat.`);
1287
+ return;
1288
+ }
1289
+ default: throw new Error(`unknown memory command "${action}". See \`nolune memory help\`.`);
1290
+ }
1291
+ }
1292
+ /** A card as `show` prints it: an empty one says so. */
1293
+ function cardNote(card) {
1294
+ return readCard(card) ?? {
1295
+ path: card.path,
1296
+ text: `# ${card.owner}\n\n(${card.owner}'s card is empty so far.)\n`
1297
+ };
1298
+ }
1299
+ /** The members' cards, after a profile's notes. */
1300
+ function listCards(io, cards) {
1301
+ if (!cards.length) return;
1302
+ const files = new Map(cardFiles(cards).map((file) => [file.path, file]));
1303
+ io.log(`Cards, which go with each member into all their profiles (${paths.cards}), at most ${MAX_CARD_CHARS} characters each:`);
1304
+ const width = Math.max(...cards.map((card) => card.path.length));
1305
+ for (const card of cards) {
1306
+ const file = files.get(card.path);
1307
+ const facts = file?.facts.length ?? 0;
1308
+ io.log(` ${card.path.padEnd(width)} ${plural(facts, "fact", "facts").padEnd(9)} ${file && facts ? `changed ${formatLocalTime(new Date(file.updatedAt))} ` : ""}(${card.owner}'s)`);
1309
+ }
1310
+ }
1311
+ //#endregion
1312
+ //#region ../relay/src/headers.ts
1313
+ /** Connection-specific headers, which HTTP/2 forbids and every proxy drops. */
1314
+ var HOP_BY_HOP = /* @__PURE__ */ new Set([
1315
+ "connection",
1316
+ "keep-alive",
1317
+ "proxy-connection",
1318
+ "transfer-encoding",
1319
+ "upgrade",
1320
+ "te",
1321
+ "trailer",
1322
+ "host",
1323
+ "http2-settings",
1324
+ "expect"
1325
+ ]);
1326
+ /**
1327
+ * A request's or answer's headers as they go on to the next hop, HTTP/1.1 or HTTP/2: without the
1328
+ * connection-specific ones (and those the Connection header names) or HTTP/2's pseudo-headers.
1329
+ */
1330
+ function endToEnd(headers) {
1331
+ const listed = new Set(String(headers.connection ?? "").split(",").map((token) => token.trim().toLowerCase()));
1332
+ const kept = {};
1333
+ for (const [name, value] of Object.entries(headers)) {
1334
+ if (value === void 0 || name.startsWith(":") || HOP_BY_HOP.has(name) || listed.has(name)) continue;
1335
+ kept[name] = value;
1336
+ }
1337
+ return kept;
1338
+ }
1339
+ //#endregion
1340
+ //#region ../relay/src/stream.ts
1341
+ var OPEN = 1;
1342
+ /** Past this much unsent, writes wait for the socket to catch up. */
1343
+ var HIGH_WATER_MARK = 1048576;
1344
+ /**
1345
+ * Binary messages become the stream's bytes; text messages go to `onText` (protocol messages, never
1346
+ * part of the stream). Reading can't pause the socket, but it needn't: HTTP/2's flow control
1347
+ * bounds what the other side sends. Writing waits while the socket has too much unsent. Ending or
1348
+ * destroying the stream closes the socket, and the socket closing ends the stream's reading side.
1349
+ */
1350
+ function webSocketStream(socket, onText) {
1351
+ socket.binaryType = "arraybuffer";
1352
+ const whenDrained = (callback) => {
1353
+ if (socket.readyState !== OPEN) return callback(/* @__PURE__ */ new Error("the WebSocket closed"));
1354
+ if (socket.bufferedAmount < HIGH_WATER_MARK) return callback();
1355
+ setTimeout(() => whenDrained(callback), 5);
1356
+ };
1357
+ const stream = new Duplex({
1358
+ read() {},
1359
+ write(chunk, _encoding, callback) {
1360
+ if (socket.readyState !== OPEN) return callback(/* @__PURE__ */ new Error("the WebSocket closed"));
1361
+ socket.send(chunk);
1362
+ whenDrained(callback);
1363
+ },
1364
+ final(callback) {
1365
+ socket.close(1e3);
1366
+ callback();
1367
+ },
1368
+ destroy(err, callback) {
1369
+ if (socket.readyState === OPEN) socket.close(err ? 1011 : 1e3);
1370
+ callback(err);
1371
+ }
1372
+ });
1373
+ socket.addEventListener("message", ({ data }) => {
1374
+ if (typeof data === "string") onText?.(data);
1375
+ else if (data instanceof ArrayBuffer) stream.push(Buffer.from(data));
1376
+ });
1377
+ socket.addEventListener("close", () => stream.push(null));
1378
+ return stream;
1379
+ }
1380
+ //#endregion
1381
+ //#region ../cli/src/relay.ts
1382
+ var RELAY_HELP = `Reaching nolune from anywhere (no tunnel, port forwarding or domain of your own)
1383
+ nolune relay enable [--name NAME] get a public address through nolune's relay, like
1384
+ https://NAME.nolune.family (a random name without
1385
+ --name). It passes the family's traffic to this
1386
+ computer, and could see it, as any tunnel could.
1387
+ --server URL uses a relay of your own
1388
+ nolune relay status the address, and whether the gateway is connected
1389
+ nolune relay disable stop using the relay and give the address back`;
1390
+ var NAME_RULE = "a name has 3 to 32 lowercase letters, digits and single dashes, and starts and ends with a letter or digit";
1391
+ var RESTART_HINT = "Restart the gateway to apply it: `nolune service restart`, or stop `nolune start` and run it again.";
1392
+ /** The relay couldn't be reached at all: no answer, rather than a refusal. */
1393
+ var RelayUnreachable = class extends Error {};
1394
+ /** What the relay said when it refused, and its status. */
1395
+ var RelayRefusal = class extends Error {
1396
+ status;
1397
+ constructor(message, status) {
1398
+ super(message);
1399
+ this.status = status;
1400
+ }
1401
+ };
1402
+ function size(bytes) {
1403
+ const gb = bytes / 1024 ** 3;
1404
+ if (gb >= 1) return `${gb >= 10 ? Math.round(gb) : Number(gb.toFixed(1))} GB`;
1405
+ return `${Math.round(bytes / 1024 ** 2)} MB`;
1406
+ }
1407
+ /** A request to the relay's API, with its error in words when it refuses. */
1408
+ async function relayApi(server, path, init = {}) {
1409
+ let res;
1410
+ try {
1411
+ res = await fetch(new URL(path, server), {
1412
+ ...init,
1413
+ signal: AbortSignal.timeout(15e3)
1414
+ });
1415
+ } catch (err) {
1416
+ const cause = err.cause?.message;
1417
+ throw new RelayUnreachable(`couldn't reach the relay at ${server} (${cause ?? err.message})`, { cause: err });
1418
+ }
1419
+ if (res.status === 204) return void 0;
1420
+ const body = await res.json().catch(() => null);
1421
+ if (!res.ok || !body) throw new RelayRefusal(body?.error ?? `the relay at ${server} answered ${res.status}`, res.status);
1422
+ return body;
1423
+ }
1424
+ function registerGateway(server, name) {
1425
+ return relayApi(server, GATEWAYS_PATH, {
1426
+ method: "POST",
1427
+ headers: { "content-type": "application/json" },
1428
+ body: JSON.stringify(name ? { name } : {})
1429
+ });
1430
+ }
1431
+ function gatewayPath(relay) {
1432
+ return `${GATEWAYS_PATH}/${encodeURIComponent(relay.name)}`;
1433
+ }
1434
+ function gatewayStatus(relay) {
1435
+ return relayApi(relay.server, gatewayPath(relay), { headers: { authorization: `Bearer ${relay.token}` } });
1436
+ }
1437
+ function releaseGateway(relay) {
1438
+ return relayApi(relay.server, gatewayPath(relay), {
1439
+ method: "DELETE",
1440
+ headers: { authorization: `Bearer ${relay.token}` }
1441
+ });
1442
+ }
1443
+ /**
1444
+ * Gets an address from the relay and keeps it in config.json, unless there's one already (from
1445
+ * this relay, and with this name when one is asked for) that the relay still knows. A new name
1446
+ * gives the old one back; an address the relay forgot is asked for again.
1447
+ */
1448
+ async function enableRelay(io, opts = {}) {
1449
+ const current = readConfig().relay;
1450
+ const server = (opts.server || io.env.NOLUNE_RELAY_SERVER || current?.server || "https://relay.nolune.dev").replace(/\/+$/, "");
1451
+ let name = opts.name?.trim().toLowerCase() || void 0;
1452
+ if (name !== void 0 && !isValidName(name)) fail$1(NAME_RULE);
1453
+ if (current && current.server === server && (name === void 0 || name === current.name)) {
1454
+ if (await gatewayStatus(current).then(() => true, (err) => !(err instanceof RelayRefusal && err.status === 401))) return {
1455
+ relay: current,
1456
+ created: false
1457
+ };
1458
+ name = current.name;
1459
+ }
1460
+ const registration = await registerGateway(server, name);
1461
+ const relay = {
1462
+ server,
1463
+ name: registration.name,
1464
+ url: registration.url,
1465
+ token: registration.token
1466
+ };
1467
+ updateConfig((c) => {
1468
+ c.relay = relay;
1469
+ });
1470
+ if (current && (current.server !== server || current.name !== relay.name)) await releaseGateway(current).catch(() => {});
1471
+ return {
1472
+ relay,
1473
+ created: true
1474
+ };
1475
+ }
1476
+ async function relayCommand(io, action, args) {
1477
+ switch (action) {
1478
+ case "enable": {
1479
+ const { values } = parseArgs({
1480
+ args,
1481
+ options: {
1482
+ name: { type: "string" },
1483
+ server: { type: "string" }
1484
+ }
1485
+ });
1486
+ const { relay, created } = await enableRelay(io, values);
1487
+ if (!created) {
1488
+ io.log(`The relay is already on: ${relay.url}`);
1489
+ return;
1490
+ }
1491
+ io.log(`nolune's address: ${relay.url}
1492
+ ${RESTART_HINT} Then open the address on any device: everyone signs in with their own account.
1493
+
1494
+ The relay passes traffic between browsers and this computer, and could see it, as any tunnel
1495
+ could. \`nolune relay disable\` stops using it.`);
1496
+ return;
1497
+ }
1498
+ case "status": {
1499
+ const relay = readConfig().relay;
1500
+ if (!relay) {
1501
+ io.log(`The relay is off; nolune's address is ${publicOrigin(readConfig())}.
1502
+ \`nolune relay enable\` gives it one that works from anywhere.`);
1503
+ return;
1504
+ }
1505
+ io.log(`Address ${relay.url}`);
1506
+ io.log(`Relay ${relay.server}`);
1507
+ let status;
1508
+ try {
1509
+ status = await gatewayStatus(relay);
1510
+ } catch (err) {
1511
+ io.log(err instanceof RelayRefusal && err.status === 401 ? "Gateway the relay doesn't know this address any more: nolune asks for it again when it connects, or `nolune relay enable` now" : `Gateway unknown: ${err.message}`);
1512
+ return;
1513
+ }
1514
+ const { online, traffic, blocked } = status;
1515
+ io.log(`Gateway ${online ? "connected" : "not connected: is nolune running? (`nolune service status`)"}`);
1516
+ if (traffic) {
1517
+ const limit = traffic.limit === null ? "" : ` of ${size(traffic.limit)}`;
1518
+ const over = traffic.limit !== null && traffic.bytes >= traffic.limit;
1519
+ io.log(`Traffic ${size(traffic.bytes)}${limit} this month${over ? ": used up, so the address doesn't work until the 1st" : ""}`);
1520
+ }
1521
+ if (blocked) io.log(`Blocked by the relay: ${blocked}`);
1522
+ return;
1523
+ }
1524
+ case "disable": {
1525
+ const relay = readConfig().relay;
1526
+ if (!relay) {
1527
+ io.log("The relay is already off.");
1528
+ return;
1529
+ }
1530
+ let note = "";
1531
+ try {
1532
+ await releaseGateway(relay);
1533
+ } catch (err) {
1534
+ note = `\nThe relay couldn't be told (${err.message}), but only this computer had the address's token, so nothing else can use it.`;
1535
+ }
1536
+ const config = updateConfig((c) => {
1537
+ delete c.relay;
1538
+ });
1539
+ io.log(`Stopped using the relay: ${relay.url} no longer leads here, and nolune's address is ${publicOrigin(config)}.
1540
+ The nolune app for iPhone gets no notifications without it.
1541
+ ${RESTART_HINT}${note}`);
1542
+ return;
1543
+ }
1544
+ default: fail$1("usage: nolune relay enable [--name NAME] [--server URL] | status | disable");
1545
+ }
1546
+ }
1547
+ var READY_TIMEOUT_MS = 3e4;
1548
+ var PING_MS = 3e4;
1549
+ var PING_TIMEOUT_MS = 15e3;
1550
+ var MAX_BACKOFF_MS = 6e4;
1551
+ /** When the relay doesn't know the gateway and it couldn't get its name back: try again later. */
1552
+ var UNKNOWN_RETRY_MS = 3e5;
1553
+ /** Asking for the name again counts as a registration, which the relay limits: once an hour. */
1554
+ var RECLAIM_EVERY_MS = 36e5;
1555
+ /** As the relay's (packages/relay/src/relay.ts): uploads don't crawl over a long distance. */
1556
+ var STREAM_WINDOW_BYTES = 1048576;
1557
+ var SESSION_WINDOW_BYTES = 16777216;
1558
+ /**
1559
+ * Keeps the gateway connected to the relay while it runs, reconnecting whenever the connection
1560
+ * drops (after a moment, then less often while the relay can't be reached), and passes every
1561
+ * request to the gateway's own web server at `target`. `log` gets a line when it connects, and
1562
+ * once when it loses the connection or can't get one, rather than at every try.
1563
+ */
1564
+ function connectRelay(relay, target, log) {
1565
+ const agent = new http.Agent({ keepAlive: true });
1566
+ const hello = {
1567
+ type: "hello",
1568
+ protocol: 1,
1569
+ name: relay.name,
1570
+ token: relay.token
1571
+ };
1572
+ let stopped = false;
1573
+ let retry;
1574
+ let endAttempt;
1575
+ let failures = 0;
1576
+ let reported = false;
1577
+ let wasOnline = false;
1578
+ let reclaimedAt = 0;
1579
+ /** config.json's address, when it's still the one this connection is for. */
1580
+ const sameAddress = (c) => c?.server === relay.server && c.name === relay.name;
1581
+ /**
1582
+ * The relay doesn't know the address: it let the name go while nolune was away for months (or
1583
+ * its operator removed it). Asks for the same name again, and keeps the new token in
1584
+ * config.json. When someone else has the name now, nolune stops using it, so nothing opens their
1585
+ * nolune for this one: 'stop'. 'later' when the relay couldn't be asked, or was asked lately.
1586
+ */
1587
+ async function reclaim() {
1588
+ const current = readConfig().relay;
1589
+ if (!sameAddress(current)) {
1590
+ log("the relay address in config.json changed, so nolune stopped using this one. " + RESTART_HINT);
1591
+ return "stop";
1592
+ }
1593
+ if (current.token !== hello.token) {
1594
+ hello.token = current.token;
1595
+ return "back";
1596
+ }
1597
+ if (Date.now() - reclaimedAt < RECLAIM_EVERY_MS) return "later";
1598
+ reclaimedAt = Date.now();
1599
+ try {
1600
+ const registration = await registerGateway(relay.server, relay.name);
1601
+ hello.token = registration.token;
1602
+ updateConfig((c) => {
1603
+ if (sameAddress(c.relay)) c.relay = {
1604
+ ...c.relay,
1605
+ token: registration.token
1606
+ };
1607
+ });
1608
+ log(`the relay had let ${relay.url} go while nolune was away, so nolune asked for it again`);
1609
+ return "back";
1610
+ } catch (err) {
1611
+ if (err instanceof RelayRefusal && err.status === 409) {
1612
+ updateConfig((c) => {
1613
+ if (sameAddress(c.relay)) delete c.relay;
1614
+ });
1615
+ log(`the relay let ${relay.url} go while nolune was away, and someone else has it now, so nolune stopped using it. \`nolune relay enable\` gets a new address; then restart nolune.`);
1616
+ return "stop";
1617
+ }
1618
+ if (!reported) log(`the relay doesn't know this address (${relay.name}) any more, and nolune couldn't ask for it again (${err.message}). It tries again every hour, or run \`nolune relay enable\` and restart nolune.`);
1619
+ reported = true;
1620
+ return "later";
1621
+ }
1622
+ }
1623
+ /** Passes one request to the web server, and its answer back, both streamed. */
1624
+ function forward(stream, headers) {
1625
+ const request = http.request({
1626
+ host: target.host,
1627
+ port: target.port,
1628
+ agent,
1629
+ method: headers[":method"],
1630
+ path: headers[":path"],
1631
+ headers: {
1632
+ ...endToEnd(headers),
1633
+ host: headers[":authority"]
1634
+ }
1635
+ });
1636
+ let answered = false;
1637
+ request.on("response", (response) => {
1638
+ response.on("end", () => answered = true);
1639
+ if (stream.destroyed) return void response.destroy();
1640
+ try {
1641
+ stream.respond({
1642
+ ":status": response.statusCode ?? 502,
1643
+ ...endToEnd(response.headers)
1644
+ });
1645
+ } catch {
1646
+ response.destroy();
1647
+ stream.close(http2.constants.NGHTTP2_INTERNAL_ERROR);
1648
+ return;
1649
+ }
1650
+ response.pipe(stream);
1651
+ });
1652
+ request.on("error", () => {
1653
+ if (!stream.destroyed) stream.close(http2.constants.NGHTTP2_INTERNAL_ERROR);
1654
+ });
1655
+ stream.on("error", () => {});
1656
+ stream.on("close", () => {
1657
+ if (!answered) request.destroy();
1658
+ });
1659
+ stream.pipe(request);
1660
+ }
1661
+ function retryIn(ms) {
1662
+ retry = setTimeout(attempt, ms);
1663
+ }
1664
+ function attempt() {
1665
+ if (stopped) return;
1666
+ const socket = new WebSocket(new URL(CONNECT_PATH, relay.server.replace(/^http/, "ws")));
1667
+ let session;
1668
+ let ended = false;
1669
+ let pinging;
1670
+ const waiting = setTimeout(() => end(), READY_TIMEOUT_MS);
1671
+ const stream = webSocketStream(socket, (text) => {
1672
+ let message;
1673
+ try {
1674
+ message = JSON.parse(text);
1675
+ } catch {
1676
+ return;
1677
+ }
1678
+ if (message.type !== "ready" || session) return;
1679
+ clearTimeout(waiting);
1680
+ const server = http2.createServer({
1681
+ settings: {
1682
+ initialWindowSize: STREAM_WINDOW_BYTES,
1683
+ maxConcurrentStreams: 256
1684
+ },
1685
+ maxSessionMemory: 64
1686
+ });
1687
+ server.on("stream", forward);
1688
+ server.on("session", (created) => {
1689
+ session = created;
1690
+ created.on("error", () => {});
1691
+ created.on("close", () => end());
1692
+ created.once("connect", () => created.setLocalWindowSize(SESSION_WINDOW_BYTES));
1693
+ });
1694
+ server.emit("connection", stream);
1695
+ pinging = setInterval(ping, PING_MS);
1696
+ log(wasOnline ? "connected to the relay again" : `nolune is reachable at ${message.url}`);
1697
+ wasOnline = true;
1698
+ failures = 0;
1699
+ reported = false;
1700
+ });
1701
+ /** A connection whose network went away never closes by itself: it stops answering. */
1702
+ function ping() {
1703
+ if (!session || session.destroyed) return;
1704
+ const timeout = setTimeout(() => end(), PING_TIMEOUT_MS);
1705
+ session.ping((err) => {
1706
+ clearTimeout(timeout);
1707
+ if (err) end();
1708
+ });
1709
+ }
1710
+ function end(code, reason) {
1711
+ if (ended) return;
1712
+ ended = true;
1713
+ clearTimeout(waiting);
1714
+ clearInterval(pinging);
1715
+ const connected = session !== void 0;
1716
+ session?.destroy();
1717
+ stream.destroy();
1718
+ if (socket.readyState === WebSocket.CONNECTING || socket.readyState === WebSocket.OPEN) socket.close();
1719
+ if (endAttempt === end) endAttempt = void 0;
1720
+ if (stopped) return;
1721
+ if (code === CLOSE.replaced) return log("another nolune connected to the relay with this address and took it over, so this one stopped using it. Only one computer can have an address.");
1722
+ if (code === CLOSE.released) return log("the relay address was given back, so nolune stopped using it. `nolune relay enable` gets a new one.");
1723
+ if (code === CLOSE.blocked) return log(`the relay blocked this address (${reason}), so nolune stopped using it.`);
1724
+ if (code === CLOSE.protocol) return log(`the relay needs a newer nolune (${reason}): update nolune and restart it.`);
1725
+ if (code === CLOSE.unknown) {
1726
+ reclaim().catch(() => "later").then((outcome) => {
1727
+ if (stopped || outcome === "stop") return;
1728
+ retryIn(outcome === "back" ? 0 : UNKNOWN_RETRY_MS);
1729
+ });
1730
+ return;
1731
+ }
1732
+ if (connected) {
1733
+ log("lost the connection to the relay; reconnecting");
1734
+ return retryIn(1e3);
1735
+ }
1736
+ failures++;
1737
+ if (!reported) log(`can't reach the relay at ${relay.server}; trying again`);
1738
+ reported = true;
1739
+ retryIn(Math.min(MAX_BACKOFF_MS, 1e3 * 2 ** failures) * (.5 + Math.random() / 2));
1740
+ }
1741
+ endAttempt = end;
1742
+ socket.addEventListener("open", () => socket.send(JSON.stringify(hello)));
1743
+ socket.addEventListener("close", (event) => end(event.code, event.reason));
1744
+ socket.addEventListener("error", () => end());
1745
+ }
1746
+ attempt();
1747
+ return { close() {
1748
+ stopped = true;
1749
+ clearTimeout(retry);
1750
+ endAttempt?.();
1751
+ agent.destroy();
1752
+ } };
1753
+ }
1754
+ //#endregion
1755
+ //#region ../cli/src/soul.ts
1756
+ var SOUL_HELP = `Soul (who nolune is for a profile: character, values, tone; at most ${MAX_SOUL_CHARS} characters)
1757
+ nolune soul [show] [--profile SLUG] print it
1758
+ nolune soul write [text] replace it (the text, or stdin); every chat gets it
1759
+ from its next message
1760
+ nolune soul rm remove it`;
1761
+ async function soulCommand(io, args) {
1762
+ const { profile: flag, words } = splitProfile(args);
1763
+ const [action = "show", ...rest] = words;
1764
+ if (action === "help") {
1765
+ io.log(SOUL_HELP);
1766
+ return;
1767
+ }
1768
+ const profile = profileFor(io, flag);
1769
+ switch (action) {
1770
+ case "show": {
1771
+ const text = readSoulFile(profile.slug);
1772
+ if (!text) {
1773
+ io.log(`${profile.name} has no soul yet. Start one with: nolune soul write < soul.md`);
1774
+ return;
1775
+ }
1776
+ io.log(text);
1777
+ return;
1778
+ }
1779
+ case "write": {
1780
+ if (!rest.length && io.stdinIsTTY) throw new Error("give the soul as text, or pipe it in: nolune soul write < soul.md");
1781
+ const text = rest.length ? rest.join(" ") : await io.readStdin();
1782
+ if (!text.trim()) throw new Error("the soul is empty. To remove it, use `nolune soul rm`.");
1783
+ writeSoul(profile.slug, text);
1784
+ io.log(`Saved the soul of ${profile.name}. Every chat gets it from its next message.`);
1785
+ return;
1786
+ }
1787
+ case "rm":
1788
+ writeSoul(profile.slug, "");
1789
+ io.log(`Removed the soul of ${profile.name}.`);
1790
+ return;
1791
+ default: throw new Error(`unknown soul command "${action}". See \`nolune soul help\`.`);
1792
+ }
1793
+ }
1794
+ //#endregion
1795
+ //#region ../cli/src/triggers.ts
1796
+ var TRIGGER_HELP = `Automations (results show up as notifications in the web UI)
1797
+ nolune trigger add <name> WHEN WHAT [--summary S] [--icon I] [--preset NAME] [--effort LEVEL]
1798
+ [--profile SLUG]
1799
+ WHEN: --cron "<min hour day month weekday>" (local time) | --at "YYYY-MM-DD HH:MM"
1800
+ | --in 30m|2h|1d | --webhook
1801
+ WHAT: --prompt "<what the agent should do>" | --script "<shell command, no model>"
1802
+ --summary: one plain sentence the family sees on the Automations page
1803
+ --icon: a Lucide icon name for it, like umbrella
1804
+ nolune trigger list [--profile SLUG]
1805
+ nolune trigger show|run|pause|resume|rm <name|id>
1806
+ nolune trigger edit <name|id> [--name N] [--summary S] [--icon I] [WHEN] [WHAT] [--preset NAME]
1807
+ [--effort LEVEL]
1808
+ nolune wake <message> [--title T] [--profile SLUG]
1809
+ start a background agent run now; trigger scripts call this (\`nolune wake -\` reads stdin)`;
1810
+ var OPTIONS = {
1811
+ cron: { type: "string" },
1812
+ at: { type: "string" },
1813
+ in: { type: "string" },
1814
+ webhook: { type: "boolean" },
1815
+ prompt: { type: "string" },
1816
+ script: { type: "string" },
1817
+ name: { type: "string" },
1818
+ summary: { type: "string" },
1819
+ icon: { type: "string" },
1820
+ title: { type: "string" },
1821
+ preset: { type: "string" },
1822
+ effort: { type: "string" },
1823
+ profile: { type: "string" }
1824
+ };
1825
+ function parse(args) {
1826
+ return parseArgs({
1827
+ args,
1828
+ allowPositionals: true,
1829
+ options: OPTIONS
1830
+ });
1831
+ }
1832
+ function optionalProfile(io, flag) {
1833
+ return flag || io.env.NOLUNE_PROFILE ? profileFor(io, flag) : void 0;
1834
+ }
1835
+ function whenFrom(values) {
1836
+ if ([
1837
+ values.cron,
1838
+ values.at,
1839
+ values.in,
1840
+ values.webhook
1841
+ ].filter((v) => v !== void 0).length > 1) throw new Error("give only one of --cron, --at, --in and --webhook");
1842
+ if (values.cron !== void 0) return {
1843
+ kind: "cron",
1844
+ cron: values.cron
1845
+ };
1846
+ if (values.at !== void 0) return {
1847
+ kind: "once",
1848
+ runAt: parseRunAt(values.at)
1849
+ };
1850
+ if (values.in !== void 0) return {
1851
+ kind: "once",
1852
+ runAt: parseRunAt(values.in)
1853
+ };
1854
+ if (values.webhook) return { kind: "webhook" };
1855
+ }
1856
+ function whatFrom(values) {
1857
+ if (values.prompt !== void 0 && values.script !== void 0) throw new Error("give either --prompt or --script, not both");
1858
+ if (values.prompt !== void 0) return {
1859
+ action: "agent",
1860
+ prompt: values.prompt
1861
+ };
1862
+ if (values.script !== void 0) return {
1863
+ action: "script",
1864
+ command: values.script
1865
+ };
1866
+ }
1867
+ function effortFrom(values) {
1868
+ if (values.effort === void 0) return void 0;
1869
+ if (!EFFORTS.includes(values.effort)) throw new Error(`--effort must be one of ${EFFORTS.join(", ")}`);
1870
+ return values.effort;
1871
+ }
1872
+ function shortId(t) {
1873
+ return t.id.slice(0, 8);
1874
+ }
1875
+ function status(t) {
1876
+ if (isFinished(t)) return "done";
1877
+ if (!t.enabled) return "paused";
1878
+ if (t.nextRunAt) return `next ${formatLocalTime(t.nextRunAt)}`;
1879
+ return "waiting for its webhook";
1880
+ }
1881
+ function printWebhook(io, t) {
1882
+ if (!t.webhookToken) return;
1883
+ const url = webhookUrl(t.webhookToken);
1884
+ io.log(`Webhook URL (keep it secret: anyone with it can start a run):
1885
+ ${url}
1886
+ Send JSON; form-encoded and text/plain bodies are refused (cross-site protection), e.g.:
1887
+ curl -X POST -H 'content-type: application/json' -d '{"text":"hello"}' '${url}'`);
1888
+ }
1889
+ function describeWhat(t) {
1890
+ return t.action === "agent" ? "wakes the agent with its prompt" : `runs \`${t.command}\``;
1891
+ }
1892
+ function triggerCommand(io, action, args) {
1893
+ const { values, positionals } = parse(args);
1894
+ const ref = () => {
1895
+ if (!positionals[0]) throw new Error("missing <name|id>. See `nolune trigger list`.");
1896
+ return findTrigger(positionals[0], optionalProfile(io, values.profile)?.id);
1897
+ };
1898
+ switch (action) {
1899
+ case void 0:
1900
+ case "help":
1901
+ io.log(TRIGGER_HELP);
1902
+ return;
1903
+ case "add": {
1904
+ const name = positionals[0];
1905
+ if (!name) throw new Error("missing <name>. See `nolune help`.");
1906
+ const when = whenFrom(values);
1907
+ if (!when) throw new Error("say when: --cron, --at, --in or --webhook");
1908
+ const what = whatFrom(values);
1909
+ if (!what) throw new Error("say what: --prompt or --script");
1910
+ const profile = profileFor(io, values.profile);
1911
+ const preset = resolvePreset(values.preset, io.env.NOLUNE_CONVERSATION_ID);
1912
+ const t = createTrigger({
1913
+ profileId: profile.id,
1914
+ name,
1915
+ summary: values.summary,
1916
+ icon: values.icon,
1917
+ when,
1918
+ what,
1919
+ presetId: preset?.id ?? null,
1920
+ effort: effortFrom(values)
1921
+ });
1922
+ io.log(`Added "${t.name}" (${shortId(t)}) to ${profile.slug}: ${describeWhen(t)}, ${describeWhat(t)}.`);
1923
+ if (t.nextRunAt) io.log(`Next run: ${formatLocalTime(t.nextRunAt)}`);
1924
+ printWebhook(io, t);
1925
+ return;
1926
+ }
1927
+ case "list": {
1928
+ const profile = optionalProfile(io, values.profile);
1929
+ const slugs = new Map(listProfiles().map((p) => [p.id, p.slug]));
1930
+ const triggers = listTriggers(profile?.id);
1931
+ if (!triggers.length) io.log("No triggers.");
1932
+ for (const t of triggers) {
1933
+ const where = profile ? "" : `${slugs.get(t.profileId)}\t`;
1934
+ io.log(`${shortId(t)}\t${where}${t.name}\t${describeWhen(t)}\t${t.action === "agent" ? "prompt" : "script"}\t${status(t)}`);
1935
+ }
1936
+ return;
1937
+ }
1938
+ case "show": {
1939
+ const t = ref();
1940
+ const preset = t.presetId ? getPreset(t.presetId) : void 0;
1941
+ io.log(`${t.name} (${t.id})
1942
+ summary ${t.summary ?? "(none: the Automations page shows only the name)"}
1943
+ icon ${t.icon ?? "(none)"}
1944
+ profile ${getProfile(t.profileId)?.slug ?? "?"}
1945
+ when ${describeWhen(t)} (${status(t)})
1946
+ ${t.action === "agent" ? `prompt ${t.prompt}` : `script ${t.command}`}
1947
+ model ${preset?.name ?? "default preset"}, reasoning ${t.effort}`);
1948
+ printWebhook(io, t);
1949
+ const runs = listRuns(t.id, 10);
1950
+ io.log(runs.length ? "Recent runs:" : "No runs yet.");
1951
+ for (const run of runs) {
1952
+ const firstLine = run.status === "failed" && run.output ? `: ${run.output.split("\n")[0]}` : "";
1953
+ io.log(` ${formatLocalTime(run.createdAt)}\t${run.action}\t${run.source}\t${run.status}${firstLine}`);
1954
+ }
1955
+ const lastScript = runs.find((r) => r.action === "script" && r.output);
1956
+ if (lastScript) io.log(`Output of the last script run:\n${lastScript.output}`);
1957
+ return;
1958
+ }
1959
+ case "run": {
1960
+ const t = ref();
1961
+ queueRun(t, "manual");
1962
+ io.log(`Queued "${t.name}". The gateway starts it within a few seconds.`);
1963
+ return;
1964
+ }
1965
+ case "pause":
1966
+ case "resume": {
1967
+ const t = setTriggerEnabled(ref().id, action === "resume");
1968
+ io.log(`"${t.name}" is ${action === "resume" ? `on (${status(t)})` : "paused"}.`);
1969
+ return;
1970
+ }
1971
+ case "rm": {
1972
+ const t = ref();
1973
+ deleteTrigger(t.id);
1974
+ io.log(`Removed "${t.name}".`);
1975
+ return;
1976
+ }
1977
+ case "edit": {
1978
+ const current = ref();
1979
+ const preset = values.preset ? resolvePreset(values.preset) : void 0;
1980
+ const t = updateTrigger(current.id, {
1981
+ name: values.name,
1982
+ summary: values.summary,
1983
+ icon: values.icon,
1984
+ when: whenFrom(values),
1985
+ what: whatFrom(values),
1986
+ presetId: preset?.id,
1987
+ effort: effortFrom(values)
1988
+ });
1989
+ io.log(`Updated "${t.name}": ${describeWhen(t)}, ${describeWhat(t)} (${status(t)}).`);
1990
+ if (t.webhookToken && !current.webhookToken) printWebhook(io, t);
1991
+ return;
1992
+ }
1993
+ default: throw new Error("usage: nolune trigger help|add|list|show|run|pause|resume|rm|edit");
1994
+ }
1995
+ }
1996
+ /** Queues a background agent run. Inside a trigger's script, the run belongs to that trigger. */
1997
+ async function wakeCommand(io, args) {
1998
+ const { values, positionals } = parse(args);
1999
+ const given = positionals.join(" ").trim();
2000
+ const text = given === "-" ? (io.stdinIsTTY ? "" : await io.readStdin()).trim() : given;
2001
+ if (!text) throw new Error("usage: nolune wake <what happened and what to do> (or - to read stdin)");
2002
+ const t = io.env.NOLUNE_TRIGGER_ID ? getTrigger(io.env.NOLUNE_TRIGGER_ID) : void 0;
2003
+ const profileId = t?.profileId ?? profileFor(io, values.profile).id;
2004
+ const preset = values.preset || !t ? resolvePreset(values.preset, io.env.NOLUNE_CONVERSATION_ID) : void 0;
2005
+ const run = queueWake({
2006
+ profileId,
2007
+ triggerId: t?.id,
2008
+ text,
2009
+ title: values.title,
2010
+ presetId: preset?.id,
2011
+ effort: effortFrom(values)
2012
+ });
2013
+ io.log(`Woke nolune ("${run.title}"). Its reply shows up as a notification.`);
2014
+ }
2015
+ //#endregion
2016
+ //#region ../cli/src/service.ts
2017
+ var logFile = join(paths.logs, "gateway.log");
2018
+ /** macOS LaunchAgent: runs as the logged-in user, so commands get their home folder and files. */
2019
+ var LABEL = "dev.nolune.gateway";
2020
+ var plistPath = join(homedir(), "Library", "LaunchAgents", `${LABEL}.plist`);
2021
+ function target() {
2022
+ return `gui/${process.getuid?.() ?? 501}/${LABEL}`;
2023
+ }
2024
+ function launchctl(...args) {
2025
+ return spawnSync("launchctl", args, { encoding: "utf8" });
2026
+ }
2027
+ function escapeXml(text) {
2028
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2029
+ }
2030
+ function renderPlist() {
2031
+ return `<?xml version="1.0" encoding="UTF-8"?>
2032
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2033
+ <plist version="1.0">
2034
+ <dict>
2035
+ <key>Label</key>
2036
+ <string>${LABEL}</string>
2037
+ <key>ProgramArguments</key>
2038
+ <array>
2039
+ ${[...cliCommand(), "start"].map((a) => `\t\t<string>${escapeXml(a)}</string>`).join("\n")}
2040
+ </array>
2041
+ <key>EnvironmentVariables</key>
2042
+ <dict>
2043
+ <key>NOLUNE_HOME</key>
2044
+ <string>${escapeXml(paths.home)}</string>
2045
+ </dict>
2046
+ <key>WorkingDirectory</key>
2047
+ <string>${escapeXml(paths.home)}</string>
2048
+ <key>RunAtLoad</key>
2049
+ <true/>
2050
+ <key>KeepAlive</key>
2051
+ <true/>
2052
+ <key>ThrottleInterval</key>
2053
+ <integer>10</integer>
2054
+ <key>StandardOutPath</key>
2055
+ <string>${escapeXml(logFile)}</string>
2056
+ <key>StandardErrorPath</key>
2057
+ <string>${escapeXml(logFile)}</string>
2058
+ </dict>
2059
+ </plist>
2060
+ `;
2061
+ }
2062
+ var launchAgent = {
2063
+ file: plistPath,
2064
+ render: renderPlist,
2065
+ async install() {
2066
+ mkdirSync(dirname(plistPath), { recursive: true });
2067
+ mkdirSync(paths.logs, { recursive: true });
2068
+ writeFileSync(plistPath, renderPlist());
2069
+ launchctl("bootout", target());
2070
+ for (let attempt = 0;; attempt++) {
2071
+ const result = launchctl("bootstrap", `gui/${process.getuid?.() ?? 501}`, plistPath);
2072
+ if (result.status === 0) return false;
2073
+ if (attempt >= 10) throw new Error(`launchctl bootstrap failed: ${result.stderr.trim()}`);
2074
+ await setTimeout$1(300);
2075
+ }
2076
+ },
2077
+ uninstall() {
2078
+ launchctl("bootout", target());
2079
+ if (existsSync(plistPath)) unlinkSync(plistPath);
2080
+ },
2081
+ restart() {
2082
+ if (launchctl("kickstart", "-k", target()).status !== 0) throw new Error("The service is not loaded. Run `nolune service install` first.");
2083
+ },
2084
+ status() {
2085
+ const result = launchctl("print", target());
2086
+ const pid = /\bpid = (\d+)/.exec(result.stdout ?? "")?.[1];
2087
+ return {
2088
+ installed: existsSync(plistPath),
2089
+ loaded: result.status === 0,
2090
+ pid: pid ? Number(pid) : null
2091
+ };
2092
+ }
2093
+ };
2094
+ /**
2095
+ * Linux: a systemd user service, so like the LaunchAgent it runs as this user. systemd runs a
2096
+ * user's services from their first login to their last logout, or from boot when they linger
2097
+ * (`loginctl enable-linger`), which install turns on when logind lets it.
2098
+ */
2099
+ var UNIT = "nolune.service";
2100
+ var configHome = process.env.XDG_CONFIG_HOME;
2101
+ var unitPath = join(configHome && isAbsolute(configHome) ? configHome : join(homedir(), ".config"), "systemd", "user", UNIT);
2102
+ /** `%` starts a specifier in a unit file (`%h` is the home folder), so a literal one is doubled. */
2103
+ function unitValue(text) {
2104
+ return text.replace(/%/g, "%%");
2105
+ }
2106
+ /** One quoted word, as an Environment= assignment is. */
2107
+ function unitWord(text) {
2108
+ return `"${unitValue(text).replace(/[\\"]/g, "\\$&")}"`;
2109
+ }
2110
+ /**
2111
+ * ExecStart=: the program's path is taken as it is (systemd refuses one with quotes or
2112
+ * backslashes), while its arguments expand `$NAME`, so a literal `$` in them is `$$`.
2113
+ */
2114
+ function execLine([program, ...args]) {
2115
+ return [unitWord(program), ...args.map((a) => unitWord(a).replace(/\$/g, () => "$$"))].join(" ");
2116
+ }
2117
+ /** Type=exec and append: need systemd 240 (2018) or later. */
2118
+ function renderUnit() {
2119
+ return `[Unit]
2120
+ Description=nolune gateway
2121
+
2122
+ [Service]
2123
+ Type=exec
2124
+ ExecStart=${execLine([...cliCommand(), "start"])}
2125
+ Environment=${unitWord(`NOLUNE_HOME=${paths.home}`)}
2126
+ WorkingDirectory=${unitValue(paths.home)}
2127
+ Restart=always
2128
+ RestartSec=10
2129
+ StandardOutput=append:${unitValue(logFile)}
2130
+ StandardError=append:${unitValue(logFile)}
2131
+
2132
+ [Install]
2133
+ WantedBy=default.target
2134
+ `;
2135
+ }
2136
+ /** Runs `systemctl --user`, failing when there's no systemd user manager to talk to. */
2137
+ function systemctl(...args) {
2138
+ const result = spawnSync("systemctl", ["--user", ...args], { encoding: "utf8" });
2139
+ const unreachable = result.error ? "there is no systemctl" : /Failed to connect to .*bus|not been booted with systemd/.test(result.stderr) ? result.stderr.trim().split("\n")[0] : null;
2140
+ if (unreachable) throw new Error(`\`nolune service\` runs nolune as a systemd user service, and this user's systemd can't be reached (${unreachable}). Log in as this user directly, not with su or sudo, or run \`nolune start\` under your own process manager.`);
2141
+ return result;
2142
+ }
2143
+ function systemctlOrFail(...args) {
2144
+ const result = systemctl(...args);
2145
+ if (result.status !== 0) throw new Error(`systemctl --user ${args.join(" ")} failed: ${result.stderr.trim()}`);
2146
+ }
2147
+ function lingering() {
2148
+ return existsSync(join("/var/lib/systemd/linger", userInfo().username));
2149
+ }
2150
+ var systemdUnit = {
2151
+ file: unitPath,
2152
+ render: renderUnit,
2153
+ async install() {
2154
+ systemctl("show-environment");
2155
+ mkdirSync(dirname(unitPath), { recursive: true });
2156
+ mkdirSync(paths.logs, { recursive: true });
2157
+ writeFileSync(unitPath, renderUnit());
2158
+ systemctlOrFail("daemon-reload");
2159
+ systemctlOrFail("enable", UNIT);
2160
+ systemctlOrFail("restart", UNIT);
2161
+ if (lingering()) return true;
2162
+ return spawnSync("loginctl", ["enable-linger", "--no-ask-password"]).status === 0;
2163
+ },
2164
+ uninstall() {
2165
+ systemctl("disable", "--now", UNIT);
2166
+ if (existsSync(unitPath)) unlinkSync(unitPath);
2167
+ systemctl("daemon-reload");
2168
+ systemctl("reset-failed", UNIT);
2169
+ },
2170
+ restart() {
2171
+ const result = systemctl("restart", UNIT);
2172
+ if (result.status === 0) return;
2173
+ if (!existsSync(unitPath)) throw new Error("The service is not installed. Run `nolune service install` first.");
2174
+ throw new Error(`systemctl --user restart ${UNIT} failed: ${result.stderr.trim()}`);
2175
+ },
2176
+ status() {
2177
+ const { stdout } = systemctl("show", UNIT, "--property=ActiveState,MainPID");
2178
+ const state = /^ActiveState=(.*)$/m.exec(stdout)?.[1];
2179
+ const pid = Number(/^MainPID=(\d+)$/m.exec(stdout)?.[1] ?? 0);
2180
+ return {
2181
+ installed: existsSync(unitPath),
2182
+ loaded: state !== void 0 && state !== "inactive",
2183
+ pid: state === "active" && pid > 0 ? pid : null
2184
+ };
2185
+ }
2186
+ };
2187
+ /**
2188
+ * nolune.app's: the app runs `Nolune --gateway` as its child while it's open, which keeps
2189
+ * `nolune start` running and writes its own pid here. SIGHUP has it start the gateway again.
2190
+ */
2191
+ var appPidFile = join(paths.home, "gateway.pid");
2192
+ /** The app's gateway keeper, when it's running. */
2193
+ function appKeeperPid(pidFile = appPidFile) {
2194
+ let pid;
2195
+ try {
2196
+ pid = Number(readFileSync(pidFile, "utf8").trim());
2197
+ } catch {
2198
+ return null;
2199
+ }
2200
+ if (!Number.isInteger(pid) || pid <= 0) return null;
2201
+ const ps = spawnSync("ps", [
2202
+ "-p",
2203
+ String(pid),
2204
+ "-o",
2205
+ "comm="
2206
+ ], { encoding: "utf8" });
2207
+ return ps.status === 0 && /(^|\/)Nolune$/.test(ps.stdout.trim()) ? pid : null;
2208
+ }
2209
+ function runByApp() {
2210
+ throw new Error("the nolune app runs the gateway while it is open.");
2211
+ }
2212
+ var appGateway = {
2213
+ file: appPidFile,
2214
+ render: runByApp,
2215
+ install: runByApp,
2216
+ uninstall: runByApp,
2217
+ restart() {
2218
+ const pid = appKeeperPid();
2219
+ if (pid === null) throw new Error("nolune isn't running. Open the nolune app.");
2220
+ process.kill(pid, "SIGHUP");
2221
+ },
2222
+ status() {
2223
+ const pid = appKeeperPid();
2224
+ return {
2225
+ installed: true,
2226
+ loaded: pid !== null,
2227
+ pid
2228
+ };
2229
+ }
2230
+ };
2231
+ function manager() {
2232
+ if (process.platform === "darwin") return appManaged() ? appGateway : launchAgent;
2233
+ if (process.platform === "linux") return systemdUnit;
2234
+ throw new Error("`nolune service` runs nolune in the background on macOS (a LaunchAgent) and Linux (a systemd user service). Here, run `nolune start` under your own process manager.");
2235
+ }
2236
+ /** The LaunchAgent's plist or the systemd unit that `install` writes here. */
2237
+ function renderServiceFile() {
2238
+ return manager().render();
2239
+ }
2240
+ async function installService() {
2241
+ const service = manager();
2242
+ return {
2243
+ file: service.file,
2244
+ atBoot: await service.install()
2245
+ };
2246
+ }
2247
+ function uninstallService() {
2248
+ manager().uninstall();
2249
+ }
2250
+ function restartService() {
2251
+ manager().restart();
2252
+ }
2253
+ function serviceStatus() {
2254
+ return manager().status();
2255
+ }
2256
+ //#endregion
2257
+ //#region ../cli/src/web.ts
2258
+ var WEB_HELP = `The web (through Firecrawl: its free tier, limited per day, until \`nolune key set firecrawl\`)
2259
+ nolune web search <query> [--limit N] [--news] [--recent day|week|month|year] [--country CC]
2260
+ the top results' titles, addresses and snippets
2261
+ (5 unless --limit, at most 20); --news for news
2262
+ articles, --country as someone there sees them (de)
2263
+ nolune web read <url> [--out FILE] a page's main text (or a PDF's) as Markdown; a long
2264
+ one is saved whole to a file, whose path it prints`;
2265
+ /** More than this and the page goes to a file: a command's output is cut at 30 KB. */
2266
+ var MAX_PRINTED = 2e4;
2267
+ function expandHome(path) {
2268
+ if (path === "~") return homedir();
2269
+ return path.startsWith("~/") ? join(homedir(), path.slice(2)) : path;
2270
+ }
2271
+ async function search(io, args) {
2272
+ const { values, positionals } = parseArgs({
2273
+ args,
2274
+ allowPositionals: true,
2275
+ options: {
2276
+ limit: {
2277
+ type: "string",
2278
+ short: "n"
2279
+ },
2280
+ news: { type: "boolean" },
2281
+ recent: { type: "string" },
2282
+ country: { type: "string" }
2283
+ }
2284
+ });
2285
+ const query = positionals.join(" ").trim();
2286
+ if (!query) throw new Error("say what to look for: nolune web search \"<query>\"");
2287
+ const limit = values.limit === void 0 ? 5 : Number(values.limit);
2288
+ if (!Number.isInteger(limit) || limit < 1 || limit > 20) throw new Error(`--limit is between 1 and 20.`);
2289
+ const recent = values.recent?.trim().toLowerCase();
2290
+ if (recent !== void 0 && !Object.hasOwn(WEB_RECENT, recent)) throw new Error(`--recent is one of ${Object.keys(WEB_RECENT).join(", ")}.`);
2291
+ const country = values.country?.trim();
2292
+ if (country !== void 0 && !/^[a-z]{2}$/i.test(country)) throw new Error("--country is a two-letter country code, like de or us.");
2293
+ const { results, warning } = await searchWeb(query, {
2294
+ limit,
2295
+ news: values.news,
2296
+ recent,
2297
+ country,
2298
+ env: io.env,
2299
+ signal: io.signal
2300
+ });
2301
+ if (warning) io.log(`Firecrawl: ${warning}`);
2302
+ if (!results.length) {
2303
+ io.log(`No results for "${query}".`);
2304
+ return;
2305
+ }
2306
+ io.log(results.map((r, i) => {
2307
+ const text = [r.text, r.date && `(${r.date})`].filter(Boolean).join(" ");
2308
+ return `${i + 1}. ${r.title}\n ${r.url}${text ? `\n ${text}` : ""}`;
2309
+ }).join("\n\n"));
2310
+ }
2311
+ /** A name for the page's file: when it was read, and its address in a few words. */
2312
+ function fileName(url, now) {
2313
+ const p = (n) => String(n).padStart(2, "0");
2314
+ const stamp = `${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())}-${p(now.getHours())}${p(now.getMinutes())}${p(now.getSeconds())}`;
2315
+ const { hostname, pathname } = new URL(url);
2316
+ return `${stamp}-${`${hostname.replace(/^www\./, "")} ${pathname}`.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/, "") || "page"}.md`;
2317
+ }
2318
+ function pageText(page) {
2319
+ return `${page.title ? `# ${page.title}\n` : ""}${page.url}\n\n${page.markdown}\n`;
2320
+ }
2321
+ async function read(io, args) {
2322
+ const { values, positionals } = parseArgs({
2323
+ args,
2324
+ allowPositionals: true,
2325
+ options: { out: {
2326
+ type: "string",
2327
+ short: "o"
2328
+ } }
2329
+ });
2330
+ if (positionals.length !== 1) throw new Error("usage: nolune web read <url> [--out FILE]");
2331
+ const page = await readWebPage(positionals[0], {
2332
+ env: io.env,
2333
+ signal: io.signal
2334
+ });
2335
+ if (page.warning) io.log(`Firecrawl: ${page.warning}`);
2336
+ if (page.status) io.log(`The page answered ${page.status}; this is what it showed.`);
2337
+ if (!page.markdown) {
2338
+ io.log(`${page.url} has no text Firecrawl could read.`);
2339
+ return;
2340
+ }
2341
+ const text = pageText(page);
2342
+ if (values.out) {
2343
+ const file = resolve(io.cwd, expandHome(values.out));
2344
+ mkdirSync(dirname(file), { recursive: true });
2345
+ writeFileSync(file, text);
2346
+ io.log(`Saved ${page.url} (${text.length} characters) to ${file}`);
2347
+ return;
2348
+ }
2349
+ if (text.length <= MAX_PRINTED) {
2350
+ io.stdout(text);
2351
+ return;
2352
+ }
2353
+ const dir = join(io.env.TMPDIR || tmpdir(), "nolune-web");
2354
+ const file = join(dir, fileName(page.url, /* @__PURE__ */ new Date()));
2355
+ mkdirSync(dir, { recursive: true });
2356
+ writeFileSync(file, text);
2357
+ const cut = text.lastIndexOf("\n", MAX_PRINTED);
2358
+ const shown = text.slice(0, cut > MAX_PRINTED / 2 ? cut : MAX_PRINTED);
2359
+ io.log(`${shown}\n\n[${text.length - shown.length} more characters. The whole page is in ${file}: grep it, or read on with sed -n.]`);
2360
+ }
2361
+ async function webCommand(io, action, args) {
2362
+ if (action === "search") return search(io, args);
2363
+ if (action === "read") return read(io, args);
2364
+ throw new Error("usage: nolune web search <query> | nolune web read <url>. See `nolune help`.");
2365
+ }
2366
+ //#endregion
2367
+ //#region ../cli/src/run.ts
2368
+ /** Built when shown, like generateHelp(): the gateway serves it for as long as it runs. */
2369
+ var help = () => `nolune - a family agent that runs on this computer
2370
+
2371
+ Getting started
2372
+ nolune setup interactive first-time setup (your account, and the
2373
+ address the family opens: nolune's relay, this
2374
+ computer, or your own URL); the model comes after: a
2375
+ new profile's welcome on the web asks for one, or use
2376
+ key set and preset add below
2377
+ nolune start run the gateway in the foreground
2378
+ nolune service install|uninstall|restart|status|logs [-f]
2379
+ run it in the background (macOS, or Linux with systemd)
2380
+
2381
+ ${RELAY_HELP}
2382
+
2383
+ Settings (${paths.home})
2384
+ nolune config show address, port and what's configured
2385
+ nolune config set <host|port|origin> <value> origin = the public URL people open (the relay's
2386
+ address is used instead while the relay is on)
2387
+ nolune config set image-model <provider/model> for pictures, e.g. openai/gpt-image-2.5-flare
2388
+ nolune config set embeddings <auto|off|provider/model>
2389
+ what memory search finds meaning with: auto uses the
2390
+ OpenAI key, else OpenRouter's; the provider is openai,
2391
+ openrouter or custom-openai (a custom provider's model,
2392
+ like custom-openai/ollama/nomic-embed-text)
2393
+ nolune config set claude-path <path> the Claude Code that claude-plan chats run (found on
2394
+ the PATH and in its usual folders otherwise)
2395
+ nolune config set command-mode <auto|unrestricted>
2396
+ auto (the default): a model checks each command the
2397
+ agent runs and blocks what could do harm nobody asked
2398
+ for; unrestricted runs them unchecked (not
2399
+ recommended). Not from the agent's own commands
2400
+ nolune config set safety-model <preset|chat> the preset whose model does auto mode's checks, or
2401
+ chat for each chat's own model (the default)
2402
+ nolune config set update-check <on|off> on (the default): the gateway asks GitHub once a
2403
+ day for nolune's newest release, and admins see when
2404
+ there's one
2405
+ nolune config set compact-when-idle <minutes|off>
2406
+ summarize a chat after that many minutes without a
2407
+ message, so its next reply reads less; off (the
2408
+ default): only near the model's window, or on request
2409
+ nolune key set <anthropic|openai|openrouter|xai|firecrawl> [key]
2410
+ store an API key (prompts if omitted) after checking
2411
+ it; OpenAI's runs GPT chats and makes pictures, xAI's
2412
+ runs Grok, Firecrawl's lifts the web search's daily
2413
+ limit. Admins can also do this on the web, under
2414
+ Models & keys
2415
+ nolune key rm <anthropic|openai|openrouter|xai|firecrawl>
2416
+ remove a stored key (the environment's is used, if set)
2417
+ nolune env set <NAME> <value> extra env var for agent commands (e.g. HASS_TOKEN)
2418
+ nolune env rm <NAME> | nolune env list
2419
+
2420
+ Custom providers (model servers of your own: Ollama, LM Studio, oMLX, vLLM, llama.cpp...)
2421
+ nolune provider add <name> <url> [--api openai|anthropic] [--key K]
2422
+ add one, through its OpenAI API (the default) or its
2423
+ Anthropic API, or change the address and key of the
2424
+ one of that name; nolune asks it for its models first,
2425
+ and for its key at a terminal when it wants one. The
2426
+ address is the server's, like http://localhost:11434.
2427
+ A server that speaks both can be added once for each
2428
+ nolune provider rm <name|id> presets on it stop working until they're moved
2429
+ nolune provider list
2430
+
2431
+ Plans (chats on your own subscription instead of an API key)
2432
+ claude-plan: a Claude Pro or Max plan, through Claude Code on this computer, signed in to your
2433
+ Claude account; Claude Code keeps the sign-in. chatgpt-plan: a ChatGPT Plus or Pro plan, signed
2434
+ in with ChatGPT (Sign in with ChatGPT), which nolune keeps in ~/.nolune/chatgpt.json.
2435
+ Plan limits assume one person's ordinary use: keep busy automations and subagents on an API key.
2436
+ nolune <plan> status who it's signed in as (and which Claude Code runs)
2437
+ nolune claude-plan setup install Claude Code and sign in, where needed,
2438
+ asking first, in a terminal
2439
+ nolune chatgpt-plan setup [--another-account] sign in with ChatGPT in a browser, where needed; from
2440
+ another device, paste the address it ends on. Signs
2441
+ in to the account used last unless told otherwise
2442
+ nolune chatgpt-plan logout sign out; chats on chatgpt-plan presets stop until
2443
+ someone signs in again
2444
+ nolune chatgpt-plan models the models the plan offers, for \`nolune preset add\`
2445
+ nolune-plan: a subscription to nolune itself, which covers chats, pictures and memory search
2446
+ with no keys at all, on the month's credits. Linked with a code you approve on nolune's page,
2447
+ from any device; nolune keeps the link in ~/.nolune/nolune-plan.json. Subscribe at
2448
+ https://api.nolune.dev.
2449
+ nolune nolune-plan setup link nolune to your plan, where needed
2450
+ nolune nolune-plan logout unlink; chats on nolune-plan presets stop until it's
2451
+ linked again
2452
+ nolune nolune-plan models the models the plan offers, for \`nolune preset add\`
2453
+
2454
+ Users (there's no sign-up page: admins add people here, or on the People page)
2455
+ nolune user create <name> <email> [--password P] [--admin]
2456
+ nolune user invite [name] a link to send, where they make their own account
2457
+ (once, within 7 days); name: who it's for
2458
+ nolune user passwd <name|email> [--password P]
2459
+ nolune user admin <name|email> [--off]
2460
+ nolune user rm <name|email>
2461
+ nolune user list name, email, admin, and their picture's
2462
+ file if they have one
2463
+
2464
+ Model presets (shared by all profiles)
2465
+ nolune preset add <model> [--provider anthropic|openai|openrouter|xai|claude-plan|chatgpt-plan|nolune-plan|<custom>]
2466
+ [--name N] [--context-window TOKENS]
2467
+ the provider checks the model id first (anthropic
2468
+ unless given); OpenAI models other than the
2469
+ flagships need --context-window. OpenRouter's ids
2470
+ name their maker (anthropic/claude-sonnet-5), and the
2471
+ model must be able to call tools. xAI's are Grok's
2472
+ (grok-4.7), and it lists them with their windows. A
2473
+ custom provider (by its name) lists its models; its
2474
+ model must call tools too, which shows at its first
2475
+ reply, and pictures and PDFs reach it as paths. The
2476
+ plans check their sign-in instead, and chatgpt-plan
2477
+ the models the plan offers
2478
+ nolune preset edit <name|id> [--provider P] [--model M] [--name N]
2479
+ [--context-window TOKENS|auto]
2480
+ change what's given; a new model is checked like
2481
+ add's. Chats already on the preset keep what they had
2482
+ nolune preset rm <name|id>
2483
+ nolune preset default <name|id> the model new chats start with
2484
+ nolune preset list
2485
+
2486
+ ${PROFILE_HELP}
2487
+ nolune skill new <name> [--description D] [--profile SLUG | --global]
2488
+ nolune skill list [--profile SLUG]
2489
+ nolune skill enable <name>... [--profile SLUG]
2490
+ nolune skill disable <name>... [--profile SLUG] leave out of the profile's chats
2491
+
2492
+ ${MCP_HELP}
2493
+
2494
+ ${TRIGGER_HELP}
2495
+
2496
+ ${MEMORY_HELP}
2497
+
2498
+ ${CARD_HELP}
2499
+
2500
+ ${SOUL_HELP}
2501
+
2502
+ ${generateHelp()}
2503
+
2504
+ ${WEB_HELP}
2505
+
2506
+ Inside agent commands (NOLUNE_PROFILE is set, so --profile can be left out)
2507
+ nolune view <image>... show images to the agent: they're attached to the
2508
+ command's result (HEIC and big photos are converted)
2509
+
2510
+ ${AGENT_HELP}
2511
+
2512
+ ${BACKGROUND_HELP}`;
2513
+ function positional(args, index, name) {
2514
+ const value = args[index];
2515
+ if (!value) fail$1(`missing <${name}>. See \`nolune help\`.`);
2516
+ return value;
2517
+ }
2518
+ /**
2519
+ * Checks a pasted key with its provider and saves it. A key the provider rejects isn't saved; one
2520
+ * it couldn't be asked about is, with a warning, so setup works while the provider is unreachable.
2521
+ */
2522
+ async function storeApiKey(io, provider, pasted) {
2523
+ const { label } = API_KEYS[provider];
2524
+ let key;
2525
+ try {
2526
+ key = normalizeApiKey(pasted);
2527
+ } catch (err) {
2528
+ fail$1(err.message);
2529
+ }
2530
+ try {
2531
+ const warning = await checkApiKey(provider, key);
2532
+ saveApiKey(provider, key);
2533
+ io.log(`Saved the ${label} API key.${warning ? ` ${warning}` : ""}`);
2534
+ } catch (err) {
2535
+ if (!(err instanceof ApiKeyError) || err.reason !== "unchecked") fail$1(err.message);
2536
+ saveApiKey(provider, key);
2537
+ io.log(`Saved the ${label} API key without checking it. ${err.message}`);
2538
+ }
2539
+ }
2540
+ /**
2541
+ * Checks a custom provider's server by asking it for its models, and saves it (adds it, or changes
2542
+ * the one of that name): its id and the models it serves. One that wants a key gets asked for it
2543
+ * at a terminal; one that can't be reached is saved with a warning, so setup works before the
2544
+ * server runs.
2545
+ */
2546
+ async function storeCustomProvider(io, name, url, api, given) {
2547
+ let key = given?.trim() || null;
2548
+ const known = findCustomProvider(name);
2549
+ if (known && api && api !== known.api) fail$1(`${known.name} speaks ${known.api === "openai" ? "OpenAI's" : "Anthropic's"} API. Add the other one under another name.`);
2550
+ let found;
2551
+ try {
2552
+ try {
2553
+ found = await checkCustomProvider(url, key);
2554
+ } catch (err) {
2555
+ if (!(err instanceof CustomProviderError) || err.reason !== "key" || key || !io.stdinIsTTY) throw err;
2556
+ key = await askHidden(io, `Its API key`) || null;
2557
+ if (!key) throw err;
2558
+ found = await checkCustomProvider(url, key);
2559
+ }
2560
+ } catch (err) {
2561
+ if (!(err instanceof CustomProviderError) || err.reason !== "unreachable") fail$1(err.message);
2562
+ const id = saveOrFail(known, name, url, api, key);
2563
+ io.log(`Saved ${findCustomProvider(id)?.name} without checking it. ${err.message}`);
2564
+ return {
2565
+ id,
2566
+ models: []
2567
+ };
2568
+ }
2569
+ const id = saveOrFail(known, name, url, api, key);
2570
+ const saved = findCustomProvider(id);
2571
+ const some = found.models.slice(0, 8).join(", ");
2572
+ const serves = found.models.length ? ` It serves ${some}${found.models.length > 8 ? ` and ${found.models.length - 8} more` : ""}.` : "";
2573
+ io.log(`${known ? "Changed" : "Added"} ${saved.name} at ${saved.url}, through its ${saved.api === "openai" ? "OpenAI" : "Anthropic"} API.${serves}${found.warning ? ` ${found.warning}` : ""}`);
2574
+ return {
2575
+ id,
2576
+ models: found.models
2577
+ };
2578
+ }
2579
+ function saveOrFail(known, name, url, api, key) {
2580
+ try {
2581
+ return saveCustomProvider({
2582
+ id: known?.id,
2583
+ name: known?.name ?? name,
2584
+ api,
2585
+ url,
2586
+ key
2587
+ });
2588
+ } catch (err) {
2589
+ fail$1(err.message);
2590
+ }
2591
+ }
2592
+ /**
2593
+ * A preset's provider and model as typed: a custom provider by its name or id, its model kept as
2594
+ * `<id>/<model>`. nolune's own providers as they are.
2595
+ */
2596
+ function presetTarget(provider, model) {
2597
+ if (!provider || isProvider$1(provider)) return {
2598
+ provider,
2599
+ model
2600
+ };
2601
+ const custom = findCustomProvider(provider);
2602
+ if (!custom) {
2603
+ const names = listCustomProviders().map((c) => c.name);
2604
+ fail$1(`no provider "${provider}". It's anthropic, openai, openrouter, xai, claude-plan, chatgpt-plan, nolune-plan${names.length ? `, or a custom provider: ${names.join(", ")}` : ", or a custom provider added with `nolune provider add <name> <url>`"}.`);
2605
+ }
2606
+ const bare = model.startsWith(`${custom.id}/`) ? model.slice(custom.id.length + 1) : model;
2607
+ return {
2608
+ provider: providerFor(custom.api),
2609
+ model: `${custom.id}/${bare}`
2610
+ };
2611
+ }
2612
+ /** A preset's model for people: a custom provider's by its name. */
2613
+ function presetSource(provider, model) {
2614
+ const on = isCustomProvider(provider) ? splitModel(model) : null;
2615
+ const custom = on?.provider ? findCustomProvider(on.provider) : void 0;
2616
+ return custom && on ? `${custom.name}/${on.model}` : `${provider}/${model}`;
2617
+ }
2618
+ function requireInit() {
2619
+ if (!configExists()) fail$1("not set up yet. Run `nolune setup` first.");
2620
+ }
2621
+ function resolveProfileSlug(io, flag) {
2622
+ const slug = flag || io.env.NOLUNE_PROFILE;
2623
+ if (!slug) fail$1("which profile? Pass --profile <slug> (or --global for a global skill).");
2624
+ if (!getProfileBySlug(slug)) fail$1(`no profile with slug "${slug}". See \`nolune profile list\`.`);
2625
+ return slug;
2626
+ }
2627
+ function formatTokens(n) {
2628
+ if (n == null) return "?";
2629
+ return n >= 1e6 ? `${n / 1e6}M` : n >= 1e3 ? `${Math.round(n / 1e3)}K` : String(n);
2630
+ }
2631
+ function listenAddress() {
2632
+ const config = readConfig();
2633
+ return {
2634
+ host: config.host ?? "127.0.0.1",
2635
+ port: config.port ?? 5780,
2636
+ origin: publicOrigin(config)
2637
+ };
2638
+ }
2639
+ /** macOS keeps background processes out of these folders; elsewhere there's nothing to say. */
2640
+ function fullDiskAccessHint() {
2641
+ if (process.platform !== "darwin") return "";
2642
+ if (appManaged()) return "\n\nTo let the agent reach Documents, Desktop, Downloads, Photos and Mail, turn on nolune in System Settings > Privacy & Security > Full Disk Access.";
2643
+ return `\n\nTo let the agent reach Documents, Desktop, Downloads, Photos and Mail, give Full Disk Access to
2644
+ ${process.execPath}
2645
+ in System Settings > Privacy & Security > Full Disk Access (click +, press Cmd+Shift+G, paste the path).
2646
+ Note: this applies to every script run with that node binary.`;
2647
+ }
2648
+ async function setup(io, args) {
2649
+ const { values } = parseArgs({
2650
+ args,
2651
+ options: {
2652
+ name: { type: "string" },
2653
+ email: { type: "string" },
2654
+ password: { type: "string" },
2655
+ origin: { type: "string" },
2656
+ port: { type: "string" },
2657
+ relay: { type: "boolean" },
2658
+ "relay-name": { type: "string" },
2659
+ url: { type: "string" },
2660
+ api: { type: "string" }
2661
+ },
2662
+ allowNegative: true
2663
+ });
2664
+ const { created } = initConfig();
2665
+ getDb();
2666
+ installCliShim();
2667
+ io.log(created ? `Created ${paths.home}` : `Using ${paths.home}`);
2668
+ const admin = listUsers().find((u) => u.isAdmin);
2669
+ if (admin) io.log(`Admin account: ${admin.name} <${admin.email}>`);
2670
+ else {
2671
+ const name = values.name ?? await ask(io, "Your name (the agent sees it on your messages)");
2672
+ const email = values.email ?? await ask(io, "Your email (to sign in)");
2673
+ const password = values.password ?? generatePassword();
2674
+ await createUser({
2675
+ name,
2676
+ email,
2677
+ password,
2678
+ isAdmin: true
2679
+ });
2680
+ io.log(`Created your account. Password: ${values.password ? "(as given)" : password}`);
2681
+ }
2682
+ const current = listenAddress();
2683
+ const port = values.port ? Number(values.port) : current.port;
2684
+ updateConfig((c) => {
2685
+ c.port = port;
2686
+ });
2687
+ const relay = values.origin === void 0 && await setupRelay(io, values);
2688
+ if (!relay) {
2689
+ const origin = values.origin ?? await ask(io, "Public URL people will open (leave as is for this computer only)", readConfig().origin ?? `http://localhost:${port}`);
2690
+ updateConfig((c) => {
2691
+ c.origin = origin;
2692
+ });
2693
+ }
2694
+ const origin = publicOrigin(readConfig());
2695
+ const reach = relay ? `Family members open that address on any device, at home or away, while the gateway runs. The
2696
+ relay passes traffic between their browsers and this computer, and could see it, as any tunnel
2697
+ could: \`nolune relay disable\` stops using it.` : `The gateway listens on http://${current.host}:${port}. To reach it from outside your home, run
2698
+ \`nolune relay enable\` for an address through nolune's relay, or point a tunnel of your own at
2699
+ it (Tailscale Funnel, Cloudflare Tunnel, or a VPS) and set its URL with
2700
+ \`nolune config set origin https://...\`. Notifications on the nolune app for iPhone only come
2701
+ through the relay.`;
2702
+ io.log(`
2703
+ Done. Next:
2704
+ nolune service install run the gateway in the background (or \`nolune start\` to try it)
2705
+ nolune user invite Anna a link for a family member (or People, in the web UI)
2706
+ open ${origin}
2707
+
2708
+ Chats need a model: sign in and make a profile, and its welcome asks for one (a key or a plan,
2709
+ then the model). Or add one under Models & keys, or with \`nolune key set\` and \`nolune preset add\`.
2710
+
2711
+ ${reach}${fullDiskAccessHint()}`);
2712
+ }
2713
+ /**
2714
+ * Setup's question of how the family reaches nolune: through the relay unless they'd rather not
2715
+ * (`--relay` / `--no-relay` answer it; without a terminal and without either, it's no). Returns
2716
+ * whether nolune has a relay address, which it keeps once it has one. One it can't get leaves the
2717
+ * choice to the origin.
2718
+ */
2719
+ async function setupRelay(io, values) {
2720
+ const existing = readConfig().relay;
2721
+ if (existing) {
2722
+ io.log(`Address (through nolune's relay): ${existing.url}`);
2723
+ return true;
2724
+ }
2725
+ let wanted = values.relay;
2726
+ if (wanted === void 0 && io.stdinIsTTY) {
2727
+ io.log(`
2728
+ How will your family open nolune? nolune's relay gives it an address like
2729
+ https://smiths.nolune.family that works on any device, at home or away, with no tunnel or
2730
+ port forwarding. It passes their traffic to this computer, and could see it, as any tunnel
2731
+ could. Or keep nolune to this computer, or give a URL of your own: then the nolune app for
2732
+ iPhone gets no notifications, which only come through the relay.`);
2733
+ wanted = /^y/i.test(await ask(io, "Use the relay? (y/n)", "y"));
2734
+ }
2735
+ if (!wanted) return false;
2736
+ let name = values["relay-name"];
2737
+ for (let tries = 0;; tries++) {
2738
+ if (name === void 0 && io.stdinIsTTY) name = await ask(io, "A name for the address, like smiths (letters, digits and dashes; empty for a random one)");
2739
+ try {
2740
+ const { relay } = await enableRelay(io, { name });
2741
+ io.log(`Address: ${relay.url}`);
2742
+ return true;
2743
+ } catch (err) {
2744
+ io.error(`nolune: ${err.message}`);
2745
+ if (!io.stdinIsTTY || tries >= 2 || err instanceof RelayUnreachable) {
2746
+ io.log("Leaving the relay off for now: `nolune relay enable` turns it on later.");
2747
+ return false;
2748
+ }
2749
+ name = void 0;
2750
+ }
2751
+ }
2752
+ }
2753
+ /** Runs the gateway in this process, so it only makes sense in a process of its own. */
2754
+ async function start(io) {
2755
+ requireInit();
2756
+ if (!existsSync(paths.server)) fail$1(`no server build at ${paths.server}. In a source checkout, run \`pnpm build\` first.`);
2757
+ const { host, port, origin } = listenAddress();
2758
+ process.env.HOST ??= host;
2759
+ process.env.PORT ??= String(port);
2760
+ process.env.ORIGIN ??= origin;
2761
+ const { relay } = readConfig();
2762
+ process.env.BODY_SIZE_LIMIT ??= String(MAX_MEDIA_BYTES + 1048576);
2763
+ io.log(`nolune gateway: ${process.env.ORIGIN} (listening on ${process.env.HOST}:${process.env.PORT})`);
2764
+ await import(
2765
+ /* @vite-ignore */
2766
+ pathToFileURL(paths.server).href
2767
+ );
2768
+ if (relay) {
2769
+ const listening = process.env.HOST;
2770
+ const link = connectRelay(relay, {
2771
+ host: !listening || listening === "0.0.0.0" || listening === "::" ? "127.0.0.1" : listening,
2772
+ port: Number(process.env.PORT)
2773
+ }, (message) => io.log(`[nolune] relay: ${message}`));
2774
+ for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => link.close());
2775
+ }
2776
+ }
2777
+ async function service(io, action, args) {
2778
+ switch (action) {
2779
+ case "install": {
2780
+ if (appManaged()) fail$1("the nolune app runs the gateway while it is open.");
2781
+ requireInit();
2782
+ if (!existsSync(paths.server)) fail$1("no server build. In a source checkout, run `pnpm build` first.");
2783
+ if (args.includes("--dry-run")) {
2784
+ io.log(renderServiceFile());
2785
+ return;
2786
+ }
2787
+ const { file, atBoot } = await installService();
2788
+ const { origin } = listenAddress();
2789
+ const linger = atBoot || process.platform !== "linux" ? "" : `\n\nIt stops when you log out. To keep it running whenever this computer is on, run
2790
+ sudo loginctl enable-linger ${userInfo().username}`;
2791
+ io.log(`Installed ${file}
2792
+ The gateway starts now and ${atBoot ? "whenever this computer starts" : "at every login"}: ${origin}
2793
+ Logs: ${logFile}
2794
+ It runs with ${process.execPath}; run \`nolune service install\` again after switching Node versions.${fullDiskAccessHint()}${linger}`);
2795
+ return;
2796
+ }
2797
+ case "uninstall":
2798
+ if (appManaged()) fail$1("the nolune app runs the gateway while it is open. Quit it from the menu bar, and turn it off under System Settings > General > Login Items so it stays closed.");
2799
+ uninstallService();
2800
+ io.log("Removed the background service.");
2801
+ return;
2802
+ case "restart":
2803
+ restartService();
2804
+ io.log("Restarted.");
2805
+ return;
2806
+ case "status": {
2807
+ const status = serviceStatus();
2808
+ if (appManaged() && !status.loaded) io.log("Not running. Open the nolune app.");
2809
+ else if (!status.installed) io.log("Not installed. Run `nolune service install`.");
2810
+ else if (!status.loaded) io.log("Installed but not loaded. Run `nolune service install`.");
2811
+ else io.log(status.pid ? `Running (pid ${status.pid}).` : "Loaded, not running. See `nolune service logs`.");
2812
+ return;
2813
+ }
2814
+ case "logs": {
2815
+ if (!existsSync(logFile)) fail$1(`no log yet at ${logFile}`);
2816
+ const follow = args.includes("-f") || args.includes("--follow");
2817
+ spawn("tail", [
2818
+ "-n",
2819
+ "100",
2820
+ ...follow ? ["-f"] : [],
2821
+ logFile
2822
+ ], { stdio: "inherit" });
2823
+ return;
2824
+ }
2825
+ default: fail$1("usage: nolune service install|uninstall|restart|status|logs [-f]");
2826
+ }
2827
+ }
2828
+ /**
2829
+ * Runs `nolune` with these arguments and returns its exit code. Everything it reads and writes
2830
+ * besides its arguments and nolune's own files goes through `io`. An error ends it with its message
2831
+ * and exit code 1.
2832
+ */
2833
+ async function runCli(argv, io) {
2834
+ try {
2835
+ return await command(io, argv) ?? 0;
2836
+ } catch (err) {
2837
+ io.error(`nolune: ${err instanceof Error ? err.message : String(err)}`);
2838
+ return 1;
2839
+ }
2840
+ }
2841
+ async function command(io, argv) {
2842
+ const [group, action, ...rest] = argv;
2843
+ switch (group) {
2844
+ case void 0:
2845
+ case "help":
2846
+ case "--help":
2847
+ case "-h":
2848
+ io.log(help());
2849
+ return;
2850
+ case "setup": return setup(io, argv.slice(1));
2851
+ case "start": return start(io);
2852
+ case "service": return service(io, action, rest);
2853
+ case "relay":
2854
+ requireInit();
2855
+ return relayCommand(io, action, rest);
2856
+ case "init": {
2857
+ const { created } = initConfig();
2858
+ getDb();
2859
+ const shim = installCliShim();
2860
+ io.log(created ? `Created ${paths.config}` : `Config already exists: ${paths.config}`);
2861
+ io.log(`Database ready: ${paths.db}`);
2862
+ io.log(`Agent shim: ${shim}`);
2863
+ return;
2864
+ }
2865
+ case "config": {
2866
+ requireInit();
2867
+ if (action === void 0) {
2868
+ const config = readConfig();
2869
+ const { host, port, origin } = listenAddress();
2870
+ const row = (name, value) => io.log(`${name.padEnd(13)} ${value}`);
2871
+ row("home", paths.home);
2872
+ row("listen", `http://${host}:${port}`);
2873
+ row("origin", origin);
2874
+ row("relay", config.relay ? `on, through ${config.relay.server} (nolune relay status)` : "off (nolune relay enable gives nolune an address that works from anywhere)");
2875
+ for (const key of apiKeyStatuses()) {
2876
+ const where = key.source === "config" ? "key set" : key.source === "env" ? `key from ${key.env}` : "";
2877
+ const shown = where ? `${where}${key.hint ? ` (…${key.hint})` : ""}` : key.optional ? `no key: the free tier, limited per day (nolune key set ${key.provider})` : `no key (nolune key set ${key.provider})`;
2878
+ row(key.provider, shown);
2879
+ }
2880
+ const customs = listCustomProviders();
2881
+ row("custom", customs.length ? customs.map((c) => `${c.name} ${c.url} (${c.api}${c.hasKey ? ", with a key" : ""})`).join(", ") : "none (nolune provider add <name> <url>)");
2882
+ const claude = claudeExecutable();
2883
+ row("claude", claude ? `Claude Code at ${claude} (nolune claude-plan status checks its sign-in)` : "no Claude Code found (nolune claude-plan setup installs it)");
2884
+ const chatgpt = await chatGptPlanStatus();
2885
+ row("chatgpt", chatgpt.signedIn ? `${chatgpt.signedIn} (nolune chatgpt-plan status checks it)` : "not signed in (nolune chatgpt-plan setup signs in)");
2886
+ const noluneLink = await nolunePlanStatus();
2887
+ row("nolune plan", noluneLink.signedIn ? `${noluneLink.signedIn} (nolune nolune-plan status checks it)` : "not linked (nolune nolune-plan setup links it)");
2888
+ const images = imageGenerationStatus();
2889
+ row("images", `${images.model}${images.problem ? ` (${images.problem})` : ""}`);
2890
+ row("embeddings", embeddingStatus());
2891
+ row("commands", describeCommandSafety());
2892
+ row("quiet chats", describeIdleCompaction());
2893
+ row("env", Object.keys(config.commandEnv ?? {}).join(", ") || "-");
2894
+ row("version", describeUpdates());
2895
+ return;
2896
+ }
2897
+ if (action !== "set") fail$1("usage: nolune config [set <host|port|origin|image-model|embeddings|claude-path|command-mode|safety-model|update-check|compact-when-idle> <value>]");
2898
+ const key = positional(rest, 0, "host|port|origin|image-model|embeddings|claude-path|command-mode|safety-model|update-check|compact-when-idle");
2899
+ if (key === "command-mode" || key === "safety-model") {
2900
+ if (io.env.NOLUNE_CONVERSATION_ID) fail$1("the agent can't change how its own commands are checked. Someone can, at this computer's terminal or on the Models & keys page.");
2901
+ if (key === "command-mode") {
2902
+ const mode = positional(rest, 1, "auto|unrestricted");
2903
+ if (!isCommandMode(mode)) fail$1("command-mode is auto or unrestricted");
2904
+ saveCommandMode(mode);
2905
+ } else {
2906
+ const which = positional(rest, 1, "preset|chat");
2907
+ let id = null;
2908
+ if (which !== "chat") try {
2909
+ id = findPreset(which).id;
2910
+ } catch (err) {
2911
+ fail$1(`${err.message}. \`nolune preset list\` shows them.`);
2912
+ }
2913
+ saveSafetyPreset(id);
2914
+ }
2915
+ io.log(`Commands: ${describeCommandSafety()}.`);
2916
+ return;
2917
+ }
2918
+ if (key === "update-check") {
2919
+ const on = positional(rest, 1, "on|off");
2920
+ if (on !== "on" && on !== "off") fail$1("update-check is on or off");
2921
+ updateConfig((c) => {
2922
+ if (on === "on") delete c.updateCheck;
2923
+ else c.updateCheck = false;
2924
+ });
2925
+ if (on === "off") forgetRelease();
2926
+ io.log(on === "on" ? "nolune will look for a new release within the hour, then once a day." : "nolune won’t look for new releases.");
2927
+ return;
2928
+ }
2929
+ if (key === "compact-when-idle") {
2930
+ const value = positional(rest, 1, "minutes|off");
2931
+ try {
2932
+ saveIdleCompaction(value === "off" ? null : Number(value));
2933
+ } catch (err) {
2934
+ fail$1(`${err.message}, or off.`);
2935
+ }
2936
+ idleCompactionChanged();
2937
+ io.log(`Quiet chats: ${describeIdleCompaction()}.`);
2938
+ return;
2939
+ }
2940
+ if (key === "embeddings") {
2941
+ let setting;
2942
+ try {
2943
+ setting = parseEmbeddingSetting(positional(rest, 1, "auto|off|provider/model"));
2944
+ } catch (err) {
2945
+ fail$1(err.message);
2946
+ }
2947
+ saveEmbeddingSetting(setting);
2948
+ const problem = await embeddingProblem();
2949
+ io.log(`Memory search by meaning: ${embeddingStatus()}.${problem ? ` It didn't answer: ${problem}` : ""}`);
2950
+ return;
2951
+ }
2952
+ const value = positional(rest, 1, "value");
2953
+ updateConfig((c) => {
2954
+ if (key === "port") {
2955
+ const port = Number(value);
2956
+ if (!Number.isInteger(port) || port <= 0) fail$1("port must be a number");
2957
+ c.port = port;
2958
+ } else if (key === "host") c.host = value;
2959
+ else if (key === "origin") c.origin = value.replace(/\/+$/, "");
2960
+ else if (key === "image-model") {
2961
+ const current = parseImageModel(c.imageModel || configuredImageModel());
2962
+ const { provider, model } = parseImageModel(value, current.provider);
2963
+ c.imageModel = `${provider}/${model}`;
2964
+ } else if (key === "claude-path") c.claudePath = value;
2965
+ else fail$1("you can set host, port, origin, image-model, embeddings, claude-path, command-mode, safety-model, update-check or compact-when-idle");
2966
+ });
2967
+ if (key === "claude-path") {
2968
+ await requireClaudePlan(io);
2969
+ return;
2970
+ }
2971
+ if (key === "image-model") {
2972
+ const { model, problem } = imageGenerationStatus();
2973
+ io.log(`Pictures are now made with ${model}.${problem ? ` ${problem}` : ""}`);
2974
+ return;
2975
+ }
2976
+ const relayNote = key === "origin" && readConfig().relay ? ` While the relay is on, nolune's address stays ${readConfig().relay?.url}; \`nolune relay disable\` switches to this one.` : "";
2977
+ io.log(`Set ${key}. Run \`nolune service restart\` if the service is running.${relayNote}`);
2978
+ return;
2979
+ }
2980
+ case "key": {
2981
+ requireInit();
2982
+ const provider = rest[0] ?? "";
2983
+ const names = Object.keys(API_KEYS).join("|");
2984
+ if (action !== "set" && action !== "rm" || !isApiKeyProvider(provider)) fail$1(`usage: nolune key set <${names}> [key] | nolune key rm <${names}> (your own servers: nolune provider add)`);
2985
+ const { label, env } = API_KEYS[provider];
2986
+ if (action === "rm") {
2987
+ removeApiKey(provider);
2988
+ const fallback = io.env[env] ? ` nolune uses ${env} from the environment now.` : "";
2989
+ io.log(`Removed the ${label} API key.${fallback}`);
2990
+ return;
2991
+ }
2992
+ const key = rest[1] || await askHidden(io, `${label} API key`);
2993
+ if (!key) fail$1("no key given");
2994
+ await storeApiKey(io, provider, key);
2995
+ return;
2996
+ }
2997
+ case "provider": {
2998
+ requireInit();
2999
+ const { values, positionals } = parseArgs({
3000
+ args: rest,
3001
+ allowPositionals: true,
3002
+ options: {
3003
+ key: { type: "string" },
3004
+ api: { type: "string" }
3005
+ }
3006
+ });
3007
+ if (action === "add") {
3008
+ const name = positional(positionals, 0, "name");
3009
+ const url = positional(positionals, 1, "url");
3010
+ const api = values.api;
3011
+ if (api !== void 0 && api !== "openai" && api !== "anthropic") fail$1("--api is openai or anthropic");
3012
+ await storeCustomProvider(io, name, url, api, values.key ?? null);
3013
+ } else if (action === "rm") {
3014
+ const which = positional(positionals, 0, "name|id");
3015
+ const custom = findCustomProvider(which);
3016
+ if (!custom) fail$1(`no custom provider "${which}". See \`nolune provider list\`.`);
3017
+ const on = listPresets().filter((p) => isCustomProvider(p.provider) && splitModel(p.model).provider === custom.id);
3018
+ removeCustomProvider(custom.id);
3019
+ io.log(`Removed ${custom.name}.${on.length ? ` Chats on ${on.map((p) => `"${p.name}"`).join(", ")} stop working until they're moved to another model.` : ""}`);
3020
+ } else if (action === "list") for (const c of listCustomProviders()) {
3021
+ const key = c.hasKey ? `key${c.hint ? ` …${c.hint}` : ""}` : "no key";
3022
+ io.log(`${c.name}\t${c.id}\t${c.api}\t${c.url}\t${key}`);
3023
+ }
3024
+ else fail$1("usage: nolune provider add <name> <url> [--api openai|anthropic] [--key K] | nolune provider rm <name|id> | nolune provider list");
3025
+ return;
3026
+ }
3027
+ case "claude-plan":
3028
+ case "chatgpt-plan":
3029
+ case "nolune-plan": return planCommand(io, group, action, rest);
3030
+ case "env":
3031
+ requireInit();
3032
+ if (action === "list") for (const name of Object.keys(readConfig().commandEnv ?? {})) io.log(name);
3033
+ else if (action === "set") {
3034
+ const name = positional(rest, 0, "NAME");
3035
+ const value = rest[1] ?? await askHidden(io, name);
3036
+ if (!value) fail$1("no value given");
3037
+ updateConfig((c) => {
3038
+ c.commandEnv = {
3039
+ ...c.commandEnv,
3040
+ [name]: value
3041
+ };
3042
+ });
3043
+ io.log(`Set ${name} for agent commands.`);
3044
+ } else if (action === "rm") {
3045
+ const name = positional(rest, 0, "NAME");
3046
+ updateConfig((c) => {
3047
+ if (c.commandEnv) delete c.commandEnv[name];
3048
+ });
3049
+ io.log(`Removed ${name}.`);
3050
+ } else fail$1("usage: nolune env set|rm|list");
3051
+ return;
3052
+ case "user": {
3053
+ requireInit();
3054
+ const { values, positionals } = parseArgs({
3055
+ args: rest,
3056
+ allowPositionals: true,
3057
+ options: {
3058
+ password: { type: "string" },
3059
+ admin: { type: "boolean" },
3060
+ off: { type: "boolean" }
3061
+ }
3062
+ });
3063
+ if (action === "create") {
3064
+ const name = positional(positionals, 0, "name");
3065
+ const email = positional(positionals, 1, "email");
3066
+ const password = values.password ?? generatePassword();
3067
+ await createUser({
3068
+ name,
3069
+ email,
3070
+ password,
3071
+ isAdmin: values.admin
3072
+ });
3073
+ io.log(`Created ${name} <${email}>${values.admin ? " (admin)" : ""}.`);
3074
+ if (!values.password) io.log(`Password: ${password}`);
3075
+ } else if (action === "passwd") {
3076
+ const who = positional(positionals, 0, "name|email");
3077
+ const password = values.password ?? generatePassword();
3078
+ await setPassword(who, password);
3079
+ io.log(`Password changed for ${who}.`);
3080
+ if (!values.password) io.log(`Password: ${password}`);
3081
+ } else if (action === "admin") {
3082
+ const who = positional(positionals, 0, "name|email");
3083
+ setAdmin(who, !values.off);
3084
+ io.log(`${who} is ${values.off ? "no longer" : "now"} an admin.`);
3085
+ } else if (action === "rm") {
3086
+ const who = positional(positionals, 0, "name|email");
3087
+ deleteUser(who);
3088
+ io.log(`Deleted ${who}.`);
3089
+ } else if (action === "invite") {
3090
+ const { token } = createInvite({ name: positionals[0] });
3091
+ io.log(`${publicOrigin(readConfig())}/invite/${token}`);
3092
+ io.log(`Works once, within 7 days. Take it back on the People page.`);
3093
+ } else if (action === "list") for (const u of listUsers()) {
3094
+ const picture = u.picture ? userPictureFile(u.picture) : null;
3095
+ const fields = [
3096
+ u.name,
3097
+ u.email,
3098
+ u.isAdmin && "admin",
3099
+ picture?.path
3100
+ ];
3101
+ io.log(fields.filter(Boolean).join(" "));
3102
+ }
3103
+ else fail$1("usage: nolune user create|invite|passwd|admin|rm|list");
3104
+ return;
3105
+ }
3106
+ case "preset": {
3107
+ requireInit();
3108
+ const { values, positionals } = parseArgs({
3109
+ args: rest,
3110
+ allowPositionals: true,
3111
+ options: {
3112
+ provider: { type: "string" },
3113
+ model: { type: "string" },
3114
+ name: { type: "string" },
3115
+ "context-window": { type: "string" }
3116
+ }
3117
+ });
3118
+ if (action === "add") {
3119
+ const { provider, model } = presetTarget(values.provider, positional(positionals, 0, "model"));
3120
+ const cw = values["context-window"];
3121
+ const preset = await addPreset({
3122
+ provider,
3123
+ model,
3124
+ name: values.name,
3125
+ contextWindow: cw ? Number(cw) : null
3126
+ });
3127
+ io.log(`Added "${preset.name}" (context ${formatTokens(effectiveContextWindow(preset))}).`);
3128
+ } else if (action === "edit") {
3129
+ const cw = values["context-window"];
3130
+ const which = positional(positionals, 0, "name|id");
3131
+ let { provider, model } = {
3132
+ provider: values.provider,
3133
+ model: values.model
3134
+ };
3135
+ if (provider && !isProvider$1(provider)) {
3136
+ const old = listPresets().find((p) => p.id === which || p.name === which);
3137
+ const id = old && isCustomProvider(old.provider) ? splitModel(old.model).model : old?.model;
3138
+ ({provider, model} = presetTarget(provider, model ?? id ?? ""));
3139
+ }
3140
+ const preset = await editPreset(which, {
3141
+ provider,
3142
+ model,
3143
+ name: values.name,
3144
+ contextWindow: cw === void 0 ? void 0 : cw === "auto" ? null : Number(cw)
3145
+ });
3146
+ io.log(`Saved "${preset.name}" (${presetSource(preset.provider, preset.model)}, context ${formatTokens(effectiveContextWindow(preset))}). Chats already on it keep what they had.`);
3147
+ } else if (action === "rm") {
3148
+ removePreset(positional(positionals, 0, "name|id"));
3149
+ io.log("Removed. Existing conversations keep working.");
3150
+ } else if (action === "default") {
3151
+ const preset = setDefaultPreset(positional(positionals, 0, "name|id"));
3152
+ io.log(`"${preset.name}" is now the default. New chats start with it.`);
3153
+ } else if (action === "list") {
3154
+ const defaultId = getDefaultPreset()?.id;
3155
+ for (const p of listPresets()) {
3156
+ const override = p.contextWindow ? " (override)" : "";
3157
+ const isDefault = p.id === defaultId ? " default" : "";
3158
+ io.log(`${p.name}\t${presetSource(p.provider, p.model)}\tcontext ${formatTokens(effectiveContextWindow(p))}${override}\t${p.id}${isDefault}`);
3159
+ }
3160
+ } else fail$1("usage: nolune preset add|edit|rm|default|list");
3161
+ return;
3162
+ }
3163
+ case "profile":
3164
+ requireInit();
3165
+ return profileCommand(io, action, rest);
3166
+ case "skill": {
3167
+ const { values, positionals } = parseArgs({
3168
+ args: rest,
3169
+ allowPositionals: true,
3170
+ options: {
3171
+ description: {
3172
+ type: "string",
3173
+ short: "d"
3174
+ },
3175
+ profile: { type: "string" },
3176
+ global: { type: "boolean" }
3177
+ }
3178
+ });
3179
+ if (action === "new") {
3180
+ const name = positional(positionals, 0, "name");
3181
+ const slug = values.global ? null : resolveProfileSlug(io, values.profile);
3182
+ const dir = slug ? profileSkillsDir(slug) : paths.globalSkills;
3183
+ const location = createSkill(dir, name, values.description ?? "");
3184
+ io.log(`Created ${location}`);
3185
+ if (slug && getProfileBySlug(slug)?.disabledSkills.includes(name)) io.log(`"${name}" is turned off in this profile, so its chats won't list it. Turn it on with \`nolune skill enable ${name}\`.`);
3186
+ } else if (action === "list") {
3187
+ const slug = values.profile || io.env.NOLUNE_PROFILE;
3188
+ const profile = slug ? getProfileBySlug(slug) : void 0;
3189
+ const { skills, warnings } = listProfileSkills(slug ? profileSkillsDir(slug) : "/nonexistent", profile?.disabledSkills ?? []);
3190
+ for (const s of skills) {
3191
+ const state = profile ? `${s.enabled ? "on" : "off"}\t` : "";
3192
+ io.log(`${s.name}\t${state}${s.scope}\t~${s.tokens} tokens\t${s.location}\n ${s.description}`);
3193
+ }
3194
+ for (const w of warnings) io.error(`warning: ${w}`);
3195
+ if (!skills.length) io.log("No skills.");
3196
+ else if (profile) {
3197
+ const on = skills.filter((s) => s.enabled);
3198
+ const tokens = on.reduce((n, s) => n + s.tokens, 0);
3199
+ io.log(`\n${on.length} of ${skills.length} on in ${profile.name}, about ${formatTokens(tokens)} tokens in every new chat.`);
3200
+ }
3201
+ } else if (action === "enable" || action === "disable") {
3202
+ if (values.global) fail$1("skills are turned on and off per profile. Pass --profile <slug>.");
3203
+ const profile = getProfileBySlug(resolveProfileSlug(io, values.profile));
3204
+ if (!positionals.length) fail$1("missing <name>. See `nolune help`.");
3205
+ const known = new Set(scanSkills(profileSkillsDir(profile.slug)).skills.map((s) => s.name));
3206
+ const unknown = positionals.filter((name) => !known.has(name));
3207
+ if (unknown.length) fail$1(`no skill named ${unknown.join(", ")}. See \`nolune skill list\`.`);
3208
+ setSkillsEnabled(profile.id, positionals, action === "enable");
3209
+ io.log(`${positionals.join(", ")}: ${action === "enable" ? "on" : "off"} for new chats in ${profile.name}.`);
3210
+ } else fail$1("usage: nolune skill new|list|enable|disable");
3211
+ return;
3212
+ }
3213
+ case "mcp":
3214
+ requireInit();
3215
+ return mcpCommand(io, action, rest);
3216
+ case "trigger":
3217
+ requireInit();
3218
+ return triggerCommand(io, action, rest);
3219
+ case "memory":
3220
+ requireInit();
3221
+ return memoryCommand(io, argv.slice(1));
3222
+ case "card":
3223
+ requireInit();
3224
+ return cardCommand(io, argv.slice(1));
3225
+ case "soul":
3226
+ requireInit();
3227
+ return soulCommand(io, argv.slice(1));
3228
+ case "wake":
3229
+ requireInit();
3230
+ return wakeCommand(io, argv.slice(1));
3231
+ case "agent":
3232
+ requireInit();
3233
+ return agentCommand(io, action, rest);
3234
+ case "background":
3235
+ requireInit();
3236
+ return backgroundCommand(io, action, rest);
3237
+ case "generate": return generateCommand(io, action, rest);
3238
+ case "web": return webCommand(io, action, rest);
3239
+ case "view": {
3240
+ const dir = io.env.NOLUNE_VIEW_DIR;
3241
+ if (!dir) fail$1("`nolune view` only works in the agent's commands: it shows images to the agent.");
3242
+ const files = argv.slice(1);
3243
+ if (!files.length) fail$1("usage: nolune view <image>...");
3244
+ let failed = false;
3245
+ for (const [i, file] of files.entries()) try {
3246
+ io.log(await viewImage(file, dir, io.cwd));
3247
+ } catch (err) {
3248
+ failed = true;
3249
+ const message = err instanceof Error ? err.message : String(err);
3250
+ io.error(`nolune: can't show ${file}: ${message.replace(/\.+$/, "")}.`);
3251
+ if (err instanceof ViewLimitError) {
3252
+ const rest = files.slice(i + 1);
3253
+ if (rest.length) io.error(`nolune: not shown either: ${rest.join(" ")}`);
3254
+ break;
3255
+ }
3256
+ }
3257
+ return failed ? 1 : 0;
3258
+ }
3259
+ default: fail$1(`unknown command "${group}". See \`nolune help\`.`);
3260
+ }
3261
+ }
3262
+ /** After how many quiet minutes chats are summarized, in words. */
3263
+ function describeIdleCompaction() {
3264
+ const minutes = idleCompactionMinutes();
3265
+ return minutes ? `summarized after ${minutes} minute${minutes === 1 ? "" : "s"} without a message` : "summarized only near the window, or on request";
3266
+ }
3267
+ //#endregion
3268
+ //#region ../cli/src/serve.ts
3269
+ function isRun(message) {
3270
+ return message.type === "run" && Array.isArray(message.argv) && message.argv.every((arg) => typeof arg === "string") && typeof message.cwd === "string" && isAbsolute(message.cwd) && typeof message.env === "object" && message.env !== null;
3271
+ }
3272
+ /** One connection, one command. The client hanging up stops it (io.signal). */
3273
+ function handle$1(socket, run) {
3274
+ const abort = new AbortController();
3275
+ let started = false;
3276
+ let answerStdin;
3277
+ let stdin;
3278
+ socket.on("error", () => {});
3279
+ socket.on("close", () => abort.abort(/* @__PURE__ */ new Error("the command was stopped")));
3280
+ receive(socket, (message) => {
3281
+ if (message.type === "stdin") {
3282
+ answerStdin?.(typeof message.data === "string" ? message.data : "");
3283
+ return;
3284
+ }
3285
+ if (started || !isRun(message)) {
3286
+ socket.destroy();
3287
+ return;
3288
+ }
3289
+ started = true;
3290
+ if (message.protocol !== 1 || LOCAL_ONLY.has(message.argv[0] ?? "")) {
3291
+ send(socket, {
3292
+ type: "decline",
3293
+ reason: message.protocol !== 1 ? "another protocol version" : "runs locally"
3294
+ });
3295
+ socket.end();
3296
+ return;
3297
+ }
3298
+ const io = createIo({
3299
+ stdout: (data) => send(socket, {
3300
+ type: "stdout",
3301
+ data
3302
+ }),
3303
+ stderr: (data) => send(socket, {
3304
+ type: "stderr",
3305
+ data
3306
+ }),
3307
+ env: message.env,
3308
+ cwd: message.cwd,
3309
+ stdinIsTTY: false,
3310
+ readStdin: () => stdin ??= new Promise((resolve, reject) => {
3311
+ if (abort.signal.aborted) return reject(abort.signal.reason);
3312
+ answerStdin = resolve;
3313
+ abort.signal.addEventListener("abort", () => reject(abort.signal.reason), { once: true });
3314
+ send(socket, { type: "stdin" });
3315
+ }),
3316
+ signal: abort.signal
3317
+ });
3318
+ run(message.argv, io).catch((err) => {
3319
+ console.error("[nolune] a CLI command failed in the gateway:", err);
3320
+ return 1;
3321
+ }).then((code) => {
3322
+ send(socket, {
3323
+ type: "exit",
3324
+ code
3325
+ });
3326
+ socket.end();
3327
+ });
3328
+ });
3329
+ }
3330
+ /** Whether something already answers on the socket: another gateway on the same nolune home. */
3331
+ function answers(socketPath) {
3332
+ return new Promise((resolve) => {
3333
+ const probe = connect(socketPath);
3334
+ probe.on("connect", () => {
3335
+ probe.destroy();
3336
+ resolve(true);
3337
+ });
3338
+ probe.on("error", () => resolve(false));
3339
+ });
3340
+ }
3341
+ /**
3342
+ * Serves `nolune` commands on the socket, calling `run()` for the code to run each with (the latest,
3343
+ * after `pnpm dev` reloads it). Resolves with the server, or null when another gateway already
3344
+ * serves this nolune home or the socket can't be made; the CLI then runs commands itself.
3345
+ */
3346
+ async function serveCommands(socketPath, run) {
3347
+ if (await answers(socketPath)) {
3348
+ console.log(`[nolune] another gateway already runs nolune commands on ${socketPath}`);
3349
+ return null;
3350
+ }
3351
+ const server = createServer((socket) => handle$1(socket, run()));
3352
+ try {
3353
+ const dir = dirname(socketPath);
3354
+ mkdirSync(dir, {
3355
+ recursive: true,
3356
+ mode: 448
3357
+ });
3358
+ chmodSync(dir, 448);
3359
+ rmSync(socketPath, { force: true });
3360
+ await new Promise((resolve, reject) => {
3361
+ server.once("error", reject);
3362
+ server.listen(socketPath, () => {
3363
+ server.off("error", reject);
3364
+ resolve();
3365
+ });
3366
+ });
3367
+ chmodSync(socketPath, 384);
3368
+ } catch (err) {
3369
+ console.error(`[nolune] couldn't run nolune commands on ${socketPath}; the CLI runs them itself:`, err);
3370
+ server.close();
3371
+ return null;
3372
+ }
3373
+ server.on("error", (err) => console.error("[nolune] the nolune command socket failed:", err));
3374
+ server.unref();
3375
+ return server;
3376
+ }
3377
+ var holder = globalThis;
3378
+ /**
3379
+ * The gateway's own command socket (paths.cliSocket), once per process. When `pnpm dev` reloads
3380
+ * this module, the running server keeps going with the new code.
3381
+ */
3382
+ function serveGatewayCommands() {
3383
+ if (holder.__noluneCommands) {
3384
+ holder.__noluneCommands.run = runCli;
3385
+ return;
3386
+ }
3387
+ const state = holder.__noluneCommands = { run: runCli };
3388
+ serveCommands(paths.cliSocket, () => state.run).then((server) => {
3389
+ if (!server) return;
3390
+ const connections = /* @__PURE__ */ new Set();
3391
+ server.on("connection", (socket) => {
3392
+ connections.add(socket);
3393
+ socket.on("close", () => connections.delete(socket));
3394
+ });
3395
+ process.once("sveltekit:shutdown", () => {
3396
+ server.close();
3397
+ for (const socket of connections) socket.destroy();
3398
+ });
3399
+ process.once("exit", () => rmSync(paths.cliSocket, { force: true }));
3400
+ });
3401
+ }
3402
+ //#endregion
3403
+ //#region src/hooks.server.ts
3404
+ var init = () => {
3405
+ installCliShim();
3406
+ recoverAfterRestart();
3407
+ startScheduler();
3408
+ startUpdateChecks();
3409
+ serveGatewayCommands();
3410
+ holdMcpConnections();
3411
+ };
3412
+ /**
3413
+ * Webhook URLs and invite links carry their own secret token instead of a login, and so does the
3414
+ * page an MCP server's sign-in comes back to (its state), which `nolune mcp login` may have
3415
+ * opened in a browser that isn't signed in to nolune. Apps ask which nolune this is
3416
+ * (`/api/version`) before anyone signs in.
3417
+ */
3418
+ var PUBLIC_PATHS = [
3419
+ "/login",
3420
+ "/api/auth/",
3421
+ "/api/hooks/",
3422
+ "/invite/",
3423
+ "/mcp/oauth/",
3424
+ "/api/version"
3425
+ ];
3426
+ /**
3427
+ * `nolune start` raises adapter-node's body limit so attachments can be uploaded. Every other route
3428
+ * keeps a small one, including the public ones that read a body before checking anything.
3429
+ */
3430
+ var UPLOAD_PATH = /^\/api\/p\/[^/]+\/uploads$/;
3431
+ var MAX_BODY_BYTES = 1048576;
3432
+ function bodyTooLarge(request, path) {
3433
+ if (UPLOAD_PATH.test(path)) return false;
3434
+ const length = request.headers.get("content-length");
3435
+ if (length === null) return request.headers.has("transfer-encoding");
3436
+ return Number(length) > MAX_BODY_BYTES;
3437
+ }
3438
+ var handle = async ({ event, resolve }) => {
3439
+ const { language } = parsePreferences(event.cookies.get(PREFERENCES_COOKIE));
3440
+ const locale = language === "auto" ? matchLocale(event.request.headers.get("accept-language")) : language;
3441
+ event.locals.locale = locale;
3442
+ if (bodyTooLarge(event.request, event.url.pathname)) error(413, "Request body too large");
3443
+ const auth = getAuth();
3444
+ const session = await auth.api.getSession({ headers: event.request.headers });
3445
+ if (session) {
3446
+ event.locals.session = session.session;
3447
+ event.locals.user = session.user;
3448
+ }
3449
+ const path = event.url.pathname;
3450
+ if (!event.locals.user && !PUBLIC_PATHS.some((p) => path === p || path.startsWith(p))) {
3451
+ if (path.startsWith("/api/")) error(401, translations(locale).m.errors.notSignedIn);
3452
+ redirect(303, "/login");
3453
+ }
3454
+ return svelteKitHandler({
3455
+ event,
3456
+ resolve: (event) => resolve(event, { transformPageChunk: ({ html }) => html.replace("%nolune.lang%", locale) }),
3457
+ auth,
3458
+ building
3459
+ });
3460
+ };
3461
+
3462
+ export { handle, init };
3463
+ //# sourceMappingURL=hooks.server.js-DGIhty0N.js.map