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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What context as questions has to do for one item, worked out from the item alone: whether the background job fills
|
|
3
|
+
* its metadata (`needsMetadata`), whether it checks it for duplicates and contradictions (`needsCheck`), and which
|
|
4
|
+
* Review kinds it is in (`reviewKinds`). The store keeps each as a column of the item's row on every write
|
|
5
|
+
* (`store/derived.ts`), so the job and the Review queue find their items with an indexed query instead of reading
|
|
6
|
+
* every item of the context table (which, on SQLite, holds the event loop while it reads).
|
|
7
|
+
*
|
|
8
|
+
* This module depends on core alone (and the hash), so the store can use it.
|
|
9
|
+
*/
|
|
10
|
+
import { liveStatus, type ContextRecord, type ContextReviewKind } from '@harness/core';
|
|
11
|
+
import { HUB_SYSTEM } from '../catalog/availability.ts';
|
|
12
|
+
import { sha256Hex } from '../link/keys.ts';
|
|
13
|
+
|
|
14
|
+
/** Why an original is hidden after a split (and how the hub knows it hid it, so it can show it again). */
|
|
15
|
+
export const SPLIT_REASON = 'Split into one item per question; its split items carry its text.';
|
|
16
|
+
|
|
17
|
+
/** The hash of what the metadata model reads of an item: its title, description and content. A change fills it again. */
|
|
18
|
+
export function metadataHash(record: Pick<ContextRecord, 'decl'>): string {
|
|
19
|
+
return sha256Hex(`${record.decl.title ?? ''}\n${record.decl.description}\n${record.decl.content ?? ''}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Whether an item is a hub item: memory, context made from a resource, or an item the hub split out of another. */
|
|
23
|
+
export function hubItem(record: Pick<ContextRecord, 'system' | 'split'>): boolean {
|
|
24
|
+
return record.system === HUB_SYSTEM || record.split?.from !== undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether the job fills an item's metadata: a hub item (or one split before) with text, in use or waiting for approval
|
|
29
|
+
* (or hidden by its own split), with no metadata or metadata of other text. Never an open plan question, an item a
|
|
30
|
+
* person hid or ruled out, or one switched off with its system.
|
|
31
|
+
*/
|
|
32
|
+
export function needsMetadata(record: ContextRecord): boolean {
|
|
33
|
+
if (record.systemOff === true || (record.decl.content ?? '').trim() === '') return false;
|
|
34
|
+
const usable = liveStatus(record.status) || record.status === 'pending_approval' || (record.status === 'hidden' && record.statusReason === SPLIT_REASON);
|
|
35
|
+
if (!usable || !(hubItem(record) || record.split?.into !== undefined)) return false;
|
|
36
|
+
return record.metadata?.contentHash !== metadataHash(record);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the job checks an item for duplicates and contradictions: in use or waiting for approval, not switched off,
|
|
41
|
+
* and not checked against its current text. A split original (hidden; its split items are checked) never is.
|
|
42
|
+
*/
|
|
43
|
+
export function needsCheck(record: ContextRecord): boolean {
|
|
44
|
+
if (record.systemOff === true || !(liveStatus(record.status) || record.status === 'pending_approval')) return false;
|
|
45
|
+
return record.checked?.contentHash !== metadataHash(record);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The Review kinds a record is in (an item can be in several: a duplicate waiting for approval). */
|
|
49
|
+
export function reviewKinds(record: ContextRecord): ContextReviewKind[] {
|
|
50
|
+
if (record.status === 'pending_plan') return [];
|
|
51
|
+
const kinds: ContextReviewKind[] = [];
|
|
52
|
+
// a flag on an item that is out of use (hidden, merged away) is not for Review
|
|
53
|
+
const flagged = liveStatus(record.status) || record.status === 'pending_approval';
|
|
54
|
+
if (record.duplicate !== undefined && flagged) kinds.push('duplicate');
|
|
55
|
+
if (record.contradiction !== undefined && flagged) kinds.push('contradiction');
|
|
56
|
+
if (record.status === 'pending_approval') kinds.push('pending_approval');
|
|
57
|
+
if (record.status === 'pending_removal') kinds.push('pending_removal');
|
|
58
|
+
return kinds;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The columns the store keeps from these, for one item. */
|
|
62
|
+
export function contextWork(record: ContextRecord): Pick<ContextRecord, 'wantsMetadata' | 'wantsCheck' | 'inReview'> {
|
|
63
|
+
return { wantsMetadata: needsMetadata(record), wantsCheck: needsCheck(record), inReview: reviewKinds(record).length > 0 };
|
|
64
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plan's own matching (plan `context-questions`; for `hub/ctx_plan`, which another lane builds on this): for each
|
|
3
|
+
* question a plan raises, the existing context item that already is that question, if any, so a question appears once
|
|
4
|
+
* however many branches raise it. It is the one search that sees `pending_plan` items (open plan questions) besides
|
|
5
|
+
* those in use and those ruled out; normal search never does. Each question's nearest items (by meaning, no threshold)
|
|
6
|
+
* are put to the decision model as "the same question?", all of them in one decision split into calls the model takes;
|
|
7
|
+
* the most likely yes at or above the decide role's threshold is the match.
|
|
8
|
+
*/
|
|
9
|
+
import { QualifiedName, yesProbability, type ContextRecord, type ContextStatus, type DecisionQuestion } from '@harness/core';
|
|
10
|
+
import type { Search } from '../index/index.ts';
|
|
11
|
+
import type { Decider, DecisionModel, ModelSite } from '../models/index.ts';
|
|
12
|
+
import type { HubStore } from '../store/index.ts';
|
|
13
|
+
import { itemForDecision } from './duplicates.ts';
|
|
14
|
+
|
|
15
|
+
/** The statuses the plan's matching looks at: questions in use, open plan questions, and those ruled out. */
|
|
16
|
+
export const PLAN_MATCH_STATUSES: readonly ContextStatus[] = ['active', 'pending_removal', 'pending_plan', 'not_applicable'];
|
|
17
|
+
|
|
18
|
+
/** What the matching needs. */
|
|
19
|
+
export interface PlanMatchDeps {
|
|
20
|
+
readonly store: HubStore;
|
|
21
|
+
readonly search: Pick<Search, 'search'>;
|
|
22
|
+
readonly decider: Pick<Decider, 'ask'>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** One question's match: the item, and how sure the decision model was; undefined when none is the same question. */
|
|
26
|
+
export interface PlanMatch {
|
|
27
|
+
readonly question: string;
|
|
28
|
+
readonly match?: { readonly record: ContextRecord; readonly probability: number };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The items nearest a question that the plan's matching considers (`PLAN_MATCH_STATUSES`, open plan questions
|
|
33
|
+
* included), at most `limit`, best first.
|
|
34
|
+
*/
|
|
35
|
+
export async function planCandidates(deps: Pick<PlanMatchDeps, 'store' | 'search'>, question: string, limit: number): Promise<ContextRecord[]> {
|
|
36
|
+
const out: ContextRecord[] = [];
|
|
37
|
+
await deps.search.search({
|
|
38
|
+
text: question, kinds: ['context'], limit, match: 'semantic',
|
|
39
|
+
keep: async (hit) => {
|
|
40
|
+
const name = QualifiedName.safeParse(hit.key);
|
|
41
|
+
const record = name.success ? await deps.store.table('context').get(name.data) : undefined;
|
|
42
|
+
if (record === undefined || record.systemOff === true || !PLAN_MATCH_STATUSES.includes(record.status)) return false;
|
|
43
|
+
out.push(record);
|
|
44
|
+
return true;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Match each question to an existing item asking the same, or none. */
|
|
51
|
+
export async function matchPlanQuestions(
|
|
52
|
+
deps: PlanMatchDeps, questions: readonly string[], options: { readonly model: DecisionModel; readonly site: ModelSite; readonly signal: AbortSignal; readonly nearest?: number; readonly onCost?: (cost: number) => void },
|
|
53
|
+
): Promise<PlanMatch[]> {
|
|
54
|
+
const nearest = options.nearest ?? 10;
|
|
55
|
+
const candidates = await Promise.all(questions.map((question) => planCandidates(deps, question, nearest)));
|
|
56
|
+
const asked: Record<string, DecisionQuestion> = {};
|
|
57
|
+
questions.forEach((question, q) => {
|
|
58
|
+
candidates[q]?.forEach((record, c) => {
|
|
59
|
+
asked[`q${q}_c${c}`] = {
|
|
60
|
+
type: 'predicate',
|
|
61
|
+
instructions: `New question: ${question}\n\nExisting item:\n${itemForDecision(record)}\n\nDoes the existing item ask the same question as the new question (the same subject and the same need, even if worded differently)?`,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
if (Object.keys(asked).length === 0) return questions.map((question) => ({ question }));
|
|
66
|
+
const decided = await deps.decider.ask({
|
|
67
|
+
input: 'You match the questions a plan raises with items of knowledge an AI assistant already keeps, each the answer to one question (or an open question waiting for an answer).',
|
|
68
|
+
questions: asked, model: options.model, site: options.site, signal: options.signal,
|
|
69
|
+
});
|
|
70
|
+
options.onCost?.(decided.cost);
|
|
71
|
+
return questions.map((question, q) => {
|
|
72
|
+
let best: PlanMatch['match'];
|
|
73
|
+
(candidates[q] ?? []).forEach((record, c) => {
|
|
74
|
+
const probability = yesProbability(decided.answers[`q${q}_c${c}`]);
|
|
75
|
+
if (probability >= options.model.threshold && (best === undefined || probability > best.probability)) best = { record, probability };
|
|
76
|
+
});
|
|
77
|
+
return best === undefined ? { question } : { question, match: best };
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the plan model is told (`hub/ctx_plan`, plan `context-questions`). It reads nothing but these calls, so each
|
|
3
|
+
* prompt says what the harness is, what a plan is for, what happens to its answer next, and what a good answer looks
|
|
4
|
+
* like. Two calls: the first questions of a request (`QUESTIONS_INSTRUCTIONS`), and one open question's options with
|
|
5
|
+
* the questions each option raises (`OPTIONS_INSTRUCTIONS`). Each answer's shape is one `@aeye/schema` schema
|
|
6
|
+
* (`models/structured.ts`), never spelled out in the prompt. General on purpose: no subject matter of any request.
|
|
7
|
+
*/
|
|
8
|
+
import { a } from '@aeye/schema';
|
|
9
|
+
import { CONTEXT_ASKERS, type ContextAskedBy } from '@harness/core';
|
|
10
|
+
import { structuredAnswer } from '../models/structured.ts';
|
|
11
|
+
|
|
12
|
+
/** The purpose the plan model's calls are recorded with. */
|
|
13
|
+
export const PLAN_PURPOSE = 'ctx_plan';
|
|
14
|
+
|
|
15
|
+
/** The most first questions, options per question, and questions per option kept from one answer. */
|
|
16
|
+
export const PLAN_MAX_ROOTS = 12;
|
|
17
|
+
export const PLAN_MAX_OPTIONS = 6;
|
|
18
|
+
export const PLAN_MAX_RAISED = 5;
|
|
19
|
+
|
|
20
|
+
/** A question as the model writes it. */
|
|
21
|
+
export interface WrittenQuestion {
|
|
22
|
+
readonly question: string;
|
|
23
|
+
readonly askedBy: ContextAskedBy;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** An option as the model writes it. */
|
|
27
|
+
export interface WrittenOption {
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly detail: string;
|
|
30
|
+
readonly raises: readonly WrittenQuestion[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const QuestionSchema = a.object({
|
|
34
|
+
question: a.string().describe('The question, in one plain sentence ending with a question mark, that makes sense on its own.'),
|
|
35
|
+
askedBy: a.enum(CONTEXT_ASKERS).describe('Who answers it: person, system or research.'),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** The first call's answer. */
|
|
39
|
+
export const Questions = structuredAnswer(a.object({
|
|
40
|
+
questions: a.array(QuestionSchema).describe('Every question that must be answered before the request can be planned, most fundamental first.'),
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
/** The options call's answer. */
|
|
44
|
+
export const Options = structuredAnswer(a.object({
|
|
45
|
+
options: a.array(a.object({
|
|
46
|
+
label: a.string().describe('The option in a few words.'),
|
|
47
|
+
detail: a.string().describe('What choosing it means, and what it costs or rules out, in one or two sentences.'),
|
|
48
|
+
raises: a.array(QuestionSchema).describe('The new questions that must be answered if this option is chosen, and only because it is; empty when it raises none.'),
|
|
49
|
+
})).describe('The realistic options for the question, the most common first.'),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
/** What every plan prompt says first: the harness, the plan, and what the answer is for. */
|
|
53
|
+
const PLAN_CONTEXT = [
|
|
54
|
+
'You help plan work for an AI agent harness: a hub where people chat with AI agents, and the agents act by calling fns (the harness\'s word for the actions and lookups that connected systems offer: reading and writing files, querying data, calling services, and so on).',
|
|
55
|
+
'Before an agent plans a request, the harness builds a decision tree: the questions that must be answered first, each with its options, and under each option the questions that choosing it would raise. The person sees the tree, picks options and adds detail; questions under options they did not pick are ruled out. Every answer is kept as a piece of context (one question and its answer), so the agents, and later plans, can find it by searching.',
|
|
56
|
+
'Each question says who answers it:',
|
|
57
|
+
'- person: a choice or a fact only the person (or their team) can give: what they want, their preferences, limits, budget, who is involved, what already exists on their side.',
|
|
58
|
+
'- system: how the software should be set up or behave: which systems, data, settings, permissions or automations to use, how parts connect.',
|
|
59
|
+
'- research: a fact about the world that can be looked up or checked (what a service supports, a rule, a price, a standard), without asking the person.',
|
|
60
|
+
'Good questions: each asks one thing, in plain words, and makes sense on its own when read later without the tree (name the subject; never write "it", "this" or "the above"). They are concrete enough that options can be listed for them. They are not tasks ("Set up X") and not yes/no questions about doing the request at all.',
|
|
61
|
+
].join('\n');
|
|
62
|
+
|
|
63
|
+
/** The first call: the questions a request needs answered at its own level. */
|
|
64
|
+
export const QUESTIONS_INSTRUCTIONS = [
|
|
65
|
+
PLAN_CONTEXT,
|
|
66
|
+
'',
|
|
67
|
+
'Your job now: list every question that must be answered at the level of the request below before a plan for it can be made. Think of questions for the person, questions about how the system should be set up, and questions that could be researched. Include only questions at this level: the next step looks for an existing answer to each of your questions and writes the options for each one that is still open, together with the deeper questions each option raises, so leave the details of particular options to that step.',
|
|
68
|
+
`Do not list a question the request already answers. Write at most ${PLAN_MAX_ROOTS}, the most fundamental first.`,
|
|
69
|
+
].join('\n');
|
|
70
|
+
|
|
71
|
+
/** The options call: one open question's options, and what each raises. */
|
|
72
|
+
export const OPTIONS_INSTRUCTIONS = [
|
|
73
|
+
PLAN_CONTEXT,
|
|
74
|
+
'',
|
|
75
|
+
'Your job now: for one open question of the tree, write its options: the realistic, distinct answers someone could choose, the most common first, at most ' + `${PLAN_MAX_OPTIONS}` + '. Several options may be chosen together when they can apply at once; say so in the detail when they usually go together. For each option, list the new questions that must be answered if it is chosen, and only because it is chosen (at most ' + `${PLAN_MAX_RAISED}` + ' per option; none is fine). A question every option would raise belongs to every option. A question may well come up under several options or branches: write it each time it applies (the harness keeps one copy and links it). An option never raises the question it answers (the one you are writing options for) or any of the questions above it, in the same or other words: choosing an option answers its question, so asking that question again under it, or a question above it, makes no sense. Do not ask what the request or an earlier answer already settles either.',
|
|
76
|
+
'Take the request and the answers above into account: options that contradict a choice already made are not options.',
|
|
77
|
+
].join('\n');
|
|
78
|
+
|
|
79
|
+
/** One question above the one being planned, as the options prompt shows it. */
|
|
80
|
+
export interface AncestorLine {
|
|
81
|
+
readonly question: string;
|
|
82
|
+
/** The options picked, when the person answered it. */
|
|
83
|
+
readonly picked?: readonly string[];
|
|
84
|
+
/** The person's own words with the answer. */
|
|
85
|
+
readonly text?: string;
|
|
86
|
+
/** The option this branch sits under (when it isn't picked yet). */
|
|
87
|
+
readonly via?: string;
|
|
88
|
+
/** The options it offers. */
|
|
89
|
+
readonly offered: readonly string[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The first call's user message. */
|
|
93
|
+
export function questionsPrompt(description: string): string {
|
|
94
|
+
return ['The request:', description.trim()].join('\n');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The options call's user message: the request, the questions above (nearest last), and the question. */
|
|
98
|
+
export function optionsPrompt(description: string, ancestors: readonly AncestorLine[], question: string): string {
|
|
99
|
+
const above = ancestors.map((line, index) => {
|
|
100
|
+
const answer = line.picked !== undefined && line.picked.length > 0
|
|
101
|
+
? `answered: ${line.picked.join('; ')}${line.text === undefined ? '' : ` (${line.text})`}`
|
|
102
|
+
: line.text !== undefined ? `answered in the person's words: ${line.text}` : `not answered yet; options: ${line.offered.join(' / ')}${line.via === undefined ? '' : `; this branch is for "${line.via}"`}`;
|
|
103
|
+
return `${index + 1}. ${line.question} — ${answer}`;
|
|
104
|
+
});
|
|
105
|
+
return [
|
|
106
|
+
'The request:', description.trim(), '',
|
|
107
|
+
...(above.length === 0 ? ['The question is one of the first questions of the tree.'] : ['The questions above it, from the top:', ...above]), '',
|
|
108
|
+
'The question to write options for:', question,
|
|
109
|
+
].join('\n');
|
|
110
|
+
}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The planner behind `hub/ctx_plan` and `hub/ctx_plan_expand` (plan `context-questions`): it grows a plan's decision
|
|
3
|
+
* tree breadth first until a limit is reached.
|
|
4
|
+
*
|
|
5
|
+
* 1. **First questions** (a new plan): the plan model lists the questions the request needs answered at its own level.
|
|
6
|
+
* 2. **Matching**: every question it writes is matched with what context already keeps, by search and the decision
|
|
7
|
+
* model (`matchPlanQuestions`, the one search that sees open plan questions). A question asked before, in this plan
|
|
8
|
+
* or another, is the same item: it joins the plan once, with an edge from each option that raises it. A question
|
|
9
|
+
* whose item already has an answer is `known` (answered in context) and needs no options. Anything else becomes a
|
|
10
|
+
* `pending_plan` item with no content (`hub/plan.q-<hash>`).
|
|
11
|
+
* 3. **Options**: each open question gets the request, the questions above it with their picks (or the option this
|
|
12
|
+
* branch is for), and writes its options and the questions each raises, which join the plan one level deeper.
|
|
13
|
+
* The options become the item's content.
|
|
14
|
+
*
|
|
15
|
+
* It stops at the first limit: `minutes` and `cost` are checked before each round of model calls; `openQuestions`
|
|
16
|
+
* keeps a new open question out of the plan (it waits in its option's `later`), and so does `depth`. Questions left
|
|
17
|
+
* without options are `planned: false`, so planning deeper (`expand`) carries on where it stopped. Up to three option
|
|
18
|
+
* calls of one level go at once; their answers are applied in order, so a plan is the same however they finish.
|
|
19
|
+
*/
|
|
20
|
+
import type { Logger } from '@ayepi/log';
|
|
21
|
+
import {
|
|
22
|
+
contextAnswered, optionsContent, qualify, splitName, type ActorId, type ContextAskedBy, type ContextDecl, type ContextPlan, type ContextRecord, type LlmMessage, type PlanEdge,
|
|
23
|
+
type PlanLimits, type PlanOption, type PlanQuestion, type PlanStop, type ProgressReport, type QualifiedName, type ResolvedRole, type RunId,
|
|
24
|
+
} from '@harness/core';
|
|
25
|
+
import type { LlmGateway } from '../execution/index.ts';
|
|
26
|
+
import { HUB_SYSTEM } from '../catalog/availability.ts';
|
|
27
|
+
import { sha256Hex } from '../link/keys.ts';
|
|
28
|
+
import { estimateTokens } from '../resources/rules.ts';
|
|
29
|
+
import type { HubStore } from '../store/index.ts';
|
|
30
|
+
import type { PlanMatch } from './plan-match.ts';
|
|
31
|
+
import {
|
|
32
|
+
OPTIONS_INSTRUCTIONS, optionsPrompt, Options, PLAN_MAX_OPTIONS, PLAN_MAX_RAISED, PLAN_MAX_ROOTS, PLAN_PURPOSE, Questions, QUESTIONS_INSTRUCTIONS, questionsPrompt,
|
|
33
|
+
type AncestorLine, type WrittenQuestion,
|
|
34
|
+
} from './plan-prompts.ts';
|
|
35
|
+
|
|
36
|
+
/** How many options calls of one level go at once. */
|
|
37
|
+
const PARALLEL = 3;
|
|
38
|
+
|
|
39
|
+
/** The tag every item a plan makes carries. */
|
|
40
|
+
export const PLAN_TAG = 'plan';
|
|
41
|
+
|
|
42
|
+
/** The local-name prefix of the items plans make (`hub/plan.q-1a2b3c4d`). */
|
|
43
|
+
export const PLAN_ITEM_PREFIX = 'plan.q-';
|
|
44
|
+
|
|
45
|
+
/** Whether an item is one a plan made (its status and content are the plans'); any other item is only read. */
|
|
46
|
+
export function planMade(name: QualifiedName): boolean {
|
|
47
|
+
const { system, local } = splitName(name);
|
|
48
|
+
return system === 'hub' && local.startsWith(PLAN_ITEM_PREFIX);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The item a new plan question becomes, named from its words so the same words are the same item. */
|
|
52
|
+
export function planItemName(question: string): QualifiedName {
|
|
53
|
+
return qualify('hub', `${PLAN_ITEM_PREFIX}${sha256Hex(normalized(question)).slice(0, 8)}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A question's words, compared: lower case, single spaces, no closing punctuation. */
|
|
57
|
+
export function normalized(question: string): string {
|
|
58
|
+
return question.trim().toLowerCase().replace(/\s+/g, ' ').replace(/[?.!\s]+$/, '');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** What the planner needs. */
|
|
62
|
+
export interface PlannerDeps {
|
|
63
|
+
readonly store: HubStore;
|
|
64
|
+
readonly llm: () => Pick<LlmGateway, 'chat'>;
|
|
65
|
+
readonly clock: () => number;
|
|
66
|
+
readonly log: Logger;
|
|
67
|
+
readonly hubActor: ActorId;
|
|
68
|
+
/** Match questions with existing items (`ContextQuestions.matchPlanQuestions`); undefined while no decision model is set. */
|
|
69
|
+
readonly match: (questions: readonly string[], signal: AbortSignal, options: { readonly run?: RunId; readonly onCost?: (cost: number) => void }) => Promise<PlanMatch[] | undefined>;
|
|
70
|
+
/** Store an item with its edges and index rows, and say it changed. */
|
|
71
|
+
readonly write: (record: ContextRecord) => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** One planning session's work: what to plan, within which limits, for which run. */
|
|
75
|
+
export interface PlanJob {
|
|
76
|
+
readonly model: ResolvedRole;
|
|
77
|
+
readonly limits: PlanLimits;
|
|
78
|
+
/** The deepest level questions may be added at (a new plan: `limits.depth`; planning deeper: from its question). */
|
|
79
|
+
readonly maxDepth: number;
|
|
80
|
+
readonly run?: RunId;
|
|
81
|
+
readonly signal: AbortSignal;
|
|
82
|
+
readonly progress?: (report: ProgressReport) => void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Whether a run's signal says stop now (read afresh: a round of calls may have stopped it). */
|
|
86
|
+
function stoppedNow(signal: AbortSignal): boolean {
|
|
87
|
+
return signal.aborted;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Why the planner could not start. */
|
|
91
|
+
export class PlanFailed extends Error {}
|
|
92
|
+
|
|
93
|
+
/** A question with what the model wrote for it, applied in order once a round's calls are back. */
|
|
94
|
+
interface Written {
|
|
95
|
+
readonly name: QualifiedName;
|
|
96
|
+
readonly options: readonly { readonly label: string; readonly detail: string; readonly raises: readonly WrittenQuestion[] }[] | undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The plan being grown: its questions by name, and what is still to do. */
|
|
100
|
+
class Work {
|
|
101
|
+
readonly questions = new Map<QualifiedName, PlanQuestion>();
|
|
102
|
+
readonly byWords = new Map<string, QualifiedName>();
|
|
103
|
+
roots: QualifiedName[];
|
|
104
|
+
queue: QualifiedName[] = [];
|
|
105
|
+
cost = 0;
|
|
106
|
+
/** The first limit that kept a question out (open questions, depth), kept to report if nothing stops harder. */
|
|
107
|
+
held: PlanStop | undefined;
|
|
108
|
+
/** What stopped it outright (time, cost, a stop). */
|
|
109
|
+
stopped: PlanStop | undefined;
|
|
110
|
+
readonly started: number;
|
|
111
|
+
|
|
112
|
+
constructor(plan: Pick<ContextPlan, 'roots' | 'questions'>, started: number) {
|
|
113
|
+
this.roots = [...plan.roots];
|
|
114
|
+
for (const question of plan.questions) {
|
|
115
|
+
this.questions.set(question.name, { ...question, parents: [...question.parents], options: question.options.map((option) => ({ ...option, raises: [...option.raises] })) });
|
|
116
|
+
this.byWords.set(normalized(question.question), question.name);
|
|
117
|
+
}
|
|
118
|
+
this.started = started;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Open questions now: in the plan, not answered in context, no answer of their own. */
|
|
122
|
+
open(): number {
|
|
123
|
+
let count = 0;
|
|
124
|
+
for (const question of this.questions.values()) if (question.known !== true && question.picked.length === 0 && (question.text ?? '') === '' && question.status !== 'not_applicable') count += 1;
|
|
125
|
+
return count;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
list(): PlanQuestion[] {
|
|
129
|
+
return [...this.questions.values()];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A question and every question above it, along all its parents: what its options may never raise. */
|
|
133
|
+
above(name: QualifiedName): Set<QualifiedName> {
|
|
134
|
+
const seen = new Set<QualifiedName>([name]);
|
|
135
|
+
const queue = [name];
|
|
136
|
+
for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
|
|
137
|
+
for (const edge of this.questions.get(next)?.parents ?? []) {
|
|
138
|
+
if (seen.has(edge.question)) continue;
|
|
139
|
+
seen.add(edge.question);
|
|
140
|
+
queue.push(edge.question);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return seen;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Grows plans. */
|
|
148
|
+
export class ContextPlanner {
|
|
149
|
+
readonly #deps: PlannerDeps;
|
|
150
|
+
|
|
151
|
+
constructor(deps: PlannerDeps) {
|
|
152
|
+
this.#deps = deps;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** A new plan's tree: its first questions, then options breadth first within the limits. */
|
|
156
|
+
async create(description: string, job: PlanJob): Promise<{ readonly roots: QualifiedName[]; readonly questions: PlanQuestion[]; readonly stop: PlanStop; readonly cost: number }> {
|
|
157
|
+
const work = new Work({ roots: [], questions: [] }, this.#deps.clock());
|
|
158
|
+
this.#report(work, job, 'Listing the questions');
|
|
159
|
+
const answer = await this.#deps.llm().chat(
|
|
160
|
+
{ request: { messages: this.#messages(QUESTIONS_INSTRUCTIONS, questionsPrompt(description)), responseFormat: Questions.responseFormat }, model: { model: job.model.model }, provider: job.model.provider },
|
|
161
|
+
{ purpose: PLAN_PURPOSE, ...(job.run === undefined ? {} : { run: job.run }) }, job.signal,
|
|
162
|
+
);
|
|
163
|
+
work.cost += answer.cost;
|
|
164
|
+
const first = (Questions.read(answer.value)?.questions ?? []).filter((one) => one.question.trim() !== '').slice(0, PLAN_MAX_ROOTS);
|
|
165
|
+
if (first.length === 0) throw new PlanFailed('The plan model gave no questions for that request; say more about what is to be done and try again.');
|
|
166
|
+
work.roots = (await this.#attach(work, first, undefined, 1, job)).added;
|
|
167
|
+
await this.#grow(work, description, job);
|
|
168
|
+
return { roots: work.roots, questions: work.list(), stop: work.stopped ?? work.held ?? 'complete', cost: work.cost };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Plan deeper in an existing plan: write options for `todo` (questions without them, in order), add the questions
|
|
173
|
+
* options kept for later (`later`, for the options in `laterOf`), and go on breadth first within the job's limits.
|
|
174
|
+
*/
|
|
175
|
+
async grow(
|
|
176
|
+
plan: Pick<ContextPlan, 'description' | 'roots' | 'questions'>, todo: readonly QualifiedName[], laterOf: readonly PlanEdge[], job: PlanJob,
|
|
177
|
+
): Promise<{ readonly roots: QualifiedName[]; readonly questions: PlanQuestion[]; readonly stop: PlanStop; readonly cost: number }> {
|
|
178
|
+
const work = new Work(plan, this.#deps.clock());
|
|
179
|
+
for (const edge of laterOf) {
|
|
180
|
+
const parent = work.questions.get(edge.question);
|
|
181
|
+
const option = parent?.options.find((one) => one.id === edge.option);
|
|
182
|
+
if (parent === undefined || option?.later === undefined || option.later.length === 0) continue;
|
|
183
|
+
const later = option.later.map((question): WrittenQuestion => ({ question, askedBy: 'person' }));
|
|
184
|
+
delete option.later;
|
|
185
|
+
await this.#raise(work, parent, option, later, job);
|
|
186
|
+
}
|
|
187
|
+
for (const name of todo) if (!work.queue.includes(name) && work.questions.get(name)?.planned === false) work.queue.push(name);
|
|
188
|
+
await this.#grow(work, plan.description, job);
|
|
189
|
+
return { roots: work.roots, questions: work.list(), stop: work.stopped ?? work.held ?? 'complete', cost: work.cost };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Write options level by level until the queue is empty or a limit stops it. */
|
|
193
|
+
async #grow(work: Work, description: string, job: PlanJob): Promise<void> {
|
|
194
|
+
const { clock, log } = this.#deps;
|
|
195
|
+
while (work.queue.length > 0) {
|
|
196
|
+
if (job.signal.aborted) { work.stopped = 'stopped'; break; }
|
|
197
|
+
if (clock() - work.started >= job.limits.minutes * 60_000) { work.stopped = 'time'; break; }
|
|
198
|
+
if (work.cost >= job.limits.cost) { work.stopped = 'cost'; break; }
|
|
199
|
+
// the next round: up to three questions of the shallowest level waiting
|
|
200
|
+
const depth = Math.min(...work.queue.map((name) => work.questions.get(name)?.depth ?? Number.POSITIVE_INFINITY));
|
|
201
|
+
const round = work.queue.filter((name) => (work.questions.get(name)?.depth ?? 0) === depth).slice(0, PARALLEL);
|
|
202
|
+
work.queue = work.queue.filter((name) => !round.includes(name));
|
|
203
|
+
this.#report(work, job, `Writing options at level ${depth}`);
|
|
204
|
+
const written = await Promise.all(round.map(async (name): Promise<Written> => {
|
|
205
|
+
const question = work.questions.get(name);
|
|
206
|
+
if (question === undefined || question.planned) return { name, options: undefined };
|
|
207
|
+
try {
|
|
208
|
+
return { name, options: await this.#options(work, description, question, job) };
|
|
209
|
+
} catch (error) {
|
|
210
|
+
if (!job.signal.aborted) log.warn('context.plan.options-failed', { question: name, error: error instanceof Error ? error.message : String(error) });
|
|
211
|
+
return { name, options: undefined };
|
|
212
|
+
}
|
|
213
|
+
}));
|
|
214
|
+
for (const one of written) {
|
|
215
|
+
const question = work.questions.get(one.name);
|
|
216
|
+
if (question === undefined || one.options === undefined) continue;
|
|
217
|
+
await this.#apply(work, question, one.options, job);
|
|
218
|
+
}
|
|
219
|
+
if (stoppedNow(job.signal)) { work.stopped = 'stopped'; break; }
|
|
220
|
+
}
|
|
221
|
+
this.#report(work, job, 'Done');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** One question's options from the plan model. */
|
|
225
|
+
async #options(work: Work, description: string, question: PlanQuestion, job: PlanJob): Promise<Written['options']> {
|
|
226
|
+
const answer = await this.#deps.llm().chat(
|
|
227
|
+
{ request: { messages: this.#messages(OPTIONS_INSTRUCTIONS, optionsPrompt(description, this.#ancestors(work, question), question.question)), responseFormat: Options.responseFormat }, model: { model: job.model.model }, provider: job.model.provider },
|
|
228
|
+
{ purpose: PLAN_PURPOSE, ...(job.run === undefined ? {} : { run: job.run }) }, job.signal,
|
|
229
|
+
);
|
|
230
|
+
work.cost += answer.cost;
|
|
231
|
+
const options = (Options.read(answer.value)?.options ?? []).filter((option) => option.label.trim() !== '').slice(0, PLAN_MAX_OPTIONS);
|
|
232
|
+
return options.map((option) => ({ label: option.label.trim().slice(0, 200), detail: option.detail.trim().slice(0, 1000), raises: option.raises.filter((one) => one.question.trim() !== '').slice(0, PLAN_MAX_RAISED) }));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Put a question's options on it (and its item), then add the questions each raises one level deeper. */
|
|
236
|
+
async #apply(work: Work, question: PlanQuestion, written: NonNullable<Written['options']>, job: PlanJob): Promise<void> {
|
|
237
|
+
question.options = written.map((option, index): PlanOption => ({ id: `o${index + 1}`, label: option.label, ...(option.detail === '' ? {} : { detail: option.detail }), raises: [] }));
|
|
238
|
+
question.planned = true;
|
|
239
|
+
await this.#writeContent(question);
|
|
240
|
+
for (const [index, option] of question.options.entries()) {
|
|
241
|
+
const raised = written[index]?.raises ?? [];
|
|
242
|
+
if (raised.length > 0) await this.#raise(work, question, option, raised, job);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Add the questions an option raises under it, or keep them for later when a limit says so. An option never raises
|
|
248
|
+
* its own question or one above it (the model sometimes writes them again): they are dropped, by their words here
|
|
249
|
+
* and by the item the matching finds in `#attach`, so the tree stays a tree with shared questions, never a loop.
|
|
250
|
+
*/
|
|
251
|
+
async #raise(work: Work, parent: PlanQuestion, option: PlanOption, written: readonly WrittenQuestion[], job: PlanJob): Promise<void> {
|
|
252
|
+
const above = work.above(parent.name);
|
|
253
|
+
const raised = written.filter((one) => {
|
|
254
|
+
const same = work.byWords.get(normalized(one.question));
|
|
255
|
+
return same === undefined || !above.has(same);
|
|
256
|
+
});
|
|
257
|
+
if (raised.length === 0) return;
|
|
258
|
+
if (parent.depth + 1 > job.maxDepth) {
|
|
259
|
+
option.later = [...(option.later ?? []), ...raised.map((one) => one.question.trim())];
|
|
260
|
+
work.held ??= 'depth';
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const { added, kept } = await this.#attach(work, raised, { question: parent.name, option: option.id }, parent.depth + 1, job, above);
|
|
264
|
+
for (const name of added) if (!option.raises.includes(name)) option.raises.push(name);
|
|
265
|
+
if (kept.length > 0) option.later = [...(option.later ?? []), ...kept];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Add questions to the plan under `edge` (none: first questions): each the same item as a question with the same
|
|
270
|
+
* words in the plan, else the item the matching found, else a new open item. A new open question past the
|
|
271
|
+
* open-question limit is kept out (`kept`). A question the matching finds to be one of `above` (the raising option's
|
|
272
|
+
* own question and those above it) is dropped.
|
|
273
|
+
*/
|
|
274
|
+
async #attach(
|
|
275
|
+
work: Work, raised: readonly WrittenQuestion[], edge: PlanEdge | undefined, depth: number, job: PlanJob, above: ReadonlySet<QualifiedName> = new Set(),
|
|
276
|
+
): Promise<{ readonly added: QualifiedName[]; readonly kept: string[] }> {
|
|
277
|
+
const added: QualifiedName[] = [];
|
|
278
|
+
const kept: string[] = [];
|
|
279
|
+
const fresh: WrittenQuestion[] = [];
|
|
280
|
+
for (const one of raised) {
|
|
281
|
+
const words = normalized(one.question);
|
|
282
|
+
const same = work.byWords.get(words);
|
|
283
|
+
if (same !== undefined) { this.#link(work, same, edge, depth, added); continue; }
|
|
284
|
+
if (!fresh.some((other) => normalized(other.question) === words)) fresh.push({ question: one.question.trim().slice(0, 500), askedBy: one.askedBy });
|
|
285
|
+
}
|
|
286
|
+
if (fresh.length === 0) return { added, kept };
|
|
287
|
+
const matches = await this.#deps.match(fresh.map((one) => one.question), job.signal, { ...(job.run === undefined ? {} : { run: job.run }), onCost: (cost) => { work.cost += cost; } });
|
|
288
|
+
if (matches === undefined) throw new PlanFailed('No decision model is set, so the plan can\'t check its questions against context (an admin sets the Decisions role).');
|
|
289
|
+
for (const [index, one] of fresh.entries()) {
|
|
290
|
+
const matched = matches[index]?.match?.record ?? (await this.#deps.store.table('context').get(planItemName(one.question)));
|
|
291
|
+
const name = matched?.name ?? planItemName(one.question);
|
|
292
|
+
if (above.has(name)) continue;
|
|
293
|
+
if (work.questions.has(name)) { this.#link(work, name, edge, depth, added); work.byWords.set(normalized(one.question), name); continue; }
|
|
294
|
+
const known = matched !== undefined && (contextAnswered(matched) || !planMade(matched.name));
|
|
295
|
+
if (!known && work.open() >= job.limits.openQuestions) { kept.push(one.question); work.held ??= 'open_questions'; continue; }
|
|
296
|
+
const record = matched ?? (await this.#create(one.question, one.askedBy));
|
|
297
|
+
const question: PlanQuestion = {
|
|
298
|
+
name, question: record.decl.question ?? one.question, askedBy: record.askedBy ?? one.askedBy, depth,
|
|
299
|
+
parents: edge === undefined ? [] : [edge], options: [], planned: known, ...(known ? { known: true } : {}), picked: [],
|
|
300
|
+
// an open question is open in this plan, whatever another plan ruled
|
|
301
|
+
status: known ? record.status : 'pending_plan', ...(known && record.statusReason !== undefined ? { statusReason: record.statusReason } : {}),
|
|
302
|
+
};
|
|
303
|
+
work.questions.set(name, question);
|
|
304
|
+
work.byWords.set(normalized(one.question), name);
|
|
305
|
+
work.byWords.set(normalized(question.question), name);
|
|
306
|
+
added.push(name);
|
|
307
|
+
if (!known) work.queue.push(name);
|
|
308
|
+
}
|
|
309
|
+
return { added, kept };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Link a question already in the plan under one more option (a shared question), raising its level when this one is shallower. */
|
|
313
|
+
#link(work: Work, name: QualifiedName, edge: PlanEdge | undefined, depth: number, added: QualifiedName[]): void {
|
|
314
|
+
const question = work.questions.get(name);
|
|
315
|
+
if (question === undefined) return;
|
|
316
|
+
if (edge === undefined) { if (!work.roots.includes(name)) work.roots.push(name); } else if (edge.question !== name && !question.parents.some((one) => one.question === edge.question && one.option === edge.option)) question.parents.push(edge);
|
|
317
|
+
if (depth < question.depth) question.depth = depth;
|
|
318
|
+
if (!added.includes(name)) added.push(name);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** A new open plan question: a hub item with no answer, seen only by plans. */
|
|
322
|
+
async #create(question: string, askedBy: ContextAskedBy): Promise<ContextRecord> {
|
|
323
|
+
const { clock } = this.#deps;
|
|
324
|
+
const name = planItemName(question);
|
|
325
|
+
const words = question.trim().slice(0, 500);
|
|
326
|
+
const decl: ContextDecl = {
|
|
327
|
+
name: splitName(name).local, title: words, description: words, content: '', question: words, when: `When deciding: ${words}`.slice(0, 500),
|
|
328
|
+
imports: [], fns: [], suggestFns: [], suggest: 'none', visible: 'both', tags: [PLAN_TAG],
|
|
329
|
+
};
|
|
330
|
+
const record: ContextRecord = {
|
|
331
|
+
name, system: HUB_SYSTEM, declaredBy: 'runtime', decl, status: 'pending_plan', askedBy, lastModified: clock(),
|
|
332
|
+
tokens: { full: 0, summary: estimateTokens(words) }, mentions: { context: [], fns: [] }, stale: false, updatedAt: clock(),
|
|
333
|
+
};
|
|
334
|
+
await this.#deps.write(record);
|
|
335
|
+
return record;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** An open plan item's content: its options (no model sees it until it is answered). */
|
|
339
|
+
async #writeContent(question: PlanQuestion): Promise<void> {
|
|
340
|
+
if (!planMade(question.name)) return;
|
|
341
|
+
const record = await this.#deps.store.table('context').get(question.name);
|
|
342
|
+
if (record === undefined || record.status !== 'pending_plan') return;
|
|
343
|
+
const content = optionsContent(question);
|
|
344
|
+
if (record.decl.content === content) return;
|
|
345
|
+
await this.#deps.write({ ...record, decl: { ...record.decl, content }, tokens: { full: estimateTokens(content), summary: record.tokens?.summary ?? 0 }, updatedAt: this.#deps.clock() });
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** The questions above one (along its first parents, from the top), with their picks or what they offer. */
|
|
349
|
+
#ancestors(work: Work, question: PlanQuestion): AncestorLine[] {
|
|
350
|
+
const lines: AncestorLine[] = [];
|
|
351
|
+
const seen = new Set<QualifiedName>([question.name]);
|
|
352
|
+
let at: PlanQuestion = question;
|
|
353
|
+
while (lines.length < 12) {
|
|
354
|
+
const edge: PlanEdge | undefined = at.parents[0];
|
|
355
|
+
const parent: PlanQuestion | undefined = edge === undefined ? undefined : work.questions.get(edge.question);
|
|
356
|
+
if (edge === undefined || parent === undefined || seen.has(parent.name)) break;
|
|
357
|
+
seen.add(parent.name);
|
|
358
|
+
const picked = parent.options.filter((option) => parent.picked.includes(option.id)).map((option) => option.label);
|
|
359
|
+
const via = parent.options.find((option) => option.id === edge.option)?.label;
|
|
360
|
+
lines.unshift({
|
|
361
|
+
question: parent.question, offered: parent.options.map((option) => option.label),
|
|
362
|
+
...(picked.length > 0 ? { picked } : {}), ...(parent.text === undefined || parent.text === '' ? {} : { text: parent.text }), ...(via === undefined ? {} : { via }),
|
|
363
|
+
});
|
|
364
|
+
at = parent;
|
|
365
|
+
}
|
|
366
|
+
return lines;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
#messages(system: string, user: string): LlmMessage[] {
|
|
370
|
+
return [{ role: 'system', content: system }, { role: 'user', content: user }];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** Say how far it is: the fraction of the nearest limit used, and the numbers. */
|
|
374
|
+
#report(work: Work, job: PlanJob, doing: string): void {
|
|
375
|
+
if (job.progress === undefined) return;
|
|
376
|
+
const elapsed = this.#deps.clock() - work.started;
|
|
377
|
+
const open = work.open();
|
|
378
|
+
const fraction = Math.min(1, Math.max(elapsed / (job.limits.minutes * 60_000), job.limits.cost === 0 ? 1 : work.cost / job.limits.cost, open / job.limits.openQuestions));
|
|
379
|
+
const deepest = Math.max(0, ...work.list().map((question) => question.depth));
|
|
380
|
+
job.progress({ fraction, message: `${doing} · ${work.questions.size} questions (${open} open) · level ${deepest} · $${work.cost.toFixed(2)} · ${Math.round(elapsed / 1000)} s` });
|
|
381
|
+
}
|
|
382
|
+
}
|