fnloom 0.3.0 → 0.4.1
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 +27 -20
- package/package.json +14 -11
- package/packages/build/package.json +2 -2
- package/packages/build/src/tests.ts +2 -2
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/cli.ts +2 -2
- package/packages/cli/src/command.ts +2 -2
- package/packages/cli/src/commands/install.ts +1 -1
- package/packages/cli/src/commands/mcp.ts +6 -6
- package/packages/cli/src/commands/store.ts +3 -3
- package/packages/cli/src/hub.ts +25 -25
- package/packages/cli/src/index.ts +1 -1
- package/packages/cli/src/io.ts +2 -2
- package/packages/cli/src/local.ts +7 -7
- package/packages/cli/src/premade.ts +1 -1
- package/packages/core/package.json +4 -4
- package/packages/core/src/auto-pair.ts +1 -1
- package/packages/core/src/connections.ts +1 -14
- package/packages/core/src/context-graph.ts +1 -1
- package/packages/core/src/data.ts +1 -1
- package/packages/core/src/gin-a.ts +13 -2
- package/packages/core/src/https.ts +2 -2
- package/packages/core/src/identity.ts +1 -1
- package/packages/core/src/image-embeddings.ts +1 -1
- package/packages/core/src/index.ts +5 -7
- package/packages/core/src/link.ts +1 -1
- package/packages/core/src/manifest.ts +2 -2
- package/packages/core/src/mention-search.ts +1 -1
- package/packages/core/src/model-calls.ts +1 -1
- package/packages/core/src/package.ts +1 -1
- package/packages/core/src/ports.ts +2 -2
- package/packages/core/src/query.ts +1 -1
- package/packages/core/src/records/chat.ts +1 -1
- package/packages/core/src/records/runs.ts +1 -1
- package/packages/core/src/records/spend.ts +4 -0
- package/packages/core/src/registries.ts +9 -3
- package/packages/core/src/sso.ts +2 -2
- package/packages/core/src/stores.ts +1 -1
- package/packages/core/src/suggestions.ts +2 -2
- package/packages/core/src/system-pages.ts +32 -6
- package/packages/core/src/tables.ts +233 -0
- package/packages/core/src/visuals.ts +47 -139
- package/packages/core/src/web.ts +2 -2
- package/packages/core/src/widgets-v1.ts +78 -1
- package/packages/hub/package.json +13 -11
- package/packages/hub/src/api/admin-ops.ts +5 -5
- package/packages/hub/src/api/auth.ts +2 -2
- package/packages/hub/src/api/https.ts +6 -6
- package/packages/hub/src/api/identities.ts +1 -1
- package/packages/hub/src/api/reads.ts +1 -1
- package/packages/hub/src/api/secrets.ts +1 -1
- package/packages/hub/src/api/serve.ts +2 -2
- package/packages/hub/src/api/sso-route.ts +2 -2
- package/packages/hub/src/api/sso.ts +6 -6
- package/packages/hub/src/api/store-ops.ts +9 -2
- package/packages/hub/src/api/testing/rig.ts +1 -1
- package/packages/hub/src/api/tls.ts +2 -2
- package/packages/hub/src/api/web/auth.ts +1 -1
- package/packages/hub/src/api/web/find.ts +1 -1
- package/packages/hub/src/api/web/pages.ts +4 -3
- package/packages/hub/src/api/web/pickers.ts +4 -4
- package/packages/hub/src/boot/env.ts +82 -78
- package/packages/hub/src/boot/hub-fns.ts +1 -1
- package/packages/hub/src/boot/identity.ts +2 -2
- package/packages/hub/src/boot/index.ts +1 -1
- package/packages/hub/src/boot/info.ts +1 -1
- package/packages/hub/src/boot/keys.ts +6 -6
- package/packages/hub/src/boot/log.ts +4 -4
- package/packages/hub/src/boot/modules.ts +4 -4
- package/packages/hub/src/boot/services.ts +9 -9
- package/packages/hub/src/boot/start.ts +23 -23
- package/packages/hub/src/catalog/catalog.ts +3 -2
- package/packages/hub/src/chat/cache.ts +1 -1
- package/packages/hub/src/chat/chat.ts +1 -1
- package/packages/hub/src/chat/compare.ts +2 -2
- package/packages/hub/src/chat/deliveries.ts +1 -1
- package/packages/hub/src/chat/deps.ts +3 -3
- package/packages/hub/src/chat/enrich.ts +7 -7
- package/packages/hub/src/chat/env.ts +20 -20
- package/packages/hub/src/chat/mention-requests.ts +1 -1
- package/packages/hub/src/chat/mention-search.ts +1 -1
- package/packages/hub/src/chat/mentions.ts +3 -3
- package/packages/hub/src/chat/notifications.ts +2 -2
- package/packages/hub/src/chat/presence.ts +2 -2
- package/packages/hub/src/chat/sessions.ts +2 -2
- package/packages/hub/src/chat/suggestions.ts +8 -8
- package/packages/hub/src/chat/testing.ts +1 -1
- package/packages/hub/src/chat/turns.ts +6 -6
- package/packages/hub/src/chat/undo.ts +1 -1
- package/packages/hub/src/connections/create.ts +1 -1
- package/packages/hub/src/connections/env.ts +2 -2
- package/packages/hub/src/connections/service.ts +5 -9
- package/packages/hub/src/contextor/contextors.ts +9 -9
- package/packages/hub/src/contextor/crawl.ts +1 -1
- package/packages/hub/src/contextor/create.ts +5 -5
- package/packages/hub/src/contextor/dynamic.ts +5 -5
- package/packages/hub/src/contextor/env.ts +46 -46
- package/packages/hub/src/contextor/injected.ts +1 -1
- package/packages/hub/src/contextor/limits.ts +9 -9
- package/packages/hub/src/contextor/planner.ts +11 -11
- package/packages/hub/src/contextor/testing.ts +1 -1
- package/packages/hub/src/data/env.ts +3 -3
- package/packages/hub/src/data/service.ts +5 -5
- package/packages/hub/src/execution/agent.ts +8 -8
- package/packages/hub/src/execution/ai.ts +7 -7
- package/packages/hub/src/execution/create.ts +11 -6
- package/packages/hub/src/execution/env.ts +16 -16
- package/packages/hub/src/execution/executors.ts +2 -2
- package/packages/hub/src/execution/gateway.ts +1 -1
- package/packages/hub/src/execution/index.ts +1 -1
- package/packages/hub/src/execution/ledger.ts +2 -2
- package/packages/hub/src/execution/limits.ts +2 -2
- package/packages/hub/src/execution/models.ts +2 -2
- package/packages/hub/src/execution/ports.ts +1 -1
- package/packages/hub/src/execution/providers.ts +55 -11
- package/packages/hub/src/execution/queues.ts +6 -6
- package/packages/hub/src/execution/runs.ts +10 -10
- package/packages/hub/src/execution/stream-guard.ts +2 -2
- package/packages/hub/src/execution/testing.ts +5 -5
- package/packages/hub/src/execution/wire.ts +3 -3
- package/packages/hub/src/fns/auto.ts +2 -2
- package/packages/hub/src/fns/client-logs.ts +2 -2
- package/packages/hub/src/fns/create.ts +2 -2
- package/packages/hub/src/fns/decided.ts +2 -2
- package/packages/hub/src/fns/env.ts +14 -14
- package/packages/hub/src/fns/examples.ts +3 -3
- package/packages/hub/src/fns/facts.ts +5 -5
- package/packages/hub/src/fns/search.ts +5 -5
- package/packages/hub/src/graph/graph.ts +1 -1
- package/packages/hub/src/index/context-sections.ts +1 -1
- package/packages/hub/src/index/embedders.ts +3 -3
- package/packages/hub/src/index/env.ts +12 -12
- package/packages/hub/src/index/index.ts +1 -1
- package/packages/hub/src/index/indexer.ts +4 -4
- package/packages/hub/src/index/search.ts +1 -1
- package/packages/hub/src/index/testing.ts +2 -2
- package/packages/hub/src/link/build.ts +32 -32
- package/packages/hub/src/link/env.ts +14 -14
- package/packages/hub/src/link/grants.ts +10 -10
- package/packages/hub/src/link/lifecycle.ts +4 -4
- package/packages/hub/src/link/migrate-api.ts +55 -15
- package/packages/hub/src/link/pairing.ts +1 -1
- package/packages/hub/src/link/process.ts +1 -1
- package/packages/hub/src/link/rig.ts +12 -12
- package/packages/hub/src/link/supervisor.ts +1 -1
- package/packages/hub/src/mcp/calls.ts +6 -6
- package/packages/hub/src/mcp/create.ts +5 -5
- package/packages/hub/src/mcp/env.ts +6 -6
- package/packages/hub/src/mcp/fns.ts +2 -2
- package/packages/hub/src/mcp/index.ts +2 -2
- package/packages/hub/src/mcp/sources.ts +3 -3
- package/packages/hub/src/mcp/tokens.ts +1 -1
- package/packages/hub/src/models/create.ts +1 -1
- package/packages/hub/src/models/decide.ts +2 -2
- package/packages/hub/src/models/index.ts +1 -1
- package/packages/hub/src/models/roles.ts +12 -12
- package/packages/hub/src/query/env.ts +5 -5
- package/packages/hub/src/query/sources.ts +3 -3
- package/packages/hub/src/questions/plans.ts +1 -1
- package/packages/hub/src/questions/worker.ts +2 -2
- package/packages/hub/src/resources/context.ts +3 -3
- package/packages/hub/src/resources/converters.ts +2 -2
- package/packages/hub/src/resources/create.ts +6 -6
- package/packages/hub/src/resources/env.ts +15 -15
- package/packages/hub/src/resources/fetch.ts +5 -5
- package/packages/hub/src/resources/forms.ts +5 -5
- package/packages/hub/src/resources/index.ts +1 -1
- package/packages/hub/src/resources/library.ts +2 -2
- package/packages/hub/src/resources/raw.ts +1 -1
- package/packages/hub/src/resources/reader.ts +2 -2
- package/packages/hub/src/resources/sqlite-files.ts +1 -1
- package/packages/hub/src/resources/storage.ts +5 -5
- package/packages/hub/src/resources/testing.ts +6 -6
- package/packages/hub/src/store/env.ts +4 -4
- package/packages/hub/src/store/hybrid.ts +4 -4
- package/packages/hub/src/store/sqlite.ts +3 -3
- package/packages/hub/src/stores/drivers.ts +2 -2
- package/packages/hub/src/stores/host.ts +3 -3
- package/packages/hub/src/stores/moves.ts +2 -2
- package/packages/hub/src/stores/service.ts +2 -2
- package/packages/hub/src/tables/env.ts +3 -3
- package/packages/hub/src/tables/index.ts +5 -5
- package/packages/hub/src/tables/service.ts +7 -7
- package/packages/sdk/AUTHORING.md +1206 -881
- package/packages/sdk/package.json +11 -8
- package/packages/sdk/src/agent.ts +1 -1
- package/packages/sdk/src/app-parts.ts +95 -0
- package/packages/sdk/src/authored.ts +26 -0
- package/packages/sdk/src/authoring.ts +13 -30
- package/packages/sdk/src/client-runtime.ts +24 -1
- package/packages/sdk/src/client-ui/AddServiceDialog.vue +43 -0
- package/packages/sdk/src/client-ui/InstanceNameField.vue +29 -0
- package/packages/sdk/src/client-ui/PairRowsEditor.vue +74 -0
- package/packages/sdk/src/client-ui/RemoteAuthFields.vue +95 -0
- package/packages/sdk/src/client-ui/ServiceRows.vue +57 -0
- package/packages/sdk/src/client-ui/draft.ts +10 -0
- package/packages/sdk/src/client-ui/host.ts +37 -0
- package/packages/sdk/src/client-ui/index.ts +19 -0
- package/packages/sdk/src/client-ui/loaded.ts +69 -0
- package/packages/sdk/src/client-ui/problems.ts +98 -0
- package/packages/sdk/src/client-ui/remote-config.ts +199 -0
- package/packages/sdk/src/client-ui/service-rows.ts +25 -0
- package/packages/sdk/src/client-ui/state.ts +14 -0
- package/packages/sdk/src/client-ui/testing.ts +147 -0
- package/packages/sdk/src/client-ui/vue-shim.d.ts +13 -0
- package/packages/sdk/src/client.ts +82 -11
- package/packages/sdk/src/hub.ts +4 -4
- package/packages/sdk/src/index.ts +13 -9
- package/packages/sdk/src/page-parts.ts +4 -0
- package/packages/sdk/src/program/env.ts +7 -7
- package/packages/sdk/src/program/runtime.ts +5 -5
- package/packages/sdk/src/program/tools.ts +3 -3
- package/packages/sdk/src/remote-auth.ts +128 -7
- package/packages/sdk/src/server/context-files.ts +1 -1
- package/packages/sdk/src/server/env.ts +36 -36
- package/packages/sdk/src/server/fake-hub-widgets.ts +7 -6
- package/packages/sdk/src/server/host.ts +28 -28
- package/packages/sdk/src/server/index.ts +2 -2
- package/packages/sdk/src/server/live.ts +4 -4
- package/packages/sdk/src/server/llm-wire.ts +54 -5
- package/packages/sdk/src/server/pairing.ts +1 -1
- package/packages/sdk/src/server/results.ts +4 -4
- package/packages/sdk/src/server/socket-guard.ts +1 -1
- package/packages/sdk/src/server/start-gate.ts +2 -2
- package/packages/sdk/src/server/store/engines.ts +2 -2
- package/packages/sdk/src/server/store/keeper.ts +2 -2
- package/packages/sdk/src/server/supervise.ts +4 -4
- package/packages/sdk/src/testing/env.ts +6 -6
- package/packages/sdk/src/testing/hub.ts +3 -1
- package/packages/sdk/src/testing/models.ts +3 -3
- package/packages/sdk/src/testing/openrouter.ts +3 -2
- package/packages/sdk/src/testing/preview.ts +7 -7
- package/packages/sdk/src/widgets.ts +21 -136
- package/packages/sdk/tsconfig.json +2 -2
- package/packages/web/dist/assets/{ActorSettingsView-v2k7v454.js → ActorSettingsView-CiWhrnP4.js} +2 -2
- package/packages/web/dist/assets/AdminLayout-CjVNzmYD.js +2 -0
- package/packages/web/dist/assets/{AdminLayout-1hbRPV3d.css → AdminLayout-ggcdQGlQ.css} +1 -1
- package/packages/web/dist/assets/{AppPage-CFmKZS8G.js → AppPage-D_kkUatv.js} +2 -2
- package/packages/web/dist/assets/{AutoPairPicker-C61gihmh.js → AutoPairPicker-BdCHi7dL.js} +2 -2
- package/packages/web/dist/assets/{BrowserFrame-Sq9EmQRT.js → BrowserFrame-CVQvfCB8.js} +2 -2
- package/packages/web/dist/assets/ChatPage-CPZJ8ya6.js +4 -0
- package/packages/web/dist/assets/{ChatPage-CbsRmktV.css → ChatPage-DjPv238m.css} +1 -1
- package/packages/web/dist/assets/{CodeViewer-tUNXZB77.js → CodeViewer-DzWZyAp4.js} +2 -2
- package/packages/web/dist/assets/ConfigWithCustom-C49loznj.js +3 -0
- package/packages/web/dist/assets/{ConfirmDialog-Dd3E4sJt.js → ConfirmDialog-BtugUGEY.js} +2 -2
- package/packages/web/dist/assets/{ConnectPage-CX9acyQH.js → ConnectPage-D8k2nSdX.js} +2 -2
- package/packages/web/dist/assets/ContextItemPage-DC4FGi8V.js +2 -0
- package/packages/web/dist/assets/ContextPage-MlEkKMq0.js +3 -0
- package/packages/web/dist/assets/{ContextRow-DrtPumZ5.js → ContextRow-BN26Di1B.js} +2 -2
- package/packages/web/dist/assets/{DataPage-DDSsxHro.js → DataPage-CvOYkEkS.js} +2 -2
- package/packages/web/dist/assets/DataTypePage-CDEL6BHp.js +2 -0
- package/packages/web/dist/assets/{DataTypePage-Cr238Hx_.css → DataTypePage-CWrWvUPs.css} +1 -1
- package/packages/web/dist/assets/{DesignPage-6e0XbOFC.js → DesignPage-D-MsKLuP.js} +3 -3
- package/packages/web/dist/assets/{ExplorePage-B7ND0W0l.js → ExplorePage-CNQpEe_8.js} +2 -2
- package/packages/web/dist/assets/{FnPill-Cp3KuLmP.js → FnPill-Dm5mmffj.js} +2 -2
- package/packages/web/dist/assets/{FnView-C0XZdnsS.js → FnView-oiIU5vka.js} +2 -2
- package/packages/web/dist/assets/{FnsView-GTH3p7a0.js → FnsView-DgIfza4W.js} +2 -2
- package/packages/web/dist/assets/{GinExprView-DGxns6lH.js → GinExprView-C19g0UgI.js} +2 -2
- package/packages/web/dist/assets/{GinForm-BDBUzuDP.js → GinForm-p7UsKQ3s.js} +2 -2
- package/packages/web/dist/assets/{GinTypeView-CUsymbVf.js → GinTypeView-DvdHc0V4.js} +2 -2
- package/packages/web/dist/assets/{GinValueView-jsKIfiEA.js → GinValueView-D6c7E4C_.js} +2 -2
- package/packages/web/dist/assets/{GraphPage-BCcPPsHu.js → GraphPage-BTamx4d-.js} +2 -2
- package/packages/web/dist/assets/GraphPanel-DKpbijQD.js +2 -0
- package/packages/web/dist/assets/{HubPicker-EoOErgmk.js → HubPicker-DfXIcUz1.js} +2 -2
- package/packages/web/dist/assets/{InboxApprovals-Dkq7DFp_.js → InboxApprovals-B9qwPCHR.js} +2 -2
- package/packages/web/dist/assets/{InboxPage-CHhslePq.js → InboxPage-j2lF00uW.js} +2 -2
- package/packages/web/dist/assets/InjectedList-BTGvy8GB.js +2 -0
- package/packages/web/dist/assets/{InstallDialog-D-VwfZYF.js → InstallDialog-BRJXLSMJ.js} +2 -2
- package/packages/web/dist/assets/InstanceTypes-DYdolFFW.js +2 -0
- package/packages/web/dist/assets/InstanceView-C5dJLBPe.js +2 -0
- package/packages/web/dist/assets/{ItemHistory-NQAP69ma.js → ItemHistory-vsyIMjIX.js} +2 -2
- package/packages/web/dist/assets/LimitsView-BtbQzkX1.js +2 -0
- package/packages/web/dist/assets/{ListSearch-BunVrDO0.js → ListSearch-BdVW9FHD.js} +2 -2
- package/packages/web/dist/assets/{LlmCallDetails-BoVNDTVs.js → LlmCallDetails-Cd7qtybU.js} +2 -2
- package/packages/web/dist/assets/{LlmCallsView-BGpV92RC.js → LlmCallsView-CrZB_I1H.js} +2 -2
- package/packages/web/dist/assets/{LoadState-h-K9bTYc.js → LoadState-8UknKQ6e.js} +2 -2
- package/packages/web/dist/assets/McpDialog-r-qJDHOO.js +2 -0
- package/packages/web/dist/assets/{McpView-GPXdCMne.js → McpView-FeDQWGxu.js} +2 -2
- package/packages/web/dist/assets/{McpsView-DJIR2JX5.js → McpsView-Czd2yUdE.js} +2 -2
- package/packages/web/dist/assets/{MemoryDialog-BTeIHQyA.js → MemoryDialog-DDiT6wO1.js} +2 -2
- package/packages/web/dist/assets/{ModelCallsView-DMcnwF2S.js → ModelCallsView-DsdztwCR.js} +2 -2
- package/packages/web/dist/assets/{ModelPicker-CgkMFxSO.js → ModelPicker-Df_3l8nS.js} +2 -2
- package/packages/web/dist/assets/ModelsView-YXwRDgWv.js +2 -0
- package/packages/web/dist/assets/{NotFoundPage-Tk92K7HN.js → NotFoundPage-DDEOlB6B.js} +2 -2
- package/packages/web/dist/assets/{PairPage-D0BK8CCw.js → PairPage-D3uHAkh1.js} +2 -2
- package/packages/web/dist/assets/{PanelHost-C-gKrxAk.js → PanelHost-BzWYqH39.js} +2 -2
- package/packages/web/dist/assets/PeopleView-Cg9RO5SF.js +2 -0
- package/packages/web/dist/assets/{PeopleView-CJ8yArTh.css → PeopleView-DBxdbT1C.css} +1 -1
- package/packages/web/dist/assets/{PoliciesView-BRi-QAuo.js → PoliciesView-BoshL7RQ.js} +2 -2
- package/packages/web/dist/assets/{RefusalList-DVO0bmeB.js → RefusalList-DnLIfmi-.js} +2 -2
- package/packages/web/dist/assets/RendererHost-CmkaVEX0.js +2 -0
- package/packages/web/dist/assets/RendererHost-Ym_SMkhp.css +1 -0
- package/packages/web/dist/assets/{ResourceViewer-Do0chYxU.js → ResourceViewer-CSAY6xIs.js} +2 -2
- package/packages/web/dist/assets/ResourcesPage-DAoa9mDs.js +2 -0
- package/packages/web/dist/assets/ResultGrid-CL2WSYQH.css +1 -0
- package/packages/web/dist/assets/ResultGrid-DSyc0btv.js +2 -0
- package/packages/web/dist/assets/{ReviewSummaryStrip-DO3p64Qj.js → ReviewSummaryStrip-Bzy-KGz_.js} +2 -2
- package/packages/web/dist/assets/ReviewView-Cwq8Az_B.js +3 -0
- package/packages/web/dist/assets/{RuleRow-DX9v4iGP.js → RuleRow-DAvl2m9p.js} +2 -2
- package/packages/web/dist/assets/RunCard-BMyRkKxJ.js +2 -0
- package/packages/web/dist/assets/RunCard-CSDiz-Nt.css +1 -0
- package/packages/web/dist/assets/{RunDetails-DjR206q6.js → RunDetails-Bvyr1HYK.js} +2 -2
- package/packages/web/dist/assets/{RunDot-lHRICdM5.js → RunDot-Lfrt5XR3.js} +2 -2
- package/packages/web/dist/assets/{RunPage-CbAQ_WPR.js → RunPage-C0-wY6Uz.js} +2 -2
- package/packages/web/dist/assets/{RunProgress-C3-B4tQf.js → RunProgress-BbzwzrTK.js} +2 -2
- package/packages/web/dist/assets/{RunsView-DMkPmkqX.js → RunsView-so-UV2Cq.js} +2 -2
- package/packages/web/dist/assets/SettingsPage-B4SQLk09.js +3 -0
- package/packages/web/dist/assets/{SettingsPage-t03BqXw8.css → SettingsPage-BTl3Ie4F.css} +1 -1
- package/packages/web/dist/assets/SignInPage-CXxLf7Rp.css +1 -0
- package/packages/web/dist/assets/{SignInPage-ByqGEZfj.js → SignInPage-Ck-v3eH0.js} +2 -2
- package/packages/web/dist/assets/{StatusBadge-CXne0sRZ.js → StatusBadge-C4NawPsO.js} +2 -2
- package/packages/web/dist/assets/{StorePlacementStep-B6SwTmdM.js → StorePlacementStep-DjLWeQF9.js} +2 -2
- package/packages/web/dist/assets/{SystemConfig-vQDL_eUl.js → SystemConfig-B5C5B3b0.js} +2 -2
- package/packages/web/dist/assets/SystemPageHost-DX7LrFoN.css +1 -0
- package/packages/web/dist/assets/SystemPageHost-DoyQlhKM.js +2 -0
- package/packages/web/dist/assets/SystemView-CTdpay8I.js +2 -0
- package/packages/web/dist/assets/SystemsView-Cnv2moRw.js +2 -0
- package/packages/web/dist/assets/TableView-BK_95qHT.js +3 -0
- package/packages/web/dist/assets/TableView-B_4MViVb.css +1 -0
- package/packages/web/dist/assets/{TableViewer-Boxx86f5.js → TableViewer-CRsIxdku.js} +3 -3
- package/packages/web/dist/assets/{ThemePicker-CIg_oRQX.js → ThemePicker-BlW7qvUd.js} +2 -2
- package/packages/web/dist/assets/{TurnTree-Ecm0yA5g.js → TurnTree-D6OYRutQ.js} +2 -2
- package/packages/web/dist/assets/{UserMessage-BtECa8ka.css → UserMessage-B63G9sxC.css} +1 -1
- package/packages/web/dist/assets/{UserMessage-BlnqZDVU.js → UserMessage-DJH2bXqv.js} +6 -6
- package/packages/web/dist/assets/{ValueVisual-C-MWpp7c.js → ValueVisual-BJUrdkHO.js} +2 -2
- package/packages/web/dist/assets/{fn-modal-B98MR7JN.js → fn-modal-DFtN7Kn-.js} +2 -2
- package/packages/web/dist/assets/{fn-notices-CfTa1E8y.js → fn-notices-C8HXeo7m.js} +2 -2
- package/packages/web/dist/assets/{formats-JwoKfXIq.js → formats-CHSYhY4X.js} +2 -2
- package/packages/web/dist/assets/index-BY7M8QUk.css +1 -0
- package/packages/web/dist/assets/index-Uz-h2M5K.js +4 -0
- package/packages/web/dist/assets/{labels-BFbk11BE.js → labels-DkV96Md_.js} +2 -2
- package/packages/web/dist/assets/{layout-D1gf481r.js → layout-CTAHAwIH.js} +2 -2
- package/packages/web/dist/assets/loaded-BrwmsuZY.js +2 -0
- package/packages/web/dist/assets/{metrics-CBPX3W5Y.js → metrics-BBvD6KSk.js} +2 -2
- package/packages/web/dist/assets/problems-CI9huk1n.js +2 -0
- package/packages/web/dist/assets/{push-payload-BeU1ADYt.js → push-payload-C1ppI5V2.js} +64 -64
- package/packages/web/dist/assets/record-edits-DFJBcNnL.js +2 -0
- package/packages/web/dist/assets/{review-fP-l9D6H.js → review-DlP8FQiO.js} +3 -3
- package/packages/web/dist/assets/routes-oIISbS5Z.js +4 -0
- package/packages/web/dist/assets/{runs-CveC2kKo.js → runs-BWVBevgu.js} +2 -2
- package/packages/web/dist/assets/{shared-LbaIHjbV.js → shared-Bc4GJbiE.js} +2 -2
- package/packages/web/dist/assets/{sources-VPrtgLIi.js → sources-gONU9kk2.js} +2 -2
- package/packages/web/dist/assets/src-ClMFVauH.js +43 -0
- package/packages/web/dist/assets/state-BQlvjJzT.js +2 -0
- package/packages/web/dist/assets/{systems-BqE3WTSF.js → systems-Dt01wDhP.js} +2 -2
- package/packages/web/dist/assets/table-host-BvEY0Zxn.js +2 -0
- package/packages/web/dist/assets/tables-CkqGZ0Yq.js +2 -0
- package/packages/web/dist/assets/{ui-BzgWquIU.js → ui-CjoSgSyZ.js} +5 -5
- package/packages/web/dist/assets/{url-DKGcECT1.js → url-Deh5u3O5.js} +2 -2
- package/packages/web/dist/index.html +49 -47
- package/packages/web/dist/sw.js +1 -1
- package/packages/web/package.json +2 -4
- package/premade/claude.zip +0 -0
- package/premade/database.zip +0 -0
- package/premade/web.zip +0 -0
- package/scripts/dev-env.ts +9 -9
- package/scripts/run-stack.ts +15 -15
- package/scripts/stack.ts +3 -3
- package/scripts/start.ts +18 -18
- package/systems/api/client/ApiServiceForm.vue +55 -0
- package/systems/api/client/ServiceList.vue +90 -0
- package/systems/api/client/ServicePage.vue +142 -0
- package/systems/api/client/ServicesPage.vue +32 -0
- package/systems/api/client/index.ts +15 -0
- package/systems/api/client/logic.ts +140 -0
- package/systems/api/client/state.ts +92 -0
- package/systems/api/package.json +9 -6
- package/systems/api/server/authoring.ts +2 -1
- package/systems/api/server/env.ts +1 -1
- package/systems/api/server/guard.ts +1 -1
- package/systems/api/server/http.ts +3 -2
- package/systems/api/server/impl.ts +3 -2
- package/systems/api/server/main.ts +11 -7
- package/systems/api/server/openapi.ts +1 -1
- package/systems/api/server/program.ts +2 -1
- package/systems/api/server/services.ts +2 -1
- package/systems/api/shared/http.ts +2 -1
- package/systems/api/shared/index.ts +15 -5
- package/{packages/core/src/programs.ts → systems/api/shared/services.ts} +7 -51
- package/systems/api/system.json +2 -1
- package/systems/api/tsconfig.json +2 -2
- package/systems/code/package.json +4 -3
- package/systems/code/server/authoring.ts +2 -1
- package/systems/code/server/impl.ts +2 -1
- package/systems/code/server/main.ts +5 -5
- package/systems/code/shared/index.ts +2 -3
- package/systems/code/shared/program.ts +23 -0
- package/systems/embedder/package.json +1 -1
- package/systems/embedder/server/env.ts +1 -1
- package/systems/embedder/server/main.ts +5 -5
- package/systems/embedder/shared/index.ts +1 -1
- package/systems/fs/client/machines/fakes.ts +1 -1
- package/systems/fs/client/machines/files/CommentComposer.vue +6 -3
- package/systems/fs/client/machines/files/FilePane.vue +2 -2
- package/systems/fs/client/machines/files/fakes.ts +1 -1
- package/systems/fs/client/machines/palette.ts +3 -2
- package/systems/fs/context/authoring/parts/client.md +23 -5
- package/systems/fs/context/authoring/parts/client.reference/client.md +7 -16
- package/systems/fs/context/authoring/parts/client.reference/pageinbox.md +524 -0
- package/systems/fs/context/authoring/parts/client.reference/{resultview.md → visuals.md} +85 -116
- package/systems/fs/context/authoring/parts/client.reference.md +8 -8
- package/systems/fs/context/authoring/parts/context.md +1 -1
- package/systems/fs/context/authoring/parts/contract.md +1 -1
- package/systems/fs/context/authoring/parts/core-types/admin-ts.md +2 -2
- package/systems/fs/context/authoring/parts/core-types/connections-ts.md +12 -1
- package/systems/fs/context/authoring/parts/core-types/context-files-ts.md +2 -2
- package/systems/fs/context/authoring/parts/core-types/context-graph-ts.md +2 -2
- package/systems/fs/context/authoring/parts/core-types/contextdecl.md +2 -2
- package/systems/fs/context/authoring/parts/core-types/lifecycle-ts.md +27 -2
- package/systems/fs/context/authoring/parts/core-types/manifest.md +27 -2
- package/systems/fs/context/authoring/parts/core-types/manifestpatch.md +26 -2
- package/systems/fs/context/authoring/parts/core-types/modes-ts.md +3 -3
- package/systems/fs/context/authoring/parts/core-types/records-systems-ts.md +145 -1
- package/systems/fs/context/authoring/parts/core-types/registries-ts.md +98 -2
- package/systems/fs/context/authoring/parts/core-types/run-ts.md +2 -2
- package/systems/fs/context/authoring/parts/core-types/system-pages-ts.md +4 -2
- package/systems/fs/context/authoring/parts/core-types/system-providers-ts.md +2 -2
- package/systems/fs/context/authoring/parts/core-types/tables-ts.md +91 -0
- package/systems/fs/context/authoring/parts/core-types/web-ts.md +1 -2
- package/systems/fs/context/authoring/parts/core-types.md +5 -8
- package/systems/fs/context/authoring/parts/examples/server-main-ts.md +4 -4
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-568-660.md +1 -1
- package/systems/fs/context/authoring/parts/fns.md +1 -1
- package/systems/fs/context/authoring/parts/folder.md +6 -6
- package/systems/fs/context/authoring/parts/hub/hub-ctx-from-resource.md +2 -2
- package/systems/fs/context/authoring/parts/hub/hub-install-package.md +2 -2
- package/systems/fs/context/authoring/parts/hub.reference.md +3 -3
- package/systems/fs/context/authoring/parts/internals/manifestof.md +2 -2
- package/systems/fs/context/authoring/parts/internals/permissionargs.md +4 -4
- package/systems/fs/context/authoring/parts/kinds-agents.md +1 -1
- package/systems/fs/context/authoring/parts/kinds-agents.reference/authoringsession.md +7 -5
- package/systems/fs/context/authoring/parts/kinds-agents.reference/kind.md +4 -4
- package/systems/fs/context/authoring/parts/outcomes.md +2 -2
- package/systems/fs/context/authoring/parts/outcomes.reference.md +2 -2
- package/systems/fs/context/authoring/parts/packaging.md +4 -4
- package/systems/fs/context/authoring/parts/remote.md +5 -5
- package/systems/fs/context/authoring/parts/remote.reference.md +201 -17
- package/systems/fs/context/authoring/parts/server.md +7 -7
- package/systems/fs/context/authoring/parts/server.reference.md +15 -15
- package/systems/fs/context/authoring/parts/testing.reference/equal.md +3 -3
- package/systems/fs/context/authoring/parts/testing.reference/fakehub.md +1 -1
- package/systems/fs/context/authoring/parts/testing.reference/kindprops.md +22 -10
- package/systems/fs/context/authoring/parts/testing.reference/{openmemorystore.md → storeconnection.md} +7 -19
- package/systems/fs/context/authoring/parts/testing.reference.md +5 -5
- package/systems/fs/context/authoring/parts/widgets.md +32 -22
- package/systems/fs/context/authoring/parts/widgets.reference.md +503 -9
- package/systems/fs/package.json +3 -3
- package/systems/fs/server/hosting.ts +10 -10
- package/systems/fs/server/main.ts +8 -8
- package/systems/fs/server/metrics/os.ts +50 -29
- package/systems/fs/server/shell.ts +1 -1
- package/systems/fs/shared/index.ts +1 -1
- package/systems/google-calendar/package.json +1 -1
- package/systems/google-calendar/server/main.ts +4 -4
- package/systems/input/package.json +3 -3
- package/systems/input/server/main.ts +6 -6
- package/systems/mcp/client/McpServerForm.vue +99 -0
- package/systems/mcp/client/ServerList.vue +78 -0
- package/systems/mcp/client/ServerPage.vue +194 -0
- package/systems/mcp/client/ServersPage.vue +32 -0
- package/systems/mcp/client/index.ts +15 -0
- package/systems/mcp/client/logic.ts +224 -0
- package/systems/mcp/client/state.ts +128 -0
- package/systems/mcp/package.json +9 -6
- package/systems/mcp/server/dial.ts +1 -1
- package/systems/mcp/server/impl.ts +2 -1
- package/systems/mcp/server/instance.ts +3 -5
- package/systems/mcp/server/main.ts +10 -6
- package/systems/mcp/server/mirror.ts +2 -3
- package/systems/mcp/server/oauth.ts +2 -1
- package/systems/mcp/server/server-link.ts +2 -1
- package/systems/mcp/shared/index.ts +15 -2
- package/{packages/core/src/mcp-servers.ts → systems/mcp/shared/servers.ts} +6 -5
- package/systems/mcp/system.json +2 -1
- package/systems/mcp/tsconfig.json +2 -2
- package/systems/ollama/package.json +3 -3
- package/systems/ollama/server/main.ts +5 -5
- package/systems/schedule/package.json +3 -3
- package/systems/schedule/server/main.ts +6 -6
- package/systems/template/README.md +2 -2
- package/systems/template/package.json +1 -1
- package/systems/template/server/main.ts +4 -4
- package/systems/widgets/client/ChipRow.vue +22 -0
- package/systems/widgets/client/ProposalCard.vue +6 -5
- package/systems/widgets/client/SavedWidget.vue +11 -8
- package/systems/widgets/client/WidgetChips.vue +137 -0
- package/systems/widgets/client/WidgetView.vue +32 -0
- package/systems/widgets/client/charts/ChartVisual.vue +157 -0
- package/systems/widgets/client/charts/chart-data.ts +230 -0
- package/systems/widgets/client/charts/echarts-setup.ts +69 -0
- package/systems/widgets/client/charts/export.ts +36 -0
- package/systems/widgets/client/charts/families/calendar.ts +105 -0
- package/systems/widgets/client/charts/families/category.ts +186 -0
- package/systems/widgets/client/charts/families/crosstab.ts +113 -0
- package/systems/widgets/client/charts/families/distribution.ts +160 -0
- package/systems/widgets/client/charts/families/finance.ts +96 -0
- package/systems/widgets/client/charts/families/gauge.ts +75 -0
- package/systems/widgets/client/charts/families/hierarchy.ts +166 -0
- package/systems/widgets/client/charts/families/index.ts +21 -0
- package/systems/widgets/client/charts/families/network.ts +140 -0
- package/systems/widgets/client/charts/families/part.ts +61 -0
- package/systems/widgets/client/charts/families/profile.ts +30 -0
- package/systems/widgets/client/charts/families/progress.ts +76 -0
- package/systems/widgets/client/charts/families/range.ts +107 -0
- package/systems/widgets/client/charts/families/time.ts +177 -0
- package/systems/widgets/client/charts/families/timeline.ts +114 -0
- package/systems/widgets/client/charts/families/wide.ts +41 -0
- package/systems/widgets/client/charts/index.ts +37 -0
- package/systems/widgets/client/charts/maths.ts +139 -0
- package/systems/widgets/client/charts/size.ts +39 -0
- package/systems/widgets/client/chips.ts +150 -0
- package/systems/widgets/client/index.ts +18 -5
- package/systems/widgets/client/proposal.ts +2 -1
- package/systems/widgets/package.json +7 -4
- package/systems/widgets/server/authoring.ts +13 -7
- package/systems/widgets/server/env.ts +1 -1
- package/systems/widgets/server/impl.ts +10 -6
- package/systems/widgets/server/main.ts +6 -6
- package/systems/widgets/server/run.ts +16 -9
- package/systems/widgets/server/upgrade.ts +34 -0
- package/systems/widgets/shared/args.ts +137 -0
- package/systems/widgets/shared/charts.ts +243 -0
- package/systems/widgets/shared/index.ts +12 -3
- package/{packages/sdk/src → systems/widgets/shared}/relative-dates.ts +2 -1
- package/systems/widgets/shared/spec.ts +208 -0
- package/{packages/sdk/src → systems/widgets/shared}/widget-check.ts +7 -9
- package/{packages/sdk/src → systems/widgets/shared}/widget-schema.ts +4 -4
- package/packages/core/src/remote-auth.ts +0 -111
- package/packages/core/src/widgets.ts +0 -427
- package/packages/web/dist/assets/AdminLayout-B6Jrc_4W.js +0 -2
- package/packages/web/dist/assets/ApiServiceForm-BxprSaAq.css +0 -1
- package/packages/web/dist/assets/ApiServiceForm-CuuQgOJc.js +0 -2
- package/packages/web/dist/assets/ApiServiceView-7bTHSO_Z.js +0 -2
- package/packages/web/dist/assets/ApiServiceView-BVmdRCjR.css +0 -1
- package/packages/web/dist/assets/ApiServicesView-BTLV6c8n.css +0 -1
- package/packages/web/dist/assets/ApiServicesView-BXi24n49.js +0 -2
- package/packages/web/dist/assets/ChartVisual-BnFG9aFi.css +0 -1
- package/packages/web/dist/assets/ChartVisual-C4mgw4wh.js +0 -11
- package/packages/web/dist/assets/ChatPage-CAhHE03Z.js +0 -4
- package/packages/web/dist/assets/ConfigWithCustom-D_-rY66L.js +0 -3
- package/packages/web/dist/assets/ContextItemPage-rUI3-T_L.js +0 -2
- package/packages/web/dist/assets/ContextPage-CtefzyKg.js +0 -3
- package/packages/web/dist/assets/DataTypePage-BW9fWaz8.js +0 -2
- package/packages/web/dist/assets/FnList-BCnb4kOB.css +0 -1
- package/packages/web/dist/assets/FnList-Bx6H-kux.js +0 -2
- package/packages/web/dist/assets/GraphPanel-9tztGHmu.js +0 -2
- package/packages/web/dist/assets/InjectedList-CSWqRiON.js +0 -2
- package/packages/web/dist/assets/InstanceTypes-D3rAEiE7.js +0 -2
- package/packages/web/dist/assets/InstanceView-DoH8C-1j.js +0 -2
- package/packages/web/dist/assets/LimitsView-DY2C9nYS.js +0 -2
- package/packages/web/dist/assets/McpDialog-DhOCk6_E.js +0 -2
- package/packages/web/dist/assets/McpServerForm-Cor3fI7s.js +0 -2
- package/packages/web/dist/assets/McpServerForm-DsHaf5Um.css +0 -1
- package/packages/web/dist/assets/McpServerView-7I76EznB.css +0 -1
- package/packages/web/dist/assets/McpServerView-ewXRPEmZ.js +0 -2
- package/packages/web/dist/assets/McpServersView-Dd0xmfws.js +0 -2
- package/packages/web/dist/assets/ModelsView-cMHygeiK.js +0 -2
- package/packages/web/dist/assets/PeopleView-DRfeNWK5.js +0 -2
- package/packages/web/dist/assets/RemoteAuthFields-CgiufuqQ.js +0 -2
- package/packages/web/dist/assets/RemoteAuthFields-Dm44vz2t.css +0 -1
- package/packages/web/dist/assets/ResourcesPage-BBx2u2mw.js +0 -2
- package/packages/web/dist/assets/ResultGrid-Bj-0I5HY.js +0 -2
- package/packages/web/dist/assets/ResultGrid-CuUQyTjW.css +0 -1
- package/packages/web/dist/assets/ReviewView-DZF9E1hb.js +0 -3
- package/packages/web/dist/assets/RunCard-BnrtK2Yp.js +0 -2
- package/packages/web/dist/assets/RunCard-CfyRaDLS.css +0 -1
- package/packages/web/dist/assets/ServiceRows-4WythFpF.js +0 -2
- package/packages/web/dist/assets/ServiceRows-HPQ0pN6b.css +0 -1
- package/packages/web/dist/assets/SettingsPage-BN4oSzoL.js +0 -3
- package/packages/web/dist/assets/SignInPage-Djx-M-0U.css +0 -1
- package/packages/web/dist/assets/SystemPageHost-BeZ-6N0-.css +0 -1
- package/packages/web/dist/assets/SystemPageHost-DrMrEPyh.js +0 -2
- package/packages/web/dist/assets/SystemView-Be6TBM4j.js +0 -2
- package/packages/web/dist/assets/SystemsView-DZtT3laz.js +0 -2
- package/packages/web/dist/assets/WidgetView-DQUDeFkB.css +0 -1
- package/packages/web/dist/assets/WidgetView-DX4ejNb6.js +0 -3
- package/packages/web/dist/assets/export-BwFkEtcm.js +0 -15
- package/packages/web/dist/assets/index-6ScWTFy2.js +0 -4
- package/packages/web/dist/assets/index-CEslGcrX.css +0 -1
- package/packages/web/dist/assets/problems-t1E_ovSz.js +0 -2
- package/packages/web/dist/assets/record-edits-Bfsi4lU3.js +0 -2
- package/packages/web/dist/assets/remote-config-BNQhSDzB.js +0 -2
- package/packages/web/dist/assets/routes-DV4IJpwe.js +0 -4
- package/packages/web/dist/assets/size-Bh__w5aI.js +0 -2
- package/packages/web/dist/assets/src-CT3TeFaM.js +0 -43
- package/packages/web/dist/assets/state-xfQqaQPX.js +0 -2
- package/packages/web/dist/assets/widget-host-B87MTaTn.js +0 -2
- package/packages/web/dist/assets/widgets-BBCuSS6E.js +0 -2
- package/systems/fs/context/authoring/parts/client.reference/textareaprops.md +0 -195
- package/systems/fs/context/authoring/parts/core-types/remote-auth-ts.md +0 -64
- package/systems/fs/context/authoring/parts/core-types/widgets-ts.md +0 -303
- package/systems/fs/context/authoring/parts/widgets.reference/hub-visuals.md +0 -627
- package/systems/fs/context/authoring/parts/widgets.reference/sourcecompatible.md +0 -154
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Things from a start to an end, each a bar across its range (`custom` series): a gantt chart (one lane per row, or per
|
|
3
|
+
* lane value, named on the axis) and a timeline (items packed into as few lanes as fit without overlapping, each bar
|
|
4
|
+
* labelled inside), and durations (`bar`: each row as long as it lasts, longest first). The time axis zooms; a zoom sets
|
|
5
|
+
* the widget's from/to args.
|
|
6
|
+
*/
|
|
7
|
+
import type { CustomSeriesRenderItem } from 'echarts';
|
|
8
|
+
import { bound, chartValue, dimension, labelOf, needed, plotGrid, splitRows, tooltip, zoom, type ChartBuilder, type ChartInput, type ChartValue } from '../chart-data.ts';
|
|
9
|
+
import { timeAxis, timeExtent, utcDay } from './time.ts';
|
|
10
|
+
|
|
11
|
+
/** A value as milliseconds, or `null` when it is not a time. */
|
|
12
|
+
function msOf(value: ChartValue): number | null {
|
|
13
|
+
const ms = typeof value === 'number' ? value : typeof value === 'string' ? Date.parse(value) : Number.NaN;
|
|
14
|
+
return Number.isNaN(ms) ? null : ms;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The lane each item takes when packed: in start order, an item goes in the first lane whose last item has ended by
|
|
19
|
+
* its start, else a new lane. Items without both times take lane 0. Returns one lane per item, in the items' order.
|
|
20
|
+
*/
|
|
21
|
+
export function packLanes(items: readonly { readonly start: number | null; readonly end: number | null }[]): number[] {
|
|
22
|
+
const lanes = items.map(() => 0);
|
|
23
|
+
const ends: number[] = [];
|
|
24
|
+
const order = items.map((_, i) => i).sort((a, b) => (items[a]?.start ?? 0) - (items[b]?.start ?? 0));
|
|
25
|
+
for (const at of order) {
|
|
26
|
+
const from = items[at]?.start ?? null; const to = items[at]?.end ?? null;
|
|
27
|
+
if (from === null || to === null) { continue; }
|
|
28
|
+
const free = ends.findIndex((end) => end <= from);
|
|
29
|
+
const lane = free < 0 ? ends.length : free;
|
|
30
|
+
ends[lane] = Math.max(to, from);
|
|
31
|
+
lanes[at] = lane;
|
|
32
|
+
}
|
|
33
|
+
return lanes;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A bar from the start's point to the end's on the item's lane, a little under the lane's height; given `ink` (the
|
|
38
|
+
* label's colour) it writes its label inside.
|
|
39
|
+
*/
|
|
40
|
+
function bar(ink?: string): CustomSeriesRenderItem {
|
|
41
|
+
return (_params, api) => {
|
|
42
|
+
const lane = api.value(0); const start = api.coord([api.value(1), lane]); const end = api.coord([api.value(2), lane]);
|
|
43
|
+
const size = api.size?.([0, 1]);
|
|
44
|
+
const height = (Array.isArray(size) ? size[1] ?? 16 : 16) * 0.6;
|
|
45
|
+
const [x0 = 0, y0 = 0] = start; const [x1 = 0] = end;
|
|
46
|
+
const width = Math.max(2, x1 - x0);
|
|
47
|
+
const fill = api.visual('color');
|
|
48
|
+
const text = String(api.value(3));
|
|
49
|
+
return {
|
|
50
|
+
type: 'rect', shape: { x: x0, y: y0 - height / 2, width, height, r: 3 }, style: fill === undefined ? {} : { fill },
|
|
51
|
+
// the label rides inside the bar and is cut at its end, so neighbouring bars never collide
|
|
52
|
+
...(ink === undefined ? {} : { textContent: { type: 'text' as const, style: { text, fill: ink, fontSize: 11, width: Math.max(0, width - 8), overflow: 'truncate' as const } }, textConfig: { position: 'insideLeft' as const } }),
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A gantt bar (no label inside: the lane's name is on the axis). */
|
|
58
|
+
export const ganttBar: CustomSeriesRenderItem = bar();
|
|
59
|
+
|
|
60
|
+
/** How long a span is, in the unit that reads best for the longest one: days, hours or minutes. */
|
|
61
|
+
export function durationUnit(longest: number): { readonly label: string; readonly ms: number } {
|
|
62
|
+
if (longest >= 2 * 86_400_000) { return { label: 'days', ms: 86_400_000 }; }
|
|
63
|
+
if (longest >= 2 * 3_600_000) { return { label: 'hours', ms: 3_600_000 }; }
|
|
64
|
+
return { label: 'minutes', ms: 60_000 };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Durations: a horizontal bar per row, as long as its end minus its start, longest first. */
|
|
68
|
+
function durations(input: ChartInput, items: readonly { readonly label: string; readonly start: number | null; readonly end: number | null }[], day: boolean): ReturnType<ChartBuilder> {
|
|
69
|
+
const spans = items.map((item, row) => ({ row, label: item.label, ms: item.start === null || item.end === null ? null : Math.max(0, item.end - item.start) }))
|
|
70
|
+
.filter((span) => span.ms !== null).sort((a, b) => (b.ms ?? 0) - (a.ms ?? 0));
|
|
71
|
+
const unit = day ? { label: 'days', ms: 86_400_000 } : durationUnit(spans[0]?.ms ?? 0);
|
|
72
|
+
return {
|
|
73
|
+
option: {
|
|
74
|
+
tooltip: tooltip('item'), grid: plotGrid(8),
|
|
75
|
+
xAxis: { type: 'value', name: unit.label, nameLocation: 'middle', nameGap: 26 },
|
|
76
|
+
yAxis: { type: 'category', inverse: true, data: spans.map((span) => span.label), axisLabel: { hideOverlap: true, width: input.phone ? 80 : 160, overflow: 'truncate' } },
|
|
77
|
+
series: [{ type: 'bar', barMaxWidth: 20, itemStyle: { borderRadius: 3 }, data: spans.map((span) => Math.round(((span.ms ?? 0) / unit.ms) * 10) / 10), label: { show: !input.phone, position: 'right', color: input.palette.muted, fontSize: 11 } }],
|
|
78
|
+
},
|
|
79
|
+
rowOf: (click) => (click.dataIndex === undefined ? undefined : spans[click.dataIndex]?.row),
|
|
80
|
+
points: spans.length,
|
|
81
|
+
height: Math.max(200, Math.min(640, spans.length * 28 + 60)),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const timeline: ChartBuilder = (input) => {
|
|
86
|
+
const start = needed(input, 'start'); const end = needed(input, 'end'); const label = needed(input, 'label');
|
|
87
|
+
const lane = bound(input, 'series');
|
|
88
|
+
const day = start.facts?.day === true && end.facts?.day === true;
|
|
89
|
+
const packed = input.style === 'timeline';
|
|
90
|
+
const rows = input.table.rows;
|
|
91
|
+
if (input.style === 'durations') { return durations(input, rows.map((row) => ({ label: labelOf(chartValue(row[label.index])), start: msOf(chartValue(row[start.index])), end: msOf(chartValue(row[end.index])) })), day); }
|
|
92
|
+
const lanes = packed
|
|
93
|
+
? packLanes(rows.map((row) => ({ start: msOf(chartValue(row[start.index])), end: msOf(chartValue(row[end.index])) })))
|
|
94
|
+
: undefined;
|
|
95
|
+
const groups = lane === undefined ? rows.map((row, at) => ({ key: chartValue(row[label.index]), rows: [at] })) : splitRows(input.table, lane.index);
|
|
96
|
+
const laneOf = new Map(groups.flatMap((group, i) => group.rows.map((at) => [at, i] as const)));
|
|
97
|
+
const count = lanes === undefined ? groups.length : Math.max(0, ...lanes) + 1;
|
|
98
|
+
const names = lanes === undefined ? groups.map((group) => labelOf(group.key)) : Array.from({ length: count }, (_, i) => String(i + 1));
|
|
99
|
+
const source = rows.map((row, at) => [lanes?.[at] ?? laneOf.get(at) ?? 0, utcDay(chartValue(row[start.index]), day), utcDay(chartValue(row[end.index]), day), labelOf(chartValue(row[label.index]))]);
|
|
100
|
+
return {
|
|
101
|
+
option: {
|
|
102
|
+
useUTC: day, tooltip: tooltip('item'), grid: plotGrid(input.phone ? 8 : 40), dataZoom: zoom(input.phone, { xAxisIndex: [0] }),
|
|
103
|
+
// typed dimensions, so a bar's start and end read as times (text dates otherwise read as names and draw nothing)
|
|
104
|
+
dataset: { dimensions: [{ name: 'lane', type: 'number' as const }, { ...dimension(start, 'start'), type: 'time' as const }, { ...dimension(end, 'end'), type: 'time' as const }, { ...dimension(label, 'label'), type: 'ordinal' as const }], source },
|
|
105
|
+
xAxis: timeAxis(day, timeExtent(source.flatMap((row) => [row[1] ?? null, row[2] ?? null]))),
|
|
106
|
+
yAxis: { type: 'category' as const, data: names, inverse: true, ...(packed ? { show: false } : { axisLabel: { hideOverlap: true, width: input.phone ? 80 : 160, overflow: 'truncate' as const } }) },
|
|
107
|
+
series: [{ type: 'custom' as const, renderItem: packed ? bar(input.palette.surface) : ganttBar, encode: { x: ['start', 'end'], y: 'lane', tooltip: ['label', 'start', 'end'] } }],
|
|
108
|
+
},
|
|
109
|
+
rowOf: (click) => click.dataIndex,
|
|
110
|
+
range: { kind: 'time', values: [], day },
|
|
111
|
+
points: source.length,
|
|
112
|
+
height: Math.max(packed ? 200 : 240, Math.min(640, count * (packed ? 36 : 28) + 80)),
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wide table a category or time family draws: a row per key, a column per series. Several measures make a series
|
|
3
|
+
* each; one measure with a series column is pivoted, a series per value of it.
|
|
4
|
+
*/
|
|
5
|
+
import { boundAll, bound, chartValue, labelOf, needed, numberOf, pivot, type ChartInput, type ChartValue } from '../chart-data.ts';
|
|
6
|
+
|
|
7
|
+
/** A family's series over its key, and where each cell came from. */
|
|
8
|
+
export interface Wide {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
/** Series names, in order. */
|
|
11
|
+
readonly names: string[];
|
|
12
|
+
/** `[key, value per series…]` per key. */
|
|
13
|
+
readonly source: ChartValue[][];
|
|
14
|
+
rowAt(key: number, series: number): number | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The wide table of a key channel, the measures channel `y` and the optional `series` channel. */
|
|
18
|
+
export function wide(input: ChartInput, keyChannel: string): Wide {
|
|
19
|
+
const key = needed(input, keyChannel);
|
|
20
|
+
const measures = boundAll(input, 'y');
|
|
21
|
+
const split = bound(input, 'series');
|
|
22
|
+
const [first] = measures;
|
|
23
|
+
if (split !== undefined && first !== undefined) {
|
|
24
|
+
const pivoted = pivot(input.table, key.index, split.index, first.index);
|
|
25
|
+
return { key: key.name, names: pivoted.series.map(labelOf), source: pivoted.source, rowAt: (k, s) => pivoted.rowAt(k, s) };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
key: key.name,
|
|
29
|
+
names: measures.map((measure) => measure.label),
|
|
30
|
+
source: input.table.rows.map((row): ChartValue[] => [chartValue(row[key.index]), ...measures.map((measure) => numberOf(row[measure.index]))]),
|
|
31
|
+
rowAt: (k) => k,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Each key's values as shares of its row's total, in percent (the 100% stacked style). */
|
|
36
|
+
export function asPercent(source: readonly ChartValue[][]): ChartValue[][] {
|
|
37
|
+
return source.map(([key = null, ...values]) => {
|
|
38
|
+
const total = values.reduce<number>((sum, value) => sum + (typeof value === 'number' ? Math.abs(value) : 0), 0);
|
|
39
|
+
return [key, ...values.map((value) => (typeof value === 'number' && total > 0 ? (Math.abs(value) / total) * 100 : null))];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart families as the client registers them in the hub's visual registry (`client({ visuals: { [HUB_VISUALS]:
|
|
3
|
+
* … } })`): one component per family, each drawing `ChartVisual` with its family, so the result view mounts a chart
|
|
4
|
+
* like any system's visual (it gets `VisualView` and the widgets system's client, and emits `drill` and `range`).
|
|
5
|
+
*/
|
|
6
|
+
import { VISUAL_EMITS, type VisualEntry, type VisualView, type WithSystem } from '@harness/sdk';
|
|
7
|
+
import { defineComponent, h, markRaw, type Component } from 'vue';
|
|
8
|
+
import type { ChartFamily } from '../../shared/charts.ts';
|
|
9
|
+
import type { WidgetsContract } from '../../shared/index.ts';
|
|
10
|
+
import ChartVisual from './ChartVisual.vue';
|
|
11
|
+
|
|
12
|
+
type Defs = WidgetsContract['defs'];
|
|
13
|
+
|
|
14
|
+
/** Every prop a visual is drawn with (`VisualView`, and the system's client), declared so none falls through as an attribute. */
|
|
15
|
+
const VIEW_PROPS = ['table', 'facts', 'bind', 'style', 'palette', 'title', 'opener', 'system'] as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A family's component: it declares the view's props (a visual's `style` is the style picked, which an undeclared
|
|
19
|
+
* prop would hand on as CSS) and draws the chart with its family, passing its `drill` and `range` on.
|
|
20
|
+
*/
|
|
21
|
+
export function chartComponent(family: ChartFamily): Component<VisualView & WithSystem<Defs>> {
|
|
22
|
+
return markRaw(defineComponent((props: VisualView & WithSystem<Defs>, { emit }) => () => h(ChartVisual, {
|
|
23
|
+
table: props.table, facts: props.facts, bind: props.bind, chartStyle: props.style, palette: props.palette, title: props.title, opener: props.opener, family,
|
|
24
|
+
onDrill: (row: number) => { emit('drill', row); }, onRange: (range: { from: string; to: string }) => { emit('range', range); },
|
|
25
|
+
// the props' types are VisualView's (the setup's signature); the names only keep them from falling through
|
|
26
|
+
// eslint-disable-next-line vue/require-prop-types -- typed by the setup function's VisualView, checked by vue-tsc
|
|
27
|
+
}), { name: `Chart-${family}`, props: [...VIEW_PROPS], emits: VISUAL_EMITS }));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const entry = (family: ChartFamily): VisualEntry<Defs> => ({ component: chartComponent(family) });
|
|
31
|
+
|
|
32
|
+
/** Every chart family's registry entry, by name (`CHART_FAMILIES`, the contract's `contributes`). */
|
|
33
|
+
export const CHART_ENTRIES: Readonly<Record<ChartFamily, VisualEntry<Defs>>> = {
|
|
34
|
+
part: entry('part'), category: entry('category'), time: entry('time'), distribution: entry('distribution'), crosstab: entry('crosstab'),
|
|
35
|
+
calendar: entry('calendar'), timeline: entry('timeline'), network: entry('network'), hierarchy: entry('hierarchy'), gauge: entry('gauge'),
|
|
36
|
+
finance: entry('finance'), range: entry('range'), profile: entry('profile'), progress: entry('progress'),
|
|
37
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser maths over rows (charts-browser-math: only over a whole result; ranking hides the styles that need it
|
|
3
|
+
* otherwise, and the authoring agent writes an aggregate query instead): a histogram's bins, a part-to-whole's
|
|
4
|
+
* "Other" slice, and the samples a box plot's quartiles are taken from (ECharts' `boxplot` transform takes the
|
|
5
|
+
* quartiles itself).
|
|
6
|
+
*/
|
|
7
|
+
import { PART_TO_WHOLE_MAX_SLICES } from '../../shared/charts.ts';
|
|
8
|
+
import type { ChartValue } from './chart-data.ts';
|
|
9
|
+
|
|
10
|
+
/** The most bins a histogram draws. */
|
|
11
|
+
export const HISTOGRAM_MAX_BINS = 30;
|
|
12
|
+
|
|
13
|
+
/** One bin: its range (from inclusive, to exclusive but for the last) and how many values fall in it. */
|
|
14
|
+
export interface Bin {
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly to: number;
|
|
17
|
+
readonly count: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A readable step near `raw` (1, 2 or 5 times a power of ten), so bin edges are round numbers. */
|
|
21
|
+
function niceStep(raw: number): number {
|
|
22
|
+
const power = 10 ** Math.floor(Math.log10(raw));
|
|
23
|
+
const unit = raw / power;
|
|
24
|
+
return (unit <= 1 ? 1 : unit <= 2 ? 2 : unit <= 5 ? 5 : 10) * power;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Bins over numbers (Sturges' count, rounded edges); one bin when every value is the same, none for no values. */
|
|
28
|
+
export function histogram(values: readonly number[]): Bin[] {
|
|
29
|
+
if (values.length === 0) { return []; }
|
|
30
|
+
const min = Math.min(...values); const max = Math.max(...values);
|
|
31
|
+
if (min === max) { return [{ from: min, to: max, count: values.length }]; }
|
|
32
|
+
const count = Math.min(HISTOGRAM_MAX_BINS, Math.ceil(Math.log2(values.length)) + 1);
|
|
33
|
+
const step = niceStep((max - min) / count);
|
|
34
|
+
const start = Math.floor(min / step) * step;
|
|
35
|
+
const bins = Math.max(1, Math.ceil((max - start) / step + 1e-9));
|
|
36
|
+
const counts = Array.from({ length: bins }, () => 0);
|
|
37
|
+
for (const value of values) {
|
|
38
|
+
const at = Math.min(bins - 1, Math.floor((value - start) / step));
|
|
39
|
+
counts[at] = (counts[at] ?? 0) + 1;
|
|
40
|
+
}
|
|
41
|
+
return counts.map((n, i) => ({ from: start + i * step, to: start + (i + 1) * step, count: n }));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One slice of a part-to-whole: its name, size, and the row it came from (none for "Other"). */
|
|
45
|
+
export interface Slice {
|
|
46
|
+
readonly name: ChartValue;
|
|
47
|
+
readonly value: number;
|
|
48
|
+
readonly row: number | undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The label of the slice the smallest ones fold into. */
|
|
52
|
+
export const OTHER_SLICE = 'Other';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Slices largest first, the smallest folded into one "Other" when there are more than `max` (`size: 'partition'`).
|
|
56
|
+
* Rows without a size are left out.
|
|
57
|
+
*/
|
|
58
|
+
export function foldSlices(slices: readonly Slice[], max = PART_TO_WHOLE_MAX_SLICES): Slice[] {
|
|
59
|
+
const sorted = [...slices].sort((a, b) => b.value - a.value);
|
|
60
|
+
if (sorted.length <= max) { return sorted; }
|
|
61
|
+
const kept = sorted.slice(0, max - 1);
|
|
62
|
+
const rest = sorted.slice(max - 1).reduce((sum, slice) => sum + slice.value, 0);
|
|
63
|
+
return [...kept, { name: OTHER_SLICE, value: rest, row: undefined }];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** One point of a curve. */
|
|
67
|
+
export interface CurvePoint {
|
|
68
|
+
readonly x: number;
|
|
69
|
+
readonly y: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** How many points a density curve is drawn with. */
|
|
73
|
+
export const DENSITY_POINTS = 60;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A kernel density estimate of numbers (Gaussian kernel, Silverman's bandwidth), from a little below the smallest to
|
|
77
|
+
* a little above the largest: the smooth shape of how they spread. Empty for no values; a single spike's width for one.
|
|
78
|
+
*/
|
|
79
|
+
export function density(values: readonly number[], points = DENSITY_POINTS): CurvePoint[] {
|
|
80
|
+
if (values.length === 0) { return []; }
|
|
81
|
+
const n = values.length;
|
|
82
|
+
const mean = values.reduce((sum, v) => sum + v, 0) / n;
|
|
83
|
+
const sd = Math.sqrt(values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / Math.max(1, n - 1));
|
|
84
|
+
const min = Math.min(...values); const max = Math.max(...values);
|
|
85
|
+
const spread = sd > 0 ? sd : Math.max(1, Math.abs(mean) * 0.1);
|
|
86
|
+
const bandwidth = 1.06 * spread * n ** -0.2;
|
|
87
|
+
const from = min - 3 * bandwidth; const to = max + 3 * bandwidth;
|
|
88
|
+
const step = (to - from) / (points - 1);
|
|
89
|
+
const scale = 1 / (n * bandwidth * Math.sqrt(2 * Math.PI));
|
|
90
|
+
return Array.from({ length: points }, (_, i) => {
|
|
91
|
+
const x = from + i * step;
|
|
92
|
+
const y = values.reduce((sum, v) => sum + Math.exp(-0.5 * ((x - v) / bandwidth) ** 2), 0) * scale;
|
|
93
|
+
return { x, y };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The empirical cumulative share: each distinct value, and the share (0 to 1) of values at or below it. */
|
|
98
|
+
export function ecdf(values: readonly number[]): CurvePoint[] {
|
|
99
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
100
|
+
const points: CurvePoint[] = [];
|
|
101
|
+
sorted.forEach((x, i) => {
|
|
102
|
+
const share = (i + 1) / sorted.length;
|
|
103
|
+
if (points.at(-1)?.x === x) { points[points.length - 1] = { x, y: share }; } else { points.push({ x, y: share }); }
|
|
104
|
+
});
|
|
105
|
+
return points;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The least-squares line through points, as its two ends over the points' x range, with its slope and intercept;
|
|
110
|
+
* `undefined` for fewer than two points or when every x is the same.
|
|
111
|
+
*/
|
|
112
|
+
export function linearFit(pairs: readonly CurvePoint[]): { readonly slope: number; readonly intercept: number; readonly points: readonly [CurvePoint, CurvePoint] } | undefined {
|
|
113
|
+
if (pairs.length < 2) { return undefined; }
|
|
114
|
+
const n = pairs.length;
|
|
115
|
+
const mx = pairs.reduce((sum, p) => sum + p.x, 0) / n; const my = pairs.reduce((sum, p) => sum + p.y, 0) / n;
|
|
116
|
+
const sxx = pairs.reduce((sum, p) => sum + (p.x - mx) ** 2, 0);
|
|
117
|
+
if (sxx === 0) { return undefined; }
|
|
118
|
+
const slope = pairs.reduce((sum, p) => sum + (p.x - mx) * (p.y - my), 0) / sxx;
|
|
119
|
+
const intercept = my - slope * mx;
|
|
120
|
+
const xs = pairs.map((p) => p.x);
|
|
121
|
+
const lo = Math.min(...xs); const hi = Math.max(...xs);
|
|
122
|
+
return { slope, intercept, points: [{ x: lo, y: intercept + slope * lo }, { x: hi, y: intercept + slope * hi }] };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** A fixed nudge in -0.5 … 0.5 for the `i`th point (the same every draw), so points with equal values don't sit on each other. */
|
|
126
|
+
export function jitter(i: number): number {
|
|
127
|
+
const s = Math.sin((i + 1) * 12.9898) * 43758.5453;
|
|
128
|
+
return s - Math.floor(s) - 0.5;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The mean of each window of `size` values ending at each index (`null` until a window is full or while it holds an empty value). */
|
|
132
|
+
export function movingAverage(values: readonly (number | null)[], size: number): (number | null)[] {
|
|
133
|
+
return values.map((_, i) => {
|
|
134
|
+
if (i + 1 < size) { return null; }
|
|
135
|
+
const window = values.slice(i + 1 - size, i + 1);
|
|
136
|
+
if (window.some((v) => v === null)) { return null; }
|
|
137
|
+
return window.reduce<number>((sum, v) => sum + (v ?? 0), 0) / size;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How wide a chart is drawn, followed live: product's phone rules key on the chart's own width (a chart in a narrow
|
|
3
|
+
* chat pane is a phone chart), not the viewport's. And whether the person asks for reduced motion.
|
|
4
|
+
*/
|
|
5
|
+
import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue';
|
|
6
|
+
|
|
7
|
+
/** Below this width a chart follows the phone rules: legends at the bottom, fewer labels, no zoom slider. */
|
|
8
|
+
export const PHONE_WIDTH = 600;
|
|
9
|
+
|
|
10
|
+
/** An element's width, updated as it resizes (0 until mounted, and where there is no `ResizeObserver`). */
|
|
11
|
+
export function useWidth(element: Readonly<Ref<HTMLElement | null>>): Readonly<Ref<number>> {
|
|
12
|
+
const width = ref(0);
|
|
13
|
+
let observer: ResizeObserver | undefined;
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
const el = element.value;
|
|
16
|
+
if (el === null) { return; }
|
|
17
|
+
width.value = el.clientWidth;
|
|
18
|
+
if (typeof ResizeObserver === 'undefined') { return; }
|
|
19
|
+
observer = new ResizeObserver(([entry]) => { if (entry !== undefined) { width.value = entry.contentRect.width; } });
|
|
20
|
+
observer.observe(el);
|
|
21
|
+
});
|
|
22
|
+
onBeforeUnmount(() => { observer?.disconnect(); });
|
|
23
|
+
return width;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Whether a media query matches, followed live (false where there is no `matchMedia`). */
|
|
27
|
+
export function useMediaQuery(query: string): Readonly<Ref<boolean>> {
|
|
28
|
+
const matches = ref(false);
|
|
29
|
+
let media: MediaQueryList | undefined;
|
|
30
|
+
const update = (): void => { matches.value = media?.matches ?? false; };
|
|
31
|
+
onMounted(() => {
|
|
32
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') { return; }
|
|
33
|
+
media = window.matchMedia(query);
|
|
34
|
+
update();
|
|
35
|
+
media.addEventListener('change', update);
|
|
36
|
+
});
|
|
37
|
+
onBeforeUnmount(() => { media?.removeEventListener('change', update); });
|
|
38
|
+
return matches;
|
|
39
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A widget's chip row, apart from any component (moved here from the web app on 2026-11-29): a chip's words and the
|
|
3
|
+
* relative dates it offers, the args a chip set runs with, and `ChipState`, which stages chip changes and applies them
|
|
4
|
+
* together (relative dates resolved then) through the app's result view (its `controls` slot runs the widget again
|
|
5
|
+
* with other args); a preset sets its args and runs at once. Also the request that asks the agent to make a widget
|
|
6
|
+
* from a plain result (the result view's "Make a widget" item, `client({ resultItems })`).
|
|
7
|
+
*/
|
|
8
|
+
import type { Json, QualifiedName } from '@harness/core';
|
|
9
|
+
import type { ResultControls } from '@harness/sdk';
|
|
10
|
+
import { computed, shallowRef } from 'vue';
|
|
11
|
+
import { relativeDatesFor, resolveArgValue } from '../shared/relative-dates.ts';
|
|
12
|
+
import { RELATIVE_DATES, WidgetResult, type ArgValue, type WidgetPreset, type WidgetShownControl } from '../shared/spec.ts';
|
|
13
|
+
|
|
14
|
+
// ─── The chip row ─────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
/** A chip's staged value: an `ArgValue`, or `null` for "Any" (the arg is cleared). */
|
|
17
|
+
export type ChipValue = ArgValue | null;
|
|
18
|
+
|
|
19
|
+
/** A value as a chip shows it: "Any" when unset, text as it is, yes or no, a list joined, else compact JSON. */
|
|
20
|
+
export function jsonText(value: Json | undefined): string {
|
|
21
|
+
if (value === undefined || value === null || value === '') { return 'Any'; }
|
|
22
|
+
if (typeof value === 'string') { return value; }
|
|
23
|
+
if (typeof value === 'number') { return String(value); }
|
|
24
|
+
if (typeof value === 'boolean') { return value ? 'Yes' : 'No'; }
|
|
25
|
+
if (Array.isArray(value)) { return value.length === 0 ? 'Any' : value.map((item) => jsonText(item)).join(', '); }
|
|
26
|
+
return JSON.stringify(value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const sameJson = (a: Json | undefined, b: Json | undefined): boolean => JSON.stringify(a) === JSON.stringify(b);
|
|
30
|
+
|
|
31
|
+
/** Whether two staged values are the same. */
|
|
32
|
+
export function sameValue(a: ChipValue | undefined, b: ChipValue | undefined): boolean {
|
|
33
|
+
if (a === undefined || a === null || b === undefined || b === null) { return (a ?? null) === (b ?? null); }
|
|
34
|
+
if ('relative' in a || 'relative' in b) { return 'relative' in a && 'relative' in b && a.relative === b.relative; }
|
|
35
|
+
return sameJson(a.literal, b.literal);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A chip's value in words: a choice's label, a relative date's words, the value, or "Any". */
|
|
39
|
+
export function chipText(control: Pick<WidgetShownControl, 'choices'>, value: ChipValue | undefined): string {
|
|
40
|
+
if (value === undefined || value === null) { return 'Any'; }
|
|
41
|
+
const choice = control.choices?.find((c) => c.value !== undefined && sameValue(c.value, value));
|
|
42
|
+
if (choice !== undefined) { return choice.label; }
|
|
43
|
+
return 'relative' in value ? RELATIVE_DATES[value.relative].label : jsonText(value.literal);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The relative dates a chip's popover offers: days for a date argument, instants for a timestamp, else none. */
|
|
47
|
+
export function relativeChoices(control: Pick<WidgetShownControl, 'relative' | 'argType'>): { readonly value: ArgValue; readonly label: string }[] {
|
|
48
|
+
if (!control.relative) { return []; }
|
|
49
|
+
return relativeDatesFor(control.argType.name).map((relative) => ({ value: { relative }, label: RELATIVE_DATES[relative].label }));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The person's time zone, for relative dates. */
|
|
53
|
+
export function localZone(): string {
|
|
54
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The widget args a chip row runs with: each chip's staged value (else the one it ran with), relative dates resolved
|
|
59
|
+
* now. A value the widget filled in from its own default (a relative one) is left out, so the widget keeps it current;
|
|
60
|
+
* "Any" leaves the arg out, or sends `null` where the widget would otherwise fill in its default (`defaulted`).
|
|
61
|
+
*/
|
|
62
|
+
export function chipArgs(controls: readonly WidgetShownControl[], staged: Readonly<Record<string, ChipValue>>, now: Date, zone: string): Record<string, Json> {
|
|
63
|
+
const args: Record<string, Json> = {};
|
|
64
|
+
for (const control of controls) {
|
|
65
|
+
const set = Object.hasOwn(staged, control.arg) ? staged[control.arg] : undefined;
|
|
66
|
+
const value = set === undefined ? control.value : set;
|
|
67
|
+
if (value === undefined || value === null) {
|
|
68
|
+
// "Any" over a chip the widget would fill from its default is sent as null, which clears it
|
|
69
|
+
if (control.defaulted === true) { args[control.arg] = null; }
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (set === undefined && 'relative' in value) { continue; }
|
|
73
|
+
args[control.arg] = resolveArgValue(value, now, zone);
|
|
74
|
+
}
|
|
75
|
+
return args;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/** The request that asks the agent to make a widget from a run's fn and args (it proposes; the person saves). */
|
|
80
|
+
export function saveWidgetRequest(fn: QualifiedName, args: Json | undefined): string {
|
|
81
|
+
const asked = args === undefined || (typeof args === 'object' && args !== null && Object.keys(args).length === 0) ? '' : ` with ${JSON.stringify(args)}`;
|
|
82
|
+
return `Make a widget from ${fn}${asked} that I can open again (use widgets/make_widget). Keep controls for its arguments and the visuals that fit.`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// ─── Staged chips ─────────────────────────────────────────────────────────────
|
|
87
|
+
|
|
88
|
+
/** When and where chips resolve relative dates (a test passes a fixed one). */
|
|
89
|
+
export interface ChipClock {
|
|
90
|
+
now(): Date;
|
|
91
|
+
zone(): string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const SYSTEM_CLOCK: ChipClock = { now: () => new Date(), zone: localZone };
|
|
95
|
+
|
|
96
|
+
/** A widget result's chip row, read from what the result view last drew (its latest run's output). */
|
|
97
|
+
export function controlsOf(value: Json | undefined): readonly WidgetShownControl[] {
|
|
98
|
+
const parsed = WidgetResult.safeParse(value);
|
|
99
|
+
return parsed.success ? parsed.data.controls : [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* One chip row's state: changes staged and applied together through the result view (`controls.run`, which runs the
|
|
104
|
+
* level again with other args), a preset applied at once. Chip values not staged are the ones the level ran with.
|
|
105
|
+
*/
|
|
106
|
+
export class ChipState {
|
|
107
|
+
readonly #view: () => ResultControls;
|
|
108
|
+
readonly #clock: ChipClock;
|
|
109
|
+
/** Chip values changed but not applied yet (`null` is "Any"). */
|
|
110
|
+
readonly staged = shallowRef<Readonly<Record<string, ChipValue>>>({});
|
|
111
|
+
|
|
112
|
+
constructor(view: () => ResultControls, clock: ChipClock = SYSTEM_CLOCK) {
|
|
113
|
+
this.#view = view;
|
|
114
|
+
this.#clock = clock;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The chips of the level shown. */
|
|
118
|
+
readonly controls = computed(() => controlsOf(this.#view().value));
|
|
119
|
+
/** Whether the chip row has changes to apply. */
|
|
120
|
+
readonly dirty = computed(() => this.controls.value.some((c) => Object.hasOwn(this.staged.value, c.arg) && !sameValue(this.staged.value[c.arg], c.value)));
|
|
121
|
+
|
|
122
|
+
/** A chip's value now: staged, else the one it ran with. */
|
|
123
|
+
value(arg: string): ChipValue | undefined {
|
|
124
|
+
if (Object.hasOwn(this.staged.value, arg)) { return this.staged.value[arg]; }
|
|
125
|
+
return this.controls.value.find((c) => c.arg === arg)?.value;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Stage a chip's value (`null` is "Any"). */
|
|
129
|
+
stage(arg: string, value: ChipValue): void {
|
|
130
|
+
this.staged.value = { ...this.staged.value, [arg]: value };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Drop the staged chip values. */
|
|
134
|
+
discard(): void {
|
|
135
|
+
this.staged.value = {};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Run with the staged chip values (each chip's, else the one it ran with); whether it worked. */
|
|
139
|
+
async apply(): Promise<boolean> {
|
|
140
|
+
const ok = await this.#view().run(chipArgs(this.controls.value, this.staged.value, this.#clock.now(), this.#clock.zone()));
|
|
141
|
+
if (ok) { this.discard(); }
|
|
142
|
+
return ok;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** A preset: set its args and run at once. */
|
|
146
|
+
async preset(preset: WidgetPreset): Promise<boolean> {
|
|
147
|
+
this.staged.value = { ...this.staged.value, ...preset.sets };
|
|
148
|
+
return this.apply();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The widgets system's client, typed by the contract:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* (
|
|
2
|
+
* The widgets system's client, typed by the contract: every chart family a result can be drawn with (the hub's visual
|
|
3
|
+
* registry, `hub/visuals`, drawn with the ECharts this bundle carries); a `make_widget` proposal drawn as its card with
|
|
4
|
+
* Save, and a saved widget's result (any fn of the `widget` kind) with the app's result view and the widget's chip row,
|
|
5
|
+
* keeping a look picked in its Settings (both through the result-renderer slot, so the chat and the fn page draw them
|
|
6
|
+
* under their own run line); "Make a widget" in a plain result table's 3-dot menu (`resultItems`, which asks the agent
|
|
7
|
+
* to propose one); and the saved widgets' page (`/s/widgets/saved`). The chat loads this module from the hub.
|
|
6
8
|
*/
|
|
7
9
|
// typescript-eslint can't see the types of .vue modules from .ts files (as for packages/web/src/main.ts); vue-tsc
|
|
8
10
|
// checks this file, so the renderers' props are still checked against the contract
|
|
9
11
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
10
|
-
import { client } from '@harness/sdk';
|
|
12
|
+
import { HUB_VISUALS, client } from '@harness/sdk';
|
|
11
13
|
import { widgets } from '../shared/index.ts';
|
|
14
|
+
import { CHART_ENTRIES } from './charts/index.ts';
|
|
15
|
+
import { saveWidgetRequest } from './chips.ts';
|
|
12
16
|
import ProposalCard from './ProposalCard.vue';
|
|
13
17
|
import SavedWidget from './SavedWidget.vue';
|
|
14
18
|
import WidgetsPage from './WidgetsPage.vue';
|
|
@@ -16,4 +20,13 @@ import WidgetsPage from './WidgetsPage.vue';
|
|
|
16
20
|
export default client(widgets, {
|
|
17
21
|
results: { fns: { make_widget: ProposalCard }, kinds: { widget: SavedWidget } },
|
|
18
22
|
pages: { WidgetsPage },
|
|
23
|
+
visuals: { [HUB_VISUALS]: CHART_ENTRIES },
|
|
24
|
+
resultItems: {
|
|
25
|
+
make_widget: {
|
|
26
|
+
label: 'Make a widget', icon: 'grid',
|
|
27
|
+
// the rows of a write can't be a widget's source
|
|
28
|
+
offered: (view) => !view.readOnly,
|
|
29
|
+
async run(view, ask) { await ask(saveWidgetRequest(view.fn, view.args), true); },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
19
32
|
});
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* keep a look picked in a saved widget's Settings, the saved widgets' search (one page of the hub's fn search), and the
|
|
5
5
|
* link to the saved widgets' page.
|
|
6
6
|
*/
|
|
7
|
-
import { QualifiedName, systemPagePath, WIDGET_KIND, WIDGETS_SYSTEM, type FnSearchQuery
|
|
7
|
+
import { QualifiedName, systemPagePath, WIDGET_KIND, WIDGETS_SYSTEM, type FnSearchQuery } from '@harness/core';
|
|
8
|
+
import type { MakeWidgetArgs, SaveWidgetArgs, WidgetProposal, WidgetResult } from '../shared/spec.ts';
|
|
8
9
|
import type { ResultLook } from '@harness/sdk';
|
|
9
10
|
import { WIDGETS_PAGE } from '../shared/index.ts';
|
|
10
11
|
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@aeye/gin": "^0.
|
|
4
|
-
"@aeye/schema": "^0.
|
|
3
|
+
"@aeye/gin": "^0.11.2",
|
|
4
|
+
"@aeye/schema": "^0.11.2",
|
|
5
5
|
"@ayepi/core": "^0.6.0",
|
|
6
6
|
"@ayepi/env": "^0.6.0",
|
|
7
7
|
"@harness/core": "*",
|
|
8
8
|
"@harness/sdk": "*",
|
|
9
|
+
"echarts": "6.1.0",
|
|
9
10
|
"vue": "^3.5.22",
|
|
11
|
+
"vue-echarts": "8.3.2",
|
|
10
12
|
"zod": "^4.6.7"
|
|
11
13
|
},
|
|
12
14
|
"name": "@harness/system-widgets",
|
|
13
15
|
"private": true,
|
|
14
|
-
"version": "0.
|
|
16
|
+
"version": "0.4.1",
|
|
15
17
|
"license": "Apache-2.0",
|
|
16
18
|
"type": "module",
|
|
17
19
|
"description": "Development only: system.json holds this system's name, version and entries.",
|
|
18
20
|
"exports": {
|
|
19
21
|
".": "./shared/index.ts",
|
|
20
22
|
"./server": "./server/index.ts",
|
|
21
|
-
"./client": "./client/index.ts"
|
|
23
|
+
"./client": "./client/index.ts",
|
|
24
|
+
"./charts": "./shared/charts.ts"
|
|
22
25
|
}
|
|
23
26
|
}
|