limixbot 0.3.51 → 0.3.53

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 (229) hide show
  1. package/dist/assets/{ActivityPanel-C74ksK5_.js → ActivityPanel-DIQkh4hc.js} +1 -1
  2. package/dist/assets/App-CxKkZhGV.js +243 -0
  3. package/dist/assets/{AppEventEditor-Derw3FHd.js → AppEventEditor-FVbe8Mvz.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-BKWvg7df.js +16 -0
  5. package/dist/assets/{BrowserPanel-BUwH6i3q.js → BrowserPanel-CkiqrVEm.js} +2 -2
  6. package/dist/assets/{BrowserProfilesManager-LPWaNOTL.js → BrowserProfilesManager-C2OqwZn1.js} +1 -1
  7. package/dist/assets/CloudAddDialog-BH5eLBvi.js +1 -0
  8. package/dist/assets/ComputerFilesPane-iOrAAtHV.js +1 -0
  9. package/dist/assets/{ComputerPanel-BKSAp5BV.js → ComputerPanel-le89nav2.js} +2 -2
  10. package/dist/assets/{DataPanel-C8JFQXPW.js → DataPanel-CcOlPY1d.js} +1 -1
  11. package/dist/assets/{DesktopViewer-DFhYwHIq.js → DesktopViewer-Du64Zar0.js} +1 -1
  12. package/dist/assets/{FilesView-uvhFDVLX.js → FilesView-hGRu-0jv.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-DqtBggcO.js → GrokMoveDialog-Dy6gcobX.js} +1 -1
  14. package/dist/assets/{InspectorPanel-B9946G8k.js → InspectorPanel-BzC5WSUu.js} +2 -2
  15. package/dist/assets/{KeyboardShortcutsModal-3p8-Y0gj.js → KeyboardShortcutsModal-BtAZADk0.js} +1 -1
  16. package/dist/assets/{LimixChannelReview-BDF1Ho_G.js → LimixChannelReview-BFN0ep6x.js} +1 -1
  17. package/dist/assets/{LiveDesktop-csn9EgQr.js → LiveDesktop-IxdGhD-Q.js} +1 -1
  18. package/dist/assets/{LocalVmWorkspace-CY-cK25P.js → LocalVmWorkspace-Gt1f31fp.js} +1 -1
  19. package/dist/assets/{MacLocalControl-tjDKmfaz.js → MacLocalControl-oEzEDSQg.js} +1 -1
  20. package/dist/assets/{MarkdownFilePreview-C9270gON.js → MarkdownFilePreview-DJwfsd44.js} +1 -1
  21. package/dist/assets/{MenuMotion-CtV49YrJ.js → MenuMotion-DFWzLAOE.js} +1 -1
  22. package/dist/assets/{NewBotDialog-QR0H-5OX.js → NewBotDialog-D35bddr4.js} +1 -1
  23. package/dist/assets/{PhoneAppDialog-4jvBw2u6.js → PhoneAppDialog-KUYTOj7D.js} +1 -1
  24. package/dist/assets/PlacesRail-i-4ph-KR.js +1 -0
  25. package/dist/assets/{PluginsPanel-DHUbnE7N.js → PluginsPanel-CuagbyMf.js} +2 -2
  26. package/dist/assets/ProIntroduction-__lUgknC.js +1 -0
  27. package/dist/assets/{RemoteAgentSettingsPanel-Dllevm4e.js → RemoteAgentSettingsPanel-cEvDuPCS.js} +1 -1
  28. package/dist/assets/{RoomPanel-Bd_Xtwqu.js → RoomPanel-BD90s9Gm.js} +1 -1
  29. package/dist/assets/{RoutinesPage-QcfeQgTy.js → RoutinesPage-D9Iluc9-.js} +2 -2
  30. package/dist/assets/SettingsModal-9sV2Uiaz.js +19 -0
  31. package/dist/assets/{ShareTeamDialog-DMqi3pEn.js → ShareTeamDialog-DtorqFJu.js} +1 -1
  32. package/dist/assets/{SignedInSites-DayALoO-.js → SignedInSites-C25nZIiv.js} +1 -1
  33. package/dist/assets/{TeamLibraryPanel-DMAGl5Yz.js → TeamLibraryPanel-DOdfbGyQ.js} +1 -1
  34. package/dist/assets/{TeamMapPage-MEkKU-EN.js → TeamMapPage-DMQdbBL9.js} +1 -1
  35. package/dist/assets/{TriggersPage-D3KTWX3z.js → TriggersPage-Yhbyd0Ek.js} +1 -1
  36. package/dist/assets/VisibilitySection-C2HwkrIB.js +22 -0
  37. package/dist/assets/{WebhookTrigger-DJlTvzBb.js → WebhookTrigger-BV_b2cuN.js} +1 -1
  38. package/dist/assets/{WorksOnGrid-CW82h_3C.js → WorksOnGrid-ag2h-J0c.js} +1 -1
  39. package/dist/assets/{abnfDiagram-YUKMZFIV-DmWI1Mtg.js → abnfDiagram-YUKMZFIV-CAhmS2rs.js} +1 -1
  40. package/dist/assets/{activity-WfPBvs3Z.js → activity-Bi0tXcsw.js} +1 -1
  41. package/dist/assets/{architectureDiagram-47P4ROYG-rzc3-Q0w.js → architectureDiagram-47P4ROYG-B6w0Yu0g.js} +1 -1
  42. package/dist/assets/{blockDiagram-E7TT5TSB-VPDyKlQ7.js → blockDiagram-E7TT5TSB-BYtaJu6s.js} +1 -1
  43. package/dist/assets/{c4Diagram-CRA5TL53-C9OGckku.js → c4Diagram-CRA5TL53-B_FsOyDV.js} +1 -1
  44. package/dist/assets/{calendar-days-W4JHp6-m.js → calendar-days-B8SfZLZO.js} +1 -1
  45. package/dist/assets/channel-DVwNbGUM.js +1 -0
  46. package/dist/assets/{chunk-2Q5K7J3B-EpYkwMC8.js → chunk-2Q5K7J3B-BdKiuWEd.js} +1 -1
  47. package/dist/assets/{chunk-5VM5RSS4-DyJEI8X6.js → chunk-5VM5RSS4-CgItQr02.js} +1 -1
  48. package/dist/assets/{chunk-7TKQ45FW-CJvVxQ2I.js → chunk-7TKQ45FW-BFsWqiRT.js} +1 -1
  49. package/dist/assets/{chunk-AW2ZBBNX-s78zNrhy.js → chunk-AW2ZBBNX-Cnj5ddTo.js} +1 -1
  50. package/dist/assets/{chunk-FVRAUYC3-CUPjaz9e.js → chunk-FVRAUYC3-BCqqreNP.js} +2 -2
  51. package/dist/assets/{chunk-HTAEGDNF-BhuM2dxl.js → chunk-HTAEGDNF-BOE8LQps.js} +1 -1
  52. package/dist/assets/{chunk-JWPE2WC7-DAj1UgJ8.js → chunk-JWPE2WC7-DhA4nyzx.js} +1 -1
  53. package/dist/assets/{chunk-KQW6MTUR-BgfdtkJI.js → chunk-KQW6MTUR-DzXl5ZXS.js} +1 -1
  54. package/dist/assets/{chunk-XXDRQBXY-Vak43p0S.js → chunk-XXDRQBXY-C6tPSut7.js} +1 -1
  55. package/dist/assets/{classDiagram-v2-K4WV4PDN-Cjvbs86l.js → classDiagram-v2-K4WV4PDN-DQW9NJQl.js} +1 -1
  56. package/dist/assets/{core-x2kyD7fr.js → core-wXrRNESU.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-BEekB3gO.js → cose-bilkent-JH36ORCC-6jNO5GSL.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-D3g3_jPk.js → cynefin-EF2NZ3EQ-mnQt4_3K.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-13xmjXZj.js → cynefinDiagram-3GCD6N5R-DoEMDFuf.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-CHAV8s2t.js → dagre-W4DXFKR2-DoKMCbtK.js} +1 -1
  61. package/dist/assets/de-C8GllVmL.js +8 -0
  62. package/dist/assets/{diagram-2UJZ2QOL-DgwdzZN7.js → diagram-2UJZ2QOL-dVwBPQ-y.js} +1 -1
  63. package/dist/assets/{diagram-OVF4WLC6-DobmWwa_.js → diagram-OVF4WLC6-xIwVUznT.js} +1 -1
  64. package/dist/assets/{diagram-PFPMY2P6-CWjTVc0N.js → diagram-PFPMY2P6-DAkRkPXu.js} +1 -1
  65. package/dist/assets/{diagram-UMYRVEAY-CAruZkhk.js → diagram-UMYRVEAY-YE49n-np.js} +1 -1
  66. package/dist/assets/{diagram-YEKJPTXX-Bcs89mQN.js → diagram-YEKJPTXX-DQkmy5qU.js} +1 -1
  67. package/dist/assets/{diagram-ZIFT7M5P-Dz-O18tl.js → diagram-ZIFT7M5P-u9Uj06_B.js} +1 -1
  68. package/dist/assets/{ebnfDiagram-VR2GEFS7-CJX4rMIs.js → ebnfDiagram-VR2GEFS7-DoxIDWDW.js} +1 -1
  69. package/dist/assets/{elk-IJKZMXRS-Byop6FtW.js → elk-IJKZMXRS-DPDeQQIg.js} +1 -1
  70. package/dist/assets/{erDiagram-O2IAPWRE-ChpLnNCF.js → erDiagram-O2IAPWRE-BHdTvU5H.js} +1 -1
  71. package/dist/assets/{file-up-G3qWGpEB.js → file-up-BkYyRMzo.js} +1 -1
  72. package/dist/assets/{flowDiagram-OXPTDLAJ-CWWhkNOE.js → flowDiagram-OXPTDLAJ-ChNmwKMG.js} +1 -1
  73. package/dist/assets/{ganttDiagram-R7TSEDQI-DMXicWgq.js → ganttDiagram-R7TSEDQI-3Sx3AKf_.js} +1 -1
  74. package/dist/assets/{gitGraphDiagram-XJZIOB7I-CpiCnPUQ.js → gitGraphDiagram-XJZIOB7I-C67fsohV.js} +1 -1
  75. package/dist/assets/{import-name-Dob2tT-n.js → import-name-CtM6o0iP.js} +1 -1
  76. package/dist/assets/{index-B7zM90O2.js → index-Bsx9nj0X.js} +1 -1
  77. package/dist/assets/index-CNJBUMXg.js +3 -0
  78. package/dist/assets/{infoDiagram-5W2HQ5XZ-BU9zbv9f.js → infoDiagram-5W2HQ5XZ-CBtxWn_a.js} +1 -1
  79. package/dist/assets/{ishikawaDiagram-K3B6WC7H-KEjUVvmG.js → ishikawaDiagram-K3B6WC7H-B0368JQ8.js} +1 -1
  80. package/dist/assets/{journeyDiagram-COXZFDF6-DGU1V_40.js → journeyDiagram-COXZFDF6-BlyoIOJv.js} +1 -1
  81. package/dist/assets/{kanban-definition-P3RFRI5V-weJ2OFB2.js → kanban-definition-P3RFRI5V-Cn5CUDI2.js} +1 -1
  82. package/dist/assets/{mcp-servers-Cki_Gh83.js → mcp-servers-2qPA-IkI.js} +1 -1
  83. package/dist/assets/{mermaid.core-DhSRukyE.js → mermaid.core-BitzuZjJ.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LZFPQGKD-DKKO0DWj.js → mindmap-definition-LZFPQGKD-Jg9lbPrn.js} +1 -1
  85. package/dist/assets/{minimize-C16JX5N8.js → minimize-CIbeUlkc.js} +1 -1
  86. package/dist/assets/{monitor-Bben4nuu.js → monitor-CQgH3Q9j.js} +1 -1
  87. package/dist/assets/{new-bot-Cdx_YpVT.js → new-bot-B_VdIM0S.js} +2 -2
  88. package/dist/assets/org-library-Dh8-yJT-.js +1 -0
  89. package/dist/assets/{package-format-C4A5Q4UD.js → package-format-DjWXsBZ0.js} +2 -2
  90. package/dist/assets/{pegDiagram-BGZESJAR-CNNprTkt.js → pegDiagram-BGZESJAR-CnAlnJHt.js} +1 -1
  91. package/dist/assets/{pieDiagram-CAPJLFHJ-pS8U8zdK.js → pieDiagram-CAPJLFHJ-DaL17-zU.js} +1 -1
  92. package/dist/assets/pt-br-DiNqB940.js +13 -0
  93. package/dist/assets/{quadrantDiagram-GDMTTRAM-CLk_fr2j.js → quadrantDiagram-GDMTTRAM-BJHzyXHs.js} +1 -1
  94. package/dist/assets/rail-BDfsZpav.js +1 -0
  95. package/dist/assets/{railroadDiagram-SM67HX2B-DH8VPMJG.js → railroadDiagram-SM67HX2B-Cw9re6eo.js} +1 -1
  96. package/dist/assets/{remote-desktop-panel-XKcfTfrc.js → remote-desktop-panel-BmTQ50TK.js} +1 -1
  97. package/dist/assets/{requirementDiagram-X7JNWC4A-CoHRI7dx.js → requirementDiagram-X7JNWC4A-Cd7X7PJA.js} +1 -1
  98. package/dist/assets/{sankeyDiagram-UM26HJRW-2zcVfvWw.js → sankeyDiagram-UM26HJRW-nufeOHip.js} +1 -1
  99. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B0d21eid.js → sequenceDiagram-ZO4K6R2Y-CMZoHw7j.js} +1 -1
  100. package/dist/assets/{sizeCapture-INFHLROL-CcYkvoh7.js → sizeCapture-INFHLROL-DPZOqMVW.js} +1 -1
  101. package/dist/assets/{stateDiagram-v2-TBUQTH76-B5EilR72.js → stateDiagram-v2-TBUQTH76-BpWOIyFw.js} +1 -1
  102. package/dist/assets/styles-BvB4UlHn.js +79 -0
  103. package/dist/assets/styles-Ce5Qc_2r.css +1 -0
  104. package/dist/assets/{swimlanes-N4OXWK64-xM7mNll9.js → swimlanes-N4OXWK64-BNx8ZaTX.js} +1 -1
  105. package/dist/assets/swimlanesDiagram-K3J5GTZL-BO73RuC_.js +8 -0
  106. package/dist/assets/{team-share-Bp69YR8I.js → team-share-CNY994iy.js} +1 -1
  107. package/dist/assets/{timeline-definition-YOQAKGHF-DM6SmhCQ.js → timeline-definition-YOQAKGHF-L78B2xWx.js} +1 -1
  108. package/dist/assets/{usecaseDiagram-VIAY4XPW-DiUdGN3G.js → usecaseDiagram-VIAY4XPW-gU5zWpPp.js} +1 -1
  109. package/dist/assets/{vennDiagram-BLWOH2XV-DrtmNBp4.js → vennDiagram-BLWOH2XV-pdiz8880.js} +1 -1
  110. package/dist/assets/vi-Cbg_srO_.js +15 -0
  111. package/dist/assets/{wardleyDiagram-YMQ3BMBF-D7jihWm5.js → wardleyDiagram-YMQ3BMBF-F-D92MhK.js} +1 -1
  112. package/dist/assets/{xychartDiagram-TAQBALBS-BCk-D9Uj.js → xychartDiagram-TAQBALBS-DKMdsWWR.js} +1 -1
  113. package/dist/index.html +3 -3
  114. package/dist/rail.html +5 -5
  115. package/dist-server/bot-box/box-check.js +10 -10
  116. package/dist-server/cloud-home-start.js +5 -5
  117. package/dist-server/container-mcp.js +2 -2
  118. package/dist-server/drivers/agents-proxy.js +128 -126
  119. package/dist-server/index.js +8241 -7922
  120. package/dist-server/mcp-gate.js +18 -17
  121. package/dist-server/openmausbot.js +1153 -1119
  122. package/dist-server/package.json +1 -1
  123. package/dist-server/pair-cli.js +1028 -997
  124. package/dist-server/server/activity.js +1 -0
  125. package/dist-server/server/agents-turn.js +2 -1
  126. package/dist-server/server/app-settings/host.js +187 -0
  127. package/dist-server/server/app-settings/picture-file.js +62 -0
  128. package/dist-server/server/app-settings/registry-bots.js +147 -0
  129. package/dist-server/server/app-settings/registry-config.js +190 -0
  130. package/dist-server/server/app-settings/registry-pictures.js +59 -0
  131. package/dist-server/server/app-settings/registry-window.js +35 -0
  132. package/dist-server/server/app-settings/registry.js +287 -0
  133. package/dist-server/server/attachments.js +16 -12
  134. package/dist-server/server/automation-reports.js +11 -1
  135. package/dist-server/server/bot-attachment.js +34 -10
  136. package/dist-server/server/bot-box/env.js +2 -2
  137. package/dist-server/server/bot-box/plan.js +1 -1
  138. package/dist-server/server/cloud-home-start.js +2 -0
  139. package/dist-server/server/config.js +1 -0
  140. package/dist-server/server/drivers/acp/client-path.js +39 -0
  141. package/dist-server/server/drivers/acp/core.js +9 -37
  142. package/dist-server/server/drivers/agents-app-settings-tool.js +22 -0
  143. package/dist-server/server/drivers/agents-call.js +8 -3
  144. package/dist-server/server/drivers/agents-catalog-profile.js +2 -1
  145. package/dist-server/server/drivers/agents-catalog.js +19 -2
  146. package/dist-server/server/drivers/agents-claude-defer.js +38 -0
  147. package/dist-server/server/drivers/agents-mcp-env.js +2 -2
  148. package/dist-server/server/drivers/agents-mcp.js +2 -1
  149. package/dist-server/server/drivers/agents-proxy.js +0 -1
  150. package/dist-server/server/drivers/agents-tool-groups.js +45 -0
  151. package/dist-server/server/drivers/antigravity-acp.js +6 -2
  152. package/dist-server/server/drivers/antigravity-skills.js +107 -0
  153. package/dist-server/server/drivers/antigravity.js +9 -1
  154. package/dist-server/server/drivers/claude-bot-settings.js +22 -1
  155. package/dist-server/server/drivers/claude-tool-search.js +20 -2
  156. package/dist-server/server/drivers/claude.js +12 -12
  157. package/dist-server/server/drivers/ollama-context.js +5 -2
  158. package/dist-server/server/drivers/openai-chat.js +10 -10
  159. package/dist-server/server/drivers/retry.js +3 -2
  160. package/dist-server/server/email/host.js +6 -2
  161. package/dist-server/server/engine-handshake.js +1 -0
  162. package/dist-server/server/generated-image.js +1 -1
  163. package/dist-server/server/host/bot-holds.js +76 -0
  164. package/dist-server/server/host/fill-login-turn.js +2 -2
  165. package/dist-server/server/host/handoff-limits.js +30 -0
  166. package/dist-server/server/host/limit-takeover.js +11 -0
  167. package/dist-server/server/host/peer-limit-resend.js +147 -0
  168. package/dist-server/server/host/skills-library.js +15 -1
  169. package/dist-server/server/host/trust-answers.js +42 -0
  170. package/dist-server/server/imported-skills.js +15 -4
  171. package/dist-server/server/index.js +109 -125
  172. package/dist-server/server/limit-poll.js +32 -0
  173. package/dist-server/server/limit-reset-owed.js +15 -0
  174. package/dist-server/server/limit-resets.js +33 -8
  175. package/dist-server/server/login-fill.js +37 -9
  176. package/dist-server/server/mcp-gate-config.js +28 -0
  177. package/dist-server/server/mcp-gate.js +8 -2
  178. package/dist-server/server/message-file.js +10 -1
  179. package/dist-server/server/quota-switch.js +7 -5
  180. package/dist-server/server/replies.js +1 -1
  181. package/dist-server/server/request-auth.js +7 -4
  182. package/dist-server/server/routes/app-settings.js +46 -0
  183. package/dist-server/server/routes/bot-holds.js +24 -0
  184. package/dist-server/server/routes/bot-patch.js +7 -0
  185. package/dist-server/server/routes/call-route.js +16 -0
  186. package/dist-server/server/routes/channels.js +45 -38
  187. package/dist-server/server/routes/custom-domain.js +36 -0
  188. package/dist-server/server/routes/sidebar-sections.js +1 -0
  189. package/dist-server/server/routes/threads.js +1 -1
  190. package/dist-server/server/routine-lines.js +25 -0
  191. package/dist-server/server/routines.js +9 -5
  192. package/dist-server/server/runtime/envelope.js +3 -0
  193. package/dist-server/server/runtime/store.js +1 -0
  194. package/dist-server/server/send-idempotency.js +43 -0
  195. package/dist-server/server/shared-computers.js +35 -6
  196. package/dist-server/server/themes/history.js +54 -0
  197. package/dist-server/server/themes/routes.js +136 -0
  198. package/dist-server/server/themes/store.js +266 -0
  199. package/dist-server/server/themes/tool.js +151 -0
  200. package/dist-server/server/tool-groups.js +12 -0
  201. package/dist-server/server/turn-continuation.js +6 -6
  202. package/dist-server/shared/app-settings.js +60 -0
  203. package/dist-server/shared/bot-limit.js +2 -0
  204. package/dist-server/shared/plain-preview.js +3 -2
  205. package/dist-server/shared/theme.js +240 -0
  206. package/dist-server/shared/tool-groups.js +27 -0
  207. package/dist-server/src/lib/composer-attachments.js +22 -6
  208. package/dist-server/vps-container-mcp.js +12 -12
  209. package/dist-server/workspace-backup.worker.js +2 -2
  210. package/package.json +1 -1
  211. package/dist/assets/App-BjHYb_ps.js +0 -243
  212. package/dist/assets/BotSettingsDialog-D8LUP9Jn.js +0 -16
  213. package/dist/assets/CloudAddDialog-BbmxUPbT.js +0 -1
  214. package/dist/assets/ComputerFilesPane-Df6Y0sr2.js +0 -1
  215. package/dist/assets/PlacesRail-COZEZH0n.js +0 -57
  216. package/dist/assets/ProIntroduction-Cc_7SVv1.js +0 -1
  217. package/dist/assets/SettingsModal-MzznkaJe.js +0 -19
  218. package/dist/assets/VisibilitySection-ajWCQrhN.js +0 -22
  219. package/dist/assets/channel-DAFePtOr.js +0 -1
  220. package/dist/assets/de-CJcRve_J.js +0 -8
  221. package/dist/assets/index-C2Sr_aMA.js +0 -2
  222. package/dist/assets/org-library-tRxkixxQ.js +0 -1
  223. package/dist/assets/pt-br-Dr9a700a.js +0 -13
  224. package/dist/assets/rail-CpM5o3ti.js +0 -1
  225. package/dist/assets/styles-Cbtcp5Re.js +0 -23
  226. package/dist/assets/styles-rYmbSF4Y.css +0 -1
  227. package/dist/assets/swimlanesDiagram-K3J5GTZL-CnVwW_RC.js +0 -8
  228. package/dist/assets/vi-vTat5qyz.js +0 -15
  229. package/dist-server/server/limix-managed-grant.js +0 -110
