fnloom 0.2.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 (618) hide show
  1. package/README.md +102 -5
  2. package/package.json +12 -11
  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/install.ts +103 -7
  8. package/packages/cli/src/commands/manage.ts +7 -5
  9. package/packages/cli/src/commands/store.ts +172 -0
  10. package/packages/cli/src/hub.ts +26 -7
  11. package/packages/cli/src/io.ts +1 -0
  12. package/packages/cli/src/testing.ts +2 -1
  13. package/packages/core/package.json +4 -4
  14. package/packages/core/src/context-files.ts +3 -1
  15. package/packages/core/src/context-graph.ts +4 -0
  16. package/packages/core/src/context-plan.ts +451 -0
  17. package/packages/core/src/context-questions.ts +305 -0
  18. package/packages/core/src/fn-facts.ts +32 -4
  19. package/packages/core/src/identity.ts +1 -1
  20. package/packages/core/src/index.ts +4 -1
  21. package/packages/core/src/link.ts +70 -0
  22. package/packages/core/src/manifest.ts +20 -1
  23. package/packages/core/src/model-calls.ts +11 -2
  24. package/packages/core/src/package.ts +10 -0
  25. package/packages/core/src/query.ts +3 -2
  26. package/packages/core/src/records/content.ts +10 -2
  27. package/packages/core/src/records/runs.ts +12 -0
  28. package/packages/core/src/records/systems.ts +87 -5
  29. package/packages/core/src/run.ts +5 -0
  30. package/packages/core/src/stores.ts +473 -0
  31. package/packages/core/src/suggestions.ts +3 -0
  32. package/packages/core/src/system-pages.ts +14 -1
  33. package/packages/core/src/web.ts +114 -9
  34. package/packages/hub/package.json +13 -12
  35. package/packages/hub/src/access/hits.ts +1 -1
  36. package/packages/hub/src/api/admin-ops.ts +36 -4
  37. package/packages/hub/src/api/auth.ts +8 -4
  38. package/packages/hub/src/api/person-ops.ts +6 -0
  39. package/packages/hub/src/api/store-ops.ts +54 -0
  40. package/packages/hub/src/api/testing/rig.ts +2 -2
  41. package/packages/hub/src/api/tls.ts +2 -2
  42. package/packages/hub/src/api/web/build5.ts +2 -1
  43. package/packages/hub/src/api/web/context-plans.ts +25 -0
  44. package/packages/hub/src/api/web/context-review.ts +43 -0
  45. package/packages/hub/src/api/web/index.ts +4 -0
  46. package/packages/hub/src/api/web/pages.ts +14 -1
  47. package/packages/hub/src/api/web/review.ts +16 -0
  48. package/packages/hub/src/api/web/systems.ts +14 -2
  49. package/packages/hub/src/boot/admin-fns.ts +8 -0
  50. package/packages/hub/src/boot/admin-secrets.ts +10 -4
  51. package/packages/hub/src/boot/env.ts +6 -1
  52. package/packages/hub/src/boot/hub-fns.ts +3 -3
  53. package/packages/hub/src/boot/hub-groups.ts +2 -2
  54. package/packages/hub/src/boot/identity.ts +1 -1
  55. package/packages/hub/src/boot/index.ts +9 -0
  56. package/packages/hub/src/boot/modules.ts +12 -3
  57. package/packages/hub/src/boot/person-fns.ts +5 -0
  58. package/packages/hub/src/boot/plan-fns.ts +39 -0
  59. package/packages/hub/src/boot/start.ts +2 -1
  60. package/packages/hub/src/catalog/catalog.ts +44 -14
  61. package/packages/hub/src/catalog/index.ts +6 -2
  62. package/packages/hub/src/chat/testing.ts +2 -2
  63. package/packages/hub/src/contextor/brought.ts +5 -3
  64. package/packages/hub/src/contextor/testing.ts +4 -4
  65. package/packages/hub/src/execution/create.ts +2 -0
  66. package/packages/hub/src/execution/env.ts +2 -0
  67. package/packages/hub/src/execution/errors.ts +12 -0
  68. package/packages/hub/src/execution/executors.ts +14 -2
  69. package/packages/hub/src/execution/index.ts +8 -0
  70. package/packages/hub/src/execution/link-handlers.ts +16 -4
  71. package/packages/hub/src/execution/runs.ts +212 -11
  72. package/packages/hub/src/execution/testing.ts +2 -1
  73. package/packages/hub/src/fns/search.ts +23 -4
  74. package/packages/hub/src/graph/graph.ts +2 -2
  75. package/packages/hub/src/index/index.ts +9 -2
  76. package/packages/hub/src/index/indexer.ts +67 -16
  77. package/packages/hub/src/index/search.ts +1 -0
  78. package/packages/hub/src/index/suggester.ts +2 -2
  79. package/packages/hub/src/link/build.ts +47 -10
  80. package/packages/hub/src/link/connections.ts +41 -3
  81. package/packages/hub/src/link/describer.ts +19 -2
  82. package/packages/hub/src/link/env.ts +10 -0
  83. package/packages/hub/src/link/handlers.ts +6 -0
  84. package/packages/hub/src/link/index.ts +16 -4
  85. package/packages/hub/src/link/lifecycle.ts +11 -4
  86. package/packages/hub/src/link/packages.ts +17 -4
  87. package/packages/hub/src/link/pairing.ts +2 -2
  88. package/packages/hub/src/link/process.ts +10 -4
  89. package/packages/hub/src/link/rig.ts +6 -2
  90. package/packages/hub/src/link/status.ts +14 -0
  91. package/packages/hub/src/link/supervisor.ts +17 -1
  92. package/packages/hub/src/link/systems.ts +16 -5
  93. package/packages/hub/src/models/roles.ts +74 -7
  94. package/packages/hub/src/query/columns.ts +4 -1
  95. package/packages/hub/src/query/contexts.ts +10 -3
  96. package/packages/hub/src/questions/apply.ts +163 -0
  97. package/packages/hub/src/questions/carry.ts +30 -0
  98. package/packages/hub/src/questions/duplicates.ts +181 -0
  99. package/packages/hub/src/questions/index.ts +112 -0
  100. package/packages/hub/src/questions/metadata.ts +142 -0
  101. package/packages/hub/src/questions/pending.ts +64 -0
  102. package/packages/hub/src/questions/plan-match.ts +79 -0
  103. package/packages/hub/src/questions/plan-prompts.ts +110 -0
  104. package/packages/hub/src/questions/planner.ts +382 -0
  105. package/packages/hub/src/questions/plans.ts +353 -0
  106. package/packages/hub/src/questions/review.ts +253 -0
  107. package/packages/hub/src/questions/setting.ts +50 -0
  108. package/packages/hub/src/questions/testing.ts +131 -0
  109. package/packages/hub/src/questions/worker.ts +182 -0
  110. package/packages/hub/src/resources/context.ts +58 -20
  111. package/packages/hub/src/resources/create.ts +16 -4
  112. package/packages/hub/src/resources/env.ts +4 -0
  113. package/packages/hub/src/resources/fns.ts +6 -2
  114. package/packages/hub/src/resources/index.ts +8 -2
  115. package/packages/hub/src/resources/testing.ts +18 -2
  116. package/packages/hub/src/store/codec.ts +23 -5
  117. package/packages/hub/src/store/context-status.ts +56 -0
  118. package/packages/hub/src/store/derived.ts +53 -0
  119. package/packages/hub/src/store/hybrid.ts +33 -6
  120. package/packages/hub/src/store/lists.ts +2 -1
  121. package/packages/hub/src/store/migrate-fn-names.ts +5 -2
  122. package/packages/hub/src/store/rows.ts +8 -1
  123. package/packages/hub/src/store/schema.ts +2 -1
  124. package/packages/hub/src/store/sqlite.ts +2 -1
  125. package/packages/hub/src/stores/backups.ts +163 -0
  126. package/packages/hub/src/stores/drivers.ts +100 -0
  127. package/packages/hub/src/stores/guard.ts +116 -0
  128. package/packages/hub/src/stores/host.ts +459 -0
  129. package/packages/hub/src/stores/moves.ts +380 -0
  130. package/packages/hub/src/stores/plugin.ts +42 -0
  131. package/packages/hub/src/stores/service.ts +340 -0
  132. package/packages/hub/src/stores/testing.ts +149 -0
  133. package/packages/sdk/AUTHORING.md +1813 -218
  134. package/packages/sdk/package.json +12 -8
  135. package/packages/sdk/src/build.ts +3 -0
  136. package/packages/sdk/src/client.ts +22 -0
  137. package/packages/sdk/src/ctx.ts +51 -17
  138. package/packages/sdk/src/declare.ts +36 -12
  139. package/packages/sdk/src/hub.ts +222 -10
  140. package/packages/sdk/src/impl.ts +3 -3
  141. package/packages/sdk/src/index.ts +6 -3
  142. package/packages/sdk/src/manifest.ts +5 -0
  143. package/packages/sdk/src/providers.ts +2 -2
  144. package/packages/sdk/src/server/asks.ts +12 -1
  145. package/packages/sdk/src/server/env.ts +13 -1
  146. package/packages/sdk/src/server/host.ts +81 -10
  147. package/packages/sdk/src/server/index.ts +21 -2
  148. package/packages/sdk/src/server/package.ts +11 -2
  149. package/packages/sdk/src/server/run.ts +6 -1
  150. package/packages/sdk/src/server/runtime.ts +78 -22
  151. package/packages/sdk/src/server/start-gate.ts +174 -0
  152. package/packages/sdk/src/server/store/checksum.ts +162 -0
  153. package/packages/sdk/src/server/store/engines.ts +400 -0
  154. package/packages/sdk/src/server/store/extend.ts +25 -0
  155. package/packages/sdk/src/server/store/keeper.ts +392 -0
  156. package/packages/sdk/src/server/store/link-driver.ts +142 -0
  157. package/packages/sdk/src/server/store/measure.ts +45 -0
  158. package/packages/sdk/src/server/store/migrations.ts +238 -0
  159. package/packages/sdk/src/server/store/move.ts +488 -0
  160. package/packages/sdk/src/server/store/portable.ts +288 -0
  161. package/packages/sdk/src/server/store/stable.ts +146 -0
  162. package/packages/sdk/src/server/store/tables.ts +28 -0
  163. package/packages/sdk/src/server/store/vectors.ts +185 -0
  164. package/packages/sdk/src/server/store/work-checks.ts +288 -0
  165. package/packages/sdk/src/server/store/work.ts +369 -0
  166. package/packages/sdk/src/server/table.ts +3 -1
  167. package/packages/sdk/src/server/testing.ts +116 -3
  168. package/packages/sdk/src/store.ts +91 -0
  169. package/packages/sdk/src/system.ts +58 -30
  170. package/packages/sdk/src/testing/hub.ts +18 -5
  171. package/packages/web/dist/assets/{ActorSettingsView-BuMYRDqv.js → ActorSettingsView-v2k7v454.js} +2 -2
  172. package/packages/web/dist/assets/{AdminLayout-sLjVTrmV.js → AdminLayout-B6Jrc_4W.js} +2 -2
  173. package/packages/web/dist/assets/{ApiServiceForm-BrMTU-7u.js → ApiServiceForm-CuuQgOJc.js} +2 -2
  174. package/packages/web/dist/assets/{ApiServiceView-BMF2zD6Q.js → ApiServiceView-7bTHSO_Z.js} +2 -2
  175. package/packages/web/dist/assets/{ApiServicesView-bjLAWO_j.js → ApiServicesView-BXi24n49.js} +2 -2
  176. package/packages/web/dist/assets/{AppPage-DSzDKCFz.js → AppPage-CFmKZS8G.js} +2 -2
  177. package/packages/web/dist/assets/{AutoPairPicker-nV38ALjl.js → AutoPairPicker-C61gihmh.js} +2 -2
  178. package/packages/web/dist/assets/{BrowserFrame-Bic7U7jN.js → BrowserFrame-Sq9EmQRT.js} +2 -2
  179. package/packages/web/dist/assets/{ChartVisual-DWw7WsfN.js → ChartVisual-C4mgw4wh.js} +4 -4
  180. package/packages/web/dist/assets/ChatPage-CAhHE03Z.js +4 -0
  181. package/packages/web/dist/assets/{CodeViewer-xHS3Xah9.js → CodeViewer-tUNXZB77.js} +2 -2
  182. package/packages/web/dist/assets/{ConfigWithCustom-DreTUdf0.js → ConfigWithCustom-D_-rY66L.js} +3 -3
  183. package/packages/web/dist/assets/{ConfirmDialog-DjQUzNqk.js → ConfirmDialog-Dd3E4sJt.js} +2 -2
  184. package/packages/web/dist/assets/{ConnectPage-CfRDrXvJ.js → ConnectPage-CX9acyQH.js} +2 -2
  185. package/packages/web/dist/assets/ContextItemPage-Cv4G0k_o.css +1 -0
  186. package/packages/web/dist/assets/ContextItemPage-rUI3-T_L.js +2 -0
  187. package/packages/web/dist/assets/ContextPage-C8u0UnYl.css +1 -0
  188. package/packages/web/dist/assets/ContextPage-CtefzyKg.js +3 -0
  189. package/packages/web/dist/assets/ContextRow-Chx99Xac.css +1 -0
  190. package/packages/web/dist/assets/ContextRow-DrtPumZ5.js +2 -0
  191. package/packages/web/dist/assets/{DataPage-wSIoGcb5.js → DataPage-DDSsxHro.js} +2 -2
  192. package/packages/web/dist/assets/DataTypePage-BW9fWaz8.js +2 -0
  193. package/packages/web/dist/assets/{DesignPage-DidMUX8m.js → DesignPage-6e0XbOFC.js} +2 -2
  194. package/packages/web/dist/assets/{ExplorePage-MUyVydVB.js → ExplorePage-B7ND0W0l.js} +2 -2
  195. package/packages/web/dist/assets/{FnList-CjQRwYaT.js → FnList-Bx6H-kux.js} +2 -2
  196. package/packages/web/dist/assets/{FnPill-BshAvm2I.js → FnPill-Cp3KuLmP.js} +2 -2
  197. package/packages/web/dist/assets/FnView-C0XZdnsS.js +2 -0
  198. package/packages/web/dist/assets/{FnsView-CeqIoaBT.js → FnsView-GTH3p7a0.js} +2 -2
  199. package/packages/web/dist/assets/{GinExprView-DYVUwZrd.js → GinExprView-DGxns6lH.js} +2 -2
  200. package/packages/web/dist/assets/{GinForm-D3mwMRTQ.js → GinForm-BDBUzuDP.js} +2 -2
  201. package/packages/web/dist/assets/{GinTypeView-C0YifSmE.js → GinTypeView-CUsymbVf.js} +2 -2
  202. package/packages/web/dist/assets/{GinValueView-HfEPq9le.js → GinValueView-jsKIfiEA.js} +2 -2
  203. package/packages/web/dist/assets/{GraphPage-ySnuA4Hp.js → GraphPage-BCcPPsHu.js} +2 -2
  204. package/packages/web/dist/assets/{GraphPanel-Cy5-KGo1.js → GraphPanel-9tztGHmu.js} +2 -2
  205. package/packages/web/dist/assets/{HubPicker-C_vA752L.js → HubPicker-EoOErgmk.js} +2 -2
  206. package/packages/web/dist/assets/{InboxApprovals-DcPCCmZ5.js → InboxApprovals-Dkq7DFp_.js} +2 -2
  207. package/packages/web/dist/assets/{InboxPage-C2DT2nuF.js → InboxPage-CHhslePq.js} +2 -2
  208. package/packages/web/dist/assets/{InjectedList-CJsEFEbz.js → InjectedList-CSWqRiON.js} +2 -2
  209. package/packages/web/dist/assets/InstallDialog-D-VwfZYF.js +2 -0
  210. package/packages/web/dist/assets/{InstallDialog-yWLZK_zN.css → InstallDialog-K-j0sdHm.css} +1 -1
  211. package/packages/web/dist/assets/InstanceTypes-CwVSAULg.css +1 -0
  212. package/packages/web/dist/assets/InstanceTypes-D3rAEiE7.js +2 -0
  213. package/packages/web/dist/assets/InstanceView-DoH8C-1j.js +2 -0
  214. package/packages/web/dist/assets/InstanceView-_9uE70tS.css +1 -0
  215. package/packages/web/dist/assets/{ItemHistory-CUGa8b6s.js → ItemHistory-NQAP69ma.js} +2 -2
  216. package/packages/web/dist/assets/LimitsView-DY2C9nYS.js +2 -0
  217. package/packages/web/dist/assets/ListSearch-BunVrDO0.js +2 -0
  218. package/packages/web/dist/assets/{LlmCallDetails-2yQftCqd.js → LlmCallDetails-BoVNDTVs.js} +2 -2
  219. package/packages/web/dist/assets/{LlmCallsView-DOHX3r0K.js → LlmCallsView-BGpV92RC.js} +2 -2
  220. package/packages/web/dist/assets/{LoadState-DeXfLvYv.js → LoadState-h-K9bTYc.js} +2 -2
  221. package/packages/web/dist/assets/{McpDialog-CA_0WKWF.js → McpDialog-DhOCk6_E.js} +2 -2
  222. package/packages/web/dist/assets/{McpServerForm-CAG8Wp2N.js → McpServerForm-Cor3fI7s.js} +2 -2
  223. package/packages/web/dist/assets/McpServerView-ewXRPEmZ.js +2 -0
  224. package/packages/web/dist/assets/McpServersView-Dd0xmfws.js +2 -0
  225. package/packages/web/dist/assets/{McpView-CC2oNOMa.js → McpView-GPXdCMne.js} +2 -2
  226. package/packages/web/dist/assets/{McpsView-CwJvyyxV.js → McpsView-DJIR2JX5.js} +2 -2
  227. package/packages/web/dist/assets/{MemoryDialog-Dbvh5uLq.js → MemoryDialog-BTeIHQyA.js} +2 -2
  228. package/packages/web/dist/assets/{ModelCallsView-RvnW3EBP.js → ModelCallsView-DMcnwF2S.js} +2 -2
  229. package/packages/web/dist/assets/{ModelPicker-DcjwQFHC.js → ModelPicker-CgkMFxSO.js} +2 -2
  230. package/packages/web/dist/assets/ModelsView-cMHygeiK.js +2 -0
  231. package/packages/web/dist/assets/{NotFoundPage-CeSwzTV-.js → NotFoundPage-Tk92K7HN.js} +2 -2
  232. package/packages/web/dist/assets/PairPage-D0BK8CCw.js +2 -0
  233. package/packages/web/dist/assets/PairPage-D_aPS1Ot.css +1 -0
  234. package/packages/web/dist/assets/{PanelHost-BkrFAnPa.js → PanelHost-C-gKrxAk.js} +2 -2
  235. package/packages/web/dist/assets/{PeopleView-D1QGPYp7.js → PeopleView-DRfeNWK5.js} +2 -2
  236. package/packages/web/dist/assets/PoliciesView-BRi-QAuo.js +2 -0
  237. package/packages/web/dist/assets/{RefusalList-DQoyUoPG.js → RefusalList-DVO0bmeB.js} +2 -2
  238. package/packages/web/dist/assets/{RemoteAuthFields-nxGWfmhf.js → RemoteAuthFields-CgiufuqQ.js} +2 -2
  239. package/packages/web/dist/assets/{ResourceViewer-Po24y4pj.js → ResourceViewer-Do0chYxU.js} +2 -2
  240. package/packages/web/dist/assets/ResourcesPage-BBx2u2mw.js +2 -0
  241. package/packages/web/dist/assets/{ResultGrid-uoq4yUYj.js → ResultGrid-Bj-0I5HY.js} +2 -2
  242. package/packages/web/dist/assets/{ReviewSummaryStrip-k3HevESg.js → ReviewSummaryStrip-DO3p64Qj.js} +2 -2
  243. package/packages/web/dist/assets/ReviewView-DZF9E1hb.js +3 -0
  244. package/packages/web/dist/assets/{RuleRow-CoXDA-SH.js → RuleRow-DX9v4iGP.js} +2 -2
  245. package/packages/web/dist/assets/{RunCard-CBSGdwdQ.js → RunCard-BnrtK2Yp.js} +2 -2
  246. package/packages/web/dist/assets/{RunDetails-CGhQQ6OI.js → RunDetails-DjR206q6.js} +2 -2
  247. package/packages/web/dist/assets/{RunDot-Ch_45985.js → RunDot-lHRICdM5.js} +2 -2
  248. package/packages/web/dist/assets/{RunPage-C_t20pB7.js → RunPage-CbAQ_WPR.js} +2 -2
  249. package/packages/web/dist/assets/{RunProgress-VrZUHUEC.js → RunProgress-C3-B4tQf.js} +2 -2
  250. package/packages/web/dist/assets/RunsView-DMkPmkqX.js +2 -0
  251. package/packages/web/dist/assets/ServiceRows-4WythFpF.js +2 -0
  252. package/packages/web/dist/assets/{ServiceRows-6BU4-MeL.css → ServiceRows-HPQ0pN6b.css} +1 -1
  253. package/packages/web/dist/assets/SettingsPage-BN4oSzoL.js +3 -0
  254. package/packages/web/dist/assets/{SignInPage-DrXZ1sG2.js → SignInPage-ByqGEZfj.js} +2 -2
  255. package/packages/web/dist/assets/{StatusBadge-Dpb9uG5e.js → StatusBadge-CXne0sRZ.js} +2 -2
  256. package/packages/web/dist/assets/StorePlacementStep-B6SwTmdM.js +2 -0
  257. package/packages/web/dist/assets/StorePlacementStep-D_G4e3ue.css +1 -0
  258. package/packages/web/dist/assets/{SystemConfig-72qKRkUk.js → SystemConfig-vQDL_eUl.js} +2 -2
  259. package/packages/web/dist/assets/{SystemPageHost-DLNg2FYK.js → SystemPageHost-DrMrEPyh.js} +2 -2
  260. package/packages/web/dist/assets/SystemView-Be6TBM4j.js +2 -0
  261. package/packages/web/dist/assets/{SystemView-C8ScHUe2.css → SystemView-_9q6eDfV.css} +1 -1
  262. package/packages/web/dist/assets/{SystemsView-B6HEL9VS.css → SystemsView-CWKnupLW.css} +1 -1
  263. package/packages/web/dist/assets/SystemsView-DZtT3laz.js +2 -0
  264. package/packages/web/dist/assets/{TableViewer-BQ7bYLOP.js → TableViewer-Boxx86f5.js} +3 -3
  265. package/packages/web/dist/assets/{ThemePicker-C2nJ21Vd.js → ThemePicker-CIg_oRQX.js} +2 -2
  266. package/packages/web/dist/assets/{TurnTree-CORdfTHj.js → TurnTree-Ecm0yA5g.js} +2 -2
  267. package/packages/web/dist/assets/UserMessage-BlnqZDVU.js +9 -0
  268. package/packages/web/dist/assets/{ValueVisual-aXEUaQ5Y.js → ValueVisual-C-MWpp7c.js} +2 -2
  269. package/packages/web/dist/assets/WidgetView-DX4ejNb6.js +3 -0
  270. package/packages/web/dist/assets/actor-names-OdvpVZeb.js +4 -0
  271. package/packages/web/dist/assets/{fn-modal-DqcxUhOQ.js → fn-modal-B98MR7JN.js} +2 -2
  272. package/packages/web/dist/assets/{fn-notices-BYaH6IoA.js → fn-notices-CfTa1E8y.js} +2 -2
  273. package/packages/web/dist/assets/{formats-DI__ADVG.js → formats-JwoKfXIq.js} +2 -2
  274. package/packages/web/dist/assets/index-6ScWTFy2.js +4 -0
  275. package/packages/web/dist/assets/{index-CSisx5mi.css → index-CEslGcrX.css} +1 -1
  276. package/packages/web/dist/assets/{labels-BhJpmLWA.js → labels-BFbk11BE.js} +2 -2
  277. package/packages/web/dist/assets/{layout-DQKldU13.js → layout-D1gf481r.js} +2 -2
  278. package/packages/web/dist/assets/{metrics-Cio5ykX6.js → metrics-CBPX3W5Y.js} +2 -2
  279. package/packages/web/dist/assets/{problems-BZY0Dwif.js → problems-t1E_ovSz.js} +2 -2
  280. package/packages/web/dist/assets/{push-payload-D5efGCzd.js → push-payload-BeU1ADYt.js} +64 -64
  281. package/packages/web/dist/assets/{record-edits-CveFEsal.js → record-edits-Bfsi4lU3.js} +2 -2
  282. package/packages/web/dist/assets/{remote-config-BkaarDf3.js → remote-config-BNQhSDzB.js} +2 -2
  283. package/packages/web/dist/assets/{review-CGUGvRV9.js → review-fP-l9D6H.js} +3 -3
  284. package/packages/web/dist/assets/routes-DV4IJpwe.js +4 -0
  285. package/packages/web/dist/assets/runs-CveC2kKo.js +2 -0
  286. package/packages/web/dist/assets/{shared-DTpYDMc_.js → shared-LbaIHjbV.js} +2 -2
  287. package/packages/web/dist/assets/{size-BwnshyOe.js → size-Bh__w5aI.js} +2 -2
  288. package/packages/web/dist/assets/{sources-Bm-TrxhL.js → sources-VPrtgLIi.js} +2 -2
  289. package/packages/web/dist/assets/src-CT3TeFaM.js +43 -0
  290. package/packages/web/dist/assets/state-xfQqaQPX.js +2 -0
  291. package/packages/web/dist/assets/{systems-DIp94AET.js → systems-BqE3WTSF.js} +2 -2
  292. package/packages/web/dist/assets/ui-BzgWquIU.js +17 -0
  293. package/packages/web/dist/assets/{ui-C7ZH_6oC.css → ui-DycHjPTZ.css} +1 -1
  294. package/packages/web/dist/assets/{url-BIg5IhGs.js → url-DKGcECT1.js} +2 -2
  295. package/packages/web/dist/assets/{widget-host-BCf6Tlt5.js → widget-host-B87MTaTn.js} +2 -2
  296. package/packages/web/dist/assets/{widgets-CrbkovMT.js → widgets-BBCuSS6E.js} +2 -2
  297. package/packages/web/dist/index.html +44 -44
  298. package/packages/web/dist/sw.js +1 -1
  299. package/packages/web/package.json +2 -2
  300. package/premade/claude.zip +0 -0
  301. package/premade/database.zip +0 -0
  302. package/premade/web.zip +0 -0
  303. package/scripts/run-stack.ts +3 -2
  304. package/scripts/stack.ts +73 -16
  305. package/scripts/start.ts +11 -2
  306. package/systems/api/package.json +3 -3
  307. package/systems/code/package.json +3 -3
  308. package/systems/embedder/package.json +1 -1
  309. package/systems/fs/client/fakes.ts +2 -0
  310. package/systems/fs/client/index.ts +4 -2
  311. package/systems/fs/client/machines/CoreHeatmap.vue +94 -0
  312. package/systems/fs/client/machines/MachineFiles.vue +121 -0
  313. package/systems/fs/client/machines/MachineMetrics.vue +330 -0
  314. package/systems/fs/client/machines/MachinesPage.vue +119 -0
  315. package/systems/fs/client/machines/TimeChart.vue +128 -0
  316. package/systems/fs/client/machines/fakes.ts +95 -0
  317. package/systems/fs/client/machines/files/ChangesPane.vue +90 -0
  318. package/systems/fs/client/machines/files/CodeView.vue +158 -0
  319. package/systems/fs/client/machines/files/CommentComposer.vue +86 -0
  320. package/systems/fs/client/machines/files/CommentThread.vue +115 -0
  321. package/systems/fs/client/machines/files/CommitPane.vue +80 -0
  322. package/systems/fs/client/machines/files/ComparePane.vue +81 -0
  323. package/systems/fs/client/machines/files/FileHistory.vue +89 -0
  324. package/systems/fs/client/machines/files/FilePane.vue +199 -0
  325. package/systems/fs/client/machines/files/FileTree.vue +26 -0
  326. package/systems/fs/client/machines/files/FolderPane.vue +154 -0
  327. package/systems/fs/client/machines/files/HistoryPane.vue +106 -0
  328. package/systems/fs/client/machines/files/ImageView.vue +160 -0
  329. package/systems/fs/client/machines/files/PatchView.vue +31 -0
  330. package/systems/fs/client/machines/files/QuickOpen.vue +67 -0
  331. package/systems/fs/client/machines/files/SearchPane.vue +87 -0
  332. package/systems/fs/client/machines/files/TreeNode.vue +72 -0
  333. package/systems/fs/client/machines/files/api.ts +127 -0
  334. package/systems/fs/client/machines/files/fake-kinds.ts +16 -0
  335. package/systems/fs/client/machines/files/fakes.ts +305 -0
  336. package/systems/fs/client/machines/files/ink.ts +117 -0
  337. package/systems/fs/client/machines/files/logic.ts +205 -0
  338. package/systems/fs/client/machines/files/state.ts +187 -0
  339. package/systems/fs/client/machines/files/viewers/CsvView.vue +29 -0
  340. package/systems/fs/client/machines/files/viewers/HexView.vue +27 -0
  341. package/systems/fs/client/machines/files/viewers/HtmlView.vue +17 -0
  342. package/systems/fs/client/machines/files/viewers/JsonNode.vue +45 -0
  343. package/systems/fs/client/machines/files/viewers/JsonView.vue +25 -0
  344. package/systems/fs/client/machines/metrics.ts +245 -0
  345. package/systems/fs/client/machines/palette.ts +97 -0
  346. package/systems/fs/client/preview/machines.ts +323 -0
  347. package/systems/fs/context/authoring/index.md +4 -0
  348. package/systems/fs/context/authoring/parts/actions.md +5 -1
  349. package/systems/fs/context/authoring/parts/actions.reference.md +6 -2
  350. package/systems/fs/context/authoring/parts/calling.md +5 -1
  351. package/systems/fs/context/authoring/parts/calling.reference.md +4 -0
  352. package/systems/fs/context/authoring/parts/client.md +9 -1
  353. package/systems/fs/context/authoring/parts/client.reference/client.md +4 -0
  354. package/systems/fs/context/authoring/parts/client.reference/resultview.md +56 -53
  355. package/systems/fs/context/authoring/parts/client.reference/{fnpillprops.md → textareaprops.md} +58 -4
  356. package/systems/fs/context/authoring/parts/client.reference.md +8 -4
  357. package/systems/fs/context/authoring/parts/context/questions.md +49 -0
  358. package/systems/fs/context/authoring/parts/context.md +23 -1
  359. package/systems/fs/context/authoring/parts/context.reference.md +27 -3
  360. package/systems/fs/context/authoring/parts/contract.md +10 -0
  361. package/systems/fs/context/authoring/parts/contract.reference.md +26 -9
  362. package/systems/fs/context/authoring/parts/core-types/access-ts.md +4 -0
  363. package/systems/fs/context/authoring/parts/core-types/admin-ts.md +5 -1
  364. package/systems/fs/context/authoring/parts/core-types/api-index-ts.md +4 -0
  365. package/systems/fs/context/authoring/parts/core-types/approvals-ts.md +11 -7
  366. package/systems/fs/context/authoring/parts/core-types/auto-pair-ts.md +4 -0
  367. package/systems/fs/context/authoring/parts/core-types/checks-ts.md +4 -0
  368. package/systems/fs/context/authoring/parts/core-types/claims-ts.md +4 -0
  369. package/systems/fs/context/authoring/parts/core-types/config-secrets-ts.md +4 -0
  370. package/systems/fs/context/authoring/parts/core-types/connections-ts.md +4 -0
  371. package/systems/fs/context/authoring/parts/core-types/context-files-ts.md +8 -0
  372. package/systems/fs/context/authoring/parts/core-types/context-graph-ts.md +5 -1
  373. package/systems/fs/context/authoring/parts/core-types/context-questions-ts.md +26 -0
  374. package/systems/fs/context/authoring/parts/core-types/contextdecl.md +9 -1
  375. package/systems/fs/context/authoring/parts/core-types/data-ts.md +4 -0
  376. package/systems/fs/context/authoring/parts/core-types/decisions-ts.md +4 -0
  377. package/systems/fs/context/authoring/parts/core-types/fn-block-ts.md +4 -0
  378. package/systems/fs/context/authoring/parts/core-types/fn-facts-ts.md +11 -0
  379. package/systems/fs/context/authoring/parts/core-types/gin-ts.md +4 -0
  380. package/systems/fs/context/authoring/parts/core-types/grants-ts.md +5 -1
  381. package/systems/fs/context/authoring/parts/core-types/lifecycle-ts.md +18 -5
  382. package/systems/fs/context/authoring/parts/core-types/link-ts.md +7 -3
  383. package/systems/fs/context/authoring/parts/core-types/llm-ts.md +4 -0
  384. package/systems/fs/context/authoring/parts/core-types/manifest.md +15 -2
  385. package/systems/fs/context/authoring/parts/core-types/manifestpatch.md +9 -1
  386. package/systems/fs/context/authoring/parts/core-types/mention-search-ts.md +4 -0
  387. package/systems/fs/context/authoring/parts/core-types/model-calls-ts.md +5 -1
  388. package/systems/fs/context/authoring/parts/core-types/model-names-ts.md +4 -0
  389. package/systems/fs/context/authoring/parts/core-types/modes-ts.md +4 -0
  390. package/systems/fs/context/authoring/parts/core-types/owner-runs-ts.md +4 -0
  391. package/systems/fs/context/authoring/parts/core-types/package-ts.md +9 -0
  392. package/systems/fs/context/authoring/parts/core-types/primitives-ts.md +4 -0
  393. package/systems/fs/context/authoring/parts/core-types/query-ts.md +4 -0
  394. package/systems/fs/context/authoring/parts/core-types/records-actors-ts.md +7 -3
  395. package/systems/fs/context/authoring/parts/core-types/records-chat-ts.md +4 -0
  396. package/systems/fs/context/authoring/parts/core-types/records-content-ts.md +4 -0
  397. package/systems/fs/context/authoring/parts/core-types/records-runs-ts.md +4 -0
  398. package/systems/fs/context/authoring/parts/core-types/records-systems-ts.md +4 -0
  399. package/systems/fs/context/authoring/parts/core-types/registries-ts.md +4 -0
  400. package/systems/fs/context/authoring/parts/core-types/remote-auth-ts.md +4 -0
  401. package/systems/fs/context/authoring/parts/core-types/resources-ts.md +5 -1
  402. package/systems/fs/context/authoring/parts/core-types/run-ts.md +7 -0
  403. package/systems/fs/context/authoring/parts/core-types/sensitivity-ts.md +5 -1
  404. package/systems/fs/context/authoring/parts/core-types/stores-ts.md +199 -0
  405. package/systems/fs/context/authoring/parts/core-types/system-events-ts.md +8 -1
  406. package/systems/fs/context/authoring/parts/core-types/system-pages-ts.md +4 -0
  407. package/systems/fs/context/authoring/parts/core-types/system-providers-ts.md +4 -0
  408. package/systems/fs/context/authoring/parts/core-types/validation-ts.md +4 -0
  409. package/systems/fs/context/authoring/parts/core-types/visuals-ts.md +4 -0
  410. package/systems/fs/context/authoring/parts/core-types/web-ts.md +4 -0
  411. package/systems/fs/context/authoring/parts/core-types/widgets-ts.md +4 -0
  412. package/systems/fs/context/authoring/parts/core-types.md +12 -2
  413. package/systems/fs/context/authoring/parts/ctx/update-result.md +33 -0
  414. package/systems/fs/context/authoring/parts/ctx.md +11 -1
  415. package/systems/fs/context/authoring/parts/ctx.reference/{hubai.md → adminnotices.md} +45 -4
  416. package/systems/fs/context/authoring/parts/ctx.reference/fnctx.md +21 -23
  417. package/systems/fs/context/authoring/parts/ctx.reference.md +8 -4
  418. package/systems/fs/context/authoring/parts/data.md +11 -6
  419. package/systems/fs/context/authoring/parts/data.reference.md +4 -0
  420. package/systems/fs/context/authoring/parts/examples/client-findview-vue.md +4 -0
  421. package/systems/fs/context/authoring/parts/examples/client-index-ts.md +4 -0
  422. package/systems/fs/context/authoring/parts/examples/client-notecard-vue.md +4 -0
  423. package/systems/fs/context/authoring/parts/examples/client-noteinput-vue.md +4 -0
  424. package/systems/fs/context/authoring/parts/examples/client-notespage-vue.md +4 -0
  425. package/systems/fs/context/authoring/parts/examples/client-reviewform-vue.md +4 -0
  426. package/systems/fs/context/authoring/parts/examples/client-wordcount-vue.md +4 -0
  427. package/systems/fs/context/authoring/parts/examples/package-json.md +4 -0
  428. package/systems/fs/context/authoring/parts/examples/server-env-ts.md +4 -0
  429. package/systems/fs/context/authoring/parts/examples/server-impl-ts.md +4 -0
  430. package/systems/fs/context/authoring/parts/examples/server-index-ts.md +4 -0
  431. package/systems/fs/context/authoring/parts/examples/server-main-ts.md +4 -0
  432. package/systems/fs/context/authoring/parts/examples/server-notes-test-ts.md +4 -0
  433. package/systems/fs/context/authoring/parts/examples/shared-index-ts.md +10 -0
  434. package/systems/fs/context/authoring/parts/examples/system-json.md +4 -0
  435. 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
  436. 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
  437. package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-383-567.md +210 -0
  438. package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-568-660.md +117 -0
  439. package/systems/fs/context/authoring/parts/examples/tsconfig-json.md +5 -1
  440. package/systems/fs/context/authoring/parts/examples.md +18 -11
  441. package/systems/fs/context/authoring/parts/fns.md +5 -1
  442. package/systems/fs/context/authoring/parts/fns.reference/fillclaims.md +5 -1
  443. package/systems/fs/context/authoring/parts/fns.reference/fn.md +6 -2
  444. package/systems/fs/context/authoring/parts/fns.reference.md +4 -0
  445. package/systems/fs/context/authoring/parts/folder.md +4 -0
  446. package/systems/fs/context/authoring/parts/gin.md +4 -0
  447. package/systems/fs/context/authoring/parts/gin.reference.md +4 -0
  448. package/systems/fs/context/authoring/parts/handlers-progress.md +5 -1
  449. package/systems/fs/context/authoring/parts/handlers-progress.reference.md +4 -0
  450. package/systems/fs/context/authoring/parts/hooks.md +5 -1
  451. package/systems/fs/context/authoring/parts/hooks.reference.md +5 -1
  452. package/systems/fs/context/authoring/parts/hub/context-questions.md +40 -0
  453. package/systems/fs/context/authoring/parts/hub/{hub-run-background.md → hub-ctx-from-resource.md} +51 -56
  454. package/systems/fs/context/authoring/parts/hub/hub-fns-load.md +35 -42
  455. package/systems/fs/context/authoring/parts/hub/hub-install-package.md +327 -0
  456. package/systems/fs/context/authoring/parts/hub/kinds-of-hub.md +8 -0
  457. package/systems/fs/context/authoring/parts/hub.md +14 -8
  458. package/systems/fs/context/authoring/parts/hub.reference.md +9 -0
  459. package/systems/fs/context/authoring/parts/internals/manifestof.md +4 -0
  460. package/systems/fs/context/authoring/parts/internals/permissionargs.md +4 -0
  461. package/systems/fs/context/authoring/parts/internals/usagefromwire.md +47 -2
  462. package/systems/fs/context/authoring/parts/internals.md +6 -2
  463. package/systems/fs/context/authoring/parts/kinds-agents.md +5 -1
  464. package/systems/fs/context/authoring/parts/kinds-agents.reference/authoringsession.md +4 -0
  465. package/systems/fs/context/authoring/parts/kinds-agents.reference/kind.md +7 -3
  466. package/systems/fs/context/authoring/parts/kinds-agents.reference.md +4 -0
  467. package/systems/fs/context/authoring/parts/lifecycle.md +8 -3
  468. package/systems/fs/context/authoring/parts/lifecycle.reference.md +6 -2
  469. package/systems/fs/context/authoring/parts/mentions.md +5 -1
  470. package/systems/fs/context/authoring/parts/mentions.reference.md +6 -2
  471. package/systems/fs/context/authoring/parts/mistakes.md +7 -2
  472. package/systems/fs/context/authoring/parts/named-types.md +4 -0
  473. package/systems/fs/context/authoring/parts/named-types.reference.md +6 -2
  474. package/systems/fs/context/authoring/parts/outcomes.md +5 -1
  475. package/systems/fs/context/authoring/parts/outcomes.reference.md +4 -0
  476. package/systems/fs/context/authoring/parts/owner-runs.md +5 -1
  477. package/systems/fs/context/authoring/parts/owner-runs.reference.md +36 -11
  478. package/systems/fs/context/authoring/parts/packaging.md +10 -3
  479. package/systems/fs/context/authoring/parts/packaging.reference.md +7 -2
  480. package/systems/fs/context/authoring/parts/providers.md +5 -1
  481. package/systems/fs/context/authoring/parts/providers.reference.md +5 -1
  482. package/systems/fs/context/authoring/parts/remote.md +5 -1
  483. package/systems/fs/context/authoring/parts/remote.reference.md +4 -0
  484. package/systems/fs/context/authoring/parts/resources.md +5 -1
  485. package/systems/fs/context/authoring/parts/resources.reference.md +4 -0
  486. package/systems/fs/context/authoring/parts/server.md +5 -1
  487. package/systems/fs/context/authoring/parts/server.reference.md +41 -20
  488. package/systems/fs/context/authoring/parts/settings-attachments.md +5 -1
  489. package/systems/fs/context/authoring/parts/settings-attachments.reference.md +4 -0
  490. package/systems/fs/context/authoring/parts/start.md +5 -1
  491. package/systems/fs/context/authoring/parts/state-forms.md +5 -1
  492. package/systems/fs/context/authoring/parts/state-forms.reference.md +4 -0
  493. package/systems/fs/context/authoring/parts/store/ctx-store.md +49 -0
  494. package/systems/fs/context/authoring/parts/store/declare.md +32 -0
  495. package/systems/fs/context/authoring/parts/store/engines.md +25 -0
  496. package/systems/fs/context/authoring/parts/store/migrations.md +53 -0
  497. package/systems/fs/context/authoring/parts/store/moves.md +38 -0
  498. package/systems/fs/context/authoring/parts/store/placement.md +25 -0
  499. package/systems/fs/context/authoring/parts/store/serve.md +30 -0
  500. package/systems/fs/context/authoring/parts/store/store-tables.md +24 -0
  501. package/systems/fs/context/authoring/parts/store/vectors.md +32 -0
  502. package/systems/fs/context/authoring/parts/store/when-to-use.md +27 -0
  503. package/systems/fs/context/authoring/parts/store/work.md +37 -0
  504. package/systems/fs/context/authoring/parts/store.md +65 -0
  505. package/systems/fs/context/authoring/parts/store.reference.md +459 -0
  506. package/systems/fs/context/authoring/parts/testing.md +14 -1
  507. package/systems/fs/context/authoring/parts/testing.reference/{memoryjournal.md → equal.md} +55 -48
  508. package/systems/fs/context/authoring/parts/testing.reference/fakehub.md +26 -45
  509. package/systems/fs/context/authoring/parts/testing.reference/{toolcall.md → kindprops.md} +111 -4
  510. package/systems/fs/context/authoring/parts/testing.reference/openmemorystore.md +105 -0
  511. package/systems/fs/context/authoring/parts/testing.reference.md +16 -9
  512. package/systems/fs/context/authoring/parts/widgets.md +5 -1
  513. package/systems/fs/context/authoring/parts/widgets.reference/hub-visuals.md +4 -0
  514. package/systems/fs/context/authoring/parts/widgets.reference/sourcecompatible.md +4 -0
  515. package/systems/fs/context/authoring/parts/widgets.reference.md +4 -0
  516. package/systems/fs/context/authoring/topics/begin.md +4 -0
  517. package/systems/fs/context/authoring/topics/client.md +4 -0
  518. package/systems/fs/context/authoring/topics/declare.md +4 -0
  519. package/systems/fs/context/authoring/topics/examples.md +4 -0
  520. package/systems/fs/context/authoring/topics/fns.md +4 -0
  521. package/systems/fs/context/authoring/topics/server.md +4 -0
  522. package/systems/fs/context/authoring/topics/types.md +8 -1
  523. package/systems/fs/context/comments/answer.md +21 -0
  524. package/systems/fs/context/comments/find.md +23 -0
  525. package/systems/fs/context/comments/read.md +26 -0
  526. package/systems/fs/context/comments.md +23 -0
  527. package/systems/fs/context/files-page.md +30 -0
  528. package/systems/fs/context/guide/attachments.md +16 -0
  529. package/systems/fs/context/guide/change.md +23 -0
  530. package/systems/fs/context/guide/commands.md +19 -0
  531. package/systems/fs/context/guide/documents.md +21 -0
  532. package/systems/fs/context/guide/find.md +25 -0
  533. package/systems/fs/context/guide/paths.md +24 -0
  534. package/systems/fs/context/guide/read.md +21 -0
  535. package/systems/fs/context/machine/history.md +25 -0
  536. package/systems/fs/context/machine/now.md +25 -0
  537. package/systems/fs/context/machine/processes.md +20 -0
  538. package/systems/fs/context/machine/recording.md +19 -0
  539. package/systems/fs/context/machine.md +24 -0
  540. package/systems/fs/package.json +5 -3
  541. package/systems/fs/server/files-page/browse.ts +391 -0
  542. package/systems/fs/server/files-page/comments.ts +439 -0
  543. package/systems/fs/server/files-page/fns.ts +158 -0
  544. package/systems/fs/server/files-page/git-view.ts +391 -0
  545. package/systems/fs/server/files-page/kinds.ts +56 -0
  546. package/systems/fs/server/impl.ts +66 -7
  547. package/systems/fs/server/main.ts +20 -4
  548. package/systems/fs/server/metrics/collector.ts +424 -0
  549. package/systems/fs/server/metrics/index.ts +181 -0
  550. package/systems/fs/server/metrics/os.ts +144 -0
  551. package/systems/fs/server/metrics/parsers.ts +268 -0
  552. package/systems/fs/server/metrics/rrd.ts +363 -0
  553. package/systems/fs/server/metrics/testing.ts +80 -0
  554. package/systems/fs/server/snapshots.ts +216 -33
  555. package/systems/fs/server/testing.ts +15 -9
  556. package/systems/fs/shared/files-page.ts +506 -0
  557. package/systems/fs/shared/index.ts +137 -10
  558. package/systems/fs/shared/metrics.ts +179 -0
  559. package/systems/fs/system.json +10 -1
  560. package/systems/google-calendar/package.json +1 -1
  561. package/systems/input/package.json +3 -3
  562. package/systems/mcp/package.json +3 -3
  563. package/systems/mcp/server/oauth.ts +1 -1
  564. package/systems/ollama/package.json +3 -3
  565. package/systems/schedule/package.json +3 -4
  566. package/systems/schedule/server/env.ts +1 -1
  567. package/systems/schedule/server/fns.ts +5 -4
  568. package/systems/schedule/server/impl.ts +2 -2
  569. package/systems/schedule/server/import.ts +189 -0
  570. package/systems/schedule/server/index.ts +2 -0
  571. package/systems/schedule/server/main.ts +3 -1
  572. package/systems/schedule/server/placements.ts +41 -0
  573. package/systems/schedule/server/store.ts +159 -79
  574. package/systems/schedule/server/timer.ts +142 -107
  575. package/systems/schedule/shared/index.ts +2 -1
  576. package/systems/schedule/system.json +5 -1
  577. package/systems/schedule/tsconfig.json +1 -1
  578. package/systems/template/package.json +1 -1
  579. package/systems/widgets/package.json +3 -3
  580. package/packages/web/dist/assets/ChatPage-7Yebk7rl.js +0 -4
  581. package/packages/web/dist/assets/ContextItemPage-B6rJG3OT.js +0 -2
  582. package/packages/web/dist/assets/ContextItemPage-BRsWxOmu.css +0 -1
  583. package/packages/web/dist/assets/ContextPage-CloIZ_2y.js +0 -2
  584. package/packages/web/dist/assets/ContextPage-rYKxjiVI.css +0 -1
  585. package/packages/web/dist/assets/ContextRow-Byz_7HG-.css +0 -1
  586. package/packages/web/dist/assets/ContextRow-Dvv8CTFk.js +0 -2
  587. package/packages/web/dist/assets/DataTypePage-Ba_zBV4b.js +0 -4
  588. package/packages/web/dist/assets/FnView-B8MGAOoB.js +0 -2
  589. package/packages/web/dist/assets/InstallDialog-C9GDoUI2.js +0 -2
  590. package/packages/web/dist/assets/InstanceTypes-D8Jcxn70.js +0 -2
  591. package/packages/web/dist/assets/InstanceTypes-DAowwLB7.css +0 -1
  592. package/packages/web/dist/assets/InstanceView-CuBD3JPU.css +0 -1
  593. package/packages/web/dist/assets/InstanceView-p7tMaylE.js +0 -2
  594. package/packages/web/dist/assets/LimitsView-DsZG6u5P.js +0 -2
  595. package/packages/web/dist/assets/ListSearch-BK4p7Nxa.js +0 -2
  596. package/packages/web/dist/assets/McpServerView-CD8qw6W_.js +0 -2
  597. package/packages/web/dist/assets/McpServersView-DNycG35u.js +0 -2
  598. package/packages/web/dist/assets/ModelsView-C_iN19xt.js +0 -2
  599. package/packages/web/dist/assets/PairPage-Bs2KuRjC.css +0 -1
  600. package/packages/web/dist/assets/PairPage-TEXPpsqi.js +0 -2
  601. package/packages/web/dist/assets/PoliciesView-BU1fudNF.js +0 -2
  602. package/packages/web/dist/assets/ResourcesPage-YluNBqIv.js +0 -2
  603. package/packages/web/dist/assets/ReviewView-79Z5rU1v.js +0 -3
  604. package/packages/web/dist/assets/RunsView-Dz9Xsvu5.js +0 -2
  605. package/packages/web/dist/assets/ServiceRows-DNzDiutg.js +0 -2
  606. package/packages/web/dist/assets/SettingsPage-CykfuYj1.js +0 -3
  607. package/packages/web/dist/assets/SystemView-Es5wtkYU.js +0 -2
  608. package/packages/web/dist/assets/SystemsView-CeuSFhlF.js +0 -2
  609. package/packages/web/dist/assets/UserMessage-qyc8dG5D.js +0 -9
  610. package/packages/web/dist/assets/WidgetView-BZyDyYRI.js +0 -3
  611. package/packages/web/dist/assets/index-Bv42jNvr.js +0 -4
  612. package/packages/web/dist/assets/routes-qP_j74V5.js +0 -4
  613. package/packages/web/dist/assets/runs-k76usGfd.js +0 -2
  614. package/packages/web/dist/assets/src-DLK1P7oz.js +0 -43
  615. package/packages/web/dist/assets/state-CjE-qA2w.js +0 -2
  616. package/packages/web/dist/assets/ui-W12UYhVu.js +0 -17
  617. package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-371-533.md +0 -183
  618. package/systems/fs/context/authoring/parts/hub/hub-auto-pair-revoke.md +0 -189
