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.
- package/README.md +133 -23
- package/package.json +13 -17
- package/packages/build/package.json +2 -2
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/cli.ts +2 -1
- package/packages/cli/src/command.ts +2 -0
- package/packages/cli/src/commands/available.ts +63 -22
- package/packages/cli/src/commands/install.ts +182 -28
- package/packages/cli/src/commands/manage.ts +7 -5
- package/packages/cli/src/commands/store.ts +172 -0
- package/packages/cli/src/hub.ts +26 -7
- package/packages/cli/src/index.ts +3 -2
- package/packages/cli/src/io.ts +1 -0
- package/packages/cli/src/local.ts +6 -0
- package/packages/cli/src/premade.ts +80 -0
- package/packages/cli/src/testing.ts +2 -1
- package/packages/core/package.json +4 -4
- package/packages/core/src/context-files.ts +3 -1
- package/packages/core/src/context-graph.ts +4 -0
- package/packages/core/src/context-plan.ts +451 -0
- package/packages/core/src/context-questions.ts +305 -0
- package/packages/core/src/fn-facts.ts +32 -4
- package/packages/core/src/identity.ts +1 -1
- package/packages/core/src/index.ts +4 -1
- package/packages/core/src/link.ts +70 -0
- package/packages/core/src/manifest.ts +20 -1
- package/packages/core/src/model-calls.ts +11 -2
- package/packages/core/src/package.ts +10 -0
- package/packages/core/src/query.ts +3 -2
- package/packages/core/src/records/content.ts +10 -2
- package/packages/core/src/records/runs.ts +12 -0
- package/packages/core/src/records/systems.ts +87 -5
- package/packages/core/src/run.ts +5 -0
- package/packages/core/src/stores.ts +473 -0
- package/packages/core/src/suggestions.ts +3 -0
- package/packages/core/src/system-pages.ts +14 -1
- package/packages/core/src/web.ts +114 -9
- package/packages/hub/package.json +13 -12
- package/packages/hub/src/access/hits.ts +1 -1
- package/packages/hub/src/api/admin-ops.ts +36 -4
- package/packages/hub/src/api/auth.ts +8 -4
- package/packages/hub/src/api/person-ops.ts +6 -0
- package/packages/hub/src/api/store-ops.ts +54 -0
- package/packages/hub/src/api/testing/rig.ts +2 -2
- package/packages/hub/src/api/tls.ts +2 -2
- package/packages/hub/src/api/web/build5.ts +2 -1
- package/packages/hub/src/api/web/context-plans.ts +25 -0
- package/packages/hub/src/api/web/context-review.ts +43 -0
- package/packages/hub/src/api/web/index.ts +4 -0
- package/packages/hub/src/api/web/pages.ts +14 -1
- package/packages/hub/src/api/web/review.ts +16 -0
- package/packages/hub/src/api/web/systems.ts +14 -2
- package/packages/hub/src/boot/admin-fns.ts +8 -0
- package/packages/hub/src/boot/admin-secrets.ts +10 -4
- package/packages/hub/src/boot/env.ts +6 -1
- package/packages/hub/src/boot/hub-fns.ts +3 -3
- package/packages/hub/src/boot/hub-groups.ts +2 -2
- package/packages/hub/src/boot/identity.ts +1 -1
- package/packages/hub/src/boot/index.ts +9 -0
- package/packages/hub/src/boot/modules.ts +12 -3
- package/packages/hub/src/boot/person-fns.ts +5 -0
- package/packages/hub/src/boot/plan-fns.ts +39 -0
- package/packages/hub/src/boot/start.ts +2 -1
- package/packages/hub/src/catalog/catalog.ts +44 -14
- package/packages/hub/src/catalog/index.ts +6 -2
- package/packages/hub/src/chat/testing.ts +2 -2
- package/packages/hub/src/contextor/brought.ts +5 -3
- package/packages/hub/src/contextor/testing.ts +4 -4
- package/packages/hub/src/execution/create.ts +2 -0
- package/packages/hub/src/execution/env.ts +2 -0
- package/packages/hub/src/execution/errors.ts +12 -0
- package/packages/hub/src/execution/executors.ts +14 -2
- package/packages/hub/src/execution/index.ts +8 -0
- package/packages/hub/src/execution/link-handlers.ts +16 -4
- package/packages/hub/src/execution/runs.ts +212 -11
- package/packages/hub/src/execution/testing.ts +2 -1
- package/packages/hub/src/fns/search.ts +23 -4
- package/packages/hub/src/graph/graph.ts +2 -2
- package/packages/hub/src/index/index.ts +9 -2
- package/packages/hub/src/index/indexer.ts +67 -16
- package/packages/hub/src/index/search.ts +1 -0
- package/packages/hub/src/index/suggester.ts +2 -2
- package/packages/hub/src/link/build.ts +47 -10
- package/packages/hub/src/link/connections.ts +41 -3
- package/packages/hub/src/link/describer.ts +19 -2
- package/packages/hub/src/link/env.ts +10 -0
- package/packages/hub/src/link/handlers.ts +6 -0
- package/packages/hub/src/link/index.ts +16 -4
- package/packages/hub/src/link/lifecycle.ts +11 -4
- package/packages/hub/src/link/packages.ts +17 -4
- package/packages/hub/src/link/pairing.ts +2 -2
- package/packages/hub/src/link/process.ts +15 -4
- package/packages/hub/src/link/rig.ts +6 -2
- package/packages/hub/src/link/status.ts +14 -0
- package/packages/hub/src/link/supervisor.ts +17 -1
- package/packages/hub/src/link/systems.ts +16 -5
- package/packages/hub/src/models/roles.ts +74 -7
- package/packages/hub/src/query/columns.ts +4 -1
- package/packages/hub/src/query/contexts.ts +10 -3
- package/packages/hub/src/questions/apply.ts +163 -0
- package/packages/hub/src/questions/carry.ts +30 -0
- package/packages/hub/src/questions/duplicates.ts +181 -0
- package/packages/hub/src/questions/index.ts +112 -0
- package/packages/hub/src/questions/metadata.ts +142 -0
- package/packages/hub/src/questions/pending.ts +64 -0
- package/packages/hub/src/questions/plan-match.ts +79 -0
- package/packages/hub/src/questions/plan-prompts.ts +110 -0
- package/packages/hub/src/questions/planner.ts +382 -0
- package/packages/hub/src/questions/plans.ts +353 -0
- package/packages/hub/src/questions/review.ts +253 -0
- package/packages/hub/src/questions/setting.ts +50 -0
- package/packages/hub/src/questions/testing.ts +131 -0
- package/packages/hub/src/questions/worker.ts +182 -0
- package/packages/hub/src/resources/context.ts +58 -20
- package/packages/hub/src/resources/create.ts +16 -4
- package/packages/hub/src/resources/env.ts +4 -0
- package/packages/hub/src/resources/fns.ts +6 -2
- package/packages/hub/src/resources/index.ts +8 -2
- package/packages/hub/src/resources/testing.ts +18 -2
- package/packages/hub/src/store/codec.ts +23 -5
- package/packages/hub/src/store/context-status.ts +56 -0
- package/packages/hub/src/store/derived.ts +53 -0
- package/packages/hub/src/store/hybrid.ts +33 -6
- package/packages/hub/src/store/lists.ts +2 -1
- package/packages/hub/src/store/migrate-fn-names.ts +5 -2
- package/packages/hub/src/store/rows.ts +8 -1
- package/packages/hub/src/store/schema.ts +2 -1
- package/packages/hub/src/store/sqlite.ts +2 -1
- package/packages/hub/src/stores/backups.ts +163 -0
- package/packages/hub/src/stores/drivers.ts +100 -0
- package/packages/hub/src/stores/guard.ts +116 -0
- package/packages/hub/src/stores/host.ts +459 -0
- package/packages/hub/src/stores/moves.ts +380 -0
- package/packages/hub/src/stores/plugin.ts +42 -0
- package/packages/hub/src/stores/service.ts +340 -0
- package/packages/hub/src/stores/testing.ts +149 -0
- package/packages/sdk/AUTHORING.md +1813 -218
- package/packages/sdk/package.json +12 -8
- package/packages/sdk/src/build.ts +3 -0
- package/packages/sdk/src/client.ts +22 -0
- package/packages/sdk/src/ctx.ts +51 -17
- package/packages/sdk/src/declare.ts +36 -12
- package/packages/sdk/src/hub.ts +222 -10
- package/packages/sdk/src/impl.ts +3 -3
- package/packages/sdk/src/index.ts +6 -3
- package/packages/sdk/src/manifest.ts +5 -0
- package/packages/sdk/src/providers.ts +2 -2
- package/packages/sdk/src/server/asks.ts +12 -1
- package/packages/sdk/src/server/env.ts +13 -1
- package/packages/sdk/src/server/host.ts +81 -10
- package/packages/sdk/src/server/index.ts +21 -2
- package/packages/sdk/src/server/package.ts +11 -2
- package/packages/sdk/src/server/run.ts +6 -1
- package/packages/sdk/src/server/runtime.ts +78 -22
- package/packages/sdk/src/server/start-gate.ts +174 -0
- package/packages/sdk/src/server/store/checksum.ts +162 -0
- package/packages/sdk/src/server/store/engines.ts +400 -0
- package/packages/sdk/src/server/store/extend.ts +25 -0
- package/packages/sdk/src/server/store/keeper.ts +392 -0
- package/packages/sdk/src/server/store/link-driver.ts +142 -0
- package/packages/sdk/src/server/store/measure.ts +45 -0
- package/packages/sdk/src/server/store/migrations.ts +238 -0
- package/packages/sdk/src/server/store/move.ts +488 -0
- package/packages/sdk/src/server/store/portable.ts +288 -0
- package/packages/sdk/src/server/store/stable.ts +146 -0
- package/packages/sdk/src/server/store/tables.ts +28 -0
- package/packages/sdk/src/server/store/vectors.ts +185 -0
- package/packages/sdk/src/server/store/work-checks.ts +288 -0
- package/packages/sdk/src/server/store/work.ts +369 -0
- package/packages/sdk/src/server/table.ts +3 -1
- package/packages/sdk/src/server/testing.ts +116 -3
- package/packages/sdk/src/store.ts +91 -0
- package/packages/sdk/src/system.ts +58 -30
- package/packages/sdk/src/testing/hub.ts +18 -5
- package/packages/web/dist/assets/{ActorSettingsView-BuMYRDqv.js → ActorSettingsView-v2k7v454.js} +2 -2
- package/packages/web/dist/assets/{AdminLayout-sLjVTrmV.js → AdminLayout-B6Jrc_4W.js} +2 -2
- package/packages/web/dist/assets/{ApiServiceForm-BrMTU-7u.js → ApiServiceForm-CuuQgOJc.js} +2 -2
- package/packages/web/dist/assets/{ApiServiceView-BMF2zD6Q.js → ApiServiceView-7bTHSO_Z.js} +2 -2
- package/packages/web/dist/assets/{ApiServicesView-bjLAWO_j.js → ApiServicesView-BXi24n49.js} +2 -2
- package/packages/web/dist/assets/{AppPage-DSzDKCFz.js → AppPage-CFmKZS8G.js} +2 -2
- package/packages/web/dist/assets/{AutoPairPicker-nV38ALjl.js → AutoPairPicker-C61gihmh.js} +2 -2
- package/packages/web/dist/assets/{BrowserFrame-Bic7U7jN.js → BrowserFrame-Sq9EmQRT.js} +2 -2
- package/packages/web/dist/assets/{ChartVisual-DWw7WsfN.js → ChartVisual-C4mgw4wh.js} +4 -4
- package/packages/web/dist/assets/ChatPage-CAhHE03Z.js +4 -0
- package/packages/web/dist/assets/{CodeViewer-xHS3Xah9.js → CodeViewer-tUNXZB77.js} +2 -2
- package/packages/web/dist/assets/{ConfigWithCustom-DreTUdf0.js → ConfigWithCustom-D_-rY66L.js} +3 -3
- package/packages/web/dist/assets/{ConfirmDialog-DjQUzNqk.js → ConfirmDialog-Dd3E4sJt.js} +2 -2
- package/packages/web/dist/assets/{ConnectPage-CfRDrXvJ.js → ConnectPage-CX9acyQH.js} +2 -2
- package/packages/web/dist/assets/ContextItemPage-Cv4G0k_o.css +1 -0
- package/packages/web/dist/assets/ContextItemPage-rUI3-T_L.js +2 -0
- package/packages/web/dist/assets/ContextPage-C8u0UnYl.css +1 -0
- package/packages/web/dist/assets/ContextPage-CtefzyKg.js +3 -0
- package/packages/web/dist/assets/ContextRow-Chx99Xac.css +1 -0
- package/packages/web/dist/assets/ContextRow-DrtPumZ5.js +2 -0
- package/packages/web/dist/assets/{DataPage-wSIoGcb5.js → DataPage-DDSsxHro.js} +2 -2
- package/packages/web/dist/assets/DataTypePage-BW9fWaz8.js +2 -0
- package/packages/web/dist/assets/{DesignPage-DidMUX8m.js → DesignPage-6e0XbOFC.js} +2 -2
- package/packages/web/dist/assets/{ExplorePage-MUyVydVB.js → ExplorePage-B7ND0W0l.js} +2 -2
- package/packages/web/dist/assets/{FnList-CjQRwYaT.js → FnList-Bx6H-kux.js} +2 -2
- package/packages/web/dist/assets/{FnPill-BshAvm2I.js → FnPill-Cp3KuLmP.js} +2 -2
- package/packages/web/dist/assets/FnView-C0XZdnsS.js +2 -0
- package/packages/web/dist/assets/{FnsView-CeqIoaBT.js → FnsView-GTH3p7a0.js} +2 -2
- package/packages/web/dist/assets/{GinExprView-DYVUwZrd.js → GinExprView-DGxns6lH.js} +2 -2
- package/packages/web/dist/assets/{GinForm-D3mwMRTQ.js → GinForm-BDBUzuDP.js} +2 -2
- package/packages/web/dist/assets/{GinTypeView-C0YifSmE.js → GinTypeView-CUsymbVf.js} +2 -2
- package/packages/web/dist/assets/{GinValueView-HfEPq9le.js → GinValueView-jsKIfiEA.js} +2 -2
- package/packages/web/dist/assets/{GraphPage-ySnuA4Hp.js → GraphPage-BCcPPsHu.js} +2 -2
- package/packages/web/dist/assets/{GraphPanel-Cy5-KGo1.js → GraphPanel-9tztGHmu.js} +2 -2
- package/packages/web/dist/assets/{HubPicker-C_vA752L.js → HubPicker-EoOErgmk.js} +2 -2
- package/packages/web/dist/assets/{InboxApprovals-DcPCCmZ5.js → InboxApprovals-Dkq7DFp_.js} +2 -2
- package/packages/web/dist/assets/{InboxPage-C2DT2nuF.js → InboxPage-CHhslePq.js} +2 -2
- package/packages/web/dist/assets/{InjectedList-CJsEFEbz.js → InjectedList-CSWqRiON.js} +2 -2
- package/packages/web/dist/assets/InstallDialog-D-VwfZYF.js +2 -0
- package/packages/web/dist/assets/{InstallDialog-yWLZK_zN.css → InstallDialog-K-j0sdHm.css} +1 -1
- package/packages/web/dist/assets/InstanceTypes-CwVSAULg.css +1 -0
- package/packages/web/dist/assets/InstanceTypes-D3rAEiE7.js +2 -0
- package/packages/web/dist/assets/InstanceView-DoH8C-1j.js +2 -0
- package/packages/web/dist/assets/InstanceView-_9uE70tS.css +1 -0
- package/packages/web/dist/assets/{ItemHistory-CUGa8b6s.js → ItemHistory-NQAP69ma.js} +2 -2
- package/packages/web/dist/assets/LimitsView-DY2C9nYS.js +2 -0
- package/packages/web/dist/assets/ListSearch-BunVrDO0.js +2 -0
- package/packages/web/dist/assets/{LlmCallDetails-2yQftCqd.js → LlmCallDetails-BoVNDTVs.js} +2 -2
- package/packages/web/dist/assets/{LlmCallsView-DOHX3r0K.js → LlmCallsView-BGpV92RC.js} +2 -2
- package/packages/web/dist/assets/{LoadState-DeXfLvYv.js → LoadState-h-K9bTYc.js} +2 -2
- package/packages/web/dist/assets/{McpDialog-CA_0WKWF.js → McpDialog-DhOCk6_E.js} +2 -2
- package/packages/web/dist/assets/{McpServerForm-CAG8Wp2N.js → McpServerForm-Cor3fI7s.js} +2 -2
- package/packages/web/dist/assets/McpServerView-ewXRPEmZ.js +2 -0
- package/packages/web/dist/assets/McpServersView-Dd0xmfws.js +2 -0
- package/packages/web/dist/assets/{McpView-CC2oNOMa.js → McpView-GPXdCMne.js} +2 -2
- package/packages/web/dist/assets/{McpsView-CwJvyyxV.js → McpsView-DJIR2JX5.js} +2 -2
- package/packages/web/dist/assets/{MemoryDialog-Dbvh5uLq.js → MemoryDialog-BTeIHQyA.js} +2 -2
- package/packages/web/dist/assets/{ModelCallsView-RvnW3EBP.js → ModelCallsView-DMcnwF2S.js} +2 -2
- package/packages/web/dist/assets/{ModelPicker-DcjwQFHC.js → ModelPicker-CgkMFxSO.js} +2 -2
- package/packages/web/dist/assets/ModelsView-cMHygeiK.js +2 -0
- package/packages/web/dist/assets/{NotFoundPage-CeSwzTV-.js → NotFoundPage-Tk92K7HN.js} +2 -2
- package/packages/web/dist/assets/PairPage-D0BK8CCw.js +2 -0
- package/packages/web/dist/assets/PairPage-D_aPS1Ot.css +1 -0
- package/packages/web/dist/assets/{PanelHost-BkrFAnPa.js → PanelHost-C-gKrxAk.js} +2 -2
- package/packages/web/dist/assets/{PeopleView-D1QGPYp7.js → PeopleView-DRfeNWK5.js} +2 -2
- package/packages/web/dist/assets/PoliciesView-BRi-QAuo.js +2 -0
- package/packages/web/dist/assets/{RefusalList-DQoyUoPG.js → RefusalList-DVO0bmeB.js} +2 -2
- package/packages/web/dist/assets/{RemoteAuthFields-nxGWfmhf.js → RemoteAuthFields-CgiufuqQ.js} +2 -2
- package/packages/web/dist/assets/{ResourceViewer-Po24y4pj.js → ResourceViewer-Do0chYxU.js} +2 -2
- package/packages/web/dist/assets/ResourcesPage-BBx2u2mw.js +2 -0
- package/packages/web/dist/assets/{ResultGrid-uoq4yUYj.js → ResultGrid-Bj-0I5HY.js} +2 -2
- package/packages/web/dist/assets/{ReviewSummaryStrip-k3HevESg.js → ReviewSummaryStrip-DO3p64Qj.js} +2 -2
- package/packages/web/dist/assets/ReviewView-DZF9E1hb.js +3 -0
- package/packages/web/dist/assets/{RuleRow-CoXDA-SH.js → RuleRow-DX9v4iGP.js} +2 -2
- package/packages/web/dist/assets/{RunCard-CBSGdwdQ.js → RunCard-BnrtK2Yp.js} +2 -2
- package/packages/web/dist/assets/{RunDetails-CGhQQ6OI.js → RunDetails-DjR206q6.js} +2 -2
- package/packages/web/dist/assets/{RunDot-Ch_45985.js → RunDot-lHRICdM5.js} +2 -2
- package/packages/web/dist/assets/{RunPage-C_t20pB7.js → RunPage-CbAQ_WPR.js} +2 -2
- package/packages/web/dist/assets/{RunProgress-VrZUHUEC.js → RunProgress-C3-B4tQf.js} +2 -2
- package/packages/web/dist/assets/RunsView-DMkPmkqX.js +2 -0
- package/packages/web/dist/assets/ServiceRows-4WythFpF.js +2 -0
- package/packages/web/dist/assets/{ServiceRows-6BU4-MeL.css → ServiceRows-HPQ0pN6b.css} +1 -1
- package/packages/web/dist/assets/SettingsPage-BN4oSzoL.js +3 -0
- package/packages/web/dist/assets/{SignInPage-DrXZ1sG2.js → SignInPage-ByqGEZfj.js} +2 -2
- package/packages/web/dist/assets/{StatusBadge-Dpb9uG5e.js → StatusBadge-CXne0sRZ.js} +2 -2
- package/packages/web/dist/assets/StorePlacementStep-B6SwTmdM.js +2 -0
- package/packages/web/dist/assets/StorePlacementStep-D_G4e3ue.css +1 -0
- package/packages/web/dist/assets/{SystemConfig-72qKRkUk.js → SystemConfig-vQDL_eUl.js} +2 -2
- package/packages/web/dist/assets/{SystemPageHost-DLNg2FYK.js → SystemPageHost-DrMrEPyh.js} +2 -2
- package/packages/web/dist/assets/SystemView-Be6TBM4j.js +2 -0
- package/packages/web/dist/assets/{SystemView-C8ScHUe2.css → SystemView-_9q6eDfV.css} +1 -1
- package/packages/web/dist/assets/{SystemsView-B6HEL9VS.css → SystemsView-CWKnupLW.css} +1 -1
- package/packages/web/dist/assets/SystemsView-DZtT3laz.js +2 -0
- package/packages/web/dist/assets/{TableViewer-BQ7bYLOP.js → TableViewer-Boxx86f5.js} +3 -3
- package/packages/web/dist/assets/{ThemePicker-C2nJ21Vd.js → ThemePicker-CIg_oRQX.js} +2 -2
- package/packages/web/dist/assets/{TurnTree-CORdfTHj.js → TurnTree-Ecm0yA5g.js} +2 -2
- package/packages/web/dist/assets/UserMessage-BlnqZDVU.js +9 -0
- package/packages/web/dist/assets/{ValueVisual-aXEUaQ5Y.js → ValueVisual-C-MWpp7c.js} +2 -2
- package/packages/web/dist/assets/WidgetView-DX4ejNb6.js +3 -0
- package/packages/web/dist/assets/actor-names-OdvpVZeb.js +4 -0
- package/packages/web/dist/assets/{fn-modal-DqcxUhOQ.js → fn-modal-B98MR7JN.js} +2 -2
- package/packages/web/dist/assets/{fn-notices-BYaH6IoA.js → fn-notices-CfTa1E8y.js} +2 -2
- package/packages/web/dist/assets/{formats-DI__ADVG.js → formats-JwoKfXIq.js} +2 -2
- package/packages/web/dist/assets/index-6ScWTFy2.js +4 -0
- package/packages/web/dist/assets/{index-CSisx5mi.css → index-CEslGcrX.css} +1 -1
- package/packages/web/dist/assets/{labels-BhJpmLWA.js → labels-BFbk11BE.js} +2 -2
- package/packages/web/dist/assets/{layout-DQKldU13.js → layout-D1gf481r.js} +2 -2
- package/packages/web/dist/assets/{metrics-Cio5ykX6.js → metrics-CBPX3W5Y.js} +2 -2
- package/packages/web/dist/assets/{problems-BZY0Dwif.js → problems-t1E_ovSz.js} +2 -2
- package/packages/web/dist/assets/{push-payload-D5efGCzd.js → push-payload-BeU1ADYt.js} +64 -64
- package/packages/web/dist/assets/{record-edits-CveFEsal.js → record-edits-Bfsi4lU3.js} +2 -2
- package/packages/web/dist/assets/{remote-config-BkaarDf3.js → remote-config-BNQhSDzB.js} +2 -2
- package/packages/web/dist/assets/{review-CGUGvRV9.js → review-fP-l9D6H.js} +3 -3
- package/packages/web/dist/assets/routes-DV4IJpwe.js +4 -0
- package/packages/web/dist/assets/runs-CveC2kKo.js +2 -0
- package/packages/web/dist/assets/{shared-DTpYDMc_.js → shared-LbaIHjbV.js} +2 -2
- package/packages/web/dist/assets/{size-BwnshyOe.js → size-Bh__w5aI.js} +2 -2
- package/packages/web/dist/assets/{sources-Bm-TrxhL.js → sources-VPrtgLIi.js} +2 -2
- package/packages/web/dist/assets/src-CT3TeFaM.js +43 -0
- package/packages/web/dist/assets/state-xfQqaQPX.js +2 -0
- package/packages/web/dist/assets/{systems-DIp94AET.js → systems-BqE3WTSF.js} +2 -2
- package/packages/web/dist/assets/ui-BzgWquIU.js +17 -0
- package/packages/web/dist/assets/{ui-C7ZH_6oC.css → ui-DycHjPTZ.css} +1 -1
- package/packages/web/dist/assets/{url-BIg5IhGs.js → url-DKGcECT1.js} +2 -2
- package/packages/web/dist/assets/{widget-host-BCf6Tlt5.js → widget-host-B87MTaTn.js} +2 -2
- package/packages/web/dist/assets/{widgets-CrbkovMT.js → widgets-BBCuSS6E.js} +2 -2
- package/packages/web/dist/index.html +44 -44
- package/packages/web/dist/sw.js +1 -1
- package/packages/web/package.json +2 -2
- package/premade/claude.zip +0 -0
- package/premade/database.zip +0 -0
- package/premade/web.zip +0 -0
- package/scripts/dev-env.ts +4 -4
- package/scripts/run-stack.ts +3 -2
- package/scripts/stack.ts +115 -43
- package/scripts/start.ts +36 -17
- package/systems/api/package.json +3 -3
- package/systems/code/package.json +3 -3
- package/systems/embedder/package.json +1 -1
- package/systems/fs/client/fakes.ts +2 -0
- package/systems/fs/client/index.ts +4 -2
- package/systems/fs/client/machines/CoreHeatmap.vue +94 -0
- package/systems/fs/client/machines/MachineFiles.vue +121 -0
- package/systems/fs/client/machines/MachineMetrics.vue +330 -0
- package/systems/fs/client/machines/MachinesPage.vue +119 -0
- package/systems/fs/client/machines/TimeChart.vue +128 -0
- package/systems/fs/client/machines/fakes.ts +95 -0
- package/systems/fs/client/machines/files/ChangesPane.vue +90 -0
- package/systems/fs/client/machines/files/CodeView.vue +158 -0
- package/systems/fs/client/machines/files/CommentComposer.vue +86 -0
- package/systems/fs/client/machines/files/CommentThread.vue +115 -0
- package/systems/fs/client/machines/files/CommitPane.vue +80 -0
- package/systems/fs/client/machines/files/ComparePane.vue +81 -0
- package/systems/fs/client/machines/files/FileHistory.vue +89 -0
- package/systems/fs/client/machines/files/FilePane.vue +199 -0
- package/systems/fs/client/machines/files/FileTree.vue +26 -0
- package/systems/fs/client/machines/files/FolderPane.vue +154 -0
- package/systems/fs/client/machines/files/HistoryPane.vue +106 -0
- package/systems/fs/client/machines/files/ImageView.vue +160 -0
- package/systems/fs/client/machines/files/PatchView.vue +31 -0
- package/systems/fs/client/machines/files/QuickOpen.vue +67 -0
- package/systems/fs/client/machines/files/SearchPane.vue +87 -0
- package/systems/fs/client/machines/files/TreeNode.vue +72 -0
- package/systems/fs/client/machines/files/api.ts +127 -0
- package/systems/fs/client/machines/files/fake-kinds.ts +16 -0
- package/systems/fs/client/machines/files/fakes.ts +305 -0
- package/systems/fs/client/machines/files/ink.ts +117 -0
- package/systems/fs/client/machines/files/logic.ts +205 -0
- package/systems/fs/client/machines/files/state.ts +187 -0
- package/systems/fs/client/machines/files/viewers/CsvView.vue +29 -0
- package/systems/fs/client/machines/files/viewers/HexView.vue +27 -0
- package/systems/fs/client/machines/files/viewers/HtmlView.vue +17 -0
- package/systems/fs/client/machines/files/viewers/JsonNode.vue +45 -0
- package/systems/fs/client/machines/files/viewers/JsonView.vue +25 -0
- package/systems/fs/client/machines/metrics.ts +245 -0
- package/systems/fs/client/machines/palette.ts +97 -0
- package/systems/fs/client/preview/machines.ts +323 -0
- package/systems/fs/context/authoring/index.md +4 -0
- package/systems/fs/context/authoring/parts/actions.md +5 -1
- package/systems/fs/context/authoring/parts/actions.reference.md +6 -2
- package/systems/fs/context/authoring/parts/calling.md +5 -1
- package/systems/fs/context/authoring/parts/calling.reference.md +4 -0
- package/systems/fs/context/authoring/parts/client.md +9 -1
- package/systems/fs/context/authoring/parts/client.reference/client.md +4 -0
- package/systems/fs/context/authoring/parts/client.reference/resultview.md +56 -53
- package/systems/fs/context/authoring/parts/client.reference/{fnpillprops.md → textareaprops.md} +58 -4
- package/systems/fs/context/authoring/parts/client.reference.md +8 -4
- package/systems/fs/context/authoring/parts/context/questions.md +49 -0
- package/systems/fs/context/authoring/parts/context.md +23 -1
- package/systems/fs/context/authoring/parts/context.reference.md +27 -3
- package/systems/fs/context/authoring/parts/contract.md +10 -0
- package/systems/fs/context/authoring/parts/contract.reference.md +26 -9
- package/systems/fs/context/authoring/parts/core-types/access-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/admin-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/api-index-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/approvals-ts.md +11 -7
- package/systems/fs/context/authoring/parts/core-types/auto-pair-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/checks-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/claims-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/config-secrets-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/connections-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/context-files-ts.md +8 -0
- package/systems/fs/context/authoring/parts/core-types/context-graph-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/context-questions-ts.md +26 -0
- package/systems/fs/context/authoring/parts/core-types/contextdecl.md +9 -1
- package/systems/fs/context/authoring/parts/core-types/data-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/decisions-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/fn-block-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/fn-facts-ts.md +11 -0
- package/systems/fs/context/authoring/parts/core-types/gin-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/grants-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/lifecycle-ts.md +18 -5
- package/systems/fs/context/authoring/parts/core-types/link-ts.md +7 -3
- package/systems/fs/context/authoring/parts/core-types/llm-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/manifest.md +15 -2
- package/systems/fs/context/authoring/parts/core-types/manifestpatch.md +9 -1
- package/systems/fs/context/authoring/parts/core-types/mention-search-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/model-calls-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/model-names-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/modes-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/owner-runs-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/package-ts.md +9 -0
- package/systems/fs/context/authoring/parts/core-types/primitives-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/query-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-actors-ts.md +7 -3
- package/systems/fs/context/authoring/parts/core-types/records-chat-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-content-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-runs-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/records-systems-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/registries-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/remote-auth-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/resources-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/run-ts.md +7 -0
- package/systems/fs/context/authoring/parts/core-types/sensitivity-ts.md +5 -1
- package/systems/fs/context/authoring/parts/core-types/stores-ts.md +199 -0
- package/systems/fs/context/authoring/parts/core-types/system-events-ts.md +8 -1
- package/systems/fs/context/authoring/parts/core-types/system-pages-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/system-providers-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/validation-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/visuals-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/web-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types/widgets-ts.md +4 -0
- package/systems/fs/context/authoring/parts/core-types.md +12 -2
- package/systems/fs/context/authoring/parts/ctx/update-result.md +33 -0
- package/systems/fs/context/authoring/parts/ctx.md +11 -1
- package/systems/fs/context/authoring/parts/ctx.reference/{hubai.md → adminnotices.md} +45 -4
- package/systems/fs/context/authoring/parts/ctx.reference/fnctx.md +21 -23
- package/systems/fs/context/authoring/parts/ctx.reference.md +8 -4
- package/systems/fs/context/authoring/parts/data.md +11 -6
- package/systems/fs/context/authoring/parts/data.reference.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-findview-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-index-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-notecard-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-noteinput-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-notespage-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-reviewform-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/client-wordcount-vue.md +4 -0
- package/systems/fs/context/authoring/parts/examples/package-json.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-env-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-impl-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-index-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-main-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/server-notes-test-ts.md +4 -0
- package/systems/fs/context/authoring/parts/examples/shared-index-ts.md +10 -0
- package/systems/fs/context/authoring/parts/examples/system-json.md +4 -0
- 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
- 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
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-383-567.md +210 -0
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-568-660.md +117 -0
- package/systems/fs/context/authoring/parts/examples/tsconfig-json.md +5 -1
- package/systems/fs/context/authoring/parts/examples.md +18 -11
- package/systems/fs/context/authoring/parts/fns.md +5 -1
- package/systems/fs/context/authoring/parts/fns.reference/fillclaims.md +5 -1
- package/systems/fs/context/authoring/parts/fns.reference/fn.md +6 -2
- package/systems/fs/context/authoring/parts/fns.reference.md +4 -0
- package/systems/fs/context/authoring/parts/folder.md +4 -0
- package/systems/fs/context/authoring/parts/gin.md +4 -0
- package/systems/fs/context/authoring/parts/gin.reference.md +4 -0
- package/systems/fs/context/authoring/parts/handlers-progress.md +5 -1
- package/systems/fs/context/authoring/parts/handlers-progress.reference.md +4 -0
- package/systems/fs/context/authoring/parts/hooks.md +5 -1
- package/systems/fs/context/authoring/parts/hooks.reference.md +5 -1
- package/systems/fs/context/authoring/parts/hub/context-questions.md +40 -0
- package/systems/fs/context/authoring/parts/hub/{hub-run-background.md → hub-ctx-from-resource.md} +51 -56
- package/systems/fs/context/authoring/parts/hub/hub-fns-load.md +35 -42
- package/systems/fs/context/authoring/parts/hub/hub-install-package.md +327 -0
- package/systems/fs/context/authoring/parts/hub/kinds-of-hub.md +8 -0
- package/systems/fs/context/authoring/parts/hub.md +14 -8
- package/systems/fs/context/authoring/parts/hub.reference.md +9 -0
- package/systems/fs/context/authoring/parts/internals/manifestof.md +4 -0
- package/systems/fs/context/authoring/parts/internals/permissionargs.md +4 -0
- package/systems/fs/context/authoring/parts/internals/usagefromwire.md +47 -2
- package/systems/fs/context/authoring/parts/internals.md +6 -2
- package/systems/fs/context/authoring/parts/kinds-agents.md +5 -1
- package/systems/fs/context/authoring/parts/kinds-agents.reference/authoringsession.md +4 -0
- package/systems/fs/context/authoring/parts/kinds-agents.reference/kind.md +7 -3
- package/systems/fs/context/authoring/parts/kinds-agents.reference.md +4 -0
- package/systems/fs/context/authoring/parts/lifecycle.md +8 -3
- package/systems/fs/context/authoring/parts/lifecycle.reference.md +6 -2
- package/systems/fs/context/authoring/parts/mentions.md +5 -1
- package/systems/fs/context/authoring/parts/mentions.reference.md +6 -2
- package/systems/fs/context/authoring/parts/mistakes.md +7 -2
- package/systems/fs/context/authoring/parts/named-types.md +4 -0
- package/systems/fs/context/authoring/parts/named-types.reference.md +6 -2
- package/systems/fs/context/authoring/parts/outcomes.md +5 -1
- package/systems/fs/context/authoring/parts/outcomes.reference.md +4 -0
- package/systems/fs/context/authoring/parts/owner-runs.md +5 -1
- package/systems/fs/context/authoring/parts/owner-runs.reference.md +36 -11
- package/systems/fs/context/authoring/parts/packaging.md +10 -3
- package/systems/fs/context/authoring/parts/packaging.reference.md +7 -2
- package/systems/fs/context/authoring/parts/providers.md +5 -1
- package/systems/fs/context/authoring/parts/providers.reference.md +5 -1
- package/systems/fs/context/authoring/parts/remote.md +5 -1
- package/systems/fs/context/authoring/parts/remote.reference.md +4 -0
- package/systems/fs/context/authoring/parts/resources.md +5 -1
- package/systems/fs/context/authoring/parts/resources.reference.md +4 -0
- package/systems/fs/context/authoring/parts/server.md +5 -1
- package/systems/fs/context/authoring/parts/server.reference.md +41 -20
- package/systems/fs/context/authoring/parts/settings-attachments.md +5 -1
- package/systems/fs/context/authoring/parts/settings-attachments.reference.md +4 -0
- package/systems/fs/context/authoring/parts/start.md +5 -1
- package/systems/fs/context/authoring/parts/state-forms.md +5 -1
- package/systems/fs/context/authoring/parts/state-forms.reference.md +4 -0
- package/systems/fs/context/authoring/parts/store/ctx-store.md +49 -0
- package/systems/fs/context/authoring/parts/store/declare.md +32 -0
- package/systems/fs/context/authoring/parts/store/engines.md +25 -0
- package/systems/fs/context/authoring/parts/store/migrations.md +53 -0
- package/systems/fs/context/authoring/parts/store/moves.md +38 -0
- package/systems/fs/context/authoring/parts/store/placement.md +25 -0
- package/systems/fs/context/authoring/parts/store/serve.md +30 -0
- package/systems/fs/context/authoring/parts/store/store-tables.md +24 -0
- package/systems/fs/context/authoring/parts/store/vectors.md +32 -0
- package/systems/fs/context/authoring/parts/store/when-to-use.md +27 -0
- package/systems/fs/context/authoring/parts/store/work.md +37 -0
- package/systems/fs/context/authoring/parts/store.md +65 -0
- package/systems/fs/context/authoring/parts/store.reference.md +459 -0
- package/systems/fs/context/authoring/parts/testing.md +14 -1
- package/systems/fs/context/authoring/parts/testing.reference/{memoryjournal.md → equal.md} +55 -48
- package/systems/fs/context/authoring/parts/testing.reference/fakehub.md +26 -45
- package/systems/fs/context/authoring/parts/testing.reference/{toolcall.md → kindprops.md} +111 -4
- package/systems/fs/context/authoring/parts/testing.reference/openmemorystore.md +105 -0
- package/systems/fs/context/authoring/parts/testing.reference.md +16 -9
- package/systems/fs/context/authoring/parts/widgets.md +5 -1
- package/systems/fs/context/authoring/parts/widgets.reference/hub-visuals.md +4 -0
- package/systems/fs/context/authoring/parts/widgets.reference/sourcecompatible.md +4 -0
- package/systems/fs/context/authoring/parts/widgets.reference.md +4 -0
- package/systems/fs/context/authoring/topics/begin.md +4 -0
- package/systems/fs/context/authoring/topics/client.md +4 -0
- package/systems/fs/context/authoring/topics/declare.md +4 -0
- package/systems/fs/context/authoring/topics/examples.md +4 -0
- package/systems/fs/context/authoring/topics/fns.md +4 -0
- package/systems/fs/context/authoring/topics/server.md +4 -0
- package/systems/fs/context/authoring/topics/types.md +8 -1
- package/systems/fs/context/comments/answer.md +21 -0
- package/systems/fs/context/comments/find.md +23 -0
- package/systems/fs/context/comments/read.md +26 -0
- package/systems/fs/context/comments.md +23 -0
- package/systems/fs/context/files-page.md +30 -0
- package/systems/fs/context/guide/attachments.md +16 -0
- package/systems/fs/context/guide/change.md +23 -0
- package/systems/fs/context/guide/commands.md +19 -0
- package/systems/fs/context/guide/documents.md +21 -0
- package/systems/fs/context/guide/find.md +25 -0
- package/systems/fs/context/guide/paths.md +24 -0
- package/systems/fs/context/guide/read.md +21 -0
- package/systems/fs/context/machine/history.md +25 -0
- package/systems/fs/context/machine/now.md +25 -0
- package/systems/fs/context/machine/processes.md +20 -0
- package/systems/fs/context/machine/recording.md +19 -0
- package/systems/fs/context/machine.md +24 -0
- package/systems/fs/package.json +5 -3
- package/systems/fs/server/files-page/browse.ts +391 -0
- package/systems/fs/server/files-page/comments.ts +439 -0
- package/systems/fs/server/files-page/fns.ts +158 -0
- package/systems/fs/server/files-page/git-view.ts +391 -0
- package/systems/fs/server/files-page/kinds.ts +56 -0
- package/systems/fs/server/impl.ts +66 -7
- package/systems/fs/server/main.ts +20 -4
- package/systems/fs/server/metrics/collector.ts +424 -0
- package/systems/fs/server/metrics/index.ts +181 -0
- package/systems/fs/server/metrics/os.ts +144 -0
- package/systems/fs/server/metrics/parsers.ts +268 -0
- package/systems/fs/server/metrics/rrd.ts +363 -0
- package/systems/fs/server/metrics/testing.ts +80 -0
- package/systems/fs/server/snapshots.ts +216 -33
- package/systems/fs/server/testing.ts +15 -9
- package/systems/fs/shared/files-page.ts +506 -0
- package/systems/fs/shared/index.ts +137 -10
- package/systems/fs/shared/metrics.ts +179 -0
- package/systems/fs/system.json +10 -1
- package/systems/google-calendar/package.json +1 -1
- package/systems/input/package.json +3 -3
- package/systems/mcp/package.json +3 -3
- package/systems/mcp/server/oauth.ts +1 -1
- package/systems/ollama/package.json +3 -3
- package/systems/schedule/package.json +3 -4
- package/systems/schedule/server/env.ts +1 -1
- package/systems/schedule/server/fns.ts +5 -4
- package/systems/schedule/server/impl.ts +2 -2
- package/systems/schedule/server/import.ts +189 -0
- package/systems/schedule/server/index.ts +2 -0
- package/systems/schedule/server/main.ts +3 -1
- package/systems/schedule/server/placements.ts +41 -0
- package/systems/schedule/server/store.ts +159 -79
- package/systems/schedule/server/timer.ts +142 -107
- package/systems/schedule/shared/index.ts +2 -1
- package/systems/schedule/system.json +5 -1
- package/systems/schedule/tsconfig.json +1 -1
- package/systems/template/package.json +1 -1
- package/systems/widgets/package.json +3 -3
- package/packages/web/dist/assets/ChatPage-7Yebk7rl.js +0 -4
- package/packages/web/dist/assets/ContextItemPage-B6rJG3OT.js +0 -2
- package/packages/web/dist/assets/ContextItemPage-BRsWxOmu.css +0 -1
- package/packages/web/dist/assets/ContextPage-CloIZ_2y.js +0 -2
- package/packages/web/dist/assets/ContextPage-rYKxjiVI.css +0 -1
- package/packages/web/dist/assets/ContextRow-Byz_7HG-.css +0 -1
- package/packages/web/dist/assets/ContextRow-Dvv8CTFk.js +0 -2
- package/packages/web/dist/assets/DataTypePage-Ba_zBV4b.js +0 -4
- package/packages/web/dist/assets/FnView-B8MGAOoB.js +0 -2
- package/packages/web/dist/assets/InstallDialog-C9GDoUI2.js +0 -2
- package/packages/web/dist/assets/InstanceTypes-D8Jcxn70.js +0 -2
- package/packages/web/dist/assets/InstanceTypes-DAowwLB7.css +0 -1
- package/packages/web/dist/assets/InstanceView-CuBD3JPU.css +0 -1
- package/packages/web/dist/assets/InstanceView-p7tMaylE.js +0 -2
- package/packages/web/dist/assets/LimitsView-DsZG6u5P.js +0 -2
- package/packages/web/dist/assets/ListSearch-BK4p7Nxa.js +0 -2
- package/packages/web/dist/assets/McpServerView-CD8qw6W_.js +0 -2
- package/packages/web/dist/assets/McpServersView-DNycG35u.js +0 -2
- package/packages/web/dist/assets/ModelsView-C_iN19xt.js +0 -2
- package/packages/web/dist/assets/PairPage-Bs2KuRjC.css +0 -1
- package/packages/web/dist/assets/PairPage-TEXPpsqi.js +0 -2
- package/packages/web/dist/assets/PoliciesView-BU1fudNF.js +0 -2
- package/packages/web/dist/assets/ResourcesPage-YluNBqIv.js +0 -2
- package/packages/web/dist/assets/ReviewView-79Z5rU1v.js +0 -3
- package/packages/web/dist/assets/RunsView-Dz9Xsvu5.js +0 -2
- package/packages/web/dist/assets/ServiceRows-DNzDiutg.js +0 -2
- package/packages/web/dist/assets/SettingsPage-CykfuYj1.js +0 -3
- package/packages/web/dist/assets/SystemView-Es5wtkYU.js +0 -2
- package/packages/web/dist/assets/SystemsView-CeuSFhlF.js +0 -2
- package/packages/web/dist/assets/UserMessage-qyc8dG5D.js +0 -9
- package/packages/web/dist/assets/WidgetView-BZyDyYRI.js +0 -3
- package/packages/web/dist/assets/index-Bv42jNvr.js +0 -4
- package/packages/web/dist/assets/routes-qP_j74V5.js +0 -4
- package/packages/web/dist/assets/runs-k76usGfd.js +0 -2
- package/packages/web/dist/assets/src-DLK1P7oz.js +0 -43
- package/packages/web/dist/assets/state-CjE-qA2w.js +0 -2
- package/packages/web/dist/assets/ui-W12UYhVu.js +0 -17
- package/systems/claude/client/FleetPage.vue +0 -132
- package/systems/claude/client/NewSessionForm.vue +0 -62
- package/systems/claude/client/SessionList.vue +0 -64
- package/systems/claude/client/SessionPage.vue +0 -199
- package/systems/claude/client/TaskList.vue +0 -61
- package/systems/claude/client/fakes.ts +0 -186
- package/systems/claude/client/host.ts +0 -23
- package/systems/claude/client/index.ts +0 -15
- package/systems/claude/client/logic.ts +0 -270
- package/systems/claude/client/state.ts +0 -344
- package/systems/claude/package.json +0 -23
- package/systems/claude/server/agent-sdk.ts +0 -379
- package/systems/claude/server/driver.ts +0 -153
- package/systems/claude/server/env.ts +0 -64
- package/systems/claude/server/fake-driver.ts +0 -112
- package/systems/claude/server/fleet.ts +0 -376
- package/systems/claude/server/impl.ts +0 -568
- package/systems/claude/server/index.ts +0 -8
- package/systems/claude/server/main.ts +0 -38
- package/systems/claude/server/preview.ts +0 -76
- package/systems/claude/server/questions.ts +0 -117
- package/systems/claude/server/transcript.ts +0 -83
- package/systems/claude/shared/index.ts +0 -262
- package/systems/claude/shared/session.ts +0 -284
- package/systems/claude/shared/shapes.ts +0 -106
- package/systems/claude/system.json +0 -18
- package/systems/claude/tsconfig.json +0 -6
- package/systems/database/package.json +0 -25
- package/systems/database/server/author.ts +0 -41
- package/systems/database/server/authoring.ts +0 -322
- package/systems/database/server/catalog.ts +0 -117
- package/systems/database/server/compile.ts +0 -332
- package/systems/database/server/dialects.ts +0 -17
- package/systems/database/server/drivers/database.ts +0 -71
- package/systems/database/server/drivers/index.ts +0 -23
- package/systems/database/server/drivers/postgres.ts +0 -157
- package/systems/database/server/drivers/sqlite.ts +0 -151
- package/systems/database/server/drivers/sqlserver.ts +0 -176
- package/systems/database/server/env.ts +0 -35
- package/systems/database/server/fixture.ts +0 -169
- package/systems/database/server/impl.ts +0 -793
- package/systems/database/server/index.ts +0 -7
- package/systems/database/server/instance.ts +0 -398
- package/systems/database/server/main.ts +0 -47
- package/systems/database/server/pick.ts +0 -97
- package/systems/database/server/queries.ts +0 -390
- package/systems/database/server/results.ts +0 -39
- package/systems/database/server/schema.ts +0 -59
- package/systems/database/server/table-fns.ts +0 -237
- package/systems/database/server/types.ts +0 -253
- package/systems/database/shared/index.ts +0 -544
- package/systems/database/shared/shapes.ts +0 -413
- package/systems/database/system.json +0 -14
- package/systems/database/tsconfig.json +0 -6
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-371-533.md +0 -183
- package/systems/fs/context/authoring/parts/hub/hub-auto-pair-revoke.md +0 -189
- package/systems/web/client/ReadView.vue +0 -110
- package/systems/web/client/SearchView.vue +0 -215
- package/systems/web/client/StatusChip.vue +0 -38
- package/systems/web/client/fakes.ts +0 -48
- package/systems/web/client/index.ts +0 -15
- package/systems/web/client/view.ts +0 -131
- package/systems/web/package.json +0 -22
- package/systems/web/server/chrome.ts +0 -121
- package/systems/web/server/crawl.ts +0 -333
- package/systems/web/server/env.ts +0 -63
- package/systems/web/server/guard.ts +0 -60
- package/systems/web/server/http.ts +0 -89
- package/systems/web/server/impl.ts +0 -203
- package/systems/web/server/index.ts +0 -71
- package/systems/web/server/loader.ts +0 -104
- package/systems/web/server/main.ts +0 -70
- package/systems/web/server/mentions.ts +0 -111
- package/systems/web/server/problem.ts +0 -72
- package/systems/web/server/renderer.ts +0 -243
- package/systems/web/server/robots.ts +0 -75
- package/systems/web/server/searches.ts +0 -29
- package/systems/web/server/tavily.ts +0 -144
- package/systems/web/server/testing.ts +0 -165
- package/systems/web/server/uploads.ts +0 -33
- package/systems/web/shared/index.ts +0 -343
- package/systems/web/shared/urls.ts +0 -60
- package/systems/web/system.json +0 -15
- package/systems/web/tsconfig.json +0 -6
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plans (`hub/ctx_plan`, `hub/ctx_plan_get`, `hub/ctx_answer`, `hub/ctx_plan_expand` and the Context page's plan
|
|
3
|
+
* endpoints; plan `context-questions`). A plan is the saved result of the `hub/ctx_plan` run that made it (Phil: "It's
|
|
4
|
+
* a fn result that is technically saved"); answering, planning deeper and re-planning change that result through
|
|
5
|
+
* `RunService.updateResult`, which keeps one change of a run at a time and tells every chat showing the run.
|
|
6
|
+
*
|
|
7
|
+
* **Answering**: a question gets its picks (one or more options) and the person's words; it becomes `active`, with
|
|
8
|
+
* the options (picks marked) and the words as its content. Questions that sit only under options not picked become
|
|
9
|
+
* `not_applicable`, with the reason written for them ("You chose Postgres for 'Which database?'") unless the person
|
|
10
|
+
* wrote their own. Changing an answer brings back what sits under the new picks (answered ones `active`, the rest
|
|
11
|
+
* open again) and names the questions where planning deeper would help (`deeper`).
|
|
12
|
+
*
|
|
13
|
+
* **Who may**: everyone who can see context (Phil). Only items plans made (`hub/plan.q-…`) are written; an item that
|
|
14
|
+
* already had an answer in context is only read.
|
|
15
|
+
*/
|
|
16
|
+
import { reject } from '@ayepi/core';
|
|
17
|
+
import type { Logger } from '@ayepi/log';
|
|
18
|
+
import {
|
|
19
|
+
answerContent, ContextPlan, optionsContent, planAnswered, planCounts, planLimits, plannedStatus, planMarkdown, settlePlan, withStatus,
|
|
20
|
+
type ActorId, type ContextAnswerArgs, type ContextAnswerResult, type ContextPlanArgs, type ContextPlanExpandArgs, type ContextPlanGetArgs, type ContextPlansPage, type ContextPlansQuery,
|
|
21
|
+
type ContextPlanSummary, type ContextPlanView, type ContextRecord, type ContextStatus, Json, type PlanEdge, type PlanQuestion, type ProgressReport, type QualifiedName,
|
|
22
|
+
type ResolvedRole, type Run, type RunId,
|
|
23
|
+
} from '@harness/core';
|
|
24
|
+
import { hub } from '@harness/sdk';
|
|
25
|
+
import type { RunService } from '../execution/index.ts';
|
|
26
|
+
import { estimateTokens } from '../resources/rules.ts';
|
|
27
|
+
import type { HubStore } from '../store/index.ts';
|
|
28
|
+
import { metadataHash } from './metadata.ts';
|
|
29
|
+
import { PLAN_PURPOSE } from './plan-prompts.ts';
|
|
30
|
+
import { planMade, type ContextPlanner } from './planner.ts';
|
|
31
|
+
|
|
32
|
+
/** The fn whose runs are plans. */
|
|
33
|
+
export const PLAN_FN: QualifiedName = hub.fns.ctx_plan.name;
|
|
34
|
+
|
|
35
|
+
/** How many plans the list shows when the query doesn't say. */
|
|
36
|
+
const LIST_PAGE = 30;
|
|
37
|
+
|
|
38
|
+
/** Who is asking. */
|
|
39
|
+
export interface PlanAsker {
|
|
40
|
+
readonly actor: ActorId;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** What a planning call gets from its run. */
|
|
44
|
+
export interface PlanRunCtx {
|
|
45
|
+
readonly run: RunId;
|
|
46
|
+
readonly signal: AbortSignal;
|
|
47
|
+
readonly progress?: (report: ProgressReport) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** What plans need. */
|
|
51
|
+
export interface ContextPlansDeps {
|
|
52
|
+
readonly store: HubStore;
|
|
53
|
+
readonly clock: () => number;
|
|
54
|
+
readonly log: Logger;
|
|
55
|
+
readonly planner: ContextPlanner;
|
|
56
|
+
/** The plan role's model now, or undefined while it has none. */
|
|
57
|
+
readonly planModel: () => Promise<ResolvedRole | undefined>;
|
|
58
|
+
/** Whether a decision model can be used now (the matching needs one). */
|
|
59
|
+
readonly decideReady: () => Promise<boolean>;
|
|
60
|
+
/** Whether an embedder is up (the matching searches by meaning). */
|
|
61
|
+
readonly embedderReady: () => boolean;
|
|
62
|
+
readonly runs: () => Pick<RunService, 'get' | 'updateResult'>;
|
|
63
|
+
/** Store an item with its edges and index rows, and say it changed. */
|
|
64
|
+
readonly write: (record: ContextRecord) => Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What planning says when there is no embedder. An embedder never comes from a provider configured under Models
|
|
69
|
+
* (OpenRouter, OpenAI): only from a system that offers an embedding model (`index/embedders.ts`).
|
|
70
|
+
*/
|
|
71
|
+
export const EMBEDDER_MISSING = 'an embedder (embedders come only from systems, not from the providers under Models: the embedder system, which starts with the hub when HARNESS_EMBEDDER_URL names an EmbeddingGemma service, or the ollama system with an embedding model named in HARNESS_EMBEDDER_DOCUMENT and HARNESS_EMBEDDER_QUERY)';
|
|
72
|
+
|
|
73
|
+
/** Why planning can't run now, said to whoever asked. */
|
|
74
|
+
export class PlanNotReady extends Error {}
|
|
75
|
+
|
|
76
|
+
/** Plans: made, read, listed, answered and grown. */
|
|
77
|
+
export class ContextPlans {
|
|
78
|
+
readonly #deps: ContextPlansDeps;
|
|
79
|
+
|
|
80
|
+
constructor(deps: ContextPlansDeps) {
|
|
81
|
+
this.#deps = deps;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The plan model, or why planning can't run: it needs an embedder, a decision model and a plan model. */
|
|
85
|
+
async model(): Promise<ResolvedRole> {
|
|
86
|
+
const missing: string[] = [];
|
|
87
|
+
if (!this.#deps.embedderReady()) missing.push(EMBEDDER_MISSING);
|
|
88
|
+
if (!(await this.#deps.decideReady())) missing.push('a decision model (the Decisions role)');
|
|
89
|
+
const model = await this.#deps.planModel();
|
|
90
|
+
if (model === undefined) missing.push('a plan model (the Context plans role)');
|
|
91
|
+
if (missing.length > 0 || model === undefined) throw new PlanNotReady(`Planning needs ${missing.join(', ')}; ask an admin to set ${missing.length === 1 ? 'it' : 'them'} up.`);
|
|
92
|
+
return model;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** `hub/ctx_plan`: a new plan within its limits (the run's result). */
|
|
96
|
+
async plan(args: ContextPlanArgs, who: PlanAsker, ctx: PlanRunCtx): Promise<ContextPlan> {
|
|
97
|
+
const model = await this.model();
|
|
98
|
+
const limits = planLimits(args.limits);
|
|
99
|
+
const started = this.#deps.clock();
|
|
100
|
+
const grown = await this.#deps.planner.create(args.description, { model, limits, maxDepth: limits.depth, run: ctx.run, signal: ctx.signal, ...(ctx.progress === undefined ? {} : { progress: ctx.progress }) });
|
|
101
|
+
const plan: ContextPlan = {
|
|
102
|
+
description: args.description, limits, stop: grown.stop, cost: grown.cost, time: this.#deps.clock() - started, startedAt: started, updatedAt: this.#deps.clock(),
|
|
103
|
+
roots: grown.roots, questions: grown.questions, counts: planCounts(grown), revision: 0,
|
|
104
|
+
};
|
|
105
|
+
const settled = await this.#settle(plan, who.actor);
|
|
106
|
+
this.#deps.log.info('context.plan.made', { run: ctx.run, questions: plan.questions.length, stop: plan.stop, cost: plan.cost, by: who.actor });
|
|
107
|
+
return settled.plan;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** `hub/ctx_plan_get`: a plan as it is now, its questions' statuses read from their items; markdown when asked. */
|
|
111
|
+
async get(args: ContextPlanGetArgs, _who: PlanAsker): Promise<ContextPlanView> {
|
|
112
|
+
const { run, plan } = await this.#read(args.run);
|
|
113
|
+
const fresh = await this.#withItems(plan);
|
|
114
|
+
return { run: run.id, plan: fresh, ...(args.format === 'markdown' ? { markdown: planMarkdown(fresh) } : {}) };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The Context page's list: plans newest first (every plan is listed to everyone who can see context). */
|
|
118
|
+
async list(query: ContextPlansQuery, _who: PlanAsker): Promise<ContextPlansPage> {
|
|
119
|
+
const page = await this.#deps.store.table('runs').find({ where: { fn: PLAN_FN }, order: [['createdAt', 'desc']], limit: query.limit ?? LIST_PAGE });
|
|
120
|
+
const items = page.items.flatMap((run): ContextPlanSummary[] => {
|
|
121
|
+
const running = run.status !== 'done' && run.status !== 'failed' && run.status !== 'cancelled' && run.status !== 'undone' && run.status !== 'invalid-input';
|
|
122
|
+
const parsed = run.outcome?.status === 'done' ? ContextPlan.safeParse(run.outcome.result) : undefined;
|
|
123
|
+
if (parsed !== undefined && !parsed.success) return [];
|
|
124
|
+
if (parsed === undefined && !running) return [];
|
|
125
|
+
const description = parsed?.data.description ?? descriptionOf(run.args);
|
|
126
|
+
return [{
|
|
127
|
+
run: run.id, description, counts: parsed?.data.counts ?? { questions: 0, answered: 0, open: 0, ruledOut: 0, decide: 0 },
|
|
128
|
+
...(parsed === undefined ? {} : { stop: parsed.data.stop }), running, actor: run.actor, ...(run.session === undefined ? {} : { session: run.session }),
|
|
129
|
+
createdAt: run.createdAt, updatedAt: parsed?.data.updatedAt ?? run.createdAt,
|
|
130
|
+
}];
|
|
131
|
+
});
|
|
132
|
+
return { items };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** `hub/ctx_answer`: answer questions (and say why ruled-out ones don't apply); the plan run's result changes. */
|
|
136
|
+
async answer(args: ContextAnswerArgs, who: PlanAsker): Promise<ContextAnswerResult> {
|
|
137
|
+
await this.#read(args.run);
|
|
138
|
+
const skipped: ContextAnswerResult['skipped'] = [];
|
|
139
|
+
const deeper = new Set<QualifiedName>();
|
|
140
|
+
let changed: Array<{ name: QualifiedName; status: ContextStatus }> = [];
|
|
141
|
+
const updated = await this.#update(args.run, who.actor, async (plan) => {
|
|
142
|
+
const byName = new Map(plan.questions.map((question) => [question.name, question]));
|
|
143
|
+
const before = settlePlan(plan);
|
|
144
|
+
const newlyPicked: PlanEdge[] = [];
|
|
145
|
+
for (const answer of args.answers ?? []) {
|
|
146
|
+
const question = byName.get(answer.question);
|
|
147
|
+
if (question === undefined) { skipped.push({ question: answer.question, reason: 'that question is not in this plan' }); continue; }
|
|
148
|
+
if (question.known === true) { skipped.push({ question: answer.question, reason: 'it is answered in context already; change it on its context page' }); continue; }
|
|
149
|
+
const ids: string[] = [];
|
|
150
|
+
for (const pick of answer.picked) {
|
|
151
|
+
const option = question.options.find((one) => one.id === pick || one.label.toLowerCase() === pick.trim().toLowerCase());
|
|
152
|
+
if (option === undefined) { skipped.push({ question: answer.question, reason: `it has no option ${pick}` }); continue; }
|
|
153
|
+
if (!ids.includes(option.id)) ids.push(option.id);
|
|
154
|
+
}
|
|
155
|
+
for (const id of ids) if (!question.picked.includes(id)) newlyPicked.push({ question: question.name, option: id });
|
|
156
|
+
const text = (answer.text ?? '').trim();
|
|
157
|
+
question.picked = question.options.filter((option) => ids.includes(option.id)).map((option) => option.id);
|
|
158
|
+
if (text === '') delete question.text; else question.text = text;
|
|
159
|
+
if (planAnswered(question)) { question.answeredBy = who.actor; question.answeredAt = this.#deps.clock(); } else { delete question.answeredBy; delete question.answeredAt; }
|
|
160
|
+
}
|
|
161
|
+
for (const given of args.reasons ?? []) {
|
|
162
|
+
const question = byName.get(given.question);
|
|
163
|
+
if (question === undefined) { skipped.push({ question: given.question, reason: 'that question is not in this plan' }); continue; }
|
|
164
|
+
question.statusReason = given.reason;
|
|
165
|
+
question.reasonEdited = true;
|
|
166
|
+
}
|
|
167
|
+
const after = settlePlan(plan);
|
|
168
|
+
// where a new pick brought questions back or leads to questions with no options yet: offer to plan deeper there
|
|
169
|
+
for (const edge of newlyPicked) {
|
|
170
|
+
const option = byName.get(edge.question)?.options.find((one) => one.id === edge.option);
|
|
171
|
+
if (option === undefined) continue;
|
|
172
|
+
const unplanned = option.raises.some((name) => byName.get(name)?.planned === false) || (option.later?.length ?? 0) > 0;
|
|
173
|
+
const restored = option.raises.some((name) => before.get(name)?.live === false && after.get(name)?.live === true);
|
|
174
|
+
if (unplanned || restored) deeper.add(edge.question);
|
|
175
|
+
}
|
|
176
|
+
const settled = await this.#settle(plan, who.actor);
|
|
177
|
+
changed = settled.changed;
|
|
178
|
+
return settled.plan;
|
|
179
|
+
});
|
|
180
|
+
return { run: args.run, plan: updated, changed, deeper: [...deeper], skipped };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* `hub/ctx_plan_expand`: plan deeper under a question (or the whole plan), within limits of its own; with `replan`,
|
|
185
|
+
* the open questions under it get their options written again first. The work is done on a copy, then merged into
|
|
186
|
+
* the plan as it is by then, so answers given meanwhile are kept.
|
|
187
|
+
*/
|
|
188
|
+
async expand(args: ContextPlanExpandArgs, who: PlanAsker, ctx: PlanRunCtx): Promise<ContextPlanView> {
|
|
189
|
+
const model = await this.model();
|
|
190
|
+
const { plan: start } = await this.#read(args.run);
|
|
191
|
+
const plan = structuredClone(start);
|
|
192
|
+
const byName = new Map(plan.questions.map((question) => [question.name, question]));
|
|
193
|
+
if (args.under !== undefined && !byName.has(args.under)) throw reject(404, 'NO_QUESTION', `${args.under} is not a question of this plan`);
|
|
194
|
+
const settled = settlePlan(plan);
|
|
195
|
+
const scope = this.#under(plan, args.under, settled);
|
|
196
|
+
if (args.replan === true) this.#reset(plan, scope, args.under);
|
|
197
|
+
const limits = planLimits(args.limits);
|
|
198
|
+
const base = args.under === undefined ? Math.max(1, ...plan.questions.filter((question) => question.planned).map((question) => question.depth)) : (byName.get(args.under)?.depth ?? 1);
|
|
199
|
+
const live = settlePlan(plan);
|
|
200
|
+
const inScope = this.#under(plan, args.under, live);
|
|
201
|
+
const todo = plan.questions.filter((question) => inScope.has(question.name) && !question.planned && !planAnswered(question)).sort((a, b) => a.depth - b.depth).map((question) => question.name);
|
|
202
|
+
const laterOf = plan.questions.filter((question) => inScope.has(question.name)).flatMap((question) => question.options
|
|
203
|
+
.filter((option) => (option.later?.length ?? 0) > 0 && (question.picked.length === 0 || question.picked.includes(option.id)))
|
|
204
|
+
.map((option): PlanEdge => ({ question: question.name, option: option.id })));
|
|
205
|
+
const started = this.#deps.clock();
|
|
206
|
+
const grown = await this.#deps.planner.grow(plan, todo, laterOf, {
|
|
207
|
+
model, limits, maxDepth: base + limits.depth, run: ctx.run, signal: ctx.signal, ...(ctx.progress === undefined ? {} : { progress: ctx.progress }),
|
|
208
|
+
});
|
|
209
|
+
const spent = { cost: grown.cost, time: this.#deps.clock() - started };
|
|
210
|
+
const merged = await this.#update(args.run, who.actor, async (current) => {
|
|
211
|
+
const next = mergeGrown(current, grown.questions, grown.roots, spent, grown.stop);
|
|
212
|
+
return (await this.#settle(next, who.actor)).plan;
|
|
213
|
+
});
|
|
214
|
+
this.#deps.log.info('context.plan.expanded', { run: args.run, under: args.under, replan: args.replan === true, questions: merged.questions.length, stop: grown.stop, by: who.actor });
|
|
215
|
+
return { run: args.run, plan: merged };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** The plan run, and its plan; refused for a run that isn't a finished plan. */
|
|
219
|
+
async #read(id: RunId): Promise<{ readonly run: Run; readonly plan: ContextPlan }> {
|
|
220
|
+
const run = await this.#deps.runs().get(id);
|
|
221
|
+
if (run?.fn !== PLAN_FN) throw reject(404, 'NO_PLAN', `there is no plan ${id} (give the id of a hub/ctx_plan run)`);
|
|
222
|
+
if (run.status !== 'done' || run.outcome?.status !== 'done') throw reject(409, 'PLAN_NOT_READY', `plan ${id} is ${run.status === 'running' || run.status === 'queued' ? 'still being made' : run.status}`);
|
|
223
|
+
const parsed = ContextPlan.safeParse(run.outcome.result);
|
|
224
|
+
if (!parsed.success) throw reject(409, 'PLAN_UNREADABLE', `plan ${id} could not be read`);
|
|
225
|
+
return { run, plan: parsed.data };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Change the plan run's result: `change` gets the plan as it is now and gives the new one, with the revision bumped. */
|
|
229
|
+
async #update(id: RunId, by: ActorId, change: (plan: ContextPlan) => Promise<ContextPlan>): Promise<ContextPlan> {
|
|
230
|
+
let out: ContextPlan | undefined;
|
|
231
|
+
await this.#deps.runs().updateResult(id, async (current: Json): Promise<Json> => {
|
|
232
|
+
const parsed = ContextPlan.safeParse(current);
|
|
233
|
+
if (!parsed.success) throw reject(409, 'PLAN_UNREADABLE', `plan ${id} could not be read`);
|
|
234
|
+
const next = await change(structuredClone(parsed.data));
|
|
235
|
+
out = { ...next, revision: parsed.data.revision + 1, updatedAt: this.#deps.clock() };
|
|
236
|
+
return Json.parse(ContextPlan.parse(out));
|
|
237
|
+
}, by);
|
|
238
|
+
if (out === undefined) throw reject(409, 'PLAN_UNREADABLE', `plan ${id} could not be updated`);
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** The questions in play under one (itself included), or every question in play. */
|
|
243
|
+
#under(plan: Pick<ContextPlan, 'questions'>, under: QualifiedName | undefined, settled: ReturnType<typeof settlePlan>): Set<QualifiedName> {
|
|
244
|
+
const byName = new Map(plan.questions.map((question) => [question.name, question]));
|
|
245
|
+
if (under === undefined) return new Set(plan.questions.filter((question) => settled.get(question.name)?.live === true).map((question) => question.name));
|
|
246
|
+
const out = new Set<QualifiedName>([under]);
|
|
247
|
+
const queue = [under];
|
|
248
|
+
while (queue.length > 0) {
|
|
249
|
+
const question = byName.get(queue.shift() ?? under);
|
|
250
|
+
for (const option of question?.options ?? []) {
|
|
251
|
+
if (question !== undefined && question.picked.length > 0 && !question.picked.includes(option.id)) continue;
|
|
252
|
+
for (const child of option.raises) if (!out.has(child) && settled.get(child)?.live === true) { out.add(child); queue.push(child); }
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Re-planning: the open questions under one lose their options (and what they raised), to be written again. */
|
|
259
|
+
#reset(plan: ContextPlan, scope: ReadonlySet<QualifiedName>, under: QualifiedName | undefined): void {
|
|
260
|
+
for (const question of plan.questions) {
|
|
261
|
+
if (!scope.has(question.name) || question.name === under || question.known === true || planAnswered(question) || !question.planned) continue;
|
|
262
|
+
for (const option of question.options) for (const child of option.raises) {
|
|
263
|
+
const kid = plan.questions.find((one) => one.name === child);
|
|
264
|
+
if (kid !== undefined) kid.parents = kid.parents.filter((edge) => edge.question !== question.name);
|
|
265
|
+
}
|
|
266
|
+
question.options = [];
|
|
267
|
+
question.planned = false;
|
|
268
|
+
}
|
|
269
|
+
dropOrphans(plan);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Each question's status and reason from the plan, written to the items plans made; what changed, and the plan with its counts. */
|
|
273
|
+
async #settle(plan: ContextPlan, by: ActorId): Promise<{ readonly plan: ContextPlan; readonly changed: Array<{ name: QualifiedName; status: ContextStatus }> }> {
|
|
274
|
+
const { store, clock } = this.#deps;
|
|
275
|
+
const settled = settlePlan(plan);
|
|
276
|
+
const changed: Array<{ name: QualifiedName; status: ContextStatus }> = [];
|
|
277
|
+
for (const question of plan.questions) {
|
|
278
|
+
const live = settled.get(question.name)?.live === true;
|
|
279
|
+
const status = plannedStatus(question, live);
|
|
280
|
+
if (live && question.reasonEdited !== true) delete question.statusReason;
|
|
281
|
+
if (!live && question.reasonEdited !== true) question.statusReason = settled.get(question.name)?.reason;
|
|
282
|
+
if (!planMade(question.name) || question.known === true) { question.status = status; continue; }
|
|
283
|
+
const record = await store.table('context').get(question.name);
|
|
284
|
+
if (record === undefined) { question.status = status; continue; }
|
|
285
|
+
// a person hid it on the Context page: the plan leaves it hidden
|
|
286
|
+
if (record.status === 'hidden') { question.status = 'hidden'; continue; }
|
|
287
|
+
const content = planAnswered(question) ? answerContent(question) : optionsContent(question);
|
|
288
|
+
const reason = status === 'not_applicable' ? question.statusReason : undefined;
|
|
289
|
+
let next = record;
|
|
290
|
+
if (record.status !== status || (status === 'not_applicable' && record.statusReason !== reason)) next = withStatus(next, status, { by, reason, at: clock() });
|
|
291
|
+
if (next.decl.content !== content) next = { ...next, decl: { ...next.decl, content }, tokens: { full: estimateTokens(content), summary: next.tokens?.summary ?? 0 } };
|
|
292
|
+
if (next !== record) {
|
|
293
|
+
// the plan wrote its question, when and who asks: the metadata job leaves it (it would split the options apart)
|
|
294
|
+
await this.#deps.write({ ...next, metadata: { model: PLAN_PURPOSE, at: clock(), contentHash: metadataHash(next), fields: ['question', 'when', 'askedBy'] }, lastModified: clock(), updatedAt: clock() });
|
|
295
|
+
if (record.status !== status) changed.push({ name: question.name, status });
|
|
296
|
+
}
|
|
297
|
+
question.status = status;
|
|
298
|
+
}
|
|
299
|
+
return { plan: { ...plan, counts: planCounts(plan) }, changed };
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** The plan with each question's status and reason as its item has them now (a person may have changed one on the Context page). */
|
|
303
|
+
async #withItems(plan: ContextPlan): Promise<ContextPlan> {
|
|
304
|
+
const questions = await Promise.all(plan.questions.map(async (question): Promise<PlanQuestion> => {
|
|
305
|
+
const record = await this.#deps.store.table('context').get(question.name);
|
|
306
|
+
if (record === undefined) return question;
|
|
307
|
+
const { statusReason: _reason, ...rest } = question;
|
|
308
|
+
return { ...rest, status: record.status, ...(record.statusReason === undefined ? (question.reasonEdited === true && _reason !== undefined ? { statusReason: _reason } : {}) : { statusReason: record.statusReason }) };
|
|
309
|
+
}));
|
|
310
|
+
return { ...plan, questions };
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** The request a plan run was asked for, from its args. */
|
|
315
|
+
function descriptionOf(args: Json): string {
|
|
316
|
+
if (typeof args === 'object' && args !== null && !Array.isArray(args) && typeof args['description'] === 'string') return args['description'];
|
|
317
|
+
return 'A plan';
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Remove questions that no longer sit anywhere (not first questions, under no option), and what only they raised. */
|
|
321
|
+
export function dropOrphans(plan: ContextPlan): void {
|
|
322
|
+
for (;;) {
|
|
323
|
+
const named = new Set(plan.questions.map((question) => question.name));
|
|
324
|
+
const orphan = plan.questions.find((question) => !plan.roots.includes(question.name) && !question.parents.some((edge) => named.has(edge.question)));
|
|
325
|
+
if (orphan === undefined) return;
|
|
326
|
+
plan.questions = plan.questions.filter((question) => question.name !== orphan.name);
|
|
327
|
+
for (const question of plan.questions) {
|
|
328
|
+
question.parents = question.parents.filter((edge) => edge.question !== orphan.name);
|
|
329
|
+
for (const option of question.options) option.raises = option.raises.filter((name) => name !== orphan.name);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* The plan as it is now with what planning deeper grew merged in: each question's options, parents and level from the
|
|
336
|
+
* grown copy, its answer from now; new questions added; questions the grown copy dropped (re-planning) removed.
|
|
337
|
+
*/
|
|
338
|
+
export function mergeGrown(current: ContextPlan, grown: readonly PlanQuestion[], roots: readonly QualifiedName[], spent: { readonly cost: number; readonly time: number }, stop: ContextPlan['stop']): ContextPlan {
|
|
339
|
+
const now = new Map(current.questions.map((question) => [question.name, question]));
|
|
340
|
+
const questions = grown.map((question): PlanQuestion => {
|
|
341
|
+
const answered = now.get(question.name);
|
|
342
|
+
if (answered === undefined) return question;
|
|
343
|
+
return {
|
|
344
|
+
...question, picked: answered.picked.filter((id) => question.options.some((option) => option.id === id)),
|
|
345
|
+
...(answered.text === undefined ? {} : { text: answered.text }), ...(answered.answeredBy === undefined ? {} : { answeredBy: answered.answeredBy }),
|
|
346
|
+
...(answered.answeredAt === undefined ? {} : { answeredAt: answered.answeredAt }), status: answered.status,
|
|
347
|
+
...(answered.statusReason === undefined ? {} : { statusReason: answered.statusReason }), ...(answered.reasonEdited === undefined ? {} : { reasonEdited: answered.reasonEdited }),
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
const plan: ContextPlan = { ...current, roots: [...roots], questions, cost: current.cost + spent.cost, time: current.time + spent.time, stop };
|
|
351
|
+
dropOrphans(plan);
|
|
352
|
+
return plan;
|
|
353
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managing context as questions (plan `context-questions`): statuses set in bulk (`hub/ctx_status`), the Review queue
|
|
3
|
+
* (`hub/ctx_review`), merging duplicates (`hub/ctx_merge`), telling the hub two items aren't duplicates
|
|
4
|
+
* (`hub/ctx_not_duplicate`), filling metadata again now (`hub/ctx_reextract`), one item's metadata and history, and the
|
|
5
|
+
* admin's setting for new context. The web endpoints and the hub fns run these same operations.
|
|
6
|
+
*
|
|
7
|
+
* Who may: an admin does everything; the author of a memory may hide and restore their own memory (as `hub/forget`
|
|
8
|
+
* hides it). Every status change is kept in the item's history with who, why and when.
|
|
9
|
+
*/
|
|
10
|
+
import { reject } from '@ayepi/core';
|
|
11
|
+
import type { Logger } from '@ayepi/log';
|
|
12
|
+
import {
|
|
13
|
+
CONTEXT_REVIEW_KINDS, contextAnswered, DeclarableRelation, lastModifiedOf, seesOrigin, withStatus,
|
|
14
|
+
type ContextLink, type ContextMergeArgs, type ContextMergeResult, type ContextMetadataView, type ContextNotDuplicateArgs, type ContextRecord, type ContextReextractArgs,
|
|
15
|
+
type ContextReextractResult, type ContextReviewEntry, type ContextReviewItem, type ContextReviewKind, type ContextReviewPage, type ContextReviewQuery,
|
|
16
|
+
type ContextStatusAction, type ContextStatusArgs, type ContextStatusResult, type MetadataField, type NewContextStatus, type NewContextStatusView, type QualifiedName,
|
|
17
|
+
} from '@harness/core';
|
|
18
|
+
import type { ContextGraph } from '../contextor/index.ts';
|
|
19
|
+
import { removeLinksFrom } from '../contextor/graph.ts';
|
|
20
|
+
import type { Indexer } from '../index/index.ts';
|
|
21
|
+
import type { Asking } from '../resources/index.ts';
|
|
22
|
+
import { rows } from '../store/rows.ts';
|
|
23
|
+
import type { HubStore } from '../store/index.ts';
|
|
24
|
+
import { metadataHash, reviewKinds } from './pending.ts';
|
|
25
|
+
import { readNewContextStatus, writeNewContextStatus } from './setting.ts';
|
|
26
|
+
|
|
27
|
+
/** How many entries a Review page holds when the query doesn't say. */
|
|
28
|
+
const REVIEW_PAGE = 50;
|
|
29
|
+
/** The longest excerpt Review shows of an item. */
|
|
30
|
+
const EXCERPT = 300;
|
|
31
|
+
|
|
32
|
+
/** What managing context needs. */
|
|
33
|
+
export interface ContextReviewDeps {
|
|
34
|
+
readonly store: HubStore;
|
|
35
|
+
readonly graph: () => Pick<ContextGraph, 'links' | 'backlinks' | 'author' | 'remove' | 'derive' | 'replaceResourceLinks'>;
|
|
36
|
+
readonly indexer: () => Pick<Indexer, 'remove'>;
|
|
37
|
+
readonly clock: () => number;
|
|
38
|
+
readonly log: Logger;
|
|
39
|
+
readonly onContext?: (name: QualifiedName) => void;
|
|
40
|
+
/** Fill items' metadata again now (`hub/ctx_reextract`): the background job's one-item step. */
|
|
41
|
+
readonly reextract: (name: QualifiedName, signal: AbortSignal) => Promise<{ readonly fields: readonly MetadataField[]; readonly split?: readonly QualifiedName[] }>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The statuses each action starts from, and the one it gives (`removed`: the item goes). */
|
|
45
|
+
const ACTIONS: Readonly<Record<ContextStatusAction, { readonly from: readonly ContextRecord['status'][]; readonly to: ContextRecord['status'] | 'removed'; readonly not: string }>> = {
|
|
46
|
+
approve: { from: ['pending_approval'], to: 'active', not: 'it is not waiting for approval' },
|
|
47
|
+
hide: { from: ['active', 'not_applicable', 'pending_approval', 'pending_removal', 'pending_plan'], to: 'hidden', not: 'it is hidden already' },
|
|
48
|
+
restore: { from: ['hidden', 'not_applicable', 'pending_removal'], to: 'active', not: 'it is not hidden, ruled out or waiting for removal' },
|
|
49
|
+
confirm_removal: { from: ['pending_removal'], to: 'removed', not: 'it is not waiting for removal' },
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** An item as Review shows it. */
|
|
53
|
+
export function reviewItem(record: ContextRecord): ContextReviewItem {
|
|
54
|
+
const content = (record.decl.content ?? '').trim();
|
|
55
|
+
return {
|
|
56
|
+
name: record.name, system: record.system, title: record.decl.title ?? record.decl.description,
|
|
57
|
+
...(record.decl.question === undefined ? {} : { question: record.decl.question }), status: record.status,
|
|
58
|
+
...(record.statusReason === undefined ? {} : { statusReason: record.statusReason }), lastModified: lastModifiedOf(record),
|
|
59
|
+
...(content === '' ? {} : { excerpt: content.length > EXCERPT ? `${content.slice(0, EXCERPT - 1)}…` : content }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { reviewKinds };
|
|
64
|
+
|
|
65
|
+
/** Manages statuses, Review, merges and the setting. */
|
|
66
|
+
export class ContextReview {
|
|
67
|
+
readonly #deps: ContextReviewDeps;
|
|
68
|
+
|
|
69
|
+
constructor(deps: ContextReviewDeps) {
|
|
70
|
+
this.#deps = deps;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** `hub/ctx_status`: one action on each named item, with the reason kept. */
|
|
74
|
+
async setStatus(args: ContextStatusArgs, who: Asking): Promise<ContextStatusResult> {
|
|
75
|
+
const { store, clock, log } = this.#deps;
|
|
76
|
+
const rule = ACTIONS[args.action];
|
|
77
|
+
const result: ContextStatusResult = { changed: [], skipped: [] };
|
|
78
|
+
for (const name of new Set(args.names)) {
|
|
79
|
+
const record = await store.table('context').get(name);
|
|
80
|
+
if (record === undefined || !seesOrigin(record.origin, who)) { result.skipped.push({ name, reason: 'there is no such context item' }); continue; }
|
|
81
|
+
const own = record.origin?.type === 'memory' && record.origin.author === who.actor && (args.action === 'hide' || args.action === 'restore');
|
|
82
|
+
if (who.admin !== true && !own) { result.skipped.push({ name, reason: 'only an admin can do that (the author of a memory can hide and restore it)' }); continue; }
|
|
83
|
+
if (!rule.from.includes(record.status)) { result.skipped.push({ name, reason: rule.not }); continue; }
|
|
84
|
+
if (rule.to === 'removed') {
|
|
85
|
+
await this.#removeItem(record);
|
|
86
|
+
result.changed.push({ name, status: 'removed' });
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// a not-applicable item without an answer comes back as an open question, never as an active item with no text
|
|
90
|
+
const to = rule.to === 'active' && record.status === 'not_applicable' && !contextAnswered(record) ? 'pending_plan' : rule.to;
|
|
91
|
+
await store.table('context').put({ ...withStatus(record, to, { by: who.actor, reason: args.reason, at: clock() }), updatedAt: clock() });
|
|
92
|
+
this.#deps.onContext?.(name);
|
|
93
|
+
result.changed.push({ name, status: to });
|
|
94
|
+
}
|
|
95
|
+
log.info('context.status.set', { action: args.action, changed: result.changed.length, skipped: result.skipped.length, by: who.actor });
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** `hub/ctx_review`: the entries of the queue, newest change first, and how many of each kind there are. */
|
|
100
|
+
async review(query: ContextReviewQuery, who: Asking): Promise<ContextReviewPage> {
|
|
101
|
+
const { store } = this.#deps;
|
|
102
|
+
const kinds = new Set<ContextReviewKind>(query.kinds ?? CONTEXT_REVIEW_KINDS);
|
|
103
|
+
const systems = query.systems === undefined ? undefined : new Set(query.systems);
|
|
104
|
+
const counts = { duplicate: 0, contradiction: 0, pending_approval: 0, pending_removal: 0 };
|
|
105
|
+
const entries: Array<{ readonly at: number; readonly entry: ContextReviewEntry }> = [];
|
|
106
|
+
// only items in Review, by the column the store keeps (`store/derived.ts`): never a read of every item
|
|
107
|
+
for await (const record of rows(store.table('context'), { where: { inReview: true } })) {
|
|
108
|
+
if (!seesOrigin(record.origin, who) || (systems !== undefined && !systems.has(record.system))) continue;
|
|
109
|
+
for (const kind of reviewKinds(record)) {
|
|
110
|
+
counts[kind] += 1;
|
|
111
|
+
if (!kinds.has(kind)) continue;
|
|
112
|
+
const flag = kind === 'duplicate' ? record.duplicate : kind === 'contradiction' ? record.contradiction : undefined;
|
|
113
|
+
const other = flag === undefined ? undefined : await store.table('context').get(flag.of);
|
|
114
|
+
entries.push({
|
|
115
|
+
at: flag?.at ?? record.statusHistory?.at(-1)?.at ?? record.updatedAt,
|
|
116
|
+
entry: { kind, item: reviewItem(record), ...(other === undefined ? {} : { other: reviewItem(other) }), ...(flag === undefined ? {} : { flag }) },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
entries.sort((a, b) => b.at - a.at || a.entry.item.name.localeCompare(b.entry.item.name));
|
|
121
|
+
const offset = Number.parseInt(query.cursor ?? '0', 10) || 0;
|
|
122
|
+
const limit = query.limit ?? REVIEW_PAGE;
|
|
123
|
+
const page = entries.slice(offset, offset + limit).map((one) => one.entry);
|
|
124
|
+
return { items: page, counts, ...(entries.length > offset + limit ? { next: String(offset + limit) } : {}) };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** `hub/ctx_merge`: keep one item; links into the other and its mentions point at the kept one, its own drawn links move, and it is hidden. */
|
|
128
|
+
async merge(args: ContextMergeArgs, who: Asking): Promise<ContextMergeResult> {
|
|
129
|
+
const { store, clock, log } = this.#deps;
|
|
130
|
+
if (who.admin !== true) throw reject(403, 'ADMIN_ONLY', 'only an admin can merge context');
|
|
131
|
+
if (args.keep === args.drop) throw reject(422, 'SAME_ITEM', 'give two different items: one to keep and one to merge into it');
|
|
132
|
+
const [keep, drop] = await Promise.all([store.table('context').get(args.keep), store.table('context').get(args.drop)]);
|
|
133
|
+
if (keep === undefined) throw reject(404, 'NO_CONTEXT', `there is no context ${args.keep}`);
|
|
134
|
+
if (drop === undefined) throw reject(404, 'NO_CONTEXT', `there is no context ${args.drop}`);
|
|
135
|
+
const graph = this.#deps.graph();
|
|
136
|
+
const target = { kind: 'context' as const, name: keep.name };
|
|
137
|
+
let links = 0;
|
|
138
|
+
// edges into the dropped item that people drew or the hub made from a resource point at the kept one
|
|
139
|
+
for (const edge of await graph.backlinks({ kind: 'context', name: drop.name })) {
|
|
140
|
+
if (edge.from === keep.name || !movable(edge)) continue;
|
|
141
|
+
const relation = DeclarableRelation.safeParse(edge.relation);
|
|
142
|
+
if (!relation.success) continue;
|
|
143
|
+
await graph.author({ from: edge.from, to: target, relation: relation.data, weight: edge.weight, by: who.actor });
|
|
144
|
+
if (edge.source === 'authored') await graph.remove(edge);
|
|
145
|
+
links += 1;
|
|
146
|
+
}
|
|
147
|
+
// the dropped item's own drawn and resource edges move to the kept one
|
|
148
|
+
for (const edge of await graph.links(drop.name)) {
|
|
149
|
+
if (!movable(edge) || (edge.to.kind === 'context' && edge.to.name === keep.name)) continue;
|
|
150
|
+
const relation = DeclarableRelation.safeParse(edge.relation);
|
|
151
|
+
if (!relation.success) continue;
|
|
152
|
+
await graph.author({ from: keep.name, to: edge.to, relation: relation.data, weight: edge.weight, by: who.actor });
|
|
153
|
+
links += 1;
|
|
154
|
+
}
|
|
155
|
+
// mentions of the dropped item in other items' text count as mentions of the kept one
|
|
156
|
+
let mentions = 0;
|
|
157
|
+
for (const edge of await graph.backlinks({ kind: 'context', name: drop.name })) {
|
|
158
|
+
if (edge.relation !== 'mentions') continue;
|
|
159
|
+
const from = await store.table('context').get(edge.from);
|
|
160
|
+
if (from === undefined || !from.mentions.context.includes(drop.name)) continue;
|
|
161
|
+
const context = [...new Set(from.mentions.context.map((name) => (name === drop.name ? keep.name : name)))];
|
|
162
|
+
const moved = await store.table('context').put({ ...from, mentions: { ...from.mentions, context } });
|
|
163
|
+
await graph.derive(moved);
|
|
164
|
+
mentions += 1;
|
|
165
|
+
}
|
|
166
|
+
const at = clock();
|
|
167
|
+
const { duplicate: keptFlag, ...keptRest } = keep;
|
|
168
|
+
const kept: ContextRecord = keptFlag?.of === drop.name ? keptRest : keep;
|
|
169
|
+
await store.table('context').put(kept);
|
|
170
|
+
const { duplicate: _flag, ...dropRest } = drop;
|
|
171
|
+
await store.table('context').put({ ...withStatus(dropRest, 'hidden', { by: who.actor, reason: args.reason ?? `Merged into ${keep.name}.`, at }), updatedAt: at });
|
|
172
|
+
this.#deps.onContext?.(keep.name);
|
|
173
|
+
this.#deps.onContext?.(drop.name);
|
|
174
|
+
log.info('context.merged', { keep: keep.name, drop: drop.name, links, mentions, by: who.actor });
|
|
175
|
+
return { kept: keep.name, hidden: drop.name, links, mentions };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** `hub/ctx_not_duplicate`: clear the flag between two items and remember the pair on both. */
|
|
179
|
+
async notDuplicate(args: ContextNotDuplicateArgs, who: Asking): Promise<{ ok: boolean }> {
|
|
180
|
+
const { store } = this.#deps;
|
|
181
|
+
if (who.admin !== true) throw reject(403, 'ADMIN_ONLY', 'only an admin can clear a duplicate flag');
|
|
182
|
+
const pair = [[args.name, args.of], [args.of, args.name]] as const;
|
|
183
|
+
let found = false;
|
|
184
|
+
for (const [name, other] of pair) {
|
|
185
|
+
const record = await store.table('context').get(name);
|
|
186
|
+
if (record === undefined) continue;
|
|
187
|
+
found = true;
|
|
188
|
+
const { duplicate, ...rest } = record;
|
|
189
|
+
const next: ContextRecord = { ...(duplicate?.of === other ? rest : record), notDuplicates: [...new Set([...(record.notDuplicates ?? []), other])] };
|
|
190
|
+
await store.table('context').put(next);
|
|
191
|
+
this.#deps.onContext?.(name);
|
|
192
|
+
}
|
|
193
|
+
if (!found) throw reject(404, 'NO_CONTEXT', `there is no context ${args.name}`);
|
|
194
|
+
return { ok: true };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** `hub/ctx_reextract`: fill each item's metadata again now (and split it again), one after another. */
|
|
198
|
+
async reextract(args: ContextReextractArgs, who: Asking, signal: AbortSignal): Promise<ContextReextractResult> {
|
|
199
|
+
if (who.admin !== true) throw reject(403, 'ADMIN_ONLY', 'only an admin can fill context metadata again');
|
|
200
|
+
const result: ContextReextractResult = { done: [], failed: [] };
|
|
201
|
+
for (const name of new Set(args.names)) {
|
|
202
|
+
try {
|
|
203
|
+
const applied = await this.#deps.reextract(name, signal);
|
|
204
|
+
result.done.push({ name, fields: [...applied.fields], ...(applied.split === undefined ? {} : { split: [...applied.split] }) });
|
|
205
|
+
} catch (error) {
|
|
206
|
+
result.failed.push({ name, reason: error instanceof Error ? error.message : String(error) });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** One item's metadata and status history, for a person who may see it. */
|
|
213
|
+
async metadata(name: QualifiedName, who: Asking): Promise<ContextMetadataView> {
|
|
214
|
+
const record = await this.#deps.store.table('context').get(name);
|
|
215
|
+
if (record === undefined || !seesOrigin(record.origin, who)) throw reject(404, 'NO_CONTEXT', `there is no context ${name}`);
|
|
216
|
+
const { decl } = record;
|
|
217
|
+
return {
|
|
218
|
+
name: record.name, ...(decl.question === undefined ? {} : { question: decl.question }), ...(decl.when === undefined ? {} : { when: decl.when }),
|
|
219
|
+
...(record.askedBy === undefined ? {} : { askedBy: record.askedBy }), ...(record.validUntil === undefined ? {} : { validUntil: record.validUntil }),
|
|
220
|
+
lastModified: lastModifiedOf(record), status: record.status, ...(record.statusReason === undefined ? {} : { statusReason: record.statusReason }),
|
|
221
|
+
statusHistory: record.statusHistory ?? [], ...(record.metadata === undefined ? {} : { metadata: record.metadata }),
|
|
222
|
+
metadataStale: record.metadata !== undefined && record.metadata.contentHash !== metadataHash(record),
|
|
223
|
+
...(record.duplicate === undefined ? {} : { duplicate: record.duplicate }), ...(record.contradiction === undefined ? {} : { contradiction: record.contradiction }),
|
|
224
|
+
notDuplicates: record.notDuplicates ?? [], ...(record.split === undefined ? {} : { split: record.split }),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** The admin's setting for new context from systems and resources. */
|
|
229
|
+
newContextStatus(): Promise<NewContextStatusView> {
|
|
230
|
+
return readNewContextStatus(this.#deps.store);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async setNewContextStatus(value: NewContextStatus, who: Asking): Promise<NewContextStatusView> {
|
|
234
|
+
if (who.admin !== true) throw reject(403, 'ADMIN_ONLY', 'only an admin can change what new context starts as');
|
|
235
|
+
const view = await writeNewContextStatus(this.#deps.store, value, who.actor, this.#deps.clock());
|
|
236
|
+
this.#deps.log.info('context.new-status.set', { value, by: who.actor });
|
|
237
|
+
return view;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Remove an item for good: its record, its edges, its index rows (a confirmed removal). */
|
|
241
|
+
async #removeItem(record: ContextRecord): Promise<void> {
|
|
242
|
+
const { store } = this.#deps;
|
|
243
|
+
await this.#deps.graph().replaceResourceLinks(record.name, []);
|
|
244
|
+
await store.tx(async (tx) => { await tx.table('context').remove(record.name); await removeLinksFrom(tx, record.name); });
|
|
245
|
+
await this.#deps.indexer().remove('context', [record.name]);
|
|
246
|
+
this.#deps.onContext?.(record.name);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Whether a merge moves an edge: one a person drew, or the hub made from a resource (declared and mentioned edges follow their records). */
|
|
251
|
+
function movable(edge: ContextLink): boolean {
|
|
252
|
+
return edge.source === 'authored' || edge.source === 'resource';
|
|
253
|
+
}
|