fuli-context 0.22.1 → 0.23.0-beta.2
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/dist/web/assets/AboutPage-CRIF2M8n.js +1 -0
- package/dist/web/assets/AgentHand-Dp9TFS4q.js +1 -0
- package/dist/web/assets/AgentMentionCopy-BXOrsEWh.css +1 -0
- package/dist/web/assets/AgentMentionCopy-C7N92Shm.js +1 -0
- package/dist/web/assets/AgentName-CbsQ9vDy.js +1 -0
- package/dist/web/assets/{AgentProfilePage-MkP7Lgo6.css → AgentProfilePage-B_V-Dm8v.css} +1 -1
- package/dist/web/assets/AgentProfilePage-DOpq0b3j.js +2 -0
- package/dist/web/assets/AgentServicesPage-Dr9WU0f9.js +1 -0
- package/dist/web/assets/AgentWorkbench-CMoeT-BY.css +1 -0
- package/dist/web/assets/AgentWorkbench-DTWZFf1A.js +2 -0
- package/dist/web/assets/AgentsDirectoryPage-CxDOdNxT.js +1 -0
- package/dist/web/assets/{AgentsDirectoryPage-Cq1z926q.css → AgentsDirectoryPage-DjEfG9dC.css} +1 -1
- package/dist/web/assets/BackLink-ByRr21Sw.js +1 -0
- package/dist/web/assets/BoardMoveMenu-Bd1T62eA.js +1 -0
- package/dist/web/assets/CaptureChangePage-DyuSSSDE.js +1 -0
- package/dist/web/assets/Card-BD5ohuk8.js +1 -0
- package/dist/web/assets/CardHeader-DTVqXpsf.js +1 -0
- package/dist/web/assets/CardTitle-C5REIVlp.js +1 -0
- package/dist/web/assets/ConnectionsPage-CKruAjBF.js +1 -0
- package/dist/web/assets/CreateProjectDialog-D6JS3RtH.js +2 -0
- package/dist/web/assets/DataFormatPage-DNaogYjf.js +2 -0
- package/dist/web/assets/DialogFooter-C5AIwQ5R.js +1 -0
- package/dist/web/assets/EmployeeScopeDialog-Lmfos9SA.js +1 -0
- package/dist/web/assets/EmployeeTaskBoard-U3KmfQG3.js +3 -0
- package/dist/web/assets/EmployeeWorkbenchPage-O9DEMzLT.js +3 -0
- package/dist/web/assets/FieldDescription-_fuW5MBO.js +1 -0
- package/dist/web/assets/GrowthLoading--m-lSUeo.js +1 -0
- package/dist/web/assets/InboxPage-DmJfYzaK.js +4 -0
- package/dist/web/assets/Input-DqjML-Qy.js +1 -0
- package/dist/web/assets/KnowledgeHardDeleteSection-AFg1ybWc.js +1 -0
- package/dist/web/assets/KnowledgeItemEditPage-B29px-r0.js +1 -0
- package/dist/web/assets/KnowledgeItemSummaryCard-BhHet9HU.js +1 -0
- package/dist/web/assets/KnowledgeOrganizerPage-BfD42JmC.js +1 -0
- package/dist/web/assets/KnowledgePage-nbTejsvV.js +1 -0
- package/dist/web/assets/KnowledgePeek-ByakOiOO.js +2 -0
- package/dist/web/assets/{KnowledgePeek-DdxwAWYs.css → KnowledgePeek-CK2RKeRx.css} +1 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-B1fMTy2W.js +1 -0
- package/dist/web/assets/KnowledgeWorkspace-DCzwenHE.js +4 -0
- package/dist/web/assets/{KnowledgeWorkspace-CA8oxVht.css → KnowledgeWorkspace-j8xlGwtg.css} +1 -1
- package/dist/web/assets/Label-CufKLEgT.js +1 -0
- package/dist/web/assets/ModelSettingsPage-jQKn4MsB.js +1 -0
- package/dist/web/assets/NotFoundPage-B4KkZO2q.js +1 -0
- package/dist/web/assets/OccupationsPage-5Ja81Cfg.js +1 -0
- package/dist/web/assets/OverviewPage-C-K4KDNM.js +2 -0
- package/dist/web/assets/PersonalProfilePage-BVZ3WHmf.js +1 -0
- package/dist/web/assets/PersonalProjectsPage-C1J8Poj8.js +1 -0
- package/dist/web/assets/PopperContent-C-KMpRbF.js +1 -0
- package/dist/web/assets/Presence-B4aVQMT8.js +3 -0
- package/dist/web/assets/ProjectAgentDetailPage-B6bTOIhe.js +8 -0
- package/dist/web/assets/ProjectAgentDialog-CWuqScFD.js +5 -0
- package/dist/web/assets/ProjectAgentFirstTask-C7qzXCQ6.js +1 -0
- package/dist/web/assets/ProjectAgentsPage-BNtWbct5.js +1 -0
- package/dist/web/assets/ProjectAgentsPage-Bym-IM4-.css +1 -0
- package/dist/web/assets/ProjectJudgmentPolicy-L_plkldY.js +1 -0
- package/dist/web/assets/ProjectScopePicker-BXy07CHg.js +1 -0
- package/dist/web/assets/PublicProjectsPage-Cftk4zLX.js +1 -0
- package/dist/web/assets/RadioGroupItem-DoOqLMbZ.js +1 -0
- package/dist/web/assets/RoundtablesPage-RCtrPHxs.js +1 -0
- package/dist/web/assets/RovingFocusGroup-BeCLKMQA.js +1 -0
- package/dist/web/assets/RovingFocusItem-BN-h70s_.js +1 -0
- package/dist/web/assets/SessionMigrationPage-Dcjylswy.js +1 -0
- package/dist/web/assets/SessionRecordsPage-jrFse2a1.js +1 -0
- package/dist/web/assets/SettingsPage-BkHm8GV4.js +1 -0
- package/dist/web/assets/{SettingsPage-DpVeP2OZ.css → SettingsPage-BxAXf6EF.css} +1 -1
- package/dist/web/assets/SharedJefaReportPage-_KXsTVGF.js +1 -0
- package/dist/web/assets/Switch-BPAVVtqu.js +1 -0
- package/dist/web/assets/TableHeader-P9d7xF7t.js +1 -0
- package/dist/web/assets/TabsContent-Casnps6y.js +1 -0
- package/dist/web/assets/TabsTrigger-AQwqcZRn.js +1 -0
- package/dist/web/assets/TagVocabularyPage-CsDJkbU3.js +1 -0
- package/dist/web/assets/TaskBlockerClear-wqHV47Vx.js +1 -0
- package/dist/web/assets/TaskBlockerNotice-DJytDDst.js +1 -0
- package/dist/web/assets/TaskExecutionPlan-8dwc8_Jf.css +1 -0
- package/dist/web/assets/TaskExecutionPlan-BPnu-yfT.js +2 -0
- package/dist/web/assets/TaskReason-C5g8DpOy.js +1 -0
- package/dist/web/assets/Teleport-BV0XYmdS.js +1 -0
- package/dist/web/assets/TextField-C69MdaFy.js +1 -0
- package/dist/web/assets/Textarea-D1Kzx_7L.js +1 -0
- package/dist/web/assets/UiChip-BqOpp18Q.js +1 -0
- package/dist/web/assets/UiDialog-BAWkdfF-.js +1 -0
- package/dist/web/assets/UiDisclosure-mGmGItAv.js +1 -0
- package/dist/web/assets/UiIcon-BUYpKd4D.js +1 -0
- package/dist/web/assets/UiIconButton-CeiP7Vmj.js +1 -0
- package/dist/web/assets/UiNotice-BlznzX5i.js +1 -0
- package/dist/web/assets/UiSegmented-DlgYMxnc.js +1 -0
- package/dist/web/assets/UiSelect-BWViyott.js +1 -0
- package/dist/web/assets/UiWeight-DZwt7cIP.js +1 -0
- package/dist/web/assets/UnassignedConversationsPanel-DV2CpIdb.js +1 -0
- package/dist/web/assets/VirtualDirectoryList-D-3X_X7D.js +1 -0
- package/dist/web/assets/VisuallyHiddenInput-BjPsr2D4.js +1 -0
- package/dist/web/assets/Workbench3D-CVlnk7bc.js +2 -0
- package/dist/web/assets/_plugin-vue_export-helper-lED7mxHY.js +9 -0
- package/dist/web/assets/accordion-GR6gjqFY.js +1 -0
- package/dist/web/assets/agent-pins-D2cylMl0.js +1 -0
- package/dist/web/assets/{agent-profile.css_vue_type_style_index_0_src_true_lang-Cmz1y1IL.js → agent-profile.css_vue_type_style_index_0_src_true_lang-w5YilVWS.js} +1 -1
- package/dist/web/assets/{agent-roster-records-DVgD9i6q.js → agent-roster-records-DgWGHLHW.js} +1 -1
- package/dist/web/assets/agent-task-board-DCS97QK2.js +1 -0
- package/dist/web/assets/{agent-work-summary-CUMg6XKp.js → agent-work-summary-QPOQuybY.js} +1 -1
- package/dist/web/assets/{attach-closest-edge-BqQXNoAj.js → attach-closest-edge-B5hSH5Q1.js} +1 -1
- package/dist/web/assets/{attention-store-C0D-sZNV.js → attention-store-DKza0N1e.js} +1 -1
- package/dist/web/assets/badge-CG2m9xwC.js +1 -0
- package/dist/web/assets/button-CZBMEiSm.js +1 -0
- package/dist/web/assets/checkbox-3VSDPUJw.js +1 -0
- package/dist/web/assets/{client-BgxDxCVo.js → client-Dwnwq6uu.js} +1 -1
- package/dist/web/assets/{client-links-store-BoDDNO2M.js → client-links-store-DG6AhNPP.js} +1 -1
- package/dist/web/assets/console-ny5TvCWK.js +1 -0
- package/dist/web/assets/conversation-launcher-settings-Ds-piWNR.js +1 -0
- package/dist/web/assets/{design-lab-B-njEjVo.js → design-lab-DrVlcS2x.js} +1 -1
- package/dist/web/assets/dialog-C3x9ziBB.js +1 -0
- package/dist/web/assets/dist-CB11Zet2.js +1 -0
- package/dist/web/assets/dropdown-menu-Cdtg4lAd.js +1 -0
- package/dist/web/assets/field-DMSD3CwL.js +1 -0
- package/dist/web/assets/{identity-IcZw_zYG.js → identity-DI_OdSEg.js} +1 -1
- package/dist/web/assets/index-B5zVxSJb.css +1 -0
- package/dist/web/assets/index-S0AnueS1.js +2 -0
- package/dist/web/assets/is-equal-8VOV02sH.js +1 -0
- package/dist/web/assets/{judgment-api-ldtIv-Jc.js → judgment-api-CwnpLQOf.js} +1 -1
- package/dist/web/assets/label-table-vGnKmYm3.js +1 -0
- package/dist/web/assets/{model-DvzuuyNk.js → model-BOXKOC62.js} +1 -1
- package/dist/web/assets/{model-mDDN02UJ.js → model-BlAV3okF.js} +1 -1
- package/dist/web/assets/{model-D2VmKHYm.js → model-C7hgak_o.js} +1 -1
- package/dist/web/assets/{model-2gNC7xGH.js → model-CmYu_CSs.js} +1 -1
- package/dist/web/assets/{model-DL29Qg9K.js → model-DSSYQ-i_.js} +1 -1
- package/dist/web/assets/{model-DvwLThbs.js → model-kV1gs-y2.js} +1 -1
- package/dist/web/assets/{motion-preference-BquW2Vpx.js → motion-preference-fHFXX4cl.js} +1 -1
- package/dist/web/assets/{occupation-catalog-CwMNzUWJ.js → occupation-catalog-DOk8egq8.js} +1 -1
- package/dist/web/assets/{orchestration-filters-DhxYUaNx.js → orchestration-filters-BqUPBFf1.js} +1 -1
- package/dist/web/assets/page-title-D1CadCvf.js +1 -0
- package/dist/web/assets/profile-model-DGbpJdVC.js +1 -0
- package/dist/web/assets/{project-board-layout-LQu5EwBM.js → project-board-layout-Dtyrl2is.js} +1 -1
- package/dist/web/assets/project-board-settings-CNVNKEfm.js +1 -0
- package/dist/web/assets/{project-capture-DHvCDGGz.js → project-capture-BpaGUI-m.js} +1 -1
- package/dist/web/assets/{project-origin-DDVfUP1_.js → project-origin-DJ4d13mb.js} +1 -1
- package/dist/web/assets/project-team-api-yJVsib_j.js +1 -0
- package/dist/web/assets/{quick-edit-api-DPb69BlT.js → quick-edit-api-CBMbWX0d.js} +1 -1
- package/dist/web/assets/rolldown-runtime-4tVxZq34.js +1 -0
- package/dist/web/assets/runtime-dom.esm-bundler-ClO7ICIC.js +2 -0
- package/dist/web/assets/select-CCN-VOqx.js +1 -0
- package/dist/web/assets/shared-report-BRgNEV5m.js +1 -0
- package/dist/web/assets/source-adapters-8UHmhZTa.js +1 -0
- package/dist/web/assets/task-labels-pCGKthln.js +1 -0
- package/dist/web/assets/ui-Bfbk4_Xk.js +1 -0
- package/dist/web/assets/{useAgentRecords-D3upwp_U.js → useAgentRecords-DZPebmJ_.js} +1 -1
- package/dist/web/assets/useApi-CROJJdhE-CpF4ddpD.js +1 -0
- package/dist/web/assets/useDirection-DXu4lssv.js +1 -0
- package/dist/web/assets/useFocusReturn-DVcg2RDp.js +1 -0
- package/dist/web/assets/useForwardExpose-CNq5826B.js +1 -0
- package/dist/web/assets/useKnowledgeItemPeek-CxwXNZqm.js +1 -0
- package/dist/web/assets/useMinimumLoadingDisplay-SSJELjga.js +1 -0
- package/dist/web/assets/usePrimitiveElement-WBpNZTN_.js +1 -0
- package/dist/web/assets/useRoutePeek-U71ADWt0.js +1 -0
- package/dist/web/assets/{useTypeahead-C4mRUlUC.js → useTypeahead-CJkAiAa9.js} +1 -1
- package/dist/web/assets/utils-CfVEk15i.js +1 -0
- package/dist/web/assets/vue-router-BFTYTsOL.js +1 -0
- package/dist/web/index.html +46 -41
- package/docs/agent-conversations-and-collaboration.md +23 -9
- package/docs/agent-interface-architecture.md +25 -0
- package/docs/client-connections.md +47 -0
- package/docs/client-links.md +4 -0
- package/docs/employee-agents.md +1 -1
- package/graph-provider/fuli_graph/agent_conversation_models.py +2 -1
- package/graph-provider/fuli_graph/conversation_context.py +40 -90
- package/graph-provider/fuli_graph/store_agent_conversations.py +26 -15
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +31 -31
- package/package.json +3 -3
- package/skills/capturing-session-knowledge/SKILL.md +7 -0
- package/skills/capturing-session-knowledge/references/coordination.md +4 -0
- package/skills/capturing-session-knowledge/references/retrieval.md +7 -0
- package/skills/operating-fuli/SKILL.md +3 -2
- package/skills/operating-fuli/references/workflow-recipes.md +4 -1
- package/src/agent-apps/host-tools/catalog.js +4 -0
- package/src/agent-kits/client-installer.js +29 -0
- package/src/agent-kits/derived-file.js +15 -0
- package/src/agent-kits/executable-download.js +53 -0
- package/src/agent-kits/executables.js +87 -0
- package/src/agent-kits/fuli-installer-manifest.json +125 -0
- package/src/agent-kits/installer-manifest.js +36 -0
- package/src/agent-kits/installer-shadow.js +82 -0
- package/src/agent-kits/launcher-host-config.js +56 -0
- package/src/agent-kits/pins.js +49 -0
- package/src/agent-kits/ports.js +13 -0
- package/src/agent-kits/session-clients.js +57 -0
- package/src/agent-kits/session-launcher.js +55 -0
- package/src/agent-kits/session-offers.js +67 -0
- package/src/agent-kits/vendor/agent-installer/LICENSE +21 -0
- package/src/agent-kits/vendor/agent-installer/README.md +9 -0
- package/src/agent-kits/vendor/agent-installer/index.d.ts +129 -0
- package/src/agent-kits/vendor/agent-installer/index.mjs +188 -0
- package/src/agent-kits/vendor/agent-session-launcher/LICENSE +21 -0
- package/src/agent-kits/vendor/agent-session-launcher/README.md +9 -0
- package/src/agent-kits/vendor/agent-session-launcher/index.d.ts +101 -0
- package/src/agent-kits/vendor/agent-session-launcher/index.mjs +159 -0
- package/src/agent-tools/agent-conversation-definitions.js +1 -1
- package/src/agent-tools/agent-workflow-definitions.js +49 -0
- package/src/agent-tools/graph-definitions.js +2 -0
- package/src/agent-tools/graph-handlers.js +2 -0
- package/src/agent-tools/interface-catalog.js +4 -1
- package/src/agent-tools/knowledge-definitions.js +7 -0
- package/src/agent-workflows/agent-tools.js +59 -0
- package/src/agent-workflows/port.js +179 -0
- package/src/agent-workflows/store.js +156 -0
- package/src/agents/claude-code/conversation-transcript.js +8 -0
- package/src/agents/claude-code/lifecycle-hook.js +9 -0
- package/src/agents/claude-code/session-client.js +29 -0
- package/src/agents/codex/conversation-transcript.js +6 -0
- package/src/agents/identity-receipt.js +1 -0
- package/src/data-format/local-stores.js +7 -1
- package/src/desktop/windows-desktop-client.js +120 -0
- package/src/desktop/windows-rollback-command.js +6 -2
- package/src/desktop/windows-rollback.js +7 -1
- package/src/desktop/windows-tray-update.js +19 -31
- package/src/desktop/windows-uninstall-command.js +2 -1
- package/src/desktop/windows-uninstall.js +10 -4
- package/src/desktop/windows-update-command.js +7 -2
- package/src/desktop/windows-update-lock.js +9 -7
- package/src/desktop/windows-update.js +7 -1
- package/src/employees/recruitment.js +12 -3
- package/src/graphiti/agent-conversations.js +1 -1
- package/src/graphiti/current-project-knowledge-search.js +3 -2
- package/src/graphiti/federated-search.js +4 -2
- package/src/graphiti/fla-mention.js +25 -8
- package/src/graphiti/fla-picker.js +25 -4
- package/src/graphiti/knowledge-result-budget.js +63 -9
- package/src/graphiti/local-runtimes.js +4 -0
- package/src/graphiti/project-agent-task-entry.js +8 -3
- package/src/graphiti/task-entry-named-fla.js +41 -19
- package/src/http/agent-workflows-api-router.js +36 -0
- package/src/http/api-router.js +9 -0
- package/src/http/doctor-api-router.js +31 -0
- package/src/http/session-launch-api-router.js +36 -0
- package/src/mcp/process-registry.js +12 -6
- package/src/mcp/session-id.js +1 -0
- package/src/mcp/tool-annotations.js +2 -0
- package/src/native-runtime/neo4j-install.js +6 -23
- package/src/native-runtime/resumable-download.js +24 -0
- package/src/native-runtime/windows-assets.js +30 -13
- package/src/native-runtime/windows-processes.js +5 -2
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/server.js +2 -1
- package/src/setup/paths.js +3 -0
- package/src/system/console-update.js +10 -2
- package/src/system/detached-job.js +8 -0
- package/src/system/doctor-repair.js +61 -0
- package/src/system/doctor.js +119 -0
- package/src/system/package-version-checker.js +8 -1
- package/src/system/system-service.js +52 -13
- package/src/text/token-estimate.js +11 -0
- package/dist/web/assets/AboutPage-45tAvgRN.js +0 -1
- package/dist/web/assets/AgentHand-CQbDVBYv.js +0 -1
- package/dist/web/assets/AgentMentionCopy-BHFp527T.js +0 -1
- package/dist/web/assets/AgentMentionCopy-BIWsPf22.css +0 -1
- package/dist/web/assets/AgentName-ChhbnrG9.js +0 -1
- package/dist/web/assets/AgentProfilePage-ZzEtdSKe.js +0 -1
- package/dist/web/assets/AgentServicesPage-B92EXg56.js +0 -1
- package/dist/web/assets/AgentsDirectoryPage-B841hRHZ.js +0 -1
- package/dist/web/assets/BackLink-C0mcoSn4.js +0 -1
- package/dist/web/assets/BoardMoveMenu-CX8jKv0V.js +0 -1
- package/dist/web/assets/CaptureChangePage-B9wtEGy3.js +0 -1
- package/dist/web/assets/Card-BOk3WbC1.js +0 -1
- package/dist/web/assets/CardHeader-79hIs3Wc.js +0 -1
- package/dist/web/assets/CardTitle-CMWcRH62.js +0 -1
- package/dist/web/assets/ConnectionsPage-CCSZ-v6k.js +0 -1
- package/dist/web/assets/CreateProjectDialog-vDAHEZ6t.js +0 -2
- package/dist/web/assets/DataFormatPage-oRc6mBRh.js +0 -2
- package/dist/web/assets/DialogFooter-mK0XBX_L.js +0 -1
- package/dist/web/assets/EmployeeScopeDialog-Bp0zLRG5.js +0 -1
- package/dist/web/assets/EmployeeWorkbenchPage-D34173ED.js +0 -3
- package/dist/web/assets/FieldDescription-C33NBGIe.js +0 -1
- package/dist/web/assets/GrowthLoading-CTsRhLfj.js +0 -1
- package/dist/web/assets/InboxPage-CekhZG9R.js +0 -4
- package/dist/web/assets/Input-jNvD1lEt.js +0 -1
- package/dist/web/assets/KnowledgeHardDeleteSection-OgNe3xoA.js +0 -1
- package/dist/web/assets/KnowledgeItemEditPage-CxUFvj7Q.js +0 -1
- package/dist/web/assets/KnowledgeItemSummaryCard-CkD55bXQ.js +0 -1
- package/dist/web/assets/KnowledgeOrganizerPage-DTfhmq7x.js +0 -1
- package/dist/web/assets/KnowledgePage-D_XPxm7U.js +0 -1
- package/dist/web/assets/KnowledgePeek-fE8eZ9yB.js +0 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-CNoJA8j_.js +0 -1
- package/dist/web/assets/KnowledgeWorkspace-CizF6YnE.js +0 -4
- package/dist/web/assets/Label-BuJcMh9m.js +0 -1
- package/dist/web/assets/ModelSettingsPage-adiuhTSX.js +0 -1
- package/dist/web/assets/NotFoundPage-JAy5KIL8.js +0 -1
- package/dist/web/assets/OccupationsPage-DG0uQx85.js +0 -1
- package/dist/web/assets/OverviewPage-DwCiWNdy.js +0 -2
- package/dist/web/assets/PersonalProfilePage-Cb-AKL4K.js +0 -1
- package/dist/web/assets/PersonalProjectsPage-BT7ebQUu.js +0 -1
- package/dist/web/assets/PopperContent-Dtpk5py4.js +0 -1
- package/dist/web/assets/Presence-9_BFOmAz.js +0 -3
- package/dist/web/assets/ProjectAgentDetailPage-WmxfcCCM.js +0 -8
- package/dist/web/assets/ProjectAgentDialog-BgdFB7il.js +0 -5
- package/dist/web/assets/ProjectAgentFirstTask-BfX-v_g5.js +0 -1
- package/dist/web/assets/ProjectAgentsPage-DAlfUVqM.js +0 -1
- package/dist/web/assets/ProjectAgentsPage-DvJh40Xl.css +0 -1
- package/dist/web/assets/ProjectJudgmentPolicy-DGFTRTvW.js +0 -1
- package/dist/web/assets/ProjectScopePicker-wlhLR465.js +0 -1
- package/dist/web/assets/PublicProjectsPage-LTXsYNme.js +0 -1
- package/dist/web/assets/RadioGroupItem-CUyRbWCt.js +0 -1
- package/dist/web/assets/RoundtablesPage-slbD8isz.js +0 -1
- package/dist/web/assets/RovingFocusGroup-DJ9gp0xI.js +0 -1
- package/dist/web/assets/RovingFocusItem-BGt9xXis.js +0 -1
- package/dist/web/assets/SessionMigrationPage-HxM5zSjY.js +0 -1
- package/dist/web/assets/SessionRecordsPage-CbZ4xiIb.js +0 -1
- package/dist/web/assets/SettingsPage-BSXZinjo.js +0 -1
- package/dist/web/assets/SharedJefaReportPage-4MylH5Ao.js +0 -1
- package/dist/web/assets/TableHeader-aFcD9wsQ.js +0 -1
- package/dist/web/assets/TabsContent-ZCMehxYx.js +0 -1
- package/dist/web/assets/TabsTrigger-BTZQbe9n.js +0 -1
- package/dist/web/assets/TagVocabularyPage-CCm1HBg3.js +0 -1
- package/dist/web/assets/TaskBlockerClear-Dg1T2rcU.js +0 -1
- package/dist/web/assets/TaskBlockerNotice-DVYIiv3y.js +0 -1
- package/dist/web/assets/TaskExecutionPlan-B411P1VJ.js +0 -2
- package/dist/web/assets/TaskExecutionPlan-uimNYWdr.css +0 -1
- package/dist/web/assets/TaskReason-CVnoUuFe.js +0 -1
- package/dist/web/assets/Teleport-Co_blCnp.js +0 -1
- package/dist/web/assets/TextField-BqL6E9zF.js +0 -1
- package/dist/web/assets/Textarea-DIra6o5H.js +0 -1
- package/dist/web/assets/UiChip-FMcrDGe6.js +0 -1
- package/dist/web/assets/UiDialog-CvESkb45.js +0 -1
- package/dist/web/assets/UiDisclosure-D3xZRwVK.js +0 -1
- package/dist/web/assets/UiIcon-CSLaDsID.js +0 -1
- package/dist/web/assets/UiIconButton-C1o6HJ39.js +0 -1
- package/dist/web/assets/UiNotice-CR_4j5lF.js +0 -1
- package/dist/web/assets/UiSegmented-Iu9IH18R.js +0 -1
- package/dist/web/assets/UiSelect-Cs53P6h-.js +0 -1
- package/dist/web/assets/UiToggle-B2sPCVZe.css +0 -1
- package/dist/web/assets/UiToggle-CSb7ErVS.js +0 -1
- package/dist/web/assets/UiWeight-BsbP9h9p.js +0 -1
- package/dist/web/assets/UnassignedConversationsPanel-D2Y2Vs-z.js +0 -1
- package/dist/web/assets/VirtualDirectoryList-DLhTuyoY.js +0 -1
- package/dist/web/assets/VisuallyHiddenInput-DoZPyFZU.js +0 -1
- package/dist/web/assets/Workbench3D-BBEJ0vTb.js +0 -2
- package/dist/web/assets/_plugin-vue_export-helper-DKHjpKWY.js +0 -10
- package/dist/web/assets/accordion-DX4SO0oU.js +0 -1
- package/dist/web/assets/agent-pins-Djo8-s9j.js +0 -1
- package/dist/web/assets/badge-CBT_nrTA.js +0 -1
- package/dist/web/assets/button-BXkZ6rdB.js +0 -1
- package/dist/web/assets/checkbox-BPKmRFwj.js +0 -1
- package/dist/web/assets/console-KIWUM9xy.js +0 -1
- package/dist/web/assets/conversation-launcher-settings-Dfhkli80.js +0 -1
- package/dist/web/assets/dialog-BSKT8LUI.js +0 -1
- package/dist/web/assets/dist-KV3E0kAK.js +0 -1
- package/dist/web/assets/dropdown-menu-BMeAsFQe.js +0 -1
- package/dist/web/assets/field-D_zmve89.js +0 -1
- package/dist/web/assets/index-CyoKfCXy.js +0 -2
- package/dist/web/assets/index-DuLqKIn8.css +0 -1
- package/dist/web/assets/label-table-BAIaH-tx.js +0 -1
- package/dist/web/assets/page-title-B2inyRB1.js +0 -1
- package/dist/web/assets/profile-model-C7xYkCgE.js +0 -1
- package/dist/web/assets/project-team-api-DNSZitOp.js +0 -1
- package/dist/web/assets/select-ByHJaNRv.js +0 -1
- package/dist/web/assets/shared-report-ClDt0UMJ.js +0 -3
- package/dist/web/assets/task-labels-De_F8I3O.js +0 -1
- package/dist/web/assets/ui-CMR2UkVp.js +0 -1
- package/dist/web/assets/useApi-CROJJdhE-lwt7Bu-G.js +0 -1
- package/dist/web/assets/useDirection-DhUUV4Jm.js +0 -1
- package/dist/web/assets/useFocusReturn-ChxuGVqv.js +0 -1
- package/dist/web/assets/useForwardExpose-BRdp7olV.js +0 -1
- package/dist/web/assets/useKnowledgeItemPeek-CRNR9LmU.js +0 -1
- package/dist/web/assets/useMinimumLoadingDisplay-DejHIUi_.js +0 -1
- package/dist/web/assets/useRoutePeek-B5Ukp8vX.js +0 -1
- package/dist/web/assets/utils-BH3OkU12.js +0 -1
- package/dist/web/assets/vue-router-B6l0ZzTV.js +0 -1
- /package/dist/web/assets/{shared-report-CjLAmGZI.css → EmployeeTaskBoard-CjLAmGZI.css} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { activeAgentHostClient } from '../app/agent-request-context.js';
|
|
2
|
+
import { ApplicationError, InvalidInputError } from '../app/application-error.js';
|
|
3
|
+
import { requiredString } from '../validation/values.js';
|
|
4
|
+
|
|
5
|
+
const TOKEN_LIMIT = 256;
|
|
6
|
+
const CANDIDATE_READ_LIMIT = 100;
|
|
7
|
+
|
|
8
|
+
// The Agent side of its workflows (rec#60 D-78). The owner is the Agent the
|
|
9
|
+
// current taskContextToken's task is bound to, never an argument, so an Agent
|
|
10
|
+
// reads and changes only its own workflows. There is no tool that confirms,
|
|
11
|
+
// rejects or retires one: that is the person's, in the console.
|
|
12
|
+
export const AGENT_WORKFLOW_HANDLERS = Object.freeze({
|
|
13
|
+
propose_agent_workflow: async (app, input) => {
|
|
14
|
+
if (input.candidateId && input.steps) throw new InvalidInputError('Pass candidateId or steps, not both');
|
|
15
|
+
const owner = await boundAgent(app, input);
|
|
16
|
+
const steps = input.candidateId ? await candidateSteps(app, owner, input.candidateId) : input.steps;
|
|
17
|
+
return workflows(app).propose(owner, { workflowId: input.workflowId, name: input.name, purpose: input.purpose,
|
|
18
|
+
steps, source: input.candidateId ? `candidate:${input.candidateId}` : 'agent' });
|
|
19
|
+
},
|
|
20
|
+
list_agent_workflows: async (app, input) => workflows(app).index(await boundAgent(app, input)),
|
|
21
|
+
read_agent_workflow: async (app, input) => workflows(app).read(await boundAgent(app, input), input),
|
|
22
|
+
record_agent_workflow_run: async (app, input) => workflows(app).recordRun(await boundAgent(app, input), input)
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function workflows(app) {
|
|
26
|
+
if (!app.agentWorkflows) {
|
|
27
|
+
throw new ApplicationError('agent_workflows_unavailable', 'Agent workflows need a local FULI installation', { status: 503 });
|
|
28
|
+
}
|
|
29
|
+
return app.agentWorkflows;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function boundAgent(app, input) {
|
|
33
|
+
const token = requiredString(input?.taskContextToken, 'taskContextToken', TOKEN_LIMIT);
|
|
34
|
+
const task = await app.taskContextRegistry.context(token, activeAgentHostClient() ?? input.sourceApplication ?? 'other');
|
|
35
|
+
if (!task.projectAgentId) {
|
|
36
|
+
throw new ApplicationError('agent_not_bound', 'Workflows belong to an Agent; this task is not bound to one', { status: 409 });
|
|
37
|
+
}
|
|
38
|
+
return { personalSpaceId: app.config.personal.spaceId, agentId: task.projectAgentId,
|
|
39
|
+
personalProjectId: task.personalProjectId ?? null };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// A learned X-then-Y pattern the Provider has seen often enough across
|
|
43
|
+
// sessions (its own policy decides how often) becomes the proposal's steps.
|
|
44
|
+
async function candidateSteps(app, owner, candidateId) {
|
|
45
|
+
const id = requiredString(candidateId, 'candidateId', 200);
|
|
46
|
+
const page = await app.listWorkflowCandidates({ personalSpaceId: owner.personalSpaceId,
|
|
47
|
+
personalProjectId: owner.personalProjectId, limit: CANDIDATE_READ_LIMIT });
|
|
48
|
+
const candidate = page.candidates.find((item) => item.candidateId === id);
|
|
49
|
+
if (!candidate) {
|
|
50
|
+
throw new ApplicationError('workflow_candidate_not_found', 'No workflow candidate in this scope has this candidateId', { status: 404 });
|
|
51
|
+
}
|
|
52
|
+
const repeated = candidate.occurrenceCount >= page.policy.minimumOccurrences
|
|
53
|
+
&& candidate.distinctSessionCount >= page.policy.minimumDistinctSessions;
|
|
54
|
+
if (!repeated || candidate.status === 'rejected') {
|
|
55
|
+
throw new ApplicationError('workflow_candidate_not_repeated',
|
|
56
|
+
'This candidate was rejected or has not repeated often enough across sessions; propose your own steps instead', { status: 409 });
|
|
57
|
+
}
|
|
58
|
+
return [{ title: candidate.sourceStepName }, { title: candidate.targetStepName }];
|
|
59
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
import { ApplicationError, InvalidInputError } from '../app/application-error.js';
|
|
4
|
+
import { approxTokens } from '../text/token-estimate.js';
|
|
5
|
+
import { positiveInteger, requiredString } from '../validation/values.js';
|
|
6
|
+
import { AgentWorkflowStore } from './store.js';
|
|
7
|
+
|
|
8
|
+
// The workflows port (rec#60 D-78): an Agent's repeated work, grown by the
|
|
9
|
+
// Agent and confirmed by the person.
|
|
10
|
+
// - The bound Agent proposes a workflow, or a change of one, from a learned
|
|
11
|
+
// workflow candidate or its own steps (agent-tools.js). A proposal is a new
|
|
12
|
+
// version that waits; it never becomes active by itself.
|
|
13
|
+
// - Only the person confirms, rejects or retires, in the local console, at the
|
|
14
|
+
// version the page showed. A confirmed version is the active one; rejecting a
|
|
15
|
+
// change of an active workflow keeps the active version, rejecting a new
|
|
16
|
+
// proposal retires it. A retired workflow proposed again waits once more.
|
|
17
|
+
// - The Agent reads an index first and the active version's steps on demand;
|
|
18
|
+
// nothing is put into a context and nothing runs by itself. A run the Agent
|
|
19
|
+
// did is recorded against the active version.
|
|
20
|
+
const LIMITS = Object.freeze({ id: 200, name: 80, purpose: 300, title: 120, detail: 600, note: 500 });
|
|
21
|
+
const MAX_STEPS = 20;
|
|
22
|
+
// Proposed and active workflows one Agent keeps; retired ones do not count.
|
|
23
|
+
const MAX_OPEN_WORKFLOWS = 50;
|
|
24
|
+
const RECENT_RUNS = 5;
|
|
25
|
+
const OUTCOMES = new Set(['done', 'stopped', 'failed']);
|
|
26
|
+
const DECISIONS = new Set(['confirm', 'reject', 'retire']);
|
|
27
|
+
|
|
28
|
+
export function createAgentWorkflows({ path = ':memory:', now = () => new Date(),
|
|
29
|
+
newId = () => `workflow-${randomUUID()}`, newRunId = () => `run-${randomUUID()}` } = {}) {
|
|
30
|
+
const store = new AgentWorkflowStore(path);
|
|
31
|
+
const at = () => now().toISOString();
|
|
32
|
+
|
|
33
|
+
// An unknown workflow and another Agent's look the same to the caller.
|
|
34
|
+
function owned(owner, workflowId) {
|
|
35
|
+
const workflow = store.get(requiredString(workflowId, 'workflowId', LIMITS.id));
|
|
36
|
+
if (!workflow || workflow.personalSpaceId !== owner.personalSpaceId || workflow.agentId !== owner.agentId) {
|
|
37
|
+
throw new ApplicationError('workflow_not_found', 'This Agent has no workflow with this workflowId', { status: 404 });
|
|
38
|
+
}
|
|
39
|
+
return workflow;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function propose(owner, input) {
|
|
43
|
+
const proposal = proposalFields(input);
|
|
44
|
+
return store.transaction(() => {
|
|
45
|
+
// One workflow per learned candidate: proposing it again proposes a change of that one.
|
|
46
|
+
const existing = input.workflowId ? owned(owner, input.workflowId) : proposal.source.startsWith('candidate:')
|
|
47
|
+
? store.fromSource(owner.personalSpaceId, owner.agentId, proposal.source) : null;
|
|
48
|
+
const time = at();
|
|
49
|
+
if (existing) {
|
|
50
|
+
const latest = store.version(existing.workflowId, existing.latestVersion);
|
|
51
|
+
const waiting = existing.pendingVersion === latest.version || existing.activeVersion === latest.version;
|
|
52
|
+
if (waiting && existing.status !== 'retired' && sameContent(latest, proposal)) {
|
|
53
|
+
return { status: 'unchanged', workflow: indexEntry(existing) };
|
|
54
|
+
}
|
|
55
|
+
const version = existing.latestVersion + 1;
|
|
56
|
+
store.addVersion({ workflowId: existing.workflowId, version, ...proposal, createdBy: 'agent', createdAt: time });
|
|
57
|
+
const next = { ...existing, status: existing.status === 'active' ? 'active' : 'proposed', latestVersion: version,
|
|
58
|
+
pendingVersion: version, updatedAt: time };
|
|
59
|
+
store.save(next);
|
|
60
|
+
return { status: 'proposed', workflow: indexEntry(next) };
|
|
61
|
+
}
|
|
62
|
+
const open = store.listForAgent(owner.personalSpaceId, owner.agentId).filter(({ status }) => status !== 'retired');
|
|
63
|
+
if (open.length >= MAX_OPEN_WORKFLOWS) {
|
|
64
|
+
throw new ApplicationError('workflow_limit', `An Agent keeps at most ${MAX_OPEN_WORKFLOWS} proposed or active workflows; change one instead`, { status: 409 });
|
|
65
|
+
}
|
|
66
|
+
const workflow = { workflowId: newId(), personalSpaceId: owner.personalSpaceId, agentId: owner.agentId,
|
|
67
|
+
personalProjectId: owner.personalProjectId ?? null, status: 'proposed', latestVersion: 1, activeVersion: null,
|
|
68
|
+
pendingVersion: 1, createdAt: time, updatedAt: time };
|
|
69
|
+
store.save(workflow);
|
|
70
|
+
store.addVersion({ workflowId: workflow.workflowId, version: 1, ...proposal, createdBy: 'agent', createdAt: time });
|
|
71
|
+
return { status: 'proposed', workflow: indexEntry(workflow) };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// What the Agent chooses from: no steps, only what a read would cost.
|
|
76
|
+
function index(owner) {
|
|
77
|
+
return { workflows: store.listForAgent(owner.personalSpaceId, owner.agentId)
|
|
78
|
+
.filter(({ status }) => status !== 'retired').map(indexEntry) };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function indexEntry(workflow) {
|
|
82
|
+
const shown = store.version(workflow.workflowId, workflow.activeVersion ?? workflow.pendingVersion ?? workflow.latestVersion);
|
|
83
|
+
const [lastRun] = store.runs(workflow.workflowId, 1);
|
|
84
|
+
return { workflowId: workflow.workflowId, name: shown.name, purpose: shown.purpose, status: workflow.status,
|
|
85
|
+
stepCount: shown.steps.length, approxTokens: approxTokens(JSON.stringify(readable(shown))),
|
|
86
|
+
...(workflow.pendingVersion ? { awaitingPerson: true } : {}),
|
|
87
|
+
lastRun: lastRun ? { recordedAt: lastRun.recordedAt, outcome: lastRun.outcome } : null };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function read(owner, { workflowId }) {
|
|
91
|
+
const workflow = owned(owner, workflowId);
|
|
92
|
+
if (workflow.status !== 'active') throw notActive();
|
|
93
|
+
const active = store.version(workflow.workflowId, workflow.activeVersion);
|
|
94
|
+
return { workflowId: workflow.workflowId, version: active.version, ...readable(active) };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function recordRun(owner, input) {
|
|
98
|
+
const workflow = owned(owner, input?.workflowId);
|
|
99
|
+
if (workflow.status !== 'active') throw notActive();
|
|
100
|
+
if (!OUTCOMES.has(input.outcome)) throw new InvalidInputError('outcome must be done, stopped or failed');
|
|
101
|
+
const run = { runId: newRunId(), workflowId: workflow.workflowId, version: workflow.activeVersion,
|
|
102
|
+
taskId: optionalText(input.taskId, 'taskId', LIMITS.id), outcome: input.outcome,
|
|
103
|
+
note: optionalText(input.note, 'note', LIMITS.note), recordedAt: at() };
|
|
104
|
+
store.transaction(() => store.addRun(run));
|
|
105
|
+
return { status: 'recorded', run };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// The console's view of one Agent's workflows: every state, with the steps
|
|
109
|
+
// of the active version and of the one waiting for the person.
|
|
110
|
+
function overview({ personalSpaceId, agentId }) {
|
|
111
|
+
return { workflows: store.listForAgent(personalSpaceId, agentId).map((workflow) => ({
|
|
112
|
+
workflowId: workflow.workflowId, status: workflow.status, personalProjectId: workflow.personalProjectId,
|
|
113
|
+
versionCount: workflow.latestVersion, active: store.version(workflow.workflowId, workflow.activeVersion),
|
|
114
|
+
pending: store.version(workflow.workflowId, workflow.pendingVersion),
|
|
115
|
+
recentRuns: store.runs(workflow.workflowId, RECENT_RUNS), createdAt: workflow.createdAt,
|
|
116
|
+
updatedAt: workflow.updatedAt })) };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// The person's answer to the version the console showed: confirm or reject
|
|
120
|
+
// the one waiting, or retire the active one. A version that is no longer the
|
|
121
|
+
// one in question is refused with 409, so the page reads again.
|
|
122
|
+
function decide({ personalSpaceId, workflowId, decision, version }) {
|
|
123
|
+
if (!DECISIONS.has(decision)) throw new InvalidInputError('decision must be confirm, reject or retire');
|
|
124
|
+
const shown = positiveInteger(version, 'version', Number.MAX_SAFE_INTEGER);
|
|
125
|
+
return store.transaction(() => {
|
|
126
|
+
const workflow = store.get(requiredString(workflowId, 'workflowId', LIMITS.id));
|
|
127
|
+
if (!workflow || workflow.personalSpaceId !== personalSpaceId) {
|
|
128
|
+
throw new ApplicationError('workflow_not_found', 'No workflow has this workflowId', { status: 404 });
|
|
129
|
+
}
|
|
130
|
+
const current = decision === 'retire' ? (workflow.status === 'active' ? workflow.activeVersion : null)
|
|
131
|
+
: workflow.pendingVersion;
|
|
132
|
+
if (current !== shown) {
|
|
133
|
+
throw new ApplicationError('version_conflict', 'The workflow changed since it was shown; read it again', { status: 409 });
|
|
134
|
+
}
|
|
135
|
+
const time = at();
|
|
136
|
+
store.addDecision({ workflowId: workflow.workflowId, version: shown, decision, decidedAt: time });
|
|
137
|
+
// A retired workflow has no active version; its decisions keep which one was.
|
|
138
|
+
const retiring = decision === 'retire' || (decision === 'reject' && workflow.status !== 'active');
|
|
139
|
+
const next = { ...workflow, pendingVersion: null, updatedAt: time,
|
|
140
|
+
...(decision === 'confirm' ? { status: 'active', activeVersion: shown } : {}),
|
|
141
|
+
...(retiring ? { status: 'retired', activeVersion: null } : {}) };
|
|
142
|
+
store.save(next);
|
|
143
|
+
return { status: decision === 'confirm' ? 'confirmed' : decision === 'reject' ? 'rejected' : 'retired',
|
|
144
|
+
workflow: { workflowId: next.workflowId, status: next.status, activeVersion: next.activeVersion } };
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return { propose, index, read, recordRun, overview, decide, close: () => store.close() };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function proposalFields(input) {
|
|
152
|
+
const source = requiredString(input?.source, 'source', LIMITS.id + 20);
|
|
153
|
+
const steps = input.steps;
|
|
154
|
+
if (!Array.isArray(steps) || !steps.length || steps.length > MAX_STEPS) {
|
|
155
|
+
throw new InvalidInputError(`steps must list 1 to ${MAX_STEPS} steps`);
|
|
156
|
+
}
|
|
157
|
+
return { name: requiredString(input.name, 'name', LIMITS.name), purpose: requiredString(input.purpose, 'purpose', LIMITS.purpose),
|
|
158
|
+
source, steps: steps.map((step, index) => {
|
|
159
|
+
const detail = optionalText(step?.detail, `steps[${index}].detail`, LIMITS.detail);
|
|
160
|
+
return { title: requiredString(step?.title, `steps[${index}].title`, LIMITS.title), ...(detail ? { detail } : {}) };
|
|
161
|
+
}) };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function readable(version) {
|
|
165
|
+
return { name: version.name, purpose: version.purpose, steps: version.steps };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function sameContent(version, proposal) {
|
|
169
|
+
return JSON.stringify(readable(version)) === JSON.stringify(readable(proposal));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function optionalText(value, label, maximum) {
|
|
173
|
+
return value === undefined || value === null ? null : requiredString(value, label, maximum);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function notActive() {
|
|
177
|
+
return new ApplicationError('workflow_not_active',
|
|
178
|
+
'Only an active workflow is read or run; the person confirms a proposal in the FULI console', { status: 409 });
|
|
179
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
import { openFormattedDatabase, sqliteFormat } from '../../packages/roundtable/src/storage/database-format.js';
|
|
4
|
+
|
|
5
|
+
// An Agent's own workflows (rec#60 D-78): the repeated work it does, as named
|
|
6
|
+
// ordered steps. agent_workflows holds each workflow's current state: which
|
|
7
|
+
// version is active (the person confirmed it) and which one waits for the
|
|
8
|
+
// person's answer. Every change is a new row in agent_workflow_versions, its
|
|
9
|
+
// first proposal included; versions, the person's decisions and recorded runs
|
|
10
|
+
// are immutable (triggers refuse UPDATE and DELETE), so a workflow can always
|
|
11
|
+
// be read back to what was proposed, by whom, and what the person decided.
|
|
12
|
+
// A retired workflow keeps every row; nothing is ever deleted.
|
|
13
|
+
export const AGENT_WORKFLOWS_FORMAT = sqliteFormat({
|
|
14
|
+
store: 'agent-workflows',
|
|
15
|
+
schema: `
|
|
16
|
+
CREATE TABLE IF NOT EXISTS agent_workflows(
|
|
17
|
+
workflow_id TEXT PRIMARY KEY, personal_space_id TEXT NOT NULL, agent_id TEXT NOT NULL, personal_project_id TEXT,
|
|
18
|
+
status TEXT NOT NULL CHECK(status IN ('proposed', 'active', 'retired')),
|
|
19
|
+
latest_version INTEGER NOT NULL, active_version INTEGER, pending_version INTEGER,
|
|
20
|
+
created_at TEXT NOT NULL, updated_at TEXT NOT NULL);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS agent_workflows_owner ON agent_workflows(personal_space_id, agent_id);
|
|
22
|
+
CREATE TABLE IF NOT EXISTS agent_workflow_versions(
|
|
23
|
+
workflow_id TEXT NOT NULL REFERENCES agent_workflows(workflow_id), version INTEGER NOT NULL,
|
|
24
|
+
name TEXT NOT NULL, purpose TEXT NOT NULL, steps TEXT NOT NULL, source TEXT NOT NULL,
|
|
25
|
+
created_by TEXT NOT NULL CHECK(created_by IN ('agent', 'person')), created_at TEXT NOT NULL,
|
|
26
|
+
PRIMARY KEY(workflow_id, version));
|
|
27
|
+
CREATE TABLE IF NOT EXISTS agent_workflow_decisions(
|
|
28
|
+
workflow_id TEXT NOT NULL REFERENCES agent_workflows(workflow_id), version INTEGER NOT NULL,
|
|
29
|
+
decision TEXT NOT NULL CHECK(decision IN ('confirm', 'reject', 'retire')),
|
|
30
|
+
decided_by TEXT NOT NULL CHECK(decided_by IN ('person')), decided_at TEXT NOT NULL);
|
|
31
|
+
CREATE INDEX IF NOT EXISTS agent_workflow_decisions_workflow ON agent_workflow_decisions(workflow_id);
|
|
32
|
+
CREATE TABLE IF NOT EXISTS agent_workflow_runs(
|
|
33
|
+
run_id TEXT PRIMARY KEY, workflow_id TEXT NOT NULL REFERENCES agent_workflows(workflow_id),
|
|
34
|
+
version INTEGER NOT NULL, task_id TEXT,
|
|
35
|
+
outcome TEXT NOT NULL CHECK(outcome IN ('done', 'stopped', 'failed')), note TEXT, recorded_at TEXT NOT NULL);
|
|
36
|
+
CREATE INDEX IF NOT EXISTS agent_workflow_runs_workflow ON agent_workflow_runs(workflow_id, recorded_at);
|
|
37
|
+
CREATE TRIGGER IF NOT EXISTS agent_workflow_versions_no_update BEFORE UPDATE ON agent_workflow_versions
|
|
38
|
+
BEGIN SELECT RAISE(ABORT, 'agent workflow versions are immutable'); END;
|
|
39
|
+
CREATE TRIGGER IF NOT EXISTS agent_workflow_versions_no_delete BEFORE DELETE ON agent_workflow_versions
|
|
40
|
+
BEGIN SELECT RAISE(ABORT, 'agent workflow versions are immutable'); END;
|
|
41
|
+
CREATE TRIGGER IF NOT EXISTS agent_workflow_decisions_no_update BEFORE UPDATE ON agent_workflow_decisions
|
|
42
|
+
BEGIN SELECT RAISE(ABORT, 'agent workflow decisions are immutable'); END;
|
|
43
|
+
CREATE TRIGGER IF NOT EXISTS agent_workflow_decisions_no_delete BEFORE DELETE ON agent_workflow_decisions
|
|
44
|
+
BEGIN SELECT RAISE(ABORT, 'agent workflow decisions are immutable'); END;
|
|
45
|
+
CREATE TRIGGER IF NOT EXISTS agent_workflow_runs_no_update BEFORE UPDATE ON agent_workflow_runs
|
|
46
|
+
BEGIN SELECT RAISE(ABORT, 'agent workflow runs are immutable'); END;
|
|
47
|
+
CREATE TRIGGER IF NOT EXISTS agent_workflow_runs_no_delete BEFORE DELETE ON agent_workflow_runs
|
|
48
|
+
BEGIN SELECT RAISE(ABORT, 'agent workflow runs are immutable'); END;`
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export class AgentWorkflowStore {
|
|
52
|
+
constructor(path = ':memory:') {
|
|
53
|
+
this.path = path;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Opened on the first write; a missing file reads as no workflows and is never created by a read.
|
|
57
|
+
get db() {
|
|
58
|
+
this.database ??= openFormattedDatabase(this.path, AGENT_WORKFLOWS_FORMAT);
|
|
59
|
+
return this.database;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get readable() {
|
|
63
|
+
return Boolean(this.database) || this.path === ':memory:' || existsSync(this.path);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
transaction(work) {
|
|
67
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
68
|
+
try { const result = work(); this.db.exec('COMMIT'); return result; }
|
|
69
|
+
catch (error) { this.db.exec('ROLLBACK'); throw error; }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get(workflowId) {
|
|
73
|
+
if (!this.readable) return null;
|
|
74
|
+
return workflowView(this.db.prepare('SELECT * FROM agent_workflows WHERE workflow_id = ?').get(workflowId));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
listForAgent(personalSpaceId, agentId) {
|
|
78
|
+
if (!this.readable) return [];
|
|
79
|
+
return this.db.prepare(`SELECT * FROM agent_workflows WHERE personal_space_id = ? AND agent_id = ?
|
|
80
|
+
ORDER BY created_at, workflow_id`).all(personalSpaceId, agentId).map(workflowView);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The Agent's workflow a candidate was first proposed from, if any.
|
|
84
|
+
fromSource(personalSpaceId, agentId, source) {
|
|
85
|
+
if (!this.readable) return null;
|
|
86
|
+
return workflowView(this.db.prepare(`SELECT w.* FROM agent_workflows w JOIN agent_workflow_versions v
|
|
87
|
+
ON v.workflow_id = w.workflow_id WHERE w.personal_space_id = ? AND w.agent_id = ? AND v.source = ?
|
|
88
|
+
ORDER BY v.created_at LIMIT 1`).get(personalSpaceId, agentId, source));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
version(workflowId, version) {
|
|
92
|
+
if (!this.readable || !version) return null;
|
|
93
|
+
return versionView(this.db.prepare('SELECT * FROM agent_workflow_versions WHERE workflow_id = ? AND version = ?')
|
|
94
|
+
.get(workflowId, version));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// The newest runs first.
|
|
98
|
+
runs(workflowId, limit) {
|
|
99
|
+
if (!this.readable) return [];
|
|
100
|
+
return this.db.prepare(`SELECT * FROM agent_workflow_runs WHERE workflow_id = ?
|
|
101
|
+
ORDER BY recorded_at DESC, rowid DESC LIMIT ?`).all(workflowId, limit).map(runView);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Writes a workflow's new current state, inside the caller's transaction.
|
|
105
|
+
save(workflow) {
|
|
106
|
+
this.db.prepare(`INSERT INTO agent_workflows VALUES(:workflow_id, :personal_space_id, :agent_id,
|
|
107
|
+
:personal_project_id, :status, :latest_version, :active_version, :pending_version, :created_at, :updated_at)
|
|
108
|
+
ON CONFLICT(workflow_id) DO UPDATE SET status = excluded.status, latest_version = excluded.latest_version,
|
|
109
|
+
active_version = excluded.active_version, pending_version = excluded.pending_version,
|
|
110
|
+
updated_at = excluded.updated_at`).run({
|
|
111
|
+
workflow_id: workflow.workflowId, personal_space_id: workflow.personalSpaceId, agent_id: workflow.agentId,
|
|
112
|
+
personal_project_id: workflow.personalProjectId, status: workflow.status,
|
|
113
|
+
latest_version: workflow.latestVersion, active_version: workflow.activeVersion,
|
|
114
|
+
pending_version: workflow.pendingVersion, created_at: workflow.createdAt, updated_at: workflow.updatedAt });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
addVersion(record) {
|
|
118
|
+
this.db.prepare('INSERT INTO agent_workflow_versions VALUES(?, ?, ?, ?, ?, ?, ?, ?)').run(record.workflowId,
|
|
119
|
+
record.version, record.name, record.purpose, JSON.stringify(record.steps), record.source, record.createdBy,
|
|
120
|
+
record.createdAt);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
addDecision({ workflowId, version, decision, decidedAt }) {
|
|
124
|
+
this.db.prepare('INSERT INTO agent_workflow_decisions VALUES(?, ?, ?, ?, ?)')
|
|
125
|
+
.run(workflowId, version, decision, 'person', decidedAt);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
addRun(run) {
|
|
129
|
+
this.db.prepare('INSERT INTO agent_workflow_runs VALUES(?, ?, ?, ?, ?, ?, ?)').run(run.runId, run.workflowId,
|
|
130
|
+
run.version, run.taskId, run.outcome, run.note, run.recordedAt);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
close() {
|
|
134
|
+
this.database?.close();
|
|
135
|
+
this.database = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function workflowView(row) {
|
|
140
|
+
if (!row) return null;
|
|
141
|
+
return { workflowId: row.workflow_id, personalSpaceId: row.personal_space_id, agentId: row.agent_id,
|
|
142
|
+
personalProjectId: row.personal_project_id, status: row.status, latestVersion: row.latest_version,
|
|
143
|
+
activeVersion: row.active_version, pendingVersion: row.pending_version, createdAt: row.created_at,
|
|
144
|
+
updatedAt: row.updated_at };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function versionView(row) {
|
|
148
|
+
if (!row) return null;
|
|
149
|
+
return { workflowId: row.workflow_id, version: row.version, name: row.name, purpose: row.purpose,
|
|
150
|
+
steps: JSON.parse(row.steps), source: row.source, createdBy: row.created_by, createdAt: row.created_at };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function runView(row) {
|
|
154
|
+
return { runId: row.run_id, workflowId: row.workflow_id, version: row.version, taskId: row.task_id,
|
|
155
|
+
outcome: row.outcome, note: row.note, recordedAt: row.recorded_at };
|
|
156
|
+
}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
export function normalizeClaudeRecord(record, sessionId) {
|
|
3
3
|
if (record?.sessionId !== sessionId || !['user', 'assistant'].includes(record.type)) return [];
|
|
4
4
|
const content = record.message?.content;
|
|
5
|
+
// The summary Claude Code writes after compacting is stored as a user
|
|
6
|
+
// record; it is the host's own words, never something the user said.
|
|
7
|
+
if (record.isCompactSummary === true) return compactionSummary(content);
|
|
5
8
|
if (typeof content === 'string') return content ? [{ role: record.type, kind: 'message', content }] : [];
|
|
6
9
|
if (!Array.isArray(content)) return [];
|
|
7
10
|
return content.flatMap(block => {
|
|
@@ -15,6 +18,11 @@ export function normalizeClaudeRecord(record, sessionId) {
|
|
|
15
18
|
return [];
|
|
16
19
|
});
|
|
17
20
|
}
|
|
21
|
+
function compactionSummary(content) {
|
|
22
|
+
const text = typeof content === 'string' ? content
|
|
23
|
+
: Array.isArray(content) ? content.filter(block => block.type === 'text').map(block => block.text ?? '').join('\n') : '';
|
|
24
|
+
return text ? [{ role: 'summary', kind: 'compaction_summary', content: text }] : [];
|
|
25
|
+
}
|
|
18
26
|
export function verifyClaudeTranscript(firstRecord, sessionId) {
|
|
19
27
|
return firstRecord?.sessionId === sessionId;
|
|
20
28
|
}
|
|
@@ -14,6 +14,7 @@ import { endTurnsObservedAtEntry, refreshCurrentTaskInPlace, settleHeldTurns, ST
|
|
|
14
14
|
import { transcriptCaptureLedger } from '../../conversations/transcript-capture-gap.js';
|
|
15
15
|
import { transcriptDigest } from '../../conversations/transcript-guard.js';
|
|
16
16
|
import { normalizeClaudeRecord, verifyClaudeTranscript } from './conversation-transcript.js';
|
|
17
|
+
import { recordClaudeSessionClient } from './session-client.js';
|
|
17
18
|
import { sessionFuliCommandResult, sessionFuliEntryRefusal, sessionFuliOffContext, sessionFuliSessionBegan }
|
|
18
19
|
from '../../conversations/session-fuli-entry.js';
|
|
19
20
|
|
|
@@ -137,6 +138,14 @@ export async function runClaudeLifecycleHook(args, dependencies = {}) {
|
|
|
137
138
|
);
|
|
138
139
|
const ledger = runtimeConfigPath && typeof input?.session_id === 'string' && input.session_id.trim()
|
|
139
140
|
? transcriptCaptureLedger(runtimeConfigPath, input, 'claude_code') : null;
|
|
141
|
+
// How this session was started (Claude Desktop or the CLI), once per
|
|
142
|
+
// session and without starting any process. It never decides this turn's
|
|
143
|
+
// answer, so a failure is only skipped.
|
|
144
|
+
if (ledger) {
|
|
145
|
+
try {
|
|
146
|
+
recordClaudeSessionClient({ runtimeConfigPath, sessionId: input.session_id, env: dependencies.env ?? process.env });
|
|
147
|
+
} catch { /* the console classifies the session from its source application */ }
|
|
148
|
+
}
|
|
140
149
|
// Noted before the entry runs, so an answer at the deadline carries it too.
|
|
141
150
|
const notice = noteEntryNotice(() => outdatedMcpNotice(runtimeConfigPath,
|
|
142
151
|
{ sourceApplication: 'claude_code', version: FULI_VERSION, sessionId: input?.session_id }));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { sessionClientRecords } from '../../agent-kits/session-clients.js';
|
|
4
|
+
|
|
5
|
+
// Claude Code tells its hooks how it was started in CLAUDE_CODE_ENTRYPOINT:
|
|
6
|
+
// `cli` in a terminal, `claude-desktop` in Claude Desktop's Code tab, others
|
|
7
|
+
// for the IDE extensions and SDKs. It is not secret. Without it Claude
|
|
8
|
+
// Desktop and the CLI look the same to FULI (rec#11 D-79).
|
|
9
|
+
const ENTRYPOINT = 'CLAUDE_CODE_ENTRYPOINT';
|
|
10
|
+
|
|
11
|
+
// The source label and entry point the session launcher classifies later. The
|
|
12
|
+
// launcher refines a Claude source only to Claude Desktop, so a terminal
|
|
13
|
+
// session is named for what it is; any other entry point stays the ambiguous
|
|
14
|
+
// "Claude Code" (no guess between IDE, SDK and CLI).
|
|
15
|
+
function claudeSessionSource(env) {
|
|
16
|
+
const entrypoint = typeof env[ENTRYPOINT] === 'string' && env[ENTRYPOINT].trim() ? env[ENTRYPOINT].trim() : null;
|
|
17
|
+
return { source: entrypoint === 'cli' ? 'Claude Code CLI' : 'Claude Code', entrypoint };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Records once per session how the session was started: a file read and at
|
|
21
|
+
// most one small write, never a process or a wait on the prompt path. The
|
|
22
|
+
// console classifies the client when it needs it (session-offers.js) and
|
|
23
|
+
// keeps the answer in the same record. runtimeConfigPath sits in the data
|
|
24
|
+
// directory.
|
|
25
|
+
export function recordClaudeSessionClient({ runtimeConfigPath, sessionId, env = process.env }) {
|
|
26
|
+
const records = sessionClientRecords(dirname(runtimeConfigPath));
|
|
27
|
+
if (records.read('claude_code', sessionId)) return;
|
|
28
|
+
records.record('claude_code', sessionId, claudeSessionSource(env));
|
|
29
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// Codex rollout v1: visible response items only; event_msg mirrors are omitted.
|
|
2
2
|
export function normalizeCodexRecord(record) {
|
|
3
|
+
// A locally written compaction summary; remote compaction leaves the message
|
|
4
|
+
// empty and keeps only an encrypted item, which is never stored.
|
|
5
|
+
if (record?.type === 'compacted') {
|
|
6
|
+
const message = record.payload?.message;
|
|
7
|
+
return typeof message === 'string' && message.trim() ? [{ role: 'summary', kind: 'compaction_summary', content: message }] : [];
|
|
8
|
+
}
|
|
3
9
|
if (record?.type !== 'response_item') return [];
|
|
4
10
|
const item = record.payload;
|
|
5
11
|
if (item?.type === 'message' && ['user', 'assistant'].includes(item.role)) {
|
|
@@ -154,6 +154,7 @@ function unassignedReceipt(status, reason) {
|
|
|
154
154
|
: 'FULI Agent:分配失败(项目归属未能恢复)';
|
|
155
155
|
}
|
|
156
156
|
if (reason === 'assistant_unavailable') return 'FULI Agent:待归属会话(助理尚未就绪)';
|
|
157
|
+
if (status === 'agent_unavailable' && reason === 'not_responsible') return 'FULI Agent:分配失败(指定 Agent 未负责此项目)';
|
|
157
158
|
const labels = {
|
|
158
159
|
unavailable: '分配失败(服务或身份恢复不可用)',
|
|
159
160
|
agent_unavailable: '分配失败(指定 FLA 不可用)',
|
|
@@ -10,6 +10,7 @@ import { ADAPTIVE_RUNTIME_SETTINGS_FORMAT } from '../adaptive-runtime/settings.j
|
|
|
10
10
|
import { ADAPTIVE_RUNTIME_STATE_FORMAT } from '../adaptive-runtime/state.js';
|
|
11
11
|
import { AGENT_APP_FORMAT } from '../agent-apps/store.js';
|
|
12
12
|
import { AGENT_SERVICES_FORMAT } from '../agent-services/store.js';
|
|
13
|
+
import { AGENT_WORKFLOWS_FORMAT } from '../agent-workflows/store.js';
|
|
13
14
|
import { EMPLOYEE_MANAGEMENT_FORMAT } from '../employees/management-policy.js';
|
|
14
15
|
import { JEFA_BOARD_FORMAT } from '../employees/builtin/jefa/board-store.js';
|
|
15
16
|
import { PREFERENCE_SESSION_FORMAT } from '../conversations/preference-session.js';
|
|
@@ -41,6 +42,7 @@ import { STANDING_ASSIGNMENTS_FORMAT } from '../standing-assignments/store.js';
|
|
|
41
42
|
import { CLIENT_CONNECTION_HISTORY_FORMAT } from '../system/client-connection-status.js';
|
|
42
43
|
import { RUNTIME_SETTINGS_FORMAT } from '../system/runtime-settings.js';
|
|
43
44
|
import { CLIENT_LINKS_STATE_FORMAT } from '../client-links/registry.js';
|
|
45
|
+
import { SESSION_CLIENT_FORMAT } from '../agent-kits/session-clients.js';
|
|
44
46
|
|
|
45
47
|
// Every FULI store kept in one data directory, by the path its owner opens
|
|
46
48
|
// (rec#17 D-09). Labels are relative to the data directory, so a report names
|
|
@@ -62,6 +64,8 @@ const sqliteStores = () => [
|
|
|
62
64
|
['agent-apps/registry.sqlite', AGENT_APP_FORMAT],
|
|
63
65
|
// The services FULI Agents started and their logs (rec#11 D-71); absent until the first one.
|
|
64
66
|
['agent-services.sqlite', AGENT_SERVICES_FORMAT],
|
|
67
|
+
// Each Agent's own workflows, their versions, the person's decisions and runs (rec#60 D-78).
|
|
68
|
+
['agent-workflows.sqlite', AGENT_WORKFLOWS_FORMAT],
|
|
65
69
|
['employees/data/management.sqlite', EMPLOYEE_MANAGEMENT_FORMAT],
|
|
66
70
|
// Jefa's built-in task board: tasks, their revisions, sharing and session titles.
|
|
67
71
|
['employees/data/jefa/board.sqlite', JEFA_BOARD_FORMAT],
|
|
@@ -109,7 +113,9 @@ const jsonDirectories = () => [
|
|
|
109
113
|
['capture-session-pause', CAPTURE_SESSION_PAUSE_FORMAT],
|
|
110
114
|
// The default each session started under (rec#5 C3b), one record per session.
|
|
111
115
|
['capture-session-pause/pins/on', CAPTURE_SESSION_PAUSE_FORMAT],
|
|
112
|
-
['capture-session-pause/pins/off', CAPTURE_SESSION_PAUSE_FORMAT]
|
|
116
|
+
['capture-session-pause/pins/off', CAPTURE_SESSION_PAUSE_FORMAT],
|
|
117
|
+
// Which client each session ran in, as the session launcher classified it (rec#11 D-79).
|
|
118
|
+
['session-clients', SESSION_CLIENT_FORMAT]
|
|
113
119
|
];
|
|
114
120
|
// The worst state of a directory's records names the directory's state.
|
|
115
121
|
const STATE_ORDER = ['unavailable', 'newer_format', 'half_applied', 'pending_confirmation', 'unsupported',
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { execFile, spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { readJsonFile } from '../storage/json-file.js';
|
|
6
|
+
import { windowsInstallPathsOverlap } from './windows-installation-context.js';
|
|
7
|
+
import { requestWindowsTrayExit } from './windows-update-lock.js';
|
|
8
|
+
|
|
9
|
+
// The FULI desktop client (desktop/flutter, client\FULI.exe started by the
|
|
10
|
+
// package root's Fuli.exe) as updates, rollbacks and uninstalls see it: closed
|
|
11
|
+
// before the program changes, opened again afterwards, and its per-user
|
|
12
|
+
// Windows entries kept pointing at the installed version. The client writes
|
|
13
|
+
// the same entries itself (desktop/flutter/lib/src/platform/desktop/windows_login_launch.dart).
|
|
14
|
+
|
|
15
|
+
const RUN_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
|
|
16
|
+
const RUN_VALUE = 'FULI';
|
|
17
|
+
// The client's own settings (the launch-at-login choice) and its notification identity.
|
|
18
|
+
const CLIENT_KEYS = ['HKCU\\Software\\Fuli\\DesktopClient', 'HKCU\\Software\\Classes\\AppUserModelId\\FULI'];
|
|
19
|
+
// A client in the middle of a start, stop or port change finishes it first
|
|
20
|
+
// (each CLI call is bounded to five minutes by windows-controller.js).
|
|
21
|
+
const CLIENT_EXIT_TIMEOUT_MS = 330_000;
|
|
22
|
+
|
|
23
|
+
const windowsLoginCommand = packageRoot => `"${join(packageRoot, 'Fuli.exe')}" --background`;
|
|
24
|
+
|
|
25
|
+
// Asks a running client of this data directory to exit and waits for it.
|
|
26
|
+
// Resolves 'exited' or 'absent'; a client that stays refuses the change.
|
|
27
|
+
async function closeWindowsDesktopClient(dataDir, { exitTray = requestWindowsTrayExit } = {}) {
|
|
28
|
+
const state = await exitTray(dataDir, { timeoutMs: CLIENT_EXIT_TIMEOUT_MS });
|
|
29
|
+
if (state === 'busy') throw new Error('The FULI desktop client did not close; nothing was changed. Finish or close what it is doing and try again.');
|
|
30
|
+
return state;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Opens the client of whichever version installation.json names now.
|
|
34
|
+
function reopenInstalledWindowsClient(installRoot, { launch = launchWindowsDesktopClient } = {}) {
|
|
35
|
+
const record = readJsonFile(join(installRoot, 'installation.json'), null);
|
|
36
|
+
if (record?.packageRoot) launch(record.packageRoot);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function launchWindowsDesktopClient(packageRoot) {
|
|
40
|
+
const launcher = join(packageRoot, 'Fuli.exe');
|
|
41
|
+
if (!existsSync(launcher)) return;
|
|
42
|
+
const child = spawn(launcher, [], { cwd: packageRoot, detached: true, stdio: 'ignore' });
|
|
43
|
+
child.once('error', () => {});
|
|
44
|
+
child.unref();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// After a switch, an existing launch-at-login entry of this installation
|
|
48
|
+
// starts the installed version. A version without the desktop client (an
|
|
49
|
+
// older tray) takes no arguments, so the entry is removed instead. Never
|
|
50
|
+
// fails the switch: 'unchanged', 'retargeted', 'removed' or 'failed'.
|
|
51
|
+
async function retargetWindowsLoginLaunch(installRoot, packageRoot, { reg = runReg } = {}) {
|
|
52
|
+
try {
|
|
53
|
+
const command = await readLoginLaunch(reg);
|
|
54
|
+
if (!command || !launchesFrom(command, installRoot)) return 'unchanged';
|
|
55
|
+
if (existsSync(join(packageRoot, 'client', 'FULI.exe'))) {
|
|
56
|
+
const next = windowsLoginCommand(packageRoot);
|
|
57
|
+
if (command === next) return 'unchanged';
|
|
58
|
+
await requireReg(reg, ['add', RUN_KEY, '/v', RUN_VALUE, '/t', 'REG_SZ', '/d', next, '/f']);
|
|
59
|
+
return 'retargeted';
|
|
60
|
+
}
|
|
61
|
+
await requireReg(reg, ['delete', RUN_KEY, '/v', RUN_VALUE, '/f']);
|
|
62
|
+
return 'removed';
|
|
63
|
+
} catch { return 'failed'; }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Uninstall: the launch-at-login entry (only when it starts this installation),
|
|
67
|
+
// the client's settings and its notification identity. 'removed' or 'failed'.
|
|
68
|
+
async function removeWindowsClientRegistrations(installRoot, { reg = runReg } = {}) {
|
|
69
|
+
try {
|
|
70
|
+
const command = await readLoginLaunch(reg);
|
|
71
|
+
if (command && launchesFrom(command, installRoot)) await requireReg(reg, ['delete', RUN_KEY, '/v', RUN_VALUE, '/f']);
|
|
72
|
+
for (const key of CLIENT_KEYS) {
|
|
73
|
+
if ((await reg(['query', key])).code === 0) await requireReg(reg, ['delete', key, '/f']);
|
|
74
|
+
}
|
|
75
|
+
return 'removed';
|
|
76
|
+
} catch { return 'failed'; }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const windowsDesktopClient = {
|
|
80
|
+
close: closeWindowsDesktopClient,
|
|
81
|
+
reopen: reopenInstalledWindowsClient,
|
|
82
|
+
followSwitch: retargetWindowsLoginLaunch,
|
|
83
|
+
unregister: removeWindowsClientRegistrations
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// The desktop client of this installation is closed while its program changes
|
|
87
|
+
// and, when it was open, opened again from whichever version is installed
|
|
88
|
+
// afterwards; its launch-at-login entry follows a successful switch.
|
|
89
|
+
export async function withWindowsClientClosed(plan, desktopClient, change) {
|
|
90
|
+
const clientWasOpen = await desktopClient.close(plan.current.dataDir) === 'exited';
|
|
91
|
+
try {
|
|
92
|
+
const result = await change();
|
|
93
|
+
return { ...result, desktopClient: clientWasOpen ? 'reopened' : 'not_open',
|
|
94
|
+
loginLaunch: await desktopClient.followSwitch(plan.installRoot, result.packageRoot) };
|
|
95
|
+
} finally {
|
|
96
|
+
if (clientWasOpen) desktopClient.reopen(plan.installRoot);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function readLoginLaunch(reg) {
|
|
101
|
+
const result = await reg(['query', RUN_KEY, '/v', RUN_VALUE]);
|
|
102
|
+
if (result.code !== 0) return null; // reg query exits 1 when the value is absent.
|
|
103
|
+
return new RegExp(`^\\s*${RUN_VALUE}\\s+REG_(?:EXPAND_)?SZ\\s+(.*?)\\s*$`, 'mi').exec(result.stdout)?.[1] ?? null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function launchesFrom(command, installRoot) {
|
|
107
|
+
const executable = /^"([^"]+)"/.exec(command)?.[1] ?? command.split(' ')[0];
|
|
108
|
+
return windowsInstallPathsOverlap(executable, installRoot);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function requireReg(reg, args) {
|
|
112
|
+
const result = await reg(args);
|
|
113
|
+
if (result.code !== 0) throw new Error('reg ' + args[0] + ' failed (exit ' + result.code + ').');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function runReg(args) {
|
|
117
|
+
return new Promise(resolve => execFile(join(process.env.SystemRoot, 'System32', 'reg.exe'), args,
|
|
118
|
+
{ windowsHide: true, timeout: 30_000, encoding: 'utf8' },
|
|
119
|
+
(error, stdout) => resolve({ code: error ? (typeof error.code === 'number' ? error.code : 1) : 0, stdout })));
|
|
120
|
+
}
|