fnloom 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (705) hide show
  1. package/README.md +133 -23
  2. package/package.json +13 -17
  3. package/packages/build/package.json +2 -2
  4. package/packages/cli/package.json +1 -1
  5. package/packages/cli/src/cli.ts +2 -1
  6. package/packages/cli/src/command.ts +2 -0
  7. package/packages/cli/src/commands/available.ts +63 -22
  8. package/packages/cli/src/commands/install.ts +182 -28
  9. package/packages/cli/src/commands/manage.ts +7 -5
  10. package/packages/cli/src/commands/store.ts +172 -0
  11. package/packages/cli/src/hub.ts +26 -7
  12. package/packages/cli/src/index.ts +3 -2
  13. package/packages/cli/src/io.ts +1 -0
  14. package/packages/cli/src/local.ts +6 -0
  15. package/packages/cli/src/premade.ts +80 -0
  16. package/packages/cli/src/testing.ts +2 -1
  17. package/packages/core/package.json +4 -4
  18. package/packages/core/src/context-files.ts +3 -1
  19. package/packages/core/src/context-graph.ts +4 -0
  20. package/packages/core/src/context-plan.ts +451 -0
  21. package/packages/core/src/context-questions.ts +305 -0
  22. package/packages/core/src/fn-facts.ts +32 -4
  23. package/packages/core/src/identity.ts +1 -1
  24. package/packages/core/src/index.ts +4 -1
  25. package/packages/core/src/link.ts +70 -0
  26. package/packages/core/src/manifest.ts +20 -1
  27. package/packages/core/src/model-calls.ts +11 -2
  28. package/packages/core/src/package.ts +10 -0
  29. package/packages/core/src/query.ts +3 -2
  30. package/packages/core/src/records/content.ts +10 -2
  31. package/packages/core/src/records/runs.ts +12 -0
  32. package/packages/core/src/records/systems.ts +87 -5
  33. package/packages/core/src/run.ts +5 -0
  34. package/packages/core/src/stores.ts +473 -0
  35. package/packages/core/src/suggestions.ts +3 -0
  36. package/packages/core/src/system-pages.ts +14 -1
  37. package/packages/core/src/web.ts +114 -9
  38. package/packages/hub/package.json +13 -12
  39. package/packages/hub/src/access/hits.ts +1 -1
  40. package/packages/hub/src/api/admin-ops.ts +36 -4
  41. package/packages/hub/src/api/auth.ts +8 -4
  42. package/packages/hub/src/api/person-ops.ts +6 -0
  43. package/packages/hub/src/api/store-ops.ts +54 -0
  44. package/packages/hub/src/api/testing/rig.ts +2 -2
  45. package/packages/hub/src/api/tls.ts +2 -2
  46. package/packages/hub/src/api/web/build5.ts +2 -1
  47. package/packages/hub/src/api/web/context-plans.ts +25 -0
  48. package/packages/hub/src/api/web/context-review.ts +43 -0
  49. package/packages/hub/src/api/web/index.ts +4 -0
  50. package/packages/hub/src/api/web/pages.ts +14 -1
  51. package/packages/hub/src/api/web/review.ts +16 -0
  52. package/packages/hub/src/api/web/systems.ts +14 -2
  53. package/packages/hub/src/boot/admin-fns.ts +8 -0
  54. package/packages/hub/src/boot/admin-secrets.ts +10 -4
  55. package/packages/hub/src/boot/env.ts +6 -1
  56. package/packages/hub/src/boot/hub-fns.ts +3 -3
  57. package/packages/hub/src/boot/hub-groups.ts +2 -2
  58. package/packages/hub/src/boot/identity.ts +1 -1
  59. package/packages/hub/src/boot/index.ts +9 -0
  60. package/packages/hub/src/boot/modules.ts +12 -3
  61. package/packages/hub/src/boot/person-fns.ts +5 -0
  62. package/packages/hub/src/boot/plan-fns.ts +39 -0
  63. package/packages/hub/src/boot/start.ts +2 -1
  64. package/packages/hub/src/catalog/catalog.ts +44 -14
  65. package/packages/hub/src/catalog/index.ts +6 -2
  66. package/packages/hub/src/chat/testing.ts +2 -2
  67. package/packages/hub/src/contextor/brought.ts +5 -3
  68. package/packages/hub/src/contextor/testing.ts +4 -4
  69. package/packages/hub/src/execution/create.ts +2 -0
  70. package/packages/hub/src/execution/env.ts +2 -0
  71. package/packages/hub/src/execution/errors.ts +12 -0
  72. package/packages/hub/src/execution/executors.ts +14 -2
  73. package/packages/hub/src/execution/index.ts +8 -0
  74. package/packages/hub/src/execution/link-handlers.ts +16 -4
  75. package/packages/hub/src/execution/runs.ts +212 -11
  76. package/packages/hub/src/execution/testing.ts +2 -1
  77. package/packages/hub/src/fns/search.ts +23 -4
  78. package/packages/hub/src/graph/graph.ts +2 -2
  79. package/packages/hub/src/index/index.ts +9 -2
  80. package/packages/hub/src/index/indexer.ts +67 -16
  81. package/packages/hub/src/index/search.ts +1 -0
  82. package/packages/hub/src/index/suggester.ts +2 -2
  83. package/packages/hub/src/link/build.ts +47 -10
  84. package/packages/hub/src/link/connections.ts +41 -3
  85. package/packages/hub/src/link/describer.ts +19 -2
  86. package/packages/hub/src/link/env.ts +10 -0
  87. package/packages/hub/src/link/handlers.ts +6 -0
  88. package/packages/hub/src/link/index.ts +16 -4
  89. package/packages/hub/src/link/lifecycle.ts +11 -4
  90. package/packages/hub/src/link/packages.ts +17 -4
  91. package/packages/hub/src/link/pairing.ts +2 -2
  92. package/packages/hub/src/link/process.ts +15 -4
  93. package/packages/hub/src/link/rig.ts +6 -2
  94. package/packages/hub/src/link/status.ts +14 -0
  95. package/packages/hub/src/link/supervisor.ts +17 -1
  96. package/packages/hub/src/link/systems.ts +16 -5
  97. package/packages/hub/src/models/roles.ts +74 -7
  98. package/packages/hub/src/query/columns.ts +4 -1
  99. package/packages/hub/src/query/contexts.ts +10 -3
  100. package/packages/hub/src/questions/apply.ts +163 -0
  101. package/packages/hub/src/questions/carry.ts +30 -0
  102. package/packages/hub/src/questions/duplicates.ts +181 -0
  103. package/packages/hub/src/questions/index.ts +112 -0
  104. package/packages/hub/src/questions/metadata.ts +142 -0
  105. package/packages/hub/src/questions/pending.ts +64 -0
  106. package/packages/hub/src/questions/plan-match.ts +79 -0
  107. package/packages/hub/src/questions/plan-prompts.ts +110 -0
  108. package/packages/hub/src/questions/planner.ts +382 -0
  109. package/packages/hub/src/questions/plans.ts +353 -0
  110. package/packages/hub/src/questions/review.ts +253 -0
  111. package/packages/hub/src/questions/setting.ts +50 -0
  112. package/packages/hub/src/questions/testing.ts +131 -0
  113. package/packages/hub/src/questions/worker.ts +182 -0
  114. package/packages/hub/src/resources/context.ts +58 -20
  115. package/packages/hub/src/resources/create.ts +16 -4
  116. package/packages/hub/src/resources/env.ts +4 -0
  117. package/packages/hub/src/resources/fns.ts +6 -2
  118. package/packages/hub/src/resources/index.ts +8 -2
  119. package/packages/hub/src/resources/testing.ts +18 -2
  120. package/packages/hub/src/store/codec.ts +23 -5
  121. package/packages/hub/src/store/context-status.ts +56 -0
  122. package/packages/hub/src/store/derived.ts +53 -0
  123. package/packages/hub/src/store/hybrid.ts +33 -6
  124. package/packages/hub/src/store/lists.ts +2 -1
  125. package/packages/hub/src/store/migrate-fn-names.ts +5 -2
  126. package/packages/hub/src/store/rows.ts +8 -1
  127. package/packages/hub/src/store/schema.ts +2 -1
  128. package/packages/hub/src/store/sqlite.ts +2 -1
  129. package/packages/hub/src/stores/backups.ts +163 -0
  130. package/packages/hub/src/stores/drivers.ts +100 -0
  131. package/packages/hub/src/stores/guard.ts +116 -0
  132. package/packages/hub/src/stores/host.ts +459 -0
  133. package/packages/hub/src/stores/moves.ts +380 -0
  134. package/packages/hub/src/stores/plugin.ts +42 -0
  135. package/packages/hub/src/stores/service.ts +340 -0
  136. package/packages/hub/src/stores/testing.ts +149 -0
  137. package/packages/sdk/AUTHORING.md +1813 -218
  138. package/packages/sdk/package.json +12 -8
  139. package/packages/sdk/src/build.ts +3 -0
  140. package/packages/sdk/src/client.ts +22 -0
  141. package/packages/sdk/src/ctx.ts +51 -17
  142. package/packages/sdk/src/declare.ts +36 -12
  143. package/packages/sdk/src/hub.ts +222 -10
  144. package/packages/sdk/src/impl.ts +3 -3
  145. package/packages/sdk/src/index.ts +6 -3
  146. package/packages/sdk/src/manifest.ts +5 -0
  147. package/packages/sdk/src/providers.ts +2 -2
  148. package/packages/sdk/src/server/asks.ts +12 -1
  149. package/packages/sdk/src/server/env.ts +13 -1
  150. package/packages/sdk/src/server/host.ts +81 -10
  151. package/packages/sdk/src/server/index.ts +21 -2
  152. package/packages/sdk/src/server/package.ts +11 -2
  153. package/packages/sdk/src/server/run.ts +6 -1
  154. package/packages/sdk/src/server/runtime.ts +78 -22
  155. package/packages/sdk/src/server/start-gate.ts +174 -0
  156. package/packages/sdk/src/server/store/checksum.ts +162 -0
  157. package/packages/sdk/src/server/store/engines.ts +400 -0
  158. package/packages/sdk/src/server/store/extend.ts +25 -0
  159. package/packages/sdk/src/server/store/keeper.ts +392 -0
  160. package/packages/sdk/src/server/store/link-driver.ts +142 -0
  161. package/packages/sdk/src/server/store/measure.ts +45 -0
  162. package/packages/sdk/src/server/store/migrations.ts +238 -0
  163. package/packages/sdk/src/server/store/move.ts +488 -0
  164. package/packages/sdk/src/server/store/portable.ts +288 -0
  165. package/packages/sdk/src/server/store/stable.ts +146 -0
  166. package/packages/sdk/src/server/store/tables.ts +28 -0
  167. package/packages/sdk/src/server/store/vectors.ts +185 -0
  168. package/packages/sdk/src/server/store/work-checks.ts +288 -0
  169. package/packages/sdk/src/server/store/work.ts +369 -0
  170. package/packages/sdk/src/server/table.ts +3 -1
  171. package/packages/sdk/src/server/testing.ts +116 -3
  172. package/packages/sdk/src/store.ts +91 -0
  173. package/packages/sdk/src/system.ts +58 -30
  174. package/packages/sdk/src/testing/hub.ts +18 -5
  175. package/packages/web/dist/assets/{ActorSettingsView-BuMYRDqv.js → ActorSettingsView-v2k7v454.js} +2 -2
  176. package/packages/web/dist/assets/{AdminLayout-sLjVTrmV.js → AdminLayout-B6Jrc_4W.js} +2 -2
  177. package/packages/web/dist/assets/{ApiServiceForm-BrMTU-7u.js → ApiServiceForm-CuuQgOJc.js} +2 -2
  178. package/packages/web/dist/assets/{ApiServiceView-BMF2zD6Q.js → ApiServiceView-7bTHSO_Z.js} +2 -2
  179. package/packages/web/dist/assets/{ApiServicesView-bjLAWO_j.js → ApiServicesView-BXi24n49.js} +2 -2
  180. package/packages/web/dist/assets/{AppPage-DSzDKCFz.js → AppPage-CFmKZS8G.js} +2 -2
  181. package/packages/web/dist/assets/{AutoPairPicker-nV38ALjl.js → AutoPairPicker-C61gihmh.js} +2 -2
  182. package/packages/web/dist/assets/{BrowserFrame-Bic7U7jN.js → BrowserFrame-Sq9EmQRT.js} +2 -2
  183. package/packages/web/dist/assets/{ChartVisual-DWw7WsfN.js → ChartVisual-C4mgw4wh.js} +4 -4
  184. package/packages/web/dist/assets/ChatPage-CAhHE03Z.js +4 -0
  185. package/packages/web/dist/assets/{CodeViewer-xHS3Xah9.js → CodeViewer-tUNXZB77.js} +2 -2
  186. package/packages/web/dist/assets/{ConfigWithCustom-DreTUdf0.js → ConfigWithCustom-D_-rY66L.js} +3 -3
  187. package/packages/web/dist/assets/{ConfirmDialog-DjQUzNqk.js → ConfirmDialog-Dd3E4sJt.js} +2 -2
  188. package/packages/web/dist/assets/{ConnectPage-CfRDrXvJ.js → ConnectPage-CX9acyQH.js} +2 -2
  189. package/packages/web/dist/assets/ContextItemPage-Cv4G0k_o.css +1 -0
  190. package/packages/web/dist/assets/ContextItemPage-rUI3-T_L.js +2 -0
  191. package/packages/web/dist/assets/ContextPage-C8u0UnYl.css +1 -0
  192. package/packages/web/dist/assets/ContextPage-CtefzyKg.js +3 -0
  193. package/packages/web/dist/assets/ContextRow-Chx99Xac.css +1 -0
  194. package/packages/web/dist/assets/ContextRow-DrtPumZ5.js +2 -0
  195. package/packages/web/dist/assets/{DataPage-wSIoGcb5.js → DataPage-DDSsxHro.js} +2 -2
  196. package/packages/web/dist/assets/DataTypePage-BW9fWaz8.js +2 -0
  197. package/packages/web/dist/assets/{DesignPage-DidMUX8m.js → DesignPage-6e0XbOFC.js} +2 -2
  198. package/packages/web/dist/assets/{ExplorePage-MUyVydVB.js → ExplorePage-B7ND0W0l.js} +2 -2
  199. package/packages/web/dist/assets/{FnList-CjQRwYaT.js → FnList-Bx6H-kux.js} +2 -2
  200. package/packages/web/dist/assets/{FnPill-BshAvm2I.js → FnPill-Cp3KuLmP.js} +2 -2
  201. package/packages/web/dist/assets/FnView-C0XZdnsS.js +2 -0
  202. package/packages/web/dist/assets/{FnsView-CeqIoaBT.js → FnsView-GTH3p7a0.js} +2 -2
  203. package/packages/web/dist/assets/{GinExprView-DYVUwZrd.js → GinExprView-DGxns6lH.js} +2 -2
  204. package/packages/web/dist/assets/{GinForm-D3mwMRTQ.js → GinForm-BDBUzuDP.js} +2 -2
  205. package/packages/web/dist/assets/{GinTypeView-C0YifSmE.js → GinTypeView-CUsymbVf.js} +2 -2
  206. package/packages/web/dist/assets/{GinValueView-HfEPq9le.js → GinValueView-jsKIfiEA.js} +2 -2
  207. package/packages/web/dist/assets/{GraphPage-ySnuA4Hp.js → GraphPage-BCcPPsHu.js} +2 -2
  208. package/packages/web/dist/assets/{GraphPanel-Cy5-KGo1.js → GraphPanel-9tztGHmu.js} +2 -2
  209. package/packages/web/dist/assets/{HubPicker-C_vA752L.js → HubPicker-EoOErgmk.js} +2 -2
  210. package/packages/web/dist/assets/{InboxApprovals-DcPCCmZ5.js → InboxApprovals-Dkq7DFp_.js} +2 -2
  211. package/packages/web/dist/assets/{InboxPage-C2DT2nuF.js → InboxPage-CHhslePq.js} +2 -2
  212. package/packages/web/dist/assets/{InjectedList-CJsEFEbz.js → InjectedList-CSWqRiON.js} +2 -2
  213. package/packages/web/dist/assets/InstallDialog-D-VwfZYF.js +2 -0
  214. package/packages/web/dist/assets/{InstallDialog-yWLZK_zN.css → InstallDialog-K-j0sdHm.css} +1 -1
  215. package/packages/web/dist/assets/InstanceTypes-CwVSAULg.css +1 -0
  216. package/packages/web/dist/assets/InstanceTypes-D3rAEiE7.js +2 -0
  217. package/packages/web/dist/assets/InstanceView-DoH8C-1j.js +2 -0
  218. package/packages/web/dist/assets/InstanceView-_9uE70tS.css +1 -0
  219. package/packages/web/dist/assets/{ItemHistory-CUGa8b6s.js → ItemHistory-NQAP69ma.js} +2 -2
  220. package/packages/web/dist/assets/LimitsView-DY2C9nYS.js +2 -0
  221. package/packages/web/dist/assets/ListSearch-BunVrDO0.js +2 -0
  222. package/packages/web/dist/assets/{LlmCallDetails-2yQftCqd.js → LlmCallDetails-BoVNDTVs.js} +2 -2
  223. package/packages/web/dist/assets/{LlmCallsView-DOHX3r0K.js → LlmCallsView-BGpV92RC.js} +2 -2
  224. package/packages/web/dist/assets/{LoadState-DeXfLvYv.js → LoadState-h-K9bTYc.js} +2 -2
  225. package/packages/web/dist/assets/{McpDialog-CA_0WKWF.js → McpDialog-DhOCk6_E.js} +2 -2
  226. package/packages/web/dist/assets/{McpServerForm-CAG8Wp2N.js → McpServerForm-Cor3fI7s.js} +2 -2
  227. package/packages/web/dist/assets/McpServerView-ewXRPEmZ.js +2 -0
  228. package/packages/web/dist/assets/McpServersView-Dd0xmfws.js +2 -0
  229. package/packages/web/dist/assets/{McpView-CC2oNOMa.js → McpView-GPXdCMne.js} +2 -2
  230. package/packages/web/dist/assets/{McpsView-CwJvyyxV.js → McpsView-DJIR2JX5.js} +2 -2
  231. package/packages/web/dist/assets/{MemoryDialog-Dbvh5uLq.js → MemoryDialog-BTeIHQyA.js} +2 -2
  232. package/packages/web/dist/assets/{ModelCallsView-RvnW3EBP.js → ModelCallsView-DMcnwF2S.js} +2 -2
  233. package/packages/web/dist/assets/{ModelPicker-DcjwQFHC.js → ModelPicker-CgkMFxSO.js} +2 -2
  234. package/packages/web/dist/assets/ModelsView-cMHygeiK.js +2 -0
  235. package/packages/web/dist/assets/{NotFoundPage-CeSwzTV-.js → NotFoundPage-Tk92K7HN.js} +2 -2
  236. package/packages/web/dist/assets/PairPage-D0BK8CCw.js +2 -0
  237. package/packages/web/dist/assets/PairPage-D_aPS1Ot.css +1 -0
  238. package/packages/web/dist/assets/{PanelHost-BkrFAnPa.js → PanelHost-C-gKrxAk.js} +2 -2
  239. package/packages/web/dist/assets/{PeopleView-D1QGPYp7.js → PeopleView-DRfeNWK5.js} +2 -2
  240. package/packages/web/dist/assets/PoliciesView-BRi-QAuo.js +2 -0
  241. package/packages/web/dist/assets/{RefusalList-DQoyUoPG.js → RefusalList-DVO0bmeB.js} +2 -2
  242. package/packages/web/dist/assets/{RemoteAuthFields-nxGWfmhf.js → RemoteAuthFields-CgiufuqQ.js} +2 -2
  243. package/packages/web/dist/assets/{ResourceViewer-Po24y4pj.js → ResourceViewer-Do0chYxU.js} +2 -2
  244. package/packages/web/dist/assets/ResourcesPage-BBx2u2mw.js +2 -0
  245. package/packages/web/dist/assets/{ResultGrid-uoq4yUYj.js → ResultGrid-Bj-0I5HY.js} +2 -2
  246. package/packages/web/dist/assets/{ReviewSummaryStrip-k3HevESg.js → ReviewSummaryStrip-DO3p64Qj.js} +2 -2
  247. package/packages/web/dist/assets/ReviewView-DZF9E1hb.js +3 -0
  248. package/packages/web/dist/assets/{RuleRow-CoXDA-SH.js → RuleRow-DX9v4iGP.js} +2 -2
  249. package/packages/web/dist/assets/{RunCard-CBSGdwdQ.js → RunCard-BnrtK2Yp.js} +2 -2
  250. package/packages/web/dist/assets/{RunDetails-CGhQQ6OI.js → RunDetails-DjR206q6.js} +2 -2
  251. package/packages/web/dist/assets/{RunDot-Ch_45985.js → RunDot-lHRICdM5.js} +2 -2
  252. package/packages/web/dist/assets/{RunPage-C_t20pB7.js → RunPage-CbAQ_WPR.js} +2 -2
  253. package/packages/web/dist/assets/{RunProgress-VrZUHUEC.js → RunProgress-C3-B4tQf.js} +2 -2
  254. package/packages/web/dist/assets/RunsView-DMkPmkqX.js +2 -0
  255. package/packages/web/dist/assets/ServiceRows-4WythFpF.js +2 -0
  256. package/packages/web/dist/assets/{ServiceRows-6BU4-MeL.css → ServiceRows-HPQ0pN6b.css} +1 -1
  257. package/packages/web/dist/assets/SettingsPage-BN4oSzoL.js +3 -0
  258. package/packages/web/dist/assets/{SignInPage-DrXZ1sG2.js → SignInPage-ByqGEZfj.js} +2 -2
  259. package/packages/web/dist/assets/{StatusBadge-Dpb9uG5e.js → StatusBadge-CXne0sRZ.js} +2 -2
  260. package/packages/web/dist/assets/StorePlacementStep-B6SwTmdM.js +2 -0
  261. package/packages/web/dist/assets/StorePlacementStep-D_G4e3ue.css +1 -0
  262. package/packages/web/dist/assets/{SystemConfig-72qKRkUk.js → SystemConfig-vQDL_eUl.js} +2 -2
  263. package/packages/web/dist/assets/{SystemPageHost-DLNg2FYK.js → SystemPageHost-DrMrEPyh.js} +2 -2
  264. package/packages/web/dist/assets/SystemView-Be6TBM4j.js +2 -0
  265. package/packages/web/dist/assets/{SystemView-C8ScHUe2.css → SystemView-_9q6eDfV.css} +1 -1
  266. package/packages/web/dist/assets/{SystemsView-B6HEL9VS.css → SystemsView-CWKnupLW.css} +1 -1
  267. package/packages/web/dist/assets/SystemsView-DZtT3laz.js +2 -0
  268. package/packages/web/dist/assets/{TableViewer-BQ7bYLOP.js → TableViewer-Boxx86f5.js} +3 -3
  269. package/packages/web/dist/assets/{ThemePicker-C2nJ21Vd.js → ThemePicker-CIg_oRQX.js} +2 -2
  270. package/packages/web/dist/assets/{TurnTree-CORdfTHj.js → TurnTree-Ecm0yA5g.js} +2 -2
  271. package/packages/web/dist/assets/UserMessage-BlnqZDVU.js +9 -0
  272. package/packages/web/dist/assets/{ValueVisual-aXEUaQ5Y.js → ValueVisual-C-MWpp7c.js} +2 -2
  273. package/packages/web/dist/assets/WidgetView-DX4ejNb6.js +3 -0
  274. package/packages/web/dist/assets/actor-names-OdvpVZeb.js +4 -0
  275. package/packages/web/dist/assets/{fn-modal-DqcxUhOQ.js → fn-modal-B98MR7JN.js} +2 -2
  276. package/packages/web/dist/assets/{fn-notices-BYaH6IoA.js → fn-notices-CfTa1E8y.js} +2 -2
  277. package/packages/web/dist/assets/{formats-DI__ADVG.js → formats-JwoKfXIq.js} +2 -2
  278. package/packages/web/dist/assets/index-6ScWTFy2.js +4 -0
  279. package/packages/web/dist/assets/{index-CSisx5mi.css → index-CEslGcrX.css} +1 -1
  280. package/packages/web/dist/assets/{labels-BhJpmLWA.js → labels-BFbk11BE.js} +2 -2
  281. package/packages/web/dist/assets/{layout-DQKldU13.js → layout-D1gf481r.js} +2 -2
  282. package/packages/web/dist/assets/{metrics-Cio5ykX6.js → metrics-CBPX3W5Y.js} +2 -2
  283. package/packages/web/dist/assets/{problems-BZY0Dwif.js → problems-t1E_ovSz.js} +2 -2
  284. package/packages/web/dist/assets/{push-payload-D5efGCzd.js → push-payload-BeU1ADYt.js} +64 -64
  285. package/packages/web/dist/assets/{record-edits-CveFEsal.js → record-edits-Bfsi4lU3.js} +2 -2
  286. package/packages/web/dist/assets/{remote-config-BkaarDf3.js → remote-config-BNQhSDzB.js} +2 -2
  287. package/packages/web/dist/assets/{review-CGUGvRV9.js → review-fP-l9D6H.js} +3 -3
  288. package/packages/web/dist/assets/routes-DV4IJpwe.js +4 -0
  289. package/packages/web/dist/assets/runs-CveC2kKo.js +2 -0
  290. package/packages/web/dist/assets/{shared-DTpYDMc_.js → shared-LbaIHjbV.js} +2 -2
  291. package/packages/web/dist/assets/{size-BwnshyOe.js → size-Bh__w5aI.js} +2 -2
  292. package/packages/web/dist/assets/{sources-Bm-TrxhL.js → sources-VPrtgLIi.js} +2 -2
  293. package/packages/web/dist/assets/src-CT3TeFaM.js +43 -0
  294. package/packages/web/dist/assets/state-xfQqaQPX.js +2 -0
  295. package/packages/web/dist/assets/{systems-DIp94AET.js → systems-BqE3WTSF.js} +2 -2
  296. package/packages/web/dist/assets/ui-BzgWquIU.js +17 -0
  297. package/packages/web/dist/assets/{ui-C7ZH_6oC.css → ui-DycHjPTZ.css} +1 -1
  298. package/packages/web/dist/assets/{url-BIg5IhGs.js → url-DKGcECT1.js} +2 -2
  299. package/packages/web/dist/assets/{widget-host-BCf6Tlt5.js → widget-host-B87MTaTn.js} +2 -2
  300. package/packages/web/dist/assets/{widgets-CrbkovMT.js → widgets-BBCuSS6E.js} +2 -2
  301. package/packages/web/dist/index.html +44 -44
  302. package/packages/web/dist/sw.js +1 -1
  303. package/packages/web/package.json +2 -2
  304. package/premade/claude.zip +0 -0
  305. package/premade/database.zip +0 -0
  306. package/premade/web.zip +0 -0
  307. package/scripts/dev-env.ts +4 -4
  308. package/scripts/run-stack.ts +3 -2
  309. package/scripts/stack.ts +115 -43
  310. package/scripts/start.ts +36 -17
  311. package/systems/api/package.json +3 -3
  312. package/systems/code/package.json +3 -3
  313. package/systems/embedder/package.json +1 -1
  314. package/systems/fs/client/fakes.ts +2 -0
  315. package/systems/fs/client/index.ts +4 -2
  316. package/systems/fs/client/machines/CoreHeatmap.vue +94 -0
  317. package/systems/fs/client/machines/MachineFiles.vue +121 -0
  318. package/systems/fs/client/machines/MachineMetrics.vue +330 -0
  319. package/systems/fs/client/machines/MachinesPage.vue +119 -0
  320. package/systems/fs/client/machines/TimeChart.vue +128 -0
  321. package/systems/fs/client/machines/fakes.ts +95 -0
  322. package/systems/fs/client/machines/files/ChangesPane.vue +90 -0
  323. package/systems/fs/client/machines/files/CodeView.vue +158 -0
  324. package/systems/fs/client/machines/files/CommentComposer.vue +86 -0
  325. package/systems/fs/client/machines/files/CommentThread.vue +115 -0
  326. package/systems/fs/client/machines/files/CommitPane.vue +80 -0
  327. package/systems/fs/client/machines/files/ComparePane.vue +81 -0
  328. package/systems/fs/client/machines/files/FileHistory.vue +89 -0
  329. package/systems/fs/client/machines/files/FilePane.vue +199 -0
  330. package/systems/fs/client/machines/files/FileTree.vue +26 -0
  331. package/systems/fs/client/machines/files/FolderPane.vue +154 -0
  332. package/systems/fs/client/machines/files/HistoryPane.vue +106 -0
  333. package/systems/fs/client/machines/files/ImageView.vue +160 -0
  334. package/systems/fs/client/machines/files/PatchView.vue +31 -0
  335. package/systems/fs/client/machines/files/QuickOpen.vue +67 -0
  336. package/systems/fs/client/machines/files/SearchPane.vue +87 -0
  337. package/systems/fs/client/machines/files/TreeNode.vue +72 -0
  338. package/systems/fs/client/machines/files/api.ts +127 -0
  339. package/systems/fs/client/machines/files/fake-kinds.ts +16 -0
  340. package/systems/fs/client/machines/files/fakes.ts +305 -0
  341. package/systems/fs/client/machines/files/ink.ts +117 -0
  342. package/systems/fs/client/machines/files/logic.ts +205 -0
  343. package/systems/fs/client/machines/files/state.ts +187 -0
  344. package/systems/fs/client/machines/files/viewers/CsvView.vue +29 -0
  345. package/systems/fs/client/machines/files/viewers/HexView.vue +27 -0
  346. package/systems/fs/client/machines/files/viewers/HtmlView.vue +17 -0
  347. package/systems/fs/client/machines/files/viewers/JsonNode.vue +45 -0
  348. package/systems/fs/client/machines/files/viewers/JsonView.vue +25 -0
  349. package/systems/fs/client/machines/metrics.ts +245 -0
  350. package/systems/fs/client/machines/palette.ts +97 -0
  351. package/systems/fs/client/preview/machines.ts +323 -0
  352. package/systems/fs/context/authoring/index.md +4 -0
  353. package/systems/fs/context/authoring/parts/actions.md +5 -1
  354. package/systems/fs/context/authoring/parts/actions.reference.md +6 -2
  355. package/systems/fs/context/authoring/parts/calling.md +5 -1
  356. package/systems/fs/context/authoring/parts/calling.reference.md +4 -0
  357. package/systems/fs/context/authoring/parts/client.md +9 -1
  358. package/systems/fs/context/authoring/parts/client.reference/client.md +4 -0
  359. package/systems/fs/context/authoring/parts/client.reference/resultview.md +56 -53
  360. package/systems/fs/context/authoring/parts/client.reference/{fnpillprops.md → textareaprops.md} +58 -4
  361. package/systems/fs/context/authoring/parts/client.reference.md +8 -4
  362. package/systems/fs/context/authoring/parts/context/questions.md +49 -0
  363. package/systems/fs/context/authoring/parts/context.md +23 -1
  364. package/systems/fs/context/authoring/parts/context.reference.md +27 -3
  365. package/systems/fs/context/authoring/parts/contract.md +10 -0
  366. package/systems/fs/context/authoring/parts/contract.reference.md +26 -9
  367. package/systems/fs/context/authoring/parts/core-types/access-ts.md +4 -0
  368. package/systems/fs/context/authoring/parts/core-types/admin-ts.md +5 -1
  369. package/systems/fs/context/authoring/parts/core-types/api-index-ts.md +4 -0
  370. package/systems/fs/context/authoring/parts/core-types/approvals-ts.md +11 -7
  371. package/systems/fs/context/authoring/parts/core-types/auto-pair-ts.md +4 -0
  372. package/systems/fs/context/authoring/parts/core-types/checks-ts.md +4 -0
  373. package/systems/fs/context/authoring/parts/core-types/claims-ts.md +4 -0
  374. package/systems/fs/context/authoring/parts/core-types/config-secrets-ts.md +4 -0
  375. package/systems/fs/context/authoring/parts/core-types/connections-ts.md +4 -0
  376. package/systems/fs/context/authoring/parts/core-types/context-files-ts.md +8 -0
  377. package/systems/fs/context/authoring/parts/core-types/context-graph-ts.md +5 -1
  378. package/systems/fs/context/authoring/parts/core-types/context-questions-ts.md +26 -0
  379. package/systems/fs/context/authoring/parts/core-types/contextdecl.md +9 -1
  380. package/systems/fs/context/authoring/parts/core-types/data-ts.md +4 -0
  381. package/systems/fs/context/authoring/parts/core-types/decisions-ts.md +4 -0
  382. package/systems/fs/context/authoring/parts/core-types/fn-block-ts.md +4 -0
  383. package/systems/fs/context/authoring/parts/core-types/fn-facts-ts.md +11 -0
  384. package/systems/fs/context/authoring/parts/core-types/gin-ts.md +4 -0
  385. package/systems/fs/context/authoring/parts/core-types/grants-ts.md +5 -1
  386. package/systems/fs/context/authoring/parts/core-types/lifecycle-ts.md +18 -5
  387. package/systems/fs/context/authoring/parts/core-types/link-ts.md +7 -3
  388. package/systems/fs/context/authoring/parts/core-types/llm-ts.md +4 -0
  389. package/systems/fs/context/authoring/parts/core-types/manifest.md +15 -2
  390. package/systems/fs/context/authoring/parts/core-types/manifestpatch.md +9 -1
  391. package/systems/fs/context/authoring/parts/core-types/mention-search-ts.md +4 -0
  392. package/systems/fs/context/authoring/parts/core-types/model-calls-ts.md +5 -1
  393. package/systems/fs/context/authoring/parts/core-types/model-names-ts.md +4 -0
  394. package/systems/fs/context/authoring/parts/core-types/modes-ts.md +4 -0
  395. package/systems/fs/context/authoring/parts/core-types/owner-runs-ts.md +4 -0
  396. package/systems/fs/context/authoring/parts/core-types/package-ts.md +9 -0
  397. package/systems/fs/context/authoring/parts/core-types/primitives-ts.md +4 -0
  398. package/systems/fs/context/authoring/parts/core-types/query-ts.md +4 -0
  399. package/systems/fs/context/authoring/parts/core-types/records-actors-ts.md +7 -3
  400. package/systems/fs/context/authoring/parts/core-types/records-chat-ts.md +4 -0
  401. package/systems/fs/context/authoring/parts/core-types/records-content-ts.md +4 -0
  402. package/systems/fs/context/authoring/parts/core-types/records-runs-ts.md +4 -0
  403. package/systems/fs/context/authoring/parts/core-types/records-systems-ts.md +4 -0
  404. package/systems/fs/context/authoring/parts/core-types/registries-ts.md +4 -0
  405. package/systems/fs/context/authoring/parts/core-types/remote-auth-ts.md +4 -0
  406. package/systems/fs/context/authoring/parts/core-types/resources-ts.md +5 -1
  407. package/systems/fs/context/authoring/parts/core-types/run-ts.md +7 -0
  408. package/systems/fs/context/authoring/parts/core-types/sensitivity-ts.md +5 -1
  409. package/systems/fs/context/authoring/parts/core-types/stores-ts.md +199 -0
  410. package/systems/fs/context/authoring/parts/core-types/system-events-ts.md +8 -1
  411. package/systems/fs/context/authoring/parts/core-types/system-pages-ts.md +4 -0
  412. package/systems/fs/context/authoring/parts/core-types/system-providers-ts.md +4 -0
  413. package/systems/fs/context/authoring/parts/core-types/validation-ts.md +4 -0
  414. package/systems/fs/context/authoring/parts/core-types/visuals-ts.md +4 -0
  415. package/systems/fs/context/authoring/parts/core-types/web-ts.md +4 -0
  416. package/systems/fs/context/authoring/parts/core-types/widgets-ts.md +4 -0
  417. package/systems/fs/context/authoring/parts/core-types.md +12 -2
  418. package/systems/fs/context/authoring/parts/ctx/update-result.md +33 -0
  419. package/systems/fs/context/authoring/parts/ctx.md +11 -1
  420. package/systems/fs/context/authoring/parts/ctx.reference/{hubai.md → adminnotices.md} +45 -4
  421. package/systems/fs/context/authoring/parts/ctx.reference/fnctx.md +21 -23
  422. package/systems/fs/context/authoring/parts/ctx.reference.md +8 -4
  423. package/systems/fs/context/authoring/parts/data.md +11 -6
  424. package/systems/fs/context/authoring/parts/data.reference.md +4 -0
  425. package/systems/fs/context/authoring/parts/examples/client-findview-vue.md +4 -0
  426. package/systems/fs/context/authoring/parts/examples/client-index-ts.md +4 -0
  427. package/systems/fs/context/authoring/parts/examples/client-notecard-vue.md +4 -0
  428. package/systems/fs/context/authoring/parts/examples/client-noteinput-vue.md +4 -0
  429. package/systems/fs/context/authoring/parts/examples/client-notespage-vue.md +4 -0
  430. package/systems/fs/context/authoring/parts/examples/client-reviewform-vue.md +4 -0
  431. package/systems/fs/context/authoring/parts/examples/client-wordcount-vue.md +4 -0
  432. package/systems/fs/context/authoring/parts/examples/package-json.md +4 -0
  433. package/systems/fs/context/authoring/parts/examples/server-env-ts.md +4 -0
  434. package/systems/fs/context/authoring/parts/examples/server-impl-ts.md +4 -0
  435. package/systems/fs/context/authoring/parts/examples/server-index-ts.md +4 -0
  436. package/systems/fs/context/authoring/parts/examples/server-main-ts.md +4 -0
  437. package/systems/fs/context/authoring/parts/examples/server-notes-test-ts.md +4 -0
  438. package/systems/fs/context/authoring/parts/examples/shared-index-ts.md +10 -0
  439. package/systems/fs/context/authoring/parts/examples/system-json.md +4 -0
  440. package/systems/fs/context/authoring/parts/examples/{systems-fs-shared-index-ts-lines-1-189.md → systems-fs-shared-index-ts-lines-1-178.md} +23 -30
  441. package/systems/fs/context/authoring/parts/examples/{systems-fs-shared-index-ts-lines-190-370.md → systems-fs-shared-index-ts-lines-179-382.md} +33 -6
  442. package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-383-567.md +210 -0
  443. package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-568-660.md +117 -0
  444. package/systems/fs/context/authoring/parts/examples/tsconfig-json.md +5 -1
  445. package/systems/fs/context/authoring/parts/examples.md +18 -11
  446. package/systems/fs/context/authoring/parts/fns.md +5 -1
  447. package/systems/fs/context/authoring/parts/fns.reference/fillclaims.md +5 -1
  448. package/systems/fs/context/authoring/parts/fns.reference/fn.md +6 -2
  449. package/systems/fs/context/authoring/parts/fns.reference.md +4 -0
  450. package/systems/fs/context/authoring/parts/folder.md +4 -0
  451. package/systems/fs/context/authoring/parts/gin.md +4 -0
  452. package/systems/fs/context/authoring/parts/gin.reference.md +4 -0
  453. package/systems/fs/context/authoring/parts/handlers-progress.md +5 -1
  454. package/systems/fs/context/authoring/parts/handlers-progress.reference.md +4 -0
  455. package/systems/fs/context/authoring/parts/hooks.md +5 -1
  456. package/systems/fs/context/authoring/parts/hooks.reference.md +5 -1
  457. package/systems/fs/context/authoring/parts/hub/context-questions.md +40 -0
  458. package/systems/fs/context/authoring/parts/hub/{hub-run-background.md → hub-ctx-from-resource.md} +51 -56
  459. package/systems/fs/context/authoring/parts/hub/hub-fns-load.md +35 -42
  460. package/systems/fs/context/authoring/parts/hub/hub-install-package.md +327 -0
  461. package/systems/fs/context/authoring/parts/hub/kinds-of-hub.md +8 -0
  462. package/systems/fs/context/authoring/parts/hub.md +14 -8
  463. package/systems/fs/context/authoring/parts/hub.reference.md +9 -0
  464. package/systems/fs/context/authoring/parts/internals/manifestof.md +4 -0
  465. package/systems/fs/context/authoring/parts/internals/permissionargs.md +4 -0
  466. package/systems/fs/context/authoring/parts/internals/usagefromwire.md +47 -2
  467. package/systems/fs/context/authoring/parts/internals.md +6 -2
  468. package/systems/fs/context/authoring/parts/kinds-agents.md +5 -1
  469. package/systems/fs/context/authoring/parts/kinds-agents.reference/authoringsession.md +4 -0
  470. package/systems/fs/context/authoring/parts/kinds-agents.reference/kind.md +7 -3
  471. package/systems/fs/context/authoring/parts/kinds-agents.reference.md +4 -0
  472. package/systems/fs/context/authoring/parts/lifecycle.md +8 -3
  473. package/systems/fs/context/authoring/parts/lifecycle.reference.md +6 -2
  474. package/systems/fs/context/authoring/parts/mentions.md +5 -1
  475. package/systems/fs/context/authoring/parts/mentions.reference.md +6 -2
  476. package/systems/fs/context/authoring/parts/mistakes.md +7 -2
  477. package/systems/fs/context/authoring/parts/named-types.md +4 -0
  478. package/systems/fs/context/authoring/parts/named-types.reference.md +6 -2
  479. package/systems/fs/context/authoring/parts/outcomes.md +5 -1
  480. package/systems/fs/context/authoring/parts/outcomes.reference.md +4 -0
  481. package/systems/fs/context/authoring/parts/owner-runs.md +5 -1
  482. package/systems/fs/context/authoring/parts/owner-runs.reference.md +36 -11
  483. package/systems/fs/context/authoring/parts/packaging.md +10 -3
  484. package/systems/fs/context/authoring/parts/packaging.reference.md +7 -2
  485. package/systems/fs/context/authoring/parts/providers.md +5 -1
  486. package/systems/fs/context/authoring/parts/providers.reference.md +5 -1
  487. package/systems/fs/context/authoring/parts/remote.md +5 -1
  488. package/systems/fs/context/authoring/parts/remote.reference.md +4 -0
  489. package/systems/fs/context/authoring/parts/resources.md +5 -1
  490. package/systems/fs/context/authoring/parts/resources.reference.md +4 -0
  491. package/systems/fs/context/authoring/parts/server.md +5 -1
  492. package/systems/fs/context/authoring/parts/server.reference.md +41 -20
  493. package/systems/fs/context/authoring/parts/settings-attachments.md +5 -1
  494. package/systems/fs/context/authoring/parts/settings-attachments.reference.md +4 -0
  495. package/systems/fs/context/authoring/parts/start.md +5 -1
  496. package/systems/fs/context/authoring/parts/state-forms.md +5 -1
  497. package/systems/fs/context/authoring/parts/state-forms.reference.md +4 -0
  498. package/systems/fs/context/authoring/parts/store/ctx-store.md +49 -0
  499. package/systems/fs/context/authoring/parts/store/declare.md +32 -0
  500. package/systems/fs/context/authoring/parts/store/engines.md +25 -0
  501. package/systems/fs/context/authoring/parts/store/migrations.md +53 -0
  502. package/systems/fs/context/authoring/parts/store/moves.md +38 -0
  503. package/systems/fs/context/authoring/parts/store/placement.md +25 -0
  504. package/systems/fs/context/authoring/parts/store/serve.md +30 -0
  505. package/systems/fs/context/authoring/parts/store/store-tables.md +24 -0
  506. package/systems/fs/context/authoring/parts/store/vectors.md +32 -0
  507. package/systems/fs/context/authoring/parts/store/when-to-use.md +27 -0
  508. package/systems/fs/context/authoring/parts/store/work.md +37 -0
  509. package/systems/fs/context/authoring/parts/store.md +65 -0
  510. package/systems/fs/context/authoring/parts/store.reference.md +459 -0
  511. package/systems/fs/context/authoring/parts/testing.md +14 -1
  512. package/systems/fs/context/authoring/parts/testing.reference/{memoryjournal.md → equal.md} +55 -48
  513. package/systems/fs/context/authoring/parts/testing.reference/fakehub.md +26 -45
  514. package/systems/fs/context/authoring/parts/testing.reference/{toolcall.md → kindprops.md} +111 -4
  515. package/systems/fs/context/authoring/parts/testing.reference/openmemorystore.md +105 -0
  516. package/systems/fs/context/authoring/parts/testing.reference.md +16 -9
  517. package/systems/fs/context/authoring/parts/widgets.md +5 -1
  518. package/systems/fs/context/authoring/parts/widgets.reference/hub-visuals.md +4 -0
  519. package/systems/fs/context/authoring/parts/widgets.reference/sourcecompatible.md +4 -0
  520. package/systems/fs/context/authoring/parts/widgets.reference.md +4 -0
  521. package/systems/fs/context/authoring/topics/begin.md +4 -0
  522. package/systems/fs/context/authoring/topics/client.md +4 -0
  523. package/systems/fs/context/authoring/topics/declare.md +4 -0
  524. package/systems/fs/context/authoring/topics/examples.md +4 -0
  525. package/systems/fs/context/authoring/topics/fns.md +4 -0
  526. package/systems/fs/context/authoring/topics/server.md +4 -0
  527. package/systems/fs/context/authoring/topics/types.md +8 -1
  528. package/systems/fs/context/comments/answer.md +21 -0
  529. package/systems/fs/context/comments/find.md +23 -0
  530. package/systems/fs/context/comments/read.md +26 -0
  531. package/systems/fs/context/comments.md +23 -0
  532. package/systems/fs/context/files-page.md +30 -0
  533. package/systems/fs/context/guide/attachments.md +16 -0
  534. package/systems/fs/context/guide/change.md +23 -0
  535. package/systems/fs/context/guide/commands.md +19 -0
  536. package/systems/fs/context/guide/documents.md +21 -0
  537. package/systems/fs/context/guide/find.md +25 -0
  538. package/systems/fs/context/guide/paths.md +24 -0
  539. package/systems/fs/context/guide/read.md +21 -0
  540. package/systems/fs/context/machine/history.md +25 -0
  541. package/systems/fs/context/machine/now.md +25 -0
  542. package/systems/fs/context/machine/processes.md +20 -0
  543. package/systems/fs/context/machine/recording.md +19 -0
  544. package/systems/fs/context/machine.md +24 -0
  545. package/systems/fs/package.json +5 -3
  546. package/systems/fs/server/files-page/browse.ts +391 -0
  547. package/systems/fs/server/files-page/comments.ts +439 -0
  548. package/systems/fs/server/files-page/fns.ts +158 -0
  549. package/systems/fs/server/files-page/git-view.ts +391 -0
  550. package/systems/fs/server/files-page/kinds.ts +56 -0
  551. package/systems/fs/server/impl.ts +66 -7
  552. package/systems/fs/server/main.ts +20 -4
  553. package/systems/fs/server/metrics/collector.ts +424 -0
  554. package/systems/fs/server/metrics/index.ts +181 -0
  555. package/systems/fs/server/metrics/os.ts +144 -0
  556. package/systems/fs/server/metrics/parsers.ts +268 -0
  557. package/systems/fs/server/metrics/rrd.ts +363 -0
  558. package/systems/fs/server/metrics/testing.ts +80 -0
  559. package/systems/fs/server/snapshots.ts +216 -33
  560. package/systems/fs/server/testing.ts +15 -9
  561. package/systems/fs/shared/files-page.ts +506 -0
  562. package/systems/fs/shared/index.ts +137 -10
  563. package/systems/fs/shared/metrics.ts +179 -0
  564. package/systems/fs/system.json +10 -1
  565. package/systems/google-calendar/package.json +1 -1
  566. package/systems/input/package.json +3 -3
  567. package/systems/mcp/package.json +3 -3
  568. package/systems/mcp/server/oauth.ts +1 -1
  569. package/systems/ollama/package.json +3 -3
  570. package/systems/schedule/package.json +3 -4
  571. package/systems/schedule/server/env.ts +1 -1
  572. package/systems/schedule/server/fns.ts +5 -4
  573. package/systems/schedule/server/impl.ts +2 -2
  574. package/systems/schedule/server/import.ts +189 -0
  575. package/systems/schedule/server/index.ts +2 -0
  576. package/systems/schedule/server/main.ts +3 -1
  577. package/systems/schedule/server/placements.ts +41 -0
  578. package/systems/schedule/server/store.ts +159 -79
  579. package/systems/schedule/server/timer.ts +142 -107
  580. package/systems/schedule/shared/index.ts +2 -1
  581. package/systems/schedule/system.json +5 -1
  582. package/systems/schedule/tsconfig.json +1 -1
  583. package/systems/template/package.json +1 -1
  584. package/systems/widgets/package.json +3 -3
  585. package/packages/web/dist/assets/ChatPage-7Yebk7rl.js +0 -4
  586. package/packages/web/dist/assets/ContextItemPage-B6rJG3OT.js +0 -2
  587. package/packages/web/dist/assets/ContextItemPage-BRsWxOmu.css +0 -1
  588. package/packages/web/dist/assets/ContextPage-CloIZ_2y.js +0 -2
  589. package/packages/web/dist/assets/ContextPage-rYKxjiVI.css +0 -1
  590. package/packages/web/dist/assets/ContextRow-Byz_7HG-.css +0 -1
  591. package/packages/web/dist/assets/ContextRow-Dvv8CTFk.js +0 -2
  592. package/packages/web/dist/assets/DataTypePage-Ba_zBV4b.js +0 -4
  593. package/packages/web/dist/assets/FnView-B8MGAOoB.js +0 -2
  594. package/packages/web/dist/assets/InstallDialog-C9GDoUI2.js +0 -2
  595. package/packages/web/dist/assets/InstanceTypes-D8Jcxn70.js +0 -2
  596. package/packages/web/dist/assets/InstanceTypes-DAowwLB7.css +0 -1
  597. package/packages/web/dist/assets/InstanceView-CuBD3JPU.css +0 -1
  598. package/packages/web/dist/assets/InstanceView-p7tMaylE.js +0 -2
  599. package/packages/web/dist/assets/LimitsView-DsZG6u5P.js +0 -2
  600. package/packages/web/dist/assets/ListSearch-BK4p7Nxa.js +0 -2
  601. package/packages/web/dist/assets/McpServerView-CD8qw6W_.js +0 -2
  602. package/packages/web/dist/assets/McpServersView-DNycG35u.js +0 -2
  603. package/packages/web/dist/assets/ModelsView-C_iN19xt.js +0 -2
  604. package/packages/web/dist/assets/PairPage-Bs2KuRjC.css +0 -1
  605. package/packages/web/dist/assets/PairPage-TEXPpsqi.js +0 -2
  606. package/packages/web/dist/assets/PoliciesView-BU1fudNF.js +0 -2
  607. package/packages/web/dist/assets/ResourcesPage-YluNBqIv.js +0 -2
  608. package/packages/web/dist/assets/ReviewView-79Z5rU1v.js +0 -3
  609. package/packages/web/dist/assets/RunsView-Dz9Xsvu5.js +0 -2
  610. package/packages/web/dist/assets/ServiceRows-DNzDiutg.js +0 -2
  611. package/packages/web/dist/assets/SettingsPage-CykfuYj1.js +0 -3
  612. package/packages/web/dist/assets/SystemView-Es5wtkYU.js +0 -2
  613. package/packages/web/dist/assets/SystemsView-CeuSFhlF.js +0 -2
  614. package/packages/web/dist/assets/UserMessage-qyc8dG5D.js +0 -9
  615. package/packages/web/dist/assets/WidgetView-BZyDyYRI.js +0 -3
  616. package/packages/web/dist/assets/index-Bv42jNvr.js +0 -4
  617. package/packages/web/dist/assets/routes-qP_j74V5.js +0 -4
  618. package/packages/web/dist/assets/runs-k76usGfd.js +0 -2
  619. package/packages/web/dist/assets/src-DLK1P7oz.js +0 -43
  620. package/packages/web/dist/assets/state-CjE-qA2w.js +0 -2
  621. package/packages/web/dist/assets/ui-W12UYhVu.js +0 -17
  622. package/systems/claude/client/FleetPage.vue +0 -132
  623. package/systems/claude/client/NewSessionForm.vue +0 -62
  624. package/systems/claude/client/SessionList.vue +0 -64
  625. package/systems/claude/client/SessionPage.vue +0 -199
  626. package/systems/claude/client/TaskList.vue +0 -61
  627. package/systems/claude/client/fakes.ts +0 -186
  628. package/systems/claude/client/host.ts +0 -23
  629. package/systems/claude/client/index.ts +0 -15
  630. package/systems/claude/client/logic.ts +0 -270
  631. package/systems/claude/client/state.ts +0 -344
  632. package/systems/claude/package.json +0 -23
  633. package/systems/claude/server/agent-sdk.ts +0 -379
  634. package/systems/claude/server/driver.ts +0 -153
  635. package/systems/claude/server/env.ts +0 -64
  636. package/systems/claude/server/fake-driver.ts +0 -112
  637. package/systems/claude/server/fleet.ts +0 -376
  638. package/systems/claude/server/impl.ts +0 -568
  639. package/systems/claude/server/index.ts +0 -8
  640. package/systems/claude/server/main.ts +0 -38
  641. package/systems/claude/server/preview.ts +0 -76
  642. package/systems/claude/server/questions.ts +0 -117
  643. package/systems/claude/server/transcript.ts +0 -83
  644. package/systems/claude/shared/index.ts +0 -262
  645. package/systems/claude/shared/session.ts +0 -284
  646. package/systems/claude/shared/shapes.ts +0 -106
  647. package/systems/claude/system.json +0 -18
  648. package/systems/claude/tsconfig.json +0 -6
  649. package/systems/database/package.json +0 -25
  650. package/systems/database/server/author.ts +0 -41
  651. package/systems/database/server/authoring.ts +0 -322
  652. package/systems/database/server/catalog.ts +0 -117
  653. package/systems/database/server/compile.ts +0 -332
  654. package/systems/database/server/dialects.ts +0 -17
  655. package/systems/database/server/drivers/database.ts +0 -71
  656. package/systems/database/server/drivers/index.ts +0 -23
  657. package/systems/database/server/drivers/postgres.ts +0 -157
  658. package/systems/database/server/drivers/sqlite.ts +0 -151
  659. package/systems/database/server/drivers/sqlserver.ts +0 -176
  660. package/systems/database/server/env.ts +0 -35
  661. package/systems/database/server/fixture.ts +0 -169
  662. package/systems/database/server/impl.ts +0 -793
  663. package/systems/database/server/index.ts +0 -7
  664. package/systems/database/server/instance.ts +0 -398
  665. package/systems/database/server/main.ts +0 -47
  666. package/systems/database/server/pick.ts +0 -97
  667. package/systems/database/server/queries.ts +0 -390
  668. package/systems/database/server/results.ts +0 -39
  669. package/systems/database/server/schema.ts +0 -59
  670. package/systems/database/server/table-fns.ts +0 -237
  671. package/systems/database/server/types.ts +0 -253
  672. package/systems/database/shared/index.ts +0 -544
  673. package/systems/database/shared/shapes.ts +0 -413
  674. package/systems/database/system.json +0 -14
  675. package/systems/database/tsconfig.json +0 -6
  676. package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-371-533.md +0 -183
  677. package/systems/fs/context/authoring/parts/hub/hub-auto-pair-revoke.md +0 -189
  678. package/systems/web/client/ReadView.vue +0 -110
  679. package/systems/web/client/SearchView.vue +0 -215
  680. package/systems/web/client/StatusChip.vue +0 -38
  681. package/systems/web/client/fakes.ts +0 -48
  682. package/systems/web/client/index.ts +0 -15
  683. package/systems/web/client/view.ts +0 -131
  684. package/systems/web/package.json +0 -22
  685. package/systems/web/server/chrome.ts +0 -121
  686. package/systems/web/server/crawl.ts +0 -333
  687. package/systems/web/server/env.ts +0 -63
  688. package/systems/web/server/guard.ts +0 -60
  689. package/systems/web/server/http.ts +0 -89
  690. package/systems/web/server/impl.ts +0 -203
  691. package/systems/web/server/index.ts +0 -71
  692. package/systems/web/server/loader.ts +0 -104
  693. package/systems/web/server/main.ts +0 -70
  694. package/systems/web/server/mentions.ts +0 -111
  695. package/systems/web/server/problem.ts +0 -72
  696. package/systems/web/server/renderer.ts +0 -243
  697. package/systems/web/server/robots.ts +0 -75
  698. package/systems/web/server/searches.ts +0 -29
  699. package/systems/web/server/tavily.ts +0 -144
  700. package/systems/web/server/testing.ts +0 -165
  701. package/systems/web/server/uploads.ts +0 -33
  702. package/systems/web/shared/index.ts +0 -343
  703. package/systems/web/shared/urls.ts +0 -60
  704. package/systems/web/system.json +0 -15
  705. package/systems/web/tsconfig.json +0 -6
@@ -0,0 +1,4 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/shared-LbaIHjbV.js","assets/rolldown-runtime-COiEfhsA.js","assets/runtime-core.esm-bundler-wlpNGAAZ.js","assets/src-CT3TeFaM.js","assets/push-payload-BeU1ADYt.js","assets/core-DdF778CY.js","assets/langs-CVIiVMBh.js","assets/preload-helper-7y9sWmk5.js","assets/mermaid.core-BNF3dRf5.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-M57EVK23-qYz6TUV4.js","assets/chunk-LEVMRMFU-paszafIt.js","assets/chunk-AXFCVDMN-CI0arS1F.js","assets/chunk-X4PVCEUW-YYhMSieL.js","assets/chunk-BG4553SI-DGn4S0JL.js","assets/d3-selection-COWvaQNI.js","assets/chunk-STOXU5M4-D5Gd-wq9.js","assets/chunk-R3KSYZAL-DW0WB_9q.js","assets/chunk-6MUBBAK2-BHXbrulB.js","assets/dist-DdXDFcej.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-DQASFODM-ClbbgMVy.js"])))=>i.map(i=>d[i]);
2
+ import{D as e,K as t,S as n,T as r,b as i,c as a,f as o,g as s,r as c,s as l}from"./src-CT3TeFaM.js";import{Ar as u,At as d,Ct as f,Dr as p,Er as m,Fr as h,Kt as g,Mr as _,Nr as ee,Or as te,Pr as ne,Tr as v,Tt as y,Ut as re,Vt as ie,ct as b,f as ae,hr as oe,i as x,jr as se,l as ce,lr as le,lt as ue,o as S,ot as de,s as fe,u as pe,wt as me,y as he}from"./routes-DV4IJpwe.js";import{$ as ge,D as C,E as w,Ft as _e,Ht as T,Lt as ve,On as E,St as ye,T as be,Zn as D,_ as O,an as xe,b as k,bt as A,ct as Se,er as Ce,et as we,fn as j,g as M,gn as Te,gt as Ee,it as De,k as N,mt as P,o as F,pn as Oe,qt as I,tr as L,tt as ke,v as R,vn as z,w as Ae,wt as je,xn as B,xt as Me,y as V}from"./runtime-core.esm-bundler-wlpNGAAZ.js";import{r as Ne}from"./RunCard-BnrtK2Yp.js";import{t as Pe}from"./LoadState-h-K9bTYc.js";import{t as Fe}from"./AppPage-CFmKZS8G.js";import{A as Ie,C as Le,D as Re,S as ze,_ as Be,b as Ve,d as He,f as Ue,g as We,h as Ge,i as Ke,j as qe,k as Je,o as Ye,p as Xe,r as Ze,s as Qe,t as $e,u as et,w as tt,x as nt,y as rt}from"./UserMessage-BlnqZDVU.js";import{d as it,i as at,r as ot,u as st}from"./labels-BFbk11BE.js";import{t as ct}from"./FnPill-Cp3KuLmP.js";import{t as lt}from"./GinValueView-jsKIfiEA.js";import{l as ut,n as dt,r as ft,t as pt}from"./ResourceViewer-Do0chYxU.js";import{A as mt,C as ht,D as gt,F as _t,G as vt,H,I as yt,M as bt,N as xt,O as St,P as Ct,R as wt,S as Tt,U as Et,V as Dt,W as Ot,X as kt,Y as At,_ as jt,a as Mt,b as Nt,f as Pt,i as Ft,j as It,l as Lt,n as Rt,o as zt,p as Bt,q as Vt,r as Ht,t as Ut,v as Wt,z as U}from"./ui-BzgWquIU.js";import{r as Gt,t as Kt}from"./fn-notices-CfTa1E8y.js";import{G as qt,H as Jt,V as Yt,z as Xt}from"./state-xfQqaQPX.js";import{t as Zt}from"./now-40JhSjx0.js";import{n as W,r as Qt,t as $t}from"./stores-BMEvTe-I.js";import{$o as en,$r as tn,Bn as nn,Br as rn,Co as an,Dr as on,Ei as sn,Hi as cn,In as ln,Jo as un,Qa as dn,Qr as fn,Rr as pn,So as mn,Ui as hn,Vt as gn,Xo as _n,Y as vn,Yo as yn,Zo as bn,Zr as xn,_ as Sn,_o as Cn,as as wn,bo as Tn,bt as En,c as Dn,ci as On,d as kn,di as An,es as jn,f as Mn,ft as Nn,g as Pn,go as Fn,hn as In,ho as Ln,is as G,k as Rn,l as zn,li as Bn,m as Vn,mr as Hn,ni as Un,nn as Wn,no as Gn,oi as Kn,or as qn,os as Jn,pi as Yn,po as Xn,rn as Zn,ro as Qn,so as $n,ss as er,tn as tr,tr as nr,ts as K,u as rr,ui as ir,vo as ar,xa as or,yo as sr,yt as cr,zi as lr}from"./push-payload-BeU1ADYt.js";import{A as ur,C as dr,E as fr,a as pr,f as mr,h as hr,r as gr,s as _r,x as vr}from"./runs-CveC2kKo.js";import{t as q}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as yr,t as br}from"./ItemHistory-NQAP69ma.js";import{n as xr,t as Sr}from"./fn-modal-B98MR7JN.js";import{i as Cr,n as wr,r as Tr,t as Er}from"./InjectedList-CSWqRiON.js";import{a as Dr,r as Or,t as kr}from"./metrics-CBPX3W5Y.js";import{a as J,i as Ar,n as Y,r as jr,t as Mr}from"./problems-t1E_ovSz.js";import{t as Nr}from"./sources-VPrtgLIi.js";import{i as Pr,t as Fr}from"./WidgetView-DX4ejNb6.js";import{t as Ir}from"./RunDot-lHRICdM5.js";import{c as Lr,l as Rr,n as zr,s as Br,t as Vr}from"./layout-D1gf481r.js";import{a as Hr,b as Ur,v as Wr}from"./systems-BqE3WTSF.js";import{c as Gr,d as Kr,f as qr,i as Jr,l as Yr,o as Xr,p as Zr,r as Qr,s as $r,u as ei}from"./remote-config-BNQhSDzB.js";import{C as ti,T as ni,d as ri,j as ii,u as ai}from"./review-fP-l9D6H.js";import{S as oi}from"./widgets-BBCuSS6E.js";import{a as si,o as ci}from"./size-Bh__w5aI.js";import{a as li,i as ui,o as di}from"./formats-JwoKfXIq.js";import{t as fi}from"./preload-helper-7y9sWmk5.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pi=N({__name:`PageApproval`,props:{approval:{},inChat:{type:Boolean,default:!1},description:{default:``}},emits:[`decide`],setup(e,{emit:t}){let n=t;return(t,r)=>(P(),R(Gt,{ident:e.approval.id,"data-approval":e.approval.id,fn:e.approval.fn,description:e.description,args:void 0,preview:e.approval.preview,rememberable:e.inChat&&E(Je)(e.approval),ask:e.approval.ask,onDecide:r[0]||=(e,t,r,i)=>n(`decide`,e,t,r,i)},null,8,[`ident`,`data-approval`,`fn`,`description`,`preview`,`rememberable`,`ask`]))}}),mi=N({__name:`PageComposer`,props:{modelValue:{},placeholder:{default:`Message`},sending:{type:Boolean,default:!1},running:{type:Boolean,default:!1},stopping:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},note:{default:``}},emits:[`update:modelValue`,`send`,`stop`],setup(e,{emit:t}){let n=e,r=t,i=qt(),a=Zt(),o={open:!1,kind:void 0,items:[],active:0,loading:!1},s={available:!1,state:`idle`,startedAt:0,problem:``},c={shown:!1,on:!1};function l(e){e===`cancel`&&r(`stop`)}return(t,u)=>(P(),R(Be,{text:e.modelValue,placeholder:e.placeholder,tokens:[],"can-send":!n.disabled&&e.modelValue.trim()!==``,sending:e.sending,running:e.running,paused:!1,stopping:e.stopping,"immediate-stop":``,picker:o,files:[],"reply-all":c,answerers:``,"can-attach":!1,voice:s,now:E(a),touch:E(i),note:e.note,onInput:u[0]||=e=>r(`update:modelValue`,e),onSend:u[1]||=e=>r(`send`),onControl:u[2]||=e=>l(e)},null,8,[`text`,`placeholder`,`can-send`,`sending`,`running`,`stopping`,`now`,`touch`,`note`]))}}),hi=Fn.parse(`ses_page`),gi=dn.parse(`act_page-agent`);function _i(e,t){let n=`${e}/${t.name}`,r={..._r(Ln.parse(`run_${t.key}`),n,t.status),args:t.args};switch(t.status){case`running`:return r;case`done`:return{...r,outcome:{status:`done`,result:t.output??``}};case`failed`:return{...r,outcome:{status:`failed`,error:{class:`fatal`,code:`failed`,message:t.output===void 0||t.output.trim()===``?`It failed.`:t.output}}}}}function vi(e,t,n,r,i,a,o){return{id:$n.parse(`msg_${e}`),session:hi,turn:sr.parse(`trn_${e}`),author:t,role:n,parts:r===``?[]:[{type:`text`,text:r}],runs:[...a],status:o?`streaming`:`done`,replyAll:!1,answerers:[],createdAt:i??0}}function yi(e,t){let n=[];return{segments:t.reduce((t,r)=>{if(r.kind!==`call`)return r.text.trim()===``?t:Ye(t,{kind:r.kind,text:r.text});let i=_i(e,r.call);return n.push(i),Ye(t,{kind:`runs`,runs:[i.id]})},[]),runs:n}}function bi(e,t){let n=e.findLastIndex(e=>e.kind===`answer`);return e.map((e,r)=>{switch(e.kind){case`user`:return{kind:`user`,key:e.key,message:vi(e.key,t.me,`user`,e.text,e.at,[],!1)};case`note`:return{kind:`note`,key:e.key,message:vi(e.key,gi,`note`,e.text,void 0,[],!1)};case`answer`:{let{segments:i,runs:a}=yi(t.system,e.pieces),o=e.pieces.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``),s=t.streaming&&r===n;return{kind:`answer`,key:e.key,message:vi(e.key,gi,`assistant`,o,e.at,a.map(e=>e.id),s),segments:i,runs:a}}}})}var xi={class:`conversation`,"data-testid":`conversation`},Si=q(N({__name:`PageConversation`,props:{entries:{},agent:{},system:{},streaming:{type:Boolean,default:!1}},setup(e){let t=e,{session:n}=W(),r=Zt(),i=M(()=>n.user.value?.id??gi),a=M(()=>bi(t.entries,{system:t.system,me:i.value,streaming:t.streaming})),o={context:[],fns:[]},s=z(new Set),c=e=>!s.value.has(e.id);function l(e){u([e],!s.value.has(e))}function u(e,t){let n=new Set(s.value);for(let r of e)t?n.add(r):n.delete(r);s.value=n}return(t,i)=>(P(),k(`div`,xi,[(P(!0),k(F,null,A(a.value,t=>(P(),k(F,{key:t.key},[t.kind===`user`?(P(),R($e,{key:0,message:t.message,mine:``,"author-name":E(n).user.value?.name??`You`,now:E(r),"command-name":e=>e,suggestions:o,actions:[]},null,8,[`message`,`author-name`,`now`,`command-name`])):t.kind===`note`?(P(),R(Ze,{key:1,message:t.message},null,8,[`message`])):(P(),R(Ke,{key:2,messages:[t.message],"author-name":e.agent,now:E(r),streaming:t.message.status===`streaming`,failed:!1,"runs-of":()=>t.runs,"live-of":()=>t.segments,collapsed:c,"view-of":()=>void 0,"attachment-view":()=>void 0,actions:[],onRunOpen:i[0]||=e=>l(e),onRunToggle:i[1]||=(e,t)=>u([e],!t),onCollapseAll:e=>u(t.runs.map(e=>e.id),!e)},null,8,[`messages`,`author-name`,`now`,`streaming`,`runs-of`,`live-of`,`onCollapseAll`]))],64))),128))]))}}),[[`__scopeId`,`data-v-aa0c3db3`]]),Ci=Object.freeze({Frame:j(Fe),Input:j(Nt),Markdown:j(Ut),Icon:j(At),Empty:j(Tt),LoadState:j(Pe),Reasoning:j(qe),Typing:j(Ie),ResourceViewer:j(pt),ValueEditor:j(lt),Button:j(U),Select:j(Pt),Textarea:j(Mt),Dialog:j(ht),Banner:j(Dt),Badge:j(H),Skeleton:j(St),FnPill:j(ct),Approval:j(pi),Conversation:j(Si),Composer:j(mi)}),wi=Object.freeze({cost:st,relativeTime:(e,t)=>Vt(e,t),fullTime:e=>vt(e)}),Ti=[7,30,90];function Ei(e,t){let{system:n,local:r}=an(e);return t===0?`${n} has no fns on this hub now (it may be uninstalled or not connected yet), so ${e} can't be shown.`:`${n} has no fn named ${r} now. It may have been removed or renamed since it ran.`}var Di=class{#e;#t;#n;name=z(void 0);days=z(7);record=new v;metrics=new v;daily=new v;recent=new v;switching=new p;constructor(e,t){this.#e=e,this.#t=t}async open(e,t){let n=this.name.value===e;n||this.close(),this.name.value=e,this.days.value=t,this.#n??=this.#t(e=>{this.#a(e)}),await Promise.all([this.#r(e,n),this.#i(e,t,n&&this.metrics.value.value!==void 0)])}async switchOn(e){let t=this.record.value.value;return t!==void 0&&(this.record.set({...t,disabled:!e}),(await this.switching.run(()=>this.#e.switchItem.call({section:`fns`,name:t.name,on:e}),`Couldn't switch that.`)).ok?!0:(this.record.set(t),!1))}close(){this.#n?.(),this.#n=void 0,this.name.value=void 0,this.record.reset(),this.metrics.reset(),this.daily.reset(),this.recent.reset()}async#r(e,t){let n=Cn.parse(an(e).system);await this.record.load(async()=>{let t=await this.#e.systemFns.call({system:n}),r=t.find(t=>t.name===e);if(r===void 0)throw new Mr(Ei(e,t.length));return r},`Couldn't load this fn.`,t)}async#i(e,t,n){await Promise.all([this.metrics.load(async()=>(await this.#e.fnMetrics.call({fn:e,days:t})).find(t=>t.fn===e),`Couldn't load this fn's metrics.`,n),this.daily.load(()=>this.#e.fnMetricsDays.call({fn:e,days:t}),`Couldn't load this fn's days.`,n),this.recent.load(async()=>(await this.#e.runs.call({query:{filters:[{field:`fn`,op:`is`,value:e}],limit:8}})).items,`Couldn't load this fn's runs.`,n)])}#a(e){let t=this.name.value;if(e.type!==`fn`||t===void 0||e.fn!==t)return;let n=this.record.value.value;n!==void 0&&this.record.set({...n,stats:e.stats}),this.#i(t,this.days.value,!0)}},Oi=[`data-testid`],ki={class:`title`},Ai=[`aria-label`],ji={class:`scale top`},Mi={class:`columns`},Ni=[`aria-label`,`data-day`,`onPointerenter`,`onFocus`],Pi={class:`labels`,"aria-hidden":`true`},Fi={class:`table`},Ii=q(N({__name:`DayBars`,props:{title:{},bars:{},format:{},testid:{default:`day-bars`}},setup(e){let t=e,n=M(()=>Dr(Math.max(0,...t.bars.map(e=>e.value)))),r=z(void 0),i=M(()=>Math.max(1,Math.ceil(t.bars.length/7))),a=M(()=>r.value===void 0?void 0:t.bars[r.value]);return(t,o)=>(P(),k(`figure`,{class:`day-bars`,"data-testid":e.testid},[O(`figcaption`,ki,L(e.title),1),O(`div`,{class:`plot`,role:`img`,"aria-label":`${e.title}: ${e.bars.map(t=>`${t.label} ${e.format(t.value)}`).join(`, `)}`,onPointerleave:o[1]||=e=>r.value=void 0},[O(`span`,ji,L(e.format(n.value)),1),o[2]||=O(`span`,{class:`scale zero`},`0`,-1),o[3]||=O(`div`,{class:`grid`,"aria-hidden":`true`},null,-1),O(`div`,Mi,[(P(!0),k(F,null,A(e.bars,(e,t)=>(P(),k(`button`,{key:e.day,type:`button`,class:D([`column`,{pointed:r.value===t}]),"aria-label":`${e.label}: ${e.lines.join(`, `)}`,"data-day":e.day,onPointerenter:e=>r.value=t,onFocus:e=>r.value=t,onBlur:o[0]||=e=>r.value=void 0},[O(`span`,{class:`bar`,style:Ce({height:`${e.value<=0?0:Math.max(2,e.value/n.value*100)}%`})},null,4)],42,Ni))),128))]),a.value&&r.value!==void 0?(P(),k(`div`,{key:0,class:`tip`,role:`status`,style:Ce({left:`${Math.min(80,Math.max(20,(r.value+.5)/e.bars.length*100))}%`})},[O(`strong`,null,L(a.value.label),1),(P(!0),k(F,null,A(a.value.lines,e=>(P(),k(`span`,{key:e},L(e),1))),128))],4)):V(``,!0)],40,Ai),O(`div`,Pi,[(P(!0),k(F,null,A(e.bars,(e,t)=>(P(),k(`span`,{key:e.day,class:`label`},L(t%i.value===0?e.label:``),1))),128))]),O(`details`,Fi,[o[5]||=O(`summary`,null,`As a table`,-1),O(`table`,null,[O(`thead`,null,[O(`tr`,null,[o[4]||=O(`th`,null,`Day`,-1),O(`th`,null,L(e.title),1)])]),O(`tbody`,null,[(P(!0),k(F,null,A(e.bars,e=>(P(),k(`tr`,{key:e.day},[O(`td`,null,L(e.label),1),O(`td`,null,L(e.lines.join(` · `)),1)]))),128))])])])],8,Oi))}}),[[`__scopeId`,`data-v-94fb9c63`]]),Li={class:`stats`,"data-testid":`fn-stats`},Ri={class:`period`},zi={class:`period-title`},Bi={key:0,class:`strip`,"data-testid":`fn-metrics`},Vi=[`data-figure`],Hi={class:`label`},Ui={class:`value`},Wi={key:0,class:`detail`},Gi=q(N({__name:`FnStats`,props:ge({metrics:{},daily:{},loading:{type:Boolean},problem:{},now:{},compact:{type:Boolean}},{days:{required:!0},daysModifiers:{}}),emits:ge([`retry`],[`update:days`]),setup(e,{emit:t}){let n=e,r=_e(e,`days`),i=t,a=Ti.map(e=>({value:String(e),label:`${String(e)} days`})),o=M({get:()=>String(r.value),set:e=>{r.value=Ti.find(t=>String(t)===e)??7}}),s=M(()=>n.metrics===void 0?[]:Or(n.metrics)),c=M(()=>({period:r.value,now:n.now})),l=M(()=>kr(n.daily,`runs`,c.value)),u=M(()=>kr(n.daily,`time`,c.value));return(t,n)=>(P(),k(`section`,Li,[O(`div`,Ri,[O(`h2`,zi,`Over the last `+L(r.value)+` days`,1),C(E(Bt),{modelValue:o.value,"onUpdate:modelValue":n[0]||=e=>o.value=e,options:E(a),label:`Period`,"data-testid":`fn-period`},null,8,[`modelValue`,`options`])]),C(Pe,{loading:e.loading,problem:e.problem,ready:e.metrics!==void 0||!e.loading,empty:!1,onRetry:n[1]||=e=>i(`retry`)},{default:I(()=>[e.metrics?(P(),k(`ul`,Bi,[(P(!0),k(F,null,A(s.value,e=>(P(),k(`li`,{key:e.key,class:`figure`,"data-figure":e.key},[O(`span`,Hi,L(e.label),1),O(`span`,Ui,L(e.value),1),e.detail?(P(),k(`span`,Wi,L(e.detail),1)):V(``,!0)],8,Vi))),128))])):(P(),R(E(Tt),{key:1,icon:`fn`,title:`No runs in this period`,body:`Its numbers show here once it runs.`})),l.value.length>0?(P(),k(`div`,{key:2,class:D([`charts`,{compact:e.compact}])},[C(E(wt),null,{default:I(()=>[C(Ii,{title:`Runs per day`,bars:l.value,format:e=>e.toLocaleString(),testid:`fn-runs-chart`},null,8,[`bars`,`format`])]),_:1}),C(E(wt),null,{default:I(()=>[C(Ii,{title:`Typical time per day`,bars:u.value,format:E(it),testid:`fn-time-chart`},null,8,[`bars`,`format`])]),_:1})],2)):V(``,!0)]),_:1},8,[`loading`,`problem`,`ready`])]))}}),[[`__scopeId`,`data-v-3e1752f2`]]),Ki={key:0,class:`problem`},qi={key:2,class:`note`,"data-testid":`access-fixed`},Ji={key:3,class:`problem`,role:`alert`},Yi=q(N({__name:`AccessControl`,props:{target:{},label:{default:`Who can use it`},title:{default:`Sharing`},compact:{type:Boolean,default:!1},fixed:{default:void 0}},setup(e){let t=e,n=Qt(),r=n?.chat.access,i=Nr().people(),a=B(void 0),o=M(()=>r?.multiUser.value===!0);Se(()=>{r?.load()}),T([()=>qn(t.target),o],([,e])=>{a.value=e&&r!==void 0?r.view(t.target):void 0},{immediate:!0});let s=M(()=>a.value?.value.value?.sharing.owner),c=B(``);T(s,async e=>{if(c.value=``,e===void 0||e===n?.session.user.value?.id)return;let[t]=await i.label([e]).catch(()=>[]);s.value===e&&(c.value=t===void 0||t.missing===!0?`its owner`:t.label)},{immediate:!0});let l=M({get:()=>{if(t.fixed!==void 0)return{visibility:`private`,with:[]};let e=a.value?.value.value?.sharing;return e===void 0?void 0:{visibility:e.visibility,with:e.with}},set:e=>{e!==void 0&&u(e)}});async function u(e){if(r===void 0||a.value===void 0)return;let n=await r.set(t.target,e);n.ok&&a.value.set(n.value)}return(t,n)=>o.value&&a.value!==void 0?(P(),R(wt,{key:0,title:e.title,compact:e.compact,"data-testid":`access-control`},{default:I(()=>[a.value.problem.value===``?l.value===void 0?V(``,!0):(P(),R(Ht,{key:1,modelValue:l.value,"onUpdate:modelValue":n[0]||=e=>l.value=e,people:E(i),label:e.label,owner:c.value,readonly:e.fixed!==void 0||a.value.value.value?.editable===!1},null,8,[`modelValue`,`people`,`label`,`owner`,`readonly`])):(P(),k(`p`,Ki,L(a.value.problem.value),1)),e.fixed===void 0?V(``,!0):(P(),k(`p`,qi,L(e.fixed),1)),E(r)?.saving.problem.value?(P(),k(`p`,Ji,L(E(r).saving.problem.value),1)):V(``,!0)]),_:1},8,[`title`,`compact`])):V(``,!0)}}),[[`__scopeId`,`data-v-9e92a917`]]);async function Xi(e,t){let n=await e.chat.sessions.create({title:t.title});if(n===void 0)throw Error(e.chat.sessions.problem.value||`Couldn't start a chat.`);if(t.run!==void 0){let r=e.chat.thread(n);if(await r.invoke(t.run.fn,t.run.args)===void 0)throw Error(r.problem.value||`Couldn't run that.`)}return await e.push(S.session(n)),n}function Zi(){let{chat:e,toasts:t}=W(),n=h(),r=z(``);async function i(i){r.value=i;try{await Xi({chat:e,push:e=>n.push(e)},{title:rn(i),run:{fn:i,args:{}}})}catch(e){t.error(`Couldn't open the widget`,e instanceof Error?e.message:String(e))}finally{r.value=``}}return{opening:r,open:i}}var Qi={read:{label:`Reads`,about:`Only reads: nothing is changed.`},write:{label:`Writes`,about:`Adds or changes things.`},delete:{label:`Deletes`,about:`Can remove things.`}},$i={read:`neutral`,write:`warn`,delete:`danger`},ea={free:`Spends nothing`,history:`From its runs`,payload:`From the call and the model’s price`,unknown:`Spends, never run yet`};function ta(e){return e.basis===`free`?`Free`:e.basis===`unknown`?`Unknown`:e.min===e.max?st(e.typical):`${st(e.typical)} (${st(e.min)}–${st(e.max)})`}function na(e){let t=[{key:`cost`,label:`Cost a call`,value:ta(e.cost),detail:ea[e.cost.basis]}],n=e.times;return n!==void 0&&n.runs>0&&t.push({key:`time`,label:`Typical time`,value:it(n.typical),detail:`The median run`},{key:`slow`,label:`Slow runs`,value:it(n.slow),detail:`Longest ${it(n.longest)}`}),t.push({key:`runs`,label:`Runs`,value:(n?.runs??e.cost.runs).toLocaleString(),detail:`Settled, all time`}),t}function ra(e){let t=JSON.stringify(e);return t.length<=80?t:JSON.stringify(e,null,2)}function ia(e,t){return`${e}(${ra(t.args)})`}var aa=un([`readable`,`stored`]);function oa(e,t,n){return t!==void 0&&n===`readable`?t:e===void 0?void 0:{language:`json`,code:JSON.stringify(e,null,2)}}var sa=[`data-fn`],ca={class:`about`},la={key:0,class:`description`},ua={class:`badges`},da={key:1,class:`signature`,"data-testid":`fn-signature`},fa={key:2,class:`dim`},pa={key:3,class:`strip`,"data-testid":`fn-facts`},ma=[`data-figure`],ha={class:`label`},ga={class:`value`},_a={class:`detail`},va={key:4,class:`uses`,"data-testid":`fn-uses`},ya={class:`examples`,"data-testid":`fn-examples`},ba={class:`heading`},xa={key:0,class:`dim`},Sa={key:0,class:`bad`,role:`alert`},Ca={key:1,class:`dim`},wa={key:3,class:`example-list`},Ta={key:0,class:`note`},Ea={class:`code`},Da={key:1,class:`code result`},Oa=q(N({__name:`FnOverview`,props:{name:{},about:{},facts:{},loading:{type:Boolean},problem:{default:``},examples:{},examplesTotal:{},moreExamples:{type:Boolean},examplesLoading:{type:Boolean},examplesProblem:{default:``},describe:{type:Boolean,default:!0}},emits:[`more`,`retry`],setup(e,{emit:t}){let n=e,r=t,i=M(()=>at(n.name)),a=M(()=>n.facts===void 0?[]:na(n.facts)),o=M(()=>n.facts?.mode??n.about?.mode),s=M(()=>(n.facts?.uses??[]).filter(e=>e!==n.name)),c=M(()=>{let e=n.facts?.kind;return e!==void 0&&!In(e)?`its kind (${e}) works one out when the hub describes it.`:"its author adds them to its declaration (`examples`)."});return(t,n)=>(P(),k(`div`,{class:`fn-overview`,"data-testid":`fn-overview`,"data-fn":e.name},[e.problem===``?e.loading&&e.facts===void 0?(P(),R(E(St),{key:1,lines:4})):V(``,!0):(P(),R(E(Dt),{key:0,tone:`danger`},{actions:I(()=>[C(E(U),{size:`sm`,variant:`ghost`,onClick:n[0]||=e=>r(`retry`)},{default:I(()=>[...n[2]||=[w(`Retry`,-1)]]),_:1})]),default:I(()=>[w(L(e.problem)+` `,1)]),_:1})),O(`section`,ca,[e.describe&&e.about?.description?(P(),k(`p`,la,L(e.about.description),1)):V(``,!0),O(`div`,ua,[o.value?(P(),R(E(H),{key:0,tone:E($i)[o.value],title:E(Qi)[o.value].about,"data-testid":`fn-mode`},{default:I(()=>[w(L(E(Qi)[o.value].label),1)]),_:1},8,[`tone`,`title`])):V(``,!0),e.facts?.free?(P(),R(E(H),{key:1,tone:`ok`},{default:I(()=>[...n[3]||=[w(`Free`,-1)]]),_:1})):V(``,!0),e.facts?.kind&&e.facts.kind!==`native`?(P(),R(E(H),{key:2},{default:I(()=>[w(L(e.facts.kind),1)]),_:1})):V(``,!0),e.about?.instance?(P(),R(E(H),{key:3},{default:I(()=>[w(L(e.about.instance),1)]),_:1})):V(``,!0),e.about&&!e.about.available?(P(),R(E(H),{key:4,tone:`warn`,title:e.about.blocked?.reason},{default:I(()=>[...n[4]||=[w(`Not available now`,-1)]]),_:1},8,[`title`])):V(``,!0),Me(t.$slots,`badges`,{},void 0,!0)]),e.about?.signature?(P(),k(`code`,da,L(e.about.signature),1)):V(``,!0),e.about&&!e.about.available&&e.about.blocked?(P(),k(`p`,fa,L(e.about.blocked.reason),1)):V(``,!0)]),e.facts?.notice?(P(),R(E(Dt),{key:2,tone:`neutral`,"data-testid":`fn-notice`},{default:I(()=>[w(L(e.facts.notice),1)]),_:1})):V(``,!0),a.value.length>0?(P(),k(`ul`,pa,[(P(!0),k(F,null,A(a.value,e=>(P(),k(`li`,{key:e.key,class:`figure`,"data-figure":e.key},[O(`span`,ha,L(e.label),1),O(`span`,ga,L(e.value),1),O(`span`,_a,L(e.detail),1)],8,ma))),128))])):V(``,!0),e.facts&&(e.facts.reads.length>0||e.facts.writes.length>0||s.value.length>0)?(P(),k(`dl`,va,[e.facts.reads.length>0?(P(),k(F,{key:0},[n[5]||=O(`dt`,null,`Reads`,-1),O(`dd`,null,[(P(!0),k(F,null,A(e.facts.reads,e=>(P(),k(`code`,{key:e,class:`chip`},L(e),1))),128))])],64)):V(``,!0),e.facts.writes.length>0?(P(),k(F,{key:1},[n[6]||=O(`dt`,null,`Writes`,-1),O(`dd`,null,[(P(!0),k(F,null,A(e.facts.writes,e=>(P(),k(`code`,{key:e,class:`chip write`},L(e),1))),128))])],64)):V(``,!0),s.value.length>0?(P(),k(F,{key:2},[n[7]||=O(`dt`,null,`Uses`,-1),O(`dd`,null,[(P(!0),k(F,null,A(s.value,e=>(P(),R(ct,{key:e,name:e},null,8,[`name`]))),128))])],64)):V(``,!0)])):V(``,!0),O(`section`,ya,[O(`h3`,ba,[n[8]||=w(`Examples`,-1),e.examplesTotal>0?(P(),k(`span`,xa,` · `+L(e.examplesTotal),1)):V(``,!0)]),e.examplesProblem===``?e.examples.length===0&&e.examplesLoading?(P(),k(`p`,Ca,`Loading…`)):e.examples.length===0?(P(),R(E(Dt),{key:2,tone:`warn`,"data-testid":`fn-no-examples`},{default:I(()=>[w(` No examples. Every fn needs at least one: `+L(c.value),1)]),_:1})):(P(),k(`ol`,wa,[(P(!0),k(F,null,A(e.examples,e=>(P(),k(`li`,{key:e.id,class:`example`},[e.note?(P(),k(`p`,Ta,L(e.note),1)):V(``,!0),O(`pre`,Ea,L(E(ia)(i.value,e)),1),e.result===void 0?V(``,!0):(P(),k(`pre`,Da,[n[9]||=O(`span`,{class:`arrow`},`→ `,-1),w(L(E(ra)(e.result)),1)]))]))),128))])):(P(),k(`p`,Sa,L(e.examplesProblem),1)),e.moreExamples?(P(),R(E(U),{key:4,size:`sm`,variant:`ghost`,loading:e.examplesLoading,"data-testid":`fn-more-examples`,onClick:n[1]||=e=>r(`more`)},{default:I(()=>[w(` More examples (`+L(e.examplesTotal-e.examples.length)+` left) `,1)]),_:1},8,[`loading`])):V(``,!0)]),Me(t.$slots,`runs`,{},void 0,!0)],8,sa))}}),[[`__scopeId`,`data-v-e343e112`]]),ka=N({__name:`FnPayload`,props:ge({payload:{},readable:{},maxHeight:{default:360}},{form:{default:`readable`},formModifiers:{}}),emits:[`update:form`],setup(e){let t=e,n=_e(e,`form`),r=M(()=>[{value:`readable`,label:t.readable?.language.toUpperCase()??`Readable`},{value:`stored`,label:`Stored form`}]),i=M(()=>oa(t.payload,t.readable,n.value));return(t,a)=>i.value?(P(),R(E(wt),{key:0,title:`What it runs`,"data-testid":`fn-payload`},Ae({default:I(()=>[C(E(bt),{code:i.value.code,language:i.value.language,wrap:``,"max-height":e.maxHeight},null,8,[`code`,`language`,`max-height`])]),_:2},[e.readable?{name:`actions`,fn:I(()=>[C(E(Bt),{modelValue:n.value,"onUpdate:modelValue":a[0]||=e=>n.value=e,options:r.value,label:`Show it as`,"data-testid":`fn-payload-form`},null,8,[`modelValue`,`options`])]),key:`0`}:void 0]),1024)):V(``,!0)}}),Aa=[`aria-current`,`data-testid`],ja={key:0,class:`mark`},Ma={class:`main`},Na={class:`top`},Pa={class:`title`},Fa={key:0,class:`badges`},Ia={key:0,class:`detail`},La={key:1,class:`figures`},Ra=[`datetime`,`title`],za=q(N({__name:`BrowserRow`,props:{title:{},detail:{default:``},at:{default:void 0},now:{},selected:{type:Boolean,default:!1},testid:{default:``}},emits:[`open`],setup(e,{emit:t}){let n=t,r=ve();return(t,i)=>(P(),k(`li`,{class:D([`browser-row`,{selected:e.selected}])},[O(`button`,{type:`button`,class:`open`,"aria-current":e.selected?`true`:void 0,"data-testid":e.testid||void 0,onClick:i[0]||=e=>n(`open`)},[r.mark?(P(),k(`span`,ja,[Me(t.$slots,`mark`)])):V(``,!0),O(`span`,Ma,[O(`span`,Na,[O(`span`,Pa,L(e.title),1),r.badges?(P(),k(`span`,Fa,[Me(t.$slots,`badges`)])):V(``,!0)]),e.detail===``?V(``,!0):(P(),k(`span`,Ia,L(e.detail),1))]),r.figures?(P(),k(`span`,La,[Me(t.$slots,`figures`)])):V(``,!0),e.at===void 0?V(``,!0):(P(),k(`time`,{key:2,class:`at`,datetime:new Date(e.at).toISOString(),title:E(vt)(e.at)},L(E(Vt)(e.at,e.now)),9,Ra))],8,Aa)],2))}}),[[`__scopeId`,`data-v-1a21ed96`]]),Ba={key:0,class:`none bad`,role:`alert`},Va={key:1,class:`none`},Ha={key:2,class:`list`},Ua={key:0},Wa=q(N({__name:`FnRuns`,props:{runs:{},now:{},title:{},loading:{type:Boolean,default:!1},problem:{default:``},empty:{default:`No runs yet.`}},emits:[`open`],setup(e,{emit:t}){let n=t,r=ve();return(t,i)=>(P(),R(E(wt),{class:`runs`,title:e.title,flush:``,compact:``,"data-testid":`fn-recent`},Ae({default:I(()=>[e.problem===``?e.runs.length===0?(P(),k(`p`,Va,L(e.loading?`Loading…`:e.empty),1)):(P(),k(`ul`,Ha,[(P(!0),k(F,null,A(e.runs,t=>(P(),R(za,{key:t.id,title:E(pn)(t.args)||E(rn)(t.fn),at:t.createdAt,now:e.now,testid:`fn-run-${t.id}`,onOpen:e=>n(`open`,t.id)},{mark:I(()=>[C(Ir,{status:t.status,size:10},null,8,[`status`])]),badges:I(()=>[t.status===`failed`||t.status===`awaiting-approval`?(P(),R(E(H),{key:0,tone:E(gr)[t.status].tone},{default:I(()=>[w(L(E(gr)[t.status].word),1)]),_:2},1032,[`tone`])):V(``,!0),t.attempt>1?(P(),R(E(H),{key:1,tone:`warn`},{default:I(()=>[w(`Try `+L(t.attempt),1)]),_:2},1024)):V(``,!0)]),figures:I(()=>[O(`span`,null,L(E(st)(t.totalCost)),1),E(vr)(t,e.now)===void 0?V(``,!0):(P(),k(`span`,Ua,L(E(it)(E(vr)(t,e.now)??0)),1))]),_:2},1032,[`title`,`at`,`now`,`testid`,`onOpen`]))),128))])):(P(),k(`p`,Ba,L(e.problem),1))]),_:2},[r.actions?{name:`actions`,fn:I(()=>[Me(t.$slots,`actions`,{},void 0,!0)]),key:`0`}:void 0]),1032,[`title`]))}}),[[`__scopeId`,`data-v-dc316a5b`]]),Ga=N({__name:`FnDetails`,props:ge({name:{},describe:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},{days:{required:!0},daysModifiers:{},form:{default:`readable`},formModifiers:{},tab:{default:`about`},tabModifiers:{}}),emits:ge([`run`,`runs`,`switched`],[`update:days`,`update:form`,`update:tab`]),setup(e,{emit:t}){let n=e,r=_e(e,`days`),i=_e(e,`form`),a=_e(e,`tab`),o=t,s=ve(),{admin:c,fns:l,toasts:d}=W(),f=c.fn,p=Zt(3e4),m=M(()=>{let e=f.record.value.value;return e?.name===n.name?e:void 0}),h=M(()=>f.recent.value.value??[]),g=M(()=>m.value?.decl.kind===vn),_=M(()=>g.value?h.value.find(e=>e.outcome?.status===`done`):void 0),ee=M(()=>{let e=_.value;return e?.outcome?.status===`done`?u(e.outcome.result,rn(n.name)):void 0}),{opening:te,open:ne}=Zi(),v=M(()=>m.value?.decl.kind===Tr),y=c.injected,re=M(()=>y.page.value.value?.injections??[]),ie=M(()=>Cr(v.value,y.page.value.value===void 0?void 0:re.value.length)),b=M(()=>v.value?a.value:`about`);async function ae(e,t){await y.switchOn(e,t)||d.error(y.saving.problem.value)}async function oe(e,t){await y.reorder(e,t)||d.error(y.saving.problem.value)}async function x(e){let t=m.value?.name;t!==void 0&&(await f.switchOn(e)?o(`switched`,t,e):d.error(f.switching.problem.value))}return T(()=>[n.name,r.value],([e,t])=>{f.open(e,t)},{immediate:!0}),T(()=>n.name,e=>{l.open(e)},{immediate:!0}),T(()=>[n.name,v.value],([e,t])=>{t?y.open({agent:e}):y.close()},{immediate:!0}),De(()=>{f.close(),l.close(),y.close()}),(t,n)=>(P(),R(Pe,{class:`fn-details`,loading:E(f).record.loading.value,problem:E(f).record.problem.value,ready:m.value!==void 0,empty:!1,lines:6,"data-testid":`fn-details`,onRetry:n[10]||=t=>E(f).open(e.name,r.value)},{default:I(()=>[m.value?(P(),k(F,{key:0},[v.value?(P(),R(E(zt),{key:0,modelValue:a.value,"onUpdate:modelValue":n[0]||=e=>a.value=e,tabs:ie.value,label:`Fn`,"data-testid":`fn-tabs`},null,8,[`modelValue`,`tabs`])):V(``,!0),b.value===`injected`?(P(),R(Er,{key:1,per:`agent`,views:re.value,loading:E(y).page.loading.value,problem:E(y).page.problem.value,busy:E(y).busyKey.value,now:E(p),"data-testid":`fn-injected`,onSwitch:ae,onReorder:oe,onRetry:n[1]||=e=>E(y).refresh()},null,8,[`views`,`loading`,`problem`,`busy`,`now`])):(P(),k(F,{key:2},[g.value?(P(),R(E(wt),{key:0,title:`The widget`,"data-testid":`fn-widget`},{actions:I(()=>[C(E(U),{size:`sm`,icon:`play`,loading:E(te)===e.name,"data-testid":`fn-widget-open`,onClick:n[2]||=t=>E(ne)(e.name)},{default:I(()=>[...n[11]||=[w(`Open in chat`,-1)]]),_:1},8,[`loading`])]),default:I(()=>[ee.value&&_.value?(P(),R(Fr,{key:_.value.id,frame:ee.value,args:_.value.args,"view-key":`fn:${_.value.id}`,"show-title":!1},null,8,[`frame`,`args`,`view-key`])):(P(),R(E(Tt),{key:1,icon:`grid`,title:`Not run yet`,body:`Open it in a chat to run it; its latest run shows here.`}))]),_:1})):V(``,!0),C(Oa,{name:e.name,about:E(l).about.value.value,facts:E(l).facts.value.value,loading:E(l).facts.loading.value,problem:E(l).facts.problem.value,describe:e.describe,examples:E(l).examples.value,"examples-total":E(l).examplesTotal.value,"more-examples":E(l).examplesNext.value!==void 0,"examples-loading":E(l).examplesLoading.value,"examples-problem":E(l).examplesProblem.value,onMore:n[3]||=e=>E(l).moreExamples(),onRetry:n[4]||=t=>E(l).open(e.name)},Ae({badges:I(()=>[C(E(Lt),{"model-value":!m.value.disabled,label:`In use`,disabled:E(f).switching.busy.value,"data-testid":`fn-on`,"onUpdate:modelValue":x},null,8,[`model-value`,`disabled`]),m.value.paused?(P(),R(E(H),{key:0},{default:I(()=>[...n[12]||=[w(`Paused`,-1)]]),_:1})):V(``,!0),(P(!0),k(F,null,A(m.value.decl.tags,e=>(P(),R(E(H),{key:e},{default:I(()=>[w(L(e),1)]),_:2},1024))),128))]),_:2},[s.runs?{name:`runs`,fn:I(()=>[Me(t.$slots,`runs`)]),key:`0`}:void 0]),1032,[`name`,`about`,`facts`,`loading`,`problem`,`describe`,`examples`,`examples-total`,`more-examples`,`examples-loading`,`examples-problem`]),C(Gi,{days:r.value,"onUpdate:days":n[5]||=e=>r.value=e,metrics:E(f).metrics.value.value,daily:E(f).daily.value.value??[],loading:E(f).metrics.loading.value,problem:E(f).metrics.problem.value||E(f).daily.problem.value,now:E(p),compact:e.compact,onRetry:n[6]||=t=>E(f).open(e.name,r.value)},null,8,[`days`,`metrics`,`daily`,`loading`,`problem`,`now`,`compact`]),C(ka,{form:i.value,"onUpdate:form":n[7]||=e=>i.value=e,payload:m.value.decl.payload,readable:m.value.decl.readable,"max-height":e.compact?240:360},null,8,[`form`,`payload`,`readable`,`max-height`]),C(Yi,{target:{kind:`fn`,fn:e.name}},null,8,[`target`]),C(br,{item:{system:m.value.system,section:`fns`,name:e.name}},null,8,[`item`]),C(Wa,{runs:h.value,now:E(p),title:`Latest runs`,loading:E(f).recent.loading.value,problem:E(f).recent.problem.value,onOpen:n[9]||=e=>o(`run`,e)},{actions:I(()=>[C(E(U),{size:`sm`,variant:`ghost`,icon:`arrow-right`,"data-testid":`fn-runs`,onClick:n[8]||=t=>o(`runs`,e.name)},{default:I(()=>[...n[13]||=[w(`All its runs`,-1)]]),_:1})]),_:1},8,[`runs`,`now`,`loading`,`problem`])],64))],64)):V(``,!0)]),_:3},8,[`loading`,`problem`,`ready`]))}}),Ka=N({__name:`FnModal`,props:{modal:{},fn:{}},setup(e){let t=e,{fns:n,session:r}=W(),i=h(),a=ne(),o=M({get:()=>{let e=oe.safeParse(a.query[Sr]);return e.success?e.data:`about`},set:e=>{let t={...a.query};e===`about`?Reflect.deleteProperty(t,Sr):t[Sr]=e,i.replace({query:t,hash:a.hash})}}),s=M(()=>r.user.value?.role===`admin`),c=z(7),l=z(`readable`),u=Zt(3e4),d=M({get:()=>!0,set:e=>{e||t.modal.close()}}),f=M(()=>[...(t.modal.scope.value.runs?.()??[]).filter(e=>e.fn===t.fn)].reverse());T([()=>t.fn,s],([e,t])=>{t||n.open(e)},{immediate:!0}),De(()=>{s.value||n.close()});function p(e){i.push(e)}return(t,r)=>(P(),R(E(ht),{open:d.value,"onUpdate:open":r[12]||=e=>d.value=e,title:E(rn)(e.fn),description:e.fn,width:`720px`},{footer:I(()=>[C(E(U),{variant:`ghost`,onClick:r[10]||=t=>e.modal.close()},{default:I(()=>[...r[13]||=[w(`Close`,-1)]]),_:1}),s.value?(P(),R(E(U),{key:0,variant:`secondary`,icon:`arrow-right`,"data-testid":`fn-open-page`,onClick:r[11]||=t=>p(E(S).fn(e.fn,o.value===`about`?{}:{tab:o.value}))},{default:I(()=>[...r[14]||=[w(`Open page`,-1)]]),_:1})):V(``,!0)]),default:I(()=>[s.value?(P(),R(Ga,{key:0,days:c.value,"onUpdate:days":r[1]||=e=>c.value=e,form:l.value,"onUpdate:form":r[2]||=e=>l.value=e,tab:o.value,"onUpdate:tab":r[3]||=e=>o.value=e,name:e.fn,compact:``,onRun:r[4]||=t=>e.modal.openRun(t),onRuns:r[5]||=e=>p(E(S).fnRuns(e)),onSwitched:r[6]||=(t,n)=>e.modal.scope.value.switched?.(t,n)},Ae({_:2},[f.value.length>0?{name:`runs`,fn:I(()=>[C(Wa,{runs:f.value,now:E(u),title:`Its runs here`,onOpen:r[0]||=t=>e.modal.openRun(t)},null,8,[`runs`,`now`])]),key:`0`}:void 0]),1032,[`days`,`form`,`tab`,`name`])):(P(),R(Oa,{key:1,name:e.fn,about:E(n).about.value.value,facts:E(n).facts.value.value,loading:E(n).facts.loading.value,problem:E(n).facts.problem.value,examples:E(n).examples.value,"examples-total":E(n).examplesTotal.value,"more-examples":E(n).examplesNext.value!==void 0,"examples-loading":E(n).examplesLoading.value,"examples-problem":E(n).examplesProblem.value,onMore:r[8]||=e=>E(n).moreExamples(),onRetry:r[9]||=t=>E(n).open(e.fn)},Ae({_:2},[f.value.length>0?{name:`runs`,fn:I(()=>[C(Wa,{runs:f.value,now:E(u),title:`Its runs here`,onOpen:r[7]||=t=>e.modal.openRun(t)},null,8,[`runs`,`now`])]),key:`0`}:void 0]),1032,[`name`,`about`,`facts`,`loading`,`problem`,`examples`,`examples-total`,`more-examples`,`examples-loading`,`examples-problem`]))]),_:1},8,[`open`,`title`,`description`]))}}),qa={"approval-needed":{icon:`shield`,tone:`warn`,label:`Approval needed`},"input-needed":{icon:`edit`,tone:`warn`,label:`Input needed`},"config-needed":{icon:`settings`,tone:`warn`,label:`Setup needed`},message:{icon:`chat`,tone:`accent`,label:`Message`},replied:{icon:`chat`,tone:`accent`,label:`Reply`},"turn-finished":{icon:`success`,tone:`ok`,label:`Finished`},"turn-failed":{icon:`error`,tone:`danger`,label:`Failed`},"pairing-requested":{icon:`key`,tone:`accent`,label:`Pairing`},"system-disconnected":{icon:`offline`,tone:`danger`,label:`Disconnected`},"spend-limit":{icon:`warning`,tone:`danger`,label:`Spend limit`},"system-paused":{icon:`pause`,tone:`danger`,label:`System paused`},"system-notice":{icon:`warning`,tone:`warn`,label:`System notice`},"system-message":{icon:`info`,tone:`neutral`,label:`Update`}},Ja={ok:{icon:`success`,tone:`ok`,label:`Went well`},failed:{icon:`error`,tone:`danger`,label:`Failed`}};function Ya(e){let t=qa[e.reason],n=e.tone===void 0||e.tone===`info`?t:{...Ja[e.tone],label:t.label};return e.resolved===void 0?n:{icon:`check`,tone:`neutral`,label:`${n.label} · ${e.resolved}`}}var Xa=[`data-testid`],Za={class:`text`},Qa={class:`top`},$a={class:`title`},eo=[`datetime`,`title`],to={key:0,class:`body`},no={key:0,class:`dot`,"aria-hidden":`true`},ro={key:1,class:`sr-only`},io={class:`side`},ao=q(N({__name:`NotificationRow`,props:{notification:{},now:{},compact:{type:Boolean,default:!1}},emits:[`open`,`also`,`read`],setup(e){let t=e,n=M(()=>Ya(t.notification));return(t,r)=>(P(),k(`li`,{class:D([`row`,{unread:!e.notification.read,resolved:e.notification.resolved!==void 0,compact:e.compact}]),"data-testid":`notification-${e.notification.id}`},[O(`button`,{type:`button`,class:`open`,onClick:r[0]||=n=>t.$emit(`open`,e.notification)},[O(`span`,{class:D([`mark`,`tone-${n.value.tone}`])},[C(E(At),{name:n.value.icon,size:16},null,8,[`name`])],2),O(`span`,Za,[O(`span`,Qa,[O(`span`,$a,L(e.notification.title),1),O(`time`,{class:`time`,datetime:new Date(e.notification.createdAt).toISOString(),title:E(vt)(e.notification.createdAt)},L(E(Vt)(e.notification.createdAt,e.now)),9,eo)]),e.notification.body===``?V(``,!0):(P(),k(`span`,to,L(e.notification.body),1)),O(`span`,{class:D([`reason`,`tone-${n.value.tone}`]),"data-testid":`notification-reason`},[e.notification.read?V(``,!0):(P(),k(`span`,no)),w(` `+L(n.value.label),1),e.notification.read?V(``,!0):(P(),k(`span`,ro,`, unread`))],2)])]),O(`div`,io,[e.notification.also?(P(),R(E(U),{key:0,class:`also`,size:`sm`,variant:`ghost`,"data-testid":`notification-also`,onClick:r[1]||=n=>t.$emit(`also`,e.notification)},{default:I(()=>[w(L(e.notification.also.label),1)]),_:1})):V(``,!0),e.notification.read?V(``,!0):(P(),R(E(yt),{key:1,class:`read`,icon:`check`,label:`Mark as read`,size:`sm`,onClick:r[2]||=n=>t.$emit(`read`,e.notification)}))])],10,Xa))}}),[[`__scopeId`,`data-v-3a6b7c55`]]),oo=[`aria-busy`],so={key:1,class:`skeletons`,"aria-label":`Loading notifications`},co={key:4,class:`more`},lo=q(N({__name:`NotificationList`,props:{items:{},now:{},loading:{type:Boolean},loaded:{type:Boolean},problem:{default:``},hasMore:{type:Boolean,default:!1},loadingMore:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},emptyTitle:{default:`All caught up`},emptyBody:{default:`Approvals, replies and finished work show up here.`}},emits:[`open`,`also`,`read`,`more`,`retry`],setup(e){return(t,n)=>(P(),k(`div`,{class:D([`list`,{compact:e.compact}]),"aria-busy":e.loading?`true`:`false`},[e.problem===``?V(``,!0):(P(),R(E(Dt),{key:0,tone:`danger`,class:`problem`},{actions:I(()=>[C(E(U),{size:`sm`,variant:`ghost`,onClick:n[0]||=e=>t.$emit(`retry`)},{default:I(()=>[...n[5]||=[w(`Retry`,-1)]]),_:1})]),default:I(()=>[w(L(e.problem)+` `,1)]),_:1})),e.loading&&!e.loaded?(P(),k(`ul`,so,[(P(!0),k(F,null,A(e.compact?3:5,e=>(P(),k(`li`,{key:e,class:`skeleton`},[C(E(St),{shape:`circle`,size:32}),C(E(St),{shape:`lines`,lines:2,class:`lines`})]))),128))])):e.loaded&&e.items.length===0?(P(),R(E(Tt),{key:2,icon:`inbox`,title:e.emptyTitle,body:e.emptyBody},null,8,[`title`,`body`])):(P(),R(r,{key:3,tag:`ul`,name:`row`,class:`rows`},{default:I(()=>[(P(!0),k(F,null,A(e.items,r=>(P(),R(ao,{key:r.id,notification:r,now:e.now,compact:e.compact,onOpen:n[1]||=e=>t.$emit(`open`,e),onAlso:n[2]||=e=>t.$emit(`also`,e),onRead:n[3]||=e=>t.$emit(`read`,e)},null,8,[`notification`,`now`,`compact`]))),128))]),_:1})),e.hasMore&&e.items.length>0?(P(),k(`div`,co,[C(E(U),{variant:`ghost`,size:`sm`,loading:e.loadingMore,onClick:n[4]||=e=>t.$emit(`more`)},{default:I(()=>[...n[6]||=[w(`Load older`,-1)]]),_:1},8,[`loading`])])):V(``,!0)],10,oo))}}),[[`__scopeId`,`data-v-c9cb4a65`]]),uo={class:`panel`,"data-testid":`inbox-panel`},fo={class:`head`},po={class:`foot`},mo=q(N({__name:`InboxPanel`,props:{items:{},unread:{},now:{},loading:{type:Boolean},loaded:{type:Boolean},problem:{default:``},limit:{default:6}},emits:[`open`,`also`,`read`,`readAll`,`all`,`retry`],setup(e){let t=e,n=M(()=>t.items.slice(0,t.limit));return(t,r)=>(P(),k(`div`,uo,[O(`header`,fo,[r[7]||=O(`h2`,{class:`title`},`Notifications`,-1),e.unread>0?(P(),R(E(U),{key:0,size:`sm`,variant:`ghost`,icon:`check`,onClick:r[0]||=e=>t.$emit(`readAll`)},{default:I(()=>[...r[6]||=[w(`Mark all read`,-1)]]),_:1})):V(``,!0)]),C(lo,{items:n.value,now:e.now,loading:e.loading,loaded:e.loaded,problem:e.problem,compact:``,onOpen:r[1]||=e=>t.$emit(`open`,e),onAlso:r[2]||=e=>t.$emit(`also`,e),onRead:r[3]||=e=>t.$emit(`read`,e),onRetry:r[4]||=e=>t.$emit(`retry`)},null,8,[`items`,`now`,`loading`,`loaded`,`problem`]),O(`footer`,po,[C(E(U),{size:`sm`,variant:`ghost`,"icon-right":`arrow-right`,block:``,onClick:r[5]||=e=>t.$emit(`all`)},{default:I(()=>[...r[8]||=[w(`Open inbox`,-1)]]),_:1})])]))}}),[[`__scopeId`,`data-v-d2b5d353`]]),ho={class:`steps`,"data-testid":`install-sheet`},go=q(N({__name:`InstallSheet`,props:ge({name:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:[`update:open`],setup(e){let t=_e(e,`open`);return(n,r)=>(P(),R(E(ht),{open:t.value,"onUpdate:open":r[1]||=e=>t.value=e,title:`Add to Home Screen`,description:`Put ${e.name} on your home screen, like any other app.`,width:`420px`},{footer:I(()=>[C(E(U),{variant:`primary`,onClick:r[0]||=e=>t.value=!1},{default:I(()=>[...r[6]||=[w(`Got it`,-1)]]),_:1})]),default:I(()=>[O(`ol`,ho,[r[4]||=O(`li`,null,[O(`span`,null,[w(`Tap `),O(`strong`,null,`Share`)]),O(`svg`,{class:`glyph`,viewBox:`0 0 24 24`,"aria-label":`the Share button`,role:`img`},[O(`path`,{d:`M12 3v12M8 7l4-4 4 4`}),O(`path`,{d:`M7 10H5v11h14V10h-2`})]),O(`span`,{class:`dim`},`at the bottom of Safari (at the top on an iPad).`)],-1),r[5]||=O(`li`,null,[O(`span`,null,[w(`Scroll down and tap `),O(`strong`,null,`Add to Home Screen`),w(`.`)])],-1),O(`li`,null,[O(`span`,null,[r[2]||=w(`Tap `,-1),r[3]||=O(`strong`,null,`Add`,-1),w(`. Open `+L(e.name)+` from your home screen from now on.`,1)])])]),r[7]||=O(`p`,{class:`dim note`},`Only Safari can add it. In another browser, open this page in Safari first.`,-1)]),_:1},8,[`open`,`description`]))}}),[[`__scopeId`,`data-v-f47f52f1`]]),_o=[`title`],vo=[`width`,`height`],yo={key:0,class:`name`,"data-testid":`brand-name`},bo=q(N({__name:`AppBrand`,props:{name:{},markOnly:{type:Boolean,default:!1},size:{default:28}},setup(e){return(t,n)=>(P(),k(`span`,{class:`brand`,title:e.markOnly?e.name:void 0},[(P(),k(`svg`,{class:`mark`,width:e.size,height:e.size,viewBox:`0 0 32 32`,"aria-hidden":`true`},[...n[0]||=[be(`<rect width="32" height="32" rx="9" class="tile" data-v-c7bc8cf6></rect><g class="lines" stroke-width="2" stroke-linecap="round" data-v-c7bc8cf6><path d="M16 16 9 9M16 16l7-7M16 16v8" data-v-c7bc8cf6></path></g><circle cx="16" cy="16" r="3.5" class="hub" data-v-c7bc8cf6></circle><circle cx="9" cy="9" r="2.3" class="node" data-v-c7bc8cf6></circle><circle cx="23" cy="9" r="2.3" class="node" data-v-c7bc8cf6></circle><circle cx="16" cy="24" r="2.3" class="node" data-v-c7bc8cf6></circle>`,6)]],8,vo)),e.markOnly?V(``,!0):(P(),k(`span`,yo,L(e.name),1))],8,_o))}}),[[`__scopeId`,`data-v-c7bc8cf6`]]),xo={class:`head`},So={class:`head-tools`},Co={class:`entries`},wo={class:`label`},To=[`aria-label`],Eo={class:`middle`},Do={key:0,class:`foot`},Oo=[`title`,`onClick`],ko={class:`who`},Ao={class:`name`},jo={class:`email`},Mo=q(N({__name:`AppSidebar`,props:{brand:{},entries:{},user:{},unread:{},collapsed:{type:Boolean,default:!1},collapsible:{type:Boolean,default:!0},installable:{type:Boolean,default:!1}},emits:[`toggle`,`inbox`,`settings`,`install`,`signOut`,`navigate`],setup(e,{emit:t}){let n=e,r=t,i=ve(),a=M(()=>[{value:`settings`,label:`Settings`,icon:`settings`},...n.installable?[{value:`install`,label:`Install app`,icon:`download`}]:[],{kind:`separator`},{value:`sign-out`,label:`Sign out`,icon:`log-out`,danger:!0}]);function o(e){e.currentTarget instanceof HTMLElement&&r(`inbox`,e.currentTarget)}function s(e){switch(e){case`settings`:r(`settings`);break;case`install`:r(`install`);break;case`sign-out`:r(`signOut`)}}return(t,n)=>{let r=ye(`RouterLink`);return P(),k(`nav`,{class:D([`sidebar`,{collapsed:e.collapsed}]),"aria-label":`Main`},[O(`div`,xo,[C(bo,{name:e.brand,"mark-only":e.collapsed},null,8,[`name`,`mark-only`]),O(`div`,So,[C(E(yt),{icon:`bell`,label:e.unread>0?`Notifications, ${E(Ot)(e.unread)} unread`:`Notifications`,badge:e.unread,"data-testid":`open-inbox`,onClick:o},null,8,[`label`,`badge`]),e.collapsible?(P(),R(E(yt),{key:0,icon:`sidebar`,label:e.collapsed?`Expand sidebar`:`Collapse sidebar`,"data-testid":`toggle-sidebar`,onClick:n[0]||=e=>t.$emit(`toggle`)},null,8,[`label`])):V(``,!0)])]),O(`ul`,Co,[(P(!0),k(F,null,A(e.entries,i=>(P(),k(`li`,{key:i.id},[C(r,{to:i.to,class:D([`entry`,{active:i.active}]),"aria-current":i.active?`page`:void 0,title:e.collapsed?i.label:void 0,"data-testid":`nav-${i.id}`,onClick:n[1]||=e=>t.$emit(`navigate`)},{default:I(()=>[C(E(At),{name:i.icon,size:18},null,8,[`name`]),O(`span`,wo,L(i.label),1),i.count>0?(P(),k(`span`,{key:0,class:`count`,"aria-label":`${i.count} unread`},L(E(Ot)(i.count)),9,To)):V(``,!0)]),_:2},1032,[`to`,`class`,`aria-current`,`title`,`data-testid`])]))),128))]),O(`div`,Eo,[i.default&&!e.collapsed?Me(t.$slots,`default`,{},void 0,!0,0):V(``,!0)]),e.user?(P(),k(`div`,Do,[C(E(jt),{items:a.value,label:`Account`,side:`top`,align:`start`,onSelect:s},{trigger:I(({toggle:t,attrs:n})=>[O(`button`,we({type:`button`,class:`person`},n,{title:e.collapsed?e.user.name:void 0,"data-testid":`user-menu`,onClick:t}),[C(E(Et),{name:e.user.name,size:30},null,8,[`name`]),O(`span`,ko,[O(`span`,Ao,L(e.user.name),1),O(`span`,jo,L(e.user.email),1)]),C(E(At),{name:`chevron-up`,size:16,class:`chevron`})],16,Oo)]),_:1},8,[`items`])])):V(``,!0)],2)}}}),[[`__scopeId`,`data-v-db84e1b2`]]),No={class:`topbar`},Po={class:`title`},Fo=q(N({__name:`AppTopBar`,props:{title:{},unread:{}},emits:[`menu`,`inbox`],setup(e,{emit:t}){let n=t;function r(e){e.currentTarget instanceof HTMLElement&&n(`inbox`,e.currentTarget)}return(t,n)=>(P(),k(`header`,No,[C(E(yt),{icon:`menu`,label:`Open navigation`,"data-testid":`open-nav`,onClick:n[0]||=e=>t.$emit(`menu`)}),O(`h1`,Po,L(e.title),1),C(E(yt),{icon:`bell`,label:e.unread>0?`Notifications, ${E(Ot)(e.unread)} unread`:`Notifications`,badge:e.unread,"data-testid":`open-inbox`,onClick:r},null,8,[`label`,`badge`])]))}}),[[`__scopeId`,`data-v-58e88c22`]]),Io=[{id:`chat`,to:S.chat(),label:`Chat`,icon:`chat`,routes:[x.chat,x.session,x.turnTree],adminOnly:!1},{id:`inbox`,to:S.inbox(),label:`Inbox`,icon:`inbox`,routes:[x.inbox],adminOnly:!1},{id:`resources`,to:S.resources(),label:`Resources`,icon:`layers`,routes:[x.resources],adminOnly:!1},{id:`context`,to:S.context(),label:`Context`,icon:`book`,routes:[x.context,x.contextItem],adminOnly:!1},{id:`data`,to:S.data(),label:`Data`,icon:`database`,routes:[x.data,x.dataType],adminOnly:!1},{id:`admin`,to:S.systems(),label:`Admin`,icon:`shield`,adminOnly:!0,routes:[x.admin,x.systems,x.system,x.review,x.instance,x.fn,x.graph,x.models,x.limits,x.people,x.policies,x.actorSettings,x.runs,x.llmCalls,x.modelCalls,x.mcps,x.mcp,x.mcpServers,x.mcpServer,x.apiServices,x.apiService]},{id:`settings`,to:S.settings(),label:`Settings`,icon:`settings`,routes:[x.settings],adminOnly:!1}],Lo=e=>typeof e==`string`&&Object.values(x).includes(e);function Ro(e,t,n){let r=e.filter(e=>e.system===t);return r.find(e=>e.segment===n)??r[0]}function zo(e,t,n,r=[],i=[]){let a=Lo(e.name)?e.name:void 0,o=Io.filter(e=>!e.adminOnly||t?.role===`admin`).map(e=>({id:e.id,to:e.to,label:e.label,icon:e.icon,active:a!==void 0&&e.routes.includes(a),count:e.id===`inbox`?n.inbox:e.id===`admin`?n.admin:0})),s=r.map(t=>({id:`connect-${t.system}`,to:S.connect(t.system),label:t.title,icon:t.icon,active:a===x.connect&&e.params?.system===t.system,count:0})),c=i.map(t=>({id:`page-${t.system}-${t.segment}`,to:S.systemPage(t.system,t.segment),label:t.title,icon:t.icon,active:a===x.systemPage&&t===Ro(i,e.params?.system,e.params?.page),count:0})),l=o.findIndex(e=>e.id===`context`)+1;return[...o.slice(0,l),...s,...c,...o.slice(l)]}function Bo(){let{keeper:e}=W(),t=h();return async()=>{await e.signOut(),window.location.replace(t.resolve(S.signIn()).href)}}function Vo(){let{session:e}=W(),t=h();T(e.signedIn,e=>{let n=t.currentRoute.value;e||n.meta.public===!0||window.location.replace(t.resolve(S.signIn(n.fullPath)).href)})}function Ho(e){return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">`,`<rect width="32" height="32" rx="9" fill="#5b5bd6"/>`,`<g stroke="#fff" stroke-width="2" stroke-linecap="round" opacity="0.7"><path d="M16 16 9 9M16 16l7-7M16 16v8"/></g>`,`<circle cx="16" cy="16" r="3.5" fill="#fff"/><circle cx="9" cy="9" r="2.3" fill="#fff"/><circle cx="23" cy="9" r="2.3" fill="#fff"/><circle cx="16" cy="24" r="2.3" fill="#fff"/>`,e?`<circle cx="26" cy="26" r="6" fill="#e5484d" stroke="#fff" stroke-width="2"/>`:``,`</svg>`].join(``)}function Uo(e){return`data:image/svg+xml,${encodeURIComponent(Ho(e))}`}function Wo(e,t){let n=e.querySelector(`link[rel="icon"]`);n===null&&(n=e.createElement(`link`),n.rel=`icon`,e.head.append(n)),n.type=`image/svg+xml`,n.href=Uo(t)}function Go(e,t,n){let r=t>0?`(${t>99?`99+`:String(t)}) `:``;return e===n?`${r}${n}`:`${r}${e} · ${n}`}var Ko={class:`titlebar`,"aria-hidden":`true`,"data-testid":`titlebar`},qo={class:`titlebar-name`},Jo=[`aria-busy`],Yo={key:0,class:`connection`,"data-testid":`connection-banner`},Xo=q(N({__name:`AppShell`,setup(e){let{session:t,identity:n,keeper:r,layout:i,toasts:a,inbox:o,connection:s,admin:c,chat:l,pages:u,outsideImages:d,install:f}=W(),p=Bo(),m=ne(),g=h(),_=It(Vr),ee=Zt(),te=t.signedIn,v=M(()=>m.meta.bare===!0||!te.value),y=M(()=>zo(m,t.user.value,{inbox:o.unread.value,admin:c.systems.pending.value},l.connections.nav.value,u.nav.value)),re=M(()=>i.pageTitle.value===void 0?(m.name===x.connect?l.connections.nav.value.find(e=>e.system===m.params.system):void 0)?.title??m.meta.title??n.name.value:i.pageTitle.value),ie=M(()=>_.value&&m.meta.ownHeader!==!0),b=B(!1),ae=B(null);T(te,(e,t)=>{n.load(),e?(r.start(),n.start(),o.start(),l.connections.load(!0),u.start(),u.load(!0),d.load()):(u.clear(),d.clear(),r.stop(),o.stop(),n.stop(),t===!0&&m.meta.public!==!0&&g.replace(S.signIn(m.fullPath)))},{immediate:!0}),T([re,o.unread,n.name],([e,t,n])=>{document.title=Go(e,t,n),Wo(document,t>0)},{immediate:!0}),T(()=>m.fullPath,()=>{i.drawerOpen.value=!1,b.value=!1});function oe(e){b.value&&ae.value===e?b.value=!1:(ae.value=e,i.drawerOpen.value=!1,b.value=!0,o.load(`all`))}async function se(e,t=`link`){b.value=!1,e.read||o.markRead([e.id]),await g.push(await fe(e,e=>l.sessionOfRun(e),t))}async function ce(){i.drawerOpen.value=!1,await f.install()===`accepted`&&a.ok(`Installed`)}async function le(){await o.markAllRead()&&a.ok(`All caught up`)}return(e,r)=>{let c=ye(`RouterView`);return P(),k(`div`,{class:D([`shell`,{bare:v.value,compact:E(_),"no-bar":E(_)&&!ie.value,collapsed:!E(_)&&E(i).collapsed}])},[O(`div`,Ko,[O(`span`,qo,L(E(n).name.value),1)]),v.value?V(``,!0):(P(),k(F,{key:0},[E(_)?ie.value?(P(),R(Fo,{key:1,title:re.value,unread:E(o).unread.value,onMenu:r[2]||=e=>E(i).drawerOpen.value=!0,onInbox:oe},null,8,[`title`,`unread`])):V(``,!0):(P(),R(Mo,{key:0,class:`side`,brand:E(n).name.value,entries:y.value,user:E(t).user.value,unread:E(o).unread.value,collapsed:E(i).collapsed,installable:E(f).offered,onToggle:r[0]||=e=>E(i).toggleSidebar(),onInbox:oe,onSettings:r[1]||=e=>E(g).push(E(S).settings()),onSignOut:E(p),onInstall:ce},null,8,[`brand`,`entries`,`user`,`unread`,`collapsed`,`installable`,`onSignOut`])),E(_)?(P(),R(E(mt),{key:2,open:E(i).drawerOpen.value,"onUpdate:open":r[5]||=e=>E(i).drawerOpen.value=e,placement:`left`,label:`Navigation`,width:`300px`},{default:I(()=>[C(Mo,{brand:E(n).name.value,entries:y.value,user:E(t).user.value,unread:E(o).unread.value,collapsible:!1,installable:E(f).offered,onInbox:oe,onSettings:r[3]||=e=>E(g).push(E(S).settings()),onSignOut:E(p),onNavigate:r[4]||=e=>E(i).drawerOpen.value=!1,onInstall:ce},null,8,[`brand`,`entries`,`user`,`unread`,`installable`,`onSignOut`])]),_:1},8,[`open`])):V(``,!0)],64)),O(`main`,{class:`page`,"aria-busy":E(o).loading.value?`true`:void 0},[!v.value&&E(s).state.value!==`online`?(P(),k(`div`,Yo,[C(E(Dt),{tone:E(s).state.value===`offline`?`warn`:`ok`,icon:E(s).state.value===`offline`?`offline`:`success`},{default:I(()=>[w(L(E(s).state.value===`offline`?`Reconnecting to the hub…`:`Back online`),1)]),_:1},8,[`tone`,`icon`])])):V(``,!0),C(c,null,{default:I(({Component:e,route:t})=>[(P(),R(je(e),{key:t.meta.group??t.matched[0]?.path??t.path,class:`routed`}))]),_:1})],8,Jo),C(E(Wt),{open:b.value,"onUpdate:open":r[11]||=e=>b.value=e,anchor:ae.value,side:E(_)?`bottom`:`right`,align:`start`,label:`Notifications`},{default:I(()=>[C(mo,{items:E(o).items.value,unread:E(o).unread.value,now:E(ee),loading:E(o).loading.value,loaded:E(o).loaded.value,problem:E(o).problem.value,onOpen:r[6]||=e=>se(e),onAlso:r[7]||=e=>se(e,`also`),onRead:r[8]||=e=>E(o).markRead([e.id]),onReadAll:le,onAll:r[9]||=e=>E(g).push(E(S).inbox()),onRetry:r[10]||=e=>E(o).load(`all`)},null,8,[`items`,`unread`,`now`,`loading`,`loaded`,`problem`])]),_:1},8,[`open`,`anchor`,`side`]),C(go,{open:E(f).sheetOpen.value,"onUpdate:open":r[12]||=e=>E(f).sheetOpen.value=e,name:E(n).name.value},null,8,[`open`,`name`]),C(E(Ft),{toasts:E(a).items,onDismiss:r[13]||=e=>E(a).dismiss(e),onAction:r[14]||=e=>E(a).act(e),onHold:r[15]||=e=>E(a).hold(e),onRelease:r[16]||=e=>E(a).release(e)},null,8,[`toasts`])],2)}}}),[[`__scopeId`,`data-v-73b0dbae`]]),Zo=N({__name:`App`,setup(e){let{chat:t,itemVersions:n,session:r,outsideImages:i}=W();Ee(Rt,()=>i.value.value),Ee(Xt,t.types),Ee(yr,n),Ee(Jt,e=>t.renderers.inputView(e)),Ee(l,pt),Ee(a,Ne),Ee(c,Ci),Vo();let o=xr(h());return(e,t)=>(P(),k(F,null,[C(Xo),E(o).name.value&&E(r).signedIn.value?(P(),R(Ka,{key:0,modal:E(o),fn:E(o).name.value},null,8,[`modal`,`fn`])):V(``,!0)],64))}});function Qo(e,t){let n=_({history:t,routes:ce,scrollBehavior:(e,t,n)=>n??{top:0}});return n.beforeEach(t=>{let n=e.signedIn.value;return t.name===x.signIn&&n?pe(t.query.next)??S.chat():t.meta.public===!0?!0:n?t.meta.admin===!0&&e.user.value?.role!==`admin`?S.chat():!0:S.signIn(t.fullPath)}),n}var $o=K({server:K({name:G(),version:G()}),instructions:G().optional(),tools:_n(K({name:G(),description:G().optional()}))}),es=`2025-06-18`,ts=Jn([K({jsonrpc:en(`2.0`),id:Jn([jn(),G()]),result:er()}),K({jsonrpc:en(`2.0`),id:Jn([jn(),G(),yn()]),error:K({code:jn(),message:G()})})]),ns=K({serverInfo:K({name:G(),version:G()}),instructions:G().optional()}),rs=K({tools:_n(K({name:G(),description:G().optional()}))});function is(e,t){if(!e.includes(`text/event-stream`))return JSON.parse(t);let n=t.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trim()).filter(e=>e!==``);for(let e of n.reverse())try{return JSON.parse(e)}catch{}throw Error(`The MCP sent no answer.`)}var as=class{#e;constructor(e){this.#e=e}async tools(e,t){let n,r=async(r,i,a)=>{let o=await this.#e(e,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json, text/event-stream`,authorization:`Bearer ${t}`,"mcp-protocol-version":es,...n===void 0?{}:{"mcp-session-id":n}},body:JSON.stringify({jsonrpc:`2.0`,method:i,params:a,...r===void 0?{}:{id:r}})});if(o.status===401||o.status===403)throw Error(`The MCP refused that secret.`);if(!o.ok&&o.status!==202)throw Error(`The MCP answered ${o.status}.`);if(n=o.headers.get(`mcp-session-id`)??n,r===void 0)return;let s=ts.parse(is(o.headers.get(`content-type`)??``,await o.text()));if(`error`in s)throw Error(s.error.message);return s.result},i=ns.parse(await r(1,`initialize`,{protocolVersion:es,capabilities:{},clientInfo:{name:`harness-admin`,version:`1`}}));await r(void 0,`notifications/initialized`,{});let a=rs.parse(await r(2,`tools/list`,{}));return $o.parse({server:i.serverInfo,...i.instructions===void 0?{}:{instructions:i.instructions},tools:a.tools})}},os=class{#e;#t;secrets=new v;revoking=new p;constructor(e){this.#e=e}async load(e,t=!1){this.#t=e,await this.secrets.load(()=>this.#e.autoPairs.call({system:e}),`Couldn't load the auto pair secrets.`,t)}async revoke(e){let t=await this.revoking.run(async()=>(await this.#e.revokeAutoPair.call({id:e})).ok,`Couldn't revoke that secret.`);return t.ok&&this.#t!==void 0&&await this.load(this.#t,!0),t}},ss=class{#e;decision=new v;saving=new p;preview=new v;search=new v;searchSaving=new p;constructor(e){this.#e=e}async load(e=!1){await this.decision.load(()=>this.#e.suggestDecision.call({}),`Couldn't load the suggestions setting.`,e)}async save(e){let t=await this.saving.run(()=>this.#e.setSuggestDecision.call(e),`Couldn't save the suggestions setting.`);return t.ok&&this.decision.set(t.value),t}async loadSearch(e=!1){await this.search.load(()=>this.#e.searchDecisions.call({}),`Couldn't load the search settings.`,e)}async saveSearch(e,t){let n=await this.searchSaving.run(()=>this.#e.setSearchDecision.call({item:e,value:t}),`Couldn't save the search setting.`);return n.ok&&this.search.set(n.value),n}async try(e,t){await this.preview.load(()=>this.#e.previewSuggestions.call({session:e,text:t}),`Couldn't try the suggestions.`)}},cs=class{#e;setting=new v;saving=new p;constructor(e){this.#e=e}async load(e=!1){await this.setting.load(()=>this.#e.autoClassifier.call({}),`Couldn't load the auto mode classifier.`,e)}async save(e){let t=await this.saving.run(()=>this.#e.setAutoClassifier.call(e),`Couldn't save the auto mode classifier.`);return t.ok&&this.setting.set(t.value),t}},ls=class{#e;setting=new v;saving=new p;constructor(e){this.#e=e}async load(e=!1){await this.setting.load(()=>this.#e.imageEmbedding.call({}),`Couldn't load where pictures are embedded.`,e)}async save(e){let t=await this.saving.run(()=>this.#e.setImageEmbedding.call(e),`Couldn't save where pictures are embedded.`);return t.ok&&this.setting.set(t.value),t}},us=class{#e;list=new v;#t=M(()=>new Map((this.list.value.value??[]).map(e=>[e.id,e])));constructor(e){this.#e=e}async load(e=!1){(e||this.list.value.value===void 0&&!this.list.loading.value)&&await this.list.load(()=>this.#e.actors.call({}),`Couldn't load people and groups.`)}nameOf=e=>this.#t.value.get(e)?.name??e;options(e){return(this.list.value.value??[]).filter(t=>e.includes(t.kind)&&!t.disabled).map(e=>({id:e.id,name:e.name,kind:e.kind,detail:e.kind===`user`?e.email:e.about})).sort((e,t)=>e.name.localeCompare(t.name))}},ds=class{#e;#t=new Set;byRun=B(new Map);problem=z(``);constructor(e){this.#e=e}async load(e){let t=[...new Set(e)].filter(e=>!this.#t.has(e)).slice(0,200);if(t.length!==0){for(let e of t)this.#t.add(e);try{let e=await this.#e.approvals.call({runs:t}),n=new Map(this.byRun.value);for(let t of e)t.status===`pending`&&n.set(t.run,t);this.byRun.value=n,this.problem.value=``}catch(e){for(let e of t)this.#t.delete(e);this.problem.value=J(e)}}}async decide(e,t,n,r){let i=this.byRun.value,a=new Map(i);a.delete(e.run),this.byRun.value=a;try{return await this.#e.approve.call({approval:e.id,approve:t,remember:`once`,...n===``?{}:{reason:n},...r===void 0?{}:{answer:r}}),!0}catch(e){return this.byRun.value=i,this.problem.value=J(e),!1}}};function fs(e){return e.run===void 0?{query:e.query}:{run:e.run}}var ps=class{#e;list;opened=new v;openedId=B(void 0);constructor(e,t){this.#e=e,this.list=new m(e,t)}async open(e){let t=this.openedId.value===e;t||this.opened.reset(),this.openedId.value=e,await this.opened.load(()=>this.#e.one(e),this.#e.oneFailure,t)}close(){this.openedId.value=void 0,this.opened.reset()}},ms=class extends ps{#e;control=new p;constructor(e,t){super(e,{}),this.#e=t}async background(e){let t=await this.control.run(()=>this.#e.background.call({run:e}),`Couldn't move it to the background.`);return t.ok&&this.open(e),t}async undoTurn(e){let t=await this.control.run(()=>this.#e.undoTurn.call({turn:e}),`Couldn't undo the turn.`);return t.ok&&this.list.refresh(),t}};function hs(e,t){return new ms({fetch:(t,n,r)=>e.runs.call(g({query:t},r,n)),key:e=>e.id,failure:`Couldn't load runs.`,limit:50,one:e=>t.run.call({run:e}),oneFailure:`Couldn't load this run.`},t)}function gs(e,t){return new ps({fetch:(t,n,r)=>e.llmCalls.call(g({query:t},r,n)),key:e=>e.id,failure:`Couldn't load LLM calls.`,limit:50,one:e=>t.llmCall.call({id:e}),oneFailure:`Couldn't load this LLM call.`},{})}function _s(e,t){return new ps({fetch:(t,n,r)=>e.modelCalls.call(g(fs(t),r,n)),key:e=>e.id,failure:`Couldn't load model calls.`,limit:50,one:async n=>{let r=await e.modelCall.call({id:n});return r.interaction===void 0?{call:r}:{call:r,interaction:await t.llmCall.call({id:r.interaction})}},oneFailure:`Couldn't load this model call.`},{query:{}})}function vs(e,t){return new ps({fetch:(t,n,r)=>e.resources.call(g({query:t},r,n)),key:e=>e.uri,failure:`Couldn't load resources.`,limit:50,one:e=>t.resource.call({uri:e,want:[`text`,`links`]}),oneFailure:`Couldn't open this resource.`},{})}var ys=class{#e;#t;#n;key=B(void 0);instances=new v;configForm=new v;config=new p;exporting=new p;removing=new p;view=M(()=>this.instances.value.value?.find(e=>e.instance===this.key.value?.instance));constructor(e,t){this.#e=e,this.#t=t}async open(e){let t=this.key.value?.system===e.system&&this.key.value.instance===e.instance;t||this.close(),this.key.value=e,this.#n??=this.#t(e=>{this.#i(e)}),await Promise.all([this.#r(e.system,t),this.configForm.load(async()=>{let t=await this.#e.system.call({system:e.system});return{type:t.configType,secrets:t.configSecrets??[],instanceMode:t.instanceMode,store:t.store}},`Couldn't load this system.`,t)])}close(){this.#n?.(),this.#n=void 0,this.key.value=void 0,this.instances.reset(),this.configForm.reset()}async configure(e){let t=this.key.value;if(t===void 0)return{ok:!1,problems:[`No instance is open.`]};let n=await this.config.run(()=>this.#e.configureSystem.call({system:t.system,instance:t.instance,config:e}),`Couldn't save the config.`);return n.ok?`problems`in n.value?{ok:!1,problems:n.value.problems}:(this.#r(t.system,!0),{ok:!0,version:n.value.version}):{ok:!1,problems:[n.problem]}}async exportData(e,t=this.key.value){return t===void 0?{ok:!1,problem:`No instance is open.`}:this.exporting.run(async()=>{let n=await this.#e.exportSystemData.call({...t,...e?{withSecrets:e}:{}});return{url:n.url,size:n.size}},`Couldn't export this instance's data.`)}async remove(e){let t=this.key.value;if(t===void 0)return!1;let n=await this.removing.run(()=>this.#e.removeInstance.call({...t,...e===void 0?{}:{keepStore:e}}),`Couldn't remove ${t.system}@${t.instance}.`);return n.ok&&n.value.ok}async#r(e,t){await this.instances.load(()=>this.#e.instances.call({system:e}),`Couldn't load this system's instances.`,t)}#i(e){let t=this.key.value;e.type===`system`&&t!==void 0&&e.system===t.system&&this.#r(t.system,!0)}};function bs(e,t){return e.filter(e=>e.decl.routing?.to===`instance`&&e.decl.routing.instance===t)}function xs(e,t,n){return{list:`types`,query:{filters:[{field:`system`,op:`is`,value:e.system},...e.instance===void 0?[]:[{field:`instance`,op:`is`,value:e.instance}]],sort:[{field:`name`,dir:`asc`}],limit:n,...t===void 0?{}:{cursor:t}}}}function Ss(e,t){let n=Xn.safeParse(t.includes(`/`)?t:`${e}/${t}`);return n.success?n.data:void 0}function Cs(e,t){let n=new Set;for(let r of t)for(let t of r.preview?.parts??[]){if(t.type!==`type-diff`)continue;let r=Ss(e,t.name);r!==void 0&&n.add(r)}return n}function ws(e,t){return e.filter(e=>e.status===`awaiting-approval`&&e.instance===t)}function Ts(e){return e.filter(e=>e.proposed===!0&&e.status===`pending`)}function Es(e,t){return[...new Set([...e??[],...Ds(t)])]}function Ds(e,t=``){return e===`•••• kept`?t===``?[]:[t]:Tn(e)?Object.entries(e).flatMap(([e,n])=>Ds(n,t===``?e:`${t}.${e}`)):[]}function Os(e,t,n,r=!1){let i=[{label:`Version`,value:e.version}];return e.address!==void 0&&!r&&i.push({label:`Address`,value:e.address}),i.push({label:`Key`,value:e.keyFingerprint}),e.pairedAt!==void 0&&i.push({label:`Paired`,value:`${Vt(e.pairedAt,t)}${e.pairedBy===void 0?``:` by ${n(e.pairedBy)}`}`,title:vt(e.pairedAt)}),e.lastSeenAt!==void 0&&i.push({label:`Last seen`,value:e.status===`connected`?`Online now`:Vt(e.lastSeenAt,t),title:vt(e.lastSeenAt)}),e.config!==void 0&&i.push({label:`Config`,value:`Version ${e.config.version}, ${Vt(e.config.setAt,t)}`,title:vt(e.config.setAt)}),i.push({label:`Manifest`,value:e.manifestHash,code:!0}),i}var ks=class{#e;#t=B(void 0);fns=new v;types;typeCount=z(void 0);waitingRuns=new v;desk;proposals=M(()=>Ts((this.waitingRuns.value.value??[]).flatMap(e=>{let t=this.desk.byRun.value.get(e.id);return t===void 0?[]:[t]})));changing=M(()=>{let e=this.#t.value;return e===void 0?new Set:Cs(e.system,this.proposals.value)});constructor(e,t){this.#e=e,this.desk=new ds(t),this.types=new m({fetch:async(e,t,n)=>{if(e===void 0)return{items:[]};let r=await this.#e.query.call(xs(e,t,n));return t===void 0&&(this.typeCount.value=r.total),{items:Zn.array().parse(r.items),...r.cursor===void 0?{}:{cursor:r.cursor}}},key:e=>e.name,failure:`Couldn't load this instance's types.`,limit:100},void 0)}async open(e){let t=this.#t.value,n=t?.system===e.system&&t.instance===e.instance;n||this.close(),this.#t.value=e,await Promise.all([this.fns.load(async()=>bs(await this.#e.systemFns.call({system:e.system}),e.instance),`Couldn't load this instance's fns.`,n),this.waitingRuns.load(async()=>{let t=ws((await this.#e.runs.call({query:{filters:[{field:`system`,op:`is`,value:e.system},{field:`status`,op:`is`,value:`awaiting-approval`}],limit:100}})).items,e.instance);return await this.desk.load(t.map(e=>e.id)),t},`Couldn't load the changes waiting for approval.`,n),this.types.load(e)])}async decide(e,t,n){let r=await this.desk.decide(e,t,n),i=this.#t.value;return r&&i!==void 0&&this.open(i),r}close(){this.#t.value=void 0,this.fns.reset(),this.types.load(void 0),this.typeCount.value=void 0,this.waitingRuns.reset()}},As=class{#e;list=new v;create=new p;constructor(e){this.#e=e}async load(e=!1){await this.list.load(()=>this.#e.mcps.call({}),`Couldn't load the MCPs.`,e)}async make(e){let t=await this.create.run(()=>this.#e.createMcp.call(e),`Couldn't make that MCP.`);return t.ok&&this.list.set([...this.list.value.value??[],t.value.mcp]),t}},js=class{#e;#t;id=z(void 0);view=new v;sessions=new v;draft=B(void 0);preview=new v;save=new p;rotate=new p;remove=new p;secret=z(``);tried=new v;changed=M(()=>this.draft.value!==void 0&&JSON.stringify(this.draft.value)!==JSON.stringify(this.view.value.value?.rules));constructor(e,t){this.#e=e,this.#t=t}async open(e,t=``){this.id.value!==e&&this.close(),this.id.value=e,t!==``&&(this.secret.value=t),await this.view.load(()=>this.#e.mcp.call({mcp:e}),`Couldn't load this MCP.`,this.view.value.value?.id===e);let n=this.view.value.value;n!==void 0&&this.draft.value===void 0&&this.edit(n.rules)}close(){this.id.value=void 0,this.view.reset(),this.sessions.reset(),this.preview.reset(),this.tried.reset(),this.draft.value=void 0,this.secret.value=``}edit(e){this.draft.value=e,this.preview.load(()=>this.#e.previewMcp.call({rules:e}),`Couldn't preview these rules.`,this.preview.value.value!==void 0)}revert(){let e=this.view.value.value;e!==void 0&&this.edit(e.rules)}async update(e={}){let t=this.id.value;if(t===void 0)return{ok:!1,problem:`No MCP is open.`};let n=e.rules??this.draft.value,r=await this.save.run(()=>this.#e.updateMcp.call({mcp:t,...e,...n===void 0?{}:{rules:n}}),`Couldn't save the MCP.`);return r.ok&&(this.view.set(r.value),this.draft.value=r.value.rules),r}async rotateSecret(){let e=this.id.value;if(e===void 0)return{ok:!1,problem:`No MCP is open.`};let t=await this.rotate.run(()=>this.#e.rotateMcpSecret.call({mcp:e}),`Couldn't rotate the secret.`);return t.ok&&(this.secret.value=t.value.secret,this.sessions.set([])),t}async delete(){let e=this.id.value;if(e===void 0)return!1;let t=await this.remove.run(()=>this.#e.deleteMcp.call({mcp:e}),`Couldn't delete the MCP.`);return t.ok&&t.value.ok}async loadSessions(e=!1){let t=this.id.value;t!==void 0&&await this.sessions.load(()=>this.#e.mcpSessions.call({mcp:t}),`Couldn't load this MCP's sessions.`,e)}async tryIt(e){let t=this.view.value.value,n=e.trim()===``?this.secret.value:e.trim();t!==void 0&&n!==``&&await this.tried.load(()=>this.#t.tools(t.url,n),`Couldn't reach the MCP with that secret.`)}},Ms=Cn.parse(`mcp`),Ns={http:{label:`HTTP`,about:`Streamable HTTP: a URL the server answers on (MCP 2025-03-26 and later).`},sse:{label:`SSE`,about:`The older HTTP + SSE transport (MCP 2024-11-05).`},stdio:{label:`Command`,about:`A program the hub starts on its own machine; credentials go in its environment.`}},Ps={writes:{label:`Writes`,about:`Calls wait for approval unless a trusted server marks the tool read-only.`},always:{label:`Always`,about:`Every call waits for approval.`},never:{label:`Never`,about:`No call waits (policies still apply).`}},Fs={connecting:{tone:`accent`,word:`Connecting`,live:!0},connected:{tone:`ok`,word:`Connected`,live:!1},"needs-auth":{tone:`warn`,word:`Needs sign-in`,live:!1},unreachable:{tone:`danger`,word:`Unreachable`,live:!1},failed:{tone:`danger`,word:`Failed`,live:!1}},Is=kn.pick({trusted:!0,approval:!0,prompts:!0,resources:!0,maxTools:!0,timeout:!0}).parse({});function Ls(e){let t=Gr(e,rr),n=Vs(e),r=n?.transport,i=n??Is;return{label:n?.label??``,description:n?.description??``,transport:r?.type??`http`,command:r?.type===`stdio`?r.command:``,args:r?.type===`stdio`?r.args:[],env:r?.type===`stdio`?Kr(r.env):[],envKept:t.has(`transport.env`),cwd:r?.type===`stdio`?r.cwd??``:``,url:r!==void 0&&r.type!==`stdio`?r.url:``,auth:Jr(n?.auth,t),trusted:i.trusted,approval:i.approval,prompts:i.prompts,resources:i.resources,maxTools:String(i.maxTools),timeout:String(i.timeout/1e3)}}function Rs(e){if(e.transport!==`stdio`)return{type:e.transport,url:e.url.trim()};let t=e.envKept?void 0:ei(e.env),n=qr(e.cwd);return{type:`stdio`,command:e.command.trim(),args:[...e.args],...t===void 0?{}:{env:t},...n===void 0?{}:{cwd:n}}}function zs(e){let t=e.transport===`stdio`?{auth:{kind:`none`},kept:[]}:Qr(e.auth),n=qr(e.description),r=Yr(e.maxTools),i=Yr(e.timeout,1e3),a={label:e.label.trim(),...n===void 0?{}:{description:n},transport:Rs(e),auth:t.auth,trusted:e.trusted,approval:e.approval,prompts:e.prompts,resources:e.resources,...r===void 0?{}:{maxTools:r},...i===void 0?{}:{timeout:i}},o=[...t.kept,...e.transport===`stdio`&&e.envKept?[`transport.env`]:[]];return Xr(kn,a,o)}function Bs(e){let t=e.transport;return t.type===`stdio`?[t.command,...t.args].join(` `):t.url}function Vs(e){let t=kn.safeParse(Zr(e,rr));return t.success?t.data:void 0}function Hs(e){let t=(e,t)=>`${e} ${e===1?t:`${t}s`}`;return[t(e.tools,`tool`),t(e.prompts,`prompt`),t(e.resources,`resource`)].join(` · `)}function Us(e){return Vn(e,`x`).slice(0,-1)}function Ws(e,t,n){let r=`${t}/${Us(n)}`;return e.filter(e=>e.name.startsWith(r))}function Gs(e){return e.decl.command===void 0?void 0:`/${e.decl.command.name}`}function Ks(e,t,n){return e?.degraded.some(e=>n.endsWith(`/${Vn(t,e)}`))===!0}function qs(e,t){return e===`connected`?t===void 0?Fs.connecting:`status`in t?Fs[t.status.state]:{tone:`warn`,word:`Status unknown`,live:!1}:Hr[e]}var Js=class{#e;system;list=new v;adding=new p;saving=new p;removing=new p;storeDecl=B(void 0);constructor(e,t){this.#e=e,this.system=t}async load(e=!1){await Promise.all([this.list.load(()=>this.#e.instances.call({system:this.system}),`Couldn't load the list.`,e),this.#t()])}async#t(){let e=await this.#e.system.call({system:this.system}).catch(()=>void 0);this.storeDecl.value=e?.store}find(e){return this.list.value.value?.find(t=>t.instance===e)}async add(e,t,n,r){let i=await this.adding.run(()=>this.#e.addInstance.call({system:this.system,instance:e,config:t,...n===void 0?{}:{description:n},...r===void 0?{}:{store:r}}),`Couldn't add ${e}.`);return i.ok&&this.load(!0),i}async configure(e,t){let n=await this.saving.run(()=>this.#e.configureSystem.call({system:this.system,instance:e,config:t}),`Couldn't save the settings.`);return n.ok?`problems`in n.value?{ok:!1,problems:n.value.problems}:(this.load(!0),{ok:!0,version:n.value.version}):{ok:!1,problems:[n.problem]}}async remove(e,t){let n=await this.removing.run(()=>this.#e.removeInstance.call({system:this.system,instance:e,...t===void 0?{}:{keepStore:t}}),`Couldn't remove ${e}.`);return n.ok&&n.value.ok&&this.list.set((this.list.value.value??[]).filter(t=>t.instance!==e)),n.ok&&n.value.ok}},Ys=Xn.parse(`${Ms}/server_status`);function Xs(e){return{list:`contexts`,query:{filters:[{field:`system`,op:`is`,value:Ms},{field:`name`,op:`contains`,value:Us(e)}],sort:[{field:`name`,dir:`asc`}],limit:200}}}var Zs=class{#e;fleet;statuses=B(new Map);open=B(void 0);tools=new v;prompts=new v;constructor(e){this.#e=e,this.fleet=new Js(e,Ms)}async load(e=!1){await this.fleet.load(e),await Promise.all((this.fleet.list.value.value??[]).map(e=>this.readStatus(e.instance)))}async readStatus(e){let t;try{let n=await this.#e.readFn.call({fn:Ys,args:{instance:e}}),r=Mn.safeParse(n);t=r.success?{status:r.data}:{problem:`Its status came back in a shape this page does not know.`}}catch(e){t={problem:J(e,`Couldn't read its status.`)}}this.statuses.value=new Map([...this.statuses.value,[e,t]])}statusOf(e){let t=this.statuses.value.get(e);return t!==void 0&&`status`in t?t.status:void 0}async show(e){let t=this.open.value===e;t||this.close(),this.open.value=e,await Promise.all([this.fleet.load(this.fleet.list.value.value!==void 0),this.readStatus(e),this.tools.load(async()=>bs(await this.#e.systemFns.call({system:Ms}),e),`Couldn't load its tools.`,t),this.prompts.load(async()=>{let t=await this.#e.query.call(Xs(e));return Ws(tr.array().parse(t.items),Ms,e)},`Couldn't load its prompts.`,t)])}close(){this.open.value=void 0,this.tools.reset(),this.prompts.reset()}},Qs=Cn.parse(`api`),$s=Xn.parse(Dn),ec=[`none`,`bearer`,`headers`],tc=zn.pick({timeout:!0,maxBody:!0}).parse({});function nc(e){let t=zn.safeParse(e);return t.success?t.data:void 0}function rc(e){let t=e??tc;return{name:e?.name??``,label:e?.label??``,description:e?.description??``,baseUrl:e?.baseUrl??``,auth:Jr(e?.auth),headers:Kr(e?.headers),openapi:e?.openapi??``,timeout:String(t.timeout/1e3),maxBody:String(Math.round(t.maxBody/1024)),allowPrivate:e?.allowPrivate??!1,shared:e?.privateTo===void 0,privateTo:e?.privateTo}}function ic(e){return e.name.trim()===``?$r(e.label)??``:e.name.trim()}function ac(e){let{auth:t}=Qr(e.auth),n=qr(e.description),r=ei(e.headers),i=qr(e.openapi),a=Yr(e.timeout,1e3),o=Yr(e.maxBody,1024),s=jr(zn,{name:ic(e),label:e.label.trim(),...n===void 0?{}:{description:n},baseUrl:e.baseUrl.trim(),auth:t,...r===void 0?{}:{headers:r},...i===void 0?{}:{openapi:i},...a===void 0?{}:{timeout:a},...o===void 0?{}:{maxBody:o},allowPrivate:e.allowPrivate,...e.shared||e.privateTo===void 0?{}:{privateTo:e.privateTo}});return s.ok?{ok:!0,service:s.value}:s}function oc(e,t=100){let n=e.trim();return{type:$s,query:{limit:t,...n===``?{sort:[{field:`label`,dir:`asc`}]}:{}},...n===``?{}:{search:n}}}function sc(e){return{type:$s,query:{filters:[{field:`name`,op:`is`,value:e}],limit:1}}}function cc(e,t=100){return{filters:[{field:`system`,op:`is`,value:Qs},{field:`name`,op:`contains`,value:`${Qs}/${e}.`}],limit:t}}function lc(e){let t=nr.safeParse(e);return t.success?t.data:void 0}function uc(e){let t=nc(e.value);return t===void 0?void 0:{id:e.id,version:e.version,service:t}}var dc=class{#e;list=new v;#t=B(``);open=B(void 0);service=new v;fns=new v;saving=new p;removing=new p;constructor(e){this.#e=e}async load(e=this.#t.value,t=!1){this.#t.value=e,await this.list.load(async()=>(await this.#e.records.call(oc(e))).items.flatMap(e=>uc(e)??[]),`Couldn’t load the API services.`,t)}async show(e){let t=this.open.value===e;t||this.close(),this.open.value=e,await Promise.all([this.service.load(async()=>{let[t]=(await this.#e.records.call(sc(e))).items;return t===void 0?void 0:uc(t)},`Couldn’t load the service.`,t),this.fns.load(async()=>(await this.#e.fns.call(cc(e))).items,`Couldn’t load its fns.`,t)])}close(){this.open.value=void 0,this.service.reset(),this.fns.reset()}async save(e,t){return this.saving.run(async()=>{if(t===void 0&&(await this.#e.records.call(sc(e.name))).items.length>0)throw new Mr(`There is a service named ${e.name} already: give the new one another name.`);let n=uc(await this.#e.saveRecord.call({type:$s,value:Qn.parse(e),...t===void 0?{}:{id:t.id,expect:t.version}}));if(n===void 0)throw new Mr(`The hub kept something that is not a service.`);return this.open.value===n.service.name&&this.service.set(n),this.load(this.#t.value,!0),n},`Couldn’t save the service.`)}async remove(e){let t=await this.removing.run(async()=>(await this.#e.removeRecord.call({type:$s,id:e.id})).removed,`Couldn’t remove the service.`);return t.ok&&this.load(this.#t.value,!0),t.ok&&t.value}};async function fc(e,t,n,r,i,a){let o=n.type===``?`application/octet-stream`:n.type,{url:s,upload:c}=await e.upload.call({name:r,mime:o,size:n.size});return await t.put(s,n,i,a),e.uploaded.call({upload:c})}var pc={make:e=>e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,revoke:e=>{URL.revokeObjectURL(e)}},mc=class{#e;#t;#n;#r=new Map;#i=1;items=B([]);busy=M(()=>this.items.value.some(e=>e.status===`uploading`));parts=M(()=>this.items.value.flatMap(e=>e.ref===void 0?[]:[{type:`file`,ref:e.ref,name:e.name}]));constructor(e,t,n=pc){this.#e=e,this.#t=t,this.#n=n}add(e){for(let t of e){let e=this.#i++,n=this.#n.make(t);this.#r.set(e,{file:t,abort:new AbortController}),this.items.value=[...this.items.value,{id:e,name:t.name===``?`pasted file`:t.name,size:t.size,mime:t.type,status:`uploading`,progress:0,...n===void 0?{}:{preview:n}}],this.#a(e)}}remove(e){this.#r.get(e)?.abort.abort(),this.#r.delete(e);let t=this.items.value.find(t=>t.id===e);t?.preview!==void 0&&this.#n.revoke(t.preview),this.items.value=this.items.value.filter(t=>t.id!==e)}retry(e){let t=this.#r.get(e);t!==void 0&&(this.#r.set(e,{file:t.file,abort:new AbortController}),this.#o(e,{status:`uploading`,progress:0}),this.#a(e))}clear(){for(let e of[...this.#r.keys()])this.remove(e)}async#a(e){let t=this.#r.get(e);if(t!==void 0)try{let n=await fc(this.#e,this.#t,t.file,t.file.name===``?`pasted file`:t.file.name,t=>{this.#o(e,{progress:t})},t.abort.signal);this.#o(e,{status:`ready`,progress:1,ref:n})}catch(t){if(!this.#r.has(e))return;this.#o(e,{status:`failed`,problem:J(t,t instanceof Error?t.message:`Upload failed.`)})}}#o(e,t){this.items.value=this.items.value.map(n=>n.id===e?{...n,...t}:n)}};function hc(e){return/\.zip$/i.test(e.name)}var gc=class{#e;#t;install=new p;progress=z(0);#n;constructor(e,t){this.#e=e,this.#t=t}async installZip(e,t){if(!hc(e))return{ok:!1,problem:`A package is a .zip made by harness system pack.`};let n=t.instance.trim();if(n!==``&&!Gn.safeParse(n).success)return{ok:!1,problem:`An instance name is lowercase letters, digits and dashes, starting with a letter.`};this.#n=new AbortController;let r=this.#n.signal;return this.progress.value=0,this.install.run(async()=>{let i=await fc(this.#e,this.#t,e,e.name,e=>{this.progress.value=e},r),a=t.data===void 0?void 0:await fc(this.#e,this.#t,t.data,t.data.name,()=>void 0,r);return this.#e.installPackage.call({zip:i,autoStart:t.autoStart,...n===``?{}:{instance:Gn.parse(n)},...t.config===void 0?{}:{config:t.config},...a===void 0?{}:{data:a},...t.store===void 0?{}:{store:t.store}})},`Couldn't install that package.`)}cancel(){this.#n?.abort()}},_c=2e3;function vc(e){return e!==void 0&&e.phase!==`done`&&e.phase!==`failed`}function yc(e){let t=e?.status?.state;return e?.holding===!0||t===`preparing`||t===`migrating`||t===`moving`||vc(e?.move)}var bc=class{#e;view=new v;moveTask=new p;answering=new p;deleting=new p;deletedNote=z(``);#t;#n;constructor(e){this.#e=e}async open(e,t,n=!1){let r=this.#t?.system!==e||this.#t.instance!==t;r&&this.close(),this.#t={system:e,instance:t},await this.view.load(()=>this.#e.systemStore.call({system:e,...t===void 0?{}:{instance:t}}),`Couldn't read its storage.`,n&&!r),this.#a()}async refresh(){this.#t!==void 0&&await this.open(this.#t.system,this.#t.instance,!0)}async move(e){if(this.#t===void 0)return{ok:!1,problem:`No store is open.`};let t=await this.moveTask.run(()=>this.#e.systemStoreMove.call({...this.#r(),to:e}),`Couldn't start the move.`);return t.ok&&this.#i(t.value),this.refresh(),t}async answer(e){let t=await this.answering.run(()=>this.#e.systemStoreMoveAnswer.call({...this.#r(),answer:e}),`Couldn't answer the move.`);return t.ok&&this.#i(t.value),this.refresh(),t}async deleteBackup(e){this.deletedNote.value=``;let t=await this.deleting.run(()=>this.#e.systemStoreBackupDelete.call({...this.#r(),backup:e}),`Couldn't delete that backup.`);if(!t.ok)return!1;this.deletedNote.value=t.value.note??``;let n=this.view.value.value;return n!==void 0&&this.view.set({...n,backups:n.backups.filter(t=>t.id!==e)}),this.refresh(),!0}close(){this.#n!==void 0&&clearTimeout(this.#n),this.#n=void 0,this.#t=void 0,this.deletedNote.value=``,this.view.reset()}#r(){let e=this.#t;if(e===void 0)throw Error(`no store is open`);return{system:e.system,...e.instance===void 0?{}:{instance:e.instance}}}#i(e){let t=this.view.value.value;t!==void 0&&this.view.set({...t,move:e}),this.#a()}#a(){this.#n!==void 0&&clearTimeout(this.#n),this.#n=void 0,this.#t!==void 0&&yc(this.view.value.value)&&(this.#n=setTimeout(()=>{this.refresh()},_c))}},X={hub:`Hub`,group:`Group`,user:`Person`,session:`Chat`,turn:`Message`,system:`System`,fn:`Fn`,model:`Model`},xc=[`hub`,`group`,`user`,`session`,`system`,`fn`,`model`],Sc=[`hub`,`group`,`user`,`session`,`turn`],Cc={urgent:`Urgent`,interactive:`Interactive`,normal:`Normal`,background:`Background`};function wc(e,t){switch(e.scope){case`hub`:return`Whole hub`;case`group`:return`${X.group}: ${t(e.group)}`;case`user`:return`${X.user}: ${t(e.user)}`;case`session`:return`${X.session}: ${e.session}`;case`turn`:return`${X.turn}: ${e.turn}`;case`system`:return`${X.system}: ${e.system}`;case`fn`:return`${X.fn}: ${rn(e.fn)}`;case`model`:return`${X.model}: ${e.model}`}}var Tc=[{label:`Hour`,ms:36e5},{label:`Day`,ms:864e5},{label:`Week`,ms:6048e5},{label:`30 days`,ms:2592e6}];function Ec(e){if(e===`all-time`)return`all time`;if(e===`per-turn`)return`per message`;let t=Tc.find(t=>t.ms===e.window);return t===void 0?`per ${it(e.window)}`:`per ${t.label.toLowerCase()}`}var Dc={refuse:`Refuses`,wait:`Waits for room`,ask:`Asks to raise it`};function Oc(e){let t=e.maxCost<=0?1:Math.min(1,Math.max(0,e.spent/e.maxCost));return{fraction:t,tone:t>=1?`danger`:t>=.8?`warn`:`ok`}}function kc(e){let t=[`${st(e.maxCost)} ${Ec(e.period)}`];return e.maxTokens!==void 0&&t.push(`${e.maxTokens.toLocaleString()} tokens`),e.maxCalls!==void 0&&t.push(`${e.maxCalls.toLocaleString()} calls`),e.maxTime!==void 0&&t.push(`${it(e.maxTime)} each`),t.join(` · `)}function Ac(e){let t=`${X[e.priorityFrom.default].toLowerCase()} default`,n=e.priorityFrom.cappedBy===void 0?``:`, capped by the ${X[e.priorityFrom.cappedBy].toLowerCase()}`;return{priority:`${Cc[e.priority]}, from the ${t}${n}.`,turn:`Each message may spend up to ${st(e.turn.cost)} and run for ${it(e.turn.time)}.`,tightest:e.limitedBy===void 0?-1:e.budgets.findIndex(t=>t.rule===e.limitedBy)}}var jc={setBudget:Rn.endpoints.setBudget.cfg.body,setPriority:Rn.endpoints.setPriority.cfg.body,setPolicy:Rn.endpoints.setPolicy.cfg.body,setModelCategory:Rn.endpoints.setModelCategory.cfg.body,createPairingToken:Rn.endpoints.createPairingToken.cfg.body,upgradeSystem:Rn.endpoints.upgradeSystem.cfg.body},Mc=e=>e.trim()===``?void 0:Number(e),Nc=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``)),Pc=e=>e===void 0?``:String(e),Fc={group:`group`,user:`user`};function Ic(e){return e.level===`hub`?{scope:`hub`}:{scope:e.level,[e.level]:e.target.trim()}}function Lc(e){let t=e[e.scope];return{level:e.scope,target:typeof t==`string`?t:``}}function Rc(e){let t=e?.period;return{scope:e===void 0?{level:`hub`,target:``}:Lc(e.target),period:t===void 0||typeof t==`object`?`window`:t,window:t!==void 0&&typeof t==`object`?t.window:Tc[1].ms,maxCost:e===void 0?``:String(e.maxCost),maxTokens:Pc(e?.maxTokens),maxCalls:Pc(e?.maxCalls),maxTime:e?.maxTime===void 0?``:String(e.maxTime/1e3),share:e?.share??`pooled`,onLimit:e?.onLimit??`refuse`}}function zc(e){let t=e.period===`window`?{window:e.window}:e.period,n=Mc(e.maxTime);return Y(jc.setBudget,Nc({target:Ic(e.scope),period:t,maxCost:Mc(e.maxCost)??NaN,maxTokens:Mc(e.maxTokens),maxCalls:Mc(e.maxCalls),maxTime:e.period===`per-turn`&&n!==void 0?Math.round(n*1e3):void 0,share:e.scope.level===`group`?e.share:void 0,onLimit:e.onLimit}))}function Bc(e){return{scope:e===void 0?{level:`hub`,target:``}:Lc(e.target),default:e?.default??``,max:e?.max??``}}function Vc(e){return e.default===``&&e.max===``?{ok:!1,problems:{default:`Set a default, a ceiling, or both.`}}:Y(jc.setPriority,Nc({target:Ic(e.scope),default:e.default,max:e.max}))}function Hc(e){let t=e?.subject,n=e?.decision,r=n?.effect===`ask`?n.approver:void 0;return{description:e?.description??``,subject:t===void 0||`everyone`in t?`everyone`:`actor`in t?`actor`:`group`in t?`group`:`kind`,subjectValue:t===void 0||`everyone`in t?``:`actor`in t?t.actor:`group`in t?t.group:t.kind,fn:e?.target.fn??``,system:e?.target.system??``,kind:e?.target.kind??``,tags:[...e?.target.tags??[]],effect:n?.effect??`ask`,reason:n?.effect===`deny`?n.reason:``,approver:r?.by??`turn-user`,approverValue:r===void 0?``:r.by===`actor`?r.actor:r.by===`group`?r.group:r.by===`judge`?r.fn:``,quorum:r?.by===`group`?Pc(r.quorum):``,priority:String(e?.priority??0)}}function Uc(e){let t=e.subjectValue.trim(),n=e.subject===`everyone`?{everyone:!0}:{[e.subject]:t},r=e.tags.map(e=>e.trim()).filter(e=>e!==``),i=Nc({fn:e.fn.trim(),system:e.system.trim(),kind:e.kind.trim(),tags:r.length===0?void 0:r}),a=e.approverValue.trim(),o=e.approver===`actor`?{by:`actor`,actor:a}:e.approver===`group`?Nc({by:`group`,group:a,quorum:Mc(e.quorum)}):e.approver===`judge`?{by:`judge`,fn:a}:{by:e.approver},s=e.effect===`allow`?{effect:`allow`}:e.effect===`deny`?{effect:`deny`,reason:e.reason.trim()}:{effect:`ask`,approver:o};return e.effect===`deny`&&e.reason.trim()===``?{ok:!1,problems:{decision:`Say why, for the people it stops.`}}:e.description.trim()===``?{ok:!1,problems:{description:`Required.`}}:Y(jc.setPolicy,{description:e.description.trim(),subject:n,target:i,decision:s,priority:Mc(e.priority)??0})}function Wc(e){return{name:e?.name??``,description:e?.description??``,models:e?.models??[]}}function Gc(e){return e.name.trim()===``?{ok:!1,problems:{name:`Required.`}}:e.models.length===0?{ok:!1,problems:{models:`Add at least one model.`}}:Y(jc.setModelCategory,{name:e.name.trim(),description:e.description.trim(),models:[...e.models]})}var Kc=[{value:`keys`,label:`Access keys`},{value:`apiKey`,label:`API key`}],qc={apiKey:{label:`API key`,secret:!0},baseURL:{label:`Base URL`,secret:!1},contextWindow:{label:`Context window (tokens)`,secret:!1,kind:`number`},decisionModels:{label:`Decision models`,secret:!1,kind:`list`,placeholder:`qwen3-systemone`,hint:`System One models to treat as decision models, comma separated. Only needed when the server’s /api/show lists no capabilities; newer servers say so themselves.`},region:{label:`Region`,secret:!1,placeholder:`us-east-1`},accessKeyId:{label:`Access key ID`,secret:!1},secretAccessKey:{label:`Secret access key`,secret:!0},sessionToken:{label:`Session token`,secret:!0,hint:`Only for temporary credentials.`},profilePrefix:{label:`Inference profile prefix`,secret:!1,placeholder:`us.`,hint:`Left empty, one is picked for the region.`}},Jc={openai:`OpenAI`,openrouter:`OpenRouter`,ollama:`Ollama`,aws:`Amazon Bedrock`};function Yc(e){let t=nn.safeParse(e);return t.success?Jc[t.data]:e}var Xc=e=>e in qc;function Zc(e){let t=Pn.options.find(t=>t.shape.provider.value===e);if(t===void 0)throw Error(`No provider input schema for ${e}`);return t}function Qc(e){let t=Zc(`aws`).shape;if(!(`auth`in t))throw Error(`The AWS provider input has no sign-in`);let n=t.auth.options.find(t=>t.shape.kind.value===e);if(n===void 0)throw Error(`No AWS sign-in schema for ${e}`);return n}function $c(e){return Object.entries(e).flatMap(([e,t])=>Xc(e)?[{name:e,...qc[e],required:!t.safeParse(void 0).success}]:[])}function el(e,t=`keys`){let n=Zc(e).shape;if(e!==`aws`)return $c(n);let r=$c(n);return[...r.filter(e=>e.name===`region`),...$c(Qc(t).shape),...r.filter(e=>e.name!==`region`)]}function tl(e,t,n=`keys`){let r=e=>Nc(Object.fromEntries(e.map(e=>[e.name,nl(e,t[e.name])]))),i=e===`aws`?$c(Qc(n).shape):[],a=el(e,n).filter(e=>!i.includes(e)),o=e===`aws`?{provider:e,...r(a),auth:{kind:n,...r(i)}}:{provider:e,...r(a)},s=Y(Zc(e),o);if(s.ok)return{ok:!0,value:s.value};let c={},l=e===`aws`&&`auth`in s.problems?{...s.problems,...rl(n,o)}:s.problems;for(let[e,t]of Object.entries(l))Xc(e)&&(c[e]=t);return{ok:!1,problems:c}}function nl(e,t){let n=t?.trim();if(n!==void 0&&n!==``){if(e.kind===`number`)return Number(n);if(e.kind===`list`){let e=n.split(/[,\n]/).map(e=>e.trim()).filter(e=>e!==``);return e.length===0?void 0:e}return n}}function rl(e,t){let n=Y(Qc(e),t.auth);return n.ok?{}:n.problems}var il=[`package`,`path`,`git`];function al(e){let t=Wn.options.find(t=>e in t.shape);if(t===void 0)throw Error(`No install source schema for ${e}`);return t}function ol(e){return Object.keys(al(e).shape).filter(cl)}var sl={package:!0,version:!0,path:!0,git:!0,ref:!0,zip:!0,file:!0},cl=e=>Object.hasOwn(sl,e);function ll(e){let t=ol(e.kind),n=Object.fromEntries(t.map(t=>[t,(e.fields[t]??``).trim()])),r=Y(al(e.kind),n),i=r.ok?{}:r.problems,a={};for(let e of t){let t=n[e]===``?`Required.`:i[e];t!==void 0&&(a[e]=t)}return r.ok&&Object.keys(a).length===0?{ok:!0,value:r.value}:{ok:!1,problems:a}}var ul=[{label:`15 minutes`,ms:9e5},{label:`1 hour`,ms:36e5},{label:`1 day`,ms:864e5}],dl=[{label:`90 days`,ms:7776e6},{label:`30 days`,ms:2592e6},{label:`1 year`,ms:31536e6},{label:`Never ends`,ms:null}];function fl(e){return e===void 0?{}:{autoPair:e}}function pl(e,t){let n=e.trim(),r=Y(jc.createPairingToken,n===``?{expiresIn:t}:{name:n,expiresIn:t});return r.ok?r:{ok:!1,problems:{...r.problems,...r.problems.name===void 0?{}:{name:`Lowercase letters, digits and dashes, starting with a letter.`}}}}var ml=class{#e;#t;#n;#r;request=new v;answer=new p;system=z(void 0);status=B(void 0);#i=z(void 0);phase=M(()=>{if(this.#i.value===`refused`)return`refused`;if(this.answer.busy.value)return`pairing`;if(this.#i.value===`approved`)return this.status.value===`connected`?`connected`:this.status.value===`needs-config`?`needs-config`:`joining`;let e=this.request.value.value;return e===void 0?`loading`:e.status===`expired`||e.expiresAt<=this.#n()?`expired`:e.status===`pending`?`waiting`:`elsewhere`});constructor(e,t,n=Date.now){this.#e=e,this.#t=t,this.#n=n}async open(e){this.request.value.value?.id!==e&&this.close(),this.#r??=this.#t(e=>{this.#a(e)}),await this.request.load(()=>this.#e.pairing.call({pairing:e}),`Couldn't load this pairing request. It may have expired or been answered.`)}close(){this.#r?.(),this.#r=void 0,this.request.reset(),this.system.value=void 0,this.status.value=void 0,this.#i.value=void 0}codeMatches(e){let t=this.request.value.value;return t===void 0?!1:t.code===void 0||t.code===e.trim()}async approve(e,t,n,r){let i=this.request.value.value;if(i===void 0)return{ok:!1,problem:`No pairing request is open.`};let a=await this.answer.run(()=>this.#e.approvePairing.call({pairing:i.id,approve:!0,...e===void 0?{}:{instance:e},...t===void 0?{}:{config:t},...fl(n),...r===void 0?{}:{store:r}}),`Couldn't pair it.`);return a.ok&&(this.#i.value=`approved`,this.system.value=a.value.system??i.name,this.status.value??=`pairing`),a}async refuse(){let e=this.request.value.value;if(e===void 0)return!1;let t=await this.answer.run(()=>this.#e.approvePairing.call({pairing:e.id,approve:!1}),`Couldn't refuse it.`);return t.ok&&(this.#i.value=`refused`),t.ok}#a(e){let t=this.request.value.value;if(e.type===`pairing`&&t!==void 0&&e.pairing.id===t.id){this.request.set(e.pairing);return}let n=this.system.value??t?.name;e.type===`system`&&e.system===n&&(this.status.value=e.status)}},hl=class{#e;budgets=new v;priorities=new v;resolved=new v;save=new p;remove=new p;constructor(e){this.#e=e}async load(e=!1){await Promise.all([this.#t(e),this.#n(e)])}async saveBudget(e){let t=await this.save.run(()=>this.#e.setBudget.call(e),`Couldn't save the budget.`);return t.ok&&this.#t(!0),t}async savePriority(e){let t=await this.save.run(()=>this.#e.setPriority.call(e),`Couldn't save the priority rule.`);return t.ok&&this.#n(!0),t}async removeBudget(e){let t=await this.remove.run(()=>this.#e.removeRule.call({kind:`budget`,id:e}),`Couldn't remove the budget.`);return t.ok&&this.budgets.set((this.budgets.value.value??[]).filter(t=>t.id!==e)),t.ok}async removePriority(e){let t=await this.remove.run(()=>this.#e.removeRule.call({kind:`priority`,id:e}),`Couldn't remove the priority rule.`);return t.ok&&this.priorities.set((this.priorities.value.value??[]).filter(t=>t.id!==e)),t.ok}async resolve(e,t){await this.resolved.load(()=>this.#e.resolveLimits.call({user:e,...t===void 0?{}:{session:t}}),`Couldn't work out the limits.`)}#t(e){return this.budgets.load(()=>this.#e.budgets.call({}),`Couldn't load budgets.`,e)}#n(e){return this.priorities.load(()=>this.#e.priorityRules.call({}),`Couldn't load priority rules.`,e)}},gl=class{#e;providers=new v;models=new v;categories=new v;save=new p;remove=new p;modelIds=M(()=>(this.models.value.value??[]).map(e=>e.id).sort());constructor(e){this.#e=e}async load(e=!1){await Promise.all([this.providers.load(()=>this.#e.providers.call({}),`Couldn't load providers.`,e),this.models.load(()=>this.#e.models.call({}),`Couldn't load models.`,e),this.categories.load(()=>this.#e.modelCategories.call({}),`Couldn't load model categories.`,e)])}async saveProvider(e){let t=await this.save.run(()=>this.#e.configureProvider.call(e),`Couldn't save the provider.`);return t.ok&&this.load(!0),t}async saveCategory(e){let t=await this.save.run(()=>this.#e.setModelCategory.call(e),`Couldn't save the category.`);return t.ok&&this.categories.load(()=>this.#e.modelCategories.call({}),`Couldn't load model categories.`,!0),t}async removeCategory(e){let t=await this.remove.run(()=>this.#e.removeRule.call({kind:`category`,id:e}),`Couldn't remove the category.`);return t.ok&&this.categories.set((this.categories.value.value??[]).filter(t=>t.id!==e)),t.ok}async removeProvider(e){let t=await this.remove.run(()=>this.#e.removeRule.call({kind:`provider`,id:e}),`Couldn't remove the provider.`);return t.ok&&this.load(!0),t.ok}},_l={user:{plural:`people`,label:`People`},group:{plural:`groups`,label:`Groups`},agent:{plural:`agents`,label:`Agents`},system:{plural:`systems`,label:`Systems`},mcp:{plural:`MCP clients`,label:`MCP clients`}};function vl(e,t){return`actor`in e?t(e.actor):`group`in e?`Group ${t(e.group)}`:`kind`in e?`All ${_l[e.kind].plural}`:`Everyone`}function yl(e){let t=[];if(e.fn!==void 0){let n=Xn.safeParse(e.fn);t.push(n.success&&!e.fn.includes(`*`)?rn(n.data):e.fn)}return e.system!==void 0&&t.push(`fns of ${e.system}`),e.kind!==void 0&&t.push(e.kind===`native`?`native fns`:`${e.kind} fns`),e.tags!==void 0&&e.tags.length>0&&t.push(`tagged ${e.tags.join(`, `)}`),e.when!==void 0&&t.push(`when its args match`),t.length===0?`any fn`:t.join(`, `)}function bl(e,t){switch(e.by){case`turn-user`:return`the message's sender`;case`actor`:return t(e.actor);case`group`:return`group ${t(e.group)}${e.quorum===void 0?``:` (${e.quorum} needed)`}`;case`judge`:return`the judge ${rn(e.fn)}`;case`hub`:return`the hub`;case`admins`:return`an admin`}}function xl(e,t){switch(e.effect){case`allow`:return{word:`Allow`,detail:`runs without asking`,tone:`ok`};case`deny`:return{word:`Deny`,detail:e.reason,tone:`danger`};case`ask`:return{word:`Ask`,detail:`asks ${bl(e.approver,t)}`,tone:`warn`}}}function Sl(e){let t={deny:0,ask:1,allow:2};return[...e].sort((e,n)=>n.priority-e.priority||t[e.decision.effect]-t[n.decision.effect])}var Cl=class{#e;list=new v;sorted=M(()=>Sl(this.list.value.value??[]));save=new p;remove=new p;constructor(e){this.#e=e}async load(e=!1){await this.list.load(()=>this.#e.policies.call({}),`Couldn't load policies.`,e)}async savePolicy(e){let t=await this.save.run(()=>this.#e.setPolicy.call(e),`Couldn't save the policy.`);return t.ok&&this.load(!0),t}async removePolicy(e){let t=await this.remove.run(()=>this.#e.removeRule.call({kind:`policy`,id:e}),`Couldn't remove the policy.`);return t.ok&&this.list.set((this.list.value.value??[]).filter(t=>t.id!==e)),t.ok}},wl=class{#e;users;groups;person=new v;members=new v;signIn=new v;checks=B(new Map);checking=B(void 0);test=new v;save=new p;constructor(e){this.#e=e,this.users=new m({fetch:(t,n,r)=>e.people.call(g(t,r,n)),key:e=>e.id,failure:`Couldn’t load the people.`,limit:50},{}),this.groups=new m({fetch:(t,n,r)=>e.groups.call(g(t,r,n)),key:e=>e.id,failure:`Couldn’t load the groups.`,limit:50},{})}openPerson(e,t=!1){return this.person.load(async()=>(await this.#e.people.call({filters:[{field:`email`,op:`is`,value:e}],limit:1})).items[0],`Couldn’t load them.`,t)}openGroup(e,t=!1){return this.members.load(()=>this.#e.groupMembers.call({group:e,limit:200}),`Couldn’t load the group.`,t)}loadSignIn(e=!1){return this.signIn.load(()=>this.#e.signInSettings.call({}),`Couldn’t load how people sign in.`,e)}loadTest(e){return this.test.load(()=>this.#e.ssoTestResult.call({test:e}),`Couldn’t read the test sign-in.`)}async check(e){this.checking.value=e;try{let t=await this.#e.checkSsoProvider.call({provider:e});this.checks.value=new Map([...this.checks.value,[e,t]])}catch(t){let n=t instanceof Error?t.message:String(t);this.checks.value=new Map([...this.checks.value,[e,{provider:e,ok:!1,discovery:{ok:!1,detail:n},keys:{ok:!1,detail:`Not checked.`},checkedAt:Date.now()}]])}finally{this.checking.value=void 0}}startTest(e){return this.save.run(()=>this.#e.testSsoSignIn.call({provider:e}),`Couldn’t start the test sign-in.`)}addPerson(e){let t={name:e.name,email:e.email,role:e.role,...e.groups===void 0?{}:{groups:[...e.groups]}};return this.#t(this.save.run(()=>this.#e.addUser.call(t),`Couldn’t add them.`))}addGroup(e){return this.#t(this.save.run(()=>this.#e.addGroup.call(e),`Couldn’t add the group.`))}update(e){return this.#t(this.save.run(()=>this.#e.updateUser.call(e),`Couldn’t change them.`))}membership(e){return this.#t(this.save.run(()=>this.#e.setMembership.call(e),`Couldn’t change the group.`))}async setPolicy(e){let t=await this.save.run(()=>this.#e.setSignInPolicy.call(e),`Couldn’t save who can join.`);return t.ok&&this.loadSignIn(!0),t}async setLimits(e){let t=await this.save.run(()=>this.#e.setSignInLimits.call(e),`Couldn’t save the sign-in limits.`);return t.ok&&this.loadSignIn(!0),t}async setProxy(e){let t=await this.save.run(()=>this.#e.setProxyTrust.call(e),`Couldn’t save the proxy setting.`);return t.ok&&this.loadSignIn(!0),t}async#t(e){let t=await e;if(!t.ok)return t;this.users.refresh(),this.groups.refresh();let n=this.person.value.value;n!==void 0&&this.openPerson(n.email,!0);let r=this.members.value.value?.group;return r!==void 0&&this.openGroup(r.id,!0),t}};function Tl(e,t,n){let r=e??[];return r.some(e=>n(e,t))?r.map(e=>n(e,t)?t:e):[...r,t]}var El=class{#e;roles=new v;limits=new v;save=new p;constructor(e){this.#e=e}async loadRoles(e=!1){await this.roles.load(()=>this.#e.modelRoles.call({}),`Couldn't load the model roles.`,e)}async loadLimits(e=!1){await this.limits.load(()=>this.#e.modelLimits.call({}),`Couldn't load the model limits.`,e)}role(e){return this.roles.value.value?.find(t=>t.role===e)}async setRole(e){let t=await this.save.run(()=>this.#e.setModelRole.call(e),`Couldn't save that role.`);return t.ok&&this.roles.set(Tl(this.roles.value.value,t.value,(e,t)=>e.role===t.role)),t}async clearRole(e){let t=await this.save.run(()=>this.#e.clearModelRole.call({role:e}),`Couldn't clear that role.`);return t.ok&&this.roles.set(Tl(this.roles.value.value,t.value,(e,t)=>e.role===t.role)),t}async setLimits(e,t){let n=await this.save.run(()=>this.#e.setModelLimits.call({model:e,limits:t}),`Couldn't save the limits of ${e}.`);return n.ok&&this.limits.set(Tl(this.limits.value.value,n.value,(e,t)=>e.model===t.model)),n}},Dl=class{#e;data=new v;save=new p;groups=M(()=>{let e=this.data.value.value;if(e===void 0)return[];let t=new Map;for(let n of[...e.declared].sort((e,t)=>e.setting.localeCompare(t.setting))){let r={view:n,values:e.values.filter(e=>e.setting===n.setting)};t.set(n.system,[...t.get(n.system)??[],r])}return[...t].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({system:e,settings:t}))});constructor(e){this.#e=e}async load(e=!1){await this.data.load(()=>this.#e.actorSettings.call({}),`Couldn't load actor settings.`,e)}async set(e,t,n,r,i){let a=await this.save.run(()=>this.#e.setActorSetting.call({setting:e,actor:t,value:n}),`Couldn't save the setting.`),o=this.data.value.value;if(!a.ok||!a.value.ok||o===void 0)return a.ok&&a.value.ok;let s={setting:e,actor:t,value:n,setBy:r,updatedAt:i};return this.data.set({...o,values:[...o.values.filter(n=>n.setting!==e||n.actor!==t),s]}),!0}},Ol=class{#e;review=new v;refusals;switching=new p;deciding=new p;decidingChange=z(void 0);testing=new p;off=M(()=>ni(this.review.value.value?.off??[]));constructor(e){this.#e=e,this.refusals=new m({fetch:async({system:e,rule:t},n,r)=>{if(e===void 0)return{items:[]};let i=await this.#e.refusals.call({system:e,limit:r,...t===void 0?{}:{rule:t},...n===void 0?{}:{cursor:n}});return{items:i.items,...i.next===void 0?{}:{cursor:i.next}}},key:e=>e.id,failure:`Couldn't load the refusals.`,limit:50},{system:void 0,rule:void 0})}async open(e){let t=this.review.value.value?.system===e;t||this.review.reset(),await this.review.load(()=>this.#e.systemReview.call({system:e}),`Couldn't load this system's review.`,t)}async loadRefusals(e,t){await this.refusals.load({system:e,rule:t})}isOn(e){return!this.off.value.has(ti(e))}async switch(e,t){let n=this.review.value.value;if(n===void 0)return!1;let r=n.off;this.review.set({...n,off:ii(r,e,t)});let i=await this.switching.run(()=>this.#t(n.system,e,t),`Couldn't switch that.`);if(!i.ok){let n=this.review.value.value;n!==void 0&&this.review.set({...n,off:ii(n.off,e,!t)})}return i.ok}async#t(e,t,n){let{section:r,name:i}=t;r===`fns`||r===`context`?await this.#e.switchItem.call({section:r,name:Xn.parse(i),on:n}):await this.#e.switchPart.call({system:e,section:r,name:i,on:n})}#n(e){let t=this.review.value.value;return t===void 0?void 0:{system:t.system,hash:e,off:t.off}}async goLive(){let e=this.review.value.value,t=e===void 0?void 0:this.#n(e.manifest.hash);if(e===void 0||t===void 0)return{ok:!1,problem:`No system is open.`};let n=await this.deciding.run(()=>this.#e.goLive.call(t),`Couldn't go live.`);return this.open(e.system),n.ok?{ok:!0,value:n.value.stage}:n}async approve(){let e=this.review.value.value,t=e?.pending,n=t===void 0?void 0:this.#n(t.hash);if(e===void 0||n===void 0)return{ok:!1,problem:`Nothing waits for review.`};let r=await this.deciding.run(()=>this.#e.approveReview.call(n),`Couldn't approve the changes.`);return this.open(e.system),r.ok?{ok:!0,value:r.value.hash}:r}async decide(e,t){let n=this.review.value.value,r=n?.pending;if(n===void 0||r===void 0)return{ok:!1,problem:`Nothing waits for review.`};this.decidingChange.value=ai(e);let i=ri(e),a={system:n.system,hash:r.hash,approve:t===`approve`?[i]:[],decline:t===`decline`?[i]:[],off:[]};try{let e=await this.deciding.run(()=>this.#e.decideReview.call(a),t===`approve`?`Couldn't approve that change.`:`Couldn't decline that change.`);return await this.open(n.system),e}finally{this.decidingChange.value=void 0}}async reject(){let e=this.review.value.value,t=e?.pending;if(e===void 0||t===void 0)return{ok:!1,problem:`Nothing waits for review.`};let n=await this.deciding.run(()=>this.#e.rejectReview.call({system:e.system,hash:t.hash}),`Couldn't reject the changes.`);return this.open(e.system),n.ok?{ok:!0,value:n.value.ok}:n}async testCall(e,t){let n=await this.testing.run(()=>this.#e.testCall.call({fn:e,args:t}),`Couldn't run that.`);return n.ok?{ok:!0,value:n.value.run}:n}close(){this.review.reset(),this.refusals.load({system:void 0,rule:void 0})}},kl=1e3,Al=`Restarted by an admin from its page`,jl=class{#e;#t;#n;#r;#i;name=z(void 0);view=new v;fns=new v;logs=new v;config=new p;enabling=new p;switching=new p;action=new p;acting=B(void 0);constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async open(e){this.name.value!==e&&(this.close(),this.name.value=e),this.#r??=this.#t(e=>{this.#o(e)}),await this.view.load(()=>this.#e.system.call({system:e}),`Couldn't load this system.`,this.view.value.value?.name===e)}close(){this.#r?.(),this.#r=void 0,this.unfollowLogs(),this.name.value=void 0,this.view.reset(),this.fns.reset(),this.logs.reset()}async loadFns(){let e=this.name.value;e!==void 0&&await this.fns.load(()=>this.#e.systemFns.call({system:e}),`Couldn't load this system's fns.`)}fnSwitched(e,t){let n=this.fns.value.value;n!==void 0&&this.fns.set(n.map(n=>n.name===e?{...n,disabled:!t}:n))}async switchFn(e,t){if(this.fnSwitched(e,t),!(await this.switching.run(()=>this.#e.switchItem.call({section:`fns`,name:e,on:t}),`Couldn't switch that.`)).ok)return this.fnSwitched(e,!t),!1;let n=this.name.value;return n!==void 0&&await this.fns.load(()=>this.#e.systemFns.call({system:n}),`Couldn't load this system's fns.`,!0),!0}async followLogs(){let e=this.name.value;e!==void 0&&(this.#i??=this.#n(e,e=>{let t=this.logs.value.value??[];this.logs.set([...t,e].slice(-1e3))}),await this.logs.load(()=>this.#e.systemLogs.call({system:e,limit:kl}),`Couldn't load this system's output.`))}unfollowLogs(){this.#i?.(),this.#i=void 0}async configure(e){let t=this.name.value;if(t===void 0)return{ok:!1,problems:[`No system is open.`]};let n=await this.config.run(()=>this.#e.configureSystem.call({system:t,config:e}),`Couldn't save the config.`);return n.ok?`problems`in n.value?{ok:!1,problems:n.value.problems}:(this.open(t),{ok:!0,version:n.value.version}):{ok:!1,problems:[n.problem]}}async enable(e,t){let n=this.name.value,r=this.view.value.value;if(n===void 0||r===void 0)return!1;this.view.set({...r,enabled:{...r.enabled,[e]:t}});let i=await this.enabling.run(()=>this.#e.enableSystem.call({system:n,[e]:t}),`Couldn't change that.`),a=this.view.value.value;return a===void 0||this.view.set({...a,enabled:i.ok?i.value.enabled:r.enabled}),i.ok}async act(e,t,n){let r=this.name.value;if(r===void 0)return{ok:!1,problem:`No system is open.`};this.acting.value=e;let i=await this.action.run(()=>this.#a(r,e,t,n),`Couldn't ${e} ${r}.`);return this.acting.value=void 0,i.ok&&e!==`remove`&&this.open(r),i}async#a(e,t,n,r){switch(t){case`start`:return await this.#e.startSystem.call({system:e}),{kind:`done`};case`stop`:return await this.#e.stopSystem.call({system:e}),{kind:`done`};case`restart`:return await this.#e.restartSystem.call({system:e,reason:Al}),{kind:`done`};case`upgrade`:return{kind:`upgrade`,...await this.#e.upgradeSystem.call({system:e,...n===void 0||n===``?{}:{version:n}})};case`reimport`:return{kind:`reimport`,report:await this.#e.reimport.call({system:e})};case`remove`:return await this.#e.removeSystem.call({system:e,...r===void 0?{}:{keepStore:r}}),{kind:`done`}}}#o(e){let t=this.view.value.value;if(t===void 0||e.type!==`system`&&e.type!==`fn`||e.system!==t.name)return;if(e.type===`system`){this.view.set({...t,status:e.status});return}let n=this.fns.value.value;n?.some(t=>t.name===e.fn)===!0&&this.fns.set(n.map(t=>t.name===e.fn?{...t,stats:e.stats}:t))}},Ml=class{#e;#t;context;types;contextCount=z(void 0);typeCount=z(void 0);others=new v;roots=new v;switching=new p;constructor(e){this.#e=e,this.context=new m({fetch:async(e,t,n)=>{if(e===void 0)return{items:[]};let r=await this.#e.query.call(Ur(e,t,n));return t===void 0&&(this.contextCount.value=r.total),{items:tr.array().parse(r.items),...r.cursor===void 0?{}:{cursor:r.cursor}}},key:e=>e.name,failure:`Couldn't load this system's context.`,limit:50},void 0),this.types=new m({fetch:async(e,t,n)=>{if(e===void 0)return{items:[]};let r=await this.#e.query.call(xs({system:e},t,n));return t===void 0&&(this.typeCount.value=r.total),{items:Zn.array().parse(r.items),...r.cursor===void 0?{}:{cursor:r.cursor}}},key:e=>e.name,failure:`Couldn't load this system's types.`,limit:50},void 0)}async loadContext(e){this.context.filter.value===e&&this.context.loaded.value?await this.context.refresh():(this.contextCount.value=void 0,await this.context.load(e))}async loadTypes(e){this.types.filter.value===e&&this.types.loaded.value?await this.types.refresh():(this.typeCount.value=void 0,await this.types.load(e))}async loadOthers(e){let t=this.#t===e&&this.others.value.value!==void 0;t||(this.others.reset(),this.roots.reset()),this.#t=e,await Promise.all([this.others.load(()=>this.#e.systemParts.call({system:e}),`Couldn't load what this system added.`,t),this.roots.load(()=>this.#e.exploreRoots.call({system:e}),`Couldn't load this system's resource roots.`,t)])}async switchContext(e,t){this.context.update(e,e=>({...e,status:t?`active`:`hidden`}));let n=await this.switching.run(()=>this.#e.switchItem.call({section:`context`,name:e,on:t}),`Couldn't switch that.`);return n.ok||this.context.update(e,e=>({...e,status:t?`hidden`:`active`})),n.ok}close(){this.others.reset(),this.roots.reset(),this.#t=void 0,this.context.load(void 0),this.types.load(void 0),this.contextCount.value=void 0,this.typeCount.value=void 0}},Nl=class{#e;#t;#n;list=new v;pairings=new v;query=B({});sorted=M(()=>{let e=this.list.value.value??[];return this.query.value.sort===void 0?Wr(e):e});pending=M(()=>(this.pairings.value.value??[]).filter(e=>e.status===`pending`).length);answering=B(new Set);answer=new p;token=new p;install=new p;constructor(e,t){this.#e=e,this.#t=t}start(){this.#n??=this.#t(e=>{this.#i(e)})}stop(){this.#n?.(),this.#n=void 0}async load(e=!1){await Promise.all([this.#r(e),this.pairings.load(()=>this.#e.pairings.call({status:`pending`}),`Couldn't load pairing requests.`,e)])}async search(e){JSON.stringify(e)!==JSON.stringify(this.query.value)&&(this.query.value=e,await this.#r(!1))}async#r(e){let t=this.query.value;await this.list.load(()=>this.#e.systems.call(Object.keys(t).length===0?{}:{query:t}),`Couldn't load systems.`,e)}async answerPairing(e,t,n,r){this.answering.value=new Set([...this.answering.value,e]);let i=await this.answer.run(()=>this.#e.approvePairing.call({pairing:e,approve:t,...t?fl(n):{},...t&&r!==void 0?{store:r}:{}}),t?`Couldn't approve the pairing.`:`Couldn't reject the pairing.`);return this.answering.value=new Set([...this.answering.value].filter(t=>t!==e)),i.ok&&(this.pairings.set((this.pairings.value.value??[]).filter(t=>t.id!==e)),t&&this.#r(!0)),i}async createToken(e,t,n){return this.token.run(()=>this.#e.createPairingToken.call({expiresIn:t,...e===void 0?{}:{name:e},...fl(n)}),`Couldn't make a pairing token.`)}async installSystem(e,t,n,r){let i=await this.install.run(()=>this.#e.installSystem.call({source:e,autoStart:t,...n===void 0?{}:{config:n},...r===void 0?{}:{store:r}}),`Couldn't install the system.`);return i.ok&&this.load(!0),i}#i(e){if(e.type===`system`){let t=this.list.value.value;if(t===void 0)return;if(!t.some(t=>t.name===e.system)){this.load(!0);return}this.list.set(t.map(t=>t.name===e.system?{...t,status:e.status}:t))}else if(e.type===`pairing`){let t=e.pairing,n=(this.pairings.value.value??[]).filter(e=>e.id!==t.id);this.pairings.set(t.status===`pending`?[t,...n]:n)}}},Pl=class{actors;systems;system;systemParts;review;models;roles;limits;policies;settings;runs;runApprovals;llm;modelCalls;fn;injected;itemInjected;instance;instanceParts;packages;storage;mcps;mcp;mcpServers;apiServices;pairing;resources;fns;suggestions;classifier;images;autoPairs;people;constructor(e){let{api:t}=e;this.actors=new us(t),this.systems=new Nl(t,e.userEvents),this.system=new jl(t,e.userEvents,e.systemLogs),this.systemParts=new Ml(t),this.review=new Ol(t),this.models=new gl(t),this.roles=new El(t),this.limits=new hl(t),this.policies=new Cl(t),this.settings=new Dl(t),this.runs=hs(t,e.chat),this.runApprovals=new ds(e.chat),this.llm=gs(t,e.chat),this.modelCalls=_s(t,e.chat),this.fn=new Di(t,e.userEvents),this.injected=new wr(t),this.itemInjected=new wr(t),this.instance=new ys(t,e.userEvents),this.instanceParts=new ks(t,e.chat),this.packages=new gc(t,e.sender),this.storage=new bc(t),this.mcps=new As(t),this.mcp=new js(t,e.probe),this.mcpServers=new Zs(t),this.apiServices=new dc({fns:t.fns,records:e.data.records,saveRecord:e.data.saveRecord,removeRecord:e.data.removeRecord}),this.pairing=new ml(t,e.userEvents),this.resources=vs(t,e.chat),this.suggestions=new ss(t),this.classifier=new cs(t),this.images=new ls(t),this.autoPairs=new os(t),this.people=new wl(t),this.fns=new m({fetch:(e,n,r)=>t.fns.call({...e,limit:r,...n===void 0?{}:{cursor:n}}),key:e=>e.name,failure:`Couldn't load the fns.`,limit:50},{})}start(){this.systems.start(),this.systems.pairings.value.value===void 0&&this.systems.load(!0)}stop(){this.systems.stop(),this.system.close()}};function Fl(e){return{systems:e.caller(`systems`,{dedupe:!0}),system:e.caller(`system`,{dedupe:!0}),pairings:e.caller(`pairings`,{dedupe:!0}),approvePairing:e.caller(`approvePairing`),createPairingToken:e.caller(`createPairingToken`),configureSystem:e.caller(`configureSystem`),enableSystem:e.caller(`enableSystem`),switchItem:e.caller(`switchItem`),switchPart:e.caller(`switchPart`),systemReview:e.caller(`systemReview`,{dedupe:!0}),goLive:e.caller(`goLive`),approveReview:e.caller(`approveReview`),rejectReview:e.caller(`rejectReview`),decideReview:e.caller(`decideReview`),testCall:e.caller(`testCall`),refusals:e.caller(`refusals`,{lastOnly:!0}),removeSystem:e.caller(`removeSystem`),installSystem:e.caller(`installSystem`),systemStore:e.caller(`systemStore`),systemStoreMove:e.caller(`systemStoreMove`),systemStoreMoveState:e.caller(`systemStoreMoveState`),systemStoreMoveAnswer:e.caller(`systemStoreMoveAnswer`),systemStoreBackups:e.caller(`systemStoreBackups`),systemStoreBackupDelete:e.caller(`systemStoreBackupDelete`),startSystem:e.caller(`startSystem`),stopSystem:e.caller(`stopSystem`),restartSystem:e.caller(`restartSystem`),upgradeSystem:e.caller(`upgradeSystem`),reimport:e.caller(`reimport`),systemFns:e.caller(`systemFns`,{dedupe:!0}),systemLogs:e.caller(`systemLogs`,{dedupe:!0}),systemParts:e.caller(`systemParts`,{dedupe:!0}),exploreRoots:e.caller(`exploreRoots`,{dedupe:!0}),providers:e.caller(`providers`,{dedupe:!0}),configureProvider:e.caller(`configureProvider`),models:e.caller(`models`,{dedupe:!0}),modelCategories:e.caller(`modelCategories`,{dedupe:!0}),setModelCategory:e.caller(`setModelCategory`),budgets:e.caller(`budgets`,{dedupe:!0}),setBudget:e.caller(`setBudget`),priorityRules:e.caller(`priorityRules`,{dedupe:!0}),setPriority:e.caller(`setPriority`),resolveLimits:e.caller(`resolveLimits`,{lastOnly:!0}),policies:e.caller(`policies`,{dedupe:!0}),setPolicy:e.caller(`setPolicy`),removeRule:e.caller(`removeRule`),actors:e.caller(`actors`,{dedupe:!0}),actorSettings:e.caller(`actorSettings`,{dedupe:!0}),setActorSetting:e.caller(`setActorSetting`),runs:e.caller(`runs`,{lastOnly:!0}),fns:e.caller(`fns`,{lastOnly:!0}),llmCalls:e.caller(`llmCalls`,{lastOnly:!0}),query:e.caller(`query`),resources:e.caller(`resources`,{lastOnly:!0}),modelRoles:e.caller(`modelRoles`,{dedupe:!0}),setModelRole:e.caller(`setModelRole`),clearModelRole:e.caller(`clearModelRole`),modelLimits:e.caller(`modelLimits`,{dedupe:!0}),setModelLimits:e.caller(`setModelLimits`),modelCalls:e.caller(`modelCalls`,{lastOnly:!0}),modelCall:e.caller(`modelCall`,{dedupe:!0}),fnMetrics:e.caller(`fnMetrics`,{dedupe:!0}),fnMetricsDays:e.caller(`fnMetricsDays`,{dedupe:!0}),mcps:e.caller(`mcps`,{dedupe:!0}),mcp:e.caller(`mcp`,{dedupe:!0}),createMcp:e.caller(`createMcp`),updateMcp:e.caller(`updateMcp`),rotateMcpSecret:e.caller(`rotateMcpSecret`),deleteMcp:e.caller(`deleteMcp`),previewMcp:e.caller(`previewMcp`,{lastOnly:!0}),mcpSessions:e.caller(`mcpSessions`,{dedupe:!0}),pairing:e.caller(`pairing`,{dedupe:!0}),instances:e.caller(`instances`,{dedupe:!0}),installPackage:e.caller(`installPackage`),removeInstance:e.caller(`removeInstance`),addInstance:e.caller(`addInstance`),readFn:e.caller(`readFn`),exportSystemData:e.caller(`exportSystemData`),autoPairs:e.caller(`autoPairs`,{dedupe:!0}),revokeAutoPair:e.caller(`revokeAutoPair`),suggestDecision:e.caller(`suggestDecision`,{dedupe:!0}),setSuggestDecision:e.caller(`setSuggestDecision`),previewSuggestions:e.caller(`previewSuggestions`,{lastOnly:!0}),searchDecisions:e.caller(`searchDecisions`,{dedupe:!0}),setSearchDecision:e.caller(`setSearchDecision`),injections:e.caller(`injections`,{lastOnly:!0}),setInjection:e.caller(`setInjection`),autoClassifier:e.caller(`autoClassifier`,{dedupe:!0}),setAutoClassifier:e.caller(`setAutoClassifier`),imageEmbedding:e.caller(`imageEmbedding`,{dedupe:!0}),setImageEmbedding:e.caller(`setImageEmbedding`),upload:e.caller(`upload`),uploaded:e.caller(`uploaded`),people:e.caller(`people`,{lastOnly:!0}),groups:e.caller(`groups`,{lastOnly:!0}),groupMembers:e.caller(`groupMembers`,{lastOnly:!0}),addUser:e.caller(`addUser`),addGroup:e.caller(`addGroup`),updateUser:e.caller(`updateUser`),setMembership:e.caller(`setMembership`),signInSettings:e.caller(`signInSettings`,{dedupe:!0}),setSignInPolicy:e.caller(`setSignInPolicy`),setSignInLimits:e.caller(`setSignInLimits`),setProxyTrust:e.caller(`setProxyTrust`),checkSsoProvider:e.caller(`checkSsoProvider`),testSsoSignIn:e.caller(`testSsoSignIn`),ssoTestResult:e.caller(`ssoTestResult`,{lastOnly:!0})}}function Il(e){return(t,n)=>e.on(`systemLog`,{system:t},n)}var Ll=`connections`;function Rl(e){return{connectPages:e.caller(`connectPages`,{cache:{ttl:3e4,tags:[Ll]},dedupe:!0}),connect:e.caller(`connect`,{invalidates:[Ll]}),updateConnection:e.caller(`updateConnection`,{invalidates:[Ll]}),disconnect:e.caller(`disconnect`,{invalidates:[Ll]})}}var zl=`access`;function Bl(e){return{pick:e.caller(`pick`,{cache:{ttl:15e3},dedupe:!0}),accessInfo:e.caller(`accessInfo`,{cache:{ttl:6e4},dedupe:!0}),access:e.caller(`access`,{cache:{ttl:3e4,tags:[zl]},dedupe:!0}),setAccess:e.caller(`setAccess`,{invalidates:[zl]})}}var Vl=`sessions`,Hl=`capabilities`;function Ul(e){return{capabilities:e.caller(`capabilities`,{cache:{ttl:6e4,tags:[Hl]},dedupe:!0}),types:e.caller(`types`,{cache:{ttl:3e5,tags:[Hl]},dedupe:!0}),sessions:e.caller(`sessions`,{cache:{ttl:5e3,tags:[Vl]},dedupe:!0,lastOnly:!0}),searchSessions:e.caller(`sessions`,{debounce:250,lastOnly:!0}),session:e.caller(`session`,{dedupe:!0}),listValues:e.caller(`listValues`,{cache:{ttl:1e4},dedupe:!0}),createSession:e.caller(`createSession`,{invalidates:[Vl]}),updateSession:e.caller(`updateSession`,{invalidates:[Vl]}),deleteSession:e.caller(`deleteSession`,{invalidates:[Vl]}),limits:e.caller(`limits`,{dedupe:!0}),messages:e.caller(`messages`,{dedupe:!0}),send:e.caller(`send`,{invalidates:[Vl]}),invoke:e.caller(`invoke`),compare:e.caller(`compare`,{invalidates:[Vl]}),compareView:e.caller(`compareView`,{lastOnly:!0}),chooseVariant:e.caller(`chooseVariant`,{invalidates:[Vl]}),control:e.caller(`control`),controls:e.caller(`controls`,{dedupe:!0}),background:e.caller(`background`),undoTurn:e.caller(`undoTurn`),continueTurn:e.caller(`continueTurn`),tree:e.caller(`tree`,{dedupe:!0}),treeRefresh:e.caller(`tree`,{debounce:400,lastOnly:!0}),run:e.caller(`run`,{dedupe:!0}),llmCall:e.caller(`llmCall`,{cache:{ttl:3e5},dedupe:!0}),suggest:e.caller(`suggest`,{debounce:700,lastOnly:!0}),mentions:e.caller(`mentions`),mentionHover:e.caller(`mentionHover`,{cache:{ttl:3e4},dedupe:!0}),waiting:e.caller(`waiting`),approve:e.caller(`approve`),approvals:e.caller(`approvals`,{dedupe:!0}),contributions:e.caller(`contributions`,{cache:{ttl:6e4,tags:[Hl]},dedupe:!0}),setBudget:e.caller(`setBudget`),answer:e.caller(`answer`),presence:e.caller(`presence`),resource:e.caller(`resource`,{cache:{ttl:3e4},dedupe:!0}),upload:e.caller(`upload`),uploaded:e.caller(`uploaded`),transcribe:e.caller(`transcribe`),act:e.caller(`act`),submit:e.caller(`submit`),state:e.caller(`state`,{dedupe:!0}),previewSelection:e.caller(`previewSelection`,{lastOnly:!0}),...Bl(e),...Rl(e)}}function Wl(e){return(t,n)=>e.on(`session`,{session:t},n)}var Gl=class{put(e,t,n,r){return new Promise((i,a)=>{let o=new XMLHttpRequest;o.open(`PUT`,e),t.type!==``&&o.setRequestHeader(`content-type`,t.type),o.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&n(e.loaded/e.total)},o.onload=()=>{o.status>=200&&o.status<300?(n(1),i()):a(Error(`Upload failed (${o.status}).`))},o.onerror=()=>{a(Error(`Upload failed.`))},o.onabort=()=>{a(new DOMException(`Upload cancelled.`,`AbortError`))},r.addEventListener(`abort`,()=>{o.abort()},{once:!0}),o.send(t)})}};function Kl(e){return{setup:e.caller(`setup`,{cache:{ttl:5e3},dedupe:!0}),createAdmin:e.caller(`createAdmin`),signIn:e.caller(`signIn`),refresh:e.caller(`refresh`),redeemSso:e.caller(`redeemSso`),signOut:e.caller(`signOut`),me:e.caller(`me`,{dedupe:!0}),account:e.caller(`account`,{dedupe:!0})}}var ql={transport:`http`};function Jl(e){return{identity:e.caller(`identity`,{dedupe:!0}),setHubName:e.caller(`setHubName`)}}function Yl(e){return{outsideImages:e.caller(`outsideImages`,{dedupe:!0}),setOutsideImages:e.caller(`setOutsideImages`)}}function Xl(e){return{https:e.caller(`https`,{dedupe:!0}),setHttps:e.caller(`setHttps`)}}var Zl=`inbox`;function Ql(e){return{list:e.caller(`notifications`,{cache:{ttl:1e4,tags:[Zl]},dedupe:!0}),markRead:e.caller(`readNotifications`,{invalidates:[Zl],retry:{attempts:3}}),pushKey:e.caller(`pushKey`,{cache:{ttl:36e5},dedupe:!0}),subscribePush:e.caller(`subscribePush`,{retry:{attempts:3}})}}function $l(e,t){return n=>{let r,i=T(t,t=>{r?.(),r=t===void 0?void 0:e.on(`user`,{user:t},n)},{immediate:!0});return()=>{i(),r?.()}}}function eu(e){return{browse:e.caller(`browseResources`,{lastOnly:!0}),browseGroup:e.caller(`browseResources`),find:e.caller(`browseResources`,{lastOnly:!0}),forms:e.caller(`resourceForms`,{dedupe:!0}),read:e.caller(`readResource`,{dedupe:!0}),convert:e.caller(`convertResource`),download:e.caller(`downloadResource`,{dedupe:!0}),importResource:e.caller(`importResource`),rename:e.caller(`renameResource`),remove:e.caller(`deleteResource`),contextFrom:e.caller(`contextFromResource`),upload:e.caller(`upload`),uploaded:e.caller(`uploaded`),systemRead:e.caller(`resource`,{dedupe:!0}),exploreRoots:e.caller(`exploreRoots`,{lastOnly:!0}),exploreList:e.caller(`exploreList`),exploreRead:e.caller(`exploreRead`,{lastOnly:!0})}}function tu(e){return t=>e(e=>{e.type===`resource`&&t({uri:e.uri,forms:e.forms})})}function nu(e){return{list:e.caller(`contexts`,{lastOnly:!0}),item:e.caller(`contextItem`,{dedupe:!0}),remember:e.caller(`remember`),updateMemory:e.caller(`updateMemory`),forget:e.caller(`forget`),link:e.caller(`linkContext`),unlink:e.caller(`unlinkContext`),fromResource:e.caller(`contextFromResource`),values:e.caller(`listValues`),metadata:e.caller(`contextMetadata`,{dedupe:!0}),setStatus:e.caller(`setContextStatus`),review:e.caller(`contextReview`,{lastOnly:!0}),merge:e.caller(`mergeContext`),notDuplicate:e.caller(`notDuplicate`),reextract:e.caller(`reextractContext`),newStatus:e.caller(`newContextStatus`),setNewStatus:e.caller(`setNewContextStatus`),plans:e.caller(`contextPlans`,{lastOnly:!0}),plan:e.caller(`contextPlan`),answerPlan:e.caller(`answerPlan`)}}function ru(e){return t=>e(e=>{e.type===`context`&&t(e.name)})}function iu(e){return{searchFns:e.caller(`searchFns`,{cache:{ttl:3e4},dedupe:!0}),fnFacts:e.caller(`fnFacts`,{dedupe:!0}),fnExamples:e.caller(`fnExamples`,{dedupe:!0}),fnsOfModelNames:e.caller(`fnsOfModelNames`,{dedupe:!0})}}function au(e){return{graph:e.caller(`graph`,{lastOnly:!0})}}var ou=`records`;function su(e){return{dataSets:e.caller(`dataSets`,{cache:{ttl:1e4,tags:[ou]},dedupe:!0,lastOnly:!0}),records:e.caller(`records`,{dedupe:!0,lastOnly:!0}),recordTable:e.caller(`recordTable`,{lastOnly:!0}),record:e.caller(`record`,{dedupe:!0}),saveRecord:e.caller(`saveRecord`,{invalidates:[ou]}),removeRecord:e.caller(`removeRecord`,{invalidates:[ou]}),recordVersions:e.caller(`recordVersions`,{dedupe:!0}),rowActions:e.caller(`rowActions`,{cache:{ttl:3e4},dedupe:!0}),readFn:e.caller(`readFn`),exportCsv:e.caller(`export`),itemVersions:e.caller(`itemVersions`,{dedupe:!0})}}function cu(e){return{systemPages:e.caller(`systemPages`,{dedupe:!0})}}function lu(e,t){let n=$l(e,t);return{auth:Kl(e),identity:Jl(e),outsideImages:Yl(e),https:Xl(e),notifications:Ql(e),userEvents:n,chat:Ul(e),sessionEvents:Wl(e),admin:Fl(e),systemLogs:Il(e),resources:eu(e),resourceEvents:tu(n),context:nu(e),fns:iu(e),graph:au(e),data:su(e),pages:cu(e),contextEvents:ru(n),connection:e.connection}}function uu(e){let t=new Map(e.questions.map(e=>[e.name,e])),n=An(e),r=new Set(e.roots.filter(e=>t.has(e))),i=new Map;for(let t of e.questions)for(let e of t.options)for(let n of e.raises)r.has(n)&&i.set(n,[...i.get(n)??[],{question:t,via:e.label}]);let a=new Set,o=[],s=(e,c,l)=>{let u=t.get(e);if(u===void 0)return;let d=n.get(e)?.live===!0,f=a.has(e),p=c===0&&!f?i.get(e):void 0;if(o.push({question:u,indent:c,...l===void 0?{}:{via:l},live:d,repeat:f,...p===void 0?{}:{alsoRaisedBy:p}}),!f){a.add(e);for(let e of u.options)for(let t of e.raises)r.has(t)||s(t,c+1,e.label)}};for(let t of e.roots)s(t,0,void 0);for(let t of e.questions)a.has(t.name)||s(t.name,0,void 0);return o}function du(e,t){return!t||e.status===`not_applicable`?{label:`Ruled out`,tone:`neutral`}:e.known===!0?{label:`Answered in context`,tone:`ok`}:ir(e)?{label:`Answered`,tone:`ok`}:e.status===`hidden`?{label:`Hidden`,tone:`warn`}:e.planned?{label:`Open`,tone:`accent`}:{label:`No options yet`,tone:`warn`}}var fu={person:`For you`,system:`For the system`,research:`To research`};function pu(e){return e.stop===`complete`?Bn(e.counts):`${Bn(e.counts)} · ${On[e.stop]}`}function mu(e){return[`${e.answered} answered`,`${e.open} open`,`${e.decide} to decide now`,...e.ruledOut>0?[`${e.ruledOut} ruled out`]:[]]}function hu(e){return`plan-${e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)||`plan`}.md`}function gu(e,t){return Math.max(0,Math.round((e-t)/2))}var _u=28,vu=72,yu=36,bu=252,xu=16,Su=24,Cu=6.4,wu=4,Tu=20,Eu=16,Du=[.62,.5,.74,.4,.84,.3,.9,.22];function Ou(e,t){let n=e.y+64;return{x1:e.x+100,y1:n,x2:t.x+100,y2:t.y,bend:Math.max(30,Math.abs(t.y-n)/2)}}function ku(e,t){let{x1:n,y1:r,x2:i,y2:a,bend:o}=e,s=1-t,[c,l,u,d]=[s*s*s,3*s*s*t,3*s*t*t,t*t*t];return{x:c*n+l*n+u*i+d*i,y:c*r+l*(r+o)+u*(a-o)+d*a}}function Au(e,t){return e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height}function ju(e,t,n,r,i){for(let a of Du){let o=ku(e,a);for(let e of[0,-t/2-2,t/2+2]){let a={x:o.x+e-t/2,y:o.y-n/2,width:t,height:n};if(!(a.x<0||a.y<0||a.x+a.width>i.width||a.y+a.height>i.height)&&!r.some(e=>Au(a,e)))return a}}}function Mu(e){let t=An(e),n=uu(e).filter(e=>!e.repeat).map(e=>e.question),r=new Map;for(let e of n)r.set(e.depth,[...r.get(e.depth)??[],e]);let i=[...r.keys()].sort((e,t)=>e-t),a=Math.max(1,...[...r.values()].map(e=>e.length)),o=32+a*200+(a-1)*_u,s=new Map;for(let t of e.questions)for(let e of t.options)for(let n of e.raises){let r=t.picked.includes(e.id)?`picked`:t.picked.length>0?`not`:`open`,i=`${t.name} ${n}`,a=s.get(i);s.set(i,a===void 0?{from:t.name,to:n,label:e.label,state:r}:{from:t.name,to:n,label:`${a.label} / ${e.label}`,state:a.state===`picked`||r===`picked`?`picked`:a.state===`open`||r===`open`?`open`:`not`})}let c=[...s.values()],l={picked:0,open:1,not:2},u=[...c].sort((e,t)=>l[e.state]-l[t.state]),d=i.slice(1).map(()=>vu);for(;;){let e=new Map,n=[],a=xu;i.forEach((i,s)=>{let c=r.get(i)??[],l=c.length*200+(c.length-1)*_u,u=(o-l)/2;c.forEach((r,i)=>{let o=t.get(r.name)?.live===!0?ir(r)?`answered`:r.planned?`open`:`unplanned`:`out`,c=r.options.filter(e=>r.picked.includes(e.id)).map(e=>e.label).join(`, `);n.push({name:r.name,label:r.question,x:u+i*228,y:a,state:o,picked:c}),e.set(r.name,s)}),a+=64+(d[s]??0)});let s=a-(d[i.length-1]??0)+xu,l={width:o,height:s},f=new Map(n.map(e=>[e.name,e])),p=n.map(e=>({x:e.x-4,y:e.y-4,width:208,height:72})),m=new Map,h=new Set,g=[];for(let t of u){let n=f.get(t.from),r=f.get(t.to);if(n===void 0||r===void 0)continue;let i=Pu(t.label,Su,2),a=ju(Ou(n,r),Math.max(...i.map(e=>e.length))*Cu+8,i.length*13+wu,p,l);a===void 0?(g.push(t),h.add(e.get(t.from)??0)):(p.push(a),m.set(`${t.from} ${t.to}`,{...a,lines:i}))}let _=!1;for(let e of h){let t=d[e];t!==void 0&&t<bu&&(d[e]=Math.min(bu,t+yu),_=!0)}if(g.length>0&&_)continue;let ee=new Map,te=[];for(let e of g){let t=f.get(e.from),n=f.get(e.to);if(t===void 0||n===void 0)continue;let r=Ou(t,n),i=ju(r,Tu,Eu,p,l),a=i===void 0?ku(r,.5):{x:i.x+Tu/2,y:i.y+Eu/2},o=te.length+1;i!==void 0&&p.push(i),ee.set(`${e.from} ${e.to}`,{n:o,x:a.x,y:a.y}),te.push({n:o,label:e.label,state:e.state})}return{width:o,height:s,nodes:n,edges:c.flatMap(e=>{let t=f.get(e.from),n=f.get(e.to);if(t===void 0||n===void 0)return[];let{x1:r,y1:i,x2:a,y2:o,bend:s}=Ou(t,n),c=`${e.from} ${e.to}`,l=m.get(c),u=ee.get(c);return[{...e,path:`M ${r} ${i} C ${r} ${i+s}, ${a} ${o-s}, ${a} ${o}`,...l===void 0?{}:{placed:l},...u===void 0?{}:{marker:u}}]}),legend:te}}}function Nu(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}function Pu(e,t,n){let r=[],i=``;for(let n of e.split(/\s+/))i===``?i=n:i.length+1+n.length<=t?i=`${i} ${n}`:(r.push(i),i=n);if(i!==``&&r.push(i),r.length<=n)return r;let a=r.slice(0,n);return a[n-1]=Nu(`${a[n-1]??``} ${r.slice(n).join(` `)}`,t),a}var Fu={class:`plan-graph-wrap`},Iu=[`width`,`height`,`viewBox`,`aria-label`],Lu={class:`edges`},Ru=[`d`],zu=[`d`],Bu={class:`labels`},Vu=[`data-x`,`data-y`,`data-w`,`data-h`],Hu=[`x`,`y`,`width`,`height`],Uu=[`x`,`y`],Wu=[`x`,`dy`],Gu=[`x`,`y`],Ku=[`x`,`y`],qu=[`transform`,`aria-label`,`data-question`,`data-state`,`onClick`,`onKeydown`],Ju=[`width`,`height`],Yu={x:`12`,y:`20`},Xu=[`dy`],Zu=[`y`],Qu={key:0,class:`legend`,"data-testid":`plan-graph-legend`,"aria-label":`Options too long to fit on their edges`},$u={class:`n`},ed=q(N({__name:`PlanGraph`,props:{plan:{}},emits:[`pick`],setup(e,{emit:n}){let r=e,i=n,a=M(()=>Mu(r.plan)),o=z(null),s=async()=>{await ke(),o.value!==null&&(o.value.scrollLeft=gu(a.value.width,o.value.clientWidth))};Se(()=>{s()}),T(()=>a.value.width,()=>{s()});let c=e=>Pu(e.label,30,e.picked===``?3:2),l={answered:`answered`,open:`open`,out:`ruled out`,unplanned:`no options yet`};return(e,n)=>(P(),k(`div`,Fu,[O(`div`,{ref_key:`box`,ref:o,class:`plan-graph`,"data-testid":`plan-graph`,tabindex:`0`,"aria-label":`The plan as a graph; scrolls both ways`},[(P(),k(`svg`,{width:a.value.width,height:a.value.height,viewBox:`0 0 ${a.value.width} ${a.value.height}`,role:`img`,"aria-label":`${a.value.nodes.length} questions and how they connect`},[n[0]||=O(`defs`,null,[O(`marker`,{id:`plan-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`},[O(`path`,{d:`M 0 0 L 8 4 L 0 8 z`,class:`arrow`})])],-1),O(`g`,Lu,[(P(!0),k(F,null,A(a.value.edges,e=>(P(),k(`g`,{key:`${e.from}-${e.to}`,class:D([`edge`,e.state]),"data-testid":`plan-graph-edge`},[O(`title`,null,L(e.label),1),O(`path`,{d:e.path,"marker-end":`url(#plan-arrow)`},null,8,Ru),O(`path`,{d:e.path,class:`hit`},null,8,zu)],2))),128))]),O(`g`,Bu,[(P(!0),k(F,null,A(a.value.edges,e=>(P(),k(F,{key:`${e.from}-${e.to}-label`},[e.placed?(P(),k(`g`,{key:0,class:D([`label`,e.state]),"data-testid":`plan-graph-label`,"data-x":e.placed.x,"data-y":e.placed.y,"data-w":e.placed.width,"data-h":e.placed.height},[O(`title`,null,L(e.label),1),O(`rect`,{x:e.placed.x,y:e.placed.y,width:e.placed.width,height:e.placed.height,rx:`4`},null,8,Hu),O(`text`,{x:e.placed.x+e.placed.width/2,y:e.placed.y+E(13)-1,"text-anchor":`middle`},[(P(!0),k(F,null,A(e.placed.lines,(t,n)=>(P(),k(`tspan`,{key:n,x:e.placed.x+e.placed.width/2,dy:n===0?0:E(13)},L(t),9,Wu))),128))],8,Uu)],10,Vu)):e.marker?(P(),k(`g`,{key:1,class:D([`label`,`numbered`,e.state]),"data-testid":`plan-graph-marker`},[O(`title`,null,L(e.marker.n)+`: `+L(e.label),1),O(`rect`,{x:e.marker.x-10,y:e.marker.y-8,width:`20`,height:`16`,rx:`8`},null,8,Gu),O(`text`,{x:e.marker.x,y:e.marker.y+4,"text-anchor":`middle`},L(e.marker.n),9,Ku)],2)):V(``,!0)],64))),128))]),(P(!0),k(F,null,A(a.value.nodes,e=>(P(),k(`g`,{key:e.name,class:D([`node`,e.state]),transform:`translate(${e.x} ${e.y})`,role:`button`,tabindex:`0`,"aria-label":`${e.label} (${l[e.state]})`,"data-testid":`plan-graph-node`,"data-question":e.name,"data-state":e.state,onClick:t=>i(`pick`,e.name),onKeydown:t(t=>i(`pick`,e.name),[`enter`])},[O(`rect`,{width:E(200),height:E(64),rx:`10`},null,8,Ju),O(`text`,Yu,[(P(!0),k(F,null,A(c(e),(e,t)=>(P(),k(`tspan`,{key:t,x:`12`,dy:t===0?0:15},L(e),9,Xu))),128))]),e.picked===``?V(``,!0):(P(),k(`text`,{key:0,x:`12`,y:E(64)-10,class:`picked`},`✓ `+L(E(Nu)(e.picked,28)),9,Zu))],42,qu))),128))],8,Iu))],512),a.value.legend.length>0?(P(),k(`ol`,Qu,[(P(!0),k(F,null,A(a.value.legend,e=>(P(),k(`li`,{key:e.n,class:D(e.state)},[O(`span`,$u,L(e.n),1),w(` `+L(e.label),1)],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-c009da68`]]),td=[`data-question`,`data-state`],nd={key:0,class:`again`},rd={key:0,class:`via`},id={class:`head`},ad=[`title`],od=[`id`],sd={key:0,class:`also faint`,"data-testid":`plan-question-also`},cd={key:0},ld=[`title`,`onClick`],ud={class:`facts`},dd={key:0,class:`faint`},fd={key:1,class:`reason`,"data-testid":`plan-question-reason`},pd={key:2,class:`reason-edit`},md={class:`row-actions`},hd={key:3,class:`faint`},gd=[`aria-label`],_d=[`aria-pressed`,`disabled`,`title`,`data-option`,`onClick`],vd={key:5,class:`faint`},yd={key:6,class:`own`},bd={class:`row-actions`},xd=q(N({__name:`PlanQuestionRow`,props:{row:{},busy:{type:Boolean,default:!1},deeper:{type:Boolean,default:!1},canDeepen:{type:Boolean,default:!0}},emits:[`answer`,`reason`,`deeper`,`jump`],setup(e,{emit:t}){let n=e,r=t,i=M(()=>n.row.question),a=M(()=>du(i.value,n.row.live)),o=M(()=>!n.row.live||i.value.status===`not_applicable`),s=M(()=>i.value.known===!0),c=z(i.value.text??``),l=z(i.value.statusReason??``),u=z(!1);T(()=>i.value.text,e=>{c.value=e??``}),T(()=>i.value.statusReason,e=>{l.value=e??``});let d=M(()=>c.value.trim()!==(i.value.text??``).trim()),f=M(()=>!i.value.planned&&!ir(i.value));function p(e){if(o.value||s.value)return;let t=i.value.picked.includes(e)?i.value.picked.filter(t=>t!==e):[...i.value.picked,e];r(`answer`,{question:i.value.name,picked:t,...c.value.trim()===``?{}:{text:c.value.trim()}})}function m(){r(`answer`,{question:i.value.name,picked:[...i.value.picked],...c.value.trim()===``?{}:{text:c.value.trim()}})}function h(){let e=l.value.trim();e!==``&&(r(`reason`,{question:i.value.name,reason:e}),u.value=!1)}return(t,n)=>(P(),k(`li`,{class:D([`plan-q`,{out:o.value,repeat:e.row.repeat}]),style:Ce({"--indent":String(Math.min(e.row.indent,6))}),"data-testid":`plan-question`,"data-question":i.value.name,"data-state":a.value.label},[e.row.repeat?(P(),k(`div`,nd,[e.row.via?(P(),k(`span`,rd,L(e.row.via)+` →`,1)):V(``,!0),O(`button`,{type:`button`,class:`link`,"data-testid":`plan-question-jump`,onClick:n[0]||=e=>r(`jump`,i.value.name)},L(i.value.question),1),n[7]||=O(`span`,{class:`faint`},`(shown above)`,-1)])):(P(),k(F,{key:1},[O(`div`,id,[e.row.via?(P(),k(`span`,{key:0,class:`via`,title:`Raised by choosing “${e.row.via}”`},L(e.row.via)+` →`,9,ad)):V(``,!0),O(`h3`,{id:`q-${i.value.name}`,class:`words`},L(i.value.question),9,od)]),e.row.alsoRaisedBy!==void 0&&e.row.alsoRaisedBy.length>0?(P(),k(`p`,sd,[n[8]||=w(` Also raised by `,-1),(P(!0),k(F,null,A(e.row.alsoRaisedBy,(e,t)=>(P(),k(F,{key:`${e.question.name}-${e.via}`},[t>0?(P(),k(`span`,cd,`, `)):V(``,!0),O(`button`,{type:`button`,class:`link`,"data-testid":`plan-question-also-jump`,title:`Choosing “${e.via}” for “${e.question.question}”`,onClick:t=>r(`jump`,e.question.name)},` “`+L(e.via)+`” `,9,ld)],64))),128))])):V(``,!0),O(`div`,ud,[C(E(H),{tone:a.value.tone,"data-testid":`plan-question-state`},{default:I(()=>[w(L(a.value.label),1)]),_:1},8,[`tone`]),i.value.askedBy?(P(),k(`span`,dd,L(E(fu)[i.value.askedBy]??i.value.askedBy),1)):V(``,!0),C(E(se),{class:`faint item-link`,to:E(S).contextItem(i.value.name),"data-testid":`plan-question-item`,title:`Open ${i.value.name} on its context page to edit it`},{default:I(()=>[C(E(At),{name:`edit`,size:12}),n[9]||=w(` Context item `,-1)]),_:1},8,[`to`,`title`])]),o.value?(P(),k(`p`,fd,[u.value?V(``,!0):(P(),k(F,{key:0},[O(`span`,null,L(i.value.statusReason??`Ruled out`),1),O(`button`,{type:`button`,class:`link`,"data-testid":`plan-reason-edit`,onClick:n[1]||=e=>u.value=!0},`Edit reason`)],64))])):V(``,!0),o.value&&u.value?(P(),k(`div`,pd,[C(E(Mt),{modelValue:l.value,"onUpdate:modelValue":n[2]||=e=>l.value=e,label:`Why it doesn't apply`,rows:2,"data-testid":`plan-reason-text`},null,8,[`modelValue`]),O(`div`,md,[C(E(U),{size:`sm`,variant:`ghost`,onClick:n[3]||=e=>u.value=!1},{default:I(()=>[...n[10]||=[w(`Cancel`,-1)]]),_:1}),C(E(U),{size:`sm`,loading:e.busy,"data-testid":`plan-reason-save`,onClick:h},{default:I(()=>[...n[11]||=[w(`Save reason`,-1)]]),_:1},8,[`loading`])])])):V(``,!0),s.value?(P(),k(`p`,hd,`Answered in context before this plan; change it on its context page.`)):V(``,!0),i.value.options.length>0?(P(),k(`div`,{key:4,class:`chips`,role:`group`,"aria-label":`Options for ${i.value.question}`},[(P(!0),k(F,null,A(i.value.options,t=>(P(),k(`button`,{key:t.id,type:`button`,class:D([`chip`,{picked:i.value.picked.includes(t.id)}]),"aria-pressed":i.value.picked.includes(t.id)?`true`:`false`,disabled:o.value||s.value||e.busy,title:t.detail,"data-testid":`plan-option`,"data-option":t.id,onClick:e=>p(t.id)},[i.value.picked.includes(t.id)?(P(),R(E(At),{key:0,name:`check`,size:12})):V(``,!0),w(L(t.label),1)],10,_d))),128))],8,gd)):f.value?(P(),k(`p`,vd,`No options yet: planning deeper writes them.`)):V(``,!0),!o.value&&!s.value?(P(),k(`div`,yd,[C(E(Mt),{modelValue:c.value,"onUpdate:modelValue":n[4]||=e=>c.value=e,label:`Your own detail`,placeholder:`Anything the options leave out`,rows:1,"max-rows":6,disabled:e.busy,"data-testid":`plan-question-text`},null,8,[`modelValue`,`disabled`]),O(`div`,bd,[e.deeper&&e.canDeepen?(P(),R(E(U),{key:0,size:`sm`,variant:`ghost`,icon:`tree`,"data-testid":`plan-deeper-here`,onClick:n[5]||=e=>r(`deeper`,i.value.name)},{default:I(()=>[...n[12]||=[w(`Plan deeper here`,-1)]]),_:1})):f.value&&e.canDeepen?(P(),R(E(U),{key:1,size:`sm`,variant:`ghost`,icon:`tree`,"data-testid":`plan-deeper-here`,onClick:n[6]||=e=>r(`deeper`,i.value.name)},{default:I(()=>[...n[13]||=[w(`Write its options`,-1)]]),_:1})):V(``,!0),d.value?(P(),R(E(U),{key:2,size:`sm`,loading:e.busy,"data-testid":`plan-question-save`,onClick:m},{default:I(()=>[...n[14]||=[w(`Save`,-1)]]),_:1},8,[`loading`])):V(``,!0)])])):V(``,!0)],64))],14,td))}}),[[`__scopeId`,`data-v-0a11b25c`]]),Sd={key:0,class:`plan`},Cd={class:`top`},wd={class:`line`,"data-testid":`plan-dialog-counts`},Td={key:0,class:`outline`,"data-testid":`plan-outline`},Ed=q(N({__name:`PlanDialog`,props:ge({run:{},canDeepen:{type:Boolean,default:!0}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:ge([`deeper`],[`update:open`]),setup(e,{emit:t}){let n=e,r=_e(e,`open`),i=t,{context:a,toasts:o}=W(),s=a.plans,c=z(`outline`),l=[{value:`outline`,label:`Outline`,icon:`list`},{value:`graph`,label:`Graph`,icon:`graph`}];T([r,()=>n.run],([e])=>{e&&s.show(n.run)},{immediate:!0}),a.follow();let u=M(()=>s.open.value.value?.run===n.run?s.open.value.value.plan:void 0),d=M(()=>u.value===void 0?[]:uu(u.value)),f=M(()=>new Set(s.deeper.value));async function p(e){let t=await s.answer(n.run,e);if(!t.ok){o.error(`Couldn't save that`,t.problem);return}let[r]=t.value.skipped;r!==void 0&&o.error(`Part of that wasn't saved`,r.reason)}async function m(e){c.value=`outline`,await ke(),document.querySelector(`[data-testid="plan-question"][data-question="${CSS.escape(e)}"]`)?.scrollIntoView({block:`center`,behavior:`smooth`})}async function h(){let e=await s.markdown(n.run);if(e===void 0){o.error(`Couldn't export the plan`);return}let t=URL.createObjectURL(new Blob([e],{type:`text/markdown`})),r=document.createElement(`a`);r.href=t,r.download=hu(u.value?.description??`plan`),r.click(),URL.revokeObjectURL(t)}async function g(){let e=await s.markdown(n.run);e===void 0||!await _t(e)?o.error(`Couldn't copy the plan`):o.ok(`Copied the plan as markdown`)}return(t,n)=>(P(),R(E(ht),{open:r.value,"onUpdate:open":n[6]||=e=>r.value=e,title:`Plan`,description:u.value?.description??``,width:`min(920px, 100vw)`,"data-testid":`plan-dialog`},{footer:I(()=>[C(E(U),{variant:`ghost`,icon:`copy`,"data-testid":`plan-copy`,onClick:g},{default:I(()=>[...n[7]||=[w(`Copy markdown`,-1)]]),_:1}),C(E(U),{variant:`ghost`,icon:`download`,"data-testid":`plan-export`,onClick:h},{default:I(()=>[...n[8]||=[w(`Export`,-1)]]),_:1}),e.canDeepen?(P(),R(E(U),{key:0,icon:`tree`,"data-testid":`plan-deeper`,onClick:n[5]||=e=>i(`deeper`,void 0)},{default:I(()=>[...n[9]||=[w(`Plan deeper`,-1)]]),_:1})):V(``,!0)]),default:I(()=>[C(Pe,{loading:E(s).open.loading.value&&u.value===void 0,problem:E(s).open.problem.value,ready:u.value!==void 0,empty:!1,onRetry:n[4]||=t=>E(s).show(e.run)},{default:I(()=>[u.value?(P(),k(`div`,Sd,[O(`div`,Cd,[O(`p`,wd,L(E(pu)(u.value)),1),C(E(Bt),{modelValue:c.value,"onUpdate:modelValue":n[0]||=e=>c.value=e,options:l,label:`Plan view`,"data-testid":`plan-view`},null,8,[`modelValue`])]),c.value===`outline`?(P(),k(`ul`,Td,[(P(!0),k(F,null,A(d.value,(t,r)=>(P(),R(xd,{key:`${t.question.name}-${r}`,row:t,busy:E(s).busyQuestion.value===t.question.name,deeper:f.value.has(t.question.name),"can-deepen":e.canDeepen,onAnswer:n[1]||=e=>p({answer:e}),onReason:n[2]||=e=>p({reason:e}),onDeeper:n[3]||=e=>i(`deeper`,e),onJump:m},null,8,[`row`,`busy`,`deeper`,`can-deepen`]))),128))])):(P(),R(ed,{key:1,plan:u.value,onPick:m},null,8,[`plan`]))])):V(``,!0)]),_:1},8,[`loading`,`problem`,`ready`])]),_:1},8,[`open`,`description`]))}}),[[`__scopeId`,`data-v-e412ee45`]]),Dd=[`data-run`],Od={key:0,class:`lead`},kd={class:`title`},Ad=[`title`],jd={class:`counts`,"data-testid":`plan-card-counts`},Md={key:0},Nd={key:1,class:`limited`,"data-testid":`plan-card-stop`},Pd={class:`actions`},Fd=q(N({__name:`PlanCardBody`,props:{planRun:{},plan:{},lead:{default:``}},emits:[`deeper`],setup(e,{emit:t}){let n=e,r=t,i=Qt(),a=z(!1),o=M(()=>n.plan.stop===`complete`?``:On[n.plan.stop]),s=z(!1);function c(e){a.value=!1,s.value=!0,r(`deeper`,e),setTimeout(()=>{s.value=!1},1500)}return(t,n)=>(P(),k(`section`,{class:`plan-card`,"data-testid":`plan-card`,"data-run":e.planRun},[e.lead===``?V(``,!0):(P(),k(`p`,Od,L(e.lead),1)),O(`div`,kd,[C(E(At),{name:`tree`,size:16}),O(`p`,{class:`description`,title:e.plan.description},L(e.plan.description),9,Ad)]),O(`p`,jd,[O(`strong`,null,L(E(Bn)(e.plan.counts)),1),e.plan.counts.ruledOut>0?(P(),k(`span`,Md,` · `+L(e.plan.counts.ruledOut)+` ruled out`,1)):V(``,!0)]),o.value===``?V(``,!0):(P(),k(`p`,Nd,L(o.value)+`; Plan deeper goes on from there.`,1)),O(`div`,Pd,[E(i)?(P(),R(E(U),{key:0,size:`sm`,variant:`primary`,icon:`maximize`,"data-testid":`plan-card-open`,onClick:n[0]||=e=>a.value=!0},{default:I(()=>[...n[3]||=[w(`Open`,-1)]]),_:1})):V(``,!0),C(E(U),{size:`sm`,icon:`tree`,loading:s.value,"data-testid":`plan-card-deeper`,onClick:n[1]||=e=>c(void 0)},{default:I(()=>[...n[4]||=[w(`Plan deeper`,-1)]]),_:1},8,[`loading`])]),E(i)&&a.value?(P(),R(Ed,{key:2,open:a.value,"onUpdate:open":n[2]||=e=>a.value=e,run:e.planRun,onDeeper:c},null,8,[`open`,`run`])):V(``,!0)],8,Dd))}}),[[`__scopeId`,`data-v-b7e399b0`]]),Id=o(s,{results:{fns:{ctx_plan:N({__name:`PlanResult`,props:{run:{},fn:{},args:{},result:{},title:{},system:{}},setup(e){let t=e,n=M(()=>Un.safeParse(t.result));function r(e){t.system.run.ctx_plan_expand({run:t.run,...e===void 0?{}:{under:e}})}return(t,i)=>n.value.success?(P(),R(Fd,{key:0,"plan-run":e.run,plan:n.value.data,onDeeper:r},null,8,[`plan-run`,`plan`])):V(``,!0)}}),ctx_plan_expand:N({__name:`PlanExpandResult`,props:{run:{},fn:{},args:{},result:{},title:{},system:{}},setup(e){let t=e,n=M(()=>Kn.safeParse(t.result)),r=M(()=>t.args.replan===!0?`Re-planned`:`Planned deeper`);function i(e){n.value.success&&t.system.run.ctx_plan_expand({run:n.value.data.run,...e===void 0?{}:{under:e}})}return(e,t)=>n.value.success?(P(),R(Fd,{key:0,"plan-run":n.value.data.run,plan:n.value.data.plan,lead:r.value,onDeeper:i},null,8,[`plan-run`,`plan`,`lead`])):V(``,!0)}})}}}),Ld=class{#e;multiUser=z(!1);saving=new p;#t=!1;constructor(e){this.#e=e}async load(){if(!this.#t){this.#t=!0;try{this.multiUser.value=(await this.#e.accessInfo.call({})).multiUser}catch{this.#t=!1}}}view(e){let t=new v;return t.load(async()=>{let[t]=await this.#e.access.call({targets:[e]});if(t===void 0)throw Error(`The hub did not say who can use this.`);return t},`Couldn’t load who can use this.`),t}async set(e,t){return this.saving.run(()=>this.#e.setAccess.call({target:e,sharing:t}),`Couldn’t change who can use this.`)}};function Rd(e,t){let n=[...e.connections].sort((e,t)=>t.updatedAt-e.updatedAt);return{own:n.find(e=>e.owner===t),shared:n.filter(e=>e.owner!==t)}}function zd(e,t){return Object.entries(e.decl.fns).map(([n,r])=>{let i=t?.fns[n],a=i??r;return{local:n,name:`${e.system}/${n}`,option:a,changed:i!==void 0&&(i.on!==r.on||i.ask!==r.ask)}})}function Bd(e,t,n){return Object.fromEntries(e.map(e=>[e.local,e.local===t?{...e.option,...n}:e.option]))}var Vd={pending:{label:`Waiting for sign-in`,tone:`warn`},connected:{label:`Connected`,tone:`ok`},expired:{label:`Expired`,tone:`warn`},failed:{label:`Failed`,tone:`danger`}},Hd=e=>e in kt;function Ud(e){let t=e.decl.icon;return t!==void 0&&Hd(t)?t:`link`}function Wd(e){return e.map(e=>({system:e.system,title:e.decl.title,icon:Ud(e)})).sort((e,t)=>e.title.localeCompare(t.title))}var Gd=e=>e.name===`optional`?e.generic?.T??e:e,Kd=e=>{let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function qd(e,t){let n=e.name===`obj`?e.props:void 0;if(n===void 0||t===void 0)return;let r=Object.entries(n).map(([e,n])=>{let r=t[e];if(r!==void 0)return{key:e,label:Kd(e),hint:n.docs??``,many:Gd(n.type).name===`list`,options:r}});return r.every(e=>e!==void 0)&&r.length>0?r:void 0}function Jd(e,t){let n=typeof e==`object`&&e&&!Array.isArray(e)?e[t]:void 0;return Array.isArray(n)?n.filter(e=>typeof e==`string`):typeof n==`string`?[n]:[]}function Yd(e,t){return Object.fromEntries(e.flatMap(e=>{let n=t[e.key]??[];return n.length===0?[]:[[e.key,e.many?[...n]:n[0]??``]]}))}function Xd(e,t){return`key`in t?e.key===t.key:e.instance===t.instance}function Zd(e){return e.decl.scope===`instance`||e.decl.scope===`key`}function Qd(e,t,n){let r=[...e.connections].sort((e,t)=>t.updatedAt-e.updatedAt);return[...(e.instances??[]).map(e=>({target:{instance:e.instance},id:e.instance,label:e.label,connect:e.connect})),...(e.keys??[]).map(e=>({target:{key:e.key},id:e.key,label:e.label,connect:e.connect,host:e.host}))].map(e=>{let i=r.filter(t=>Xd(t,e.target)),a=e.connect.flow?.flow??`none`;return{...e,own:i.find(e=>e.owner===t),shared:i.filter(e=>e.owner!==t),flow:a,mayConnect:a!==`none`&&(!e.connect.share||n)}}).sort((e,t)=>e.label.localeCompare(t.label))}var $d=class{#e;pages=new v;saving=new p;nav=M(()=>Wd(this.pages.value.value??[]));constructor(e){this.#e=e}async load(e=!1){await this.pages.load(()=>this.#e.connectPages.call({}),`Couldn’t load the connect pages.`,e)}page(e){return this.pages.value.value?.find(t=>t.system===e)}async connect(e,t,n){let r={system:e,...t===void 0?{}:{form:t},...n},i=await this.saving.run(()=>this.#e.connect.call(r),`Couldn’t start connecting.`);return i.ok&&`connection`in i.value&&this.#t(i.value.connection),i}async update(e){let t=await this.saving.run(()=>this.#e.updateConnection.call(e),`Couldn’t save the change.`);return t.ok&&this.#t(t.value),t}async disconnect(e){let t=await this.saving.run(async()=>(await this.#e.disconnect.call({connection:e})).ok,`Couldn’t disconnect.`);return t.ok&&this.#n(e),t}#t(e){this.#r(e.system,t=>[e,...t.filter(t=>t.id!==e.id)])}#n(e){let t=this.pages.value.value?.find(t=>t.connections.some(t=>t.id===e));t!==void 0&&this.#r(t.system,t=>t.filter(t=>t.id!==e))}#r(e,t){let n=this.pages.value.value;n!==void 0&&this.pages.set(n.map(n=>n.system===e?{...n,connections:t(n.connections)}:n))}},ef=class{#e;#t=new Map;#n;constructor(e){this.#e=e}source(e){let t=this.#t.get(e);if(t!==void 0)return t;let n={search:async t=>this.#e.pick.call({source:e,limit:12,...t===``?{}:{text:t}}),label:async t=>t.length===0?[]:this.#e.pick.call({source:e,values:[...t]})};return this.#t.set(e,n),n}people(){if(this.#n!==void 0)return this.#n;let e=this.source(`person`),t=this.source(`group`);return this.#n={search:async n=>(await Promise.all([e.search(n),t.search(n)])).flat(),label:async n=>tf(n,await Promise.all([e.label(n),t.label(n)]))},this.#n}};function tf(e,t){let n=t.flat();return e.map(e=>n.find(t=>t.value===e&&t.missing!==!0)??{value:e,label:e,missing:!0})}var nf=class{#e;#t;#n;#r=0;value=B(void 0);session=z(void 0);problem=z(``);can=M(()=>{let e=this.value.value;return{mention:(e?.mentions.length??0)>0,command:(e?.commands.length??0)>0,invoke:(e?.invocations.length??0)>0,upload:e?.uploads===!0,voice:e?.voiceInput===!0}});constructor(e,t){this.#e=e,this.#t=t}start(){this.#n===void 0&&(this.#n=this.#t(e=>{this.#i(e)}))}stop(){this.#n?.(),this.#n=void 0}async load(e=this.session.value){this.session.value=e;let t=++this.#r;try{let n=await this.#e.capabilities.call(e===void 0?{}:{session:e});if(t!==this.#r)return;this.value.value=n,this.problem.value=``}catch(e){t===this.#r&&(this.problem.value=J(e,`Couldn't load what this chat can do.`))}}online(e){return this.value.value?.systems.find(t=>t.name===e)?.status===`connected`}invocation(e){return this.value.value?.invocations.find(t=>t.fn===e)}commandFor(e){return this.value.value?.commands.find(t=>t.context===e)}#i(e){if(e.type===`capabilities`)this.#e.capabilities.invalidate(),this.load();else if(e.type===`system`){let t=this.value.value;if(t===void 0)return;this.value.value={...t,systems:t.systems.map(t=>t.name===e.system?{...t,status:e.status}:t)}}}},rf=`harness.runCards`,af=new Set([`hub/ctx_plan`,`hub/ctx_plan_expand`]),of=wn([Ln,bn()]);function sf(e){return e.status===`done`&&e.fn!==void 0&&af.has(e.fn)||e.status===`done`&&e.outcome?.status===`done`&&oi(e.outcome.result)?!1:e.status===`done`||e.status===`undone`}var cf=class{#e;constructor(e){this.#e=Br(e,rf,_n(of),[])}choice(e){return this.#e.value.find(([t])=>t===e)?.[1]}isCollapsed(e){return this.choice(e.id)??sf(e)}set(e,t){this.setAll([e],t)}setAll(e,t){let n=new Set(e),r=this.#e.value.filter(([e])=>!n.has(e));this.#e.value=[...r,...e.map(e=>[e,t])].slice(-500)}};async function lf(e,t,n,r,i){let a=n.outgoing();if(a===void 0)return{ok:!1,problem:`Write the message to compare first.`};let o=n.snapshot();n.clear(`keep`);try{let o=await e.compare.call({session:t.id,parts:[...a.parts],variants:[...r],client:i});return t.messages.value=We(t.messages.value,o.message),n.uploads.clear(),{ok:!0,value:o.turn}}catch(e){return n.restore(o),{ok:!1,problem:J(e,`Couldn’t start the compare. Your message is back in the box.`)}}}function uf(e,t){let n=setTimeout(e,t);return()=>{clearTimeout(n)}}var df=class{view=new v;streamed=B(new Map);choosing=new p;deciding=new p;turn;#e;#t;#n=new Map;#r;constructor(e,t,n){this.#t=e,this.#e=t,this.turn=n}async open(){this.#i(this.#e),await this.view.load(()=>this.#t.api.compareView.call({turn:this.turn}),`Couldn’t load the compare.`);for(let e of this.view.value.value?.variants??[])this.#i(e.session)}close(){for(let e of this.#n.values())e();this.#n.clear(),this.#r?.(),this.#r=void 0}async choose(e,t){let n=await this.choosing.run(()=>this.#t.api.chooseVariant.call({turn:this.turn,variant:e,adopt:t}),`Couldn’t use that answer.`);return n.ok&&this.view.set(n.value),n}async decide(e,t,n,r,i){let a=await this.deciding.run(()=>this.#t.api.approve.call({approval:e,approve:t,remember:n,...r===``?{}:{reason:r},...i===void 0?{}:{answer:i}}),`Couldn’t answer that.`);return a.ok&&this.#o(),a.ok}#i(e){this.#n.has(e)||this.#n.set(e,this.#t.events(e,t=>{this.#a(e,t)}))}#a(e,t){switch(t.type){case`compare`:t.turn===this.turn&&this.#o();return;case`token`:case`reasoning`:{if(e===this.#e)return;let n=new Map(this.streamed.value),r=n.get(t.message)??{text:``,reasoning:``};n.set(t.message,t.type===`token`?{...r,text:r.text+t.text}:{...r,reasoning:r.reasoning+t.text}),this.streamed.value=n;return}case`message`:case`approval`:case`run`:e!==this.#e&&this.#o();return;case`controls`:case`state`:case`delivery`:case`handler`:case`budget`:case`presence`:case`session`:case`cite`:return}}#o(){this.#r?.(),this.#r=(this.#t.later??uf)(()=>{this.#r=void 0,this.view.load(()=>this.#t.api.compareView.call({turn:this.turn}),`Couldn’t load the compare.`,!0).then(()=>{this.streamed.value=new Map})},300)}},ff=e=>`harness.draft.${e}`,pf=K({text:G(),mentions:_n(cr).transform(e=>e.filter(e=>e.type===`mention`)),replyTo:$n.optional(),replyAll:bn()}),mf={delay:120,perProvider:6,max:24},hf=(e,t)=>e.provider===t.provider&&JSON.stringify(e.target)===JSON.stringify(t.target),gf=(e,...t)=>{let n=e.toLowerCase();return n===``||t.some(e=>e.toLowerCase().includes(n))},_f=class{session;uploads;#e;#t;#n;#r;#i=0;#a;text=z(``);caret=z(0);mentions=B([]);replyTo=z(void 0);replyAll=z(!1);editing=z(void 0);invoking=B(void 0);caretRequest=z(void 0);pickerItems=B([]);pickerActive=z(0);pickerLoading=z(!1);#o=z(void 0);trigger=M(()=>{let e=Ve(this.text.value,this.caret.value),t=this.#e.capabilities();if(e!==void 0&&t!==void 0)return(e.kind===`mention`?t.mentions.length>0:e.kind===`command`?t.commands.length>0:t.invocations.length>0)?e:void 0});pickerOpen=M(()=>{let e=this.trigger.value;return e!==void 0&&this.#o.value!==`${e.kind}:${e.start}`});hint=M(()=>rt(this.text.value,this.#e.capabilities()?.commands??[]));canSend=M(()=>!this.uploads.busy.value&&(this.text.value.trim()!==``||this.uploads.parts.value.length>0));constructor(e,t=mf){this.session=e.session,this.uploads=e.uploads,this.#e=e,this.#t=t,this.#n=Br(e.store,ff(e.session),pf.optional(),void 0);let n=this.#n.value;n!==void 0&&(this.text.value=n.text,this.caret.value=n.text.length,this.mentions.value=n.mentions,this.replyTo.value=n.replyTo,this.replyAll.value=n.replyAll),T([this.text,this.mentions,this.replyTo,this.replyAll],()=>{this.#c()}),T(()=>[this.trigger.value?.kind,this.trigger.value?.query,this.trigger.value?.start],()=>{this.#l()})}input(e,t){this.text.value=e,this.caret.value=t,this.mentions.value=Re(e,this.mentions.value)}moveCaret(e){this.caret.value=e}movePicker(e){let t=this.pickerItems.value.length;t!==0&&(this.pickerActive.value=(this.pickerActive.value+e+t)%t)}dismissPicker(){let e=this.trigger.value;e!==void 0&&(this.#o.value=`${e.kind}:${e.start}`)}pick(e=this.pickerItems.value[this.pickerActive.value]){let t=this.trigger.value;if(e!==void 0&&t!==void 0){if(e.kind===`mention`){let n={type:`mention`,provider:e.provider,label:e.option.label,target:e.option.target},r=this.mentions.value.find(e=>hf(e,n)),i=r??n;this.#s(t,`${Le(i)} `),r===void 0&&(this.mentions.value=[...this.mentions.value,i])}else if(e.kind===`command`){if(e.command.unavailable!==void 0)return;this.#s(t,`/${e.command.name} `)}else this.#s(t,``),this.invoking.value=e.invocation}}openInvocation(e,t){this.invoking.value=e,this.#a=t}closeInvocation(){this.invoking.value=void 0,this.#a=void 0}invocationArgs(e){return this.#a===void 0?e:tt(e,this.#a)}insert(e){let t=this.caret.value,n=this.text.value.slice(0,t),r=n===``||/\s$/.test(n)?e:` ${e}`,i=ze(this.text.value,t,t,r);this.text.value=i.text,this.caret.value=i.caret,this.caretRequest.value=i.caret}replace(e){this.text.value=e,this.caret.value=e.length,this.caretRequest.value=e.length,this.mentions.value=Re(e,this.mentions.value)}setReply(e){this.replyTo.value=e}outgoing(){if(!this.canSend.value)return;let e=[...nt(this.text.value,this.mentions.value,this.#e.capabilities()?.commands??[]),...this.uploads.parts.value];if(e.length!==0)return{parts:e,replyTo:this.replyTo.value,replyAll:this.replyAll.value}}startEdit(e,t,n){this.editing.value=e,this.replyTo.value=void 0,this.mentions.value=n,this.replace(t)}cancelEdit(){this.editing.value=void 0,this.clear()}snapshot(){return{editing:this.editing.value,text:this.text.value,mentions:this.mentions.value,replyTo:this.replyTo.value,replyAll:this.replyAll.value}}restore(e){this.editing.value=e.editing,this.text.value=e.text,this.caret.value=e.text.length,this.mentions.value=e.mentions,this.replyTo.value=e.replyTo,this.replyAll.value=e.replyAll}clear(e=`clear`){this.text.value=``,this.caret.value=0,this.caretRequest.value=0,this.mentions.value=[],this.replyTo.value=void 0,this.editing.value=void 0,e===`clear`&&this.uploads.clear()}dispose(){clearTimeout(this.#r),this.uploads.clear()}#s(e,t){let n=ze(this.text.value,e.start,e.end,t);this.text.value=n.text,this.caret.value=n.caret,this.caretRequest.value=n.caret}#c(){let e=this.text.value===``&&this.replyTo.value===void 0&&!this.replyAll.value;this.#n.value=e?void 0:{text:this.text.value,mentions:[...this.mentions.value],replyAll:this.replyAll.value,...this.replyTo.value===void 0?{}:{replyTo:this.replyTo.value}}}#l(){clearTimeout(this.#r);let e=++this.#i;this.pickerActive.value=0;let t=this.trigger.value,n=this.#e.capabilities();t===void 0||n===void 0?(this.pickerItems.value=[],this.pickerLoading.value=!1):t.kind===`command`?this.pickerItems.value=n.commands.filter(e=>gf(t.query,e.name,e.description)).slice(0,this.#t.max).map(e=>({kind:`command`,key:`c:${e.context}:${e.name}`,command:e})):t.kind===`invoke`?this.pickerItems.value=n.invocations.filter(e=>gf(t.query,e.fn,rn(e.fn),e.description)).slice(0,this.#t.max).map(e=>({kind:`invoke`,key:`i:${e.fn}`,invocation:e})):(this.pickerLoading.value=!0,this.#r=setTimeout(()=>{this.#u(t.query,n.mentions,e)},this.#t.delay))}async#u(e,t,n){let r=await Promise.all(t.map(async t=>{try{return(await this.#e.api.mentions.call({session:this.session,provider:t.provider,query:e})).slice(0,this.#t.perProvider).map((e,n)=>({kind:`mention`,key:`m:${t.provider}:${n}:${e.label}`,provider:t.provider,group:t.title,option:e}))}catch{return[]}}));n===this.#i&&(this.pickerItems.value=r.flat().slice(0,this.#t.max),this.pickerLoading.value=!1)}},vf=class{#e;run=new v;tree=new v;treeTurn=z(void 0);resource=new v;calls=B(new Map);callProblems=B(new Map);constructor(e){this.#e=e}async openRun(e){this.run.value.value?.id!==e&&this.run.reset(),await this.run.load(()=>this.#e.run.call({run:e}),`Couldn't load this run.`,this.run.value.value?.id===e)}async openResource(e){this.resource.value.value?.stat.uri!==e&&this.resource.reset(),await this.resource.load(()=>this.#e.resource.call({uri:e,want:[`text`,`links`]}),`Couldn't open this.`)}async openTree(e){this.treeTurn.value!==e&&this.tree.reset(),this.treeTurn.value=e,await this.tree.load(()=>this.#e.tree.call({turn:e}),`Couldn't load this turn's tree.`)}refreshTree(){let e=this.treeTurn.value;e!==void 0&&this.tree.load(()=>this.#e.treeRefresh.call({turn:e}),`Couldn't refresh this turn's tree.`,!0)}closeTree(){this.#e.treeRefresh.cancel(),this.treeTurn.value=void 0,this.tree.reset()}async loadCalls(e){let t=[...new Set(e)].filter(e=>!this.calls.value.has(e));await Promise.all(t.map(async e=>{try{let t=await this.#e.llmCall.call({id:e}),n=new Map(this.calls.value);n.set(e,t),this.calls.value=n}catch(t){let n=new Map(this.callProblems.value);n.set(e,J(t,`Couldn't load this LLM call.`)),this.callProblems.value=n}}))}async loadTurn(e){await this.openTree(e);let t=this.tree.value.value;if(t===void 0)return[];let n=le(t);return await this.loadCalls(n),n.flatMap(e=>{let t=this.calls.value.get(e);return t===void 0?[]:[t]})}dispose(){this.#e.treeRefresh.cancel()}},yf=(e,t)=>`${e}:${JSON.stringify(t)}`,bf=class{#e;cards=B(new Map);constructor(e){this.#e=e}card(e,t){return this.cards.value.get(yf(e,t))??{loading:!0,hover:void 0,problem:``}}async load(e,t,n){let r=yf(t,n),i=this.cards.value.get(r);if(i===void 0||!i.loading&&i.problem!==``){this.#t(r,{loading:!0,hover:void 0,problem:``});try{let{hover:i}=await this.#e.mentionHover.call({session:e,provider:t,target:n});this.#t(r,{loading:!1,hover:i,problem:``})}catch(e){this.#t(r,{loading:!1,hover:void 0,problem:J(e,`Not available right now.`)})}}}#t(e,t){let n=new Map(this.cards.value);n.set(e,t),this.cards.value=n}},xf=Symbol.for(`harness.shared`);function Sf(e){Reflect.set(globalThis,xf,{vue:e.vue,"@harness/sdk":e.sdk})}function Cf(e){return typeof e==`object`&&!!e&&`system`in e&&typeof e.system==`string`&&`renderers`in e&&typeof e.renderers==`object`&&e.renderers!==null&&`contract`in e&&typeof e.contract==`object`&&e.contract!==null}function wf(e){return typeof e==`object`&&`component`in e&&`mode`in e}function Tf(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))}function Z(e){let t=e.indexOf(`/`);return{system:e.slice(0,t),local:e.slice(t+1)}}function Ef(e,t){if(e===void 0)return{};if(!(e instanceof or)){let r=n(e,t);return typeof r==`object`&&r?{...r}:{}}let r=e.fields;return Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let i=r[e];return i===void 0?[]:[[e,n(i.type,t)]]}))}function Df(e){let t=e.renderers;return{renderers:{fns:t.fns??{},kinds:t.kinds??{},attachments:t.attachments??{},inputs:t.inputs??{},mentions:t.mentions??{},resultFns:t.results?.fns??{},resultKinds:t.results?.kinds??{}},config:Of(e),pages:kf(e),actions:e.contract.defs.actions,fns:e.contract.defs.fns,forms:Object.fromEntries(Object.entries(e.contract.defs.fns).map(([e,t])=>[e,t.form])),attachments:Tf(e.contract.defs.attachments,e=>e.data),types:Tf(e.contract.defs.types,e=>e.shape),mentions:Tf(e.contract.defs.mentions,e=>e.target)}}function Of(e){let t=e.contract.configComponent,n=t===void 0?void 0:e.renderers.configs?.[t.component];return t===void 0||n===void 0?void 0:{component:n,mode:t.mode,type:e.contract.defs.config}}function kf(e){let t=e.renderers.pages??{};return new Map(e.contract.pages.flatMap(e=>{let n=t[e.component];return n===void 0?[]:[[e.segment,{decl:e,component:n}]]}))}var Af=class{#e=new Map;#t;#n=new Map;#r=new Map;#i=new Map;constructor(e){this.#t=e}register(e){this.#n.set(e.system,Df(e));for(let t of this.#i.keys())(t===e.system||t.startsWith(`${e.system} `))&&this.#i.delete(t);for(let[t,n]of this.#r)this.#r.set(t,n.filter(t=>t.system!==e.system));for(let[t,n]of this.#e)this.#e.set(t,n.filter(t=>t.system!==e.system));for(let[t,n]of Object.entries(e.renderers.visuals??{})){let r=Xn.parse(t),i=Object.entries(n).flatMap(([t,n])=>{let i=e.contract.contributes.find(e=>e.registry===r&&e.name===t);return i?.shape===void 0?[]:[{system:e.system,name:t,label:i.label,icon:i.icon,shape:i.shape,veto:(e,t)=>n.veto?.(e,t),component:n.component}]});this.#e.set(r,[...this.#e.get(r)??[],...i])}let t=e.renderers.resources??{};for(let[n,r]of Object.entries(t)){let t=wf(r)?{component:r.component,system:e.system,mode:r.mode,label:r.label??e.system}:{component:r,system:e.system,mode:`replace`,label:e.system};this.#r.set(n,[...this.#r.get(n)??[],t])}}async load(e){let t=await import(e),n=typeof t==`object`&&t&&`default`in t?t.default:void 0;if(!Cf(n))throw Error(`${e} is not a system client module (its default export should be client(contract, renderers)).`);return this.register(n),n}visuals(e,t,n){return(this.#e.get(e)??[]).flatMap(r=>{let i;try{i=r.veto(t,n)}catch(t){return console.warn(`client.visual.veto-failed`,{registry:e,system:r.system,name:r.name,error:t}),[]}return i===void 0?[{system:r.system,name:r.name,label:r.label,...r.icon===void 0?{}:{icon:r.icon},shape:r.shape,component:r.component,client:this.systemClient(r.system)}]:[]})}systems(){return[...this.#n.keys()]}fnRenderer(e,t){return this.#s(e,`fns`)??(t===void 0?void 0:this.#s(t,`kinds`))}attachmentRenderer(e){return this.#s(e,`attachments`)}inputRenderer(e){return this.#s(e,`inputs`)}mentionRenderer(e){return this.#s(e,`mentions`)}resourceViewers(e){return this.#r.get(e)??[]}resourceViewer(e){return this.#a(e)?.component}viewerSystem(e){return this.#a(e)?.system}#a(e){return this.resourceViewers(e).find(e=>e.mode===`replace`)}systemClient(e,t){let r=t===void 0?e:`${e} ${t}`,a=this.#i.get(r);if(a!==void 0)return a;let o=this.#n.get(e),s=this.#t,c=t===void 0?{}:{run:t},l={get online(){return s.online(e)},send:Object.fromEntries(Object.entries(o?.actions??{}).map(([t,r])=>[t,a=>this.#c(e=>n(r.returns,e),()=>s.act({system:e,action:t,input:i(r.input,a),...c}))])),run:Object.fromEntries(Object.entries(o?.fns??{}).map(([t,n])=>[t,r=>Promise.resolve().then(()=>s.invoke({fn:mn(e,t),args:i(n.args,r)}))]))};return this.#i.set(r,l),l}submit(e,t,n){let r=i(t,n);return this.#c(()=>void 0,()=>this.#t.submit({run:e,value:r}))}formSubmit(e,t){let{system:n,local:r}=Z(e),i=this.#n.get(n)?.forms[r];return i===void 0?void 0:e=>this.submit(t,i,e)}fnView(e){let{fn:t,kind:r,args:i,result:a,state:o,...s}=e,c=this.#s(t,`fns`),l={...s,submit:this.formSubmit(t,e.run)};if(c!==void 0){let{system:r,local:s}=Z(t),u=this.#n.get(r)?.fns[s];if(u===void 0)return;let d=this.#o(t,()=>({args:n(u.args,i),state:Ef(u.state,o),...a===void 0?{}:{result:n(u.returns,a)}}));return d===void 0?void 0:{component:c,props:{...l,...d,system:this.systemClient(r,e.run)}}}let u=r===void 0?void 0:this.#s(r,`kinds`);if(r!==void 0&&u!==void 0)return{component:u,props:{...l,args:i,state:o,...a===void 0?{}:{result:a},system:this.systemClient(Z(r).system,e.run)}}}resultView(e){let{kind:t,args:r,result:i,...a}=e,o=this.#s(e.fn,`resultFns`);if(o!==void 0){let{system:t,local:s}=Z(e.fn),c=this.#n.get(t)?.fns[s];if(c===void 0)return;let l=this.#o(e.fn,()=>({args:n(c.args,r),result:n(c.returns,i)}));return l===void 0?void 0:{component:o,props:{...a,...l,system:this.systemClient(t,e.run)}}}let s=t===void 0?void 0:this.#s(t,`resultKinds`);if(t!==void 0&&s!==void 0)return{component:s,props:{...a,args:r,result:i,system:this.systemClient(Z(t).system,e.run)}}}attachmentView(e){let t=this.#s(e.attachment,`attachments`),{system:r,local:i}=Z(e.attachment),a=this.#n.get(r)?.attachments[i];if(t===void 0||a===void 0)return;let o=this.#o(e.attachment,()=>n(a,e.data));return o===void 0?void 0:{component:t,props:{data:o,title:e.title,system:this.systemClient(r)}}}mentionView(e){let t=this.#s(e.provider,`mentions`),{system:r,local:i}=Z(e.provider),a=this.#n.get(r)?.mentions[i];if(t===void 0||a===void 0)return;let o=this.#o(e.provider,()=>n(a,e.target));return o===void 0?void 0:{component:t,props:{label:e.label,target:o,hover:e.hover,system:this.systemClient(r)}}}inputView(e){let t=this.#s(e,`inputs`),{system:r,local:a}=Z(e),o=this.#n.get(r)?.types[a];if(t!==void 0&&o!==void 0)return{component:t,props:{system:this.systemClient(r)},decode:t=>t===void 0?void 0:this.#o(e,()=>n(o,t)),encode:t=>t===void 0?void 0:this.#o(e,()=>i(o,t))}}configView(e,t){let r=this.#n.get(e)?.config;if(r===void 0)return;let a=mn(e,`config`),o=r.type;return{component:r.component,mode:r.mode,props:{config:t.config===void 0?void 0:this.#o(a,()=>n(o,t.config)),type:o,validate:e=>Promise.resolve().then(()=>t.validate(i(o,e))),change:e=>{t.change(i(o,e))},system:this.systemClient(e)}}}pages(e){return[...this.#n.get(e)?.pages.values()??[]].map(e=>e.decl)}pageView(e,t,n){let r=this.#n.get(e)?.pages.get(t);return r===void 0?void 0:{component:r.component,props:{...n,page:t,system:this.systemClient(e)}}}#o(e,t){try{return t()}catch(t){console.warn(`client.view.unfit`,{name:e,error:t});return}}#s(e,t){let{system:n,local:r}=Z(e);return this.#n.get(n)?.renderers[t][r]}#c(e,t){let n=this.#t,r=Te({id:void 0,status:ln.enum.queued}),i=t().then(async t=>(r.id=t,e(await n.follow(t,e=>{r.status=e}))));return i.catch(()=>void 0),{get id(){return r.id},get status(){return r.status},result:i}}},jf=class{runtime;#e;#t=new Map;#n;status=B(new Map);version=B(0);constructor(e){this.#e=e;let t={online:t=>e.online(t),act:({system:e,action:t,input:n,run:r})=>Promise.resolve().then(()=>this.#i().act(Cn.parse(e),t,n,r)),submit:async({run:e,value:t})=>{let n=await this.#i().submit(e,t);if(n===void 0)throw Error(`Couldn't submit that.`);return n},invoke:async({fn:e,args:t})=>{let n=await this.#i().invoke(e,t);if(n===void 0)throw Error(`Couldn't run that.`);return n},follow:(e,t)=>Promise.resolve().then(()=>this.#i().follow(e,t))};this.runtime=new Af(t)}async sync(e){let t=e.filter(e=>this.#t.get(e.system)!==e.hash);t.length!==0&&(this.#n??=this.#e.share?.()??Promise.resolve(),await this.#n,await Promise.all(t.map(async e=>{this.#t.set(e.system,e.hash),this.#a(e.system,`loading`);try{await(this.#e.load??((e,t)=>e.load(t).then(()=>void 0)))(this.runtime,e.url),this.#a(e.system,`ready`),this.version.value++}catch(t){console.error(`chat.renderer.load-failed`,{system:e.system,url:e.url,error:t}),this.#a(e.system,`failed`)}})))}fnView(e,t){if(this.#r(),e.args===void 0)return;let n=fr(e),r=dr(e);return this.runtime.fnView({fn:e.fn,kind:e.kind===void 0||e.kind===`native`?void 0:e.kind,run:e.id,status:ur(e),args:e.args,state:t,...n===void 0?{}:{result:n},...r===void 0?{}:{error:r},...e.progress===void 0?{}:{progress:e.progress}})}resultView(e,t){this.#r();let n=fr(e);if(e.status===`done`&&e.args!==void 0&&n!==void 0)return this.runtime.resultView({fn:e.fn,kind:e.kind===void 0||e.kind===`native`?void 0:e.kind,run:e.id,args:e.args,result:n,title:t})}pageView(e,t,n){return this.#r(),this.runtime.pageView(e,t,n)}attachmentView(e){return this.#r(),this.runtime.attachmentView({attachment:e.attachment,data:e.data,title:e.title})}inputView(e){this.#r();let t=Xn.safeParse(e);return t.success?this.runtime.inputView(t.data):void 0}mentionView(e,t){return this.#r(),this.runtime.mentionView({provider:e.provider,label:e.label,target:e.target,hover:t})}contributedVisuals(e,t,n){return this.#r(),this.runtime.visuals(e,t,n)}#r(){return this.version.value}#i(){let e=this.#e.thread();if(e===void 0)throw Error(`No chat is open.`);return e}#a(e,t){let n=new Map(this.status.value);n.set(e,t),this.status.value=n}},Mf=(e,t)=>t.updatedAt-e.updatedAt;function Nf(e){return e.updatedAt===e.createdAt}function Pf(e){return En.parse(e)}var Ff=class{#e;#t;#n;#r;items=B([]);search=z(``);archived=z(!1);loading=z(!1);loadingMore=z(!1);loaded=z(!1);problem=z(``);creating=z(!1);partial=z(!1);#i=z(!1);hasMore=M(()=>this.#i.value);constructor(e,t){this.#e=e,this.#t=t}start(){this.#n===void 0&&(this.#n=this.#t(e=>{this.#u(e)}))}stop(){this.#n?.(),this.#n=void 0,this.#e.searchSessions.cancel()}load(){return this.#e.searchSessions.cancel(),this.#a(e=>this.#e.sessions.call(e))}async#a(e){this.loading.value=!0,this.problem.value=``;try{let t=await e(this.#s());this.items.value=t.items,this.#r=t.cursor,this.#i.value=t.cursor!==void 0,this.partial.value=te(t),this.loaded.value=!0,this.loading.value=!1}catch(e){if(Ar(e))return;this.problem.value=J(e,`Couldn't load your chats.`),this.loading.value=!1}}async loadMore(){let e=this.#r;if(!(e===void 0||this.loadingMore.value)){this.loadingMore.value=!0;try{let t=await this.#e.sessions.call(this.#s(e)),n=new Set(this.items.value.map(e=>e.id));this.items.value=[...this.items.value,...t.items.filter(e=>!n.has(e.id))],this.#r=t.cursor,this.#i.value=t.cursor!==void 0}catch(e){this.problem.value=J(e,`Couldn't load more chats.`)}finally{this.loadingMore.value=!1}}}setSearch(e){this.search.value=e,this.#e.sessions.cancel(),this.#a(e=>this.#e.searchSessions.call(e))}async showArchived(e){this.archived.value=e,await this.load()}listed(e){return this.items.value.filter(t=>!Nf(t)||t.id===e)}async create(e={}){if(this.creating.value)return;let t=e.agent===void 0&&e.title===void 0&&!this.archived.value?this.items.value.find(Nf):void 0;if(t!==void 0)return t.id;this.creating.value=!0;try{let t=await this.#e.createSession.call(e);return this.#c(Pf(t)),t.id}catch(e){this.problem.value=J(e,`Couldn't start a new chat.`);return}finally{this.creating.value=!1}}async rename(e,t){return this.#o(e,{title:t},e=>({...e,title:t}))}async archive(e,t){return this.#o(e,{archived:t},e=>({...e,archived:t}))}async remove(e){let t=this.items.value;this.items.value=t.filter(t=>t.id!==e);try{return await this.#e.deleteSession.call({session:e}),!0}catch(e){return this.items.value=t,this.problem.value=J(e,`Couldn't delete that chat.`),!1}}find(e){return this.items.value.find(t=>t.id===e)}remember(e){this.#c(e)}async#o(e,t,n){let r=this.items.value,i=r.find(t=>t.id===e);i!==void 0&&this.#c(n(i));try{let n=await this.#e.updateSession.call({session:e,...t});return this.#c(Pf(n)),!0}catch(e){return this.items.value=r,this.problem.value=J(e,`Couldn't change that chat.`),!1}}#s(e){let t=ie(re(`sessions`,this.search.value)),n=t.filters??[],r={field:`archived`,op:`is`,value:this.archived.value};return g({query:n.some(e=>e.field===`archived`)?t:{...t,filters:[...n,r]}},40,e)}#c(e){let t=this.items.value.filter(t=>t.id!==e.id);if(!(e.archived===this.archived.value&&this.#l(e))){this.items.value=t;return}if((re(`sessions`,this.search.value).sort??[]).length===0){this.items.value=[e,...t].sort(Mf);return}let n=this.items.value.findIndex(t=>t.id===e.id);this.items.value=n<0?[e,...t]:this.items.value.map(t=>t.id===e.id?e:t)}#l(e){let t=(re(`sessions`,this.search.value).text??``).toLowerCase();return t===``||e.title.toLowerCase().includes(t)}#u(e){e.type===`session-deleted`?this.items.value=this.items.value.filter(t=>t.id!==e.session):e.type===`session`&&(this.items.value.some(t=>t.id===e.session.id)||this.loaded.value)&&this.#c(e.session)}},If=class{#e;#t;report=new v;text=z(``);constructor(e,t){this.#e=e,this.#t=t}async preview(e){let t=e.trim();t!==``&&(this.text.value=t,await this.report.load(()=>this.#e.previewSelection.call({session:this.#t,text:t}),`Couldn't preview this message.`))}clear(){this.text.value=``,this.report.reset()}},Lf={minLength:12,limit:6},Rf=class{#e;#t;#n;#r=``;items=B([]);loading=z(!1);constructor(e,t,n=Lf){this.#e=e,this.#t=t,this.#n=n}update(e){let t=e.trim();t.length<this.#n.minLength||t.startsWith(`/`)||t.startsWith(`!`)?this.clear():t!==this.#r&&this.#i(t)}clear(){this.#e.suggest.cancel(),this.items.value=[],this.loading.value=!1,this.#r=``}async#i(e){this.#r=e,this.loading.value=!0;try{let t=await this.#e.suggest.call({session:this.#t,text:e,limit:this.#n.limit});this.items.value=[...t].sort((e,t)=>t.score-e.score),this.loading.value=!1}catch(e){if(Ar(e))return;this.#r=``,this.items.value=[],this.loading.value=!1}}},zf={delays:[500,1e3,2e3,4e3,8e3,15e3],sleep:e=>new Promise(t=>{setTimeout(t,e)})};async function Bf(e,t,n,r=()=>void 0){for(let i=0;n();i++)try{return await e(),!0}catch(e){if(r(e),!n())return!1;await t.sleep(t.delays[Math.min(i,t.delays.length-1)]??1e3)}return!1}var Vf={now:()=>typeof document>`u`||document.visibilityState===`visible`,watch:e=>typeof document>`u`?()=>void 0:(document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)})},Hf={page:50,runsOnOpen:60,typingFor:6e3,presenceEvery:3e3};function Uf(e){return{reports:e,undone:e.reduce((e,t)=>e+t.undone.length,0),failed:e.reduce((e,t)=>e+t.failed.length,0),notUndoable:e.reduce((e,t)=>e+t.notUndoable.length,0),kept:e.reduce((e,t)=>e+Wf(t),0)}}function Wf(e){return(e.kept??[]).reduce((e,t)=>e+t.effects.length,0)}function Gf(e,t){return Nn(e,t.name,t.type)}var Kf=class{id;#e;#t;#n;#r;#i=new Set;#a=new Map;#o=new Map;#s=new Map;#c=new Set;#l=new Set;#u=0;#d=!1;#f=!1;#p;session=B(void 0);messages=B([]);live=B(new Map);liveCites=B(new Map);runs=B(new Map);approvals=B([]);handlers=B([]);budgets=B([]);deliveries=B(new Map);presence=B([]);controls=B(void 0);state=B(new Map);#m=B(new Map);limits=B(void 0);status=z(`loading`);problem=z(``);stale=z(!1);#h=0;loadingOlder=z(!1);sending=z(!1);pending=B(void 0);stopping=z(!1);awaiting=z(void 0);#g=z(!1);#_=z(0);hasOlder=M(()=>this.#g.value);beginning=M(()=>this.status.value===`ready`&&!this.#g.value);running=M(()=>this.session.value?.status===`running`||this.awaiting.value!==void 0);paused=M(()=>this.session.value?.status===`paused`);spent=M(()=>[...this.runs.value.values()].reduce((e,t)=>e+t.cost,0));spentSince=M(()=>Math.max(0,this.spent.value-this.#_.value));background=M(()=>[...this.runs.value.values()].filter(e=>e.background&&!on(e.status)));failures=M(()=>{let e=0;for(let t of[...this.messages.value].reverse())if(!(t.role===`note`||this.undone.value.has(t.turn))){if(t.role===`assistant`&&t.status===`failed`)e++;else break}return e});typing=M(()=>this.presence.value.filter(e=>e.typing&&e.user!==this.#e.me()));notify=M(()=>this.session.value?.participants.find(e=>e.actor===this.#e.me())?.notify??`all`);undone=M(()=>Ge(this.messages.value));lastTurn=M(()=>[...this.messages.value].reverse().find(e=>e.role!==`note`&&!this.undone.value.has(e.turn))?.turn);canUndo=M(()=>this.controls.value?.undoLastTurn??(this.lastTurn.value!==void 0&&!this.running.value));canContinue=M(()=>!this.running.value&&this.controls.value?.continueLastTurn===!0);constructor(e,t,n=Hf){this.id=e,this.#e=t,this.#t=n}async open(){this.#n??=this.#e.events(this.id,e=>{this.#D(e)});let e=this.#e.looking??Vf;this.#p??=e.watch(()=>{this.reportPresence({typing:this.#d&&e.now()})}),this.reportPresence({typing:this.#d}),this.status.value=this.messages.value.length>0?`ready`:`loading`,this.problem.value=``;try{let e=await this.#v();this.loadLimits(),this.loadWaiting(),this.loadControls(),this.#w(e.flatMap(e=>e.runs).slice(-this.#t.runsOnOpen))}catch(e){let t=this.session.value!==void 0;this.status.value=t?`ready`:`error`,this.problem.value=J(e,t?`Couldn't catch up with this chat.`:`Couldn't open this chat.`)}}async#v(){let[e,t]=await Promise.all([this.#e.api.session.call({session:this.id}),this.#e.api.messages.call({session:this.id,limit:this.#t.page})]);this.session.value=e,this.#e.changed(Pf(e));let n=[...t.items].reverse();for(let e of this.messages.value)n=We(n,e);return this.messages.value=n,this.#r=t.cursor,this.#g.value=t.cursor!==void 0,this.status.value=`ready`,n}close(){this.#n?.(),this.#n=void 0;for(let e of this.#o.values())clearTimeout(e);this.#o.clear(),this.#p?.(),this.#p=void 0,(this.#d||this.#f)&&this.#S(!1,!1)}async refresh(){let e=++this.#h;this.stale.value=!0,this.#n??=this.#e.events(this.id,e=>{this.#D(e)}),await Bf(()=>this.#y(),this.#e.retry??zf,()=>e===this.#h&&this.#n!==void 0,e=>{this.problem.value=J(e,`Couldn't catch up with this chat.`),this.session.value===void 0&&(this.status.value=`error`)})&&e===this.#h&&(this.stale.value=!1,this.problem.value=``,this.status.value===`error`&&(this.status.value=`ready`),this.loadLimits())}async#y(){let e=await this.#v(),t=[...this.runs.value.values()].filter(e=>!on(e.status)).map(e=>e.id);await Promise.all([this.#b(),this.#w(e.flatMap(e=>e.runs).slice(-this.#t.runsOnOpen),!1,!0),this.#w(t,!0,!0),...[...this.#m.value.keys()].map(e=>this.loadState(e))])}stateOf(e){let t=this.#m.value.get(e);if(t===void 0)return this.loadState(e),{};let n={};for(let e of t.fields){let r=this.state.value.get(Gf(t.system,e));r!==void 0&&(n[e.name]=r)}return n}async loadState(e){if(!this.#c.has(e)){this.#c.add(e);try{let{system:t,fields:n}=await this.#e.api.state.call({run:e});this.#O(t,n);let r=new Map(this.#m.value);r.set(e,{system:t,fields:n.map(({name:e,type:t})=>({name:e,type:t}))}),this.#m.value=r}catch{}finally{this.#c.delete(e)}}}async loadOlder(){let e=this.#r;if(!(e===void 0||this.loadingOlder.value)){this.loadingOlder.value=!0;try{let t=await this.#e.api.messages.call({session:this.id,limit:this.#t.page,cursor:e});this.messages.value=et(this.messages.value,t.items),this.#r=t.cursor,this.#g.value=t.cursor!==void 0,this.#w(t.items.flatMap(e=>e.runs))}catch(e){this.problem.value=J(e,`Couldn't load older messages.`)}finally{this.loadingOlder.value=!1}}}async loadWaiting(){try{await this.#b()}catch{}}async#b(){let e=await this.#e.api.waiting.call({session:this.id});this.approvals.value=[...e.approvals].sort((e,t)=>e.createdAt-t.createdAt);let t=this.#e.me();this.handlers.value=this.#x(e.handlers.filter(e=>`user`in e.answerer&&e.answerer.user===t)),this.#w([...e.approvals.map(e=>e.run),...e.handlers.map(e=>e.run)])}async loadLimits(){try{this.limits.value=await this.#e.api.limits.call({session:this.id}),this.#_.value=this.spent.value}catch{}}async send(e){if(this.sending.value||e.parts.length===0)return!1;this.sending.value=!0,this.pending.value={parts:e.parts,at:this.#e.clock()},this.problem.value=``;try{let t=await this.#e.api.send.call({session:this.id,parts:[...e.parts],client:this.#e.client(),...e.replyTo===void 0?{}:{replyTo:e.replyTo},...e.replyAll===!0?{replyAll:!0}:{}});return this.messages.value=We(this.messages.value,t.message),this.awaiting.value=t.turn,this.#k(),this.reportPresence({typing:!1}),!0}catch(e){return this.problem.value=J(e,`Couldn't send that. Your message is back in the box.`),!1}finally{this.sending.value=!1,this.pending.value=void 0}}async invoke(e,t,n){try{let r=await this.#e.api.invoke.call({session:this.id,fn:e,args:t,...n===void 0?{}:{on:n},client:this.#e.client()});return this.#T(this.runs.value.get(r.run)??_r(r.run,e)),this.awaiting.value=r.turn,this.#k(),this.#w([r.run],!0),r.run}catch(e){this.problem.value=J(e,`Couldn't run that.`);return}}async control(e,t){this.stopping.value=e!==`resume`;try{return this.controls.value=await this.#e.api.control.call({session:this.id,action:e,...t===void 0||t.length===0?{}:{runs:[...t]}}),e===`cancel`&&(this.awaiting.value=void 0,this.loadWaiting()),!0}catch(e){return this.stopping.value=!1,this.problem.value=J(e,`Couldn't stop the turn.`),!1}}async toBackground(e){try{let{accepted:t}=await this.#e.api.background.call({run:e}),n=this.runs.value.get(e);return t&&n!==void 0&&this.#T({...n,background:!0}),t}catch(e){return this.problem.value=J(e,`Couldn't move that to the background.`),!1}}async undoTurn(e){try{let t=await this.#e.api.undoTurn.call({turn:e});for(let e of[...t.undone.map(e=>e.run)]){let t=this.runs.value.get(e);t!==void 0&&this.#T({...t,status:`undone`})}return t}catch(e){this.problem.value=J(e,`Couldn't undo that.`);return}}async loadControls(){try{this.controls.value=await this.#e.api.controls.call({session:this.id})}catch{}}async continueTurn(e){try{return await this.#e.api.continueTurn.call({turn:e}),!0}catch(e){return this.problem.value=J(e,`Couldn't continue that.`),!1}}async continueLast(){let e=this.lastTurn.value;return e!==void 0&&this.continueTurn(e)}async undoLast(){let e=this.lastTurn.value;return e===void 0?void 0:this.undoTurn(e)}turnMessage(e){return this.messages.value.find(t=>t.turn===e&&t.role===`user`)}async retry(e){let t=this.turnMessage(e);return t===void 0||await this.undoTurn(e)===void 0?!1:(await this.#C(),this.send({parts:He(t.parts),replyTo:t.replyTo,replyAll:t.replyAll}))}turnsFrom(e){let t=this.messages.value.findIndex(t=>t.id===e);if(t===-1)return[];let n=[];for(let e of this.messages.value.slice(t))e.role!==`note`&&!this.undone.value.has(e.turn)&&!n.includes(e.turn)&&n.push(e.turn);return n.reverse()}async editResend(e,t){let n=this.messages.value.find(t=>t.id===e);if(n===void 0)return;let r=[];for(let t of this.turnsFrom(e)){let e=await this.undoTurn(t);if(e===void 0)return;r.push(e)}return await this.#C(),await this.send({parts:t,replyTo:n.replyTo,replyAll:n.replyAll})?Uf(r):void 0}async approve(e,t,n,r,i){let a=this.approvals.value,o=a.find(t=>t.id===e)?.run;this.approvals.value=a.filter(t=>t.id!==e);try{return t&&o!==void 0&&this.#l.add(o),await this.#e.api.approve.call({approval:e,approve:t,remember:n,...r===void 0||r===``?{}:{reason:r},...i===void 0?{}:{answer:i}}),!0}catch(e){return o!==void 0&&this.#l.delete(o),this.approvals.value=a,this.problem.value=J(e,`Couldn't send your answer.`),!1}}#x(e){let t=[];for(let n of e)this.#l.has(n.run)&&ot(n)?this.answer(n.id,!0):t.push(n);return t}async approveAll(e,t,n){let r=this.approvals.value.filter(t=>e.includes(t.id));return(await Promise.all(r.map(e=>this.approve(e.id,t,Je(e)?n:`once`)))).every(Boolean)}async raiseBudget(e,t){let{setBy:n,...r}=e.budget;try{return await this.#e.api.setBudget.call({...r,maxCost:r.maxCost+t}),this.leaveBudget(e),!0}catch(e){return this.problem.value=J(e,`Couldn't raise the budget.`),!1}}leaveBudget(e){this.budgets.value=this.budgets.value.filter(t=>t.budget.id!==e.budget.id)}async answer(e,t){let n=this.handlers.value;this.handlers.value=n.filter(t=>t.id!==e);try{return await this.#e.api.answer.call({call:e,value:t}),!0}catch(e){return this.handlers.value=n,this.problem.value=J(e,`Couldn't send your answer.`),!1}}async submit(e,t){try{return(await this.#e.api.submit.call({run:e,value:t})).delivery}catch(e){this.problem.value=J(e,`Couldn't submit that.`);return}}async act(e,t,n,r){let{delivery:i}=await this.#e.api.act.call({session:this.id,system:e,action:t,input:n,client:this.#e.client(),...r===void 0?{}:{run:r}});return i}follow(e,t){return new Promise((n,r)=>{let i={status:t,resolve:n,reject:r},a=this.deliveries.value.get(e);a!==void 0&&this.#E(a,i)||this.#s.set(e,[...this.#s.get(e)??[],i])})}async update(e){try{let t=await this.#e.api.updateSession.call({session:this.id,...e});return this.session.value=t,this.#e.changed(Pf(t)),e.priority!==void 0&&this.loadLimits(),!0}catch(e){return this.problem.value=J(e,`Couldn't change this chat.`),!1}}reportPresence(e){let t=(this.#e.looking??Vf).now();e.typing===this.#d&&t===this.#f&&(!e.typing||this.#e.clock()-this.#u<this.#t.presenceEvery)||this.#S(e.typing,t)}#S(e,t){this.#d=e,this.#f=t,this.#u=this.#e.clock(),this.#e.api.presence.call({session:this.id,typing:e,focused:t}).catch(()=>void 0)}citesOf(e){return e.citations??this.liveCites.value.get(e.id)??[]}liveOf(e){return this.live.value.get(e.id)}runsOf(e){let t=e.runs.filter(e=>!this.runs.value.has(e));return t.length>0&&this.#w(t),e.runs.flatMap(e=>{let t=this.runs.value.get(e);return t===void 0?[]:[this.shown(t)]})}shown(e){let t=this.handlers.value.some(t=>t.run===e.id);return t===(e.asking===!0)?e:{...e,asking:t}}async ensureRun(e,t=!1){await this.#w([e],t)}async#C(){try{let e=await this.#e.api.messages.call({session:this.id,limit:this.#t.page});this.messages.value=[...e.items].reverse(),this.#r=e.cursor,this.#g.value=e.cursor!==void 0}catch{}}async#w(e,t=!1,n=!1){let r=[...new Set(e)].filter(e=>!this.#i.has(e)&&(t||this.runs.value.get(e)?.createdAt===void 0)),i=[];if(await Promise.all(r.map(async e=>{this.#i.add(e);try{let t=await this.#e.api.run.call({run:e});this.#T(hr(this.runs.value.get(e),t))}catch(e){i.push(e)}finally{this.#i.delete(e)}})),n&&i.length>0)throw i[0]}#T(e){let t=new Map(this.runs.value);t.set(e.id,e),this.runs.value=t}#E(e,t){return t.status(e.status),e.status===`done`?(t.resolve(e.result??null),!0):e.status===`failed`||e.status===`expired`?(t.reject(Error(e.error?.message??(e.status===`expired`?`It expired before the system came online.`:`It failed.`))),!0):!1}#D(e){switch(e.type){case`message`:{let t=this.#a.get(e.message.id);this.#a.delete(e.message.id);let n=t!==void 0&&e.message.status===`streaming`?Qe(e.message,t):e.message;this.#M(n),this.messages.value=We(this.messages.value,n),n.role===`assistant`&&n.turn===this.awaiting.value&&(this.awaiting.value=void 0),this.#w(n.runs);return}case`token`:{let t=this.messages.value.findIndex(t=>t.id===e.message),n=this.messages.value[t];if(this.#j(e.message,{kind:`text`,text:e.text}),n===void 0){this.#a.set(e.message,(this.#a.get(e.message)??``)+e.text);return}let r=[...this.messages.value];r[t]=Qe(n,e.text),this.messages.value=r,n.turn===this.awaiting.value&&(this.awaiting.value=void 0);return}case`reasoning`:this.#j(e.message,{kind:`reasoning`,text:e.text});return;case`cite`:{let t=new Map(this.liveCites.value);t.set(e.message,[...(t.get(e.message)??[]).filter(t=>t.index!==e.cite.index),e.cite]),this.liveCites.value=t;return}case`run`:{let t=this.runs.value.get(e.run)??_r(e.run,e.fn);this.#T(pr(t,e.update,this.#e.clock()));let n=e.update.type===`status`&&on(e.update.status),r=e.update.type===`result`;(t.createdAt===void 0||n||r)&&this.#w([e.run],n||r),(n||e.update.type===`cost`)&&this.#A(e.run),e.update.type===`status`&&mr(e.update.status)&&(this.awaiting.value=void 0);return}case`controls`:this.controls.value=e.controls,this.stopping.value=!1;return;case`approval`:{let t=this.approvals.value.filter(t=>t.id!==e.approval.id);this.approvals.value=e.approval.status===`pending`?[...t,e.approval].sort((e,t)=>e.createdAt-t.createdAt):t;return}case`handler`:{let t=this.handlers.value.filter(t=>t.id!==e.call.id),n=`user`in e.call.answerer&&e.call.answerer.user===this.#e.me();this.handlers.value=e.call.status===`pending`&&n?[...t,...this.#x([e.call])]:t;return}case`delivery`:{let t=new Map(this.deliveries.value);t.set(e.delivery.id,e.delivery),this.deliveries.value=t;let n=(this.#s.get(e.delivery.id)??[]).filter(t=>!this.#E(e.delivery,t));n.length===0?this.#s.delete(e.delivery.id):this.#s.set(e.delivery.id,n);return}case`budget`:{let{type:t,...n}=e;this.budgets.value=[...this.budgets.value.filter(e=>e.budget.id!==n.budget.id),n];return}case`presence`:this.#N(e.presence);return;case`compare`:return;case`state`:this.#O(e.system,e.fields);return;case`session`:{let t=this.session.value;t!==void 0&&(this.session.value={...t,...e.session}),e.session.status===`idle`&&(this.awaiting.value=void 0,this.stopping.value=!1,this.loadLimits()),this.#e.changed(e.session);return}}}#O(e,t){let n=new Map(this.state.value);for(let r of t){let t=Gf(e,r);r.value===void 0?n.delete(t):n.set(t,r.value)}this.state.value=n}#k(){this.controls.value=void 0,this.stopping.value=!1}#A(e){this.approvals.value.some(t=>t.run===e)&&(this.approvals.value=this.approvals.value.filter(t=>t.run!==e)),this.handlers.value.some(t=>t.run===e)&&(this.handlers.value=this.handlers.value.filter(t=>t.run!==e)),this.budgets.value.some(t=>t.run===e)&&(this.budgets.value=this.budgets.value.filter(t=>t.run!==e))}#j(e,t){let n=this.messages.value.find(t=>t.id===e),r=this.live.value.get(e)??(n===void 0?[]:Xe(n)),i=new Map(this.live.value);i.set(e,Ye(r,t)),this.live.value=i}#M(e){let t=this.live.value.get(e.id);if(t===void 0||e.role!==`assistant`)return;if(e.status!==`streaming`){let n=new Map(this.live.value);n.set(e.id,Ue(t,e)),this.live.value=n;return}let n=new Set(t.flatMap(e=>e.kind===`runs`?e.runs:[])),r=e.runs.filter(e=>!n.has(e));r.length>0&&this.#j(e.id,{kind:`runs`,runs:r})}#N(e){this.presence.value=[...this.presence.value.filter(t=>t.user!==e.user),e],clearTimeout(this.#o.get(e.user)),e.typing&&this.#o.set(e.user,setTimeout(()=>{this.presence.value=this.presence.value.map(t=>t.user===e.user?{...t,typing:!1}:t)},this.#t.typingFor))}},qf=class{#e;#t=B(new Map);#n=new Map;source={visuals:(e,t,n)=>(this.prepare(e),this.#e.renderers.contributedVisuals(e,t,n))};constructor(e){this.#e=e}visuals(e,t,n){let r=this.#e.renderers.contributedVisuals(e,t,n).map(e=>({name:e.name,label:e.label,icon:si(e.icon)?e.icon:`layers`,system:e.system,shape:e.shape,component:j(e.component),props:{system:e.client}}));return ci(Pr,r,t,n)}prepare(e){let t=this.#n.get(e);if(t!==void 0)return t;let n=(async()=>{try{(await this.#e.api.contributions.call({registry:e})).length>0&&await this.#e.prepare()}catch(t){this.#n.delete(e),console.error(`chat.visuals.contributions-failed`,{registry:e,error:t})}})();return this.#n.set(e,n),n}choice(e){return this.#t.value.get(e)}choose(e,t){this.#t.value=new Map([...this.#t.value,[e,t]])}},Jf=class{#e;#t=[];static available(){return typeof navigator<`u`&&`mediaDevices`in navigator&&typeof navigator.mediaDevices.getUserMedia==`function`&&typeof MediaRecorder<`u`}async start(){let e=await navigator.mediaDevices.getUserMedia({audio:!0});this.#t=[];let t=new MediaRecorder(e);t.ondataavailable=e=>{e.data.size>0&&this.#t.push(e.data)},t.start(),this.#e=t}stop(){let e=this.#e;return e===void 0?Promise.reject(Error(`Not recording.`)):new Promise(t=>{e.onstop=()=>{for(let t of e.stream.getTracks())t.stop();t(new Blob(this.#t,{type:e.mimeType===``?`audio/webm`:e.mimeType}))},e.stop(),this.#e=void 0})}cancel(){let e=this.#e;e!==void 0&&(e.onstop=()=>{for(let t of e.stream.getTracks())t.stop()},e.stop(),this.#e=void 0)}},Yf=class{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}start(){return this.#e.start()}async stop(){let e=await this.#e.stop(),t=await this.#t(e);return(await this.#n.transcribe.call({audio:t})).text}cancel(){this.#e.cancel()}};function Xf(e){let t=Reflect.get(e,`SpeechRecognition`)??Reflect.get(e,`webkitSpeechRecognition`);if(typeof t==`function`)return()=>{let e=Reflect.construct(t,[]);if(!Zf(e))throw Error(`This browser’s speech recognition is not usable.`);return e}}function Zf(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`start`)==`function`&&typeof Reflect.get(e,`stop`)==`function`}var Qf=new Set([`not-allowed`,`service-not-allowed`]),$f=class{#e;#t;#n=[];#r;#i;constructor(e){this.#e=e}start(e){let t=this.#e();return this.#n=[],this.#r=void 0,t.lang=e??``,t.continuous=!0,t.interimResults=!1,t.onresult=e=>{this.#n=Array.from(e.results).filter(e=>e.isFinal).map(e=>e[0]?.transcript.trim()??``)},t.onend=()=>{this.#i?.()},new Promise((e,n)=>{t.onerror=e=>{this.#r=e.error,Qf.has(e.error)&&n(new DOMException(`The microphone is blocked.`,`NotAllowedError`))},t.start(),this.#t=t,e()})}stop(){let e=this.#t;return e===void 0?Promise.reject(Error(`Not listening.`)):(this.#t=void 0,new Promise((t,n)=>{this.#i=()=>{this.#i=void 0,this.#r!==void 0&&this.#r!==`no-speech`&&this.#n.length===0?n(Error(`Speech recognition failed (${this.#r}).`)):t(this.#n.filter(e=>e!==``).join(` `))},e.stop()}))}cancel(){this.#i=void 0,this.#t?.abort(),this.#t=void 0}},ep=class{#e;#t;#n;state=z(`idle`);startedAt=z(0);problem=z(``);constructor(e,t=Date.now){this.#e=e,this.#t=t}can(e){return this.#e[e]!==void 0}async start(e,t){if(this.state.value===`recording`||this.state.value===`transcribing`)return;this.problem.value=``;let n=this.#e[e];if(n===void 0)this.state.value=`failed`,this.problem.value=e===`browser`?`This browser can’t recognise speech. An admin can switch dictation to a model.`:`This browser can’t record audio.`;else try{await n.start(t),this.#n=n,this.startedAt.value=this.#t(),this.state.value=`recording`}catch(e){let t=e instanceof DOMException&&(e.name===`NotAllowedError`||e.name===`SecurityError`);this.state.value=t?`denied`:`failed`,this.problem.value=t?`The microphone is blocked. Allow it in your browser’s site settings to dictate.`:`Couldn't start the microphone.`}}async stop(){let e=this.#n;if(this.state.value===`recording`&&e!==void 0){this.#n=void 0,this.state.value=`transcribing`;try{let t=await e.stop();return this.state.value=`idle`,t}catch(e){this.state.value=`failed`,this.problem.value=J(e,`Couldn't transcribe that.`);return}}}cancel(){this.state.value===`recording`&&this.#n?.cancel(),this.#n=void 0,this.state.value=`idle`}dismiss(){this.problem.value=``,(this.state.value===`denied`||this.state.value===`failed`)&&(this.state.value=`idle`)}};function tp(e=Date.now){return{timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,locale:navigator.language,now:e()}}var np=class{listValues;pickers;access;connections;sessions;capabilities;inspector;types;collapse;renderers;mentions;visuals;approvals;#e=B(new Map);#t=new Set;current=z(void 0);#n;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s;constructor(e){this.#n=e,this.listValues=e.api.listValues,this.pickers=new ef(e.api),this.access=new Ld(e.api),this.connections=new $d(e.api),this.sessions=new Ff(e.api,e.userEvents),this.capabilities=new nf(e.api,e.userEvents),this.inspector=new vf(e.api),this.types=new Yt(t=>e.api.types.call({names:[...t]})),this.collapse=new cf(e.store),this.mentions=new bf(e.api),this.renderers=new jf({thread:()=>this.current.value===void 0?void 0:this.#r.get(this.current.value),online:e=>this.capabilities.online(e),...e.renderers}),this.visuals=new qf({api:e.api,renderers:this.renderers,prepare:()=>this.prepareRenderers()}),this.approvals=new ds(e.api)}start(){this.sessions.start(),this.capabilities.start()}stop(){this.sessions.stop(),this.capabilities.stop();for(let e of this.#r.values())e.close()}titleOf(e){let t=this.sessions.items.value.find(t=>t.id===e);if(t!==void 0)return t.title===``?void 0:t.title;let n=this.#e.value.get(e);if(n!==void 0)return n===``?void 0:n;let r=Fn.safeParse(e);r.success&&!this.#t.has(e)&&(this.#t.add(e),this.#n.api.session.call({session:r.data}).then(t=>{this.#e.value=new Map([...this.#e.value,[e,t.title]])},()=>void 0))}thread(e){let t=this.#r.get(e);if(t!==void 0)return this.#r.delete(e),this.#r.set(e,t),t;let n=new Kf(e,{api:this.#n.api,events:this.#n.sessionEvents,clock:this.#n.clock,client:this.#n.client,me:this.#n.me,changed:e=>{this.sessions.remember(e)},...this.#n.retry===void 0?{}:{retry:this.#n.retry}},this.#n.thread??Hf);this.#r.set(e,n);for(let[t,n]of this.#r){if(this.#r.size<=5)break;t!==e&&t!==this.current.value&&(n.close(),this.#r.delete(t))}return n}async sessionOfRun(e){return(await this.#n.api.run.call({run:e})).session}composer(e){let t=this.#i.get(e);if(t!==void 0)return t;let n=new _f({session:e,store:this.#n.store,api:this.#n.api,capabilities:()=>this.capabilities.value.value,uploads:new mc(this.#n.api,this.#n.sender,this.#n.previews)});return this.#i.set(e,n),n}suggestions(e){let t=this.#a.get(e);if(t!==void 0)return t;let n=new Rf(this.#n.api,e);return this.#a.set(e,n),n}preview(e){let t=this.#o.get(e);if(t!==void 0)return t;let n=new If(this.#n.api,e);return this.#o.set(e,n),n}startCompare(e,t){return lf(this.#n.api,this.thread(e),this.composer(e),t,this.#n.client())}compare(e,t){return new df({api:this.#n.api,events:this.#n.sessionEvents},e,t)}voice(){if(this.#s===void 0){let e=this.#n.recorder(),t=this.#n.speech?.(),n={...e===void 0?{}:{model:new Yf(e,e=>this.#l(e),this.#n.api)},...t===void 0?{}:{browser:new $f(t)}};this.#s=Object.keys(n).length===0?null:new ep(n,this.#n.clock)}return this.#s??void 0}async open(e){let t=this.current.value;t!==void 0&&t!==e&&this.#r.get(t)?.close(),this.current.value=e;let n=this.thread(e);return await Promise.all([n.open(),this.#c(e)]),n}leave(){let e=this.current.value;e!==void 0&&this.#r.get(e)?.close(),this.current.value=void 0}async refresh(){let e=this.current.value;await Promise.all([this.sessions.loaded.value?this.sessions.load():Promise.resolve(),this.#c(e),e===void 0?Promise.resolve():this.thread(e).refresh()])}async prepareRenderers(){this.capabilities.value.value===void 0&&await this.#c(this.current.value)}async#c(e){await this.capabilities.load(e);let t=this.capabilities.value.value;t!==void 0&&this.renderers.sync(t.clients)}#l(e){let t=e.type.includes(`ogg`)?`ogg`:e.type.includes(`mp4`)?`m4a`:`webm`;return fc(this.#n.api,this.#n.sender,e,`dictation.${t}`,()=>void 0,new AbortController().signal)}},rp={endpoints:{setup:{method:`GET`,path:`/setup`,ws:`setup`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},createAdmin:{method:`POST`,path:`/createAdmin`,ws:`createAdmin`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`email`,`name`,`password`,`setup`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},signIn:{method:`POST`,path:`/signIn`,ws:`signIn`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`email`,`password`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},refresh:{method:`POST`,path:`/refresh`,ws:`refresh`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`refresh`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},redeemSso:{method:`POST`,path:`/redeemSso`,ws:`redeemSso`,httpOnly:!0,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`code`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},signOut:{method:`POST`,path:`/signOut`,ws:`signOut`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},me:{method:`GET`,path:`/me`,ws:`me`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},account:{method:`GET`,path:`/account`,ws:`account`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},capabilities:{method:`POST`,path:`/capabilities`,ws:`capabilities`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},types:{method:`POST`,path:`/types`,ws:`types`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`names`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},sessions:{method:`POST`,path:`/sessions`,ws:`sessions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},session:{method:`POST`,path:`/session`,ws:`session`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},createSession:{method:`POST`,path:`/createSession`,ws:`createSession`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`agent`,`systems`,`title`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},updateSession:{method:`POST`,path:`/updateSession`,ws:`updateSession`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`title`,`systems`,`agent`,`archived`,`priority`,`notify`,`model`,`mode`,`contextor`,`fnMode`,`instructions`,`citations`,`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},deleteSession:{method:`POST`,path:`/deleteSession`,ws:`deleteSession`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},limits:{method:`POST`,path:`/limits`,ws:`limits`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},messages:{method:`POST`,path:`/messages`,ws:`messages`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},send:{method:`POST`,path:`/send`,ws:`send`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`parts`,`replyTo`,`replyAll`,`client`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},compare:{method:`POST`,path:`/compare`,ws:`compare`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`parts`,`variants`,`client`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},compareView:{method:`POST`,path:`/compareView`,ws:`compareView`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`turn`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},chooseVariant:{method:`POST`,path:`/chooseVariant`,ws:`chooseVariant`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`turn`,`variant`,`adopt`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},invoke:{method:`POST`,path:`/invoke`,ws:`invoke`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`fn`,`args`,`on`,`client`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},control:{method:`POST`,path:`/control`,ws:`control`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`action`,`runs`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},controls:{method:`POST`,path:`/controls`,ws:`controls`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},presence:{method:`POST`,path:`/presence`,ws:`presence`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`focused`,`typing`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},background:{method:`POST`,path:`/background`,ws:`background`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},undoTurn:{method:`POST`,path:`/undoTurn`,ws:`undoTurn`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`turn`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},continueTurn:{method:`POST`,path:`/continueTurn`,ws:`continueTurn`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`turn`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},tree:{method:`POST`,path:`/tree`,ws:`tree`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`turn`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},run:{method:`POST`,path:`/run`,ws:`run`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},llmCall:{method:`POST`,path:`/llmCall`,ws:`llmCall`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},waiting:{method:`POST`,path:`/waiting`,ws:`waiting`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},approve:{method:`POST`,path:`/approve`,ws:`approve`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`approval`,`approve`,`remember`,`reason`,`answer`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},answer:{method:`POST`,path:`/answer`,ws:`answer`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`call`,`value`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},act:{method:`POST`,path:`/act`,ws:`act`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`system`,`action`,`input`,`run`,`client`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},submit:{method:`POST`,path:`/submit`,ws:`submit`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`run`,`value`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},state:{method:`POST`,path:`/state`,ws:`state`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},suggest:{method:`POST`,path:`/suggest`,ws:`suggest`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`text`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},mentions:{method:`POST`,path:`/mentions`,ws:`mentions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`provider`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},mentionHover:{method:`POST`,path:`/mentionHover`,ws:`mentionHover`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`provider`,`target`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},resource:{method:`POST`,path:`/resource`,ws:`resource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`want`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},notifications:{method:`POST`,path:`/notifications`,ws:`notifications`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`unread`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},readNotifications:{method:`POST`,path:`/readNotifications`,ws:`readNotifications`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`ids`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},pushKey:{method:`GET`,path:`/pushKey`,ws:`pushKey`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},subscribePush:{method:`POST`,path:`/subscribePush`,ws:`subscribePush`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`endpoint`,`keys`,`device`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},upload:{method:`POST`,path:`/upload`,ws:`upload`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`,`mime`,`size`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},uploaded:{method:`POST`,path:`/uploaded`,ws:`uploaded`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`upload`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},transcribe:{method:`POST`,path:`/transcribe`,ws:`transcribe`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`audio`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systems:{method:`POST`,path:`/systems`,ws:`systems`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},system:{method:`POST`,path:`/system`,ws:`system`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},pairings:{method:`POST`,path:`/pairings`,ws:`pairings`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`status`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},approvePairing:{method:`POST`,path:`/approvePairing`,ws:`approvePairing`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`pairing`,`approve`,`instance`,`config`,`autoPair`,`store`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},createPairingToken:{method:`POST`,path:`/createPairingToken`,ws:`createPairingToken`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`,`expiresIn`,`autoPair`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},configureSystem:{method:`POST`,path:`/configureSystem`,ws:`configureSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`config`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},enableSystem:{method:`POST`,path:`/enableSystem`,ws:`enableSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`functions`,`renderers`,`context`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},switchItem:{method:`POST`,path:`/switchItem`,ws:`switchItem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`section`,`name`,`on`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},switchPart:{method:`POST`,path:`/switchPart`,ws:`switchPart`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`section`,`name`,`on`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},removeSystem:{method:`POST`,path:`/removeSystem`,ws:`removeSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`keepStore`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},installSystem:{method:`POST`,path:`/installSystem`,ws:`installSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`source`,`config`,`autoStart`,`store`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemStore:{method:`POST`,path:`/systemStore`,ws:`systemStore`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemStoreMove:{method:`POST`,path:`/systemStoreMove`,ws:`systemStoreMove`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`to`,`runs`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemStoreMoveState:{method:`POST`,path:`/systemStoreMoveState`,ws:`systemStoreMoveState`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemStoreMoveAnswer:{method:`POST`,path:`/systemStoreMoveAnswer`,ws:`systemStoreMoveAnswer`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`answer`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemStoreBackups:{method:`POST`,path:`/systemStoreBackups`,ws:`systemStoreBackups`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemStoreBackupDelete:{method:`POST`,path:`/systemStoreBackupDelete`,ws:`systemStoreBackupDelete`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`backup`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},startSystem:{method:`POST`,path:`/startSystem`,ws:`startSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},stopSystem:{method:`POST`,path:`/stopSystem`,ws:`stopSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},restartSystem:{method:`POST`,path:`/restartSystem`,ws:`restartSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`reason`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},upgradeSystem:{method:`POST`,path:`/upgradeSystem`,ws:`upgradeSystem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`version`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},reimport:{method:`POST`,path:`/reimport`,ws:`reimport`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},configureProvider:{method:`POST`,path:`/configureProvider`,ws:`configureProvider`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},providers:{method:`POST`,path:`/providers`,ws:`providers`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setModelCategory:{method:`POST`,path:`/setModelCategory`,ws:`setModelCategory`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`,`name`,`description`,`models`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setBudget:{method:`POST`,path:`/setBudget`,ws:`setBudget`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`,`target`,`period`,`maxCost`,`maxTokens`,`maxCalls`,`maxTime`,`share`,`onLimit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setPriority:{method:`POST`,path:`/setPriority`,ws:`setPriority`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`,`target`,`default`,`max`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setPolicy:{method:`POST`,path:`/setPolicy`,ws:`setPolicy`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`,`description`,`subject`,`target`,`decision`,`priority`,`expiresAt`,`yields`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setActorSetting:{method:`POST`,path:`/setActorSetting`,ws:`setActorSetting`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`setting`,`actor`,`value`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},addUser:{method:`POST`,path:`/addUser`,ws:`addUser`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`email`,`name`,`role`,`groups`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},addGroup:{method:`POST`,path:`/addGroup`,ws:`addGroup`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`,`about`,`members`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},updateUser:{method:`POST`,path:`/updateUser`,ws:`updateUser`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`user`,`name`,`role`,`disabled`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setMembership:{method:`POST`,path:`/setMembership`,ws:`setMembership`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`group`,`user`,`member`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setSignInPolicy:{method:`POST`,path:`/setSignInPolicy`,ws:`setSignInPolicy`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setSignInLimits:{method:`POST`,path:`/setSignInLimits`,ws:`setSignInLimits`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`account`,`address`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setProxyTrust:{method:`POST`,path:`/setProxyTrust`,ws:`setProxyTrust`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`proxies`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemFns:{method:`POST`,path:`/systemFns`,ws:`systemFns`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemParts:{method:`POST`,path:`/systemParts`,ws:`systemParts`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemLogs:{method:`POST`,path:`/systemLogs`,ws:`systemLogs`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},models:{method:`POST`,path:`/models`,ws:`models`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`provider`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},modelCategories:{method:`POST`,path:`/modelCategories`,ws:`modelCategories`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},budgets:{method:`POST`,path:`/budgets`,ws:`budgets`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},priorityRules:{method:`POST`,path:`/priorityRules`,ws:`priorityRules`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},resolveLimits:{method:`POST`,path:`/resolveLimits`,ws:`resolveLimits`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`user`,`session`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},policies:{method:`POST`,path:`/policies`,ws:`policies`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},actors:{method:`POST`,path:`/actors`,ws:`actors`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`kind`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},actorSettings:{method:`POST`,path:`/actorSettings`,ws:`actorSettings`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},runs:{method:`POST`,path:`/runs`,ws:`runs`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},llmCalls:{method:`POST`,path:`/llmCalls`,ws:`llmCalls`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},resources:{method:`POST`,path:`/resources`,ws:`resources`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},removeRule:{method:`POST`,path:`/removeRule`,ws:`removeRule`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},indexStatus:{method:`POST`,path:`/indexStatus`,ws:`indexStatus`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},browseResources:{method:`POST`,path:`/browseResources`,ws:`browseResources`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`search`,`system`,`family`,`source`,`under`,`form`,`missing`,`group`,`in`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},resourceForms:{method:`POST`,path:`/resourceForms`,ws:`resourceForms`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},readResource:{method:`POST`,path:`/readResource`,ws:`readResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`form`,`section`,`offset`,`maxChars`,`rows`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},convertResource:{method:`POST`,path:`/convertResource`,ws:`convertResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`kind`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},downloadResource:{method:`POST`,path:`/downloadResource`,ws:`downloadResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`form`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},importResource:{method:`POST`,path:`/importResource`,ws:`importResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},renameResource:{method:`POST`,path:`/renameResource`,ws:`renameResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`name`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},deleteResource:{method:`POST`,path:`/deleteResource`,ws:`deleteResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contextFromResource:{method:`POST`,path:`/contextFromResource`,ws:`contextFromResource`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`sections`,`copy`,`weight`,`tags`,`fns`,`suggestFns`,`inject`,`command`,`visible`,`suggest`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contexts:{method:`POST`,path:`/contexts`,ws:`contexts`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contextItem:{method:`POST`,path:`/contextItem`,ws:`contextItem`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},remember:{method:`POST`,path:`/remember`,ws:`remember`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`text`,`title`,`scope`,`about`,`question`,`when`,`weight`,`summary`,`tags`,`fns`,`suggestFns`,`inject`,`command`,`visible`,`suggest`,`parent`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},updateMemory:{method:`POST`,path:`/updateMemory`,ws:`updateMemory`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`text`,`title`,`about`,`question`,`when`,`weight`,`summary`,`tags`,`fns`,`suggestFns`,`inject`,`command`,`visible`,`suggest`,`parent`,`name`,`clear`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},forget:{method:`POST`,path:`/forget`,ws:`forget`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},linkContext:{method:`POST`,path:`/linkContext`,ws:`linkContext`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`from`,`to`,`relation`,`weight`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},unlinkContext:{method:`POST`,path:`/unlinkContext`,ws:`unlinkContext`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`from`,`toKey`,`relation`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contextMetadata:{method:`POST`,path:`/contextMetadata`,ws:`contextMetadata`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setContextStatus:{method:`POST`,path:`/setContextStatus`,ws:`setContextStatus`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`names`,`action`,`reason`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contextReview:{method:`POST`,path:`/contextReview`,ws:`contextReview`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`kinds`,`systems`,`limit`,`cursor`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},mergeContext:{method:`POST`,path:`/mergeContext`,ws:`mergeContext`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`keep`,`drop`,`reason`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},notDuplicate:{method:`POST`,path:`/notDuplicate`,ws:`notDuplicate`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`,`of`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},reextractContext:{method:`POST`,path:`/reextractContext`,ws:`reextractContext`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`names`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},newContextStatus:{method:`POST`,path:`/newContextStatus`,ws:`newContextStatus`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setNewContextStatus:{method:`POST`,path:`/setNewContextStatus`,ws:`setNewContextStatus`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`value`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contextPlans:{method:`POST`,path:`/contextPlans`,ws:`contextPlans`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contextPlan:{method:`POST`,path:`/contextPlan`,ws:`contextPlan`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`run`,`format`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},answerPlan:{method:`POST`,path:`/answerPlan`,ws:`answerPlan`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`run`,`answers`,`reasons`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},modelLimits:{method:`POST`,path:`/modelLimits`,ws:`modelLimits`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`model`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},previewSelection:{method:`POST`,path:`/previewSelection`,ws:`previewSelection`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`text`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setModelLimits:{method:`POST`,path:`/setModelLimits`,ws:`setModelLimits`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`model`,`limits`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},previewPrompt:{method:`POST`,path:`/previewPrompt`,ws:`previewPrompt`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`text`,`model`,`count`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},modelRoles:{method:`POST`,path:`/modelRoles`,ws:`modelRoles`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setModelRole:{method:`POST`,path:`/setModelRole`,ws:`setModelRole`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},clearModelRole:{method:`POST`,path:`/clearModelRole`,ws:`clearModelRole`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`role`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},modelCalls:{method:`POST`,path:`/modelCalls`,ws:`modelCalls`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`run`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},modelCall:{method:`POST`,path:`/modelCall`,ws:`modelCall`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},fnMetrics:{method:`POST`,path:`/fnMetrics`,ws:`fnMetrics`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`fn`,`system`,`days`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},fnMetricsDays:{method:`POST`,path:`/fnMetricsDays`,ws:`fnMetricsDays`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`fn`,`days`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},mcps:{method:`POST`,path:`/mcps`,ws:`mcps`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},mcp:{method:`POST`,path:`/mcp`,ws:`mcp`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`mcp`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},createMcp:{method:`POST`,path:`/createMcp`,ws:`createMcp`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`slug`,`name`,`instructions`,`rules`,`toolMode`,`user`,`grantees`,`origins`,`enabled`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},updateMcp:{method:`POST`,path:`/updateMcp`,ws:`updateMcp`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`slug`,`name`,`instructions`,`rules`,`toolMode`,`user`,`grantees`,`origins`,`enabled`,`mcp`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},rotateMcpSecret:{method:`POST`,path:`/rotateMcpSecret`,ws:`rotateMcpSecret`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`mcp`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},deleteMcp:{method:`POST`,path:`/deleteMcp`,ws:`deleteMcp`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`mcp`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},previewMcp:{method:`POST`,path:`/previewMcp`,ws:`previewMcp`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`rules`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},mcpSessions:{method:`POST`,path:`/mcpSessions`,ws:`mcpSessions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`mcp`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},pairing:{method:`POST`,path:`/pairing`,ws:`pairing`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`pairing`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},instances:{method:`POST`,path:`/instances`,ws:`instances`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},installPackage:{method:`POST`,path:`/installPackage`,ws:`installPackage`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`zip`,`instance`,`config`,`data`,`autoStart`,`store`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},removeInstance:{method:`POST`,path:`/removeInstance`,ws:`removeInstance`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`keepStore`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},addInstance:{method:`POST`,path:`/addInstance`,ws:`addInstance`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`description`,`config`,`store`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},exportSystemData:{method:`POST`,path:`/exportSystemData`,ws:`exportSystemData`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`withSecrets`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},query:{method:`POST`,path:`/query`,ws:`query`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`list`,`query`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},listValues:{method:`POST`,path:`/listValues`,ws:`listValues`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`list`,`field`,`prefix`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},fns:{method:`POST`,path:`/fns`,ws:`fns`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`text`,`filters`,`sort`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},suggestDecision:{method:`POST`,path:`/suggestDecision`,ws:`suggestDecision`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setSuggestDecision:{method:`POST`,path:`/setSuggestDecision`,ws:`setSuggestDecision`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},searchDecisions:{method:`POST`,path:`/searchDecisions`,ws:`searchDecisions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setSearchDecision:{method:`POST`,path:`/setSearchDecision`,ws:`setSearchDecision`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`item`,`value`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},previewSuggestions:{method:`POST`,path:`/previewSuggestions`,ws:`previewSuggestions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`session`,`text`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},autoPairs:{method:`POST`,path:`/autoPairs`,ws:`autoPairs`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},revokeAutoPair:{method:`POST`,path:`/revokeAutoPair`,ws:`revokeAutoPair`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`id`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},imageEmbedding:{method:`POST`,path:`/imageEmbedding`,ws:`imageEmbedding`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setImageEmbedding:{method:`POST`,path:`/setImageEmbedding`,ws:`setImageEmbedding`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:`raw`,f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},outsideImages:{method:`POST`,path:`/outsideImages`,ws:`outsideImages`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setOutsideImages:{method:`POST`,path:`/setOutsideImages`,ws:`setOutsideImages`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`value`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},https:{method:`POST`,path:`/https`,ws:`https`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setHttps:{method:`POST`,path:`/setHttps`,ws:`setHttps`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`on`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},accessInfo:{method:`POST`,path:`/accessInfo`,ws:`accessInfo`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},access:{method:`POST`,path:`/access`,ws:`access`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`targets`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setAccess:{method:`POST`,path:`/setAccess`,ws:`setAccess`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`target`,`sharing`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},connectPages:{method:`POST`,path:`/connectPages`,ws:`connectPages`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},connect:{method:`POST`,path:`/connect`,ws:`connect`,httpOnly:!0,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`,`key`,`form`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},updateConnection:{method:`POST`,path:`/updateConnection`,ws:`updateConnection`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`connection`,`settings`,`fns`,`share`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},disconnect:{method:`POST`,path:`/disconnect`,ws:`disconnect`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`connection`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},pick:{method:`POST`,path:`/pick`,ws:`pick`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`source`,`text`,`values`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},approvals:{method:`POST`,path:`/approvals`,ws:`approvals`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`runs`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},contributions:{method:`POST`,path:`/contributions`,ws:`contributions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`registry`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemPages:{method:`POST`,path:`/systemPages`,ws:`systemPages`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemInstances:{method:`POST`,path:`/systemInstances`,ws:`systemInstances`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},searchFns:{method:`POST`,path:`/searchFns`,ws:`searchFns`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`text`,`match`,`items`,`kinds`,`systems`,`instance`,`visibility`,`types`,`modes`,`effects`,`names`,`filters`,`off`,`statuses`,`returnNotApplicable`,`semanticOver`,`scopes`,`available`,`niches`,`order`,`offset`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},fnExamples:{method:`POST`,path:`/fnExamples`,ws:`fnExamples`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`fn`,`query`,`offset`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},fnFacts:{method:`POST`,path:`/fnFacts`,ws:`fnFacts`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`fn`,`args`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},fnsOfModelNames:{method:`POST`,path:`/fnsOfModelNames`,ws:`fnsOfModelNames`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`names`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},clientLogs:{method:`POST`,path:`/clientLogs`,ws:`clientLogs`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`entries`,`page`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},autoClassifier:{method:`POST`,path:`/autoClassifier`,ws:`autoClassifier`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setAutoClassifier:{method:`POST`,path:`/setAutoClassifier`,ws:`setAutoClassifier`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`model`,`messages`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},exploreRoots:{method:`POST`,path:`/exploreRoots`,ws:`exploreRoots`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},exploreList:{method:`POST`,path:`/exploreList`,ws:`exploreList`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`cursor`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},exploreRead:{method:`POST`,path:`/exploreRead`,ws:`exploreRead`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`uri`,`want`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},systemReview:{method:`POST`,path:`/systemReview`,ws:`systemReview`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},goLive:{method:`POST`,path:`/goLive`,ws:`goLive`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`hash`,`off`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},approveReview:{method:`POST`,path:`/approveReview`,ws:`approveReview`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`hash`,`off`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},rejectReview:{method:`POST`,path:`/rejectReview`,ws:`rejectReview`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`hash`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},decideReview:{method:`POST`,path:`/decideReview`,ws:`decideReview`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`hash`,`approve`,`decline`,`off`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},testCall:{method:`POST`,path:`/testCall`,ws:`testCall`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`fn`,`args`,`instance`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},refusals:{method:`POST`,path:`/refusals`,ws:`refusals`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`system`,`rule`,`cursor`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},graph:{method:`POST`,path:`/graph`,ws:`graph`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`text`,`filters`,`systems`,`external`,`focus`,`collapse`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},injections:{method:`POST`,path:`/injections`,ws:`injections`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`agent`,`context`,`mode`,`fnMode`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},setInjection:{method:`POST`,path:`/setInjection`,ws:`setInjection`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`agent`,`context`,`on`,`order`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},identity:{method:`GET`,path:`/identity`,ws:`identity`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},setHubName:{method:`POST`,path:`/setHubName`,ws:`setHubName`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`name`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},itemVersions:{method:`POST`,path:`/itemVersions`,ws:`itemVersions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`system`,`section`,`name`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},dataSets:{method:`POST`,path:`/dataSets`,ws:`dataSets`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`text`,`system`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},records:{method:`POST`,path:`/records`,ws:`records`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`type`,`query`,`search`,`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},record:{method:`POST`,path:`/record`,ws:`record`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`type`,`id`,`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},recordTable:{method:`POST`,path:`/recordTable`,ws:`recordTable`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`type`,`query`,`search`,`run`,`offset`,`limit`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},saveRecord:{method:`POST`,path:`/saveRecord`,ws:`saveRecord`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`type`,`id`,`value`,`expect`,`run`,`owner`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},updateRecord:{method:`POST`,path:`/updateRecord`,ws:`updateRecord`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`type`,`id`,`set`,`expect`,`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},removeRecord:{method:`POST`,path:`/removeRecord`,ws:`removeRecord`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`type`,`id`,`run`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},recordVersions:{method:`POST`,path:`/recordVersions`,ws:`recordVersions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`type`,`id`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},rowActions:{method:`POST`,path:`/rowActions`,ws:`rowActions`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`types`,`narrow`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},readFn:{method:`POST`,path:`/readFn`,ws:`readFn`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`fn`,`args`,`on`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},export:{method:`GET`,path:`/export`,ws:null,httpOnly:!0,streamIn:null,itemsIn:!1,streamOut:`text/csv`,items:!1,p:[],q:[`fn`,`args`,`offset`,`limit`,`format`],b:null,f:[],hasBody:!1,hasHeaders:!1,multi:!1,bodyEnc:null},people:{method:`POST`,path:`/people`,ws:`people`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`text`,`filters`,`sort`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},groups:{method:`POST`,path:`/groups`,ws:`groups`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`text`,`filters`,`sort`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},groupMembers:{method:`POST`,path:`/groupMembers`,ws:`groupMembers`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`cursor`,`limit`,`group`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},signInSettings:{method:`POST`,path:`/signInSettings`,ws:`signInSettings`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},checkSsoProvider:{method:`POST`,path:`/checkSsoProvider`,ws:`checkSsoProvider`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`provider`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},testSsoSignIn:{method:`POST`,path:`/testSsoSignIn`,ws:`testSsoSignIn`,httpOnly:!0,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`provider`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`},ssoTestResult:{method:`POST`,path:`/ssoTestResult`,ws:`ssoTestResult`,httpOnly:!1,streamIn:null,itemsIn:!1,streamOut:null,items:!1,p:[],q:[],b:[`test`],f:[],hasBody:!0,hasHeaders:!1,multi:!1,bodyEnc:`json`}},events:{systemLog:{ws:`on.systemLog`,hasParams:!0},session:{ws:`on.session`,hasParams:!0},user:{ws:`on.user`,hasParams:!0}}},ip={whileDisconnected:`queue`,heartbeat:{interval:3e4,timeout:1e4},backoff:{initial:500,max:15e3}};async function ap(e,t){let n=await e();return n&&t.reconnect(),n}function op(e){let t=tn(()=>{let t=e.token();return`${e.origin.replace(/^http/,`ws`)}/ws${t===``?``:`?access_token=${encodeURIComponent(t)}`}`},ip),n=e.unauthorized;return{hub:fn({baseUrl:`${e.origin}/api`,manifest:rp,headers:()=>{let t=e.token();return t===``?{}:{authorization:`Bearer ${t}`}},ws:t,prefer:`ws`,...n===void 0?{}:{unauthorized:()=>ap(n,t)}}),socket:t}}function sp(e){return e instanceof xn?e.status:0}function cp(e){let t=rp.endpoints[e];return{method:t.method,endpoint:t.path}}function lp(e,t,n=Date.now){let r=(r,i)=>{let a=cp(r),o=new WeakMap,s=(e,t)=>{let n=typeof e==`object`&&e?o.get(e):void 0;n!==void 0&&(n.status=t)};return e.caller(r,{...i,onStart:e=>{typeof e==`object`&&e&&o.set(e,{at:n(),status:0}),i?.onStart?.(e)},onSuccess:(e,t)=>{s(t,200),i?.onSuccess?.(e,t)},onError:(e,t)=>{s(t,sp(e)),i?.onError?.(e,t)},onSettled:e=>{let r=typeof e==`object`&&e?e:void 0,s=r===void 0?void 0:o.get(r);r!==void 0&&s!==void 0&&(o.delete(r),t({at:s.at,...a,status:s.status,duration:Math.max(0,Math.round(n()-s.at))})),i?.onSettled?.(e)}})};return{...e,caller:r}}var up={wait:5e3,maxWait:3e4,max:500},dp=4e3,fp=3e3,pp=1e3,mp=`[hidden]`,hp=/token|password|passwd|secret|authorization|cookie|api[-_]?key|private[-_]?key|credential/i,gp=[/(bearer\s+)[\w.~+/=-]+/gi,/\beyJ[\w-]+\.[\w-]+\.[\w-]+/g],_p={log:`info`,info:`info`,warn:`warn`,error:`error`};function vp(e){return gp.reduce((e,t)=>e.replace(t,(e,t)=>typeof t==`string`?`${t}${mp}`:mp),e)}function yp(e){if(typeof e==`string`)return vp(e).slice(0,pp);if(e instanceof Error)return vp(`${e.name}: ${e.message}`).slice(0,pp);if(e===void 0||typeof e==`function`||typeof e==`symbol`)return String(e);try{return vp(JSON.stringify(e,(e,t)=>e!==``&&hp.test(e)?mp:t)).slice(0,pp)}catch{return Object.prototype.toString.call(e)}}function bp(e){return e.map(yp).join(` `).slice(0,dp)}function xp(e){return e.caller(`clientLogs`,{debounce:{wait:up.wait,maxWait:up.maxWait,accumulate:e=>{let t=e.at(-1);return{entries:e.flatMap(e=>e.entries).slice(-up.max),...t?.page===void 0?{}:{page:t.page}}}},retry:{attempts:3}})}function Sp(e){return e instanceof Error?{message:`${e.name}: ${e.message}`.slice(0,dp),fields:e.stack===void 0?{}:{stack:e.stack.slice(0,fp)}}:{message:String(e).slice(0,dp),fields:{}}}var Cp=class{#e;#t;constructor(e){this.#e=e,this.#t=e.clock??Date.now}log(e,t,n={}){let r=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,hp.test(e)?mp:vp(t)]));this.#r({type:`log`,at:this.#t(),level:e,message:vp(t).slice(0,dp),...Object.keys(r).length===0?{}:{fields:r}})}error(e,t){let{message:n,fields:r}=Sp(e);this.log(`error`,n,{source:t,...r})}traffic(e){this.#r({type:`traffic`,at:e.at,method:e.method.slice(0,16),endpoint:e.endpoint.slice(0,300),status:e.status,duration:e.duration})}watch(e,t=console){let n=e=>{this.error(e.error??e.message,`window`)},r=e=>{this.error(e.reason,`promise`)};e.addEventListener(`error`,n),e.addEventListener(`unhandledrejection`,r);let i=this.#n(t);return()=>{e.removeEventListener(`error`,n),e.removeEventListener(`unhandledrejection`,r),i()}}#n(e){let t=Object.keys(_p).filter(e=>e in _p),n=t.map(t=>[t,Object.getOwnPropertyDescriptor(e,t)]),r=!1;for(let n of t){let t=e[n].bind(e);e[n]=(...e)=>{if(t(...e),!r){r=!0;try{this.log(_p[n],bp(e),{source:`console`})}finally{r=!1}}}}return()=>{for(let[t,r]of n)r===void 0?Reflect.deleteProperty(e,t):Object.defineProperty(e,t,r)}}#r(e){if(!this.#e.signedIn())return;let t={entries:[e],page:this.#e.page().slice(0,300)};this.#e.send.call(t).catch(()=>void 0)}},wp=Rn.endpoints.createAdmin.cfg.body,Tp=Rn.endpoints.signIn.cfg.body,Ep=`harness.sign-in`,Dp=K({remember:bn(),email:G().optional()}),Op=class{#e;#t;#n;remembered;setup=B();loading=z(!0);busy=z(!1);problem=z(``);fields=B({});constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n,this.remembered=(n===void 0?void 0:Lr(n,`harness.sign-in`,Dp))??{remember:!0}}get needsAdmin(){return this.setup.value?.needsAdmin===!0}get providers(){return this.setup.value?.sso??[]}async finishSso(e){this.busy.value=!0,this.problem.value=``;try{return this.#t.keep(await this.#e.redeemSso.call({code:e},ql),this.remembered.remember),!0}catch(e){return this.problem.value=J(e,`That sign-in didn’t finish. Sign in again.`),!1}finally{this.busy.value=!1}}async load(){this.loading.value=!0,this.problem.value=``;try{this.setup.value=await this.#e.setup.call(ql)}catch(e){this.problem.value=J(e)}finally{this.loading.value=!1}}async submit(e){let t=this.needsAdmin?Y(wp,e):Y(Tp,e);if(this.fields.value=t.ok?{}:t.problems,this.problem.value=``,!t.ok)return!1;this.busy.value=!0;try{let t=this.needsAdmin?await this.#e.createAdmin.call({email:e.email,name:e.name,password:e.password,setup:e.setup??``},ql):await this.#e.signIn.call({email:e.email,password:e.password},ql),n=e.remember??!0;return this.#t.keep(t,n),this.#n?.setItem(Ep,JSON.stringify(n?{remember:n,email:e.email}:{remember:n})),!0}catch(e){return this.problem.value=J(e,`Couldn't sign in. Try again.`),!1}finally{this.busy.value=!1}}},kp=6e4,Ap=`harness.refresh`,jp=class{#e=new Map;run(e,t){let n=(this.#e.get(e)??Promise.resolve()).catch(()=>void 0).then(t);return this.#e.set(e,n),n}},Mp=class{#e;#t=new jp;constructor(e){this.#e=e?.locks}run(e,t){return this.#e===void 0?this.#t.run(e,t):this.#e.request(e,t).then(e=>e)}},Np=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n=Date.now,r=new jp){this.#e=e,this.#t=t,this.#n=n,this.#r=r}start(){this.#a??=T(this.#t.expiresAt,e=>{this.#c(e)},{immediate:!0})}stop(){this.#a?.(),this.#a=void 0,clearTimeout(this.#i)}refresh(e=`due`){let t=this.#t.refreshToken.value;return this.#r.run(Ap,async()=>{this.#t.reload();let n=this.#t.refreshToken.value;if(n===``)return!1;if(n!==t||e===`due`&&!this.#s())return!0;try{return this.#t.keep(await this.#e.refresh.call({refresh:n},ql)),!0}catch{return this.#t.forget(),!1}})}recover(){return this.#o??=this.refresh(`refused`).finally(()=>{this.#o=void 0}),this.#o}async signOut(){try{await this.#e.signOut.call()}catch{}this.#t.forget()}#s(){let e=this.#t.expiresAt.value;return e!==void 0&&e-6e4<=this.#n()}#c(e){clearTimeout(this.#i),e!==void 0&&(this.#i=setTimeout(()=>{this.refresh()},Math.max(0,e-kp-this.#n())))}},Pp=class{#e;view=new v;constructor(e){this.#e=e}load(){return this.view.load(()=>this.#e.account.call(),`Couldn’t load your account.`,this.view.value.value!==void 0)}},Fp=1500,Ip=2500,Lp=class{state=z(`online`);#e=new Set;#t;#n;#r=!1;constructor(e){this.#t=e.subscribe(e=>{this.#i(e)}),e.status===`offline`&&this.#i(`offline`)}onReconnect(e){return this.#e.add(e),()=>{this.#e.delete(e)}}dispose(){this.#t(),clearTimeout(this.#n)}#i(e){if(e===`offline`){if(this.#r)return;this.#r=!0,clearTimeout(this.#n),this.#n=setTimeout(()=>{this.state.value=`offline`},Fp)}else if(this.#r){this.#r=!1,clearTimeout(this.#n);for(let e of this.#e)e();this.state.value===`offline`&&(this.state.value=`back`,this.#n=setTimeout(()=>{this.state.value=`online`},Ip))}}},Rp=class{#e;#t;#n;state=z(`off`);busy=z(!1);problem=z(``);constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async check(){this.#t.supported()?this.#t.permission()===`denied`?this.state.value=`blocked`:this.state.value=await this.#t.current().catch(()=>void 0)===void 0?`off`:`on`:this.state.value=`unsupported`}async enable(){if(this.state.value===`unsupported`)return!1;this.busy.value=!0,this.problem.value=``;try{let{publicKey:e}=await this.#e.pushKey.call(),t=await this.#t.subscribe(e);return t===void 0?(this.state.value=this.#t.permission()===`denied`?`blocked`:`off`,!1):(await this.#e.subscribePush.call({endpoint:t.endpoint,keys:{p256dh:t.keys.p256dh,auth:t.keys.auth},device:this.#n()}),this.state.value=`on`,!0)}catch(e){return this.problem.value=J(e,`Couldn't turn on notifications.`),!1}finally{this.busy.value=!1}}async disable(){this.busy.value=!0;try{await this.#t.unsubscribe(),this.state.value=`off`}finally{this.busy.value=!1}}},zp={built:`/sw.js`,source:`/sw/sw.ts`};function Bp(e){let t=`${e}${`=`.repeat((4-e.length%4)%4)}`.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(new ArrayBuffer(n.length));for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var Vp=K({endpoint:G(),keys:K({p256dh:G(),auth:G()})}),Hp=class{#e;#t;constructor(e,t){this.#t=t,this.#e=e}supported(){return this.#e.isSecureContext&&`serviceWorker`in this.#e.navigator&&`PushManager`in this.#e&&`Notification`in this.#e}permission(){return Notification.permission}async current(){let e=await(await this.#e.navigator.serviceWorker.getRegistration(this.#t))?.pushManager.getSubscription();return e==null?void 0:Vp.parse(e.toJSON())}async subscribe(e){if(await Notification.requestPermission()!==`granted`)return;let t=await this.#e.navigator.serviceWorker.register(this.#t,{type:`module`,scope:`/`});await this.#e.navigator.serviceWorker.ready;let n=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Bp(e)});return Vp.parse(n.toJSON())}async unsubscribe(){await(await(await this.#e.navigator.serviceWorker.getRegistration(this.#t))?.pushManager.getSubscription())?.unsubscribe()}},Up=class{#e;view=B(void 0);loading=new p;saving=new p;authority=M(()=>this.view.value?.on===!0&&this.view.value.source===`own`?lr.der:void 0);constructor(e){this.#e=e}async load(){let e=await this.loading.run(()=>this.#e.https.call({}),`Couldn't read the hub's secure connection.`);e.ok&&(this.view.value=e.value)}async set(e){let t=await this.saving.run(()=>this.#e.setHttps.call({on:e}),`Couldn't save the setting.`);return t.ok&&(this.view.value=t.value),t}};function Wp(e,t){let n=new URL(t,e);return n.protocol=`http:`,n.toString()}var Gp=class{#e;#t;#n=[];state=z(`browser`);sheetOpen=z(!1);secure;constructor(e){this.#e=e,this.secure=e.secure(),this.#r(),this.#n.push(e.onPrompt(e=>{this.#t=e,this.#r()}),e.onChange(()=>{this.#t=void 0,this.#r()}))}get offered(){return this.state.value===`ready`||this.state.value===`ios`}#r(){let e=this.#e;this.state.value=e.standalone()?`installed`:e.secure()?this.#t===void 0?e.ios()?`ios`:`browser`:`ready`:`insecure`}async install(){if(this.state.value===`ios`)return this.sheetOpen.value=!0,`sheet`;let e=this.#t;if(this.state.value!==`ready`||e===void 0)return`unavailable`;this.#t=void 0,await e.prompt();let{outcome:t}=await e.userChoice;return this.#r(),t}stop(){for(let e of this.#n.splice(0))e()}},Kp=[`standalone`,`window-controls-overlay`,`minimal-ui`,`fullscreen`],qp=class{#e;constructor(e){this.#e=e}standalone(){return this.#e.navigator.standalone===!0||Kp.some(e=>this.#e.matchMedia(`(display-mode: ${e})`).matches)}secure(){return this.#e.isSecureContext}ios(){let e=this.#e.navigator;return/iPhone|iPad|iPod/.test(e.userAgent)||/Macintosh/.test(e.userAgent)&&e.maxTouchPoints>1}onPrompt(e){let t=t=>{Jp(t)&&(t.preventDefault(),e(t))};return this.#e.addEventListener(`beforeinstallprompt`,t),()=>{this.#e.removeEventListener(`beforeinstallprompt`,t)}}onChange(e){let t=Kp.map(e=>this.#e.matchMedia(`(display-mode: ${e})`));for(let n of t)n.addEventListener(`change`,e);return this.#e.addEventListener(`appinstalled`,e),()=>{for(let n of t)n.removeEventListener(`change`,e);this.#e.removeEventListener(`appinstalled`,e)}}};function Jp(e){return`prompt`in e&&typeof e.prompt==`function`&&`userChoice`in e}async function Yp(e,t){if(e.isSecureContext&&`serviceWorker`in e.navigator)try{await e.navigator.serviceWorker.register(t,{type:`module`,scope:`/`})}catch{}}var Xp=`harness.session`,Zp=Sn.pick({access:!0,refresh:!0,user:!0}).extend({expiresAt:ar,remember:bn().optional()}),Qp=`harness.alive`;function $p(e){return{alive:()=>e.cookie.split(`;`).some(e=>e.trim()===`${Qp}=1`),set:()=>{e.cookie=`${Qp}=1; Path=/; SameSite=Lax`},clear:()=>{e.cookie=`${Qp}=; Path=/; Max-Age=0; SameSite=Lax`}}}var em=class{#e;#t;#n;#r;constructor(e,t=Date.now,n,r){this.#e=e,this.#t=t,this.#r=r,this.#n=Br(e,Xp,Zp.optional(),void 0),this.#n.value?.remember===!1&&r!==void 0&&!r.alive()&&(this.#n.value=void 0),n?.(e=>{(e===null||e===`harness.session`)&&this.reload()})}accessToken=M(()=>this.#n.value?.access??``);refreshToken=M(()=>this.#n.value?.refresh??``);user=M(()=>this.#n.value?.user);signedIn=M(()=>this.#n.value!==void 0);expiresAt=M(()=>this.#n.value?.expiresAt);remembered=M(()=>this.#n.value?.remember!==!1);keep(e,t){let n=t??this.#n.value?.remember??!0;t===!1&&this.#r?.set(),this.#n.value={access:e.access,refresh:e.refresh,user:e.user,expiresAt:this.#t()+e.expiresIn,...n?{}:{remember:!1}}}forget(){this.#n.value=void 0}reload(){let e=Lr(this.#e,Xp,Zp);(e?.access!==this.#n.value?.access||e?.refresh!==this.#n.value?.refresh)&&(this.#n.value=e)}},tm=class{#e;query=B({});facets=B([]);list;groups=B(new Map);folders=B(new Map);selected=B(new Set);uploads=B([]);acting=new p;importing=new p;selectedCount=M(()=>this.selected.value.size);#t=0;#n;#r;#i=new Map;#a=new Map;#o=0;constructor(e){this.#e=e,this.list=new m({fetch:async(t,n,r)=>{let i=await e.api.browse.call(g(t,r,n));return this.facets.value=n===void 0?i.facets:d(this.facets.value,i.facets),i},key:e=>e.uri,failure:`Couldn't load resources.`,limit:60},{})}start(){return this.#n??=this.#e.events(()=>{clearTimeout(this.#r),this.#r=setTimeout(()=>{this.refresh()},500)}),()=>{this.stop()}}stop(){this.#n?.(),this.#n=void 0,clearTimeout(this.#r)}async show(e){this.query.value=e,this.#o++,this.selected.value=new Set,await this.list.load(y(e)),e.view===`groups`&&e.in===void 0&&await this.#s(e)}async refresh(){let e=this.query.value;await Promise.all([this.list.refresh(),...e.view===`groups`&&e.in===void 0?[this.#s(e,!0)]:[]])}async#s(e,t=!1){let n=this.#o,r=new Map;await Promise.all(this.facets.value.map(async n=>{let i=(t?this.groups.value.get(n.value):void 0)??new v;r.set(n.value,i),await i.load(()=>this.#e.api.browseGroup.call(me(e,n)),`Couldn't load this group.`,t)})),n===this.#o&&(this.groups.value=r)}async openFolder(e,t=!1){let n=this.folders.value.get(e);if(n!==void 0&&!t)return;let r=n??new v;n===void 0&&(this.folders.value=new Map([...this.folders.value,[e,r]])),await r.load(async()=>(await this.#e.api.browseGroup.call(f(this.query.value,e))).facets,`Couldn't load the folders.`)}peek(e){let t=`${e.uri}@${e.stat.version}`,n=this.#a.get(t);if(n!==void 0)return n;let r=new v;return this.#a.set(t,r),r.load(()=>this.#c(e),``,!0),r}async#c(e){let t=li(e.stat);if(e.forms?.includes(`thumbnail`)===!0)return{kind:`image`,url:(await this.#e.api.download.call({uri:e.uri,form:`thumbnail`})).url};if(t===`image`)return{kind:`image`,url:(await this.#e.api.download.call({uri:e.uri})).url};if(t===`code`||t===`document`||t===`data`||t===`table`||t===`web`){let t=await this.#e.api.read.call({uri:e.uri,maxChars:400});return t.text.trim()===``?{kind:`none`}:{kind:`text`,text:t.text}}return{kind:`none`}}toggle(e){let t=new Set(this.selected.value);t.has(e)?t.delete(e):t.add(e),this.selected.value=t}toggleAll(){let e=this.list.items.value.map(e=>e.uri);this.selected.value=e.every(e=>this.selected.value.has(e))?new Set:new Set(e)}clearSelection(){this.selected.value=new Set}async importUrl(e){let t=await this.importing.run(()=>this.#e.api.importResource.call({url:e}),`Couldn't import that address.`);return t.ok&&this.list.refresh(),t}async refetch(e){let t=e.flatMap(e=>{let t=ut(e);return t===void 0?[]:[{url:t,name:e.stat.name}]}),n=await this.acting.run(()=>Promise.all(t.map(e=>this.#e.api.importResource.call(e))),`Couldn't fetch that again.`);if(n.ok)return this.list.refresh(),n.value.length}async upload(e){await Promise.all(e.map(e=>this.#l(e))),this.list.refresh()}async#l(e){let t=++this.#t,n=new AbortController;this.#i.set(t,n),this.#u({id:t,name:e.name,size:e.size,status:`uploading`,progress:0});try{let r=e.type===``?`application/octet-stream`:e.type,{url:i,upload:a}=await this.#e.api.upload.call({name:e.name,mime:r,size:e.size});await this.#e.sender.put(i,e,e=>{this.#d(t,{progress:e})},n.signal),this.#d(t,{status:`importing`,progress:1});let o=await this.#e.api.uploaded.call({upload:a}),s=await this.#e.api.importResource.call({content:o,name:e.name});this.#d(t,{status:`done`,uri:s.uri})}catch(n){this.#d(t,{status:`failed`,problem:J(n,`Couldn't upload ${e.name}.`)})}finally{this.#i.delete(t)}}dismissUpload(e){this.#i.get(e)?.abort(),this.uploads.value=this.uploads.value.filter(t=>t.id!==e)}#u(e){this.uploads.value=[...this.uploads.value,e]}#d(e,t){this.uploads.value=this.uploads.value.map(n=>n.id===e?{...n,...t}:n)}async rename(e,t){let n=await this.acting.run(()=>this.#e.api.rename.call({uri:e,name:t}),`Couldn't rename it.`);return n.ok&&this.list.refresh(),n.ok}async remove(e){let t=await this.acting.run(async()=>{let t=await Promise.all(e.map(e=>this.#e.api.remove.call({uri:e})));return{deleted:t.filter(e=>e.deleted).length,kept:t.filter(e=>!e.deleted).length}},`Couldn't delete that.`);if(t.ok)return this.selected.value=new Set([...this.selected.value].filter(t=>!e.includes(t))),await this.list.load(),t.value}async makeContext(e){let t=await this.acting.run(async()=>(await Promise.all(e.map(e=>this.#e.api.contextFrom.call({uri:e,copy:`live`})))).flatMap(e=>[...e.created,...e.updated]),`Couldn't make context from that.`);return t.ok?t.value:void 0}async downloadUrl(e){let t=await this.acting.run(()=>this.#e.api.download.call({uri:e}),`Couldn't start the download.`);return t.ok?t.value.url:void 0}async make(e,t){let n=await this.acting.run(()=>Promise.all(e.map(e=>this.#e.api.convert.call({uri:e,kind:t}))),`Couldn't make that.`);return n.ok&&this.list.refresh(),n.ok}},nm=class{#e;#t=new Map;at=B(``);roots=new v;file=new v;constructor(e){this.#e=e}async open(e,t){let n=`${e}/${t}`;(this.at.value!==n||this.roots.value.value===void 0)&&(this.at.value=n,this.#t.clear(),this.file.reset(),await this.roots.load(()=>this.#e.exploreRoots.call({system:e,instance:t}),`Couldn't list ${n}'s folders.`))}folder(e){let t=this.#t.get(e);if(t!==void 0)return t;let n=new m({fetch:(e,t)=>this.#e.exploreList.call({uri:e,...t===void 0?{}:{cursor:t}}),key:e=>e.uri,failure:`Couldn't list this folder.`,limit:200},e);return this.#t.set(e,n),n.load(),n}peek(e){let t=sn.safeParse(e);return t.success?this.#t.get(t.data):void 0}async read(e){e===void 0?this.file.reset():this.file.value.value?.stat.uri!==e&&await this.file.load(()=>this.#e.exploreRead.call({uri:e,want:[`text`]}),`Couldn't read this file.`)}refresh(e){this.#t.get(e)?.load()}},rm=class{#e;found=new v;constructor(e){this.#e=e}async search(e){let t=e.trim();t===``?this.found.reset():await this.found.load(async()=>(await this.#e.find.call({search:t,limit:8})).items,`Couldn't search resources.`)}},Q={as:`text`,form:`raw`},im={as:`url`},$={as:`none`},am={svg:{preview:{draws:`svg`,reads:im},source:`code`},mermaid:{preview:{draws:`diagram`,reads:Q},source:`code`},markdown:{preview:{draws:`markdown`,reads:Q},source:`code`},html:{preview:{draws:`html`,reads:Q},source:`code`},csv:{preview:{draws:`table`,reads:Q},source:`code`},tsv:{preview:{draws:`table`,reads:Q},source:`code`},excel:{preview:{draws:`table`,reads:{as:`version`,form:`table`}}},ods:{preview:{draws:`table`,reads:{as:`version`,form:`table`}}},pdf:{preview:{draws:`pdf`,reads:im}},docx:{preview:{draws:`markdown`,reads:{as:`text`,form:`markdown`}}},pptx:{preview:{draws:`markdown`,reads:{as:`text`,form:`markdown`}}},odt:{preview:{draws:`markdown`,reads:{as:`text`,form:`markdown`}}},rtf:{preview:{draws:`markdown`,reads:{as:`text`,form:`markdown`}}},notebook:{preview:{draws:`markdown`,reads:{as:`text`,form:`markdown`}},source:`code`},json:{preview:{draws:`json`,reads:Q},source:`code`},jsonl:{preview:{draws:`json`,reads:Q},source:`code`},text:{source:`text`}},om={document:{source:`text`},code:{source:`code`},image:{preview:{draws:`image`,reads:im}},table:{preview:{draws:`table`,reads:{as:`version`,form:`table`}}},audio:{preview:{draws:`audio`,reads:im}},video:{preview:{draws:`video`,reads:im}},web:{preview:{draws:`html`,reads:Q},source:`code`},data:{source:`code`},archive:{preview:{draws:`folder`,reads:$}},folder:{preview:{draws:`folder`,reads:$}},other:{preview:{draws:`binary`,reads:$}}},sm=[`markdown`,`table`,`pages`,`code`,`text`,`description`,`ocr`,`transcript`],cm={markdown:{draws:`markdown`,reads:{as:`text`,form:`markdown`}},text:{draws:`text`,reads:{as:`text`,form:`text`}},code:{draws:`code`,reads:{as:`text`,form:`code`}},pages:{draws:`pages`,reads:{as:`version`,form:`pages`}},table:{draws:`table`,reads:{as:`version`,form:`table`}},description:{draws:`markdown`,reads:{as:`text`,form:`description`}},ocr:{draws:`text`,reads:{as:`text`,form:`ocr`}},transcript:{draws:`text`,reads:{as:`text`,form:`transcript`}},thumbnail:{draws:`image`,reads:{as:`url`}}};function lm(e){return e.as===`text`?e.form===`raw`?void 0:e.form:e.as===`version`?e.form:void 0}function um(e,t){let n=t.preview;return e===`thumbnail`||n===void 0?e===`thumbnail`:lm(n.reads)===e||n.reads.as===`text`&&n.reads.form===`raw`&&cm[e].draws===n.draws}function dm(e,t,n=[],r=[]){let i=li(e),a=e.mime?.startsWith(`image/svg`)===!0?am.svg:void 0,o=(e.format===void 0?void 0:am[e.format])??a??om[i],s=di(e.format)||`text`,c=new Set(t),l=[],u=r.find(e=>e.mode===`replace`);if(u!==void 0)l.push({id:`preview`,label:`Preview`,draws:`system`,reads:$,system:u.system});else if(o.preview!==void 0){let e=lm(o.preview.reads),t=e===void 0?void 0:n.find(t=>t.kind===e);e===void 0||c.has(e)?l.push({id:`preview`,label:`Preview`,...o.preview,...e===void 0?{}:{form:e}}):l.push(t===void 0?{id:`preview`,label:`Preview`,draws:`binary`,reads:$}:{id:`preview`,label:`Preview`,draws:`offer`,reads:$,form:t.kind,offer:t})}o.source!==void 0&&l.push({id:`source`,label:l.length===0?`Text`:`Source`,draws:o.source,reads:Q,...o.source===`code`?{language:s}:{}});for(let e of r.filter(e=>e.mode===`tab`))l.push({id:`system:${e.system}`,label:e.label,draws:`system`,reads:$,system:e.system});let d=[...sm,...t.filter(e=>!sm.includes(e))];for(let e of d){if(um(e,o))continue;if(c.has(e)){l.push({id:e,label:ui[e],...cm[e],form:e,...e===`code`?{language:s}:{}});continue}let t=n.find(t=>t.kind===e);t!==void 0&&l.push({id:e,label:ui[e],draws:`offer`,reads:$,form:e,offer:t})}return l.push({id:`info`,label:`Info`,draws:`info`,reads:$}),{family:i,modes:l,initial:l[0]?.id??`info`}}function fm(e,t){let n={id:`info`,label:`Info`,draws:`info`,reads:$};return e.modes.find(e=>e.id===t)??e.modes.find(t=>t.id===e.initial)??n}function pm(e){switch(e.as){case`text`:return`text:${e.form}`;case`url`:return`url`;case`version`:return`version:${e.form}`;case`none`:return`none`}}function mm(e){return e.value}var hm=2e5;z(0);var gm=class{#e;uri=B(void 0);section=B(void 0);opened=new v;asked=z(void 0);#t=new Map;#n=z(0);making=new p;contexting=new p;plan;mode;systemViewers;constructor(e){this.#e=e,this.systemViewers=M(()=>{mm(e.systems.version);let t=this.opened.value.value?.stat.format;return t===void 0?[]:e.systems.viewers(t)}),this.plan=M(()=>{let e=this.opened.value.value;if(e===void 0)return;let t=this.systemViewers.value.map(e=>({system:e.system,mode:e.mode,label:e.label}));return dm(e.stat,e.forms.map(e=>e.kind),e.offers,t)}),this.mode=M(()=>this.plan.value===void 0?void 0:fm(this.plan.value,this.asked.value))}async open(e,t){let n=this.uri.value===e;n||(this.#t.clear(),this.#n.value++),this.uri.value=e,this.section.value=t,await this.opened.load(()=>this.#r(e),`Couldn't open this resource.`,n&&this.opened.value.value!==void 0)}close(){this.uri.value=void 0,this.opened.reset(),this.#t.clear(),this.#n.value++}async#r(e){try{let t=await this.#e.api.forms.call({uri:e});return{stat:t.record.stat,record:t.record,forms:t.forms,offers:t.offers,links:t.record.links,from:`library`,text:void 0}}catch(t){try{let t=await this.#e.api.systemRead.call({uri:e,want:[`text`,`links`]}),n=t.text!==void 0&&`inline`in t.text?t.text.inline:void 0;return{stat:t.stat,record:void 0,forms:[],offers:[],links:t.links??[],from:`system`,text:n}}catch{throw t}}}load(e){mm(this.#n);let t=this.uri.value,n=this.opened.value.value;if(e.as===`none`||t===void 0||n===void 0)return;let r=pm(e),i=this.#t.get(r);if(i!==void 0)return i;let a=new v;return this.#t.set(r,a),a.load(()=>this.#i(t,n,e),e.as===`url`?`Couldn't load this file.`:`Couldn't read this.`),a}async#i(e,t,n){switch(n.as){case`text`:if(t.from===`system`){let n=t.text??``;return{as:`text`,result:{uri:e,form:`raw`,text:n,offset:0,total:n.length,truncated:!1,forms:[],offers:[]}}}return{as:`text`,result:await this.#e.api.read.call({uri:e,form:n.form,maxChars:hm})};case`url`:if(t.from===`system`)throw Error(`This system resource has no download.`);return{as:`url`,download:await this.#e.api.download.call({uri:e})};case`version`:{let t=await this.#e.api.download.call({uri:e,form:n.form}),r=await this.#e.fetch(t.url);if(!r.ok)throw Error(`The download answered ${r.status}.`);return{as:`version`,version:Hn.parse(await r.json())}}}}retry(e){this.#t.delete(pm(e)),this.#n.value++}text(e){let t=this.load(e)?.value.value;return t?.as===`text`?t.result:void 0}download(e){let t=this.load(e)?.value.value;return t?.as===`url`?t.download:void 0}version(e){let t=this.load(e)?.value.value;return t?.as===`version`?t.version:void 0}async downloadUrl(e){let t=this.uri.value;if(t===void 0)return;let n=await this.making.run(()=>this.#e.api.download.call({uri:t,...e===void 0?{}:{form:e}}),`Couldn't start the download.`);return n.ok?n.value:void 0}async make(e){let t=this.uri.value;if(t===void 0)return!1;let n=await this.making.run(()=>this.#e.api.convert.call({uri:t,kind:e}),`Couldn't make that.`);return n.ok&&await this.open(t,this.section.value),n.ok}async makeContext(){let e=this.uri.value;if(e===void 0)return;let t=await this.contexting.run(()=>this.#e.api.contextFrom.call({uri:e,copy:`live`}),`Couldn't make context from this.`);return t.ok?t.value:void 0}changed(e){e.uri===this.uri.value&&(this.#t.clear(),this.#n.value++,this.open(e.uri,this.section.value))}systemView(e){let t=this.opened.value.value,n=this.uri.value;if(t===void 0||n===void 0)return;let r=this.#e;return{stat:t.stat,...this.section.value===void 0?{}:{section:this.section.value},forms:t.forms.map(e=>e.kind),text:async e=>t.from===`system`?t.text??``:(await r.api.read.call({uri:n,form:e??`raw`,maxChars:hm})).text,bytes:async()=>{if(t.from===`system`)return new Uint8Array;let e=await r.api.download.call({uri:n});return new Uint8Array(await(await r.fetch(e.url)).arrayBuffer())},system:r.systems.client(e)}}},_m=class{#e;browser;explorer;constructor(e){this.#e=e,this.browser=new tm({api:e.api,events:e.events,sender:e.sender}),this.explorer=new nm(e.api)}search(){return new rm(this.#e.api)}viewer(){let e=new gm({api:this.#e.api,fetch:this.#e.fetch,systems:this.#e.systems}),t=this.#e.events(t=>{e.changed(t)});return this.#e.prepare(),xe()!==void 0&&Oe(t),{store:e,stop:t}}},vm=[`active`,`hidden`,`not_applicable`,`pending_approval`,`pending_removal`],ym={active:`ok`,hidden:`neutral`,not_applicable:`neutral`,pending_approval:`warn`,pending_removal:`danger`,pending_plan:`accent`},bm={person:`A person`,system:`A system`,research:`Research`};function xm(e,t){let n=(e.filters??[]).filter(e=>e.field===t),[r]=n;return n.length===1&&r!==void 0&&r.op===`is`&&typeof r.value==`string`?r.value:void 0}function Sm(e,t,n){let r=(e.filters??[]).filter(e=>e.field!==t),i=n===void 0?r:[...r,{field:t,op:`is`,value:n}],{filters:a,...o}=e;return i.length===0?o:{...o,filters:i}}function Cm(e){return new Map(e.map(e=>[String(e.value),e.count]))}function wm(e){return e.sort?.[0]?.field===`lastModified`}var Tm={approve:{label:`Approve`,icon:`check`,from:[`pending_approval`],danger:!1,done:`Approved`},hide:{label:`Hide`,icon:`eye-off`,from:[`active`,`not_applicable`,`pending_approval`,`pending_removal`,`pending_plan`],danger:!1,done:`Hidden`},restore:{label:`Restore`,icon:`undo`,from:[`hidden`,`not_applicable`,`pending_removal`],danger:!1,done:`Restored`},confirm_removal:{label:`Confirm removal`,icon:`trash`,from:[`pending_removal`],danger:!0,done:`Removed`}};function Em(e,t){return e.origin?.type===`memory`&&t.me!==void 0&&e.origin.author===t.me}function Dm(e,t){return t.admin||Em(e,t)}function Om(e,t,n){return Tm[t].from.includes(e.status)?n.admin||Em(e,n)&&(t===`hide`||t===`restore`):!1}function km(e,t){return Yn.flatMap(n=>{let r=e.filter(e=>Om(e,n,t)).map(e=>e.name),i=Tm[n];return r.length===0?[]:[{action:n,label:i.label,icon:i.icon,danger:i.danger,names:r}]})}function Am(e,t,n){let r=`${Tm[e].done} ${t.toLocaleString()}`;return n===0?r:`${r} · ${n.toLocaleString()} left as ${n===1?`it was`:`they were`}`}function jm(e){return e===void 0?``:`${Math.round(Math.min(1,Math.max(0,e))*100)}% alike`}function Mm(e){let t=[];if(e.duplicate!==void 0){let n=jm(e.duplicate.similarity);t.push({key:`duplicate`,label:`Possible duplicate`,tone:`warn`,icon:`copy`,title:`May say the same as ${e.duplicate.of}${n===``?``:` (${n})`}: ${e.duplicate.reason}`})}if(e.contradiction!==void 0&&t.push({key:`contradiction`,label:`Contradiction`,tone:`danger`,icon:`warning`,title:`Its answer may disagree with ${e.contradiction.of}: ${e.contradiction.reason}`}),e.metadataStale===!0&&t.push({key:`stale`,label:`Metadata out of date`,tone:`neutral`,icon:`clock`,title:`Its text changed since its question was written; it is filled in again in the background.`}),e.split?.from!==void 0)t.push({key:`split`,label:`Split out`,tone:`accent`,icon:`tree`,title:`Made from ${e.split.from}, which answered several questions.`});else if(e.split?.into!==void 0&&e.split.into.length>0){let n=e.split.into.length;t.push({key:`split`,label:`Split into ${n}`,tone:`accent`,icon:`tree`,title:`It answered several questions, so it was split into ${n} items, one per question.`})}return t}function Nm(e){return e.statusReason??Pm[e.status]}var Pm={active:`In use: searched, suggested and loaded.`,hidden:`Switched off: left out of every selection and search.`,not_applicable:`Ruled out by a plan’s answer; a model sees it only when it has an answer and asks for it.`,pending_approval:`New from a system or a resource; not searched or loaded until an admin approves it.`,pending_removal:`Its source dropped it; it keeps working until an admin confirms the removal.`,pending_plan:`An open question in a plan, with no answer yet.`},Fm={duplicate:{label:`Duplicates`,about:`Items that may answer the same question as a newer one. Merge them, keep both, or hide the older.`},contradiction:{label:`Contradictions`,about:`Items whose answers to the same question may disagree. Hide the one that is wrong, or edit it.`},pending_approval:{label:`Waiting for approval`,about:`New context from systems and resources. It is not searched or loaded until it is approved.`},pending_removal:{label:`Waiting for removal`,about:`Items their source dropped. They keep working until the removal is confirmed.`}};function Im(e){let t=new Set;return e.filter(e=>{if(e.kind!==`contradiction`||e.other===void 0)return!0;let n=[e.item.name,e.other.name].sort().join(`|`);return!t.has(n)&&(t.add(n),!0)})}function Lm(e){if(e===void 0)return 0;let{duplicate:t,contradiction:n,pending_approval:r,pending_removal:i}=e.counts;return t+n+r+i-(e.items.length-Im(e.items).length)}var Rm={active:{label:`Active`,about:`New context from systems and resources is in use at once.`},pending_approval:{label:`Pending approval`,about:`An admin approves each new item in Review before it is used.`},hidden:{label:`Hidden`,about:`New items start switched off; an admin restores the ones to use.`}},zm={question:`Question`,when:`When`,askedBy:`Asked by`,validUntil:`Valid until`};function Bm(e,t){return e!==void 0&&e<=t}function Vm(e){return new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function Hm(e){return[...e].sort((e,t)=>t.at-e.at)}function Um(e,t){return e.from===void 0?t[e.status]:`${t[e.from]} → ${t[e.status]}`}var Wm=class{#e;statusCounts=new v;askerCounts=new v;queue=new v;setting=new v;acting=new p;saving=new p;busyKey=z(``);#t=!1;constructor(e){this.#e=e}async load(e){this.#t=e,await Promise.all([this.loadCounts(!1),...e?[this.loadQueue(!1),this.setting.load(()=>this.#e.newStatus.call({}),`Couldn't load the setting.`)]:[]])}async loadCounts(e=!0){await Promise.all([this.statusCounts.load(async()=>Cm(await this.#e.values.call({list:`contexts`,field:`status`,limit:20})),`Couldn't count the statuses.`,e),this.askerCounts.load(async()=>Cm(await this.#e.values.call({list:`contexts`,field:`askedBy`,limit:20})),`Couldn't count who asked.`,e)])}async loadQueue(e=!0){await this.queue.load(()=>this.#e.review.call({limit:100}),`Couldn't load Review.`,e)}changed(){this.loadCounts(),this.#t&&this.loadQueue()}async setStatus(e,t=``){return this.#n(t,()=>this.#e.setStatus.call(e),`Couldn't change those items.`)}async merge(e,t=``){return this.#n(t,()=>this.#e.merge.call(e),`Couldn't merge them.`)}async notDuplicate(e,t=``){return this.#n(t,async()=>(await this.#e.notDuplicate.call(e)).ok,`Couldn't clear that flag.`)}async saveSetting(e){let t=await this.saving.run(()=>this.#e.setNewStatus.call({value:e}),`Couldn't change the setting.`);return t.ok&&this.setting.set(t.value),t}async#n(e,t,n){this.busyKey.value=e;let r=await this.acting.run(t,n);return this.busyKey.value=``,r.ok&&await Promise.all([this.loadCounts(),...this.#t?[this.loadQueue()]:[]]),r}},Gm=class{#e;list=new v;open=new v;answering=new p;busyQuestion=z(``);deeper=z([]);#t=!1;constructor(e){this.#e=e}async loadList(e=!1){this.#t=!0,await this.list.load(()=>this.#e.plans.call({}),`Couldn't load the plans.`,e)}async show(e){let t=this.open.value.value?.run===e;t||(this.open.reset(),this.deeper.value=[]),await this.open.load(()=>this.#e.plan.call({run:e}),`Couldn't load the plan.`,t)}close(){this.open.reset(),this.deeper.value=[]}async markdown(e){try{return(await this.#e.plan.call({run:e,format:`markdown`})).markdown}catch{return}}async answer(e,t){let n={run:e,...t.answer===void 0?{}:{answers:[t.answer]},...t.reason===void 0?{}:{reasons:[t.reason]}};this.busyQuestion.value=t.answer?.question??t.reason?.question??``;let r=await this.answering.run(()=>this.#e.answerPlan.call(n),`Couldn't save that answer.`);return this.busyQuestion.value=``,r.ok&&(this.open.value.value?.run===e&&this.open.set({run:e,plan:r.value.plan}),this.deeper.value=r.value.deeper,this.#t&&this.loadList(!0)),r}changed(){this.#t&&this.loadList(!0);let e=this.open.value.value?.run;e!==void 0&&!this.answering.busy.value&&this.show(e)}},Km=class{#e;name=z(void 0);view=new v;metadata=new v;reextracting=new p;choiceTargets=z(new Map);linking=new p;unlinking=new p;forgetting=new p;saving=new p;constructor(e){this.#e=e}async open(e){let t=this.name.value===e&&this.view.value.value!==void 0;t||(this.view.reset(),this.metadata.reset(),this.choiceTargets.value=new Map),this.name.value=e,await Promise.all([this.view.load(()=>this.#e.item.call({name:e}),`Couldn't load this context item.`,t),this.metadata.load(()=>this.#e.metadata.call({name:e}),`Couldn't load its metadata.`,t)]),await this.#t(e)}async#t(e){let t=[...new Set(this.view.value.value?.record.decl.choices?.map(e=>e.to)??[])];if(t.length===0)this.choiceTargets.value=new Map;else try{let n=await this.#e.list.call({query:{filters:[{field:`name`,op:`in`,values:t}]},limit:Math.min(t.length,200)});this.name.value===e&&(this.choiceTargets.value=new Map(n.items.map(e=>[e.name,e])))}catch{}}close(){this.name.value=void 0,this.view.reset(),this.metadata.reset(),this.choiceTargets.value=new Map}touches(e){let t=this.view.value.value;return this.name.value===void 0||t===void 0?!1:this.name.value===e||t.backlinks.some(t=>t.from===e)||t.links.some(t=>t.to.kind===`context`&&t.to.name===e)}async reload(){let e=this.name.value;e!==void 0&&await this.open(e)}async addLink(e){let t=this.name.value;if(t===void 0)return{ok:!1,problem:`No context item is open.`};let n=de(e,t);if(!n.ok)return this.linking.problem.value=n.problem,n;let r=await this.linking.run(()=>this.#e.link.call({from:t,to:n.value.to,relation:n.value.relation,weight:n.value.weight}),`Couldn't add that link.`);return r.ok&&await this.reload(),r}async removeLink(e){let t=await this.unlinking.run(async()=>(await this.#e.unlink.call({from:e.from,toKey:e.toKey,relation:e.relation})).ok,`Couldn't remove that link.`);return t.ok&&await this.reload(),t}async forget(){let e=this.name.value;if(e===void 0)return{ok:!1,problem:`No context item is open.`};let t=await this.forgetting.run(async()=>(await this.#e.forget.call({name:e})).ok,`Couldn't forget this memory.`);return t.ok&&await this.reload(),t}async reextract(){let e=this.name.value;if(e===void 0)return{ok:!1,problem:`No context item is open.`};let t=await this.reextracting.run(()=>this.#e.reextract.call({names:[e]}),`Couldn't fill its metadata again.`);return t.ok&&await this.reload(),t}async edit(e){let t=this.view.value.value;if(t?.record.origin?.type!==`memory`)return{ok:!1,problem:`Only a memory can be edited.`};let n=ue(t.record.name,e);if(!n.ok)return this.saving.problem.value=n.problem,n;let r=await this.saving.run(async()=>(await this.#e.updateMemory.call(n.value)).name,`Couldn't save this memory.`);return r.ok&&await this.open(r.value),r}},qm=class{#e;list;item;review;plans;remembering=new p;making=new p;#t=0;#n;constructor(e){this.#e=e,this.list=new m({fetch:(t,n,r)=>e.api.list.call({...t,limit:r,...n===void 0?{}:{cursor:n}}),key:e=>e.name,failure:`Couldn't load the context.`,limit:50},{}),this.item=new Km(e.api),this.review=new Wm(e.api),this.plans=new Gm(e.api)}async show(e){this.list.loaded.value&&JSON.stringify(e)===JSON.stringify(this.list.filter.value)?await this.list.refresh():await this.list.load(e)}follow(){this.#t++,this.#n??=this.#e.events(e=>{this.changed(e)});let e=!1,t=()=>{e||(e=!0,this.#t--,this.#t===0&&(this.#n?.(),this.#n=void 0))};return xe()!==void 0&&Oe(t),t}changed(e){this.list.refresh(),this.review.changed(),this.plans.changed(),this.item.touches(e)&&this.item.reload()}async remember(e){let t=b(e);if(!t.ok)return this.remembering.problem.value=t.problem,t;let n=await this.remembering.run(async()=>(await this.#e.api.remember.call(t.value)).name,`Couldn't remember that.`);return n.ok&&this.list.refresh(),n}async fromResource(e){let t=await this.making.run(()=>this.#e.api.fromResource.call(e),`Couldn't make context from that resource.`);return t.ok&&this.list.refresh(),t}},Jm=class{#e;#t;#n;name=z(void 0);about=new v;facts=new v;examples=B([]);examplesTotal=z(0);examplesNext=z(void 0);examplesLoading=z(!1);examplesProblem=z(``);#r=0;constructor(e,t){this.#e=e,this.#t=t}async open(e){let t=this.name.value===e;t||this.close(),this.name.value=e,this.#n??=this.#t(e=>{this.#o(e)}),await Promise.all([this.#i(e,t),this.#a(e,t),t?Promise.resolve():this.moreExamples()])}close(){this.#n?.(),this.#n=void 0,this.name.value=void 0,this.about.reset(),this.facts.reset(),this.#r++,this.examples.value=[],this.examplesTotal.value=0,this.examplesNext.value=void 0,this.examplesLoading.value=!1,this.examplesProblem.value=``}async moreExamples(){let e=this.name.value,t=this.examples.value.length===0?0:this.examplesNext.value;if(e===void 0||t===void 0||this.examplesLoading.value)return;let n=++this.#r;this.examplesLoading.value=!0,this.examplesProblem.value=``;try{let r=await this.#e.fnExamples.call({fn:e,offset:t,limit:5});if(n!==this.#r)return;this.examples.value=[...this.examples.value,...r.items],this.examplesTotal.value=r.total,this.examplesNext.value=r.next}catch(e){n===this.#r&&(this.examplesProblem.value=J(e,`Couldn't load its examples.`))}finally{n===this.#r&&(this.examplesLoading.value=!1)}}async#i(e,t){await this.about.load(async()=>(await this.#e.searchFns.call({names:[e],items:[`fn`],available:!1,limit:1})).items.find(t=>t.name===e),`Couldn't load this fn.`,t)}async#a(e,t){await this.facts.load(()=>this.#e.fnFacts.call({fn:e}),`Couldn't load this fn's facts.`,t)}#o(e){let t=this.name.value;e.type===`fn`&&t!==void 0&&e.fn===t&&this.#a(t,!0)}},Ym=class{#e;known=B(new Map);#t=new Set;constructor(e){this.#e=e}fnOf(e){return cn(e,e=>this.known.value.get(e))}async resolve(e){let t=[...new Set(e)].filter(e=>hn(e)&&!this.#t.has(e));if(t.length!==0){for(let e of t)this.#t.add(e);try{let e=await this.#e.fnsOfModelNames.call({names:t});this.known.value=new Map([...this.known.value,...Object.entries(e)])}catch{for(let e of t)this.#t.delete(e)}}}},Xm=`harness.hubName`,Zm=class{#e;#t;#n;#r;#i;identity=B(void 0);name=M(()=>this.identity.value?.name??this.#r??`fnloom`);source=M(()=>this.identity.value?.source);version=M(()=>this.identity.value?.version??``);saving=new p;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n,this.#r=n===void 0?void 0:Lr(n,Xm,gn)}async load(){try{this.#o(await this.#e.identity.call(ql))}catch{}}start(){this.#i??=this.#t(e=>{this.#a(e)})}stop(){this.#i?.(),this.#i=void 0}async rename(e){let t=await this.saving.run(()=>this.#e.setHubName.call({name:e}),`Couldn't save the name.`);return t.ok&&this.#o(t.value),t}#a(e){e.type===`identity`&&this.#o(e.identity)}#o(e){this.identity.value=e;try{this.#n?.setItem(Xm,JSON.stringify(e.name))}catch{}}},Qm={setting:`Set here.`,env:`From the hub’s HARNESS_NAME setting.`,default:`The default name.`};function $m(e){let t=gn.safeParse(e);return t.success?{ok:!0,name:t.data}:{ok:!1,problem:e.trim()===``?`Give the hub a name.`:`Keep it to one line of at most 40 characters.`}}var eh=class{#e;view=B(void 0);value=M(()=>this.view.value?.value??`ask`);saving=new p;constructor(e){this.#e=e}async load(){try{this.view.value=await this.#e.outsideImages.call({})}catch{}}async set(e){let t=await this.saving.run(()=>this.#e.setOutsideImages.call({value:e}),`Couldn't save the setting.`);return t.ok&&(this.view.value=t.value),t}clear(){this.view.value=void 0}},th=class{#e;page=new v;#t;constructor(e){this.#e=e}async show(e){let t=this.#t!==void 0&&JSON.stringify(e)===JSON.stringify(this.#t)&&this.page.value.value!==void 0;this.#t=e,await this.page.load(()=>this.#e.graph.call(e),`Couldn't load the graph.`,t)}async refresh(){this.#t!==void 0&&await this.show(this.#t)}},nh=class{#e;run=new v;tree=new v;approval=B(void 0);acting=new p;id=B(void 0);branch=M(()=>this.id.value===void 0?void 0:ae(this.tree.value.value,this.id.value));constructor(e){this.#e=e}async open(e){this.id.value!==e&&(this.id.value=e,this.run.reset(),this.tree.reset(),this.approval.value=void 0),await this.#t(e,!1)}async refresh(){let e=this.id.value;e!==void 0&&await this.#t(e,!0)}async decide(e,t,n){let r=this.approval.value;if(r===void 0)return!1;let i=await this.acting.run(()=>this.#e.approve.call({approval:r.id,approve:e,remember:`once`,...t===``?{}:{reason:t},...n===void 0?{}:{answer:n}}),`Couldn't send your answer.`);return i.ok&&(this.approval.value=void 0,this.refresh()),i.ok}async undo(){let e=this.run.value.value;if(e===void 0)return{ok:!1,problem:`The run has not loaded yet.`};let t=await this.acting.run(()=>this.#e.undoTurn.call({turn:e.turn}),`Couldn't undo it.`);return t.ok&&await this.refresh(),t}async background(){let e=this.run.value.value;if(e===void 0)return{ok:!1,problem:`The run has not loaded yet.`};let t=await this.acting.run(async()=>(await this.#e.background.call({run:e.id})).accepted,`Couldn't move it to the background.`);return t.ok&&this.refresh(),t}async#t(e,t){await this.run.load(()=>this.#e.run.call({run:e}),`Couldn't load this run.`,t);let n=this.run.value.value;n!==void 0&&n.id===e&&this.id.value===e&&await Promise.all([this.tree.load(()=>this.#e.tree.call({turn:n.turn}),`Couldn't load what it called.`,t||this.tree.value.value!==void 0),this.#n(n)])}async#n(e){if(e.status!==`awaiting-approval`)this.approval.value=void 0;else try{let t=await this.#e.approvals.call({runs:[e.id]});this.id.value===e.id&&(this.approval.value=t.find(t=>t.run===e.id&&t.status===`pending`))}catch{this.id.value===e.id&&(this.approval.value=void 0)}}},rh=class{#e;sets;constructor(e){this.#e=e,this.sets=new m({fetch:async(e,t,n)=>this.#e.dataSets.call({limit:n,...t===void 0?{}:{cursor:t},...e.text===``?{}:{text:e.text},...e.system===void 0?{}:{system:e.system}}),key:e=>e.type,failure:`Couldn't load the stored data.`,limit:50},{text:``,system:void 0})}async rowActions(e){return this.#e.rowActions.call(e)}async findRecords(e){return this.#e.records.call(e)}async readFn(e,t){return this.#e.readFn.call({fn:e,args:{...t}})}async exportCsv(e){let t=await this.#e.exportCsv.call(e);return new Response(t).blob()}records(){return new ih(this.#e)}},ih=class{#e;table=new v;shown=B(void 0);#t;record=new v;versions=B([]);versionsNext=z(void 0);versionsLoading=z(!1);versionsProblem=z(``);saving=new p;constructor(e){this.#e=e}async show(e){let t=this.#t!==void 0&&JSON.stringify(this.#t)===JSON.stringify(e)&&this.table.value.value!==void 0;this.#t!==void 0&&this.#t.type!==e.type&&(this.table.reset(),this.shown.value=void 0),this.#t=e,await this.table.load(()=>this.#e.recordTable.call(e),`Couldn't load these records.`,t),this.#t===e&&this.table.problem.value===``&&(this.shown.value=e)}async open(e,t){let n=this.record.value.value?.id===t;await Promise.all([this.record.load(async()=>(await this.#e.record.call({type:e,id:t})).record,`Couldn't load this record.`,n),this.#r(e,t,!0)])}close(){this.record.reset(),this.versions.value=[],this.versionsNext.value=void 0,this.versionsProblem.value=``}async moreVersions(){let e=this.record.value.value;e!==void 0&&this.versionsNext.value!==void 0&&await this.#r(e.type,e.id,!1)}async save(e,t,n,r){let i=await this.saving.run(()=>this.#e.saveRecord.call({type:e,value:t,...n===void 0?{}:{id:n},...r===void 0?{}:{expect:r}}),`Couldn't save this record.`);if(i.ok)return this.record.value.value?.id===i.value.id&&(this.record.set(i.value),this.#r(e,i.value.id,!0)),await this.#n(),i.value}async window(e){return this.#e.recordTable.call(e)}follow(e){this.record.value.value?.id===e.id&&(this.record.set(e),this.#r(e.type,e.id,!0))}async remove(e,t){let n=await this.saving.run(()=>this.#e.removeRecord.call({type:e,id:t}),`Couldn't remove this record.`);return!n.ok||!n.value.removed?!1:(this.close(),await this.#n(),!0)}async#n(){let e=this.#t;e!==void 0&&await this.table.load(()=>this.#e.recordTable.call(e),`Couldn't load these records.`,!0)}async#r(e,t,n){this.versionsLoading.value=!0,this.versionsProblem.value=``;try{let r=n?void 0:this.versionsNext.value,i=await this.#e.recordVersions.call({type:e,id:t,limit:20,...r===void 0?{}:{cursor:r}});this.versions.value=n?i.items:[...this.versions.value,...i.items],this.versionsNext.value=i.cursor}catch{this.versionsProblem.value=`Couldn't load this record's history.`}finally{this.versionsLoading.value=!1}}},ah=e=>e in kt;function oh(e){return e!==void 0&&ah(e)?e:`layers`}function sh(e){return e.filter(e=>e.nav===`main`).map(e=>({system:e.system,segment:e.segment,title:e.title,icon:oh(e.icon)}))}function ch(e){let t=Cn.safeParse(e.system),n=e.page;if(!t.success||typeof n!=`string`)return;let r=e.path,i=Array.isArray(r)?r:typeof r==`string`&&r!==``?[r]:[];return{system:t.data,page:n,path:i}}function lh(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{let n=Array.isArray(t)?t[0]:t;return typeof n==`string`?[[e,n]]:[]}))}function uh(e){let t=t=>{let n=e.here(),r=t.page??n.page,i=t.path??(r===n.page?n.path:[]);return S.systemPage(n.system,r,i,t.query??{})},n=(t,n)=>{let r=e.here();e.navigate(S.systemPage(r.system,r.page,r.path,{...r.query,...t}),!n)};return{get user(){return e.user()},hub:e.hub,query:{get values(){return e.here().query},get:t=>e.here().query[t],set:(e,t)=>{n(e,t?.push===!0)},bind:(t,r=``)=>({get value(){return e.here().query[t]??r},set value(e){n({[t]:e===r?void 0:e},!1)}})},href:n=>e.resolve(t(n)),chatHref:t=>e.chatHref(t),goChat:t=>{e.goChat(t)},runHref:t=>e.runHref(t),goRun:t=>{e.goRun(t)},go:(n,r)=>{e.navigate(t(n),r?.replace===!0)},openChat:t=>e.openChat(t),components:e.components,runs:t=>e.runs(t),inbox:e.inbox,notify:e.notify,format:e.format,live:(t,n)=>{e.live(t,n)}}}function dh(e,t){return t.some(t=>t.system===e.system)?{title:`No such page`,body:`${e.system} has no page called “${e.page}”. It may have been renamed in a newer version.`}:{title:`${e.system} isn’t installed`,body:`This page belongs to the ${e.system} system, which isn’t installed and live here, or you can’t use it. The link will work again once it is.`}}var fh=class{#e;#t;list=new v;nav=M(()=>sh(this.list.value.value??[]));constructor(e){this.#e=e}get hub(){return this.#e.hub}async load(e=!1){await this.list.load(()=>this.#e.api.systemPages.call({}),`Couldn’t load the systems’ pages.`,e)}async refresh(){this.#e.api.systemPages.invalidate(),await this.load(!0)}start(){this.#t===void 0&&(this.#t=this.#e.events(e=>{this.#n(e)}))}stop(){this.#t?.(),this.#t=void 0}clear(){this.stop(),this.list.reset()}page(e,t){return this.list.value.value?.find(n=>n.system===e&&n.segment===t)}#n(e){e.type===`capabilities`&&this.refresh()}},ph=`harness.theme`,mh=un([`system`,`light`,`dark`]),hh=`(prefers-color-scheme: dark)`,gh=class{choice;#e=z(!1);#t;constructor(e){this.choice=Br(e.store,ph,mh,`system`);let t=e.media(hh);this.#e.value=t.matches;let n=e=>{this.#e.value=e.matches};t.addEventListener(`change`,n);let r=T(this.theme,t=>{e.root.dataset.theme=t},{immediate:!0,flush:`sync`});this.#t=()=>{t.removeEventListener(`change`,n),r()}}theme=M(()=>this.choice.value===`system`?this.#e.value?`dark`:`light`:this.choice.value);dispose(){this.#t()}},_h={duration:5e3,max:4},vh=class{#e;#t=new Map;#n=B([]);#r=1;constructor(e=_h){this.#e=e}get items(){return this.#n.value}push(e){let t=this.#r++,n={view:{id:t,tone:e.tone??`neutral`,title:e.title,...e.body===void 0?{}:{body:e.body},...e.action===void 0?{}:{action:e.action.label}},run:e.action?.run,duration:e.duration??this.#e.duration,timer:void 0};for(this.#t.set(t,n),this.#i(n);this.#t.size>this.#e.max;){let e=this.#t.keys().next();if(e.done===!0)break;this.dismiss(e.value)}return this.#a(),t}ok(e,t){return this.push({tone:`ok`,title:e,...t===void 0?{}:{body:t}})}error(e,t){return this.push({tone:`danger`,title:e,...t===void 0?{}:{body:t}})}dismiss(e){let t=this.#t.get(e);t!==void 0&&(clearTimeout(t.timer),this.#t.delete(e),this.#a())}act(e){let t=this.#t.get(e);this.dismiss(e),t?.run?.()}hold(e){let t=this.#t.get(e);t!==void 0&&(clearTimeout(t.timer),t.timer=void 0)}release(e){let t=this.#t.get(e);t!==void 0&&t.timer===void 0&&this.#i(t)}#i(e){e.duration>0&&(e.timer=setTimeout(()=>{this.dismiss(e.view.id)},e.duration))}#a(){this.#n.value=Array.from(this.#t.values(),e=>e.view)}};function yh(e){return e.connection.onReconnect(()=>{e.session.signedIn.value&&(e.inbox.refresh(),e.chat.refresh(),e.pages.refresh(),e.admin.systems.list.value.value!==void 0&&e.admin.systems.load(!0))})}function bh(e){let t=new em(e.localStorage,Date.now,Rr(e),$p(e.document)),{hub:n}=op({origin:e.location.origin,token:()=>t.accessToken.value,unauthorized:()=>o.recover()}),r=new Cp({send:xp(n),signedIn:()=>t.signedIn.value,page:()=>e.location.pathname});r.watch(e);let i=lp(n,e=>{r.traffic(e)}),a=lu(i,()=>t.user.value?.id),o=new Np(a.auth,t,Date.now,new Mp(e.navigator)),s=new Lp(a.connection),c=new he(a.notifications,a.userEvents),l=new np({api:a.chat,userEvents:a.userEvents,sessionEvents:a.sessionEvents,store:e.localStorage,sender:new Gl,clock:Date.now,client:()=>tp(),me:()=>t.user.value?.id,recorder:()=>Jf.available()?new Jf:void 0,speech:()=>Xf(e),renderers:{share:async()=>{(await fi(async()=>{let{shareChatModules:e}=await import(`./shared-LbaIHjbV.js`);return{shareChatModules:e}},__vite__mapDeps([0,1,2,3,4]))).shareChatModules()}}}),u=new Pl({api:a.admin,chat:a.chat,userEvents:a.userEvents,systemLogs:a.systemLogs,sender:new Gl,probe:new as((t,n)=>e.fetch(t,n)),data:a.data}),d=l.renderers.runtime;d.register(Id);let f=new _m({api:a.resources,events:a.resourceEvents,sender:new Gl,fetch:(t,n)=>e.fetch(t,n),systems:{viewers:e=>d.resourceViewers(e),client:e=>d.systemClient(e),version:l.renderers.version},prepare:()=>l.prepareRenderers()}),p=new fh({api:a.pages,events:a.userEvents,hub:i});return yh({session:t,connection:s,inbox:c,chat:l,admin:u,pages:p}),{session:t,identity:new Zm(a.identity,a.userEvents,e.localStorage),outsideImages:new eh(a.outsideImages),keeper:o,theme:new gh({store:e.localStorage,media:t=>e.matchMedia(t),root:e.document.documentElement}),layout:new zr(e.localStorage),toasts:new vh,inbox:c,connection:s,chat:l,admin:u,signInForm:()=>new Op(a.auth,t,e.localStorage),account:new Pp(a.auth),resources:f,context:new qm({api:a.context,events:a.contextEvents}),fns:new Jm(a.fns,a.userEvents),fnNotices:new Kt(a.fns),modelNames:new Ym(a.fns),graph:()=>new th(a.graph),runPage:()=>new nh(a.chat),data:new rh(a.data),pages:p,itemVersions:e=>a.data.itemVersions.call(e),logs:r,push:new Rp(a.notifications,new Hp(e,zp.built),()=>e.navigator.userAgent),install:new Gp(new qp(e)),https:new Up(a.https)}}var xh={name:`harness-scopes`,type:`light`,fg:`#000000`,bg:`#ffffff`,settings:[]},Sh=[[`comment`,`comment`],[`punctuation.definition.comment`,`comment`],[`string`,`string`],[`punctuation.definition.string`,`string`],[`constant.numeric`,`number`],[`constant.language`,`literal`],[`support.constant`,`literal`],[`constant.character`,`literal`],[`keyword.operator`,`plain`],[`keyword`,`keyword`],[`storage`,`keyword`]];function Ch(e){for(let t of[...e].reverse()){let e=Sh.find(([e])=>t===e||t.startsWith(`${e}.`));if(e!==void 0)return e[1]}return`plain`}function wh(e){let t=[],n=(e,n)=>{let r=t.at(-1);r?.kind===e?t[t.length-1]={kind:e,text:r.text+n}:n!==``&&t.push({kind:e,text:n})};return e.forEach((e,t)=>{t>0&&n(`plain`,`
3
+ `);for(let t of e)if(t.explanation===void 0)n(`plain`,t.content);else for(let e of t.explanation)n(Ch(e.scopes.map(e=>e.scopeName)),e.content)}),t}var Th={async core(){let[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([fi(()=>import(`./core-DdF778CY.js`),__vite__mapDeps([5,1])),fi(()=>import(`./engine-javascript-C30F4iNc.js`),[])]);return e({themes:[xh],langs:[],engine:t({forgiving:!0})})},async languages(){let{bundledLanguages:e,bundledLanguagesAlias:t}=await fi(async()=>{let{bundledLanguages:e,bundledLanguagesAlias:t}=await import(`./langs-CVIiVMBh.js`);return{bundledLanguages:e,bundledLanguagesAlias:t}},__vite__mapDeps([6,7]));return new Map([...Object.entries(t),...Object.entries(e)])}},Eh=class{#e;#t;#n;#r;#i=new Map;#a=new Set;constructor(e=Th,t=xt){this.#e=e,this.#t=t}tokens(e,t){let n=this.#r;if(n===void 0||!this.#a.has(t))return this.#t.tokens(e,t);try{return wh(n.codeToTokensBase(e,{lang:t,theme:xh.name??``,includeExplanation:`scopeName`}))}catch{return this.#t.tokens(e,t)}}prepare(e){if(this.#a.has(e))return Promise.resolve(!1);let t=this.#i.get(e);if(t!==void 0)return t;let n=this.#o(e).catch(()=>!1);return this.#i.set(e,n),n}knows(e){return this.#a.has(e)||this.#t.knows(e)}async#o(e){let t=(await this.#e.languages()).get(e);if(t===void 0)return!1;this.#n??=this.#e.core();let n=await this.#n;return await n.loadLanguage(t),this.#r=n,this.#a.add(e),!0}},Dh=/<svg\b[^>]*>/,Oh=/viewBox="\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)\s*"/,kh=/\s(?:width|height)="[^"]*"/g;function Ah(e){let t=Dh.exec(e)?.[0],n=t===void 0?void 0:Oh.exec(t);if(t===void 0||n==null)return e;let[,r=`0`,i=`0`]=n,a=t.replace(kh,``).replace(/^<svg/,`<svg width="${r}" height="${i}"`);return e.replace(t,a)}function jh(e,t,n){t.style.color=`var(${n})`,e.clearRect(0,0,1,1),e.fillStyle=getComputedStyle(t).color,e.fillRect(0,0,1,1);let[r=0,i=0,a=0,o=0]=e.getImageData(0,0,1,1).data;return o===0?void 0:`#${[r,i,a].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}var Mh=[`--bg`,`--surface-2`,`--border-strong`,`--text`,`--text-dim`,`--accent`],Nh=()=>{if(typeof document>`u`)return;let e=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0});if(e===null)return;let t=document.createElement(`span`);document.body.append(t);try{let[n,r,i,a,o,s]=Mh.map(n=>jh(e,t,n)),c=getComputedStyle(document.documentElement).getPropertyValue(`--font`).trim();return n===void 0||r===void 0||i===void 0||a===void 0||o===void 0||s===void 0||c===``?void 0:{font:c,background:n,surface:r,border:i,text:a,muted:o,accent:s}}finally{t.remove()}};function Ph(e,t){return{theme:`base`,fontFamily:e.font,themeVariables:{darkMode:t,fontFamily:e.font,fontSize:`14px`,background:e.background,primaryColor:e.surface,primaryBorderColor:e.border,primaryTextColor:e.text,secondaryColor:e.surface,secondaryBorderColor:e.border,secondaryTextColor:e.text,tertiaryColor:e.background,tertiaryBorderColor:e.border,tertiaryTextColor:e.text,mainBkg:e.surface,nodeBorder:e.border,nodeTextColor:e.text,lineColor:e.muted,textColor:e.text,clusterBkg:e.background,clusterBorder:e.border,edgeLabelBackground:e.background,titleColor:e.text,noteBkgColor:e.surface,noteBorderColor:e.accent,noteTextColor:e.text,actorBorder:e.border,actorBkg:e.surface}}}var Fh=async()=>(await fi(async()=>{let{default:e}=await import(`./mermaid.core-BNF3dRf5.js`);return{default:e}},__vite__mapDeps([8,9,10,11,12,13,14,15,16,1,7,17,18,19,20,21,22,23]))).default,Ih=class{languages=[`mermaid`];#e;#t;#n;#r=Promise.resolve();#i=0;constructor(e=Fh,t=Nh){this.#e=e,this.#t=t}render(e,t,n){let r=this.#r.then(()=>this.#a(e,n));return this.#r=r.catch(()=>void 0),r}async#a(e,t){this.#n??=this.#e();let n=await this.#n,r=this.#t();n.initialize({startOnLoad:!1,securityLevel:`strict`,...r===void 0?{theme:t?`dark`:`default`}:Ph(r,t)}),this.#i+=1;try{let{svg:t}=await n.render(`harness-diagram-${this.#i}`,e);return{ok:!0,value:Ah(t)}}catch(e){return{ok:!1,problem:e instanceof Error?e.message:String(e)}}}},Lh={light:`#f9fafb`,dark:`#0c0d10`};function Rh(e,t){let n=e instanceof Element?e.closest(`a[href]`):null;if(!(n instanceof HTMLAnchorElement)||n.target!==``||n.hasAttribute(`download`))return;let r=new URL(n.href,t);return(r.protocol===`http:`||r.protocol===`https:`)&&r.origin!==t?r.toString():void 0}function zh(e,t){let n=n=>{if(n.defaultPrevented||n.button!==0||!t())return;let r=Rh(n.target,e.location.origin);r!==void 0&&(n.preventDefault(),e.open(r,`_blank`,`noopener,noreferrer`))};return e.document.addEventListener(`click`,n),()=>{e.document.removeEventListener(`click`,n)}}function Bh(e,t){return T(t,t=>{for(let t of e.querySelectorAll(`meta[name="theme-color"]`))t.remove();let n=e.createElement(`meta`);n.name=`theme-color`,n.content=Lh[t],e.head.append(n)},{immediate:!0})}var Vh=bh(window),Hh=e(Zo);Hh.config.errorHandler=e=>{Vh.logs.error(e,`vue`),console.error(e)},Hh.provide($t,Vh).provide(Ct,new Eh).provide(gt,new Ih).provide(dt,new ft).use(Qo(Vh.session,ee())).mount(`#app`),Yp(window,zp.built),zh(window,()=>Vh.install.state.value===`installed`),Bh(document,Vh.theme.theme);export{Jc as $,ta as $t,Wf as A,ac as At,Zd as B,Vs as Bt,Dm as C,Ac as Ct,Im as D,Qs as Dt,Nm as E,hc as Et,Qd as F,Gs as Ft,_l as G,Bo as Gt,Bd as H,Bs as Ht,Rd as I,Hs as It,yl as J,Ga as Jt,xl as K,bo as Kt,Ud as L,Ks as Lt,Sf as M,Ps as Mt,Vd as N,Ms as Nt,Sm as O,ec as Ot,zd as P,Ns as Pt,il as Q,aa as Qt,Yd as R,zs as Rt,Lm as S,Oc as St,wm as T,vc as Tt,Ed as U,Os as Ut,qd as V,qs as Vt,mu as W,Es as Wt,dl as X,$i as Xt,Fc as Y,za as Yt,Kc as Z,Qi as Zt,Vm as _,Dc as _t,Qm as a,Ci as an,ol as at,Mm as b,Tc as bt,zm as c,Uc as ct,Fm as d,Bc as dt,ia as en,ul as et,Pm as f,tl as ft,Um as g,X as gt,km as h,xc as ht,lh as i,wi as in,Wc as it,Cf as j,lc as jt,Wp as k,rc as kt,vm as l,Hc as lt,Am as m,pl as mt,ch as n,Yi as nn,Rc as nt,$m as o,ll as ot,ym as p,el as pt,vl as q,lo as qt,uh as r,Ti as rn,Gc as rt,bm as s,Yc as st,dh as t,Xi as tn,zc as tt,Rm as u,Vc as ut,xm as v,Sc as vt,jm as w,wc as wt,Bm as x,kc as xt,Hm as y,Cc as yt,Jd as z,Ls as zt};
4
+ //# sourceMappingURL=index-6ScWTFy2.js.map