@@ -0,0 +1,266 @@
1
+ // Each person's themes on this workspace: <dataDir>/themes/<person>/<theme id>/theme.json with its files beside it in
2
+ // assets/, active.json naming the one their windows wear, and history.json with their last look changes.
3
+ import { createHash } from "node:crypto";
4
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { LOOK_HISTORY_LIMIT, rehomeThemeCss, THEME_ASSET_NAME, THEME_EXPORT_VERSION, THEME_ID, THEME_LIMITS, themeAssetType, themeAssetUrl, themeCssProblem, themeFileSchema, } from "../../shared/theme.js";
7
+ import { writeFileAtomic } from "../atomic.js";
8
+ import { appendHistory, lookAfter, readHistory } from "./history.js";
9
+ const refused = (refusal) => ({ refusal });
10
+ export const isRefusal = (value) => typeof value === "object" && value !== null && "refusal" in value;
11
+ /** A person's folder name: the key itself when it is plain, a hash otherwise, so no key can name a path. */
12
+ const personFolder = (person) => (/^[\w-]{1,64}$/.test(person) ? person : `h_${createHash("sha256").update(person).digest("hex").slice(0, 32)}`);
13
+ /** Route words under /api/themes/, and the tool's word for no theme. */
14
+ const RESERVED_IDS = new Set(["active", "history", "import", "none"]);
15
+ export const slugFor = (name) => name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "theme";
16
+ /** Security: a file's first bytes must match its extension, so a theme file is only ever the image or font it claims. */
17
+ function looksLike(name, bytes) {
18
+ const ext = name.slice(name.lastIndexOf(".") + 1);
19
+ const starts = (...values) => values.every((value, index) => bytes[index] === value);
20
+ const ascii = (at, text) => bytes.subarray(at, at + text.length).toString("latin1") === text;
21
+ switch (ext) {
22
+ case "png": return starts(0x89, 0x50, 0x4e, 0x47);
23
+ case "jpg":
24
+ case "jpeg": return starts(0xff, 0xd8, 0xff);
25
+ case "gif": return ascii(0, "GIF8");
26
+ case "webp": return ascii(0, "RIFF") && ascii(8, "WEBP");
27
+ case "avif": return ascii(4, "ftyp");
28
+ case "woff": return ascii(0, "wOFF");
29
+ case "woff2": return ascii(0, "wOF2");
30
+ case "ttf": return starts(0x00, 0x01, 0x00, 0x00) || ascii(0, "true");
31
+ case "otf": return ascii(0, "OTTO");
32
+ case "svg": {
33
+ const head = bytes.subarray(0, 4096).toString("utf8").replace(/^/, "").trimStart();
34
+ return /^(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>]/i.test(head);
35
+ }
36
+ default: return false;
37
+ }
38
+ }
39
+ export function createThemeStore(deps) {
40
+ const root = join(deps.dataDir, "themes");
41
+ const home = (person) => join(root, personFolder(person));
42
+ const folder = (person, id) => join(home(person), id);
43
+ const assetsDir = (person, id) => join(folder(person, id), "assets");
44
+ const validId = (id) => THEME_ID.test(id) && !RESERVED_IDS.has(id);
45
+ function read(person, id) {
46
+ if (!validId(id))
47
+ return null;
48
+ try {
49
+ const parsed = themeFileSchema.safeParse(JSON.parse(readFileSync(join(folder(person, id), "theme.json"), "utf8")));
50
+ return parsed.success ? parsed.data : null;
51
+ }
52
+ catch {
53
+ return null;
54
+ }
55
+ }
56
+ function ids(person) {
57
+ try {
58
+ return readdirSync(home(person), { withFileTypes: true }).filter((entry) => entry.isDirectory() && validId(entry.name)).map((entry) => entry.name).sort();
59
+ }
60
+ catch {
61
+ return [];
62
+ }
63
+ }
64
+ function assets(person, id) {
65
+ try {
66
+ return readdirSync(assetsDir(person, id)).filter((name) => THEME_ASSET_NAME.test(name)).sort();
67
+ }
68
+ catch {
69
+ return [];
70
+ }
71
+ }
72
+ function active(person) {
73
+ try {
74
+ const value = JSON.parse(readFileSync(join(home(person), "active.json"), "utf8")).id;
75
+ return typeof value === "string" && read(person, value) ? value : null;
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ function setActive(person, id) {
82
+ if (id !== null && !read(person, id))
83
+ return refused(`No saved theme has the id ${id}.`);
84
+ mkdirSync(home(person), { recursive: true });
85
+ writeFileAtomic(join(home(person), "active.json"), JSON.stringify({ id }));
86
+ return null;
87
+ }
88
+ function saveProblem(person, id, file) {
89
+ if (!validId(id))
90
+ return refused("A theme id is lowercase letters, digits and dashes, up to 48 characters.");
91
+ const problem = file.css ? themeCssProblem(file.css) : null;
92
+ if (problem)
93
+ return refused(problem);
94
+ if (!read(person, id) && ids(person).length >= THEME_LIMITS.themesPerPerson)
95
+ return refused(`You can keep up to ${THEME_LIMITS.themesPerPerson} themes. Delete one first.`);
96
+ return null;
97
+ }
98
+ function writeTheme(person, id, file) {
99
+ mkdirSync(folder(person, id), { recursive: true });
100
+ writeFileAtomic(join(folder(person, id), "theme.json"), `${JSON.stringify(file, null, 2)}\n`);
101
+ }
102
+ /** Saves a theme without recording a look change: a copy, an import or a new name. */
103
+ function save(person, id, file) {
104
+ const problem = saveProblem(person, id, file);
105
+ if (problem)
106
+ return problem;
107
+ writeTheme(person, id, file);
108
+ return null;
109
+ }
110
+ const nameOf = (person, id) => read(person, id)?.name ?? id;
111
+ function describe(person, before, after, edited, skin) {
112
+ if (edited.length)
113
+ return { kind: edited[0].was.file ? "edited" : "made", name: edited[0].file.name };
114
+ if (after.id && after.id !== before.id)
115
+ return { kind: "wore", name: nameOf(person, after.id) };
116
+ if (after.id === before.id && after.skin === before.skin)
117
+ return null;
118
+ return skin && skin !== "system" ? { kind: "skin", name: skin } : { kind: "default" };
119
+ }
120
+ /** Saves themes and changes what is worn as one entry in the person's look history; answers the skin to put on. */
121
+ function change(person, write) {
122
+ const saves = write.saves ?? [];
123
+ for (const { id, file } of saves) {
124
+ const problem = saveProblem(person, id, file);
125
+ if (problem)
126
+ return problem;
127
+ }
128
+ if (write.wear && !read(person, write.wear) && !saves.some((save) => save.id === write.wear))
129
+ return refused(`No saved theme has the id ${write.wear}.`);
130
+ const known = readHistory(home(person)).at(-1)?.after.skin;
131
+ const before = { id: active(person), ...(known ? { skin: known } : {}) };
132
+ const themes = Object.fromEntries([...saves.map((save) => save.id), ...(write.keep ?? [])].map((id) => [id, { file: read(person, id), assets: assets(person, id) }]));
133
+ for (const { id, file } of saves)
134
+ writeTheme(person, id, file);
135
+ if (write.wear !== undefined)
136
+ setActive(person, write.wear);
137
+ const skin = write.skin ?? known;
138
+ const after = { id: active(person), ...(skin ? { skin } : {}) };
139
+ const edited = saves.flatMap((save) => (JSON.stringify(themes[save.id].file) === JSON.stringify(save.file) ? [] : [{ ...save, was: themes[save.id] }]));
140
+ const said = write.change ?? describe(person, before, after, edited, write.skin);
141
+ if (said)
142
+ appendHistory(home(person), { change: said, before, after, ...(Object.keys(themes).length ? { themes } : {}) });
143
+ return write.skin ? { skin: write.skin } : {};
144
+ }
145
+ /** The person's kept look changes, newest first, each with the look right after it. */
146
+ function history(person) {
147
+ const since = {};
148
+ return readHistory(home(person)).reverse().map((entry, index) => {
149
+ const id = entry.after.id;
150
+ const file = id ? (id in since ? since[id].file : read(person, id)) : null;
151
+ Object.assign(since, entry.themes);
152
+ return { index: index + 1, at: entry.at, ...entry.change, seq: entry.seq, look: entry.after, file };
153
+ });
154
+ }
155
+ /** Goes back to how things looked right after change `seq`, as a new change, so going back on it is a redo. */
156
+ function restore(person, seq) {
157
+ const plan = lookAfter(readHistory(home(person)), seq);
158
+ if (!plan)
159
+ return refused(`Only the last ${LOOK_HISTORY_LIMIT} look changes are kept.`);
160
+ if (!plan.undone.length)
161
+ return refused("That is how it looks now.");
162
+ const saves = Object.entries(plan.themes).flatMap(([id, snapshot]) => (snapshot.file ? [{ id, file: snapshot.file }] : []));
163
+ const skin = plan.look.skin ?? (plan.undone.some((entry) => entry.before.skin !== entry.after.skin) ? "system" : undefined);
164
+ return change(person, { saves, wear: plan.look.id, ...(skin ? { skin } : {}), change: { kind: "undid", count: plan.undone.length } });
165
+ }
166
+ /** The files a theme had at change `seq` that are gone from its folder now. */
167
+ function missingAssets(person, seq) {
168
+ const plan = lookAfter(readHistory(home(person)), seq);
169
+ return Object.entries(plan?.themes ?? {}).flatMap(([id, snapshot]) => snapshot.assets.filter((name) => !asset(person, id, name)));
170
+ }
171
+ function addAsset(person, id, name, bytes) {
172
+ const clean = name.toLowerCase();
173
+ if (!read(person, id))
174
+ return refused(`Save the theme ${id} first, then add files to it.`);
175
+ if (!THEME_ASSET_NAME.test(clean))
176
+ return refused("A theme file name is lowercase letters, digits, - and _, ending in .png, .jpg, .webp, .gif, .avif, .svg, .woff2, .woff, .ttf or .otf.");
177
+ if (bytes.byteLength === 0)
178
+ return refused("The file is empty.");
179
+ if (bytes.byteLength > THEME_LIMITS.assetBytes)
180
+ return refused(`A theme file may be up to ${THEME_LIMITS.assetBytes / 1024 / 1024} MB.`);
181
+ if (!looksLike(clean, bytes))
182
+ return refused(`${clean} is not the kind of file its name says.`);
183
+ const others = assets(person, id).filter((existing) => existing !== clean);
184
+ if (others.length >= THEME_LIMITS.assetsPerTheme)
185
+ return refused(`A theme holds up to ${THEME_LIMITS.assetsPerTheme} files.`);
186
+ const kept = others.reduce((sum, existing) => sum + statSync(join(assetsDir(person, id), existing)).size, 0);
187
+ if (kept + bytes.byteLength > THEME_LIMITS.themeBytes)
188
+ return refused(`A theme's files may total up to ${THEME_LIMITS.themeBytes / 1024 / 1024} MB.`);
189
+ mkdirSync(assetsDir(person, id), { recursive: true });
190
+ writeFileAtomic(join(assetsDir(person, id), clean), bytes);
191
+ return { url: themeAssetUrl(id, clean) };
192
+ }
193
+ /** A theme file to serve, or null; the name is checked before it nears the disk. */
194
+ function asset(person, id, name) {
195
+ if (!validId(id) || !THEME_ASSET_NAME.test(name))
196
+ return null;
197
+ const path = join(assetsDir(person, id), name);
198
+ const type = themeAssetType(name);
199
+ try {
200
+ const stat = statSync(path);
201
+ return stat.isFile() && type ? { path, type, bytes: stat.size, mtimeMs: stat.mtimeMs } : null;
202
+ }
203
+ catch {
204
+ return null;
205
+ }
206
+ }
207
+ function freeId(person, wanted) {
208
+ const base = slugFor(wanted);
209
+ let id = base;
210
+ for (let n = 2; existsSync(folder(person, id)) || RESERVED_IDS.has(id); n++)
211
+ id = `${base}-${n}`;
212
+ return id;
213
+ }
214
+ function duplicate(person, id, name) {
215
+ const file = read(person, id);
216
+ if (!file)
217
+ return refused(`No saved theme has the id ${id}.`);
218
+ if (ids(person).length >= THEME_LIMITS.themesPerPerson)
219
+ return refused(`You can keep up to ${THEME_LIMITS.themesPerPerson} themes. Delete one first.`);
220
+ const copy = freeId(person, name);
221
+ if (existsSync(assetsDir(person, id)))
222
+ cpSync(assetsDir(person, id), assetsDir(person, copy), { recursive: true });
223
+ const saved = save(person, copy, { ...file, name, ...(file.css ? { css: rehomeThemeCss(file.css, id, copy) } : {}) });
224
+ return saved ?? { id: copy };
225
+ }
226
+ function remove(person, id) {
227
+ if (!validId(id))
228
+ return;
229
+ if (active(person) === id)
230
+ change(person, { wear: null, keep: [id], change: { kind: "deleted", name: nameOf(person, id) } });
231
+ rmSync(folder(person, id), { recursive: true, force: true });
232
+ }
233
+ function exportTheme(person, id) {
234
+ const theme = read(person, id);
235
+ if (!theme)
236
+ return null;
237
+ const files = Object.fromEntries(assets(person, id).map((name) => [name, `data:${themeAssetType(name)};base64,${readFileSync(join(assetsDir(person, id), name)).toString("base64")}`]));
238
+ return { mausbotTheme: THEME_EXPORT_VERSION, id, theme, ...(Object.keys(files).length ? { assets: files } : {}) };
239
+ }
240
+ /** Saves an exported theme under a new id, with its files stored again and its CSS pointed at them. */
241
+ function importTheme(person, data) {
242
+ const id = freeId(person, data.id ?? data.theme.name);
243
+ const theme = data.id && data.theme.css ? { ...data.theme, css: rehomeThemeCss(data.theme.css, data.id, id) } : data.theme;
244
+ const saved = save(person, id, theme);
245
+ if (saved)
246
+ return saved;
247
+ for (const [name, address] of Object.entries(data.assets ?? {})) {
248
+ const added = addAsset(person, id, name, Buffer.from(address.slice(address.indexOf(",") + 1), "base64"));
249
+ if (isRefusal(added)) {
250
+ remove(person, id);
251
+ return added;
252
+ }
253
+ }
254
+ return { id };
255
+ }
256
+ return {
257
+ read, save, active, setActive, change, history, restore, missingAssets, addAsset, asset, duplicate, remove, exportTheme, importTheme, freeId,
258
+ list(person) {
259
+ const themes = ids(person).flatMap((id) => {
260
+ const file = read(person, id);
261
+ return file ? [{ id, name: file.name, hasCss: Boolean(file.css), assets: assets(person, id) }] : [];
262
+ });
263
+ return { active: active(person), themes };
264
+ },
265
+ };
266
+ }
@@ -0,0 +1,151 @@
1
+ // app_settings' theme actions: read the person's themes with the guide, save and wear one, copy a file from the bot's own
2
+ // folders into a theme, and list or go back on their look changes. A theme is the person's who started the turn, so it
3
+ // reaches their windows and no one else's.
4
+ import { basename, dirname, extname } from "node:path";
5
+ import { z } from "zod";
6
+ import { SKIN_IDS } from "../../shared/app-settings.js";
7
+ import { THEME_ID, THEME_LIMITS, themeCssProblem, themeFileSchema, themeGuide } from "../../shared/theme.js";
8
+ import { openMessageFile } from "../message-file.js";
9
+ import { isRefusal, slugFor } from "./store.js";
10
+ const BUILT_IN = [...SKIN_IDS, "system"];
11
+ const reply = (status, body) => ({ status, body });
12
+ const refuse = (status, error) => reply(status, { error });
13
+ /** A look change in a few words, as the bot reads it in theme_history and on a card. */
14
+ function said(change) {
15
+ switch (change.kind) {
16
+ case "made": return `made ${change.name}`;
17
+ case "edited": return `edited ${change.name}`;
18
+ case "deleted": return `deleted ${change.name} while wearing it`;
19
+ case "wore": return `wore ${change.name}`;
20
+ case "skin": return `wore the built-in ${change.name} skin`;
21
+ case "default": return "back to default";
22
+ case "undid": return `went back ${change.count === 1 ? "1 change" : `${change.count} changes`}`;
23
+ }
24
+ }
25
+ export function createThemeTool(deps) {
26
+ const { store } = deps;
27
+ /** The person's current theme as a setting, so the applied card and its Undo work as every other setting's do. */
28
+ function entry(person) {
29
+ const read = () => {
30
+ const id = store.active(person);
31
+ return id ? (store.read(person, id)?.name ?? id) : "";
32
+ };
33
+ return {
34
+ id: "appearance.theme", label: "Theme", help: "A custom look for the app.", where: "Settings → Appearance", synonyms: [], tier: "safe",
35
+ value: z.unknown(), allowed: "a theme", read,
36
+ current: () => ({ undoTo: store.history(person)[0]?.seq ?? 0 }),
37
+ write: async (value) => {
38
+ const wear = value;
39
+ const done = "undoTo" in wear ? store.restore(person, wear.undoTo) : store.change(person, { saves: wear.save ? [wear.save] : [], wear: wear.id, ...(wear.skin ? { skin: wear.skin } : {}) });
40
+ if (isRefusal(done))
41
+ return done.refusal;
42
+ deps.changed(person, done.skin);
43
+ return null;
44
+ },
45
+ };
46
+ }
47
+ function overview(person, id) {
48
+ const list = store.list(person);
49
+ const asked = typeof id === "string" && THEME_ID.test(id) ? store.read(person, id) : null;
50
+ const current = list.active ? store.read(person, list.active) : null;
51
+ return reply(200, {
52
+ text: JSON.stringify({
53
+ current: list.active ? { id: list.active, theme: current } : "none: the person's built-in skin",
54
+ builtIn: BUILT_IN,
55
+ saved: list.themes,
56
+ ...(asked ? { theme: { id, ...asked } } : {}),
57
+ guide: themeGuide(),
58
+ }),
59
+ });
60
+ }
61
+ /** What set_theme asks for, as the change to make and the line its card shows; or why it cannot. */
62
+ function wanted(person, body) {
63
+ const id = typeof body.id === "string" ? body.id.trim() : "";
64
+ if (body.theme !== undefined) {
65
+ let raw = body.theme;
66
+ if (typeof raw === "string") {
67
+ try {
68
+ raw = JSON.parse(raw);
69
+ }
70
+ catch {
71
+ return { error: "theme must be the theme as JSON: {\"name\", \"canvas\", \"accent\", \"colors\", \"css\", ...}." };
72
+ }
73
+ }
74
+ const parsed = themeFileSchema.safeParse(raw);
75
+ if (!parsed.success)
76
+ return { error: `The theme does not fit: ${parsed.error.issues.slice(0, 6).map((issue) => `${issue.path.join(".") || "theme"}: ${issue.message}`).join("; ")}.` };
77
+ const themeId = id || slugFor(parsed.data.name);
78
+ if (BUILT_IN.includes(themeId) || !THEME_ID.test(themeId) || themeId === "none")
79
+ return { error: `${themeId} cannot be a saved theme's id. Use lowercase letters, digits and dashes, not a built-in skin's name.` };
80
+ const problem = parsed.data.css ? themeCssProblem(parsed.data.css) : null;
81
+ if (problem)
82
+ return { error: `Nothing changed. ${problem}` };
83
+ const existed = store.read(person, themeId) !== null;
84
+ return { wear: { id: themeId, save: { id: themeId, file: parsed.data } }, change: `${existed ? "Update" : "Save"} the theme ${parsed.data.name} and wear it` };
85
+ }
86
+ if (id === "none")
87
+ return { wear: { id: null }, change: "Take off the custom theme" };
88
+ if (BUILT_IN.includes(id))
89
+ return { wear: { id: null, skin: id }, change: id === "system" ? "Go back to the built-in look that follows the computer" : `Go back to the built-in ${id} skin` };
90
+ const saved = THEME_ID.test(id) ? store.read(person, id) : null;
91
+ if (!saved)
92
+ return { error: `No saved theme or built-in skin is called ${JSON.stringify(id)}. Call theme to list them, or send theme to save a new one.` };
93
+ return { wear: { id }, change: `Wear the theme ${saved.name}` };
94
+ }
95
+ function history(person) {
96
+ const items = store.history(person).map((item) => ({
97
+ index: item.index, at: item.at, what: said(item),
98
+ look: item.file ? { theme: item.file.name, ...(item.file.canvas ? { canvas: item.file.canvas } : {}), ...(item.file.accent ? { accent: item.file.accent } : {}) } : item.look.skin && item.look.skin !== "system" ? `built-in ${item.look.skin}` : "default",
99
+ }));
100
+ return reply(200, { text: items.length ? JSON.stringify({ now: new Date().toISOString(), changes: items }) : "No look changes yet." });
101
+ }
102
+ /** What undo_theme asks for: `steps` back (default 1), or `index` from theme_history to return to the look right after it. */
103
+ function undo(person, body) {
104
+ const items = store.history(person);
105
+ const whole = (value) => (typeof value === "number" ? value : typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : Number.NaN);
106
+ const byIndex = body.index !== undefined && body.index !== "";
107
+ const count = byIndex ? whole(body.index) - 1 : body.steps === undefined || body.steps === "" ? 1 : whole(body.steps);
108
+ if (!items.length)
109
+ return { error: "There are no look changes to go back on." };
110
+ if (!Number.isInteger(count) || count < (byIndex ? 0 : 1) || count > items.length - (byIndex ? 1 : 0)) {
111
+ return { error: `${byIndex ? "index" : "steps"} must be a whole number from 1 to ${items.length}. Call theme_history to see the changes.` };
112
+ }
113
+ if (count === 0)
114
+ return { error: "That is how it looks now." };
115
+ const target = byIndex ? items[count] : items[count - 1];
116
+ const undoTo = byIndex ? target.seq : target.seq - 1;
117
+ const missing = store.missingAssets(person, undoTo);
118
+ const back = byIndex ? `Go back to the look after: ${said(target)}` : count === 1 ? `Undo the last look change (${said(items[0])})` : `Undo the last ${count} look changes`;
119
+ return { wear: { undoTo }, change: `${back}${missing.length ? `; files no longer there: ${missing.join(", ")}` : ""}` };
120
+ }
121
+ async function addAsset(turn, person, body) {
122
+ const id = typeof body.id === "string" ? body.id : "";
123
+ if (!THEME_ID.test(id) || !store.read(person, id))
124
+ return refuse(404, "Name a saved theme in id: save it with set_theme first.");
125
+ const path = typeof body.path === "string" ? body.path.trim() : "";
126
+ if (!path)
127
+ return refuse(400, "path is the file in your workspace or this conversation's attachments.");
128
+ const sources = deps.sources(turn);
129
+ const attached = sources.attachments.includes(path);
130
+ let file;
131
+ try {
132
+ file = await openMessageFile(path, attached ? [dirname(path)] : sources.roots, THEME_LIMITS.assetBytes);
133
+ }
134
+ catch (error) {
135
+ const status = error.status ?? 400;
136
+ return refuse(status, status === 413 ? `A theme file may be up to ${THEME_LIMITS.assetBytes / 1024 / 1024} MB.` : "That file is not in your workspace or this conversation's attachments, or it cannot be read.");
137
+ }
138
+ try {
139
+ const ext = (extname(file.name).slice(1) || "").toLowerCase();
140
+ const stem = slugFor(basename(file.name, extname(file.name))).slice(0, 60);
141
+ const added = store.addAsset(person, id, `${stem}.${ext}`, await file.handle.readFile());
142
+ if (isRefusal(added))
143
+ return refuse(400, added.refusal);
144
+ return reply(200, { text: `Added. In the theme's css write url("${added.url}"). Then call set_theme with the theme to use it.` });
145
+ }
146
+ finally {
147
+ await file.handle.close().catch(() => undefined);
148
+ }
149
+ }
150
+ return { entry, overview, wanted, undo, history, addAsset, person: deps.person };
151
+ }
@@ -0,0 +1,12 @@
1
+ // The tool groups a person turned off for a bot, as the bot's prompt and the app's Settings see them.
2
+ import { TOOL_GROUP_LABELS, TOOL_GROUPS } from "../shared/tool-groups.js";
3
+ /** The prompt part that tells a bot which of its tools the person turned off, so it can say so instead of guessing. */
4
+ export function toolsOffPart(bot) {
5
+ const off = TOOL_GROUPS.filter((group) => bot?.toolsOff?.includes(group));
6
+ const text = off.length === 0 ? "" : ` The person turned off some of your tools to keep requests small: ${off.map((group) => TOOL_GROUP_LABELS[group]).join(", ")}. When they ask for something those tools do, tell them in one line that it is turned off for you and that they can turn it back on in your Settings (Access, Tools), or ask you to.`;
7
+ return { id: "tools-off", label: "Tools turned off", text };
8
+ }
9
+ /** The groups this workspace has, the ones its bots' Settings offer to turn off. */
10
+ export function availableToolGroups(has) {
11
+ return TOOL_GROUPS.filter((group) => group === "pages" || has[group]);
12
+ }
@@ -20,12 +20,12 @@ export function writeTurnHandoff(input) {
20
20
  L.push(`- Tokens this turn: ${input.usage.input} in / ${input.usage.output} out`);
21
21
  L.push(`- Stop reason: ${input.failure ?? "unknown"}`);
22
22
  L.push(`- Written at: ${new Date().toISOString()}`, "");
23
- L.push("## Original task (first user message)", "```");
24
- const firstUser = input.messages.find((m) => m.role === "user");
25
- const firstText = firstUser && typeof firstUser.content === "string"
26
- ? firstUser.content
27
- : JSON.stringify(firstUser?.content ?? null);
28
- L.push(String(firstText).slice(0, 8000), "```", "");
23
+ L.push("## Current task", "```", input.task.slice(0, 8000), "```", "");
24
+ if (input.updates?.length) {
25
+ L.push("## Updates delivered during this turn (in order)", "");
26
+ for (const update of input.updates)
27
+ L.push("```", update.slice(0, 8000), "```", "");
28
+ }
29
29
  L.push("## Work performed (tool calls in order)", "");
30
30
  let n = 0;
31
31
  for (const m of input.messages) {
@@ -0,0 +1,60 @@
1
+ // The app_settings tool's wire shapes: a setting's tier (the whole policy), the applied card a change rides on, and the
2
+ // preferences that live in the window's localStorage, which the server reaches through an SSE frame.
3
+ import { z } from "zod";
4
+ export const SKIN_IDS = [
5
+ "midnight",
6
+ "atelier",
7
+ "foundry",
8
+ "lagoon",
9
+ "graphite",
10
+ "linen",
11
+ "dusk",
12
+ "daylight",
13
+ "meadow",
14
+ "pop",
15
+ "halloween",
16
+ "diwali",
17
+ "aurora",
18
+ ];
19
+ export const FONT_IDS = ["skin", "system", "inter", "poppins", "serif"];
20
+ export const CHAT_WIDTH_IDS = ["standard", "wide", "full"];
21
+ /** The Enter-adds-a-line modes are for input methods that confirm a conversion with Enter (Japanese). */
22
+ export const SEND_KEYS = ["enter", "shift-enter", "mod-enter"];
23
+ export const PLACE_SWATCHES = ["blue", "green", "amber", "rose", "violet", "slate"];
24
+ export const TALK_KEYS = ["ctrl-opt-space", "ctrl-shift-space", "opt-shift-space"];
25
+ const pinnedPage = z.object({ name: z.string().trim().min(1).max(40), url: z.string().trim().max(2048).regex(/^https?:\/\/\S+$/, "an http(s) address") }).strict();
26
+ /** Preferences kept in the window or behind the desktop app's own bridge, by setting id; the renderer applies a frame with
27
+ * the matching setter. */
28
+ export const WINDOW_PREFS = {
29
+ "appearance.skin": z.enum([...SKIN_IDS, "system"]),
30
+ "appearance.advanced": z.boolean(),
31
+ "appearance.font": z.enum(FONT_IDS),
32
+ "appearance.chatWidth": z.enum(CHAT_WIDTH_IDS),
33
+ "general.sendKey": z.enum(SEND_KEYS),
34
+ "general.notificationSounds": z.boolean(),
35
+ "appearance.userBubbles": z.boolean(),
36
+ "appearance.runCard": z.boolean(),
37
+ "appearance.showThreads": z.boolean(),
38
+ "appearance.toolsLayout": z.enum(["rows", "toolbar"]),
39
+ "appearance.pinnedCircles": z.boolean(),
40
+ "appearance.universalPins": z.boolean(),
41
+ "appearance.pinnedPages": z.array(pinnedPage).max(6),
42
+ "appearance.showComputers": z.boolean(),
43
+ "appearance.windowFrame": z.boolean(),
44
+ "appearance.sidebarColor": z.enum([...PLACE_SWATCHES, "none"]),
45
+ "general.followUp": z.enum(["steer", "queue"]),
46
+ "general.finishedNotifications": z.boolean(),
47
+ "general.notificationFeed": z.boolean(),
48
+ "general.analytics": z.boolean(),
49
+ "general.openAtLogin": z.boolean(),
50
+ "general.talkShortcut": z.object({ enabled: z.boolean(), key: z.enum(TALK_KEYS) }).strict(),
51
+ "account.productEmails": z.boolean(),
52
+ "remote.wifi": z.boolean(),
53
+ "remote.relay": z.boolean(),
54
+ "remote.tailscale": z.boolean(),
55
+ "remote.keepAwake": z.boolean(),
56
+ };
57
+ export const WINDOW_PREF_IDS = Object.keys(WINDOW_PREFS);
58
+ export const isWindowPrefId = (id) => Object.hasOwn(WINDOW_PREFS, id);
59
+ /** What the window reports as its current values (PUT /api/window-prefs). */
60
+ export const windowPrefReportSchema = z.object({ values: z.record(z.string(), z.unknown()) }).strict();
@@ -3,6 +3,8 @@
3
3
  export const BOT_LIMIT_CODE = "bot_limit";
4
4
  /** The code on a turn refused because its bot is paused: a Starter Cloud keeps only so many bots awake. */
5
5
  export const BOT_PAUSED_CODE = "bot_paused";
6
+ /** The code on a turn refused because the person paused its bot, or its department (Pause in the sidebar menus). */
7
+ export const BOT_HELD_CODE = "bot_held";
6
8
  /** The bots a plan's awake limit counts. A place's MausBot comes with it; an archived bot or one that moved away isn't at work here. */
7
9
  export function botsTowardLimit(bots) {
8
10
  return bots.filter((bot) => !bot.defaultBot && !bot.hidden && !bot.movedTo).length;
@@ -29,8 +29,9 @@ export function plainPreviewText(text) {
29
29
  out = out.replace(/^[ \t]{0,3}(?:[-*_][ \t]*){3,}$/gm, "");
30
30
  out = out.replace(/^[ \t]*\|(.*)\|[ \t]*$/gm, (_row, cells) => cells.split("|").map((cell) => cell.trim()).filter(Boolean).join(" "));
31
31
  // Underscores inside a word (snake_case) and a lone * (2 * 3) are not emphasis.
32
- out = out.replace(/(\*{1,3}|_{1,3})(?=\S)([\s\S]*?\S)\1(?![\p{L}\p{N}])/gu, (match, marks, inner, offset, whole) => {
33
- if (marks[0] === "_" && offset > 0 && /[\p{L}\p{N}]/u.test(whole[offset - 1]))
32
+ out = out.replace(/(\*{1,3})(?=\S)([\s\S]*?\S)\1/gu, "$2");
33
+ out = out.replace(/(_{1,3})(?=\S)([\s\S]*?\S)\1(?![\p{L}\p{N}])/gu, (match, _marks, inner, offset, whole) => {
34
+ if (/[\p{L}\p{N}]$/u.test(whole.slice(0, offset)))
34
35
  return match;
35
36
  return inner;
36
37
  });