@@ -27,6 +27,8 @@ export const cliEnv = env({
27
27
  HARNESS_DATA: z.string().optional(),
28
28
  /** A hub MCP's secret, for `harness mcp`. */
29
29
  HARNESS_MCP_SECRET: z.string().optional(),
30
+ /** An external store's connection URL, for `system store move --to external` (rather than `--url` on the command line). */
31
+ HARNESS_STORE_URL: z.string().optional(),
30
32
  /** How long `install` waits for a system to connect, in ms. */
31
33
  HARNESS_CLI_WAIT: z.number().int().min(0).default(30_000),
32
34
  /** How long reading a system's contract (in a sandboxed child process) may take, in ms. */
@@ -40,7 +42,11 @@ export type CliEnv = ReturnType<typeof cliEnv.parse>;
40
42
  export type CliSetting = keyof CliEnv;
41
43
 
42
44
  /** The CLI settings, and which of them came from `.env` in the folder it runs in rather than the environment. */
43
- export type CliSettings = CliEnv & { readonly fromFile: ReadonlySet<CliSetting> };
45
+ export type CliSettings = CliEnv & {
46
+ readonly fromFile: ReadonlySet<CliSetting>;
47
+ /** The settings given at all (in the environment or `.env`), not left to their defaults; unknown when absent. */
48
+ readonly given?: ReadonlySet<CliSetting>;
49
+ };
44
50
 
45
51
  /** The CLI settings from `.env` in `cwd` and the environment (the environment wins). */
46
52
  export function cliSettings(cwd: string, environment: Readonly<Record<string, string | undefined>>): CliSettings {
@@ -49,7 +55,8 @@ export function cliSettings(cwd: string, environment: Readonly<Record<string, st
49
55
  const settings = cliEnv.parse();
50
56
  const isSetting = (name: string): name is CliSetting => name in settings;
51
57
  const fromFile = new Set(Object.keys(settings).filter(isSetting).filter((name) => file[name] !== undefined && environment[name] === undefined));
52
- return { ...settings, fromFile };
58
+ const given = new Set(Object.keys(settings).filter(isSetting).filter((name) => file[name] !== undefined || environment[name] !== undefined));
59
+ return { ...settings, fromFile, given };
53
60
  }
54
61
 
55
62
  /** A signed-in hub. */
@@ -68,6 +75,10 @@ export interface HubTarget {
68
75
  readonly url: string;
69
76
  readonly token?: string | undefined;
70
77
  readonly admin?: { readonly email: string; readonly password: string } | undefined;
78
+ /** False when neither `--hub` nor `HARNESS_URL` named the address (it is the default), so a saved admin's address is used. */
79
+ readonly addressGiven?: boolean | undefined;
80
+ /** The address of the hub the data folder's saved admin is for, when it is not this one (said when signing in fails). */
81
+ readonly savedUrl?: string | undefined;
71
82
  }
72
83
 
73
84
  /** Why a hub address from the folder's `.env` isn't signed in to with a sign-in from elsewhere. */
@@ -85,16 +96,21 @@ export function hubTarget(settings: CliSettings, options: { hub?: string | undef
85
96
  if (options.hub === undefined && settings.fromFile.has('HARNESS_URL') && !signInFromFile(settings, options, token, admin, secret)) {
86
97
  throw new Error(ENV_FILE_URL_REFUSED);
87
98
  }
88
- return { url: (options.hub ?? settings.HARNESS_URL).replace(/\/$/, ''), token, admin };
99
+ const addressGiven = options.hub !== undefined || (settings.given?.has('HARNESS_URL') ?? true);
100
+ return { url: (options.hub ?? settings.HARNESS_URL).replace(/\/$/, ''), token, admin, addressGiven };
89
101
  }
90
102
 
91
103
  /**
92
- * A target with no sign-in given, signed in with the admin account `harness start` saved, when that account is for this
93
- * same hub on this machine; any other target as it is.
104
+ * A target with no sign-in given, signed in with the admin account `harness start` saved: at the saved account's
105
+ * address when no address was named (`--hub`, `HARNESS_URL`), or when the one named is that same hub on this machine.
106
+ * A named address of another hub keeps no sign-in, and notes the saved one's address so the refusal can name it.
94
107
  */
95
108
  export function withSavedAdmin(target: HubTarget, saved: AdminFile | undefined): HubTarget {
96
- if (target.token !== undefined || target.admin !== undefined || saved === undefined || !sameLocalHub(saved.url, target.url)) { return target; }
97
- return { ...target, admin: { email: saved.email, password: saved.password } };
109
+ if (target.token !== undefined || target.admin !== undefined || saved === undefined) { return target; }
110
+ const admin = { email: saved.email, password: saved.password };
111
+ if (target.addressGiven === false) { return { ...target, url: saved.url.replace(/\/$/, ''), admin }; }
112
+ if (!sameLocalHub(saved.url, target.url)) { return { ...target, savedUrl: saved.url }; }
113
+ return { ...target, admin };
98
114
  }
99
115
 
100
116
  /** Whether the sign-in a hub target uses came from the folder's `.env` (none at all counts: nothing is sent). */
@@ -155,6 +171,9 @@ export async function connectHub(target: HubTarget, fetcher: typeof fetch = fetc
155
171
 
156
172
  /** Signed in as the admin account. */
157
173
  async function adminClient(target: HubTarget): Promise<{ api: HubClient; close: () => void }> {
174
+ if (target.admin === undefined && target.savedUrl !== undefined) {
175
+ throw new Error(`Say how to sign in to ${target.url}: the admin saved in this data folder is for the hub at ${target.savedUrl}. Pass --hub ${target.savedUrl} (or set HARNESS_URL to it) to use that one, or set HARNESS_TOKEN, or HARNESS_ADMIN_EMAIL and HARNESS_ADMIN_PASSWORD, for this one.`);
176
+ }
158
177
  if (target.admin === undefined) {
159
178
  throw new Error('Say how to sign in: set HARNESS_TOKEN (or pass --token - and give it on stdin), or HARNESS_ADMIN_EMAIL and HARNESS_ADMIN_PASSWORD in the environment or .env. For the hub the start command runs here, set HARNESS_DATA to its data folder when it is not ~/.harness.');
160
179
  }
@@ -15,6 +15,7 @@ export function nodeIo(cwd: string, environment: Readonly<Record<string, string
15
15
  return {
16
16
  out: { line: (text) => { process.stdout.write(`${text}\n`); }, warn: (text) => { process.stderr.write(`${text}\n`); } },
17
17
  files,
18
+ env: environment,
18
19
  cwd,
19
20
  builder: new ViteBuilder({ probeTimeout: settings.HARNESS_CLI_PROBE_TIMEOUT, probeEnv: scrubbedEnv(environment) }),
20
21
  tests: new VitestRunner(files),
@@ -188,7 +188,7 @@ export class FakeTests implements SystemTestRunner {
188
188
  }
189
189
 
190
190
  /** Io over memory files, a fake builder and the given hub; `cwd` is a made-up absolute folder. */
191
- export function testIo(options: { hub?: FakeHub; cwd?: string; stdin?: readonly string[] } = {}): TestIo {
191
+ export function testIo(options: { hub?: FakeHub; cwd?: string; stdin?: readonly string[]; env?: Readonly<Record<string, string | undefined>> } = {}): TestIo {
192
192
  const memory = new MemoryFiles();
193
193
  const lines: string[] = [];
194
194
  const warnings: string[] = [];
@@ -202,6 +202,7 @@ export function testIo(options: { hub?: FakeHub; cwd?: string; stdin?: readonly
202
202
  start: ({ out: _out, ...options }) => { started.push(options); return Promise.resolve(0); },
203
203
  out: { line: (text) => { lines.push(text); }, warn: (text) => { warnings.push(text); } },
204
204
  files: memory,
205
+ env: options.env ?? {},
205
206
  cwd,
206
207
  settings,
207
208
  sleep: () => Promise.resolve(),
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "dependencies": {
3
- "@aeye/gin": "^0.10.1",
4
- "@aeye/schema": "^0.10.1",
5
- "@aeye/resources": "^0.10.1",
3
+ "@aeye/gin": "^0.10.2",
4
+ "@aeye/schema": "^0.10.2",
5
+ "@aeye/resources": "^0.10.2",
6
6
  "@ayepi/auth": "^0.6.0",
7
7
  "@ayepi/core": "^0.6.0",
8
8
  "@ayepi/log": "^0.6.0",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "name": "@harness/core",
13
13
  "private": true,
14
- "version": "0.2.0",
14
+ "version": "0.3.0",
15
15
  "license": "Apache-2.0",
16
16
  "type": "module",
17
17
  "description": "Wire contracts: zod schemas and ayepi specs for the system link (both directions), the web API and events. Every record and wire type is derived from them.",
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { z } from 'zod';
8
8
  import { ContextDecl } from './manifest.ts';
9
- import { Audience, LocalName, ModelCallId, QualifiedName } from './primitives.ts';
9
+ import { Audience, LocalName, ModelCallId, QualifiedName, Timestamp } from './primitives.ts';
10
10
  import { CRAWL_DEFAULTS } from './context-graph.ts';
11
11
  import { FnRefusal } from './fn-block.ts';
12
12
 
@@ -25,6 +25,8 @@ export const ContextFileHeader = ContextDecl.omit({ name: true, content: true })
25
25
  suggest: Audience.default('both'),
26
26
  visible: Audience.default('both'),
27
27
  tags: z.array(z.string()).default([]),
28
+ /** When the text last changed: a date (`2026-11-28`, or an ISO time) or ms since the epoch. */
29
+ lastModified: z.union([Timestamp, z.iso.date().transform((day) => Date.parse(day)), z.iso.datetime({ offset: true }).transform((time) => Date.parse(time))]).optional(),
28
30
  }).strict();
29
31
  export type ContextFileHeader = z.infer<typeof ContextFileHeader>;
30
32
 
@@ -178,6 +178,10 @@ export const RememberArgs = z.object({
178
178
  title: z.string().optional(),
179
179
  scope: z.enum(['session', 'user', 'everyone']).default('session'),
180
180
  about: z.array(LinkTarget).optional(),
181
+ /** The question the memory answers ("Which day do reports go out?"); written by the metadata model when left out. */
182
+ question: z.string().min(1).max(500).optional(),
183
+ /** When it matters, for a model ("When planning or sending a report."); written by the metadata model when left out. */
184
+ when: z.string().min(1).max(500).optional(),
181
185
  }).extend(ContextOptions.shape);
182
186
 
183
187
  /** The options a model may name to clear: every option but the people-only ones (`inject`), which it never sets. */
@@ -0,0 +1,451 @@
1
+ /**
2
+ * Context plans (plan `context-questions-2026-11-28`, `hub/ctx_plan`): a decision tree of the questions a request
3
+ * needs answered before a plan can be made. Each question is a context item (a `pending_plan` item until it is
4
+ * answered, so it appears once however many branches or plans raise it), each with its options, and each option with
5
+ * the questions it raises if it is chosen. A question can sit under several options, so the tree is a DAG.
6
+ *
7
+ * There is no plan record (Phil: "It's a fn result that is technically saved, do we need a different one?"): the plan
8
+ * is the saved result of the `hub/ctx_plan` run that made it, and answering, planning deeper and re-planning update
9
+ * that result (`RunService.updateResult`), so its chat card always shows the plan as it is now.
10
+ *
11
+ * This module holds the shapes and the rules every reader applies: which questions are still in play once some are
12
+ * answered (`settlePlan`), the counts a card shows (`planCounts`), the text an answered question keeps as its content
13
+ * (`answerContent`), the reason a ruled-out question gets (`ruledOutReason`), and the markdown export (`planMarkdown`).
14
+ */
15
+ import { z } from 'zod';
16
+ import { ContextAskedBy, ContextStatus } from './context-questions.ts';
17
+ import { ActorId, QualifiedName, RunId, Timestamp, Usd } from './primitives.ts';
18
+
19
+ // ─── Limits ───────────────────────────────────────────────────────────────────
20
+
21
+ /** The limits a plan runs to when the call gives none (Phil: 60 open questions, depth 6, 10 minutes, $2). */
22
+ export const PLAN_LIMIT_DEFAULTS = { openQuestions: 60, depth: 6, minutes: 10, cost: 2 } as const;
23
+
24
+ /** The limits a call may set; each one left out takes its default (`PLAN_LIMIT_DEFAULTS`). */
25
+ export const PlanLimitsArgs = z.object({
26
+ openQuestions: z.number().int().min(1).max(500).optional().describe('The most open (unanswered) questions the plan may hold; planning stops when it is reached. Default 60.'),
27
+ depth: z.number().int().min(1).max(12).optional().describe('How many levels of questions deep the plan may go (1: only the first questions and their options). Default 6.'),
28
+ minutes: z.number().min(0.1).max(120).optional().describe('The most minutes planning may take. Default 10.'),
29
+ cost: z.number().min(0).max(100).optional().describe('The most US dollars the model calls may cost. Default 2.'),
30
+ });
31
+ export type PlanLimitsArgs = z.infer<typeof PlanLimitsArgs>;
32
+
33
+ /** Limits with every one set. */
34
+ export const PlanLimits = z.object({ openQuestions: z.number().int().min(1), depth: z.number().int().min(1), minutes: z.number().min(0), cost: z.number().min(0) });
35
+ export type PlanLimits = z.infer<typeof PlanLimits>;
36
+
37
+ /** The limits a call asked for, with the defaults filled in. */
38
+ export function planLimits(given?: PlanLimitsArgs): PlanLimits {
39
+ return {
40
+ openQuestions: given?.openQuestions ?? PLAN_LIMIT_DEFAULTS.openQuestions, depth: given?.depth ?? PLAN_LIMIT_DEFAULTS.depth,
41
+ minutes: given?.minutes ?? PLAN_LIMIT_DEFAULTS.minutes, cost: given?.cost ?? PLAN_LIMIT_DEFAULTS.cost,
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Why planning stopped: `complete` (no question was left to write options for), one of the limits (`open_questions`,
47
+ * `depth`, `time`, `cost`), or `stopped` (the run was cancelled or its model calls failed).
48
+ */
49
+ export const PLAN_STOPS = ['complete', 'open_questions', 'depth', 'time', 'cost', 'stopped'] as const;
50
+ export const PlanStop = z.enum(PLAN_STOPS);
51
+ export type PlanStop = z.infer<typeof PlanStop>;
52
+
53
+ /** Each stop in plain words, for cards and the export. */
54
+ export const PLAN_STOP_WORDS: Readonly<Record<PlanStop, string>> = {
55
+ complete: 'Every question has its options',
56
+ open_questions: 'Stopped at the open-question limit',
57
+ depth: 'Stopped at the depth limit',
58
+ time: 'Stopped at the time limit',
59
+ cost: 'Stopped at the cost limit',
60
+ stopped: 'Stopped before it finished',
61
+ };
62
+
63
+ // ─── The plan ─────────────────────────────────────────────────────────────────
64
+
65
+ /** An option's id within its question: `o1`, `o2`, … */
66
+ export const PlanOptionId = z.string().regex(/^o\d+$/);
67
+
68
+ /** One option of a question, and the questions it raises if it is chosen. */
69
+ export const PlanOption = z.object({
70
+ id: PlanOptionId,
71
+ label: z.string().min(1).max(200),
72
+ /** What choosing it means, in a sentence or two. */
73
+ detail: z.string().max(1000).optional(),
74
+ /** The questions choosing it raises, by context name (each a question of the plan). */
75
+ raises: z.array(QualifiedName),
76
+ /** Questions it raises that a limit kept out of the plan; planning deeper here adds them. */
77
+ later: z.array(z.string().min(1).max(500)).optional(),
78
+ });
79
+ export type PlanOption = z.infer<typeof PlanOption>;
80
+
81
+ /** Where a question sits: under an option of another question (none for the plan's first questions). */
82
+ export const PlanEdge = z.object({ question: QualifiedName, option: PlanOptionId });
83
+ export type PlanEdge = z.infer<typeof PlanEdge>;
84
+
85
+ /** One question of a plan: the context item it is, its options, and its answer when it has one. */
86
+ export const PlanQuestion = z.object({
87
+ name: QualifiedName,
88
+ question: z.string().min(1),
89
+ askedBy: ContextAskedBy.optional(),
90
+ /** Its level: 1 for the first questions, one more than the shallowest question it sits under. */
91
+ depth: z.number().int().min(1),
92
+ /** The options it sits under; empty for a first question. */
93
+ parents: z.array(PlanEdge),
94
+ options: z.array(PlanOption),
95
+ /** Whether its options have been written (false: planning deeper would write them). */
96
+ planned: z.boolean(),
97
+ /** It already had an answer in context when the plan found it, so the plan wrote no options for it. */
98
+ known: z.boolean().optional(),
99
+ /** The options picked (one or more), by id. */
100
+ picked: z.array(PlanOptionId),
101
+ /** The person's own words with their answer. */
102
+ text: z.string().max(4000).optional(),
103
+ answeredBy: ActorId.optional(),
104
+ answeredAt: Timestamp.optional(),
105
+ /** Its item's status as the plan last set or read it. */
106
+ status: ContextStatus,
107
+ /** Why it was ruled out, for a `not_applicable` question. */
108
+ statusReason: z.string().optional(),
109
+ /** A person wrote the reason it was ruled out, so the automatic one doesn't replace it. */
110
+ reasonEdited: z.boolean().optional(),
111
+ });
112
+ export type PlanQuestion = z.infer<typeof PlanQuestion>;
113
+
114
+ /** What a card shows: how many questions are answered, open and ruled out, and the decisions to make now. */
115
+ export const PlanCounts = z.object({
116
+ questions: z.number().int().min(0),
117
+ answered: z.number().int().min(0),
118
+ open: z.number().int().min(0),
119
+ ruledOut: z.number().int().min(0),
120
+ /** Open questions nothing undecided sits above: a first question, or one under an option that was picked. */
121
+ decide: z.number().int().min(0),
122
+ });
123
+ export type PlanCounts = z.infer<typeof PlanCounts>;
124
+
125
+ /** A plan: what it is for, how it ran, and its questions (a DAG: question → options → questions). */
126
+ export const ContextPlan = z.object({
127
+ description: z.string().min(1),
128
+ limits: PlanLimits,
129
+ stop: PlanStop,
130
+ /** What its model calls cost in all, planning deeper included (US dollars). */
131
+ cost: Usd,
132
+ /** How long planning took in all (ms). */
133
+ time: z.number().min(0),
134
+ startedAt: Timestamp,
135
+ updatedAt: Timestamp,
136
+ /** The first questions, by name. */
137
+ roots: z.array(QualifiedName),
138
+ questions: z.array(PlanQuestion),
139
+ counts: PlanCounts,
140
+ /** Bumped by every change after the plan was made (an answer, planning deeper). */
141
+ revision: z.number().int().min(0),
142
+ });
143
+ export type ContextPlan = z.infer<typeof ContextPlan>;
144
+
145
+ // ─── Fns and endpoints ────────────────────────────────────────────────────────
146
+
147
+ /** `hub/ctx_plan`: a plan for a request, within limits. */
148
+ export const ContextPlanArgs = z.object({
149
+ description: z.string().trim().min(1).max(4000).describe('What is to be planned, in the person\'s words with whatever they said about it: the more it says, the better the questions.'),
150
+ limits: PlanLimitsArgs.optional(),
151
+ });
152
+ export type ContextPlanArgs = z.infer<typeof ContextPlanArgs>;
153
+
154
+ /** A plan by the run that made it. */
155
+ export const ContextPlanRef = z.object({ run: RunId.describe('The run of hub/ctx_plan that made the plan (its id, such as run_01HZX3).') });
156
+ export type ContextPlanRef = z.infer<typeof ContextPlanRef>;
157
+
158
+ /** `hub/ctx_plan_get`: a plan as it is now, or its markdown export. */
159
+ export const ContextPlanGetArgs = ContextPlanRef.extend({
160
+ format: z.enum(['plan', 'markdown']).optional().describe('`plan` (the default): the plan itself; `markdown`: the questions, answers and what was ruled out, as markdown to read or share.'),
161
+ });
162
+ export type ContextPlanGetArgs = z.infer<typeof ContextPlanGetArgs>;
163
+
164
+ /** A plan with the run it belongs to (what reading or changing one answers). */
165
+ export const ContextPlanView = z.object({ run: RunId, plan: ContextPlan, markdown: z.string().optional() });
166
+ export type ContextPlanView = z.infer<typeof ContextPlanView>;
167
+
168
+ /** One question's answer: the options picked (by id or label; several allowed) and the person's own words. Both empty clears it. */
169
+ export const PlanAnswer = z.object({
170
+ question: QualifiedName.describe('The question, by its context name as the plan gives it.'),
171
+ picked: z.array(z.string().min(1)).max(20).describe('The options chosen, by id (o1) or label; several when more than one applies. Empty with no text clears the answer.'),
172
+ text: z.string().max(4000).optional().describe('The person\'s own words with the answer: a detail, a condition, or an answer none of the options gives.'),
173
+ });
174
+ export type PlanAnswer = z.infer<typeof PlanAnswer>;
175
+
176
+ /** A person's own reason a ruled-out question doesn't apply (it replaces the automatic one). */
177
+ export const PlanReason = z.object({ question: QualifiedName, reason: z.string().trim().min(1).max(500) });
178
+ export type PlanReason = z.infer<typeof PlanReason>;
179
+
180
+ /** `hub/ctx_answer`: answer questions of a plan, and say why ruled-out ones don't apply. */
181
+ export const ContextAnswerArgs = ContextPlanRef.extend({
182
+ answers: z.array(PlanAnswer).max(100).optional(),
183
+ reasons: z.array(PlanReason).max(100).optional(),
184
+ });
185
+ export type ContextAnswerArgs = z.infer<typeof ContextAnswerArgs>;
186
+
187
+ /** What answering did: the plan now, each question whose status changed, and where planning deeper would help. */
188
+ export const ContextAnswerResult = z.object({
189
+ run: RunId,
190
+ plan: ContextPlan,
191
+ changed: z.array(z.object({ name: QualifiedName, status: ContextStatus })),
192
+ /** Questions under a newly picked option that have no options yet (or options a limit kept out): "Plan deeper here". */
193
+ deeper: z.array(QualifiedName),
194
+ /** Answers it could not take, with why (an option the question doesn't have, a question not in the plan). */
195
+ skipped: z.array(z.object({ question: z.string(), reason: z.string() })),
196
+ });
197
+ export type ContextAnswerResult = z.infer<typeof ContextAnswerResult>;
198
+
199
+ /** `hub/ctx_plan_expand`: plan deeper under a question (or the whole plan), with its own limits; `replan` writes the options under it again. */
200
+ export const ContextPlanExpandArgs = ContextPlanRef.extend({
201
+ under: QualifiedName.optional().describe('The question to plan deeper under, by its context name; leave out to go on with the whole plan.'),
202
+ replan: z.boolean().optional().describe('Write the options of the open questions under it again, taking the answers given since into account (after an answer changed).'),
203
+ limits: PlanLimitsArgs.optional().describe('Limits of its own. Its `depth` is counted from the question it plans under (1: only the questions right under it), or, without `under`, from the deepest level that already has options.'),
204
+ });
205
+ export type ContextPlanExpandArgs = z.infer<typeof ContextPlanExpandArgs>;
206
+
207
+ /** One plan in the Context page's list. */
208
+ export const ContextPlanSummary = z.object({
209
+ run: RunId,
210
+ description: z.string(),
211
+ counts: PlanCounts,
212
+ stop: PlanStop.optional(),
213
+ /** Still planning (its run hasn't finished). */
214
+ running: z.boolean(),
215
+ actor: ActorId,
216
+ session: z.string().optional(),
217
+ createdAt: Timestamp,
218
+ updatedAt: Timestamp,
219
+ });
220
+ export type ContextPlanSummary = z.infer<typeof ContextPlanSummary>;
221
+
222
+ /** The plans list: newest first. */
223
+ export const ContextPlansQuery = z.object({ limit: z.number().int().min(1).max(100).optional() });
224
+ export type ContextPlansQuery = z.infer<typeof ContextPlansQuery>;
225
+ export const ContextPlansPage = z.object({ items: z.array(ContextPlanSummary) });
226
+ export type ContextPlansPage = z.infer<typeof ContextPlansPage>;
227
+
228
+ // ─── Rules ────────────────────────────────────────────────────────────────────
229
+
230
+ /** Whether a question has an answer: options picked, words of its own, or an answer in context already. */
231
+ export function planAnswered(question: Pick<PlanQuestion, 'picked' | 'text' | 'known'>): boolean {
232
+ return question.known === true || question.picked.length > 0 || (question.text ?? '').trim() !== '';
233
+ }
234
+
235
+ /** The labels of a question's picked options, in option order. */
236
+ export function pickedLabels(question: Pick<PlanQuestion, 'options' | 'picked'>): string[] {
237
+ return question.options.filter((option) => question.picked.includes(option.id)).map((option) => option.label);
238
+ }
239
+
240
+ /** The first line of an answered question's content: what was picked (and the person's words when nothing was). */
241
+ export const ANSWER_PREFIX = 'Picked: ';
242
+
243
+ /**
244
+ * The content an answered question keeps (Phil: "the options with the picks marked, plus the person's text"): a first
245
+ * line with the picks (what a search hit shows inline), the person's words, then every option, picked ones marked.
246
+ */
247
+ export function answerContent(question: Pick<PlanQuestion, 'options' | 'picked' | 'text'>): string {
248
+ const labels = pickedLabels(question);
249
+ const text = (question.text ?? '').trim();
250
+ const lines: string[] = [];
251
+ lines.push(labels.length > 0 ? `${ANSWER_PREFIX}${labels.join('; ')}` : `${ANSWER_PREFIX}none of the options`);
252
+ if (text !== '') lines.push('', text);
253
+ if (question.options.length > 0) {
254
+ lines.push('', 'Options:');
255
+ for (const option of question.options) lines.push(`- [${question.picked.includes(option.id) ? 'x' : ' '}] ${option.label}${option.detail === undefined ? '' : `: ${option.detail}`}`);
256
+ }
257
+ return lines.join('\n');
258
+ }
259
+
260
+ /** The content an open question keeps: its options, none picked yet (only a plan's own matching reads it). */
261
+ export function optionsContent(question: Pick<PlanQuestion, 'options'>): string {
262
+ if (question.options.length === 0) return '';
263
+ return ['Options:', ...question.options.map((option) => `- ${option.label}${option.detail === undefined ? '' : `: ${option.detail}`}`)].join('\n');
264
+ }
265
+
266
+ /**
267
+ * What a person chose for a question, as a reason says it: `"Postgres" for 'Which database?'`. Each option's label is
268
+ * quoted, so a long one ("Up to about 10 users, light use") doesn't run on into the question.
269
+ */
270
+ function choseFor(parent: Pick<PlanQuestion, 'question' | 'options' | 'picked'>): string {
271
+ const labels = pickedLabels(parent).map((label) => `"${label}"`);
272
+ const chose = labels.length > 0 ? labels.join(' and ') : 'none of the options';
273
+ return `${chose} for '${parent.question}'`;
274
+ }
275
+
276
+ /** The automatic reason a question is ruled out (Phil: "You chose Postgres for 'Which database?'", its label quoted). */
277
+ export function ruledOutReason(parent: Pick<PlanQuestion, 'question' | 'options' | 'picked'>): string {
278
+ return `You chose ${choseFor(parent)}`;
279
+ }
280
+
281
+ /**
282
+ * The reason a question is ruled out because the question that raised it was itself ruled out (it was never answered):
283
+ * "'Which host?' no longer applies: you chose SQLite for 'Which database?'", naming the answer that ruled that one out
284
+ * when there is one.
285
+ */
286
+ export function noLongerAppliesReason(raiser: Pick<PlanQuestion, 'question'>, answered?: Pick<PlanQuestion, 'question' | 'options' | 'picked'>): string {
287
+ return `'${raiser.question}' no longer applies${answered === undefined ? '' : `: you chose ${choseFor(answered)}`}`;
288
+ }
289
+
290
+ /** What `settlePlan` worked out for one question. */
291
+ export interface SettledQuestion {
292
+ /** Still in play: a first question, or under an option of a question in play that is picked (or not decided yet). */
293
+ readonly live: boolean;
294
+ /** For one out of play: the reason (the answer that ruled it out, or the ruled-out question it sat under). */
295
+ readonly reason?: string;
296
+ }
297
+
298
+ /** Whether an option's questions stay in play under its question: it is picked, or the question has no picks yet (words alone rule nothing out). */
299
+ function optionOpen(question: Pick<PlanQuestion, 'picked'>, option: string): boolean {
300
+ return question.picked.length === 0 || question.picked.includes(option);
301
+ }
302
+
303
+ /** The questions in play from `seeds`: each seed, and every question under an option that is open (`optionOpen`) of a question in play. */
304
+ function reach(byName: ReadonlyMap<QualifiedName, PlanQuestion>, seeds: readonly QualifiedName[]): Set<QualifiedName> {
305
+ const live = new Set<QualifiedName>(seeds);
306
+ const queue = [...seeds];
307
+ for (let name = queue.shift(); name !== undefined; name = queue.shift()) {
308
+ const question = byName.get(name);
309
+ if (question === undefined) continue;
310
+ for (const option of question.options) {
311
+ if (!optionOpen(question, option.id)) continue;
312
+ for (const child of option.raises) {
313
+ if (live.has(child) || !byName.has(child)) continue;
314
+ live.add(child);
315
+ queue.push(child);
316
+ }
317
+ }
318
+ }
319
+ return live;
320
+ }
321
+
322
+ /** Whether an option was answered against: its question has picks, and this option isn't one of them. */
323
+ function answeredWithout(question: Pick<PlanQuestion, 'picked'>, option: string): boolean {
324
+ return question.picked.length > 0 && !question.picked.includes(option);
325
+ }
326
+
327
+ /**
328
+ * Which questions are still in play. A question is in play when one of the options it sits under belongs to a
329
+ * question in play that is either undecided or has that option picked; every other is ruled out, with a reason.
330
+ *
331
+ * A first question is one the description itself raises, so it is in play on its own. Options may raise it too (the
332
+ * first pass asked it, and then options showed it depends on them: "Which vegetables?" asked first, and raised again by
333
+ * the food-growing options of "What is the garden for?"). Such a question is ruled out only once every option raising
334
+ * it was answered without being picked. A raiser that was only ruled out (never answered) says nothing about it, so it
335
+ * stays in play: "How many people?" answered "Not known yet" must not drop the budget question the description asked
336
+ * just because a question that also raised the budget went with it. Questions below the first level keep the plain rule.
337
+ *
338
+ * The reason names the answer that ruled a question out ("You chose Postgres for 'Which database?'"), or, when the
339
+ * question above it was itself ruled out rather than answered, says that one no longer applies and names the answer
340
+ * that ruled it out.
341
+ */
342
+ export function settlePlan(plan: Pick<ContextPlan, 'roots' | 'questions'>): ReadonlyMap<QualifiedName, SettledQuestion> {
343
+ const byName = new Map(plan.questions.map((question) => [question.name, question]));
344
+ const seeds = plan.roots.filter((name) => {
345
+ const edges = (byName.get(name)?.parents ?? []).filter((edge) => edge.question !== name && byName.has(edge.question));
346
+ if (edges.length === 0) return byName.has(name);
347
+ return !edges.every((edge) => {
348
+ const parent = byName.get(edge.question);
349
+ return parent !== undefined && answeredWithout(parent, edge.option);
350
+ });
351
+ });
352
+ const live = reach(byName, seeds);
353
+ /** The questions raising one (its own question left out). */
354
+ const raisers = (question: PlanQuestion): Array<{ readonly edge: PlanEdge; readonly parent: PlanQuestion }> => question.parents
355
+ .flatMap((edge) => { const parent = byName.get(edge.question); return parent === undefined || edge.question === question.name ? [] : [{ edge, parent }]; });
356
+ /** A question answered without the option raising this one (one in play first), if any was. */
357
+ const answeredBy = (question: PlanQuestion): PlanQuestion | undefined => {
358
+ const answered = raisers(question).filter((one) => answeredWithout(one.parent, one.edge.option)).map((one) => one.parent);
359
+ return answered.find((parent) => live.has(parent.name)) ?? answered[0];
360
+ };
361
+ /** The answer that ruled a question out, following ruled-out raisers up (`seen` stops a loop). */
362
+ const cause = (question: PlanQuestion, seen: Set<QualifiedName>): PlanQuestion | undefined => {
363
+ if (seen.has(question.name)) return undefined;
364
+ seen.add(question.name);
365
+ const direct = answeredBy(question);
366
+ if (direct !== undefined) return direct;
367
+ for (const { parent } of raisers(question)) {
368
+ const found = cause(parent, seen);
369
+ if (found !== undefined) return found;
370
+ }
371
+ return undefined;
372
+ };
373
+ const out = new Map<QualifiedName, SettledQuestion>();
374
+ for (const question of plan.questions) {
375
+ if (live.has(question.name)) { out.set(question.name, { live: true }); continue; }
376
+ const direct = answeredBy(question);
377
+ if (direct !== undefined) { out.set(question.name, { live: false, reason: ruledOutReason(direct) }); continue; }
378
+ const raiser = raisers(question)[0]?.parent;
379
+ if (raiser === undefined) { out.set(question.name, { live: false, reason: 'It no longer sits under any question of the plan' }); continue; }
380
+ out.set(question.name, { live: false, reason: noLongerAppliesReason(raiser, cause(raiser, new Set([question.name]))) });
381
+ }
382
+ return out;
383
+ }
384
+
385
+ /** The counts a card shows (`PlanCounts`). */
386
+ export function planCounts(plan: Pick<ContextPlan, 'roots' | 'questions'>): PlanCounts {
387
+ const settled = settlePlan(plan);
388
+ const byName = new Map(plan.questions.map((question) => [question.name, question]));
389
+ let answered = 0;
390
+ let open = 0;
391
+ let ruledOut = 0;
392
+ let decide = 0;
393
+ for (const question of plan.questions) {
394
+ if (settled.get(question.name)?.live !== true) { ruledOut += 1; continue; }
395
+ if (planAnswered(question)) { answered += 1; continue; }
396
+ open += 1;
397
+ const free = plan.roots.includes(question.name) || question.parents.some((edge) => {
398
+ const parent = byName.get(edge.question);
399
+ return parent !== undefined && settled.get(parent.name)?.live === true && parent.picked.includes(edge.option);
400
+ });
401
+ if (free) decide += 1;
402
+ }
403
+ return { questions: plan.questions.length, answered, open, ruledOut, decide };
404
+ }
405
+
406
+ /** The card's line: "3 answered · 5 open · 2 decisions to make now". */
407
+ export function countsLine(counts: PlanCounts): string {
408
+ return `${counts.answered} answered · ${counts.open} open · ${counts.decide} ${counts.decide === 1 ? 'decision' : 'decisions'} to make now`;
409
+ }
410
+
411
+ /** The status a question's item should have now: ruled out, answered (active), or open (pending_plan); an item known before keeps its own. */
412
+ export function plannedStatus(question: Pick<PlanQuestion, 'picked' | 'text' | 'known' | 'status'>, live: boolean): ContextStatus {
413
+ if (!live) return 'not_applicable';
414
+ if (question.known === true) return question.status === 'not_applicable' ? 'active' : question.status;
415
+ return planAnswered(question) ? 'active' : 'pending_plan';
416
+ }
417
+
418
+ // ─── Markdown ─────────────────────────────────────────────────────────────────
419
+
420
+ /** A plan as markdown: what it is for, every question in the tree's order with its options and answer, and what was ruled out and why. */
421
+ export function planMarkdown(plan: ContextPlan): string {
422
+ const byName = new Map(plan.questions.map((question) => [question.name, question]));
423
+ const settled = settlePlan(plan);
424
+ const lines: string[] = [`# Plan: ${plan.description.split('\n')[0] ?? ''}`, ''];
425
+ if (plan.description.includes('\n')) lines.push(...plan.description.split('\n').slice(1).map((line) => `> ${line}`), '');
426
+ lines.push(`${countsLine(plan.counts)} · ${plan.counts.ruledOut} ruled out`, '', `${PLAN_STOP_WORDS[plan.stop]}. ${plan.questions.length} questions, $${plan.cost.toFixed(2)}, ${Math.round(plan.time / 1000)} s.`, '');
427
+ const seen = new Set<QualifiedName>();
428
+ const walk = (name: QualifiedName, indent: string): void => {
429
+ const question = byName.get(name);
430
+ if (question === undefined || settled.get(name)?.live !== true) return;
431
+ if (seen.has(name)) { lines.push(`${indent}- ${question.question} _(see above)_`); return; }
432
+ seen.add(name);
433
+ const answer = planAnswered(question) ? (question.known === true ? ' — answered in context' : ` — **${pickedLabels(question).join('; ') || 'answered'}**`) : ' — _open_';
434
+ lines.push(`${indent}- **${question.question}**${answer}`);
435
+ if ((question.text ?? '').trim() !== '') lines.push(`${indent} > ${(question.text ?? '').trim().split('\n').join(`\n${indent} > `)}`);
436
+ for (const option of question.options) {
437
+ const mark = question.picked.length === 0 ? '- [ ]' : question.picked.includes(option.id) ? '- [x]' : '- [ ] ~~';
438
+ const end = question.picked.length > 0 && !question.picked.includes(option.id) ? '~~' : '';
439
+ lines.push(`${indent} ${mark}${option.label}${end}${option.detail === undefined ? '' : ` — ${option.detail}`}`);
440
+ for (const child of option.raises) walk(child, `${indent} `);
441
+ }
442
+ };
443
+ lines.push('## Questions', '');
444
+ for (const root of plan.roots) walk(root, '');
445
+ const out = plan.questions.filter((question) => settled.get(question.name)?.live !== true);
446
+ if (out.length > 0) {
447
+ lines.push('', '## Ruled out', '');
448
+ for (const question of out) lines.push(`- ${question.question} — ${question.statusReason ?? settled.get(question.name)?.reason ?? 'ruled out'}`);
449
+ }
450
+ return `${lines.join('\n').trimEnd()}\n`;
451
+ }