fuli-context 0.20.0-beta.8 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh-CN.md +1 -0
- package/dist/web/assets/{AboutPage-Dy3drTbS.css → AboutPage-Bxm7RJZg.css} +1 -1
- package/dist/web/assets/{AboutPage-BybzKsx-.js → AboutPage-CjDenGS_.js} +1 -1
- package/dist/web/assets/{AgentName-CXf8heW-.js → AgentName-DdlJlpT3.js} +1 -1
- package/dist/web/assets/{AgentProfilePage-D0YyiAA6.js → AgentProfilePage-Cx_Uf5Vf.js} +1 -1
- package/dist/web/assets/{AgentProfilePage-B2yMnmQP.css → AgentProfilePage-DXvLQu-C.css} +1 -1
- package/dist/web/assets/{AgentsDirectoryPage-DvPJNJm-.css → AgentsDirectoryPage-BwF-0nFO.css} +1 -1
- package/dist/web/assets/{AgentsDirectoryPage-LU-bRYPw.js → AgentsDirectoryPage-DylT-GSW.js} +1 -1
- package/dist/web/assets/{BackLink-Dgc1V1EN.js → BackLink-D7oAvDG5.js} +1 -1
- package/dist/web/assets/{BoardMoveMenu-XrAiFzGj.js → BoardMoveMenu-B0pA7LLx.js} +1 -1
- package/dist/web/assets/CaptureChangePage-Cch3mT4b.css +1 -0
- package/dist/web/assets/{CaptureChangePage-DcJKvaGf.js → CaptureChangePage-DEuqPb14.js} +1 -1
- package/dist/web/assets/{Card-96u8qomm.js → Card-BZFLZ_2I.js} +1 -1
- package/dist/web/assets/{CardHeader-4je7E12I.js → CardHeader-C_c0keQn.js} +1 -1
- package/dist/web/assets/{CardTitle-bjMusOR6.js → CardTitle-yXOhV577.js} +1 -1
- package/dist/web/assets/ConnectionsPage-DlnHdtwn.js +1 -0
- package/dist/web/assets/{CreateProjectDialog-BDwT_wZd.js → CreateProjectDialog-BVJqWdlT.js} +1 -1
- package/dist/web/assets/{DataFormatPage-PxwqDWeZ.js → DataFormatPage-BdcjcyhZ.js} +1 -1
- package/dist/web/assets/DataFormatPage-Dp7mePUw.css +1 -0
- package/dist/web/assets/{DialogFooter-DwgFgHdH.js → DialogFooter-DYawfDCD.js} +1 -1
- package/dist/web/assets/{EmployeeRecruitDialog-DjX_wOWx.js → EmployeeRecruitDialog-CB4ARFkM.js} +1 -1
- package/dist/web/assets/{EmployeeWorkbenchPage-DWhBevwY.js → EmployeeWorkbenchPage-BUMfMBc8.js} +2 -2
- package/dist/web/assets/{EmployeeWorkbenchPage-l_LYqBnr.css → EmployeeWorkbenchPage-BenZP7De.css} +1 -1
- package/dist/web/assets/{GrowthLoading-DssogOkP.js → GrowthLoading-smW3-Gfp.js} +1 -1
- package/dist/web/assets/{InboxPage-fFg4gETv.css → InboxPage-CbbiHgTr.css} +1 -1
- package/dist/web/assets/{InboxPage-BF38gnSV.js → InboxPage-Crn1UU7s.js} +2 -2
- package/dist/web/assets/{Input-DHF3Ivr3.js → Input-F1oftPWh.js} +1 -1
- package/dist/web/assets/{KnowledgeEditDialog-uAzeQbMB.js → KnowledgeEditDialog-VdQwbX4E.js} +1 -1
- package/dist/web/assets/{KnowledgeHardDeleteSection-qGeE1YrK.js → KnowledgeHardDeleteSection-CXRmNnZF.js} +1 -1
- package/dist/web/assets/{KnowledgeItemEditPage-Cj5uNVo6.js → KnowledgeItemEditPage-CQo3TbCJ.js} +1 -1
- package/dist/web/assets/{KnowledgeItemSummaryCard-CeOSN36n.js → KnowledgeItemSummaryCard-Dd2McM-d.js} +1 -1
- package/dist/web/assets/{KnowledgeOrganizerPage-7VC_JAWQ.css → KnowledgeOrganizerPage-BIOaMzgQ.css} +1 -1
- package/dist/web/assets/{KnowledgeOrganizerPage-BVLMc2jL.js → KnowledgeOrganizerPage-BVgAyu6U.js} +1 -1
- package/dist/web/assets/KnowledgePage-Bfbfz_Z8.js +1 -0
- package/dist/web/assets/{KnowledgePeek-BD2zoQqA.js → KnowledgePeek-BNBkh1ey.js} +1 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-Ckw_olrt.js +1 -0
- package/dist/web/assets/{KnowledgeWorkspace-CgFI31jK.js → KnowledgeWorkspace-pH2tAFld.js} +1 -1
- package/dist/web/assets/{Label-DM1yZ2CL.js → Label-yDCtlpkb.js} +1 -1
- package/dist/web/assets/ModelSettingsPage-C3eBDWRL.js +1 -0
- package/dist/web/assets/ModelSettingsPage-DZkrJw7R.css +1 -0
- package/dist/web/assets/NotFoundPage-8gVVukRR.js +1 -0
- package/dist/web/assets/OccupationsPage-BTormZIO.css +1 -0
- package/dist/web/assets/{OccupationsPage-CHgGGvDu.js → OccupationsPage-PNoqE21Y.js} +1 -1
- package/dist/web/assets/{OverviewPage-E0tfzQRr.js → OverviewPage-DiwYSnhh.js} +2 -2
- package/dist/web/assets/{OverviewPage-CpHmwB7u.css → OverviewPage-YBQHyU7s.css} +1 -1
- package/dist/web/assets/{PersonalProfilePage-CfqsnB1K.css → PersonalProfilePage-CGW50MHm.css} +1 -1
- package/dist/web/assets/{PersonalProfilePage-o5Gpo9nJ.js → PersonalProfilePage-C_v2BFee.js} +1 -1
- package/dist/web/assets/PersonalProjectsPage-Cf5mrQmy.css +1 -0
- package/dist/web/assets/{PersonalProjectsPage-Boj9kG6I.js → PersonalProjectsPage-DGRV8cM5.js} +1 -1
- package/dist/web/assets/{PopperContent-BDOio_9z.js → PopperContent-5zqbtnYr.js} +1 -1
- package/dist/web/assets/{Presence-Bk6m9rvx.js → Presence-BYfYJNMD.js} +1 -1
- package/dist/web/assets/{ProjectAgentDetailPage-Cyl3ZPBO.js → ProjectAgentDetailPage-BQ9ffaCX.js} +2 -2
- package/dist/web/assets/{ProjectAgentDetailPage-Ns2ATys8.css → ProjectAgentDetailPage-CRFE6n-s.css} +1 -1
- package/dist/web/assets/{ProjectAgentDialog-C1_KluEx.js → ProjectAgentDialog-BGckQDTq.js} +1 -1
- package/dist/web/assets/{ProjectAgentFirstTask-CXKvWwhZ.js → ProjectAgentFirstTask-DrSd3nR-.js} +1 -1
- package/dist/web/assets/{ProjectAgentsPage-DKNDXWow.css → ProjectAgentsPage-BBzKAhZx.css} +1 -1
- package/dist/web/assets/{ProjectAgentsPage-DHTo0uNy.js → ProjectAgentsPage-U4Om3EPu.js} +1 -1
- package/dist/web/assets/{ProjectScopePicker-GjK7Hm4N.js → ProjectScopePicker-D0oxbwOd.js} +1 -1
- package/dist/web/assets/{PublicProjectsPage-BuJo0ReR.js → PublicProjectsPage-CvkQ3E8I.js} +1 -1
- package/dist/web/assets/{PublicProjectsPage-yA6Md4oM.css → PublicProjectsPage-Ditr0SY-.css} +1 -1
- package/dist/web/assets/{RadioGroupItem-DxktHt0c.js → RadioGroupItem-CBpbQlHx.js} +1 -1
- package/dist/web/assets/{RoundtablesPage-Bd3XCn7B.js → RoundtablesPage-BEUaKOjI.js} +1 -1
- package/dist/web/assets/RoundtablesPage-BMYSDYH8.css +1 -0
- package/dist/web/assets/{RovingFocusGroup-DyZDm-Bn.js → RovingFocusGroup-X9U-ufYr.js} +1 -1
- package/dist/web/assets/{RovingFocusItem-BKyXKG9n.js → RovingFocusItem-_uA_OCLT.js} +1 -1
- package/dist/web/assets/SessionMigrationPage-WVFSDcUO.js +1 -0
- package/dist/web/assets/{SessionRecordsPage-CvGaB3h3.js → SessionRecordsPage-Bs2eLXEi.js} +1 -1
- package/dist/web/assets/{SettingsPage-DG3ialW3.css → SettingsPage-BbX9ysTX.css} +1 -1
- package/dist/web/assets/{SettingsPage-OasIZiIz.js → SettingsPage-DlIwICIz.js} +1 -1
- package/dist/web/assets/{SharedJefaReportPage-_f2bnFY-.js → SharedJefaReportPage-B_rreEep.js} +1 -1
- package/dist/web/assets/{TabsContent-CTM6GBGk.js → TabsContent-8pXwYJPz.js} +1 -1
- package/dist/web/assets/{TabsTrigger-BFj6S2XJ.js → TabsTrigger-Cd6SI2yI.js} +1 -1
- package/dist/web/assets/{TagVocabularyPage-Cp1UVDoe.js → TagVocabularyPage-BQiuKG-4.js} +1 -1
- package/dist/web/assets/{TaskExecutionPlan-D_MbMVvj.js → TaskExecutionPlan-CupxJeyo.js} +1 -1
- package/dist/web/assets/TaskSchedulesPage-DcmDdY10.css +1 -0
- package/dist/web/assets/{TaskSchedulesPage-Dd38ntqQ.js → TaskSchedulesPage-zYQs7s6T.js} +1 -1
- package/dist/web/assets/{Teleport-D5d1fEVm.js → Teleport-BZX1Eb7R.js} +1 -1
- package/dist/web/assets/{TextField-DUZTbKVz.js → TextField-CielK4l3.js} +1 -1
- package/dist/web/assets/{UiDialog-CU8nqGKC.js → UiDialog-BSDblUpR.js} +1 -1
- package/dist/web/assets/{UiDisclosure-DbxNZe0B.js → UiDisclosure-DLmVwmy1.js} +1 -1
- package/dist/web/assets/{UiIcon-DSkB5Juh.js → UiIcon-B8eZeuGI.js} +1 -1
- package/dist/web/assets/{UiIconButton-Bgy8Hoy4.js → UiIconButton-e754Tmnq.js} +1 -1
- package/dist/web/assets/{UiSegmented-BwkPHeLK.js → UiSegmented-D1HD-qin.js} +1 -1
- package/dist/web/assets/{UiSelect-CW3HNsRZ.js → UiSelect-CbkTsi2e.js} +1 -1
- package/dist/web/assets/{UiToggle--Z_LpW41.js → UiToggle-Dz93aXFK.js} +1 -1
- package/dist/web/assets/{UiWeight-D8U0orbz.js → UiWeight-CUvyApSB.js} +1 -1
- package/dist/web/assets/{UnassignedConversationsPanel-BeWzhuBr.js → UnassignedConversationsPanel-xY7gsFot.js} +1 -1
- package/dist/web/assets/{VirtualDirectoryList-BT099Zuk.js → VirtualDirectoryList-Dv6PwLjU.js} +1 -1
- package/dist/web/assets/{Workbench3D-BAb5m-Qk.js → Workbench3D--4N_uKzp.js} +1 -1
- package/dist/web/assets/WritingTastePage-B7KojA4r.js +1 -0
- package/dist/web/assets/{WritingTastePage-Dh1qW6bK.css → WritingTastePage-asIa-2U5.css} +1 -1
- package/dist/web/assets/{_plugin-vue_export-helper-Crd8aFkh.js → _plugin-vue_export-helper-BmfQlfI8.js} +1 -1
- package/dist/web/assets/{accordion-C-pFa1cg.js → accordion-gXElbGP_.js} +1 -1
- package/dist/web/assets/{agent-occupation-BooDHzf0.js → agent-occupation-ChN-1QjC.js} +1 -1
- package/dist/web/assets/{agent-pins-CFO-xYmz.js → agent-pins-Chh_rdBi.js} +1 -1
- package/dist/web/assets/{agent-profile-Bi--2zRQ.css → agent-profile-LzhgJINr.css} +1 -1
- package/dist/web/assets/{agent-profile.css_vue_type_style_index_0_src_true_lang-BKk2RVxy.js → agent-profile.css_vue_type_style_index_0_src_true_lang-DWlz7UoN.js} +1 -1
- package/dist/web/assets/{agent-work-summary-BIZoVGaT.js → agent-work-summary-C9yMf019.js} +1 -1
- package/dist/web/assets/{attention-store-dDH6VA6Z.js → attention-store-CG9cF6DX.js} +1 -1
- package/dist/web/assets/{badge-BnU2j9Nh.js → badge-DvvDq2Wb.js} +1 -1
- package/dist/web/assets/{button-B4gCj85U.js → button-CFEnxtio.js} +1 -1
- package/dist/web/assets/{checkbox-CzVOT2cF.js → checkbox-DovdRz8u.js} +1 -1
- package/dist/web/assets/{client-Cg0bLxrO.js → client-lh80ewvs.js} +1 -1
- package/dist/web/assets/{console-k05BnLkZ.js → console-CQMgYkk9.js} +1 -1
- package/dist/web/assets/{conversation-launcher-settings-C745vZJa.js → conversation-launcher-settings-B1QM-wZB.js} +1 -1
- package/dist/web/assets/{design-lab-CJiqHzsm.js → design-lab-BDKwIbI8.js} +1 -1
- package/dist/web/assets/{dialog-DQaUWk4W.js → dialog-D2mO6m3B.js} +1 -1
- package/dist/web/assets/{dist-2CLFk118.js → dist-PmK0PfVA.js} +1 -1
- package/dist/web/assets/{dropdown-menu-CN5wjWUD.js → dropdown-menu-YzCnvjAb.js} +1 -1
- package/dist/web/assets/{field-6gOLsuT_.js → field-BMEFEyVC.js} +1 -1
- package/dist/web/assets/{identity-NbL1GGSB.js → identity-bK-fJdnj.js} +1 -1
- package/dist/web/assets/index-BhekqRSJ.js +2 -0
- package/dist/web/assets/index-DedvhyS3.css +1 -0
- package/dist/web/assets/{judgment-types-DfSuVLnV.js → judgment-types-DJnAr9c0.js} +1 -1
- package/dist/web/assets/{model-BjNAHvfb.js → model-BwNZZZNP.js} +1 -1
- package/dist/web/assets/{model-DrZFCNN6.js → model-CPMYnu3S.js} +1 -1
- package/dist/web/assets/{model-DPykou4S.js → model-Cengn9fg.js} +1 -1
- package/dist/web/assets/{model-YYqd0CSe.js → model-CuY1vtEy.js} +1 -1
- package/dist/web/assets/{model-2BvryZbU.js → model-DpVrfbnj.js} +1 -1
- package/dist/web/assets/{model-BsfqK9w_.js → model-rumuELTi.js} +1 -1
- package/dist/web/assets/{motion-preference-CxKthhLy.js → motion-preference-A1AMssSH.js} +1 -1
- package/dist/web/assets/{occupation-catalog-JHFMVvBn.js → occupation-catalog-DxwlYD1L.js} +1 -1
- package/dist/web/assets/{orchestration-filters-B7ZbjZKo.js → orchestration-filters-DZpJ0FN3.js} +1 -1
- package/dist/web/assets/{page-title-BawJ25Bw.js → page-title-Bg-mVyrS.js} +1 -1
- package/dist/web/assets/{personal-profile-graph-BEjSAQMe.js → personal-profile-graph-tMneNj_m.js} +1 -1
- package/dist/web/assets/{project-capture-BUtkhbr1.js → project-capture-QgMw6qvo.js} +1 -1
- package/dist/web/assets/{project-origin-DI7ft7I8.js → project-origin-ppsYHpYL.js} +1 -1
- package/dist/web/assets/project-team-api-DwP0O3rn.js +1 -0
- package/dist/web/assets/{quick-edit-api-CTMfc9uz.js → quick-edit-api-BiyK3ih-.js} +1 -1
- package/dist/web/assets/{shared-report-o1Tvfyn-.js → shared-report-D3Hem1t5.js} +3 -3
- package/dist/web/assets/{task-labels-dW28Ybet.js → task-labels-7KyNw9id.js} +1 -1
- package/dist/web/assets/{ui-BkbPVq3y.js → ui-Ck58paqr.js} +1 -1
- package/dist/web/assets/{useAgentRecords-D6BTApmV.js → useAgentRecords-C6RrZwwv.js} +1 -1
- package/dist/web/assets/{useApi-CROJJdhE-BMswzZdS.js → useApi-CROJJdhE-BujjnKN_.js} +1 -1
- package/dist/web/assets/{useFocusReturn-DQOtrYO8.js → useFocusReturn-D9IOIg17.js} +1 -1
- package/dist/web/assets/{useKnowledgeItemPeek-CGzVMWJz.js → useKnowledgeItemPeek-C6nAzvDL.js} +1 -1
- package/dist/web/assets/{useMinimumLoadingDisplay-DEBBYuGI.js → useMinimumLoadingDisplay-HnxkDut6.js} +1 -1
- package/dist/web/assets/{useRoutePeek-R9W605pr.js → useRoutePeek-BvYFc1BA.js} +1 -1
- package/dist/web/assets/{vue-router-BUjBh_Iw.js → vue-router-Bl55c88B.js} +1 -1
- package/dist/web/index.html +33 -33
- package/docs/agent-apps.md +110 -0
- package/docs/employee-agents.md +1 -1
- package/graph-provider/fuli_graph/app.py +16 -11
- package/graph-provider/fuli_graph/graph_query.py +30 -2
- package/graph-provider/fuli_graph/knowledge_audit.py +9 -1
- package/graph-provider/fuli_graph/knowledge_item_routes.py +10 -6
- package/graph-provider/fuli_graph/knowledge_item_view.py +41 -12
- package/graph-provider/fuli_graph/knowledge_item_view_models.py +3 -3
- package/graph-provider/fuli_graph/knowledge_review.py +47 -10
- package/graph-provider/fuli_graph/knowledge_search.py +18 -22
- package/graph-provider/fuli_graph/knowledge_session_migration.py +14 -4
- package/graph-provider/fuli_graph/knowledge_session_migration_models.py +2 -2
- package/graph-provider/fuli_graph/knowledge_tag_routes.py +7 -5
- package/graph-provider/fuli_graph/knowledge_tags.py +8 -4
- package/graph-provider/fuli_graph/knowledge_visibility.py +195 -0
- package/graph-provider/fuli_graph/models.py +12 -2
- package/graph-provider/fuli_graph/preference_conflicts.py +50 -4
- package/graph-provider/fuli_graph/publication_source_copies.py +36 -0
- package/graph-provider/fuli_graph/session_records.py +33 -13
- package/graph-provider/fuli_graph/session_records_models.py +4 -2
- package/graph-provider/fuli_graph/store_knowledge.py +5 -1
- package/graph-provider/fuli_graph/store_publication.py +70 -12
- package/graph-provider/fuli_graph/task_context_models.py +2 -0
- package/graph-provider/fuli_graph/task_session_hints.py +7 -3
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +8 -8
- package/package.json +3 -2
- package/skills/capturing-session-knowledge/references/retrieval.md +6 -0
- package/src/agent-apps/activation.js +3 -3
- package/src/agent-apps/app-host.js +2 -0
- package/src/agent-apps/app-launcher.js +25 -0
- package/src/agent-apps/authorization.js +6 -4
- package/src/agent-apps/bounded-wait.js +13 -0
- package/src/agent-apps/{verified-decisions.js → confirmed-decisions.js} +100 -55
- package/src/agent-apps/decision-source.js +17 -17
- package/src/agent-apps/host-identity.js +8 -2
- package/src/agent-apps/instances.js +218 -29
- package/src/agent-apps/operations.js +4 -3
- package/src/agent-apps/run-gate.js +25 -20
- package/src/agent-apps/service.js +40 -16
- package/src/agent-apps/store.js +28 -14
- package/src/agent-apps/trust-terms.js +23 -0
- package/src/agent-apps/trusted-runner.js +136 -0
- package/src/agent-apps/versions.js +5 -4
- package/src/agent-apps/views.js +11 -6
- package/src/agent-tools/agent-app-definitions.js +1 -1
- package/src/agent-tools/graph-definitions.js +4 -4
- package/src/agent-tools/interface-catalog.js +2 -2
- package/src/agent-tools/interface-definitions.js +2 -1
- package/src/agent-tools/session-fuli-gate.js +55 -26
- package/src/agent-tools.js +2 -4
- package/src/agents/claude-code/lifecycle-hook.js +29 -12
- package/src/agents/codex/lifecycle-hook.js +25 -10
- package/src/agents/lifecycle-message.js +18 -0
- package/src/agents/turn-receipt.js +15 -8
- package/src/app/agent-request-context.js +18 -0
- package/src/cli/app-command.js +46 -61
- package/src/cli/remote-mcp-command.js +6 -2
- package/src/cli/setup-command.js +6 -0
- package/src/cli/terminal-io.js +22 -0
- package/src/cli/update-command.js +14 -1
- package/src/cli/update-installation.js +46 -2
- package/src/conversations/entry-budget.js +116 -0
- package/src/conversations/preference-evidence.js +6 -2
- package/src/conversations/task-context-view.js +13 -8
- package/src/data-format/local-stores.js +2 -0
- package/src/graphiti/agent-conversations.js +24 -3
- package/src/graphiti/assistant-project-candidate.js +5 -2
- package/src/graphiti/capture-notice.js +4 -1
- package/src/graphiti/entry-hint-claim.js +13 -0
- package/src/graphiti/federated-application.js +55 -62
- package/src/graphiti/human-review-channel.js +9 -5
- package/src/graphiti/jefa-board-match.js +4 -1
- package/src/graphiti/knowledge-item-edit.js +7 -4
- package/src/graphiti/knowledge-reader.js +46 -0
- package/src/graphiti/knowledge-result-budget.js +63 -12
- package/src/graphiti/knowledge-tags.js +12 -1
- package/src/graphiti/provider-client.js +18 -25
- package/src/graphiti/publication-draft-capture.js +28 -0
- package/src/graphiti/session-knowledge-migration.js +7 -3
- package/src/graphiti/session-layer-decision.js +28 -6
- package/src/graphiti/session-records.js +26 -15
- package/src/graphiti/shared-project-list.js +36 -0
- package/src/graphiti/task-entry-preferences.js +87 -46
- package/src/graphiti/turn-receipt-delivery.js +5 -2
- package/src/graphiti/writing-taste-profile-workflow.js +13 -7
- package/src/http/api-router.js +2 -1
- package/src/http/graph-api-router.js +13 -10
- package/src/http/knowledge-item-api-router.js +17 -4
- package/src/http/knowledge-tags-api-router.js +21 -9
- package/src/http/request-policy.js +18 -2
- package/src/http/session-records-api-router.js +7 -3
- package/src/judgment/review-prompt.js +21 -1
- package/src/knowledge-owner-reads/console-port.js +51 -0
- package/src/knowledge-tags/console-port.js +3 -2
- package/src/mcp/preference-delivery.js +7 -4
- package/src/mcp/provider-task-context-registry.js +23 -0
- package/src/mcp/tool-result.js +3 -3
- package/src/presence/platforms.js +3 -2
- package/src/presence/port.js +2 -1
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/server.js +14 -2
- package/src/standing-assignments/port.js +146 -0
- package/src/standing-assignments/store.js +151 -0
- package/src/standing-assignments/term-match.js +28 -0
- package/src/text/name-identity.js +33 -0
- package/dist/web/assets/CaptureChangePage-C833Eiqu.css +0 -1
- package/dist/web/assets/ConnectionsPage-EFMP-UeV.js +0 -1
- package/dist/web/assets/DataFormatPage-DERqhmng.css +0 -1
- package/dist/web/assets/KnowledgePage-8ct5iO0F.js +0 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-Yn3jhDyx.js +0 -1
- package/dist/web/assets/ModelSettingsPage-5RkvgNYN.js +0 -1
- package/dist/web/assets/ModelSettingsPage-BqtWIKEA.css +0 -1
- package/dist/web/assets/NotFoundPage-BUUf2-MZ.js +0 -1
- package/dist/web/assets/OccupationsPage-B55DftFp.css +0 -1
- package/dist/web/assets/PersonalProjectsPage-aU1rApzX.css +0 -1
- package/dist/web/assets/RoundtablesPage-BmmsB1mW.css +0 -1
- package/dist/web/assets/SessionMigrationPage-CQhrJ1OQ.js +0 -1
- package/dist/web/assets/TaskSchedulesPage-CDalUfNj.css +0 -1
- package/dist/web/assets/WritingTastePage-BsekLhC3.js +0 -1
- package/dist/web/assets/index-BczJo3GN.js +0 -2
- package/dist/web/assets/index-C2rHjaT6.css +0 -1
- package/dist/web/assets/project-team-api-BZMMPuUd.js +0 -1
- package/src/agent-apps/isolation.js +0 -23
|
@@ -2,6 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
3
|
|
|
4
4
|
import { createAppTokens } from './app-tokens.js';
|
|
5
|
+
import { settledWithin } from './bounded-wait.js';
|
|
5
6
|
import { createDataDeletion } from './data-deletion.js';
|
|
6
7
|
import { ensureDataDirectory } from './data-directory.js';
|
|
7
8
|
import { appConflict } from './errors.js';
|
|
@@ -10,51 +11,111 @@ import { createRunGate, runRefused } from './run-gate.js';
|
|
|
10
11
|
const INSTANCE_ID_BYTES = 16;
|
|
11
12
|
// Sealing waits this long for a write tool that holds the gate (D-28.17).
|
|
12
13
|
const SEAL_WAIT_MS = 10_000;
|
|
14
|
+
// Closing waits this long for work in flight and for each seal; an app process
|
|
15
|
+
// still held after it is stopped, and its records are left to the next owner.
|
|
16
|
+
const CLOSE_WAIT_MS = 30_000;
|
|
13
17
|
|
|
14
18
|
// An instance has ended only once its process is confirmed stopped (stoppedAt):
|
|
15
|
-
// sealed alone, after a
|
|
19
|
+
// sealed alone, after a runner stop that failed, still blocks a start, an
|
|
16
20
|
// export and a deletion until a stop or an orphan cleanup confirms it.
|
|
17
21
|
const unfinished = (instance) => Boolean(instance) && !instance.stoppedAt;
|
|
18
22
|
|
|
23
|
+
// What an app_exited record says of each way an app process ends
|
|
24
|
+
// (trusted-runner.js). Fixed text only: nothing the app wrote is recorded.
|
|
25
|
+
const EXIT_MESSAGES = Object.freeze({
|
|
26
|
+
load_failed: 'The app ended before its entry finished loading.',
|
|
27
|
+
crashed: 'The app ended with an error after it had started.',
|
|
28
|
+
exited: 'The app finished and ended by itself.'
|
|
29
|
+
});
|
|
30
|
+
|
|
19
31
|
// Waits ms unless aborted; resolves either way.
|
|
20
32
|
const waitFor = (ms, signal) => delay(ms, undefined, { signal }).catch(() => {});
|
|
21
33
|
|
|
22
34
|
// The app runner (rec#7 D-28.9, D-28.14, D-28.17): the one current instance
|
|
23
35
|
// of each app this process hosts, and the serial contract around it.
|
|
24
|
-
// - start: the run gate and the
|
|
36
|
+
// - start: the run gate and the runner's self-check pass, the owner lease is
|
|
25
37
|
// taken for the instance's life, and inside the write gate the next instance
|
|
26
38
|
// generation is claimed, the data root is created (the only place it is),
|
|
27
|
-
// a token bound to the instance is issued and the
|
|
39
|
+
// a token bound to the instance is issued and the runner starts it.
|
|
28
40
|
// - seal: stopping (no new call verifies) → sealing (a write tool still holds
|
|
29
41
|
// the gate after 10 s; every decision on the app answers instance_sealing
|
|
30
42
|
// until it ends) → sealed (sealedAt written inside the gate). Then the
|
|
31
|
-
// process stops through the
|
|
43
|
+
// process stops through the runner's own reference, the tokens end and
|
|
32
44
|
// the lease is released.
|
|
33
45
|
// - reconcile, before every operation: an instance whose host has exited
|
|
34
|
-
// (its lease was just taken over on exit evidence) is stopped
|
|
35
|
-
//
|
|
46
|
+
// (its lease was just taken over on exit evidence) is confirmed stopped by the
|
|
47
|
+
// runner and sealed with reason host_gone, which also completes a sealing
|
|
36
48
|
// its host left; an interrupted data deletion is settled.
|
|
49
|
+
// - exit: an app process that ends by itself (its entry failed to load, it
|
|
50
|
+
// crashed or it finished) is wrapped up in the app's lifecycle, bound to
|
|
51
|
+
// its instance id and generation: recorded with its exit code, signal and a
|
|
52
|
+
// fixed category message (never anything the app wrote) and sealed like a stop. An exit of an earlier instance touches nothing.
|
|
53
|
+
// - close: no new start, stop, decision or call is admitted; work in flight
|
|
54
|
+
// finishes, every instance this process holds is sealed and its process
|
|
55
|
+
// stopped, and only then do the lease and the registry close. Every handle
|
|
56
|
+
// the runner returned is held in memory until its stop succeeded, so a
|
|
57
|
+
// start that returns after close began, a registration that throws or a
|
|
58
|
+
// stop that failed never leaves a process nobody holds; close reports what
|
|
59
|
+
// it could not stop instead of a clean close, and records a stop it could
|
|
60
|
+
// confirm only on its retry while this process still owns the app.
|
|
37
61
|
export function createAppInstances(context) {
|
|
38
|
-
const { store, leases, gates, lifecycles,
|
|
62
|
+
const { store, leases, gates, lifecycles, runner, now } = context;
|
|
39
63
|
const wait = context.wait ?? waitFor;
|
|
64
|
+
const closeWaitMs = context.closeWaitMs ?? CLOSE_WAIT_MS;
|
|
40
65
|
const tokens = createAppTokens(context);
|
|
41
66
|
const { runGate } = createRunGate(context);
|
|
42
67
|
const deletion = createDataDeletion(context);
|
|
43
68
|
const hosted = new Map();
|
|
69
|
+
// Starts, stops and decisions in flight in this process, which close waits for.
|
|
70
|
+
const inFlight = new Set();
|
|
71
|
+
let closing = false;
|
|
72
|
+
// Every runner handle not yet confirmed stopped, with the instance it was started for.
|
|
73
|
+
const held = new Map();
|
|
74
|
+
|
|
75
|
+
// Stops a handle through the runner; only a stop that succeeded lets it go.
|
|
76
|
+
async function stopHandle(handle) {
|
|
77
|
+
await runner.stop(handle);
|
|
78
|
+
held.delete(handle);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Once this process closes, its registry may already be closed: what a
|
|
82
|
+
// late step could not record stays for the next owner's reconcile, as after a crash.
|
|
83
|
+
function unlessClosed(work) {
|
|
84
|
+
try {
|
|
85
|
+
work();
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (!closing) throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Work queued before close began, and calls of a closing host, are refused.
|
|
92
|
+
function assertOpen() {
|
|
93
|
+
if (closing) throw hostClosing();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Admits one piece of lifecycle work unless this process is closing.
|
|
97
|
+
function admit(work) {
|
|
98
|
+
if (closing) return Promise.reject(hostClosing());
|
|
99
|
+
const running = work();
|
|
100
|
+
inFlight.add(running);
|
|
101
|
+
running.then(() => inFlight.delete(running), () => inFlight.delete(running));
|
|
102
|
+
return running;
|
|
103
|
+
}
|
|
44
104
|
|
|
45
105
|
// start, stop and every decision on an app (operations.js) run one at a
|
|
46
106
|
// time in this process (lifecycles): a decision never runs beside a start
|
|
47
107
|
// still in flight, and a start never begins while an earlier instance is
|
|
48
108
|
// still being sealed or stopped.
|
|
49
109
|
function start({ appId, mode = 'managed' }) {
|
|
50
|
-
return lifecycles.run(appId, { toolName: 'start' }, async () => {
|
|
110
|
+
return admit(() => lifecycles.run(appId, { toolName: 'start' }, async () => {
|
|
111
|
+
assertOpen();
|
|
51
112
|
const earlier = hosted.get(appId);
|
|
52
113
|
if (earlier) throw earlier.sealing ? sealingRefusal({ instanceId: earlier.instanceId, waitingFor: null })
|
|
53
114
|
: liveInstance({ state: 'running', instanceId: earlier.instanceId });
|
|
54
115
|
const gate = runGate({ appId });
|
|
55
116
|
if (gate.status !== 'ready') return gate;
|
|
56
|
-
const check = await
|
|
57
|
-
if (!check.ok) return runRefused('
|
|
117
|
+
const check = await runner.selfCheck();
|
|
118
|
+
if (!check.ok) return runRefused('runner_check_failed');
|
|
58
119
|
const lease = await leases.acquire(appId);
|
|
59
120
|
let started = false;
|
|
60
121
|
try {
|
|
@@ -65,9 +126,9 @@ export function createAppInstances(context) {
|
|
|
65
126
|
started = outcome.status === 'running';
|
|
66
127
|
return outcome;
|
|
67
128
|
} finally {
|
|
68
|
-
if (!started) leases.release(lease);
|
|
129
|
+
if (!started) unlessClosed(() => leases.release(lease));
|
|
69
130
|
}
|
|
70
|
-
});
|
|
131
|
+
}));
|
|
71
132
|
}
|
|
72
133
|
|
|
73
134
|
async function launch(appId, mode, lease) {
|
|
@@ -103,20 +164,41 @@ export function createAppInstances(context) {
|
|
|
103
164
|
leases.assertOwned(lease);
|
|
104
165
|
ensureDataDirectory(context.dataOf(appId));
|
|
105
166
|
}
|
|
106
|
-
handle = await
|
|
167
|
+
handle = await runner.start({ appId, instanceId, generation, mode, manifest: version.manifest,
|
|
107
168
|
packageDirectory: context.packageOf(appId, version.version), dataDirectory: context.dataOf(appId),
|
|
108
|
-
environment: { FULI_APP_ID: appId, FULI_APP_INSTANCE: instanceId, FULI_APP_TOKEN: token }
|
|
169
|
+
environment: { FULI_APP_ID: appId, FULI_APP_INSTANCE: instanceId, FULI_APP_TOKEN: token },
|
|
170
|
+
onExit: (exit) => exited(appId, instance, exit) });
|
|
109
171
|
} catch (error) {
|
|
110
|
-
endInstance(appId, lease, instance, 'start_failed', { sealedAt: now() });
|
|
172
|
+
unlessClosed(() => endInstance(appId, lease, instance, 'start_failed', { sealedAt: now() }));
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
held.set(handle, { appId, instanceId, generation });
|
|
176
|
+
// A start that returns after close began is stopped, never registered.
|
|
177
|
+
if (closing) {
|
|
178
|
+
await stopHandle(handle);
|
|
179
|
+
unlessClosed(() => endInstance(appId, lease, instance, 'host_closing', { sealedAt: now() }));
|
|
180
|
+
throw hostClosing();
|
|
181
|
+
}
|
|
182
|
+
let recorded;
|
|
183
|
+
try {
|
|
184
|
+
recorded = store.transaction(() => {
|
|
185
|
+
leases.assertOwned(lease);
|
|
186
|
+
return store.updateInstance(instance, { pid: handle.pid ?? null, pidIdentity: handle.pidIdentity ?? null,
|
|
187
|
+
exePath: handle.exePath ?? null, socket: handle.socket ?? null });
|
|
188
|
+
});
|
|
189
|
+
} catch (error) {
|
|
190
|
+
// The process is stopped first; only then does the instance end, so no
|
|
191
|
+
// running row of this owner outlives it and blocks the next start.
|
|
192
|
+
await stopHandle(handle);
|
|
193
|
+
try {
|
|
194
|
+
endInstance(appId, lease, instance, 'start_failed', { sealedAt: now() });
|
|
195
|
+
} catch {
|
|
196
|
+
// The registry still fails: the record stays for the next owner's reconcile.
|
|
197
|
+
}
|
|
111
198
|
throw error;
|
|
112
199
|
}
|
|
113
|
-
const recorded = store.transaction(() => {
|
|
114
|
-
leases.assertOwned(lease);
|
|
115
|
-
return store.updateInstance(instance, { pid: handle.pid ?? null, pidIdentity: handle.pidIdentity ?? null,
|
|
116
|
-
exePath: handle.exePath ?? null, socket: handle.socket ?? null });
|
|
117
|
-
});
|
|
118
200
|
if (!recorded) {
|
|
119
|
-
await
|
|
201
|
+
await stopHandle(handle);
|
|
120
202
|
throw superseded();
|
|
121
203
|
}
|
|
122
204
|
hosted.set(appId, { lease, ...instance, handle, sealing: null, sealed: false });
|
|
@@ -150,10 +232,12 @@ export function createAppInstances(context) {
|
|
|
150
232
|
// When the seal completes after the caller was told sealing, a failure
|
|
151
233
|
// is recorded and left to the next seal or the next owner's reconcile.
|
|
152
234
|
done.catch(() => {});
|
|
235
|
+
local.done = done;
|
|
153
236
|
const timeout = new AbortController();
|
|
237
|
+
// The wait ends with the race either way, a failed stop included, so no timer outlives it.
|
|
154
238
|
return Promise.race([done.then(() => 'sealed'), wait(SEAL_WAIT_MS, timeout.signal).then(() => 'waiting')])
|
|
239
|
+
.finally(() => timeout.abort())
|
|
155
240
|
.then((state) => {
|
|
156
|
-
timeout.abort();
|
|
157
241
|
if (state === 'sealed') return { status: 'sealed', appId, instanceId: local.instanceId };
|
|
158
242
|
const holder = gates.holder(appId);
|
|
159
243
|
store.transaction(() => {
|
|
@@ -177,9 +261,11 @@ export function createAppInstances(context) {
|
|
|
177
261
|
store.recordEvent({ appId, at: now(), action: 'sealed', detail: { instanceId: local.instanceId, reason } });
|
|
178
262
|
});
|
|
179
263
|
local.sealed = true;
|
|
264
|
+
// Why it was sealed: a later seal (close's host_closing) retries the stop but keeps this.
|
|
265
|
+
local.sealReason = reason;
|
|
180
266
|
}
|
|
181
267
|
try {
|
|
182
|
-
await
|
|
268
|
+
await stopHandle(local.handle);
|
|
183
269
|
} catch (error) {
|
|
184
270
|
local.sealing = null;
|
|
185
271
|
store.transaction(() => {
|
|
@@ -189,7 +275,8 @@ export function createAppInstances(context) {
|
|
|
189
275
|
});
|
|
190
276
|
throw error;
|
|
191
277
|
}
|
|
192
|
-
|
|
278
|
+
// A retried seal (close's host_closing) records why the instance was first sealed.
|
|
279
|
+
endInstance(appId, local.lease, local, local.sealReason);
|
|
193
280
|
if (hosted.get(appId) === local) hosted.delete(appId);
|
|
194
281
|
leases.release(local.lease);
|
|
195
282
|
} finally {
|
|
@@ -215,10 +302,26 @@ export function createAppInstances(context) {
|
|
|
215
302
|
if (sealed.status === 'sealing') throw sealingRefusal(sealed);
|
|
216
303
|
}
|
|
217
304
|
|
|
305
|
+
// An app process that ended by itself. Only the instance it was started
|
|
306
|
+
// for, still hosted here and not already being sealed, is wrapped up.
|
|
307
|
+
function exited(appId, { instanceId, generation }, { code = null, signal = null, category } = {}) {
|
|
308
|
+
lifecycles.run(appId, { toolName: 'exit' }, async () => {
|
|
309
|
+
const local = hosted.get(appId);
|
|
310
|
+
const exitCategory = Object.hasOwn(EXIT_MESSAGES, category) ? category : 'crashed';
|
|
311
|
+
if (closing || local?.instanceId !== instanceId || local.generation !== generation || local.sealing) return;
|
|
312
|
+
store.transaction(() => {
|
|
313
|
+
if (!leases.owns(local.lease)) return;
|
|
314
|
+
store.recordEvent({ appId, at: now(), action: 'app_exited',
|
|
315
|
+
detail: { instanceId, generation, code, signal, category: exitCategory, message: EXIT_MESSAGES[exitCategory] } });
|
|
316
|
+
});
|
|
317
|
+
await seal(appId, 'app_exited');
|
|
318
|
+
}).catch(() => {});
|
|
319
|
+
}
|
|
320
|
+
|
|
218
321
|
// fuli app stop: this process's instance, or one whose host has exited
|
|
219
322
|
// (taken over on exit evidence). force against a live host is refused.
|
|
220
323
|
function stop({ appId, force = false }) {
|
|
221
|
-
return lifecycles.run(appId, { toolName: 'stop' }, async () => {
|
|
324
|
+
return admit(() => lifecycles.run(appId, { toolName: 'stop' }, async () => {
|
|
222
325
|
if (hosted.has(appId)) {
|
|
223
326
|
const sealed = await seal(appId, 'stopped');
|
|
224
327
|
if (sealed.status === 'sealing') throw sealingRefusal(sealed);
|
|
@@ -231,7 +334,89 @@ export function createAppInstances(context) {
|
|
|
231
334
|
} finally {
|
|
232
335
|
leases.release(lease);
|
|
233
336
|
}
|
|
234
|
-
});
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Ends this process's part: admits nothing new, lets work in flight finish
|
|
341
|
+
// (for CLOSE_WAIT_MS at most), seals and stops every instance it holds, then
|
|
342
|
+
// stops every handle still held. A seal still waiting after CLOSE_WAIT_MS (a
|
|
343
|
+
// write tool that never returns) has its process stopped all the same; its
|
|
344
|
+
// records stay for the next owner's reconcile, as after a crash; so do the
|
|
345
|
+
// records of a seal whose registry write threw. Never rejects: resolves
|
|
346
|
+
// { complete, startsInFlight, notStopped }, complete only when nothing is in
|
|
347
|
+
// flight and nothing is still held, so every process FULI started is
|
|
348
|
+
// confirmed stopped; notStopped names every handle still held, a late
|
|
349
|
+
// start's among them. Asked again, it retries the stops that failed and
|
|
350
|
+
// keeps their handles meanwhile.
|
|
351
|
+
async function close() {
|
|
352
|
+
const first = !closing;
|
|
353
|
+
closing = true;
|
|
354
|
+
if (first) await settledWithin(Promise.allSettled([...inFlight]), closeWaitMs);
|
|
355
|
+
await Promise.all([...hosted.entries()].map(async ([appId, local]) => {
|
|
356
|
+
if (!await sealForClose(appId, local, first)) hosted.delete(appId);
|
|
357
|
+
}));
|
|
358
|
+
const failures = await stopHeld();
|
|
359
|
+
for (const [appId, local] of hosted) if (!held.has(local.handle)) hosted.delete(appId);
|
|
360
|
+
const notStopped = [...held].map(([handle, started]) => ({ ...started, pid: handle.pid ?? null,
|
|
361
|
+
code: failures.get(handle) ?? null }));
|
|
362
|
+
return { complete: idle(), startsInFlight: inFlight.size, notStopped };
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Tries each held handle's stop once, passing again while a late start
|
|
366
|
+
// returned a handle during the last pass. Resolves each failed stop's error code.
|
|
367
|
+
async function stopHeld() {
|
|
368
|
+
const failures = new Map();
|
|
369
|
+
for (;;) {
|
|
370
|
+
const pending = [...held].filter(([handle]) => !failures.has(handle));
|
|
371
|
+
if (pending.length === 0) return failures;
|
|
372
|
+
await Promise.all(pending.map(async ([handle, started]) => {
|
|
373
|
+
try {
|
|
374
|
+
await stopHandle(handle);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
failures.set(handle, error?.code ?? null);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
recordLateStop(started.appId, handle);
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Nothing hosted, held or in flight: closing has nothing to wait for.
|
|
385
|
+
function idle() {
|
|
386
|
+
return hosted.size === 0 && held.size === 0 && inFlight.size === 0;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Whether this instance's seal settled within the close wait; never throws,
|
|
390
|
+
// so close always reaches its stops. A host whose lease another process
|
|
391
|
+
// took over records nothing more, and a seal that cannot even begin (its
|
|
392
|
+
// registry write throws) leaves the records to the next owner; either way
|
|
393
|
+
// the process still ends through its held handle.
|
|
394
|
+
async function sealForClose(appId, local, first) {
|
|
395
|
+
try {
|
|
396
|
+
if (!first || !leases.owns(local.lease)) return false;
|
|
397
|
+
local.sealing ??= sealHosted(appId, local, 'host_closing');
|
|
398
|
+
local.sealing.catch(() => {});
|
|
399
|
+
return await settledWithin(local.done, closeWaitMs);
|
|
400
|
+
} catch {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// A stop close confirmed after the seal's own stop failed: the sealed
|
|
406
|
+
// instance ends and its lease is released while this process still owns
|
|
407
|
+
// it (endInstance asserts that inside its transaction). Otherwise, or once
|
|
408
|
+
// the registry is closed (a retried close), it stays for the next owner's
|
|
409
|
+
// reconcile.
|
|
410
|
+
function recordLateStop(appId, handle) {
|
|
411
|
+
const local = hosted.get(appId);
|
|
412
|
+
if (local?.handle !== handle || !local.sealed) return;
|
|
413
|
+
try {
|
|
414
|
+
if (!leases.owns(local.lease)) return;
|
|
415
|
+
endInstance(appId, local.lease, local, local.sealReason);
|
|
416
|
+
leases.release(local.lease);
|
|
417
|
+
} catch {
|
|
418
|
+
// Left for the next owner, as after a crash.
|
|
419
|
+
}
|
|
235
420
|
}
|
|
236
421
|
|
|
237
422
|
// Inside the app's write gate, holding its lease.
|
|
@@ -240,7 +425,7 @@ export function createAppInstances(context) {
|
|
|
240
425
|
// stopOrphan resolves only once the process is confirmed gone (or never
|
|
241
426
|
// ran); a failure keeps the record and refuses the operation.
|
|
242
427
|
if (unfinished(instance) && instance.ownerId !== lease.ownerId) {
|
|
243
|
-
await
|
|
428
|
+
await runner.stopOrphan(instance);
|
|
244
429
|
// A sealing the exited host left completes here.
|
|
245
430
|
if (!instance.sealedAt) {
|
|
246
431
|
store.transaction(() => {
|
|
@@ -260,11 +445,15 @@ export function createAppInstances(context) {
|
|
|
260
445
|
}
|
|
261
446
|
|
|
262
447
|
return {
|
|
263
|
-
start, stop, seal, end, reconcile, assertNoInstance, verifyToken: tokens.verifyToken,
|
|
264
|
-
hosted: (appId) => hosted.get(appId) ?? null
|
|
448
|
+
start, stop, seal, end, reconcile, assertNoInstance, admit, close, verifyToken: tokens.verifyToken,
|
|
449
|
+
hosted: (appId) => hosted.get(appId) ?? null,
|
|
450
|
+
idle,
|
|
451
|
+
assertOpen
|
|
265
452
|
};
|
|
266
453
|
}
|
|
267
454
|
|
|
455
|
+
const hostClosing = () => appConflict('host_closing', 'This FULI process is shutting down; try again from a running FULI');
|
|
456
|
+
|
|
268
457
|
function liveInstance(instance) {
|
|
269
458
|
if (instance.state === 'sealed') {
|
|
270
459
|
return appConflict('instance_not_stopped', 'The app instance is sealed but its stop is not confirmed; '
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
// transactions and before each data file operation. The lease and the gate
|
|
10
10
|
// are released only after the work, with all its file I/O, has finished.
|
|
11
11
|
// keepInstance: an export, which refuses a running instance instead of
|
|
12
|
-
// stopping it.
|
|
12
|
+
// stopping it. While this process closes (instances.js) no operation is admitted.
|
|
13
13
|
export function createAppOperations(context) {
|
|
14
14
|
const { leases, gates, lifecycles, instances, now } = context;
|
|
15
15
|
|
|
16
16
|
function run(appId, operation, work, { keepInstance = false } = {}) {
|
|
17
|
-
return lifecycles.run(appId, { toolName: operation }, async () => {
|
|
17
|
+
return instances.admit(() => lifecycles.run(appId, { toolName: operation }, async () => {
|
|
18
|
+
instances.assertOpen();
|
|
18
19
|
if (!keepInstance) await instances.end(appId, operation);
|
|
19
20
|
const lease = await leases.acquire(appId);
|
|
20
21
|
try {
|
|
@@ -25,7 +26,7 @@ export function createAppOperations(context) {
|
|
|
25
26
|
} finally {
|
|
26
27
|
leases.release(lease);
|
|
27
28
|
}
|
|
28
|
-
});
|
|
29
|
+
}));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
return { run };
|
|
@@ -1,42 +1,47 @@
|
|
|
1
|
-
import { presenceKindFor } from '../presence/platforms.js';
|
|
2
1
|
import { approvalBinds } from './authorization.js';
|
|
3
|
-
import {
|
|
2
|
+
import { TERMINAL_CONFIRMATION } from './decision-source.js';
|
|
4
3
|
import { storedPackageMatches } from './package-files.js';
|
|
4
|
+
import { TERMS_VERSION, TRUST_MODE } from './trust-terms.js';
|
|
5
5
|
|
|
6
|
-
// The fixed reasons a run is refused (rec#7 D-28.2).
|
|
6
|
+
// The fixed reasons a run is refused (rec#7 D-28.2, rec#11 D-36.2).
|
|
7
7
|
const RUN_REFUSALS = Object.freeze({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
confirmation_required: 'The running version has not been confirmed at a terminal; approve or roll back with '
|
|
9
|
+
+ 'fuli app approve/rollback.',
|
|
10
|
+
reconfirmation_required: 'This version was approved under earlier terms (isolated mode), which do not cover running it '
|
|
11
|
+
+ 'with your account\'s permissions; confirm it again with fuli app rollback <app> <version> '
|
|
12
|
+
+ '(该版本是按旧的隔离模式批准的,不会自动转为受信任模式,请重新确认).',
|
|
13
|
+
challenge_mismatch: 'The confirmed challenge does not cover the approved terms or the package on disk.',
|
|
14
|
+
runner_check_failed: 'The app runner\'s self-check failed, so no app code runs.'
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
// The run gate every start of an app passes (on demand, idle restart, resident
|
|
16
18
|
// launch). It reads the persisted approval of the active version and never
|
|
17
|
-
// asks
|
|
18
|
-
// that activated the version
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
19
|
+
// asks again: the terminal confirmation was fresh for the approval or rollback
|
|
20
|
+
// that activated the version. It passes when that approval completed the
|
|
21
|
+
// terminal confirmation flow under this version's terms (trusted mode,
|
|
22
|
+
// trust-terms.js), its challenge is recorded as confirmed, it covers the
|
|
23
|
+
// version's terms and the package on disk still has the approved digest. An
|
|
24
|
+
// approval from the console, from an earlier FULI (the isolated mode, Windows
|
|
25
|
+
// Hello approvals included) or under other terms never passes. ready means
|
|
26
|
+
// the runner may go on to its self-check; this version has no sandbox, so the
|
|
27
|
+
// app then runs with the user's own permissions.
|
|
22
28
|
export function createRunGate(context) {
|
|
23
29
|
const { store } = context;
|
|
24
30
|
|
|
25
31
|
function runGate({ appId }) {
|
|
26
|
-
const kind = presenceKindFor(context.platform);
|
|
27
|
-
if (!kind) return runRefused('presence_unsupported_platform');
|
|
28
32
|
const app = store.existingApp(appId);
|
|
29
33
|
const approval = app.status === 'active' ? store.approval(appId, app.activeVersion) : null;
|
|
30
|
-
if (!approval || approval.
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
if (!approval?.challengeId || !approval.verifiedAt) return runRefused('confirmation_required');
|
|
35
|
+
if (approval.verification !== TERMINAL_CONFIRMATION || approval.trustMode !== TRUST_MODE
|
|
36
|
+
|| approval.termsVersion !== TERMS_VERSION) {
|
|
37
|
+
return runRefused('reconfirmation_required');
|
|
33
38
|
}
|
|
34
39
|
const version = store.version(appId, app.activeVersion);
|
|
35
|
-
if (!store.
|
|
40
|
+
if (!store.challengeConfirmed(appId, approval.challengeId) || !approvalBinds(approval, version)
|
|
36
41
|
|| !storedPackageMatches(context.packageOf(appId, version.version), approval.digest)) {
|
|
37
42
|
return runRefused('challenge_mismatch');
|
|
38
43
|
}
|
|
39
|
-
return
|
|
44
|
+
return { status: 'ready', trustMode: approval.trustMode };
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
return { runGate };
|
|
@@ -3,13 +3,14 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
import { createAppHost } from './app-host.js';
|
|
5
5
|
import { grantableTools } from './authorization.js';
|
|
6
|
+
import { appConflict } from './errors.js';
|
|
6
7
|
import { createHostIdentity } from './host-identity.js';
|
|
7
8
|
import { fuliHostTools } from './host-tools/fuli-tools.js';
|
|
8
9
|
import { createAppInstances } from './instances.js';
|
|
9
|
-
import { NO_ISOLATION } from './isolation.js';
|
|
10
10
|
import { createAppOperations } from './operations.js';
|
|
11
11
|
import { createOwnerLeases } from './owner-lease.js';
|
|
12
12
|
import { createAppRemoval } from './removal.js';
|
|
13
|
+
import { createTrustedRunner } from './trusted-runner.js';
|
|
13
14
|
import { AgentAppStore } from './store.js';
|
|
14
15
|
import { createAppVersions } from './versions.js';
|
|
15
16
|
import { createAppViews } from './views.js';
|
|
@@ -29,8 +30,8 @@ export function createAgentAppService(options) {
|
|
|
29
30
|
return agentAppServiceOver(agentAppContext(options));
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
// The CLI builds the context itself to add its
|
|
33
|
-
// (
|
|
33
|
+
// The CLI builds the context itself to add its terminal-confirmed decisions
|
|
34
|
+
// (confirmed-decisions.js) over the same registry.
|
|
34
35
|
export function agentAppServiceOver(context) {
|
|
35
36
|
const host = createAppHost(context);
|
|
36
37
|
return {
|
|
@@ -41,29 +42,52 @@ export function agentAppServiceOver(context) {
|
|
|
41
42
|
stop: context.instances.stop,
|
|
42
43
|
authorizeCall: host.authorizeCall,
|
|
43
44
|
callTool: host.callTool,
|
|
44
|
-
close: () =>
|
|
45
|
-
context.leases.close();
|
|
46
|
-
context.store.close();
|
|
47
|
-
}
|
|
45
|
+
close: () => closeContext(context)
|
|
48
46
|
};
|
|
49
47
|
}
|
|
50
48
|
|
|
49
|
+
// Closes once, however often it is asked: the instances this process holds
|
|
50
|
+
// are sealed and their processes stopped (instances.js) before the leases and
|
|
51
|
+
// the registry close. With nothing hosted or in flight the registry closes
|
|
52
|
+
// before this returns. Only a close that left nothing held or in flight is
|
|
53
|
+
// kept as done. One that could not confirm every app process stopped (a stop
|
|
54
|
+
// that failed, a late start's handle among them, or a start still in flight)
|
|
55
|
+
// rejects with close_incomplete and names them; their handles stay held, the
|
|
56
|
+
// records stay for the next owner's reconcile, and asking again retries those stops.
|
|
57
|
+
function closeContext(context) {
|
|
58
|
+
const finish = () => {
|
|
59
|
+
context.leases.close();
|
|
60
|
+
context.store.close();
|
|
61
|
+
};
|
|
62
|
+
if (!context.closed) {
|
|
63
|
+
const idle = context.instances.idle();
|
|
64
|
+
const ending = context.instances.close();
|
|
65
|
+
if (idle) finish();
|
|
66
|
+
context.closed = idle ? Promise.resolve() : ending.finally(finish).then((result) => {
|
|
67
|
+
if (result.complete) return;
|
|
68
|
+
context.closed = null;
|
|
69
|
+
throw appConflict('close_incomplete', 'FULI closed the registry but could not confirm that every app process it '
|
|
70
|
+
+ 'started has stopped; close again to retry, or end those processes yourself', result);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return context.closed;
|
|
74
|
+
}
|
|
75
|
+
|
|
51
76
|
// One context is one FULI process's view of the registry: its owner lease
|
|
52
77
|
// identity (ownerKind: console, standalone or cli) and its in-process write
|
|
53
|
-
// gates.
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
// for synthetic tests.
|
|
78
|
+
// gates. runner: what instances run in (trusted-runner.js: this version has
|
|
79
|
+
// no sandbox, so an approved app runs with the user's own permissions).
|
|
80
|
+
// callFuliTool runs a granted FULI Agent tool for an app; hostTools,
|
|
81
|
+
// hostIdentity, dataFs, wait, closeWaitMs and timers are seams for synthetic tests.
|
|
58
82
|
export function agentAppContext({
|
|
59
|
-
root, providerIdentity = null, resolveOwner = null, toolNames, clock = () => new Date(),
|
|
60
|
-
|
|
61
|
-
hostTools = null, fs = dataFs, wait, timers
|
|
83
|
+
root, providerIdentity = null, resolveOwner = null, toolNames, clock = () => new Date(), ownerKind = 'cli',
|
|
84
|
+
hostIdentity = createHostIdentity(), runner = createTrustedRunner({ hostIdentity }), callFuliTool = null,
|
|
85
|
+
hostTools = null, fs = dataFs, wait, closeWaitMs, timers
|
|
62
86
|
}) {
|
|
63
87
|
const store = new AgentAppStore(join(root, 'registry.sqlite'));
|
|
64
88
|
const now = () => clock().toISOString();
|
|
65
89
|
const context = {
|
|
66
|
-
store, clock, now, resolveOwner,
|
|
90
|
+
store, clock, now, resolveOwner, runner, wait, closeWaitMs, dataFs: fs,
|
|
67
91
|
provider: providerIdentity === null ? null : String(providerIdentity).replace(/\/+$/, ''),
|
|
68
92
|
packagesOf: (appId) => join(root, 'packages', appId),
|
|
69
93
|
packageOf: (appId, version) => join(root, 'packages', appId, version),
|
package/src/agent-apps/store.js
CHANGED
|
@@ -177,28 +177,31 @@ export class AgentAppStore {
|
|
|
177
177
|
appId: row.app_id, version: row.version, digest: row.digest, permissions: JSON.parse(row.permissions),
|
|
178
178
|
data: JSON.parse(row.data), resident: row.resident === 1, approvedBy: row.approved_by,
|
|
179
179
|
entrypoint: row.entrypoint, presence: row.presence, verification: row.verification,
|
|
180
|
-
challengeId: row.challenge_id, verifiedAt: row.verified_at,
|
|
180
|
+
challengeId: row.challenge_id, verifiedAt: row.verified_at, trustMode: row.trust_mode, termsVersion: row.terms_version,
|
|
181
|
+
approvedAt: row.approved_at
|
|
181
182
|
} : null;
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
// check: the
|
|
185
|
+
// check: the confirmation of the decision ({ presence, verification, challengeId, verifiedAt, trustMode, termsVersion }).
|
|
185
186
|
insertApproval({ appId, version, digest, permissions, data, resident, approvedBy, entrypoint, approvedAt }, check) {
|
|
186
187
|
this.database.prepare(`INSERT INTO agent_app_approvals (app_id, version, digest, permissions, data, resident,
|
|
187
|
-
approved_by, entrypoint, presence, verification, challenge_id, verified_at, approved_at)
|
|
188
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
188
|
+
approved_by, entrypoint, presence, verification, challenge_id, verified_at, trust_mode, terms_version, approved_at)
|
|
189
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
189
190
|
.run(appId, version, digest, JSON.stringify(permissions), JSON.stringify(data), resident ? 1 : 0,
|
|
190
|
-
approvedBy, entrypoint, check.presence, check.verification, check.challengeId, check.verifiedAt,
|
|
191
|
+
approvedBy, entrypoint, check.presence, check.verification, check.challengeId, check.verifiedAt,
|
|
192
|
+
check.trustMode, check.termsVersion, approvedAt);
|
|
191
193
|
}
|
|
192
194
|
|
|
193
|
-
// Every activation rewrites the
|
|
194
|
-
//
|
|
195
|
+
// Every activation rewrites the confirmation of the version it activates, so
|
|
196
|
+
// a confirmation made for an earlier activation never carries over to a later one.
|
|
195
197
|
setApprovalCheck(appId, version, check) {
|
|
196
|
-
this.database.prepare(`UPDATE agent_app_approvals SET presence = ?, verification = ?, challenge_id = ?, verified_at =
|
|
197
|
-
WHERE app_id = ? AND version = ?`)
|
|
198
|
-
.run(check.presence, check.verification, check.challengeId, check.verifiedAt,
|
|
198
|
+
this.database.prepare(`UPDATE agent_app_approvals SET presence = ?, verification = ?, challenge_id = ?, verified_at = ?,
|
|
199
|
+
trust_mode = ?, terms_version = ? WHERE app_id = ? AND version = ?`)
|
|
200
|
+
.run(check.presence, check.verification, check.challengeId, check.verifiedAt, check.trustMode, check.termsVersion,
|
|
201
|
+
appId, version);
|
|
199
202
|
}
|
|
200
203
|
|
|
201
|
-
// One open
|
|
204
|
+
// One open confirmation challenge per app; issuing another replaces it.
|
|
202
205
|
challenge(appId) {
|
|
203
206
|
const row = this.database.prepare(`SELECT challenge_id, challenge_nonce_hash, challenge_decision, challenge_terms,
|
|
204
207
|
challenge_expires_at, challenge_consumed_at FROM agent_apps WHERE app_id = ?`).get(appId);
|
|
@@ -227,10 +230,10 @@ export class AgentAppStore {
|
|
|
227
230
|
WHERE app_id = ? AND challenge_id = ? AND challenge_claim = ?`).run(appId, challengeId, claim).changes) === 1;
|
|
228
231
|
}
|
|
229
232
|
|
|
230
|
-
// Whether the history records this challenge consumed by a
|
|
231
|
-
|
|
233
|
+
// Whether the history records this challenge consumed by a completed terminal confirmation.
|
|
234
|
+
challengeConfirmed(appId, challengeId) {
|
|
232
235
|
return Boolean(this.database.prepare(`SELECT 1 FROM agent_app_events WHERE app_id = ? AND action = 'challenge_consumed'
|
|
233
|
-
AND json_extract(detail, '$.challengeId') = ? AND json_extract(detail, '$.outcome') = '
|
|
236
|
+
AND json_extract(detail, '$.challengeId') = ? AND json_extract(detail, '$.outcome') = 'confirmed' LIMIT 1`)
|
|
234
237
|
.get(appId, challengeId));
|
|
235
238
|
}
|
|
236
239
|
|
|
@@ -379,6 +382,17 @@ export const AGENT_APP_FORMAT = sqliteFormat({
|
|
|
379
382
|
// Asked before the column exists, so every existing app needs it.
|
|
380
383
|
backfillKeys: (database) => database.prepare('SELECT app_id FROM agent_apps ORDER BY app_id').all().map((row) => row.app_id),
|
|
381
384
|
backfill: (database) => database.exec('UPDATE agent_apps SET identity_key = substr(app_id, 5, 32)')
|
|
385
|
+
}, {
|
|
386
|
+
// rec#11 D-36.2/D-36.9: this version has no sandbox, so an approved app runs
|
|
387
|
+
// in trusted mode (trust-terms.js). Every approval made before it (the
|
|
388
|
+
// isolated mode of rec#7 PR①, Windows Hello approvals included) keeps NULL
|
|
389
|
+
// here, and the run gate asks for a new terminal confirmation: consent to
|
|
390
|
+
// code that was to run isolated is not consent to run it with the user's
|
|
391
|
+
// own permissions, so it is never converted.
|
|
392
|
+
id: 'agent-apps/8-approval-trust-mode', to: 8, kind: 'add-columns', table: 'agent_app_approvals',
|
|
393
|
+
summary: 'the trust mode and terms version an approval was confirmed under; an earlier approval (isolated mode, '
|
|
394
|
+
+ 'Windows Hello included) has none, so its version is confirmed again before it runs',
|
|
395
|
+
columns: { trust_mode: 'TEXT', terms_version: 'INTEGER' }
|
|
382
396
|
}]
|
|
383
397
|
});
|
|
384
398
|
|