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.
- package/README.md +102 -5
- package/package.json +12 -11
- 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/install.ts +103 -7
- 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/io.ts +1 -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 +10 -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/run-stack.ts +3 -2
- package/scripts/stack.ts +73 -16
- package/scripts/start.ts +11 -2
- 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/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
|
@@ -22,6 +22,7 @@ import type { Provider } from '@aeye/ai';
|
|
|
22
22
|
import type { ToolClaims } from '@aeye/core';
|
|
23
23
|
import { refuseOldEmbedders, type AnyContract, type ConnectImpl, type ContractShape, type EventHandlers, type Lifecycle, type SystemImpl } from '../system.ts';
|
|
24
24
|
import { expectType, type Equal } from '../util.ts';
|
|
25
|
+
import type { StoreDb, SystemStore } from '../store.ts';
|
|
25
26
|
|
|
26
27
|
/** Any outcome, as the runtime handles it before encoding it for the wire. */
|
|
27
28
|
export type AnyOutcome = Outcome<FnTypes>;
|
|
@@ -49,6 +50,7 @@ export interface OutcomeHelpers {
|
|
|
49
50
|
export interface RuntimeRunBase extends Services, OutcomeHelpers, Proposals, Decisions, Fleets, FnSearch, RunNotices {
|
|
50
51
|
readonly config: unknown;
|
|
51
52
|
readonly run: RunInfo;
|
|
53
|
+
readonly store: SystemStore<StoreDb> | undefined;
|
|
52
54
|
readonly budget: BudgetInfo;
|
|
53
55
|
readonly signal: AbortSignal;
|
|
54
56
|
readonly state: SessionState<Record<string, unknown>>;
|
|
@@ -191,7 +193,7 @@ expectType<Equal<keyof RuntimeKindCtx, keyof KindRunCtx<object>>>(true);
|
|
|
191
193
|
* that through a string-keyed lookup; this is the one place the SDK states it, and the pins above keep the two
|
|
192
194
|
* shapes in step.
|
|
193
195
|
*/
|
|
194
|
-
export function implTable<C extends ContractShape>(impl: SystemImpl<C>): ImplTable {
|
|
196
|
+
export function implTable<C extends ContractShape, Db extends StoreDb = StoreDb>(impl: SystemImpl<C, Db>): ImplTable {
|
|
195
197
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- see the doc comment: each context is built from its own declaration
|
|
196
198
|
return impl as unknown as ImplTable;
|
|
197
199
|
}
|
|
@@ -17,11 +17,12 @@ import {
|
|
|
17
17
|
type ConnectResult, type DecideAnswer, type KindEstimateAnswer, type FleetInstance, type HubModelInfo, type PreviewAnswer, type ProposedRun, type InstanceName, type ModelForward, type ModelForwardResult, type PairingInfo, type AdminNotice,
|
|
18
18
|
type AutoPairGrant, type ConfigValue, type Hello, type HandlerAnswer, type HubLinkSpec, type ImportReport, type JsonObject, type KindFnShape, type LinkSession, type LlmForward,
|
|
19
19
|
type LlmForwardChunk, type LogLine, type Manifest, type ManifestPatch, type OutcomeWire, type PairingId, type QualifiedName,
|
|
20
|
+
type StoreLease, type StoreLeaseId, type StoreMoveId, type StoreOpen, type StoreResult, type StoreSnapshotName, type StoreStatement, type StoreStatusReport,
|
|
20
21
|
type PairingGrant, type PairingGrantRequest, type KindFnWire, type StartedRun, RunId, TurnId, type ResourceRead, type ResourceHit, type MentionResourceSearch, type FlagsAnswer, type ClaimsAnswer, type ArgsCheckAnswer, type MentionOption as WireMentionOption, type RunControl, type Section, type RunInfo, type RunRequest, type RunSettled, type StateOwner, type SystemLinkSpec, type TypeDefinitions, type UserInfo, ActorId, SystemName,
|
|
21
22
|
} from '@harness/core';
|
|
22
23
|
import type { z } from 'zod';
|
|
23
24
|
import { g, parseValue } from '../gin.ts';
|
|
24
|
-
import type { AdminNotices, AiSource, Decisions, Fleets, FnSearch, InstanceConnects, OwnerRuns, Proposals, RunNotices, SystemPlace } from '../ctx.ts';
|
|
25
|
+
import type { AdminNotices, AiSource, Decisions, Fleets, FnSearch, InstanceConnects, OwnerRuns, Proposals, ResultUpdates, RunNotices, SystemPlace } from '../ctx.ts';
|
|
25
26
|
import { fakeHubAi, streamOf } from './fake-models.ts';
|
|
26
27
|
import { filledWire } from './llm-wire.ts';
|
|
27
28
|
import { FakeHubFns } from './fake-hub-fns.ts';
|
|
@@ -29,6 +30,11 @@ import { FakeHubWidgets } from './fake-hub-widgets.ts';
|
|
|
29
30
|
import { FakeRecords, type StoredTypeDecl } from './fake-records.ts';
|
|
30
31
|
import { contentHash } from './content.ts';
|
|
31
32
|
import { LinkHost, type LinkHostDeps } from './host.ts';
|
|
33
|
+
import { openLocalStore, openMemoryStore, type StoreConnection } from './store/engines.ts';
|
|
34
|
+
import { systemStore } from './store/keeper.ts';
|
|
35
|
+
import { Kysely, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler, type DatabaseConnection, type Driver } from 'kysely';
|
|
36
|
+
import { runMigrations, type Migration } from './store/migrations.ts';
|
|
37
|
+
import type { StoreDb, SystemStore } from '../store.ts';
|
|
32
38
|
import { MemoryJournal } from './journal.ts';
|
|
33
39
|
import { MemoryKeyStore, verifyNonce } from './keys.ts';
|
|
34
40
|
import { systemLogger } from './log.ts';
|
|
@@ -47,12 +53,14 @@ export type SystemBody<K extends keyof SystemLinkSpec['endpoints']> = SystemLink
|
|
|
47
53
|
export const TEST_PLACE: SystemPlace = { instance: MAIN_INSTANCE, dataDir: '.harness-test/data', cacheDir: '.harness-test/cache' };
|
|
48
54
|
|
|
49
55
|
/**
|
|
50
|
-
* `ctx.propose`, `ctx.decide`, `ctx.ai`, `ctx.runs` and `ctx.
|
|
56
|
+
* `ctx.propose`, `ctx.decide`, `ctx.ai`, `ctx.runs`, `ctx.notify` and `ctx.store` (none) for a hand-made test context that has no hub:
|
|
51
57
|
* proposing and starting runs fail (the test didn't expect them), the decision model is off, notices and kind fns are
|
|
52
58
|
* none, and `ctx.ai()` is an aeye `AI` over `FakeModelLink` answering `ok`.
|
|
53
59
|
* Spread it in beside `TEST_PLACE`; `FakeHub` serves the real ones.
|
|
54
60
|
*/
|
|
55
|
-
export const NO_ASKS: Proposals & Decisions & Fleets & FnSearch & AiSource & AdminNotices & InstanceConnects & OwnerRuns & RunNotices = {
|
|
61
|
+
export const NO_ASKS: Proposals & Decisions & Fleets & FnSearch & AiSource & AdminNotices & ResultUpdates & InstanceConnects & OwnerRuns & RunNotices & { readonly store: undefined } = {
|
|
62
|
+
// a hand-made context has no store; serve against FakeHub for one
|
|
63
|
+
store: undefined,
|
|
56
64
|
ai: () => fakeHubAi(),
|
|
57
65
|
propose: () => Promise.reject(new Error('This test context proposes no runs; serve against FakeHub to record them.')),
|
|
58
66
|
decide: () => Promise.resolve({ by: 'off' }),
|
|
@@ -60,6 +68,7 @@ export const NO_ASKS: Proposals & Decisions & Fleets & FnSearch & AiSource & Adm
|
|
|
60
68
|
searchFns: () => Promise.resolve({ items: [] }),
|
|
61
69
|
fnExamples: (query) => Promise.resolve({ fn: query.fn, items: [], total: 0 }),
|
|
62
70
|
notifyAdmins: () => Promise.resolve(),
|
|
71
|
+
updateResult: () => Promise.reject(new Error('This test context keeps no runs; serve against FakeHub to record result updates.')),
|
|
63
72
|
instanceConnect: () => Promise.resolve(),
|
|
64
73
|
runs: {
|
|
65
74
|
kindFns: () => Promise.resolve({ items: [] }),
|
|
@@ -210,8 +219,35 @@ export interface FakeHubOptions {
|
|
|
210
219
|
autoPair?: AutoPairGrant;
|
|
211
220
|
/** Refuse every hello that brings an auto-pair secret, as the hub does for an expired or revoked one. */
|
|
212
221
|
refuseAutoPair?: boolean;
|
|
222
|
+
/** Where the welcome says the system's store lives (default absent: with the system). */
|
|
223
|
+
store?: StoreOpen;
|
|
213
224
|
}
|
|
214
225
|
|
|
226
|
+
/**
|
|
227
|
+
* A store the hub keeps, as the fake hub answers its endpoints (`FakeHub.stores`). The hub's own store host fits it;
|
|
228
|
+
* by default every call is refused, as a hub that keeps no store for the system would.
|
|
229
|
+
*/
|
|
230
|
+
export interface FakeStoreEndpoints {
|
|
231
|
+
open(): Promise<{ bytes: number }>;
|
|
232
|
+
run(statement: StoreStatement): Promise<StoreResult>;
|
|
233
|
+
begin(): Promise<StoreLease>;
|
|
234
|
+
commit(lease: StoreLeaseId): Promise<void>;
|
|
235
|
+
rollback(lease: StoreLeaseId): Promise<void>;
|
|
236
|
+
snapshot(): Promise<StoreSnapshotName>;
|
|
237
|
+
restore(snapshot: StoreSnapshotName): Promise<void>;
|
|
238
|
+
/** A move from the hub: a whole copy of the store, its size and sha-256. */
|
|
239
|
+
export?(move: StoreMoveId): Promise<{ bytes: number; hash: string }>;
|
|
240
|
+
/** A chunk of that copy, base64. */
|
|
241
|
+
download?(move: StoreMoveId, offset: number, length: number): Promise<{ chunk: string }>;
|
|
242
|
+
/** A move to the hub: a chunk of the copy, base64. */
|
|
243
|
+
upload?(move: StoreMoveId, offset: number, chunk: string): Promise<void>;
|
|
244
|
+
/** The copy is all sent. */
|
|
245
|
+
uploadDone?(move: StoreMoveId, bytes: number, hash: string): Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** The refusal every store endpoint gives until a test sets `FakeHub.stores`. */
|
|
249
|
+
const NO_STORES = (): Promise<never> => Promise.reject(reject(409, 'STORE_NOT_ON_HUB', 'The fake hub keeps no store for this system: set hub.stores.'));
|
|
250
|
+
|
|
215
251
|
/** A hub in memory for testing systems. */
|
|
216
252
|
export class FakeHub {
|
|
217
253
|
readonly systems: Peers<SystemLinkSpec> = peers(systemLinkSpec);
|
|
@@ -231,6 +267,8 @@ export class FakeHub {
|
|
|
231
267
|
readonly progress: Array<HubBody<'progress'>> = [];
|
|
232
268
|
readonly allowed: Array<HubBody<'allow'>> = [];
|
|
233
269
|
readonly undos: Array<HubBody<'undoWith'>> = [];
|
|
270
|
+
/** The finished runs' results the system replaced (`ctx.updateResult`). */
|
|
271
|
+
readonly resultUpdates: Array<HubBody<'updateResult'>> = [];
|
|
234
272
|
readonly attachments: Array<HubBody<'attach'>> = [];
|
|
235
273
|
readonly logs: LogLine[] = [];
|
|
236
274
|
/** Refreshed (or expired) credentials systems handed back (`connectionUpdate`). */
|
|
@@ -282,6 +320,16 @@ export class FakeHub {
|
|
|
282
320
|
readonly exampleChanges: Array<HubBody<'examples'>> = [];
|
|
283
321
|
/** Pairing tokens approved install runs asked for (`grantPairing`), with the grant the fake hub made. */
|
|
284
322
|
readonly pairingGrants: Array<PairingGrantRequest & PairingGrant> = [];
|
|
323
|
+
/** What the system reported about its store (`storeStatus`), in order. */
|
|
324
|
+
readonly storeStatuses: StoreStatusReport[] = [];
|
|
325
|
+
/** Called with each store status the system reports (after it is kept in `storeStatuses`), as the hub would hear it. */
|
|
326
|
+
onStoreStatus: (report: StoreStatusReport) => void | Promise<void> = () => undefined;
|
|
327
|
+
/** How far store moves got, as the system reported it (`storeMoveProgress`), in order. */
|
|
328
|
+
readonly storeMoves: Array<HubBody<'storeMoveProgress'>> = [];
|
|
329
|
+
/** Called with each move progress report, as the hub would hear it. */
|
|
330
|
+
onStoreMoveProgress: (report: HubBody<'storeMoveProgress'>) => void | Promise<void> = () => undefined;
|
|
331
|
+
/** The store the hub keeps for the system, when its welcome puts it on the hub. Default: every call refused. */
|
|
332
|
+
stores: FakeStoreEndpoints = { open: NO_STORES, run: NO_STORES, begin: NO_STORES, commit: NO_STORES, rollback: NO_STORES, snapshot: NO_STORES, restore: NO_STORES };
|
|
285
333
|
|
|
286
334
|
// ─── What the hub holds ─────────────────────────────────────────────────────
|
|
287
335
|
/** Paired keys by system name. */
|
|
@@ -391,6 +439,8 @@ export class FakeHub {
|
|
|
391
439
|
folders: () => Promise.resolve(),
|
|
392
440
|
// a test's contracts are fixtures: the real ones are checked for examples by their own tests
|
|
393
441
|
requireExamples: false,
|
|
442
|
+
// a store with the system is a real file in the system's data folder, as `serve` keeps it (testHub, whose state
|
|
443
|
+
// folder is never made, keeps it in memory); one on the hub goes over the link to `stores`
|
|
394
444
|
...deps,
|
|
395
445
|
});
|
|
396
446
|
}
|
|
@@ -707,6 +757,7 @@ export class FakeHub {
|
|
|
707
757
|
sendManifest,
|
|
708
758
|
limits: { maxFrame: 1_000_000, maxChunk: this.#options.maxChunk ?? 64_000, heartbeat: 1_000 },
|
|
709
759
|
...(this.#options.autoPair === undefined ? {} : { autoPair: this.#options.autoPair }),
|
|
760
|
+
...(this.#options.store === undefined ? {} : { store: this.#options.store }),
|
|
710
761
|
};
|
|
711
762
|
},
|
|
712
763
|
manifest: ({ data }) => {
|
|
@@ -740,6 +791,7 @@ export class FakeHub {
|
|
|
740
791
|
progress: ({ data }) => { this.progress.push(data); },
|
|
741
792
|
allow: ({ data }) => { this.allowed.push(data); },
|
|
742
793
|
undoWith: ({ data }) => { this.undos.push(data); },
|
|
794
|
+
updateResult: ({ data }) => { this.resultUpdates.push(data); return { revision: this.resultUpdates.filter((one) => one.run === data.run).length }; },
|
|
743
795
|
attach: ({ data }) => { this.attachments.push(data); },
|
|
744
796
|
types: async ({ data }) => {
|
|
745
797
|
this.typeRequests.push(data.names);
|
|
@@ -850,6 +902,19 @@ export class FakeHub {
|
|
|
850
902
|
recordTable: ({ data }) => this.data.table(data),
|
|
851
903
|
saveRecord: ({ data }) => this.data.save(data),
|
|
852
904
|
removeRecord: ({ data }) => this.data.remove(data),
|
|
905
|
+
storeOpen: () => this.stores.open(),
|
|
906
|
+
storeRun: ({ data }) => this.stores.run(data),
|
|
907
|
+
storeBegin: () => this.stores.begin(),
|
|
908
|
+
storeCommit: ({ data }) => this.stores.commit(data.lease),
|
|
909
|
+
storeRollback: ({ data }) => this.stores.rollback(data.lease),
|
|
910
|
+
storeSnapshot: async () => ({ snapshot: await this.stores.snapshot() }),
|
|
911
|
+
storeRestore: ({ data }) => this.stores.restore(data.snapshot),
|
|
912
|
+
storeStatus: async ({ data }) => { this.storeStatuses.push(data); await this.onStoreStatus(data); },
|
|
913
|
+
storeExport: ({ data }) => (this.stores.export ?? NO_STORES)(data.move),
|
|
914
|
+
storeDownload: ({ data }) => (this.stores.download ?? NO_STORES)(data.move, data.offset, data.length),
|
|
915
|
+
storeUpload: ({ data }) => (this.stores.upload ?? NO_STORES)(data.move, data.offset, data.chunk),
|
|
916
|
+
storeUploadDone: ({ data }) => (this.stores.uploadDone ?? NO_STORES)(data.move, data.bytes, data.hash),
|
|
917
|
+
storeMoveProgress: async ({ data }) => { this.storeMoves.push(data); await this.onStoreMoveProgress(data); },
|
|
853
918
|
});
|
|
854
919
|
}
|
|
855
920
|
}
|
|
@@ -877,6 +942,54 @@ function argsWithAnswer(proposal: HubBody<'propose'>, answer: Json | undefined):
|
|
|
877
942
|
function emptyReport(): ImportReport {
|
|
878
943
|
return { added: [], updated: [], removed: [], refused: [] };
|
|
879
944
|
}
|
|
945
|
+
/** A `LinkHostDeps.storeConnect` that keeps a store with the system as a real SQLite file in `dir` (`<dir>/store/store.db`). */
|
|
946
|
+
export function localStoreConnect(dir: string, now: () => number = Date.now): () => Promise<StoreConnection> {
|
|
947
|
+
return () => openLocalStore(dir, now);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/** Refuses every statement of `NO_STORE`. */
|
|
951
|
+
class NoStoreDriver implements Driver {
|
|
952
|
+
init(): Promise<void> { return Promise.resolve(); }
|
|
953
|
+
acquireConnection(): Promise<DatabaseConnection> {
|
|
954
|
+
return Promise.reject(new Error('This test context has no store: serve against FakeHub, or give it testStore(migrations).'));
|
|
955
|
+
}
|
|
956
|
+
beginTransaction(): Promise<void> { return Promise.resolve(); }
|
|
957
|
+
commitTransaction(): Promise<void> { return Promise.resolve(); }
|
|
958
|
+
rollbackTransaction(): Promise<void> { return Promise.resolve(); }
|
|
959
|
+
releaseConnection(): Promise<void> { return Promise.resolve(); }
|
|
960
|
+
destroy(): Promise<void> { return Promise.resolve(); }
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* `ctx.store` for a hand-made test context of a system that declares a store, when the code under test never touches
|
|
965
|
+
* it: every statement is refused, saying so. Spread it in beside `NO_ASKS` (`{ ...NO_ASKS, store: NO_STORE }`).
|
|
966
|
+
*/
|
|
967
|
+
export const NO_STORE: SystemStore<StoreDb> = systemStore(new Kysely<Record<string, Record<string, unknown>>>({
|
|
968
|
+
dialect: {
|
|
969
|
+
createAdapter: () => new SqliteAdapter(),
|
|
970
|
+
createDriver: () => new NoStoreDriver(),
|
|
971
|
+
createQueryCompiler: () => new SqliteQueryCompiler(),
|
|
972
|
+
createIntrospector: (db) => new SqliteIntrospector(db),
|
|
973
|
+
},
|
|
974
|
+
}), { engine: 'sqlite' });
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* A store for a unit test without a hub: SQLite in memory (or a real file in `dir`), migrated with `migrations`, as
|
|
978
|
+
* `ctx.store` would be. Close it when the test is done.
|
|
979
|
+
*/
|
|
980
|
+
export async function testStore(migrations: readonly Migration[], options: { readonly dir?: string } = {}): Promise<{ readonly store: SystemStore<StoreDb>; close(): Promise<void> }> {
|
|
981
|
+
const connection = options.dir === undefined ? await openMemoryStore() : await openLocalStore(options.dir, Date.now);
|
|
982
|
+
try {
|
|
983
|
+
await runMigrations(connection, migrations);
|
|
984
|
+
} catch (error) {
|
|
985
|
+
await connection.close();
|
|
986
|
+
throw error;
|
|
987
|
+
}
|
|
988
|
+
return { store: systemStore(connection.db, connection.place), close: () => connection.close() };
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
export { openMemoryStore, type StoreConnection } from './store/engines.ts';
|
|
992
|
+
export { CheckClock, WORK_BACKEND_CHECKS, type WorkBackendCheck, type WorkBackendMaker } from './store/work-checks.ts';
|
|
880
993
|
export { liveEnv, liveModels } from './live.ts';
|
|
881
994
|
export { FakeHubFns, type KeptFn } from './fake-hub-fns.ts';
|
|
882
995
|
export { FakeHubWidgets, HUB_WIDGET_FNS, type FakeTableSource } from './fake-hub-widgets.ts';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A system's own store, as its contract declares it and as its code sees it. Safe to import anywhere: only types come
|
|
3
|
+
* from Kysely here; the runtime (opening the store, migrations, the dialects) is in `@harness/sdk/server`.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* export const notes = system('notes', { description: 'Keeps notes.' })
|
|
7
|
+
* .with({ store: store({ description: 'Notes and their embeddings.', vectors: true }) });
|
|
8
|
+
*
|
|
9
|
+
* export const createImpl = () => notes.implement<NotesDb>({
|
|
10
|
+
* fns: { add: { async run({ title }, ctx) { await ctx.store.insertInto('notes').values({ id, title }).execute(); … } } },
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* `ctx.store` is Kysely over the store's tables (the interface the system writes for them), plus `vectors(name)`. The
|
|
15
|
+
* same code runs on every placement: SQLite with the system, SQLite on the hub (statements travel over the link), or
|
|
16
|
+
* Postgres and SQL Server.
|
|
17
|
+
*/
|
|
18
|
+
import { StoreDecl, type StoreEngine } from '@harness/core';
|
|
19
|
+
import type { z } from 'zod';
|
|
20
|
+
import type { Kysely, Transaction } from 'kysely';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Declare the system's store (`.with({ store: store({ ... }) })`): what it holds, whether it keeps vectors, and the
|
|
24
|
+
* engines it may run on (default every one; `['sqlite']` keeps it on the hub or with the system). Its migrations are
|
|
25
|
+
* the server's (`serve(..., { store: { migrations } })`).
|
|
26
|
+
*/
|
|
27
|
+
export function store(input: z.input<typeof StoreDecl>): StoreDecl {
|
|
28
|
+
return StoreDecl.parse(input);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A row of `_store_migrations`, the table every store keeps its applied migrations in. */
|
|
32
|
+
export interface StoreMigrationRow {
|
|
33
|
+
/** The migration's id. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** When it ran, as ISO text (Kysely's own column). */
|
|
36
|
+
timestamp: string;
|
|
37
|
+
/** The checksum of its code when it ran: a later change to it is refused. */
|
|
38
|
+
checksum: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The tables every store has, which a system's own table interface extends (`interface NotesDb extends StoreDb`). The
|
|
43
|
+
* SDK keeps them; a system reads them at most.
|
|
44
|
+
*/
|
|
45
|
+
export interface StoreDb {
|
|
46
|
+
_store_migrations: StoreMigrationRow;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** One vector found near another: its key, its cosine distance (0 the same, 2 opposite) and a similarity score in [0, 1]. */
|
|
50
|
+
export interface VectorHit {
|
|
51
|
+
readonly key: string;
|
|
52
|
+
readonly distance: number;
|
|
53
|
+
readonly score: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A named set of vectors in the store (`ctx.store.vectors('note_text')`), each kept under a text key, all of the size
|
|
58
|
+
* its migration made it with (`db.vectors.create(name, { dimensions })`). On SQLite it is a sqlite-vec `vec0` table,
|
|
59
|
+
* on Postgres a pgvector column, on SQL Server 2025 a `VECTOR` column; distance is cosine everywhere.
|
|
60
|
+
*/
|
|
61
|
+
export interface StoreVectors {
|
|
62
|
+
/** Add or replace the vector kept under `key`. */
|
|
63
|
+
upsert(key: string, vector: readonly number[]): Promise<void>;
|
|
64
|
+
/** Remove the vectors under these keys (missing ones are skipped). */
|
|
65
|
+
remove(keys: string | readonly string[]): Promise<void>;
|
|
66
|
+
/** The `k` nearest (default 10), nearest first; with `keys`, only among those. */
|
|
67
|
+
nearest(vector: readonly number[], options?: { readonly k?: number; readonly keys?: readonly string[] }): Promise<VectorHit[]>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A transaction on the store: Kysely's, plus vectors in the same transaction. */
|
|
71
|
+
export type StoreTransaction<Db> = Transaction<Db> & {
|
|
72
|
+
vectors(name: string): StoreVectors;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** `ctx.store.transaction()`: run a function in one transaction; it commits when the function resolves, else rolls back. */
|
|
76
|
+
export interface StoreTransactionBuilder<Db> {
|
|
77
|
+
execute<T>(fn: (tx: StoreTransaction<Db>) => Promise<T>): Promise<T>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* `ctx.store`: Kysely over the store's tables (`Db`), the same in every placement, plus its vectors. Its transactions
|
|
82
|
+
* carry vectors too. On the hub a transaction holds the store's file for itself under a lease (30 s by default between
|
|
83
|
+
* statements); a quiet one is rolled back.
|
|
84
|
+
*/
|
|
85
|
+
export type SystemStore<Db> = Omit<Kysely<Db>, 'transaction'> & {
|
|
86
|
+
/** The engine it runs on. */
|
|
87
|
+
readonly engine: StoreEngine;
|
|
88
|
+
transaction(): StoreTransactionBuilder<Db>;
|
|
89
|
+
vectors(name: string): StoreVectors;
|
|
90
|
+
};
|
|
91
|
+
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* call can use the refs declared before it. The implementation's type (`SystemImpl`) is computed from the contract,
|
|
4
4
|
* so everything declared must be implemented and nothing undeclared can be.
|
|
5
5
|
*/
|
|
6
|
-
import { ApiGroupDecl, ConfigComponentDecl, ConfigPath, ConnectDecl, ContributionDecl, SystemGrants, SystemName, SystemPageDecl, qualify, systemPageProblems, type SystemPageInput, type ConnectFinish, type ConnectResult, type ConnectStart, type Duration, type RunConnection, type QualifiedName, type SystemEvent, type StopReason } from '@harness/core';
|
|
7
|
-
import type { Own, SystemCtx } from './ctx.ts';
|
|
6
|
+
import { ApiGroupDecl, ConfigComponentDecl, ConfigPath, ConnectDecl, ContributionDecl, StoreDecl, SystemGrants, SystemName, SystemPageDecl, qualify, systemPageProblems, type SystemPageInput, type ConnectFinish, type ConnectResult, type ConnectStart, type Duration, type RunConnection, type QualifiedName, type SystemEvent, type StopReason } from '@harness/core';
|
|
7
|
+
import type { AnyOwn, Own, SystemCtx } from './ctx.ts';
|
|
8
8
|
import type {
|
|
9
9
|
ActionDef, ActionImpl, AnyContextDef, AnyTypeDef, AttachmentDef, ContextDef, ContextImpl, HookDef, HookImpl,
|
|
10
10
|
KindDef, KindImpl, MentionDef, MentionImpl, MethodImpl, SectionerDef, SectionerImpl, SettingDef, TypeDef,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { entriesOf, mapValues, type Simplify } from './util.ts';
|
|
20
20
|
import type { ResourceProvider } from './resources.ts';
|
|
21
21
|
import type { ProviderDef, ProviderImpl } from './providers.ts';
|
|
22
|
+
import type { StoreDb, SystemStore } from './store.ts';
|
|
22
23
|
|
|
23
24
|
/** Everything a contract can hold, by section. */
|
|
24
25
|
export interface ContractShape {
|
|
@@ -41,14 +42,19 @@ export interface ContractShape {
|
|
|
41
42
|
* fns act as them. `undefined` for a system everyone shares. The implementation then serves `connect`.
|
|
42
43
|
*/
|
|
43
44
|
connect: ConnectDecl | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The system's own SQL store (`store()`), or `undefined` for a system that keeps nothing of its own. Its code sees it
|
|
47
|
+
* as `ctx.store`, typed by the table interface given to `implement<Db>`.
|
|
48
|
+
*/
|
|
49
|
+
store: StoreDecl | undefined;
|
|
44
50
|
/** The system's name (`schedule`), so what is computed from the contract alone (the refs its ctxs take) is named. */
|
|
45
51
|
system: string;
|
|
46
52
|
/** Its declared pages, by segment (`system(name, { pages })`), so links to them are refs (`contract.page.item`). */
|
|
47
53
|
pages: Record<string, SystemPageDecl>;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
/** The sections of a contract that add named declarations (all but `config`, `connect`, `system` and `pages`). */
|
|
51
|
-
export type ContractSection = Exclude<keyof ContractShape, 'config' | 'connect' | 'system' | 'pages'>;
|
|
56
|
+
/** The sections of a contract that add named declarations (all but `config`, `connect`, `store`, `system` and `pages`). */
|
|
57
|
+
export type ContractSection = Exclude<keyof ContractShape, 'config' | 'connect' | 'store' | 'system' | 'pages'>;
|
|
52
58
|
|
|
53
59
|
/** The contract sections, in the order the manifest lists them. */
|
|
54
60
|
export const CONTRACT_SECTIONS = ['types', 'settings', 'attachments', 'kinds', 'fns', 'context', 'hooks', 'mentions', 'sectioners', 'actions', 'providers'] as const satisfies readonly ContractSection[];
|
|
@@ -58,22 +64,25 @@ export interface EmptyContract<N extends string = string, S extends string = nev
|
|
|
58
64
|
config: GinType<{}>;
|
|
59
65
|
types: {}; settings: {}; attachments: {}; kinds: {}; fns: {}; context: {}; hooks: {}; mentions: {}; sectioners: {}; actions: {}; providers: {};
|
|
60
66
|
connect: undefined;
|
|
67
|
+
store: undefined;
|
|
61
68
|
system: N;
|
|
62
69
|
pages: { [K in S]: SystemPageDecl };
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
/**
|
|
66
|
-
* A contract with more sections merged in: `config` and `
|
|
67
|
-
* declared once, by `system()`), every other section adds to what was declared.
|
|
73
|
+
* A contract with more sections merged in: `config`, `connect` and `store` are replaced, `system` and `pages` are kept
|
|
74
|
+
* (they are declared once, by `system()`), every other section adds to what was declared.
|
|
68
75
|
*/
|
|
69
76
|
export type Merge<C extends ContractShape, P extends Partial<ContractShape>> = {
|
|
70
77
|
[K in keyof ContractShape]: K extends 'config'
|
|
71
78
|
? (P extends { config: infer X extends GinType<object> } ? X : C['config'])
|
|
72
79
|
: K extends 'connect'
|
|
73
80
|
? (P extends { connect: infer X extends ConnectDecl } ? X : C['connect'])
|
|
74
|
-
: K extends '
|
|
75
|
-
? C[
|
|
76
|
-
:
|
|
81
|
+
: K extends 'store'
|
|
82
|
+
? (P extends { store: infer X extends StoreDecl } ? X : C['store'])
|
|
83
|
+
: K extends 'system' | 'pages'
|
|
84
|
+
? C[K]
|
|
85
|
+
: Simplify<C[K] & (K extends keyof P ? NonNullable<P[K]> : {})>;
|
|
77
86
|
};
|
|
78
87
|
|
|
79
88
|
type Q<N extends string, K> = QualifiedName<N, K & string>;
|
|
@@ -99,11 +108,14 @@ export interface SystemRefs<N extends string, C extends ContractShape> {
|
|
|
99
108
|
|
|
100
109
|
/**
|
|
101
110
|
* What a contract's implementation calls its own (`Own`): the refs of its kinds and of its pages, so `ctx.runs` and
|
|
102
|
-
* notices take those and nothing of another system's
|
|
111
|
+
* notices take those and nothing of another system's, and its store over its own tables (`Db`) when it declares a
|
|
112
|
+
* store. Without one it is the plain context's store type (`undefined` at run time), so such a context still fits
|
|
113
|
+
* where a plain `SystemCtx` is taken and the other way round.
|
|
103
114
|
*/
|
|
104
|
-
export type OwnOf<C extends ContractShape> = Own<
|
|
115
|
+
export type OwnOf<C extends ContractShape, Db extends StoreDb = StoreDb> = Own<
|
|
105
116
|
{ [K in keyof C['kinds']]: C['kinds'][K] extends KindDef<infer P> ? KindRef<Q<C['system'], K>, P> : never }[keyof C['kinds']],
|
|
106
|
-
{ [K in keyof C['pages']]: PageRef<Q<C['system'], K>> }[keyof C['pages']]
|
|
117
|
+
{ [K in keyof C['pages']]: PageRef<Q<C['system'], K>> }[keyof C['pages']],
|
|
118
|
+
C['store'] extends StoreDecl ? SystemStore<Db> : SystemStore<StoreDb> | undefined
|
|
107
119
|
>;
|
|
108
120
|
|
|
109
121
|
/**
|
|
@@ -138,8 +150,19 @@ export interface SystemContract<N extends string, C extends ContractShape> exten
|
|
|
138
150
|
readonly defs: C;
|
|
139
151
|
/** Add declarations: any sections, given directly or built from the refs so far. */
|
|
140
152
|
with<const P extends Partial<ContractShape>>(part: P | ((self: SystemRefs<N, C>) => P)): SystemContract<N, Merge<C, P>>;
|
|
153
|
+
/**
|
|
154
|
+
* Type an implementation against this contract, with the store's tables as `Db` (`notes.implement<NotesDb>({ ... })`),
|
|
155
|
+
* so `ctx.store` is Kysely over them. It returns the implementation as given; `SystemImpl<C, Db>` is the same type.
|
|
156
|
+
*/
|
|
157
|
+
readonly implement: Implement<C>;
|
|
141
158
|
}
|
|
142
159
|
|
|
160
|
+
/**
|
|
161
|
+
* A contract's `implement`. Any contract (`AnyContract`) has one of unknown type, so every contract still fits where
|
|
162
|
+
* any contract is taken: an implementation is typed by its own contract only.
|
|
163
|
+
*/
|
|
164
|
+
export type Implement<C extends ContractShape> = ContractShape extends C ? unknown : <Db extends StoreDb = StoreDb>(impl: SystemImpl<C, Db>) => SystemImpl<C, Db>;
|
|
165
|
+
|
|
143
166
|
export type AnyContract = SystemContract<string, ContractShape>;
|
|
144
167
|
|
|
145
168
|
/** A system's config type: what it needs before it can be used. The value is in every context as `ctx.config`. */
|
|
@@ -310,7 +333,9 @@ function assemble<N extends string, C extends ContractShape>(name: N, extras: Co
|
|
|
310
333
|
const more = refsOf(name, added);
|
|
311
334
|
if (added.connect !== undefined && defs.connect !== undefined) { throw new Error(`system ${name}: connect is declared twice`); }
|
|
312
335
|
const connect = added.connect === undefined ? defs.connect : ConnectDecl.parse(added.connect);
|
|
313
|
-
|
|
336
|
+
if (added.store !== undefined && defs.store !== undefined) { throw new Error(`system ${name}: store is declared twice`); }
|
|
337
|
+
const store = added.store === undefined ? defs.store : StoreDecl.parse(added.store);
|
|
338
|
+
const merged = { config: added.config ?? defs.config, connect, store, system: defs.system, pages: defs.pages } as Record<string, unknown>; // eslint-disable-line @typescript-eslint/consistent-type-assertions -- filled per section just below
|
|
314
339
|
const mergedRefs: AnyRefs = EMPTY_SECTIONS();
|
|
315
340
|
for (const section of CONTRACT_SECTIONS) {
|
|
316
341
|
merged[section] = { ...defs[section], ...added[section] };
|
|
@@ -319,6 +344,9 @@ function assemble<N extends string, C extends ContractShape>(name: N, extras: Co
|
|
|
319
344
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- `merged` holds every section of C with P's added: exactly Merge<C, P>
|
|
320
345
|
return assemble(name, extras, merged as Merge<C, P>, mergedRefs);
|
|
321
346
|
},
|
|
347
|
+
implement<Db extends StoreDb>(impl: SystemImpl<C, Db>): SystemImpl<C, Db> {
|
|
348
|
+
return impl;
|
|
349
|
+
},
|
|
322
350
|
};
|
|
323
351
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- the refs were built from `defs` section by section, which is what SystemRefs<N, C> maps
|
|
324
352
|
const self = contract as unknown as SystemContract<N, C>;
|
|
@@ -368,7 +396,7 @@ export function system<const N extends string, const S extends string = never>(n
|
|
|
368
396
|
};
|
|
369
397
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- the pages were checked just above; keyed by their segments, they are exactly S's
|
|
370
398
|
const pages = Object.fromEntries(extras.pages.map((page) => [page.segment, page])) as EmptyContract<N, S>['pages'];
|
|
371
|
-
const defs: EmptyContract<N, S> = { config: g.obj({}), connect: undefined, system: name, pages, ...EMPTY_SECTIONS() };
|
|
399
|
+
const defs: EmptyContract<N, S> = { config: g.obj({}), connect: undefined, store: undefined, system: name, pages, ...EMPTY_SECTIONS() };
|
|
372
400
|
return assemble(name, extras, defs, EMPTY_SECTIONS());
|
|
373
401
|
}
|
|
374
402
|
|
|
@@ -382,12 +410,12 @@ type DynamicContextKeys<X> = { [K in keyof X]: X[K] extends ContextDef<unknown,
|
|
|
382
410
|
type Needs<K extends string, T> = [keyof T] extends [never] ? { readonly [P in K]?: never } : { readonly [P in K]: T };
|
|
383
411
|
|
|
384
412
|
/** Hub events a system handles, by event type. Subscriptions follow the handlers given. */
|
|
385
|
-
export type EventHandlers<Cfg, O extends
|
|
413
|
+
export type EventHandlers<Cfg, O extends AnyOwn = Own> = {
|
|
386
414
|
readonly [E in SystemEvent['type']]?: (event: Extract<SystemEvent, { type: E }>, ctx: SystemCtx<Cfg, O>) => Promise<void>;
|
|
387
415
|
};
|
|
388
416
|
|
|
389
417
|
/** Moments in a system's life. All optional; each gets the system's context with its current config. */
|
|
390
|
-
export interface Lifecycle<Cfg, O extends
|
|
418
|
+
export interface Lifecycle<Cfg, O extends AnyOwn = Own> {
|
|
391
419
|
/** The first time it connects after being paired or installed (with a valid config). */
|
|
392
420
|
installed?(ctx: SystemCtx<Cfg, O>): Promise<void>;
|
|
393
421
|
/** Every time it connects with a valid config and its contract is imported. */
|
|
@@ -413,25 +441,25 @@ export interface Lifecycle<Cfg, O extends Own = Own> {
|
|
|
413
441
|
/**
|
|
414
442
|
* A system's implementation, computed from its contract. It must implement exactly what the contract declares: every
|
|
415
443
|
* native fn, every method of its types, every kind, every dynamic context, hook, mention provider,
|
|
416
|
-
* sectioner, action and model provider.
|
|
444
|
+
* sectioner, action and model provider. `Db` is its store's tables, for a contract that declares a store (`ctx.store`).
|
|
417
445
|
*/
|
|
418
|
-
export type SystemImpl<C extends ContractShape> =
|
|
419
|
-
Needs<'fns', { readonly [K in NativeFnKeys<C['fns']>]: FnImpl<TypesOf<C['fns'][K]>, ConfigOf<C>, OwnOf<C>> }> &
|
|
420
|
-
Needs<'kinds', { readonly [K in keyof C['kinds']]: C['kinds'][K] extends KindDef<infer P> ? KindImpl<P, ConfigOf<C>, OwnOf<C>> : never }> &
|
|
421
|
-
Needs<'context', { readonly [K in DynamicContextKeys<C['context']>]: C['context'][K] extends ContextDef<infer A, true> ? ContextImpl<A, ConfigOf<C>, OwnOf<C>> : never }> &
|
|
422
|
-
Needs<'hooks', { readonly [K in keyof C['hooks']]: HookImpl<ConfigOf<C>, OwnOf<C>> }> &
|
|
423
|
-
Needs<'mentions', { readonly [K in keyof C['mentions']]: C['mentions'][K] extends MentionDef<infer T, infer V> ? MentionImpl<T, V, ConfigOf<C>, OwnOf<C>> : never }> &
|
|
424
|
-
Needs<'types', { readonly [K in TypesWithMethods<C['types']>]: C['types'][K] extends TypeDef<infer V, infer M extends Methods> ? { readonly [J in keyof M]: MethodImpl<V, TypesOf<M[J]>, ConfigOf<C>, OwnOf<C>> } : never }> &
|
|
446
|
+
export type SystemImpl<C extends ContractShape, Db extends StoreDb = StoreDb> =
|
|
447
|
+
Needs<'fns', { readonly [K in NativeFnKeys<C['fns']>]: FnImpl<TypesOf<C['fns'][K]>, ConfigOf<C>, OwnOf<C, Db>> }> &
|
|
448
|
+
Needs<'kinds', { readonly [K in keyof C['kinds']]: C['kinds'][K] extends KindDef<infer P> ? KindImpl<P, ConfigOf<C>, OwnOf<C, Db>> : never }> &
|
|
449
|
+
Needs<'context', { readonly [K in DynamicContextKeys<C['context']>]: C['context'][K] extends ContextDef<infer A, true> ? ContextImpl<A, ConfigOf<C>, OwnOf<C, Db>> : never }> &
|
|
450
|
+
Needs<'hooks', { readonly [K in keyof C['hooks']]: HookImpl<ConfigOf<C>, OwnOf<C, Db>> }> &
|
|
451
|
+
Needs<'mentions', { readonly [K in keyof C['mentions']]: C['mentions'][K] extends MentionDef<infer T, infer V> ? MentionImpl<T, V, ConfigOf<C>, OwnOf<C, Db>> : never }> &
|
|
452
|
+
Needs<'types', { readonly [K in TypesWithMethods<C['types']>]: C['types'][K] extends TypeDef<infer V, infer M extends Methods> ? { readonly [J in keyof M]: MethodImpl<V, TypesOf<M[J]>, ConfigOf<C>, OwnOf<C, Db>> } : never }> &
|
|
425
453
|
Needs<'sectioners', { readonly [K in keyof C['sectioners']]: SectionerImpl }> &
|
|
426
|
-
Needs<'actions', { readonly [K in keyof C['actions']]: C['actions'][K] extends ActionDef<infer I, infer R, infer St> ? ActionImpl<I, R, St, ConfigOf<C>, OwnOf<C>> : never }> &
|
|
427
|
-
Needs<'providers', { readonly [K in keyof C['providers']]: ProviderImpl<ConfigOf<C>, OwnOf<C>> }> &
|
|
428
|
-
(C['connect'] extends ConnectDecl ? { readonly connect: ConnectImpl<ConfigOf<C>, OwnOf<C>> } : { readonly connect?: never }) &
|
|
454
|
+
Needs<'actions', { readonly [K in keyof C['actions']]: C['actions'][K] extends ActionDef<infer I, infer R, infer St> ? ActionImpl<I, R, St, ConfigOf<C>, OwnOf<C, Db>> : never }> &
|
|
455
|
+
Needs<'providers', { readonly [K in keyof C['providers']]: ProviderImpl<ConfigOf<C>, OwnOf<C, Db>> }> &
|
|
456
|
+
(C['connect'] extends ConnectDecl ? { readonly connect: ConnectImpl<ConfigOf<C>, OwnOf<C, Db>> } : { readonly connect?: never }) &
|
|
429
457
|
{
|
|
430
458
|
/** Resources this system serves. */
|
|
431
459
|
readonly resources?: ResourceProvider;
|
|
432
460
|
/** Hub events to receive. */
|
|
433
|
-
readonly events?: EventHandlers<ConfigOf<C>, OwnOf<C>>;
|
|
434
|
-
readonly lifecycle?: Lifecycle<ConfigOf<C>, OwnOf<C>>;
|
|
461
|
+
readonly events?: EventHandlers<ConfigOf<C>, OwnOf<C, Db>>;
|
|
462
|
+
readonly lifecycle?: Lifecycle<ConfigOf<C>, OwnOf<C, Db>>;
|
|
435
463
|
};
|
|
436
464
|
|
|
437
465
|
/**
|
|
@@ -440,7 +468,7 @@ export type SystemImpl<C extends ContractShape> =
|
|
|
440
468
|
* query, or the form) into the account and credentials, or a problem in words; `disconnect` revokes the credentials
|
|
441
469
|
* where the provider can (best effort).
|
|
442
470
|
*/
|
|
443
|
-
export interface ConnectImpl<Cfg, O extends
|
|
471
|
+
export interface ConnectImpl<Cfg, O extends AnyOwn = Own> {
|
|
444
472
|
start(request: ConnectStart, ctx: SystemCtx<Cfg, O>): Promise<{ url: string }> | { url: string };
|
|
445
473
|
finish(request: ConnectFinish, ctx: SystemCtx<Cfg, O>): Promise<ConnectResult>;
|
|
446
474
|
disconnect(connection: Pick<RunConnection, 'id' | 'owner' | 'credentials'>, ctx: SystemCtx<Cfg, O>): Promise<void>;
|
|
@@ -15,8 +15,10 @@ import type { AnyFnDef, FnDef, TypesOf } from '../fn.ts';
|
|
|
15
15
|
import { encodeValue, parseValue } from '../gin.ts';
|
|
16
16
|
import type { ModelLink } from '../server/llm.ts';
|
|
17
17
|
import type { RunningSystem, ServeOptions } from '../server/index.ts';
|
|
18
|
-
import { FakeHub, type FakeHubOptions } from '../server/testing.ts';
|
|
18
|
+
import { FakeHub, openMemoryStore, type FakeHubOptions, type FakeStoreEndpoints } from '../server/testing.ts';
|
|
19
|
+
import type { LinkHostDeps } from '../server/host.ts';
|
|
19
20
|
import type { ContractShape, SystemContract, SystemImpl } from '../system.ts';
|
|
21
|
+
import type { StoreDb } from '../store.ts';
|
|
20
22
|
import { BUILT_IN_CONTRIBUTIONS, rankedVisuals, resultFacts } from '../widgets.ts';
|
|
21
23
|
|
|
22
24
|
/** A fn of the contract, by local name. */
|
|
@@ -100,6 +102,13 @@ export interface TestHubOptions {
|
|
|
100
102
|
readonly serve?: Partial<Omit<ServeOptions, 'hub' | 'state'>>;
|
|
101
103
|
/** Records the hub keeps before the system starts (what a restarted system finds), as stored. */
|
|
102
104
|
readonly records?: readonly DataRecord[];
|
|
105
|
+
/**
|
|
106
|
+
* For a system with a store on the hub (`hub: { store: { placement: 'hub' } }`): what answers its store endpoints,
|
|
107
|
+
* such as the hub's own store host. A store with the system lives in memory unless `host.storeConnect` says where.
|
|
108
|
+
*/
|
|
109
|
+
readonly stores?: FakeStoreEndpoints;
|
|
110
|
+
/** More of the link host's seams (`storeConnect`, `now`, …). */
|
|
111
|
+
readonly host?: Partial<LinkHostDeps>;
|
|
103
112
|
}
|
|
104
113
|
|
|
105
114
|
/** A system served to a fake hub: run its fns and kinds, read what it asked the hub for, and stop it. */
|
|
@@ -267,7 +276,7 @@ export class TestSystem<N extends string, C extends ContractShape> {
|
|
|
267
276
|
}
|
|
268
277
|
|
|
269
278
|
/** Serve a system to a fake hub in memory and wait until it is ready (connected, configured, its contract imported). */
|
|
270
|
-
export async function testHub<N extends string, C extends ContractShape>(contract: SystemContract<N, C>, impl: SystemImpl<C>, options: TestHubOptions = {}): Promise<TestSystem<N, C>> {
|
|
279
|
+
export async function testHub<N extends string, C extends ContractShape, Db extends StoreDb = StoreDb>(contract: SystemContract<N, C>, impl: SystemImpl<C, Db>, options: TestHubOptions = {}): Promise<TestSystem<N, C>> {
|
|
271
280
|
const hub = new FakeHub({ ...options.hub, ...(options.config === undefined ? {} : { config: options.config }) });
|
|
272
281
|
for (const record of options.records ?? []) { hub.data.records.set(record.id, record); }
|
|
273
282
|
const model = options.model;
|
|
@@ -276,14 +285,18 @@ export async function testHub<N extends string, C extends ContractShape>(contrac
|
|
|
276
285
|
hub.onModel = (forward) => model.model(forward);
|
|
277
286
|
hub.onModels = () => model.models();
|
|
278
287
|
}
|
|
279
|
-
|
|
288
|
+
if (options.stores !== undefined) { hub.stores = options.stores; }
|
|
289
|
+
// its state folder is a name, never made: a store with the system lives in memory unless the test says where
|
|
290
|
+
const inMemory = (options.hub?.store === undefined || options.hub.store.placement === 'system') && options.host?.storeConnect === undefined;
|
|
291
|
+
const host = { ...(inMemory ? { storeConnect: () => openMemoryStore() } : {}), ...options.host };
|
|
292
|
+
const running = await hub.host(host).start(contract, impl, { version: '0.0.0-test', ...options.serve, hub: 'ws://hub.test/link', state: '.harness-test/state' });
|
|
280
293
|
await running.ready();
|
|
281
294
|
return new TestSystem(contract, hub, running);
|
|
282
295
|
}
|
|
283
296
|
|
|
284
297
|
/** Serve a system, call one fn and stop: the typed result, its progress and what it asked the hub for. */
|
|
285
|
-
export async function callFn<N extends string, C extends ContractShape, K extends FnNameOf<C
|
|
286
|
-
contract: SystemContract<N, C>, impl: SystemImpl<C>, name: K, args: FnArgsOf<C, K>, options: TestHubOptions = {},
|
|
298
|
+
export async function callFn<N extends string, C extends ContractShape, K extends FnNameOf<C>, Db extends StoreDb = StoreDb>(
|
|
299
|
+
contract: SystemContract<N, C>, impl: SystemImpl<C, Db>, name: K, args: FnArgsOf<C, K>, options: TestHubOptions = {},
|
|
287
300
|
): Promise<TestCall<FnResultOf<C, K>>> {
|
|
288
301
|
const kit = await testHub(contract, impl, options);
|
|
289
302
|
try {
|
package/packages/web/dist/assets/{ActorSettingsView-BuMYRDqv.js → ActorSettingsView-v2k7v454.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as e,D as t,E as n,Ft as r,Ht as i,On as a,_ as o,b as s,bt as c,ct as l,g as u,k as d,mt as f,o as p,qt as m,tr as h,v as g,vn as _,xn as v,y}from"./runtime-core.esm-bundler-wlpNGAAZ.js";import{
|
|
2
|
-
//# sourceMappingURL=ActorSettingsView-
|
|
1
|
+
import{$ as e,D as t,E as n,Ft as r,Ht as i,On as a,_ as o,b as s,bt as c,ct as l,g as u,k as d,mt as f,o as p,qt as m,tr as h,v as g,vn as _,xn as v,y}from"./runtime-core.esm-bundler-wlpNGAAZ.js";import{Rr as b}from"./push-payload-BeU1ADYt.js";import{t as x}from"./AppPage-CFmKZS8G.js";import{n as S}from"./stores-BMEvTe-I.js";import{t as C}from"./now-40JhSjx0.js";import{t as w}from"./LoadState-h-K9bTYc.js";import"./runs-CveC2kKo.js";import{C as T,G as E,H as D,I as O,V as k,f as A,q as j,z as M}from"./ui-BzgWquIU.js";import{G as N}from"./index-6ScWTFy2.js";import{t as P}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{t as F}from"./GinForm-BDBUzuDP.js";var I=[`data-testid`],L={class:`head`},R={class:`titles`},z={class:`title`},B={class:`name`},V={class:`description`},H={class:`chips`},U={key:0,class:`values`},W={class:`who`},G={class:`what`},K=[`title`],q={key:1,class:`none`},J=P(d({__name:`SettingCard`,props:{entry:{},nameOf:{type:Function},now:{}},emits:[`edit`],setup(e,{emit:r}){let i=r,l={"user-wins":`The person's own value wins`,union:`Values add up`,intersect:`Only what all allow`,"most-restrictive":`The strictest wins`};return(r,u)=>(f(),s(`article`,{class:`setting`,"data-testid":`setting-${e.entry.view.setting}`},[o(`header`,L,[o(`div`,R,[o(`h3`,z,[n(h(e.entry.view.decl.name)+` `,1),o(`code`,B,h(e.entry.view.setting),1)]),o(`p`,V,h(e.entry.view.decl.description),1),o(`p`,H,[t(a(D),null,{default:m(()=>[n(`On `+h(e.entry.view.decl.appliesTo.map(e=>a(N)[e].plural).join(`, `)),1)]),_:1}),t(a(D),null,{default:m(()=>[n(h(l[e.entry.view.decl.merge]),1)]),_:1})])]),t(a(M),{icon:`plus`,size:`sm`,"data-testid":`setting-add`,onClick:u[0]||=e=>i(`edit`,void 0)},{default:m(()=>[...u[1]||=[n(`Set`,-1)]]),_:1})]),e.entry.values.length>0?(f(),s(`ul`,U,[(f(!0),s(p,null,c(e.entry.values,n=>(f(),s(`li`,{key:n.actor,class:`value`},[o(`span`,W,h(e.nameOf(n.actor)),1),o(`code`,G,h(a(b)(n.value,80)),1),o(`time`,{class:`when`,title:a(E)(n.updatedAt)},h(a(j)(n.updatedAt,e.now)),9,K),t(a(O),{icon:`edit`,size:`sm`,label:`Edit for ${e.nameOf(n.actor)}`,onClick:e=>i(`edit`,n.actor)},null,8,[`label`,`onClick`])]))),128))])):(f(),s(`p`,q,`Not set on anyone yet; systems use their own default.`))],8,I))}}),[[`__scopeId`,`data-v-b4db3c06`]]),Y={key:0,class:`body`,"data-testid":`setting-form`},X=P(d({__name:`SettingDialog`,props:e({entry:{},actors:{},actor:{default:void 0},busy:{type:Boolean,default:!1},problem:{default:``}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:e([`save`],[`update:open`]),setup(e,{emit:o}){let c=e,l=r(e,`open`),d=o,p=_(``),v=u(()=>[{value:``,label:`Choose who…`},...c.actors.map(e=>({value:e.id,label:`${e.name} (${e.kind})`}))]),b=u(()=>c.actors.find(e=>e.id===p.value)),x=u(()=>c.entry?.values.find(e=>e.actor===b.value?.id)?.value);i(l,e=>{e&&(p.value=c.actor??``)});function S(e){b.value!==void 0&&d(`save`,b.value.id,e)}return(r,i)=>(f(),g(a(T),{open:l.value,"onUpdate:open":i[2]||=e=>l.value=e,title:e.entry?`Set ${e.entry.view.decl.name}`:`Set`,description:e.entry?.view.decl.description??``,width:`560px`},{default:m(()=>[e.entry?(f(),s(`div`,Y,[t(a(A),{modelValue:p.value,"onUpdate:modelValue":i[0]||=e=>p.value=e,options:v.value,label:`On`},null,8,[`modelValue`,`options`]),b.value?(f(),g(F,{key:b.value.id,type:e.entry.view.decl.type,initial:x.value,"submit-label":`Save`,busy:e.busy,label:`Value`,onSubmit:S,onCancel:i[1]||=e=>l.value=!1},null,8,[`type`,`initial`,`busy`])):y(``,!0),e.problem===``?y(``,!0):(f(),g(a(k),{key:1,tone:`danger`},{default:m(()=>[n(h(e.problem),1)]),_:1}))])):y(``,!0)]),_:1},8,[`open`,`title`,`description`]))}}),[[`__scopeId`,`data-v-058a090f`]]),Z=[`aria-labelledby`],Q=[`id`],$={class:`cards`},ee=P(d({__name:`ActorSettingsView`,setup(e){let{admin:n,session:r,toasts:i}=S(),d=n.settings,y=n.actors,b=C(),T=_(!1),E=v(void 0),D=_(void 0),O=u(()=>y.options(E.value?.view.decl.appliesTo??[]));l(()=>{d.load(d.data.value.value!==void 0),y.load()});function k(e,t){E.value=e,D.value=t,T.value=!0}async function A(e,t){let n=E.value,a=r.user.value?.id;n!==void 0&&a!==void 0&&await d.set(n.view.setting,e,t,a,Date.now())&&(T.value=!1,i.ok(`Saved for ${y.nameOf(e)}`))}return(e,n)=>(f(),g(x,{title:`Actor settings`,description:`Typed controls systems attach to people and groups, such as which rows a group may read.`},{default:m(()=>[t(w,{loading:a(d).data.loading.value,problem:a(d).data.problem.value,ready:a(d).data.value.value!==void 0,empty:a(d).groups.value.length===0,"empty-icon":`users`,"empty-title":`No actor settings`,"empty-body":`Systems that declare settings list them here.`,onRetry:n[0]||=e=>a(d).load()},{default:m(()=>[(f(!0),s(p,null,c(a(d).groups.value,e=>(f(),s(`section`,{key:e.system,class:`group`,"aria-labelledby":`settings-${e.system}`},[o(`h2`,{id:`settings-${e.system}`,class:`system`},h(e.system),9,Q),o(`div`,$,[(f(!0),s(p,null,c(e.settings,e=>(f(),g(J,{key:e.view.setting,entry:e,"name-of":a(y).nameOf,now:a(b),onEdit:t=>k(e,t)},null,8,[`entry`,`name-of`,`now`,`onEdit`]))),128))])],8,Z))),128))]),_:1},8,[`loading`,`problem`,`ready`,`empty`]),t(X,{open:T.value,"onUpdate:open":n[1]||=e=>T.value=e,entry:E.value,actors:O.value,actor:D.value,busy:a(d).save.busy.value,problem:a(d).save.problem.value,onSave:A},null,8,[`open`,`entry`,`actors`,`actor`,`busy`,`problem`])]),_:1}))}}),[[`__scopeId`,`data-v-235f95b7`]]);export{ee as default};
|
|
2
|
+
//# sourceMappingURL=ActorSettingsView-v2k7v454.js.map
|