fuli-context 0.20.1 → 0.21.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-CjDenGS_.js → AboutPage-D0dTwKq8.js} +1 -1
- package/dist/web/assets/{AgentName-DdlJlpT3.js → AgentName-n4oqQUwE.js} +1 -1
- package/dist/web/assets/{AgentProfilePage-Cx_Uf5Vf.js → AgentProfilePage-DH54S93r.js} +1 -1
- package/dist/web/assets/{AgentsDirectoryPage-DylT-GSW.js → AgentsDirectoryPage-xwIRrNb8.js} +1 -1
- package/dist/web/assets/{BackLink-D7oAvDG5.js → BackLink-nM3e40IT.js} +1 -1
- package/dist/web/assets/{BoardMoveMenu-B0pA7LLx.js → BoardMoveMenu-Cxgkbwkl.js} +1 -1
- package/dist/web/assets/{CaptureChangePage-DEuqPb14.js → CaptureChangePage-DWdz9dEk.js} +1 -1
- package/dist/web/assets/{Card-BZFLZ_2I.js → Card-89NKHANE.js} +1 -1
- package/dist/web/assets/{CardHeader-C_c0keQn.js → CardHeader-9MwjWRxl.js} +1 -1
- package/dist/web/assets/{CardTitle-yXOhV577.js → CardTitle-BAhmXjAK.js} +1 -1
- package/dist/web/assets/{ConnectionsPage-DlnHdtwn.js → ConnectionsPage-Yf4UvjDT.js} +1 -1
- package/dist/web/assets/{CreateProjectDialog-BVJqWdlT.js → CreateProjectDialog-crpLTyDf.js} +1 -1
- package/dist/web/assets/{DataFormatPage-BdcjcyhZ.js → DataFormatPage-BPuUH0PG.js} +1 -1
- package/dist/web/assets/{DialogFooter-DYawfDCD.js → DialogFooter-D9A9hRP4.js} +1 -1
- package/dist/web/assets/{EmployeeRecruitDialog-CB4ARFkM.js → EmployeeRecruitDialog-DeB0XHeM.js} +1 -1
- package/dist/web/assets/EmployeeWorkbenchPage-0oK2RfIh.js +3 -0
- package/dist/web/assets/{EmployeeWorkbenchPage-BenZP7De.css → EmployeeWorkbenchPage-CMutwFBC.css} +1 -1
- package/dist/web/assets/{GrowthLoading-smW3-Gfp.js → GrowthLoading-Cs9brXcN.js} +1 -1
- package/dist/web/assets/{InboxPage-Crn1UU7s.js → InboxPage-CTQ425Ez.js} +1 -1
- package/dist/web/assets/{Input-F1oftPWh.js → Input-DGf4juEs.js} +1 -1
- package/dist/web/assets/{KnowledgeEditDialog-VdQwbX4E.js → KnowledgeEditDialog-Ccgj30Wu.js} +1 -1
- package/dist/web/assets/{KnowledgeHardDeleteSection-CXRmNnZF.js → KnowledgeHardDeleteSection-CSnqisUv.js} +1 -1
- package/dist/web/assets/{KnowledgeItemEditPage-CQo3TbCJ.js → KnowledgeItemEditPage-C0Y2DsHz.js} +1 -1
- package/dist/web/assets/{KnowledgeItemSummaryCard-Dd2McM-d.js → KnowledgeItemSummaryCard-BRvaf4Fw.js} +1 -1
- package/dist/web/assets/{KnowledgeOrganizerPage-BVgAyu6U.js → KnowledgeOrganizerPage-CRC3mk0j.js} +1 -1
- package/dist/web/assets/KnowledgePage-NsKFUWth.js +1 -0
- package/dist/web/assets/{KnowledgePeek-BNBkh1ey.js → KnowledgePeek-Bc0bqyZp.js} +1 -1
- package/dist/web/assets/{KnowledgeTurnReceiptPage-Ckw_olrt.js → KnowledgeTurnReceiptPage-Dl0KeFDe.js} +1 -1
- package/dist/web/assets/{KnowledgeWorkspace-pH2tAFld.js → KnowledgeWorkspace-BGlODG7G.js} +1 -1
- package/dist/web/assets/{Label-yDCtlpkb.js → Label-CafdTnDF.js} +1 -1
- package/dist/web/assets/ModelSettingsPage-Bz1tMXtW.js +1 -0
- package/dist/web/assets/ModelSettingsPage-DJuEaw6p.css +1 -0
- package/dist/web/assets/{NotFoundPage-8gVVukRR.js → NotFoundPage-TfZ2eoA2.js} +1 -1
- package/dist/web/assets/{OccupationsPage-PNoqE21Y.js → OccupationsPage-CnSp6362.js} +1 -1
- package/dist/web/assets/{OverviewPage-DiwYSnhh.js → OverviewPage-D5W-DhOz.js} +2 -2
- package/dist/web/assets/{PersonalProfilePage-C_v2BFee.js → PersonalProfilePage-CndOcRQ6.js} +1 -1
- package/dist/web/assets/{PersonalProjectsPage-DGRV8cM5.js → PersonalProjectsPage-CXBOwEqC.js} +1 -1
- package/dist/web/assets/{PopperContent-5zqbtnYr.js → PopperContent-BXbztFFi.js} +1 -1
- package/dist/web/assets/{Presence-BYfYJNMD.js → Presence-BLar6FCs.js} +1 -1
- package/dist/web/assets/{ProjectAgentDetailPage-BQ9ffaCX.js → ProjectAgentDetailPage-SmZ2NYTw.js} +1 -1
- package/dist/web/assets/{ProjectAgentDialog-BGckQDTq.js → ProjectAgentDialog-Bg0V3Zr2.js} +1 -1
- package/dist/web/assets/{ProjectAgentFirstTask-DrSd3nR-.js → ProjectAgentFirstTask-CbOWaP7Q.js} +1 -1
- package/dist/web/assets/{ProjectAgentsPage-U4Om3EPu.js → ProjectAgentsPage-Y6qCYRZj.js} +1 -1
- package/dist/web/assets/{ProjectScopePicker-D0oxbwOd.js → ProjectScopePicker-ClDUoUHW.js} +1 -1
- package/dist/web/assets/{PublicProjectsPage-CvkQ3E8I.js → PublicProjectsPage-C63vW9UZ.js} +1 -1
- package/dist/web/assets/{RadioGroupItem-CBpbQlHx.js → RadioGroupItem-tL_2upmD.js} +1 -1
- package/dist/web/assets/{RoundtablesPage-BEUaKOjI.js → RoundtablesPage-2Akxagrm.js} +1 -1
- package/dist/web/assets/{RovingFocusGroup-X9U-ufYr.js → RovingFocusGroup-D5mf9s6I.js} +1 -1
- package/dist/web/assets/{RovingFocusItem-_uA_OCLT.js → RovingFocusItem-DAumq9xD.js} +1 -1
- package/dist/web/assets/{SessionMigrationPage-WVFSDcUO.js → SessionMigrationPage-B5r2PWCF.js} +1 -1
- package/dist/web/assets/{SessionRecordsPage-Bs2eLXEi.js → SessionRecordsPage-DIc2GoCQ.js} +1 -1
- package/dist/web/assets/{SettingsPage-DlIwICIz.js → SettingsPage-BAxKpnBx.js} +1 -1
- package/dist/web/assets/{SharedJefaReportPage-B_rreEep.js → SharedJefaReportPage-B54qEdIV.js} +1 -1
- package/dist/web/assets/{TabsContent-8pXwYJPz.js → TabsContent-DZQE2Iq8.js} +1 -1
- package/dist/web/assets/{TabsTrigger-Cd6SI2yI.js → TabsTrigger-CHnq6mkI.js} +1 -1
- package/dist/web/assets/{TagVocabularyPage-BQiuKG-4.js → TagVocabularyPage-BIsHYk2i.js} +1 -1
- package/dist/web/assets/{TaskExecutionPlan-CupxJeyo.js → TaskExecutionPlan-IYG_JeuT.js} +1 -1
- package/dist/web/assets/{TaskSchedulesPage-zYQs7s6T.js → TaskSchedulesPage-Cxjqc8XQ.js} +1 -1
- package/dist/web/assets/{Teleport-BZX1Eb7R.js → Teleport-BKN3dSMk.js} +1 -1
- package/dist/web/assets/{TextField-CielK4l3.js → TextField-DoKtn--E.js} +1 -1
- package/dist/web/assets/{UiDialog-BSDblUpR.js → UiDialog-7pnZ-eQA.js} +1 -1
- package/dist/web/assets/{UiDisclosure-DLmVwmy1.js → UiDisclosure-COV4NwHI.js} +1 -1
- package/dist/web/assets/{UiIcon-B8eZeuGI.js → UiIcon-BADOYtHM.js} +1 -1
- package/dist/web/assets/{UiIconButton-e754Tmnq.js → UiIconButton-CkBP6pnX.js} +1 -1
- package/dist/web/assets/{UiSegmented-D1HD-qin.js → UiSegmented-FwOnE2IZ.js} +1 -1
- package/dist/web/assets/{UiSelect-CbkTsi2e.js → UiSelect-BIhr03Gk.js} +1 -1
- package/dist/web/assets/{UiToggle-Dz93aXFK.js → UiToggle-bpyawyIe.js} +1 -1
- package/dist/web/assets/{UiWeight-CUvyApSB.js → UiWeight-TyBehy3K.js} +1 -1
- package/dist/web/assets/{UnassignedConversationsPanel-xY7gsFot.js → UnassignedConversationsPanel-B4PqImRi.js} +1 -1
- package/dist/web/assets/{VirtualDirectoryList-Dv6PwLjU.js → VirtualDirectoryList-DNQP6X8j.js} +1 -1
- package/dist/web/assets/{Workbench3D--4N_uKzp.js → Workbench3D-DNwgymIE.js} +1 -1
- package/dist/web/assets/{WritingTastePage-B7KojA4r.js → WritingTastePage-D-ELo7mh.js} +1 -1
- package/dist/web/assets/{_plugin-vue_export-helper-BmfQlfI8.js → _plugin-vue_export-helper-RegzAV-H.js} +1 -1
- package/dist/web/assets/{accordion-gXElbGP_.js → accordion-DpqAdXTB.js} +1 -1
- package/dist/web/assets/{agent-occupation-ChN-1QjC.js → agent-occupation-Ba5Fl0ys.js} +1 -1
- package/dist/web/assets/{agent-pins-Chh_rdBi.js → agent-pins-Bb7-1Uoz.js} +1 -1
- package/dist/web/assets/{agent-profile.css_vue_type_style_index_0_src_true_lang-DWlz7UoN.js → agent-profile.css_vue_type_style_index_0_src_true_lang-wT8gjVyZ.js} +1 -1
- package/dist/web/assets/{agent-work-summary-C9yMf019.js → agent-work-summary-D0a836ik.js} +1 -1
- package/dist/web/assets/{attention-store-CG9cF6DX.js → attention-store-g2-_vAhV.js} +1 -1
- package/dist/web/assets/{badge-DvvDq2Wb.js → badge-BIoC0hjn.js} +1 -1
- package/dist/web/assets/{button-CFEnxtio.js → button-A2esxd6G.js} +1 -1
- package/dist/web/assets/{checkbox-DovdRz8u.js → checkbox-DxBVlC6t.js} +1 -1
- package/dist/web/assets/{client-lh80ewvs.js → client-DAoXcTUz.js} +1 -1
- package/dist/web/assets/{console-CQMgYkk9.js → console-DiNe1hFP.js} +1 -1
- package/dist/web/assets/{conversation-launcher-settings-B1QM-wZB.js → conversation-launcher-settings-CtOlr9uP.js} +1 -1
- package/dist/web/assets/{design-lab-BDKwIbI8.js → design-lab-UWXx2ZtA.js} +1 -1
- package/dist/web/assets/{dialog-D2mO6m3B.js → dialog-DTVE8tN1.js} +1 -1
- package/dist/web/assets/{dist-PmK0PfVA.js → dist-D-8b3yGa.js} +1 -1
- package/dist/web/assets/{dropdown-menu-YzCnvjAb.js → dropdown-menu-NcUrhhmG.js} +1 -1
- package/dist/web/assets/{field-BMEFEyVC.js → field-6mg5DSC8.js} +1 -1
- package/dist/web/assets/{identity-bK-fJdnj.js → identity-FG3YqHVj.js} +1 -1
- package/dist/web/assets/index-BpQe3IT5.js +2 -0
- package/dist/web/assets/{judgment-types-DJnAr9c0.js → judgment-types-rLsl2Cis.js} +1 -1
- package/dist/web/assets/{model-Cengn9fg.js → model-BCnsjEuP.js} +1 -1
- package/dist/web/assets/{model-rumuELTi.js → model-BcMr6R8m.js} +1 -1
- package/dist/web/assets/{model-DpVrfbnj.js → model-CYJ_LZ47.js} +1 -1
- package/dist/web/assets/{model-BwNZZZNP.js → model-CeF2BATq.js} +1 -1
- package/dist/web/assets/{model-CuY1vtEy.js → model-CtmCtjml.js} +1 -1
- package/dist/web/assets/{model-CPMYnu3S.js → model-t2ZvD7wL.js} +1 -1
- package/dist/web/assets/{motion-preference-A1AMssSH.js → motion-preference-DeZURhN7.js} +1 -1
- package/dist/web/assets/{occupation-catalog-DxwlYD1L.js → occupation-catalog-q0ZjGx2o.js} +1 -1
- package/dist/web/assets/{orchestration-filters-DZpJ0FN3.js → orchestration-filters-CKf_Gzdl.js} +1 -1
- package/dist/web/assets/{page-title-Bg-mVyrS.js → page-title-BLHrexaP.js} +1 -1
- package/dist/web/assets/{personal-profile-graph-tMneNj_m.js → personal-profile-graph-IYovB9sV.js} +1 -1
- package/dist/web/assets/{project-capture-QgMw6qvo.js → project-capture-BvIPecIS.js} +1 -1
- package/dist/web/assets/{project-origin-ppsYHpYL.js → project-origin-JnGPwlfA.js} +1 -1
- package/dist/web/assets/project-team-api-Cfn41MCR.js +1 -0
- package/dist/web/assets/{quick-edit-api-BiyK3ih-.js → quick-edit-api-DzpRAPsr.js} +1 -1
- package/dist/web/assets/{shared-report-D3Hem1t5.js → shared-report-BLmBg2FG.js} +3 -3
- package/dist/web/assets/{task-labels-7KyNw9id.js → task-labels-BArOYZEW.js} +1 -1
- package/dist/web/assets/{ui-Ck58paqr.js → ui-CtW0tAA1.js} +1 -1
- package/dist/web/assets/{useAgentRecords-C6RrZwwv.js → useAgentRecords-BoOqLQcf.js} +1 -1
- package/dist/web/assets/{useApi-CROJJdhE-BujjnKN_.js → useApi-CROJJdhE-CH5wlWTU.js} +1 -1
- package/dist/web/assets/{useFocusReturn-D9IOIg17.js → useFocusReturn-DX2zmPSK.js} +1 -1
- package/dist/web/assets/{useKnowledgeItemPeek-C6nAzvDL.js → useKnowledgeItemPeek-Cfvr5H1q.js} +1 -1
- package/dist/web/assets/{useMinimumLoadingDisplay-HnxkDut6.js → useMinimumLoadingDisplay-GhG1ICNJ.js} +1 -1
- package/dist/web/assets/{useRoutePeek-BvYFc1BA.js → useRoutePeek-DydCbUhy.js} +1 -1
- package/dist/web/assets/{vue-router-Bl55c88B.js → vue-router-Dad-4p7O.js} +1 -1
- package/dist/web/index.html +32 -32
- package/docs/agent-conversations-and-collaboration.md +10 -0
- package/docs/employee-agents.md +3 -1
- package/docs/judgment-and-autonomy.md +30 -1
- package/graph-provider/fuli_graph/agent_conversation_models.py +7 -0
- package/graph-provider/fuli_graph/agent_conversation_routes.py +5 -1
- package/graph-provider/fuli_graph/default_project_lead.py +7 -3
- package/graph-provider/fuli_graph/store_agent_conversations.py +66 -34
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/roundtable/src/host.js +5 -0
- package/packages/roundtable/src/peer/coordinator-service.js +20 -3
- package/packages/roundtable/src/roundtable/service.js +31 -5
- package/skills/capturing-session-knowledge/references/retrieval.md +10 -2
- package/skills/operating-fuli/references/workflow-recipes.md +2 -0
- package/src/agent-apps/host-tools/catalog.js +1 -0
- package/src/agent-tools/executor-routing-definitions.js +194 -0
- package/src/agent-tools/graph-definitions.js +20 -1279
- package/src/agent-tools/graph-handlers.js +6 -2
- package/src/agent-tools/graph-tool-fields.js +43 -0
- package/src/agent-tools/interface-catalog.js +5 -1
- package/src/agent-tools/knowledge-curation-definitions.js +167 -0
- package/src/agent-tools/knowledge-definitions.js +431 -0
- package/src/agent-tools/project-agent-tool-definitions.js +271 -0
- package/src/agent-tools/project-space-definitions.js +155 -0
- package/src/agent-tools/session-fuli-gate.js +33 -31
- package/src/agent-tools/standing-assignment-definitions.js +32 -0
- package/src/agent-tools/task-entry-definitions.js +105 -0
- package/src/agent-tools.js +5 -4
- package/src/agents/claude-code/lifecycle-hook.js +16 -2
- package/src/agents/claude-code/preference-evidence.js +11 -1
- package/src/app/application-error.js +21 -3
- package/src/conversations/capture-window.js +8 -3
- package/src/conversations/entry-budget.js +2 -10
- package/src/conversations/entry-inline-budget.js +144 -0
- package/src/conversations/entry-rules.js +1 -1
- package/src/conversations/entry-time.js +15 -0
- package/src/conversations/preference-evidence.js +19 -0
- package/src/conversations/preference-lifecycle.js +28 -7
- package/src/conversations/preference-session.js +26 -10
- package/src/conversations/preference-snapshot.js +12 -1
- package/src/conversations/sync-transcript.js +10 -6
- package/src/conversations/transcript-guard.js +4 -3
- package/src/conversations/transcript-lifecycle.js +6 -3
- package/src/data-format/local-stores.js +3 -0
- package/src/desktop/windows-installation.js +2 -1
- package/src/external-knowledge/connectors/feishu.js +3 -1
- package/src/graphiti/active-personal-space.js +5 -0
- package/src/graphiti/agent-conversations.js +23 -28
- package/src/graphiti/agent-knowledge-workflows.js +12 -1299
- package/src/graphiti/agent-project-resolution.js +11 -0
- package/src/graphiti/agent-view-records.js +19 -0
- package/src/graphiti/capture-notice.js +20 -6
- package/src/graphiti/collaboration-preference-entry.js +89 -0
- package/src/graphiti/collaboration-preference-workflow.js +1 -1
- package/src/graphiti/common-knowledge-candidates.js +222 -0
- package/src/graphiti/cross-project-knowledge-similarity.js +59 -0
- package/src/graphiti/current-project-knowledge-search.js +86 -0
- package/src/graphiti/decision-trace.js +136 -0
- package/src/graphiti/federated-application.js +158 -795
- package/src/graphiti/human-knowledge-changes.js +45 -0
- package/src/graphiti/knowledge-credential-guard.js +43 -0
- package/src/graphiti/knowledge-curation.js +178 -0
- package/src/graphiti/knowledge-feedback.js +25 -0
- package/src/graphiti/knowledge-graph-reads.js +62 -0
- package/src/graphiti/local-runtimes.js +78 -0
- package/src/graphiti/personal-global-preference-candidates.js +431 -0
- package/src/graphiti/personal-projects.js +33 -0
- package/src/graphiti/preference-conflict-requests.js +57 -0
- package/src/graphiti/preference-project-resolution.js +39 -0
- package/src/graphiti/preference-task-scope.js +18 -0
- package/src/graphiti/project-agent-control-plane.js +6 -1
- package/src/graphiti/project-agent-task-entry.js +18 -1
- package/src/graphiti/project-path-context.js +28 -9
- package/src/graphiti/provider-client.js +1 -1
- package/src/graphiti/public-project-relations.js +28 -0
- package/src/graphiti/public-projects.js +125 -0
- package/src/graphiti/publication-review-queues.js +50 -0
- package/src/graphiti/roundtable-host.js +35 -3
- package/src/graphiti/session-capture-pause-request.js +3 -2
- package/src/graphiti/session-fuli-switch.js +4 -3
- package/src/graphiti/session-knowledge-capture.js +59 -0
- package/src/graphiti/session-records.js +4 -3
- package/src/graphiti/source-marker.js +13 -3
- package/src/graphiti/standing-assignment-confirmation.js +66 -0
- package/src/graphiti/standing-assignment-correction.js +148 -0
- package/src/graphiti/standing-assignment-entry.js +223 -0
- package/src/graphiti/task-context-entry.js +114 -0
- package/src/graphiti/task-entry-preferences.js +4 -1
- package/src/graphiti/task-entry-project-mention.js +13 -2
- package/src/graphiti/task-entry-project-scope.js +12 -3
- package/src/graphiti/task-entry-standing-owner.js +141 -0
- package/src/graphiti/task-knowledge-checkpoint.js +212 -0
- package/src/graphiti/task-knowledge-guidance.js +13 -0
- package/src/graphiti/task-knowledge-recall.js +113 -2
- package/src/graphiti/task-preference-reader.js +1 -1
- package/src/graphiti/workflow-learning.js +38 -0
- package/src/graphiti/workspace-provider-client.js +10 -0
- package/src/http/api-router.js +13 -3
- package/src/http/standing-assignment-api-router.js +35 -0
- package/src/judgment/agent-view.js +29 -7
- package/src/judgment/conversation.js +8 -2
- package/src/judgment/engine.js +16 -4
- package/src/judgment/http.js +37 -5
- package/src/judgment/review-injection-precheck.js +97 -0
- package/src/judgment/review-suggestions.js +46 -0
- package/src/judgment/store.js +8 -0
- package/src/knowledge-hard-delete/delete-ledger.js +12 -3
- package/src/knowledge-hard-delete/recovery-gate.js +4 -4
- package/src/knowledge-owner-reads/console-port.js +8 -0
- package/src/knowledge-owner-reads/owner-proof.js +35 -0
- package/src/local-runtime/lifecycle.js +2 -1
- package/src/local-runtime/provider-readiness.js +35 -11
- package/src/mcp/instructions.js +3 -3
- package/src/mcp/preference-delivery.js +13 -3
- package/src/mcp/session-id.js +2 -0
- package/src/mcp/tool-annotations.js +3 -2
- package/src/model-backends/http.js +45 -8
- package/src/model-backends/role-settings.js +25 -3
- package/src/model-backends/role-trust.js +39 -6
- package/src/model-backends/runtime.js +10 -3
- package/src/model-backends/settings-history-list.js +132 -0
- package/src/model-backends/settings-history.js +175 -0
- package/src/native-runtime/java-runtime.js +4 -4
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/semantic-version.js +5 -1
- package/src/server.js +3 -2
- package/src/setup/claude-code-config.js +1 -1
- package/src/setup/graph-runtime.js +42 -15
- package/src/setup/paths.js +2 -0
- package/src/standing-assignments/port.js +189 -44
- package/src/standing-assignments/store.js +12 -1
- package/src/standing-assignments/term-match.js +7 -0
- package/src/system/file-identity.js +11 -0
- package/src/system/platform-path.js +38 -0
- package/src/validation/values.js +22 -6
- package/dist/web/assets/EmployeeWorkbenchPage-BUMfMBc8.js +0 -3
- package/dist/web/assets/KnowledgePage-Bfbfz_Z8.js +0 -1
- package/dist/web/assets/ModelSettingsPage-C3eBDWRL.js +0 -1
- package/dist/web/assets/ModelSettingsPage-DZkrJw7R.css +0 -1
- package/dist/web/assets/index-r-WFOs21.js +0 -2
- package/dist/web/assets/project-team-api-DwP0O3rn.js +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ApplicationError, ApplicationErrorCode } from '../app/application-error.js';
|
|
2
|
+
import { requiredString } from '../validation/values.js';
|
|
3
|
+
import { loadProjectTeam } from './project-team-view.js';
|
|
4
|
+
import { assertPreviewed, leadName, personsConversation, previewOf, projectNamed, quoted,
|
|
5
|
+
standingAssignmentsOf } from './standing-assignment-confirmation.js';
|
|
6
|
+
import { nameableProjects, projectDisplayName } from './task-entry-project-mention.js';
|
|
7
|
+
|
|
8
|
+
// The person corrects or ends a standing assignment (rec#29 F5, D-41 D7):
|
|
9
|
+
// retire stops it routing and frees its terms, reassign points it with its
|
|
10
|
+
// terms at another Agent of its project or at another project, edit_terms
|
|
11
|
+
// adds or removes terms. In a conversation the assignment is named by one of
|
|
12
|
+
// its terms and the change goes through preview and confirm like its
|
|
13
|
+
// registration; in the local console the person acted on the record they
|
|
14
|
+
// read, so its revision stands in for the digest. Either way the change is
|
|
15
|
+
// the person's (source user), recorded as a new revision. The project's own
|
|
16
|
+
// lead never changes, and routing and find_agents read the store, so they
|
|
17
|
+
// follow at once. A change already in place, such as a confirm sent again
|
|
18
|
+
// after it was saved, is answered unchanged before any digest or revision.
|
|
19
|
+
|
|
20
|
+
const TERM_LIMIT = 80;
|
|
21
|
+
const PROJECT_NAME_LIMIT = 80;
|
|
22
|
+
const ID_LIMIT = 200;
|
|
23
|
+
const NOTHING_TO_CHANGE = 'The standing assignment already is as asked; there is nothing to change.';
|
|
24
|
+
|
|
25
|
+
export async function correctStandingAssignment(application, input) {
|
|
26
|
+
const plan = await correctionPlan(application, input);
|
|
27
|
+
if (plan.inPlace) {
|
|
28
|
+
return { status: 'unchanged', executed: false, assignment: plan.assignment, restatement: NOTHING_TO_CHANGE };
|
|
29
|
+
}
|
|
30
|
+
if (input.action === 'preview') return previewOf(plan, planView(plan), restatement(plan));
|
|
31
|
+
assertPreviewed(input, plan);
|
|
32
|
+
// The plan was read across Provider awaits: the new Agent is read again
|
|
33
|
+
// last, with nothing awaited between it and the write.
|
|
34
|
+
if (plan.change === 'reassign') await assertStillOnTeam(application, plan.correction);
|
|
35
|
+
return { ...standingAssignmentsOf(application).correct(plan.assignmentId, plan.correction,
|
|
36
|
+
{ source: 'user', sourceConversationId: plan.sourceConversationId, expectedRevision: plan.revision }),
|
|
37
|
+
executed: false };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The console's change of the assignment it shows, at the revision it showed.
|
|
41
|
+
export async function correctStandingAssignmentInConsole(application, { assignmentId, action, expectedRevision,
|
|
42
|
+
projectId, leadAgentId, addTerms, removeTerms }) {
|
|
43
|
+
const port = standingAssignmentsOf(application);
|
|
44
|
+
const correction = action === 'reassign'
|
|
45
|
+
? { action, ...await reassignmentTarget(application, requiredString(projectId, 'projectId', ID_LIMIT), leadAgentId) }
|
|
46
|
+
: { action, addTerms, removeTerms };
|
|
47
|
+
return port.correct(assignmentId, correction, { source: 'user', sourceConversationId: null, expectedRevision });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function correctionPlan(application, input) {
|
|
51
|
+
const port = standingAssignmentsOf(application);
|
|
52
|
+
const task = await personsConversation(application, input);
|
|
53
|
+
const spaceId = application.config.personal.spaceId;
|
|
54
|
+
const term = requiredString(input.term, 'term', TERM_LIMIT);
|
|
55
|
+
// A term no active assignment holds may name the one a correction already changed.
|
|
56
|
+
const held = port.named(spaceId, term);
|
|
57
|
+
const current = held ?? port.lastNamed(spaceId, term);
|
|
58
|
+
if (!current || (!held && current.retiredAt && input.change !== 'retire')) throw unnamed(term);
|
|
59
|
+
const target = input.change === 'reassign' ? await reassignmentTarget(application, input.projectName === undefined
|
|
60
|
+
? current.projectId : await namedProjectId(application, input.projectName), input.leadAgentId) : null;
|
|
61
|
+
const correction = target ? { action: 'reassign', projectId: target.projectId, leadAgentId: target.leadAgentId }
|
|
62
|
+
: input.change === 'retire' ? { action: 'retire' }
|
|
63
|
+
: { action: 'edit_terms', addTerms: input.addTerms ?? [], removeTerms: input.removeTerms ?? [] };
|
|
64
|
+
const { change, next } = port.previewCorrection(current.assignmentId, correction,
|
|
65
|
+
{ source: 'user', sourceConversationId: task.sessionId });
|
|
66
|
+
if (!change) return { inPlace: true, assignment: current };
|
|
67
|
+
if (!held) throw unnamed(term);
|
|
68
|
+
return { personalSpaceId: spaceId, sourceConversationId: task.sessionId, assignmentId: current.assignmentId,
|
|
69
|
+
revision: current.revision, change: input.change, correction, from: await ownerOf(application, current),
|
|
70
|
+
to: target ?? null, terms: next.terms, termsBefore: current.terms };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function unnamed(term) {
|
|
74
|
+
return new ApplicationError(ApplicationErrorCode.NOT_FOUND, `No active standing assignment has the term "${term}". `
|
|
75
|
+
+ 'Nothing was saved.', { status: 404 });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function namedProjectId(application, name) {
|
|
79
|
+
const projectId = await projectNamed(application, requiredString(name, 'projectName', PROJECT_NAME_LIMIT));
|
|
80
|
+
if (projectId) return projectId;
|
|
81
|
+
throw new ApplicationError(ApplicationErrorCode.NOT_FOUND, `No project is named "${name}". Nothing was saved.`,
|
|
82
|
+
{ status: 404 });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The project and the Agent work would go to: the named Agent or, without
|
|
86
|
+
// one, the project's lead, active on that project either way. The person's
|
|
87
|
+
// choice for this work never changes who leads the project.
|
|
88
|
+
async function reassignmentTarget(application, projectId, leadAgentId) {
|
|
89
|
+
const project = (await nameableProjects(application)).find(item => item.project_id === projectId);
|
|
90
|
+
if (!project) {
|
|
91
|
+
throw new ApplicationError(ApplicationErrorCode.NOT_FOUND, `No project ${projectId} can take this work. Nothing `
|
|
92
|
+
+ 'was saved.', { status: 404 });
|
|
93
|
+
}
|
|
94
|
+
const team = await loadProjectTeam(application, application.config.personal.spaceId, projectId);
|
|
95
|
+
const agentId = leadAgentId === undefined || leadAgentId === null ? team.lead?.agentId
|
|
96
|
+
: requiredString(leadAgentId, 'leadAgentId', ID_LIMIT);
|
|
97
|
+
if (!agentId) {
|
|
98
|
+
throw new ApplicationError('standing_assignment_lead_unavailable', `Project ${projectId} has no active lead; name `
|
|
99
|
+
+ 'an Agent of it. Nothing was saved.', { status: 409 });
|
|
100
|
+
}
|
|
101
|
+
const agent = teamAgent(team, agentId);
|
|
102
|
+
if (!agent) {
|
|
103
|
+
throw new ApplicationError('standing_assignment_lead_not_in_project', `${agentId} is not an active Agent of project `
|
|
104
|
+
+ `${projectId}. Nothing was saved.`, { status: 422 });
|
|
105
|
+
}
|
|
106
|
+
return { projectId, projectName: projectDisplayName(project), leadAgentId: agentId, leadName: agent.name };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The lead, a member or a collaborator of the project, active on it.
|
|
110
|
+
function teamAgent(team, agentId) {
|
|
111
|
+
return [team.lead, ...team.members, ...team.collaborators].find(person => person?.agentId === agentId) ?? null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function assertStillOnTeam(application, { projectId, leadAgentId }) {
|
|
115
|
+
if (teamAgent(await loadProjectTeam(application, application.config.personal.spaceId, projectId), leadAgentId)) return;
|
|
116
|
+
throw new ApplicationError('standing_assignment_plan_changed', `${leadAgentId} left project ${projectId} while `
|
|
117
|
+
+ 'confirming. Nothing was saved; preview again and ask the user again.', { status: 409 });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Where the assignment sends work now, named for the person. A lead that
|
|
121
|
+
// is gone keeps its ID, so the person can still end or move its work.
|
|
122
|
+
async function ownerOf(application, { projectId, leadAgentId }) {
|
|
123
|
+
const spaceId = application.config.personal.spaceId;
|
|
124
|
+
const project = (await nameableProjects(application)).find(item => item.project_id === projectId);
|
|
125
|
+
const name = await leadName(application, spaceId, projectId, leadAgentId).catch(error => {
|
|
126
|
+
if (error?.status === 404) return leadAgentId;
|
|
127
|
+
throw error;
|
|
128
|
+
});
|
|
129
|
+
return { projectId, projectName: project ? projectDisplayName(project) : projectId, leadAgentId, leadName: name };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function restatement({ change, from, to, terms, termsBefore }) {
|
|
133
|
+
const owner = ({ projectName, leadName: lead }) => `project "${projectName}" (lead "${lead}")`;
|
|
134
|
+
if (change === 'retire') {
|
|
135
|
+
return `FULI will stop sending later tasks that mention ${quoted(termsBefore)} to ${owner(from)}; its history is `
|
|
136
|
+
+ 'kept and nothing is done now.';
|
|
137
|
+
}
|
|
138
|
+
if (change === 'reassign') {
|
|
139
|
+
return `FULI will send later tasks that mention ${quoted(terms)} to ${owner(to)} instead of ${owner(from)}; `
|
|
140
|
+
+ 'nothing is done now.';
|
|
141
|
+
}
|
|
142
|
+
return `FULI will send later tasks that mention ${quoted(terms)} to ${owner(from)}, instead of those that mention `
|
|
143
|
+
+ `${quoted(termsBefore)}; nothing is done now.`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function planView({ assignmentId, revision, change, from, to, terms }) {
|
|
147
|
+
return { assignmentId, revision, change, from, to, terms };
|
|
148
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { ApplicationError, ApplicationErrorCode, isControlledError } from '../app/application-error.js';
|
|
2
|
+
import { identityKey } from '../text/name-identity.js';
|
|
3
|
+
import { requiredString } from '../validation/values.js';
|
|
4
|
+
import { correctStandingAssignment } from './standing-assignment-correction.js';
|
|
5
|
+
import { assertPreviewed, leadName, personsConversation, previewOf, projectLead, projectNamed, quoted,
|
|
6
|
+
standingAssignmentsOf } from './standing-assignment-confirmation.js';
|
|
7
|
+
import { createProjectNamed } from './task-entry-project-mention.js';
|
|
8
|
+
|
|
9
|
+
// "From now on, this kind of work goes to that project": the person's own
|
|
10
|
+
// decision, said in a conversation (rec#29 D-41 D1). preview resolves what
|
|
11
|
+
// would happen and writes nothing; the host asks the person once with its one
|
|
12
|
+
// sentence. confirm, given the preview's digest, recomputes the plan and
|
|
13
|
+
// applies it only while it is unchanged: it reuses the project of that name
|
|
14
|
+
// or creates it, has AR staff the project's lead with the person's
|
|
15
|
+
// responsibility when it has none (D4), and registers the terms as the
|
|
16
|
+
// person's (source user). Global preferences are referenced by ID only (D5).
|
|
17
|
+
// Neither step starts or does the work itself.
|
|
18
|
+
//
|
|
19
|
+
// Confirming a plan that is already in place changes nothing, so a repeated
|
|
20
|
+
// confirm never creates a second project or hire. Any other change is a
|
|
21
|
+
// correction of an assignment (standing-assignment-correction.js).
|
|
22
|
+
|
|
23
|
+
const CHANGES = new Set(['register', 'retire', 'reassign', 'edit_terms']);
|
|
24
|
+
const PROJECT_NAME_LIMIT = 80;
|
|
25
|
+
const USER_WORDS_LIMIT = 600;
|
|
26
|
+
// A standing rule in the person's own words, with the markers Tonborg's
|
|
27
|
+
// standing-rule criterion names (judgment/review-prompt.js). A request for
|
|
28
|
+
// this time only is done in its task, not registered.
|
|
29
|
+
const STANDING_INTENT = /(?:from now on|going forward|from here on|in (?:the )?future|always|every time|whenever|以后|今后|往后|从现在起|从今往后|从此|一律|一直|每次|长期|默认)/iu;
|
|
30
|
+
const NOT_EXECUTED = 'Registered and assigned, NOT executed: no task was started or done. Later tasks that mention these terms go to this lead.';
|
|
31
|
+
|
|
32
|
+
export async function registerStandingAssignment(application, input = {}) {
|
|
33
|
+
standingAssignmentsOf(application);
|
|
34
|
+
if (input.action !== 'preview' && input.action !== 'confirm') throw invalid('action must be preview or confirm');
|
|
35
|
+
const change = input.change ?? 'register';
|
|
36
|
+
if (!CHANGES.has(change)) throw invalid('change must be register, retire, reassign or edit_terms');
|
|
37
|
+
if (change !== 'register') return correctStandingAssignment(application, input);
|
|
38
|
+
const plan = await currentPlan(application, input);
|
|
39
|
+
return input.action === 'preview' ? previewResult(plan) : confirm(application, plan, input);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function currentPlan(application, input) {
|
|
43
|
+
const userWords = requiredString(input.userWords, 'userWords', USER_WORDS_LIMIT);
|
|
44
|
+
if (!STANDING_INTENT.test(userWords)) {
|
|
45
|
+
throw new ApplicationError('standing_assignment_one_off', 'The user\'s words state no standing rule (from now on, '
|
|
46
|
+
+ '以后, always). Do a one-off request in this task; nothing was registered.', { status: 422 });
|
|
47
|
+
}
|
|
48
|
+
const task = await personsConversation(application, input);
|
|
49
|
+
const spaceId = application.config.personal.spaceId;
|
|
50
|
+
const name = requiredString(input.projectName, 'projectName', PROJECT_NAME_LIMIT);
|
|
51
|
+
const projectId = await projectNamed(application, name);
|
|
52
|
+
const leadAgentId = projectId ? await projectLead(application, spaceId, projectId) : null;
|
|
53
|
+
const registration = application.standingAssignments.preview({ personalSpaceId: spaceId, projectId, leadAgentId,
|
|
54
|
+
terms: input.terms, responsibility: input.responsibility, preferenceIds: input.preferenceIds, source: 'user',
|
|
55
|
+
sourceConversationId: task.sessionId });
|
|
56
|
+
const current = registration.assignment;
|
|
57
|
+
return {
|
|
58
|
+
personalSpaceId: spaceId, sourceConversationId: task.sessionId, userWords,
|
|
59
|
+
project: { action: projectId ? 'reuse' : 'create', projectId, name },
|
|
60
|
+
lead: { action: leadAgentId ? 'reuse' : 'hire', agentId: leadAgentId,
|
|
61
|
+
name: leadAgentId ? await leadName(application, spaceId, projectId, leadAgentId) : null },
|
|
62
|
+
terms: registration.terms, preferenceIds: registration.preferenceIds,
|
|
63
|
+
// An existing assignment keeps the responsibility it was registered with.
|
|
64
|
+
responsibility: current?.responsibility ?? registration.responsibility,
|
|
65
|
+
assignment: { action: registration.status, assignmentId: current?.assignmentId ?? null,
|
|
66
|
+
revision: current?.revision ?? null }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function previewResult(plan) {
|
|
71
|
+
if (inPlace(plan)) {
|
|
72
|
+
return { status: 'already_registered', plan: planView(plan), executed: false,
|
|
73
|
+
restatement: `${quoted(plan.terms)} already go to project "${plan.project.name}" (lead "${plan.lead.name}"); `
|
|
74
|
+
+ 'there is nothing to register.' };
|
|
75
|
+
}
|
|
76
|
+
return previewOf(plan, planView(plan), restatement(plan));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Other requests run while this one awaits the Provider, so the project's
|
|
80
|
+
// lead and the terms are checked again just before the writes that depend on
|
|
81
|
+
// them. Every failure after the first Provider write goes through
|
|
82
|
+
// partiallyApplied: what was written stays (another request may already use
|
|
83
|
+
// it, so nothing is rolled back), and the error names it, with the failure
|
|
84
|
+
// itself as its cause. Before any write the failure stands as it is.
|
|
85
|
+
async function confirm(application, plan, input) {
|
|
86
|
+
if (inPlace(plan)) return confirmed('unchanged', plan, existingState(plan), null);
|
|
87
|
+
assertPreviewed(input, plan);
|
|
88
|
+
const state = existingState(plan);
|
|
89
|
+
try {
|
|
90
|
+
// A term another request took since the plan was read refuses before anything is written.
|
|
91
|
+
application.standingAssignments.preview(registrationOf(plan, state.projectId, state.leadAgentId));
|
|
92
|
+
if (!state.projectId) {
|
|
93
|
+
// Until the Provider answers, whether the project exists is unknown.
|
|
94
|
+
Object.assign(state, { attempted: true, project: 'unknown' });
|
|
95
|
+
const created = await createProjectNamed(application, plan.project.name, plan.responsibility);
|
|
96
|
+
Object.assign(state, { projectId: created.personalProjectId,
|
|
97
|
+
project: created.basis === 'created_from_prompt' ? 'created' : 'existing' });
|
|
98
|
+
}
|
|
99
|
+
if (!state.leadAgentId) await hireLead(application, plan, state, input.sourceApplication ?? 'other');
|
|
100
|
+
const lead = await projectLead(application, plan.personalSpaceId, state.projectId);
|
|
101
|
+
if (lead !== state.leadAgentId) throw leadChanged(state, lead);
|
|
102
|
+
const { assignment } = application.standingAssignments.register(
|
|
103
|
+
registrationOf(plan, state.projectId, state.leadAgentId));
|
|
104
|
+
return confirmed('registered', plan, state, assignment);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw state.attempted ? partiallyApplied(application, plan, state, error) : unwritten(error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// AR hires the lead through the ordinary default-lead staffing, with the
|
|
111
|
+
// person's responsibility leading the lead's own (D4). A lead another request
|
|
112
|
+
// hired meanwhile is not the lead this plan was confirmed for.
|
|
113
|
+
async function hireLead(application, plan, state, sourceApplication) {
|
|
114
|
+
Object.assign(state, { attempted: true, lead: 'unknown' });
|
|
115
|
+
const staffed = await application.personal.staffDefaultProjectLead({ personal_space_id: plan.personalSpaceId,
|
|
116
|
+
personal_project_id: state.projectId, source_application: sourceApplication, responsibility: plan.responsibility });
|
|
117
|
+
if (staffed?.agent?.agent_id) {
|
|
118
|
+
Object.assign(state, { lead: 'hired', leadAgentId: staffed.agent.agent_id });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
state.lead = null;
|
|
122
|
+
const lead = await projectLead(application, plan.personalSpaceId, state.projectId);
|
|
123
|
+
if (lead) throw leadChanged(state, lead);
|
|
124
|
+
throw refusal('standing_assignment_lead_unavailable',
|
|
125
|
+
`AR could not staff the project's lead (${staffed?.reason ?? 'unavailable'}).`, 503);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// What exists before confirm writes: the plan's project and lead, if any.
|
|
129
|
+
function existingState(plan) {
|
|
130
|
+
return { attempted: false, projectId: plan.project.projectId, project: plan.project.projectId ? 'existing' : null,
|
|
131
|
+
leadAgentId: plan.lead.agentId, lead: plan.lead.agentId ? 'existing' : null };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function registrationOf(plan, projectId, leadAgentId) {
|
|
135
|
+
return { personalSpaceId: plan.personalSpaceId, projectId, leadAgentId, terms: plan.terms,
|
|
136
|
+
responsibility: plan.responsibility, preferenceIds: plan.preferenceIds, source: 'user',
|
|
137
|
+
sourceConversationId: plan.sourceConversationId };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function leadChanged(state, lead) {
|
|
141
|
+
return refusal('standing_assignment_plan_changed', 'The project\'s lead changed while confirming: it is now '
|
|
142
|
+
+ `${lead ?? 'nobody'}, not ${state.leadAgentId ?? 'a lead hired for this plan'}.`, 409);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// confirm's own refusals: a reason that claims nothing about what was saved,
|
|
146
|
+
// completed by unwritten or partiallyApplied.
|
|
147
|
+
function refusal(code, reason, status) {
|
|
148
|
+
return Object.assign(new ApplicationError(code, reason, { status }), { refusal: true });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function unwritten(error) {
|
|
152
|
+
if (!error?.refusal) return error;
|
|
153
|
+
return new ApplicationError(error.code, `${error.message} The terms were NOT registered. Nothing was saved; preview `
|
|
154
|
+
+ 'again and ask the user again.', { status: error.status });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The written state leads; the original failure is kept as cause. A
|
|
158
|
+
// diagnostic that fails only leaves its detail out.
|
|
159
|
+
function partiallyApplied(application, plan, state, error) {
|
|
160
|
+
const controlled = isControlledError(error);
|
|
161
|
+
const cause = { code: typeof error?.code === 'string' ? error.code : 'internal_error',
|
|
162
|
+
message: controlled ? error.message : 'unexpected error' };
|
|
163
|
+
const detail = (cause.code === 'standing_assignment_term_taken' ? takenTermDetail(application, plan, state)
|
|
164
|
+
: cause.message)?.replace(/\.$/, '');
|
|
165
|
+
const failed = new ApplicationError('standing_assignment_partially_applied', `Partly applied: `
|
|
166
|
+
+ `${writtenSoFar(plan, state)}; what was written is kept. The terms were NOT registered (${cause.code}`
|
|
167
|
+
+ `${detail ? `: ${detail}` : ''}). Preview again and ask the user again: it reuses the project and lead that exist `
|
|
168
|
+
+ 'now.', { status: error?.status ?? 500 });
|
|
169
|
+
return Object.assign(failed, { cause, written: { project: state.project, projectId: state.projectId,
|
|
170
|
+
projectName: plan.project.name, lead: state.lead, leadAgentId: state.leadAgentId } });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function takenTermDetail(application, plan, state) {
|
|
174
|
+
try {
|
|
175
|
+
for (const assignment of application.standingAssignments.list(plan.personalSpaceId)) {
|
|
176
|
+
if (assignment.projectId === state.projectId && assignment.leadAgentId === state.leadAgentId) continue;
|
|
177
|
+
const keys = new Set(assignment.terms.map(identityKey));
|
|
178
|
+
const term = plan.terms.find(value => keys.has(identityKey(value)));
|
|
179
|
+
if (term) {
|
|
180
|
+
return `"${term}" already names the standing assignment of project ${assignment.projectId} `
|
|
181
|
+
+ `(lead ${assignment.leadAgentId})`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} catch {
|
|
185
|
+
// Best effort: the failure and the written state are reported without it.
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function writtenSoFar(plan, { project, projectId, lead, leadAgentId }) {
|
|
191
|
+
const projectPart = project === 'unknown' ? `whether project "${plan.project.name}" was created is unknown`
|
|
192
|
+
: `project "${plan.project.name}" (${projectId}) ${project === 'created' ? 'was created' : 'already existed'}`;
|
|
193
|
+
const leadPart = { hired: `AR hired its lead ${leadAgentId}`, existing: `its lead ${leadAgentId} already existed`,
|
|
194
|
+
unknown: 'whether AR hired its lead is unknown' }[lead];
|
|
195
|
+
return leadPart ? `${projectPart}, and ${leadPart}` : projectPart;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function confirmed(status, plan, { projectId, project, leadAgentId, lead }, assignment) {
|
|
199
|
+
return { status, executed: false, notice: NOT_EXECUTED,
|
|
200
|
+
project: { projectId, name: plan.project.name, created: project === 'created' },
|
|
201
|
+
lead: { agentId: leadAgentId, hired: lead === 'hired' },
|
|
202
|
+
terms: plan.terms, ...(assignment ? { assignment } : {}) };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// The project, its lead and every term already name one active assignment.
|
|
206
|
+
function inPlace(plan) {
|
|
207
|
+
return plan.project.action === 'reuse' && plan.lead.action === 'reuse' && plan.assignment.action === 'unchanged';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function restatement(plan) {
|
|
211
|
+
const project = `${plan.project.action === 'create' ? 'create' : 'reuse'} project "${plan.project.name}"`;
|
|
212
|
+
const lead = plan.lead.action === 'hire' ? 'have AR hire its lead' : `keep its lead "${plan.lead.name}"`;
|
|
213
|
+
return `FULI will ${project}, ${lead} for "${plan.responsibility}", and send later tasks that mention `
|
|
214
|
+
+ `${quoted(plan.terms)} there; nothing is done now.`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function planView({ project, lead, terms, responsibility, preferenceIds, assignment }) {
|
|
218
|
+
return { project, lead, terms, responsibility, preferenceIds, assignment };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function invalid(message) {
|
|
222
|
+
return new ApplicationError(ApplicationErrorCode.VALIDATION, message);
|
|
223
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { taskAgentAssignment } from './task-agent-assignment.js';
|
|
2
|
+
import { beginConversation } from './agent-conversations.js';
|
|
3
|
+
import { REMEMBER_GUIDANCE, rememberRequested } from './task-remember.js';
|
|
4
|
+
import { withRecoveredSource } from './task-knowledge-recall.js';
|
|
5
|
+
import { entryAgentReceipt } from './turn-receipt-delivery.js';
|
|
6
|
+
import { taskPreferenceScope } from '../mcp/provider-task-context-registry.js';
|
|
7
|
+
|
|
8
|
+
import { validationError } from '../app/application-error.js';
|
|
9
|
+
import { withStandingRoute } from './task-entry-standing-owner.js';
|
|
10
|
+
import { taskPreferenceMetadata, withPreferenceScope } from '../conversations/preference-snapshot.js';
|
|
11
|
+
import { STOP_HOOK_CHECKPOINT_GUIDANCE, taskKnowledgeGuidance } from './task-knowledge-guidance.js';
|
|
12
|
+
|
|
13
|
+
export async function beginTaskContext(application, {
|
|
14
|
+
sessionId,
|
|
15
|
+
turnId = null,
|
|
16
|
+
projectPath,
|
|
17
|
+
personalProjectId = null,
|
|
18
|
+
taskPrompt = null,
|
|
19
|
+
sourceApplication = 'other',
|
|
20
|
+
sourceSessionId = null,
|
|
21
|
+
projectAgentId = null,
|
|
22
|
+
workKind,
|
|
23
|
+
workflow,
|
|
24
|
+
requiredCapabilities = []
|
|
25
|
+
}) {
|
|
26
|
+
const continuationToken = /^FULI_CHECKPOINT_REQUIRED: (fuli-task-[a-zA-Z0-9-]{8,128})\b/.exec(taskPrompt ?? '')?.[1];
|
|
27
|
+
const current = !continuationToken && turnId && application.taskContextRegistry.current
|
|
28
|
+
? await application.taskContextRegistry.current(sessionId, sourceApplication) : null;
|
|
29
|
+
const resumed = continuationToken
|
|
30
|
+
? await application.taskContextRegistry.context(continuationToken, sourceApplication) : null;
|
|
31
|
+
const scopeRetry = current?.turnId === turnId
|
|
32
|
+
? current : null;
|
|
33
|
+
if (resumed && resumed.sessionId !== sessionId) {
|
|
34
|
+
throw validationError('Checkpoint continuation belongs to another host session');
|
|
35
|
+
}
|
|
36
|
+
const existingTask = resumed ?? scopeRetry;
|
|
37
|
+
if (existingTask && personalProjectId && existingTask.personalProjectId !== personalProjectId) {
|
|
38
|
+
throw validationError('Task context belongs to another project');
|
|
39
|
+
}
|
|
40
|
+
const preferenceScope = existingTask ? taskPreferenceScope(existingTask.preferenceScope)
|
|
41
|
+
: taskPreferenceScope({ version: 1, work_kind: workKind ?? null, workflow: workflow ?? null });
|
|
42
|
+
if (!preferenceScope) throw validationError('Task preference scope is unknown; legacy recovery cannot guess preference dimensions');
|
|
43
|
+
if (existingTask && ((workKind !== undefined && workKind !== preferenceScope.work_kind) ||
|
|
44
|
+
(workflow !== undefined && workflow !== preferenceScope.workflow))) {
|
|
45
|
+
throw Object.assign(validationError('Task preference scope is immutable; begin a new task for different dimensions'), { status: 409 });
|
|
46
|
+
}
|
|
47
|
+
const preferences = await application.getCollaborationPreferences({
|
|
48
|
+
personalProjectId: resumed?.personalProjectId ?? scopeRetry?.personalProjectId ?? personalProjectId,
|
|
49
|
+
projectPath,
|
|
50
|
+
sessionId,
|
|
51
|
+
turnId: existingTask?.turnId ?? turnId,
|
|
52
|
+
taskPrompt,
|
|
53
|
+
projectAgentId: resumed?.projectAgentId ?? scopeRetry?.projectAgentId ?? projectAgentId,
|
|
54
|
+
sourceApplication,
|
|
55
|
+
sourceSessionId,
|
|
56
|
+
workKind: preferenceScope.work_kind,
|
|
57
|
+
workflow: preferenceScope.workflow,
|
|
58
|
+
requiredCapabilities,
|
|
59
|
+
agentInvocation: true,
|
|
60
|
+
agentToolName: 'begin_task_context'
|
|
61
|
+
});
|
|
62
|
+
if (resumed && resumed.personalProjectId !== preferences.context.personal_project_id) {
|
|
63
|
+
throw validationError('Checkpoint continuation belongs to another project');
|
|
64
|
+
}
|
|
65
|
+
return beginTaskFromPreferences(application, preferences, {
|
|
66
|
+
sessionId, turnId: existingTask?.turnId ?? turnId, sourceApplication, sourceSessionId, taskPrompt,
|
|
67
|
+
workKind: preferenceScope.work_kind, workflow: preferenceScope.workflow
|
|
68
|
+
}, { existingTask: resumed ?? (scopeRetry?.projectScope?.type === 'temporary' ? scopeRetry : null), resumed: Boolean(resumed),
|
|
69
|
+
entryVia: 'hook' });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Hook and model fallback share the same durable lifecycle. A stored pending
|
|
73
|
+
// task is not evidence that its context reached this model turn.
|
|
74
|
+
export async function beginTaskFromPreferences(application, preferences, {
|
|
75
|
+
sessionId, turnId = null, sourceApplication = 'other', sourceSessionId = null,
|
|
76
|
+
workKind = null, workflow = null, taskPrompt = null
|
|
77
|
+
}, { existingTask = null, resumed = false, entryVia = 'tool' } = {}) {
|
|
78
|
+
const task = existingTask ?? await application.taskContextRegistry.begin({
|
|
79
|
+
sessionId,
|
|
80
|
+
turnId,
|
|
81
|
+
personalProjectId: preferences.context.personal_project_id,
|
|
82
|
+
projectAgentId: preferences.context.project_agent_id,
|
|
83
|
+
sourceApplication,
|
|
84
|
+
sourceSessionId,
|
|
85
|
+
delegationToken: application.roundtable?.taskEntryDelegation?.({ sessionId })?.token,
|
|
86
|
+
preferenceScope: taskPreferenceScope({ version: 1, work_kind: workKind, workflow }),
|
|
87
|
+
agentAssignment: withStandingRoute(taskAgentAssignment(preferences.project_agent_context), preferences.standing_owner),
|
|
88
|
+
memoryRevision: preferences.project_agent_context?.memory?.revision ?? null,
|
|
89
|
+
workLogRequired: Boolean(preferences.project_agent_context?.memory),
|
|
90
|
+
entryVia
|
|
91
|
+
});
|
|
92
|
+
// Only the Provider can establish that a fallback has no claim or worker /
|
|
93
|
+
// coordination associations. Missing metadata keeps the legacy requirement.
|
|
94
|
+
// A request to keep something is never a routine auto-closed task.
|
|
95
|
+
const remembering = rememberRequested(taskPrompt);
|
|
96
|
+
const autoClosed = !remembering && ((entryVia === 'hook' && task.entryVia === 'hook') || task.routineAutoCloseEligible === true);
|
|
97
|
+
const conversation = await beginConversation(application, task);
|
|
98
|
+
const receipt = preferences.agent_receipt ? await entryAgentReceipt(application, task, preferences.agent_receipt) : null;
|
|
99
|
+
return withPreferenceScope({
|
|
100
|
+
conversation,
|
|
101
|
+
taskContextToken: task.token,
|
|
102
|
+
task_context_token: task.token,
|
|
103
|
+
checkpoint_required: !autoClosed && task.checkpoint?.phase !== 'complete',
|
|
104
|
+
...(autoClosed ? { checkpoint_guidance: STOP_HOOK_CHECKPOINT_GUIDANCE } : {}),
|
|
105
|
+
...(remembering ? { remember_guidance: REMEMBER_GUIDANCE } : {}),
|
|
106
|
+
resumed_checkpoint: Boolean(resumed),
|
|
107
|
+
previous_checkpoint_missing: task.previousCheckpointMissing,
|
|
108
|
+
...preferences, ...(receipt ? { agent_receipt: receipt } : {}),
|
|
109
|
+
...(preferences.task_knowledge_recall ? { task_knowledge_recall: withRecoveredSource(preferences.task_knowledge_recall, conversation, {
|
|
110
|
+
consoleUrl: application.consoleUrl, spaceId: preferences.context?.personal_space_id, agentId: preferences.context?.project_agent_id }) } : {}),
|
|
111
|
+
...(task.projectScope ? { project_scope: task.projectScope } : {}),
|
|
112
|
+
task_guidance: taskKnowledgeGuidance()
|
|
113
|
+
}, taskPreferenceMetadata(task, application.config?.personal?.spaceId));
|
|
114
|
+
}
|
|
@@ -13,6 +13,7 @@ import { receiptNotices } from './capture-notice.js';
|
|
|
13
13
|
import { receiptFormatNotices } from '../data-format/format-notices.js';
|
|
14
14
|
import { noteEntryTask } from '../conversations/entry-budget.js';
|
|
15
15
|
import { withSharedProjectList } from './shared-project-list.js';
|
|
16
|
+
import { standingOwnerEntry } from './task-entry-standing-owner.js';
|
|
16
17
|
|
|
17
18
|
export async function finishTaskEntryPreferences(application, preferences, input) {
|
|
18
19
|
if (!input.agentInvocation || input.agentToolName !== 'get_collaboration_preferences') return preferences;
|
|
@@ -93,6 +94,7 @@ async function entryPreferences(application, projectResolution, {
|
|
|
93
94
|
}, selection, recordAgentViews, reads, { includeManagement = true, includeMessages = true } = {}) {
|
|
94
95
|
// A rejected explicit role must not leak its private preferences via fallback.
|
|
95
96
|
const selectedAgentId = selection ? selection.agent?.agentId ?? null : projectAgentId;
|
|
97
|
+
const standing = standingOwnerEntry(projectResolution, selection);
|
|
96
98
|
const team = reads.management.then(management => {
|
|
97
99
|
// Sealed workers already carry a coordinator's reporting contract. Ordinary
|
|
98
100
|
// entry advertises team/judgment only with an available authorized manager.
|
|
@@ -141,10 +143,11 @@ async function entryPreferences(application, projectResolution, {
|
|
|
141
143
|
// Answers a person gave to this Agent's own requests while it was away.
|
|
142
144
|
const answered = includeMessages && selection?.agent && projectResolution.personalProjectId && application.roundtable?.attentionReplies
|
|
143
145
|
? application.roundtable.attentionReplies(selection.agent.agentId, projectResolution.personalProjectId) : [];
|
|
144
|
-
const notices = [...receiptNotices(capture, projectResolution.basis === 'created_from_prompt' ? ['project_created'] : [],
|
|
146
|
+
const notices = [...(standing?.notice ? [standing.receiptNotice] : []), ...receiptNotices(capture, projectResolution.basis === 'created_from_prompt' ? ['project_created'] : [],
|
|
145
147
|
{ settingsUrl: captureSettingsUrl(application) }), ...formatNotices];
|
|
146
148
|
return { ...managedPreferences, ...(context ? { project_agent_context: context } : {}),
|
|
147
149
|
...(triage ? { triage_candidates: triage } : {}),
|
|
150
|
+
...(standing ? { standing_owner: standing.field } : {}),
|
|
148
151
|
...(judgmentContext ? { judgment_context: judgmentContext } : {}),
|
|
149
152
|
...(waiting.length ? { agent_messages: waiting,
|
|
150
153
|
agent_messages_guidance: 'Other Agents are waiting for your answers. Reply to each with reply_agent_message.' } : {}),
|
|
@@ -19,13 +19,24 @@ export async function projectNamedInPrompt(application, taskPrompt) {
|
|
|
19
19
|
if (existing.length) return choice(existing, 'named_in_prompt');
|
|
20
20
|
return createNamedProject(application, spaceId, all, requested, requestedBrief(taskPrompt, requested));
|
|
21
21
|
}
|
|
22
|
+
return choice(namedAtOpening(projects, taskPrompt), 'named_in_prompt');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Whether the prompt names a project by the rules above, read-only: a
|
|
26
|
+
// "新项目:" line counts even before its project exists, and nothing is created.
|
|
27
|
+
export async function promptNamesProject(application, taskPrompt) {
|
|
28
|
+
if (typeof taskPrompt !== 'string' || !taskPrompt.trim()) return false;
|
|
29
|
+
return NEW_PROJECT.test(taskPrompt) || namedAtOpening(await nameableProjects(application), taskPrompt).length > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The projects whose longest name opens the prompt as a whole word.
|
|
33
|
+
function namedAtOpening(projects, taskPrompt) {
|
|
22
34
|
const opening = taskPrompt.trimStart().toLowerCase();
|
|
23
35
|
const matches = projects
|
|
24
36
|
.flatMap(project => names(project).map(name => ({ project, name: name.toLowerCase() })))
|
|
25
37
|
.filter(({ name }) => opening.startsWith(name) && NAME_END.test(opening.slice(name.length)));
|
|
26
38
|
const longest = Math.max(0, ...matches.map(({ name }) => name.length));
|
|
27
|
-
return
|
|
28
|
-
'named_in_prompt');
|
|
39
|
+
return matches.filter(({ name }) => name.length === longest).map(({ project }) => project);
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
// Shared by Jefa's triage: the same name rules decide which project a label means.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TASK_ENTRY_TOOLS } from './repository-project-registration.js';
|
|
2
2
|
import { hostInternalActivity } from './task-entry-activity-origin.js';
|
|
3
3
|
import { projectNamedInPrompt } from './task-entry-project-mention.js';
|
|
4
|
+
import { sessionTaskContext, withStandingOwner } from './task-entry-standing-owner.js';
|
|
4
5
|
|
|
5
6
|
// The fixed assistant receives conversations no project has claimed yet.
|
|
6
7
|
export const ASSISTANT_AGENT_ID = 'employee.assistant';
|
|
@@ -8,11 +9,17 @@ export const ASSISTANT_AGENT_ID = 'employee.assistant';
|
|
|
8
9
|
// Restore only exact session provenance; a normal folder name is not a role binding.
|
|
9
10
|
// An unclaimed conversation never creates a project or hires a lead: it stays
|
|
10
11
|
// pending in the assistant's global scope until it is assigned to a project.
|
|
12
|
+
// A standing assignment the prompt names then scopes this task alone
|
|
13
|
+
// (task-entry-standing-owner.js).
|
|
11
14
|
export async function resolveTaskEntryProject(application, resolution, input) {
|
|
15
|
+
if (!input.agentInvocation || !TASK_ENTRY_TOOLS.has(input.agentToolName)) return resolution;
|
|
16
|
+
return withStandingOwner(application, await sessionEntryProject(application, resolution, input), input);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function sessionEntryProject(application, resolution, input) {
|
|
12
20
|
// An unregistered repository ID is only a hint: when auto-registration did
|
|
13
21
|
// not apply, the prompt, the session and the assistant still decide.
|
|
14
|
-
if (
|
|
15
|
-
|| resolution.personalProjectId
|
|
22
|
+
if (resolution.personalProjectId
|
|
16
23
|
|| !['unmatched', 'not_provided'].includes(resolution.status)) return resolution;
|
|
17
24
|
// An explicit FLA outside a project uses its independent global context.
|
|
18
25
|
if (input.projectAgentId || String(input.taskPrompt ?? '').trimStart().startsWith('@')) {
|
|
@@ -27,7 +34,9 @@ export async function resolveTaskEntryProject(application, resolution, input) {
|
|
|
27
34
|
const source = input.sourceApplication ?? 'other';
|
|
28
35
|
try {
|
|
29
36
|
for (const sessionId of sessions) {
|
|
30
|
-
|
|
37
|
+
// A task a standing assignment routed never moves its session there:
|
|
38
|
+
// the session continues where it was before that task.
|
|
39
|
+
const context = sessionTaskContext(await application.taskContextRegistry?.current?.(sessionId, source));
|
|
31
40
|
if (context?.projectScope?.type === 'temporary') continue;
|
|
32
41
|
if (context?.personalProjectId === null && context.projectAgentId) {
|
|
33
42
|
return { status: 'global', basis: 'host_session_context', personalProjectId: null,
|