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,431 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
commonKnowledgeItem, commonKnowledgeSimilarity, preferenceContentTokens, sharedPreferenceTerms
|
|
5
|
+
} from './cross-project-knowledge-similarity.js';
|
|
6
|
+
|
|
7
|
+
export async function discoverPersonalGlobalPreferenceCandidates(application, {
|
|
8
|
+
personalSpaceId,
|
|
9
|
+
personalProjectIds,
|
|
10
|
+
query,
|
|
11
|
+
minProjects = 2,
|
|
12
|
+
similarityThreshold = 0.72,
|
|
13
|
+
limitPerProject = 12
|
|
14
|
+
}) {
|
|
15
|
+
if (!Array.isArray(personalProjectIds) || personalProjectIds.length < 2) {
|
|
16
|
+
throw new TypeError('Personal-global candidates need at least two explicit projects');
|
|
17
|
+
}
|
|
18
|
+
if (!Number.isInteger(minProjects) || minProjects < 2) {
|
|
19
|
+
throw new TypeError('Personal-global candidates need evidence from at least two projects');
|
|
20
|
+
}
|
|
21
|
+
if (
|
|
22
|
+
typeof similarityThreshold !== 'number'
|
|
23
|
+
|| similarityThreshold < 0
|
|
24
|
+
|| similarityThreshold > 1
|
|
25
|
+
) {
|
|
26
|
+
throw new TypeError('Similarity threshold must be between 0 and 1');
|
|
27
|
+
}
|
|
28
|
+
const projectIds = [...new Set(personalProjectIds)].sort();
|
|
29
|
+
if (projectIds.length < 2 || minProjects > projectIds.length) {
|
|
30
|
+
throw new TypeError('The selected project set cannot satisfy minProjects');
|
|
31
|
+
}
|
|
32
|
+
const knownProjectIds = new Set(
|
|
33
|
+
(await application.personal.listPersonalProjects(personalSpaceId))
|
|
34
|
+
.map(({ project_id: projectId }) => projectId)
|
|
35
|
+
);
|
|
36
|
+
if (projectIds.some((projectId) => !knownProjectIds.has(projectId))) {
|
|
37
|
+
throw new TypeError('Every selected project must exist in the active personal space');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const projectResults = await Promise.all(projectIds.map(async (projectId) => ({
|
|
41
|
+
projectId,
|
|
42
|
+
result: await application.personal.search({
|
|
43
|
+
space_ids: [personalSpaceId],
|
|
44
|
+
query,
|
|
45
|
+
limit: limitPerProject,
|
|
46
|
+
include_historical: false,
|
|
47
|
+
include_exploratory: false,
|
|
48
|
+
personal_project_ids: [projectId],
|
|
49
|
+
active_personal_project_id: projectId,
|
|
50
|
+
inherit_project_knowledge: false,
|
|
51
|
+
include_personal_global: false
|
|
52
|
+
})
|
|
53
|
+
})));
|
|
54
|
+
const items = projectResults.flatMap(({ projectId, result }) => [
|
|
55
|
+
...(result.entities ?? []).map((item) =>
|
|
56
|
+
commonKnowledgeItem(item, 'entity', projectId)
|
|
57
|
+
),
|
|
58
|
+
...(result.facts ?? []).map((item) =>
|
|
59
|
+
commonKnowledgeItem(item, 'relationship', projectId)
|
|
60
|
+
)
|
|
61
|
+
]).filter((item) =>
|
|
62
|
+
item.profile_aspect
|
|
63
|
+
&& item.preference_scope === 'project'
|
|
64
|
+
&& item.preference_project_id === item.defined_project_id
|
|
65
|
+
&& ['confirmed', 'agent_confirmed'].includes(item.confirmation_status)
|
|
66
|
+
&& item.requires_attention !== true
|
|
67
|
+
);
|
|
68
|
+
const clusteredCandidates = clusterPersonalGlobalPreferenceItems(
|
|
69
|
+
items,
|
|
70
|
+
minProjects,
|
|
71
|
+
similarityThreshold,
|
|
72
|
+
query,
|
|
73
|
+
projectIds.length
|
|
74
|
+
);
|
|
75
|
+
const candidates = await Promise.all(clusteredCandidates.map(async (candidate) => {
|
|
76
|
+
const options = await application.personal.personalGlobalPreferenceScopeOptions(
|
|
77
|
+
candidate.candidate_id,
|
|
78
|
+
{
|
|
79
|
+
personal_space_id: personalSpaceId,
|
|
80
|
+
source_items: candidate.source_items.map((item) => ({
|
|
81
|
+
item_id: item.id,
|
|
82
|
+
item_kind: item.item_kind,
|
|
83
|
+
project_id: item.defined_project_id
|
|
84
|
+
})),
|
|
85
|
+
preference_key: candidate.preference_key
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
return {
|
|
89
|
+
...candidate,
|
|
90
|
+
candidate_version: options.candidate_version,
|
|
91
|
+
target_scope: 'human_selected',
|
|
92
|
+
eligible_target_scopes: options.eligible_target_scopes,
|
|
93
|
+
source_snapshots: options.source_snapshots
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
const decisionState = await personalGlobalCandidateDecisionState(
|
|
97
|
+
application,
|
|
98
|
+
personalSpaceId,
|
|
99
|
+
candidates
|
|
100
|
+
);
|
|
101
|
+
const visibleCandidates = candidates
|
|
102
|
+
.filter(({ candidate_id: id, candidate_version: version }) =>
|
|
103
|
+
!decisionState.decisions.has(`${id}:${version}`)
|
|
104
|
+
)
|
|
105
|
+
.map((candidate) => personalGlobalCandidateWithDecisionState(
|
|
106
|
+
candidate,
|
|
107
|
+
decisionState.revisions.get(candidate.candidate_id)
|
|
108
|
+
));
|
|
109
|
+
const suppressedCandidates = candidates
|
|
110
|
+
.filter(({ candidate_id: id, candidate_version: version }) =>
|
|
111
|
+
decisionState.decisions.has(`${id}:${version}`)
|
|
112
|
+
)
|
|
113
|
+
.map(({ candidate_id: candidateId, candidate_version: version }) => ({
|
|
114
|
+
candidate_id: candidateId,
|
|
115
|
+
candidate_version: version,
|
|
116
|
+
...decisionState.decisions.get(`${candidateId}:${version}`)
|
|
117
|
+
}));
|
|
118
|
+
return {
|
|
119
|
+
status: visibleCandidates.length > 0
|
|
120
|
+
? 'candidates_found'
|
|
121
|
+
: suppressedCandidates.length > 0
|
|
122
|
+
? 'candidates_suppressed'
|
|
123
|
+
: 'no_candidates',
|
|
124
|
+
personal_space_id: personalSpaceId,
|
|
125
|
+
target_scope: 'human_selected',
|
|
126
|
+
selected_project_ids: projectIds,
|
|
127
|
+
query,
|
|
128
|
+
candidates: visibleCandidates,
|
|
129
|
+
suppressed_candidates: suppressedCandidates,
|
|
130
|
+
policy: personalGlobalCandidatePolicy()
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function previewPersonalGlobalPreferenceDecision(application, input) {
|
|
135
|
+
return application.personal.inspectPersonalGlobalPreferenceDecision(
|
|
136
|
+
input.candidateId,
|
|
137
|
+
providerPersonalGlobalPreferenceDecision(input)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function applyPersonalGlobalPreferenceDecision(application, input) {
|
|
142
|
+
return application.personal.applyPersonalGlobalPreferenceDecision(
|
|
143
|
+
input.candidateId,
|
|
144
|
+
providerPersonalGlobalPreferenceDecision(input, {
|
|
145
|
+
approvalToken: input.previewToken
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function clusterPersonalGlobalPreferenceItems(
|
|
151
|
+
items,
|
|
152
|
+
minProjects,
|
|
153
|
+
similarityThreshold,
|
|
154
|
+
query,
|
|
155
|
+
selectedProjectCount
|
|
156
|
+
) {
|
|
157
|
+
const groups = [];
|
|
158
|
+
for (const item of items) {
|
|
159
|
+
const preferenceKey = personalGlobalItemPreferenceKey(item);
|
|
160
|
+
const matching = groups
|
|
161
|
+
.map((group) => ({
|
|
162
|
+
group,
|
|
163
|
+
similarity: Math.min(
|
|
164
|
+
...group.items.map((member) => commonKnowledgeSimilarity(item, member))
|
|
165
|
+
)
|
|
166
|
+
}))
|
|
167
|
+
.filter(({ group, similarity }) =>
|
|
168
|
+
group.itemKind === item.item_kind
|
|
169
|
+
&& group.preferenceKey === preferenceKey
|
|
170
|
+
&& similarity >= similarityThreshold
|
|
171
|
+
&& !group.projectIds.has(item.defined_project_id)
|
|
172
|
+
)
|
|
173
|
+
.sort((left, right) => right.similarity - left.similarity)[0];
|
|
174
|
+
if (matching) {
|
|
175
|
+
matching.group.items.push(item);
|
|
176
|
+
matching.group.projectIds.add(item.defined_project_id);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
groups.push({
|
|
180
|
+
itemKind: item.item_kind,
|
|
181
|
+
preferenceKey,
|
|
182
|
+
projectIds: new Set([item.defined_project_id]),
|
|
183
|
+
items: [item]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return groups
|
|
188
|
+
.filter(({ projectIds }) => projectIds.size >= minProjects)
|
|
189
|
+
.map((group) => {
|
|
190
|
+
const sourceItems = [...group.items].sort((left, right) =>
|
|
191
|
+
left.defined_project_id.localeCompare(right.defined_project_id)
|
|
192
|
+
);
|
|
193
|
+
const itemIds = sourceItems.map(({ id }) => id).sort();
|
|
194
|
+
const commonTerms = sharedPreferenceTerms(sourceItems);
|
|
195
|
+
const pairScores = [];
|
|
196
|
+
for (let left = 0; left < sourceItems.length; left += 1) {
|
|
197
|
+
for (let right = left + 1; right < sourceItems.length; right += 1) {
|
|
198
|
+
pairScores.push(commonKnowledgeSimilarity(
|
|
199
|
+
sourceItems[left],
|
|
200
|
+
sourceItems[right]
|
|
201
|
+
));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const averageSimilarity = pairScores.length === 0
|
|
205
|
+
? 1
|
|
206
|
+
: pairScores.reduce((sum, score) => sum + score, 0) / pairScores.length;
|
|
207
|
+
const ranking = personalGlobalCandidateRanking({
|
|
208
|
+
sourceItems,
|
|
209
|
+
projectCount: group.projectIds.size,
|
|
210
|
+
selectedProjectCount,
|
|
211
|
+
lexicalSimilarity: averageSimilarity
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
candidate_id: personalGlobalPreferenceCandidateId(itemIds),
|
|
215
|
+
candidate_version: null,
|
|
216
|
+
target_scope: 'human_selected',
|
|
217
|
+
source_project_ids: [...group.projectIds].sort(),
|
|
218
|
+
item_kind: group.itemKind,
|
|
219
|
+
preference_key: group.preferenceKey,
|
|
220
|
+
query,
|
|
221
|
+
similarity_score: Number(averageSimilarity.toFixed(4)),
|
|
222
|
+
similarity_basis: 'lexical_overlap_across_explicit_personal_projects',
|
|
223
|
+
candidate_score: ranking.score,
|
|
224
|
+
ranking,
|
|
225
|
+
source_items: sourceItems,
|
|
226
|
+
derived_common_core: {
|
|
227
|
+
terms: commonTerms,
|
|
228
|
+
basis: 'lexical_intersection_of_preserved_source_text',
|
|
229
|
+
authoritative: false,
|
|
230
|
+
source_item_ids: itemIds
|
|
231
|
+
},
|
|
232
|
+
source_specific_terms: sourceItems.map((item) => ({
|
|
233
|
+
item_id: item.id,
|
|
234
|
+
project_id: item.defined_project_id,
|
|
235
|
+
terms: [...preferenceContentTokens(item)]
|
|
236
|
+
.filter((term) => !commonTerms.includes(term))
|
|
237
|
+
.sort()
|
|
238
|
+
})),
|
|
239
|
+
requires_human_scope_judgment: true,
|
|
240
|
+
scope_apply_performed: false
|
|
241
|
+
};
|
|
242
|
+
})
|
|
243
|
+
.sort((left, right) =>
|
|
244
|
+
right.candidate_score - left.candidate_score
|
|
245
|
+
|| right.source_project_ids.length - left.source_project_ids.length
|
|
246
|
+
|| right.similarity_score - left.similarity_score
|
|
247
|
+
|| left.candidate_id.localeCompare(right.candidate_id)
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function personalGlobalItemPreferenceKey(item) {
|
|
252
|
+
return item.preference_key
|
|
253
|
+
?? item.attributes?.preferenceKey
|
|
254
|
+
?? item.attributes?.preference_key
|
|
255
|
+
?? item.key
|
|
256
|
+
?? item.id;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const PERSONAL_GLOBAL_RANKING_WEIGHTS = Object.freeze({
|
|
260
|
+
distinct_projects: 0.25,
|
|
261
|
+
lexical_similarity: 0.35,
|
|
262
|
+
confirmation_authority: 0.2,
|
|
263
|
+
recency: 0.1,
|
|
264
|
+
negative_evidence: 0.1
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
function personalGlobalCandidateRanking({
|
|
268
|
+
sourceItems,
|
|
269
|
+
projectCount,
|
|
270
|
+
selectedProjectCount,
|
|
271
|
+
lexicalSimilarity
|
|
272
|
+
}) {
|
|
273
|
+
const signals = {
|
|
274
|
+
distinct_projects: boundedScore(
|
|
275
|
+
projectCount / Math.max(selectedProjectCount, 1)
|
|
276
|
+
),
|
|
277
|
+
lexical_similarity: boundedScore(lexicalSimilarity),
|
|
278
|
+
confirmation_authority: averageScore(sourceItems.map((item) =>
|
|
279
|
+
item.confirmation_status === 'confirmed' ? 1 : 0.65
|
|
280
|
+
)),
|
|
281
|
+
recency: averageScore(sourceItems.map(personalGlobalItemRecency)),
|
|
282
|
+
negative_evidence: averageScore(sourceItems.map((item) =>
|
|
283
|
+
item.requires_attention === true
|
|
284
|
+
? 0
|
|
285
|
+
: 1 / (1 + Math.max(0, Number(item.negative_evidence_count ?? 0)))
|
|
286
|
+
))
|
|
287
|
+
};
|
|
288
|
+
const details = Object.fromEntries(
|
|
289
|
+
Object.entries(signals).map(([key, value]) => {
|
|
290
|
+
const weight = PERSONAL_GLOBAL_RANKING_WEIGHTS[key];
|
|
291
|
+
return [key, {
|
|
292
|
+
value: Number(value.toFixed(4)),
|
|
293
|
+
weight,
|
|
294
|
+
contribution: Number((value * weight).toFixed(4))
|
|
295
|
+
}];
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
const score = Object.values(details)
|
|
299
|
+
.reduce((sum, signal) => sum + signal.contribution, 0);
|
|
300
|
+
return {
|
|
301
|
+
score: Number(score.toFixed(4)),
|
|
302
|
+
signals: details,
|
|
303
|
+
source_project_count: projectCount,
|
|
304
|
+
selected_project_count: selectedProjectCount,
|
|
305
|
+
policy: 'ranking_only_never_changes_scope_or_confirmation_authority'
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function personalGlobalItemRecency(item) {
|
|
310
|
+
const timestamp = [
|
|
311
|
+
item.last_used_at,
|
|
312
|
+
item.last_human_changed_at,
|
|
313
|
+
item.created_at
|
|
314
|
+
].map((value) => Date.parse(value ?? ''))
|
|
315
|
+
.find(Number.isFinite);
|
|
316
|
+
if (!Number.isFinite(timestamp)) return 0.5;
|
|
317
|
+
const ageDays = Math.max(0, (Date.now() - timestamp) / 86_400_000);
|
|
318
|
+
return Math.exp(-ageDays / 180);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function averageScore(values) {
|
|
322
|
+
if (values.length === 0) return 0;
|
|
323
|
+
return boundedScore(
|
|
324
|
+
values.reduce((sum, value) => sum + value, 0) / values.length
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function boundedScore(value) {
|
|
329
|
+
return Math.max(0, Math.min(1, Number(value) || 0));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function personalGlobalCandidatePolicy() {
|
|
333
|
+
return {
|
|
334
|
+
read_only: true,
|
|
335
|
+
exact_projects_only: true,
|
|
336
|
+
inherited_knowledge_excluded: true,
|
|
337
|
+
personal_global_excluded: true,
|
|
338
|
+
original_text_and_sources_preserved: true,
|
|
339
|
+
derived_core_is_non_authoritative: true,
|
|
340
|
+
human_scope_judgment_required: true,
|
|
341
|
+
automatic_scope_apply: false,
|
|
342
|
+
ranking_scores_are_non_authoritative: true,
|
|
343
|
+
stale_decisions_do_not_suppress_changed_candidates: true
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async function personalGlobalCandidateDecisionState(
|
|
348
|
+
application,
|
|
349
|
+
personalSpaceId,
|
|
350
|
+
candidates
|
|
351
|
+
) {
|
|
352
|
+
if (candidates.length === 0) {
|
|
353
|
+
return { decisions: new Map(), revisions: new Map() };
|
|
354
|
+
}
|
|
355
|
+
const result = await application.personal
|
|
356
|
+
.personalGlobalPreferenceDecisionStatus({
|
|
357
|
+
personal_space_id: personalSpaceId,
|
|
358
|
+
candidates: candidates.map((candidate) => ({
|
|
359
|
+
candidate_id: candidate.candidate_id,
|
|
360
|
+
candidate_version: candidate.candidate_version
|
|
361
|
+
}))
|
|
362
|
+
});
|
|
363
|
+
return {
|
|
364
|
+
decisions: new Map((result.decisions ?? []).map((decision) => [
|
|
365
|
+
`${decision.candidate_id}:${decision.candidate_version}`,
|
|
366
|
+
{
|
|
367
|
+
decision: decision.decision,
|
|
368
|
+
decision_event_id: decision.decision_event_id,
|
|
369
|
+
decision_revision: decision.decision_revision,
|
|
370
|
+
target_scope: decision.target_scope,
|
|
371
|
+
target_project_id: decision.target_project_id ?? null,
|
|
372
|
+
global_assertion_id: decision.global_assertion_id,
|
|
373
|
+
global_assertion_active: decision.global_assertion_active
|
|
374
|
+
}
|
|
375
|
+
])),
|
|
376
|
+
revisions: new Map((result.revisions ?? []).map((revision) => [
|
|
377
|
+
revision.candidate_id,
|
|
378
|
+
revision
|
|
379
|
+
]))
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function personalGlobalCandidateWithDecisionState(candidate, revision) {
|
|
384
|
+
const decisionRevision = revision?.decision_revision ?? 0;
|
|
385
|
+
const previousVersion = revision?.current_candidate_version ?? null;
|
|
386
|
+
const sourceDrift = Boolean(
|
|
387
|
+
previousVersion && previousVersion !== candidate.candidate_version
|
|
388
|
+
);
|
|
389
|
+
return {
|
|
390
|
+
...candidate,
|
|
391
|
+
decision_revision: decisionRevision,
|
|
392
|
+
prior_decision_source_drift: sourceDrift,
|
|
393
|
+
prior_decision_candidate_version: sourceDrift ? previousVersion : null,
|
|
394
|
+
fresh_human_review_required: true
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function providerPersonalGlobalPreferenceDecision(input, {
|
|
399
|
+
approvalToken = null
|
|
400
|
+
} = {}) {
|
|
401
|
+
const result = {
|
|
402
|
+
personal_space_id: input.personalSpaceId,
|
|
403
|
+
candidate_version: input.candidateVersion,
|
|
404
|
+
decision_revision: input.decisionRevision,
|
|
405
|
+
source_items: input.sourceItems.map((item) => ({
|
|
406
|
+
item_id: item.itemId,
|
|
407
|
+
item_kind: item.itemKind,
|
|
408
|
+
project_id: item.projectId
|
|
409
|
+
})),
|
|
410
|
+
preference_key: input.preferenceKey,
|
|
411
|
+
target_scope: input.targetScope,
|
|
412
|
+
target_project_id: input.targetProjectId ?? null,
|
|
413
|
+
decision: input.decision,
|
|
414
|
+
global_title: input.globalTitle ?? null,
|
|
415
|
+
global_instruction: input.globalInstruction ?? null,
|
|
416
|
+
profile_aspect: input.profileAspect ?? null,
|
|
417
|
+
human_confirmation_reason: input.humanConfirmationReason,
|
|
418
|
+
confirmed_at: input.confirmedAt,
|
|
419
|
+
session_id: input.sessionId,
|
|
420
|
+
idempotency_key: input.idempotencyKey
|
|
421
|
+
};
|
|
422
|
+
if (approvalToken) result.approval_token = approvalToken;
|
|
423
|
+
return result;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function personalGlobalPreferenceCandidateId(itemIds) {
|
|
427
|
+
return `personal-global-${createHash('sha256')
|
|
428
|
+
.update([...itemIds].sort().join('\n'))
|
|
429
|
+
.digest('hex')
|
|
430
|
+
.slice(0, 20)}`;
|
|
431
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { providerProjectProfile } from './project-profile-mapping.js';
|
|
2
|
+
|
|
3
|
+
export async function upsertPersonalProject(application, input) {
|
|
4
|
+
if (input.personalSpaceId !== application.config.personal.spaceId) {
|
|
5
|
+
throw new TypeError('Personal project must belong to the active personal space');
|
|
6
|
+
}
|
|
7
|
+
return application.personal.upsertPersonalProject({
|
|
8
|
+
personal_space_id: input.personalSpaceId,
|
|
9
|
+
project_id: input.projectId,
|
|
10
|
+
profile: providerProjectProfile(input.profile),
|
|
11
|
+
...(input.createOnly === true ? { create_only: true } : {})
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function listPersonalProjects(application, input = {}) {
|
|
16
|
+
const personalSpaceId = input.personalSpaceId ?? application.config.personal.spaceId;
|
|
17
|
+
if (personalSpaceId !== application.config.personal.spaceId) {
|
|
18
|
+
throw new TypeError('Personal projects must use the active personal space');
|
|
19
|
+
}
|
|
20
|
+
return application.personal.listPersonalProjects(personalSpaceId);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function listProjectRelationWeights(application, input = {}) {
|
|
24
|
+
const personalSpaceId = input.personalSpaceId ?? application.config.personal.spaceId;
|
|
25
|
+
if (personalSpaceId !== application.config.personal.spaceId) {
|
|
26
|
+
throw new TypeError('Project relation weights must use the active personal space');
|
|
27
|
+
}
|
|
28
|
+
// The authenticated observation reader filters temporary/archived projects
|
|
29
|
+
// and applies the same directional thresholds as the graph projection.
|
|
30
|
+
const observations = await application.personal.readProjectMemoryUsage(personalSpaceId);
|
|
31
|
+
return observations.map(row => ({ fromProjectId: row.source_project_id, toProjectId: row.target_project_id,
|
|
32
|
+
tier: row.statistics.tier, recent30dCount: row.statistics.recent30dCount }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { providerReaderFields, taskKnowledgeReader } from './knowledge-reader.js';
|
|
2
|
+
import { assertActivePersonalSpace } from './active-personal-space.js';
|
|
3
|
+
import { assertSafeKnowledgeMutation } from './knowledge-credential-guard.js';
|
|
4
|
+
|
|
5
|
+
// An Agent reads as a plain session: no conflict naming an FLA's own item (an FLA meets those in its
|
|
6
|
+
// task context). Only the console passes ownerReads (src/knowledge-owner-reads) for the full list.
|
|
7
|
+
export async function listPreferenceConflicts(application, { personalSpaceId, status = null, limit = 500 }, ownerReads = null) {
|
|
8
|
+
assertActivePersonalSpace(application, personalSpaceId);
|
|
9
|
+
return ownerReads
|
|
10
|
+
? ownerReads.preferenceConflicts({ personalSpaceId, status, limit })
|
|
11
|
+
: application.personal.listPreferenceConflicts(personalSpaceId, status, limit);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// A conflict naming an item its reader may not see answers as missing: an Agent names its FLA
|
|
15
|
+
// (projectAgentId) or reads as a plain session; the console's defer and completion pass ownerReads.
|
|
16
|
+
export async function deferPreferenceConflict(application, input, ownerReads = null) {
|
|
17
|
+
assertActivePersonalSpace(application, input.personalSpaceId);
|
|
18
|
+
const body = {
|
|
19
|
+
personal_space_id: input.personalSpaceId,
|
|
20
|
+
conflict_id: input.conflictId,
|
|
21
|
+
preference_key: input.preferenceKey,
|
|
22
|
+
preference_scope: input.preferenceScope,
|
|
23
|
+
preference_project_id: input.preferenceProjectId ?? null,
|
|
24
|
+
left_item_id: input.leftItemId,
|
|
25
|
+
left_item_kind: input.leftItemKind,
|
|
26
|
+
right_item_id: input.rightItemId,
|
|
27
|
+
right_item_kind: input.rightItemKind,
|
|
28
|
+
reason: input.reason,
|
|
29
|
+
operation_actor: input.operationActor ?? 'human'
|
|
30
|
+
};
|
|
31
|
+
return ownerReads ? ownerReads.deferPreferenceConflict(body)
|
|
32
|
+
: application.personal.deferPreferenceConflict({ ...body, ...providerReaderFields(taskKnowledgeReader(input)) });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function resolveDeferredPreferenceConflict(application, input) {
|
|
36
|
+
assertActivePersonalSpace(application, input.personalSpaceId);
|
|
37
|
+
assertSafeKnowledgeMutation(input);
|
|
38
|
+
return application.personal.resolvePreferenceConflict(input.conflictId, {
|
|
39
|
+
...providerReaderFields(taskKnowledgeReader(input)),
|
|
40
|
+
personal_space_id: input.personalSpaceId,
|
|
41
|
+
resolution: input.resolution,
|
|
42
|
+
reason: input.reason,
|
|
43
|
+
canonical_item_id: input.canonicalItemId ?? null,
|
|
44
|
+
merged_instruction: input.mergedInstruction ?? null,
|
|
45
|
+
split_item_id: input.splitItemId ?? null,
|
|
46
|
+
split_project_id: input.splitProjectId ?? null,
|
|
47
|
+
operation_actor: input.operationActor ?? 'agent'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function completePreferenceConflict(application, input, ownerReads = null) {
|
|
52
|
+
assertActivePersonalSpace(application, input.personalSpaceId);
|
|
53
|
+
const body = { personal_space_id: input.personalSpaceId, resolution: input.resolution, reason: input.reason,
|
|
54
|
+
operation_actor: input.operationActor ?? 'human' };
|
|
55
|
+
return ownerReads ? ownerReads.completePreferenceConflict(input.conflictId, body)
|
|
56
|
+
: application.personal.completePreferenceConflict(input.conflictId, body);
|
|
57
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InvalidInputError } from '../app/application-error.js';
|
|
2
|
+
|
|
3
|
+
export async function resolvePreferenceProject(application, { personalProjectId, projectPath }) {
|
|
4
|
+
if (projectPath !== undefined && projectPath !== null) {
|
|
5
|
+
const projects = await application.personal.listPersonalProjects(
|
|
6
|
+
application.config.personal.spaceId
|
|
7
|
+
);
|
|
8
|
+
const resolution = application.projectPathResolver(projectPath, projects);
|
|
9
|
+
if (
|
|
10
|
+
personalProjectId
|
|
11
|
+
&& resolution.personalProjectId
|
|
12
|
+
&& personalProjectId !== resolution.personalProjectId
|
|
13
|
+
) {
|
|
14
|
+
throw new InvalidInputError(
|
|
15
|
+
'personalProjectId conflicts with the exact projectPath match'
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
if (personalProjectId) {
|
|
19
|
+
return {
|
|
20
|
+
status: 'matched',
|
|
21
|
+
basis: 'explicit_personal_project_id',
|
|
22
|
+
personalProjectId
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return resolution;
|
|
26
|
+
}
|
|
27
|
+
if (personalProjectId) {
|
|
28
|
+
return {
|
|
29
|
+
status: 'matched',
|
|
30
|
+
basis: 'explicit_personal_project_id',
|
|
31
|
+
personalProjectId
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
status: 'not_provided',
|
|
36
|
+
basis: null,
|
|
37
|
+
personalProjectId: null
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -48,6 +48,24 @@ export function preferenceSceneReplaceable(item) {
|
|
|
48
48
|
|| generalItemReplaceable(qualifiers, item.profile_aspect);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
// What an inline entry budget leaves out last (rec#11 D-54, D-69): a rule a
|
|
52
|
+
// person marked constraint: "hard". A boundary in the scene sense (an
|
|
53
|
+
// unmarked judgment_preference without a scene key, task-scene.js) is only the
|
|
54
|
+
// scene table's default, so a scene switch never revokes it; it carries no
|
|
55
|
+
// marker that it must never be left out, so the budget ranks it first among
|
|
56
|
+
// the rest instead (entry-inline-budget.js).
|
|
57
|
+
export function preferenceAlwaysInline(item) {
|
|
58
|
+
return itemQualifiers(item).constraint === 'hard';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Whether the item's own scene key (a workKind qualifier or a tasteDomain)
|
|
62
|
+
// names this work kind: such an item is the task scene's own personalization,
|
|
63
|
+
// so an inline budget keeps it before a general one (D-54).
|
|
64
|
+
export function preferenceNamesWorkKind(item, workKind) {
|
|
65
|
+
return Boolean(workKind) && taskScopeConditions(item, itemQualifiers(item), {})
|
|
66
|
+
.some(({ values, scene }) => scene && Array.isArray(values) && values.includes(workKind));
|
|
67
|
+
}
|
|
68
|
+
|
|
51
69
|
function itemQualifiers(item) {
|
|
52
70
|
return { ...item.attributes, ...item.attributes?.preference_qualifiers, ...item.preference_qualifiers };
|
|
53
71
|
}
|
|
@@ -7,7 +7,8 @@ import { planAgentCollaboration, agentLoan, agentVerification } from './agent-co
|
|
|
7
7
|
import { queryConversations, resumeConversation, updateConversationPolicy } from './agent-conversations.js';
|
|
8
8
|
import { recordUserTriage } from './conversation-triage.js';
|
|
9
9
|
import { acceptTopicProposal, declineTopicProposal, listTopicProposals } from './topic-proposals.js';
|
|
10
|
-
import {
|
|
10
|
+
import { registerStandingAssignment } from './standing-assignment-entry.js';
|
|
11
|
+
import { agentProjectResolution } from './agent-project-resolution.js';
|
|
11
12
|
import { listAgentAttention, getAgentAttention, changeAgentAttention, respondToAgentAttention } from './agent-attention.js';
|
|
12
13
|
import { loadProjectTeam } from './project-team-view.js';
|
|
13
14
|
import { dismissProjectAgent, getAgentHandoff, listAgentDismissalLessons } from './project-agent-dismissal.js';
|
|
@@ -95,6 +96,10 @@ export class ProjectAgentControlPlaneApplication {
|
|
|
95
96
|
if (operation === 'accept') return acceptTopicProposal(this, { topic: input.topic });
|
|
96
97
|
return declineTopicProposal(this, { topic: input.topic });
|
|
97
98
|
}
|
|
99
|
+
// The person's "from now on this work goes to that project" (rec#29 F2).
|
|
100
|
+
async registerStandingAssignment(input) {
|
|
101
|
+
return registerStandingAssignment(this, input);
|
|
102
|
+
}
|
|
98
103
|
async queryAgentConversations(input) {
|
|
99
104
|
this.#assertSpace(input.personalSpaceId);
|
|
100
105
|
return queryConversations(this, input);
|
|
@@ -67,6 +67,23 @@ export async function resolveTaskEntryAgent(application, resolution, input) {
|
|
|
67
67
|
required_action: 'Use coordinate_project_agent_task to select or recruit a qualified durable owner before implementation. AR and project managers collaborate in their own roles; do not attribute development to them by fallback.' };
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
// A standing assignment's Agent other than the one chosen is asked for by
|
|
71
|
+
// name, like an explicit Agent: the Provider keeps the project's lead
|
|
72
|
+
// accountable and names a member as requested_agent_id. A request it
|
|
73
|
+
// cannot serve or answer keeps the ordinary choice, marked unreached so
|
|
74
|
+
// the routing notice does not claim the switch; one never repeats the other.
|
|
75
|
+
const standingAgentId = resolution.standingOwner?.leadAgentId ?? resolution.standingAgentId ?? null;
|
|
76
|
+
let standingAgentUnreached = false;
|
|
77
|
+
if (implicit && !delegation && standingAgentId && value.status === 'ready'
|
|
78
|
+
&& ![agent?.agentId, value.requested_agent_id].includes(standingAgentId)) {
|
|
79
|
+
const standing = await application.personal.resolveProjectAgentContext({ ...contextRequest,
|
|
80
|
+
agent_id: standingAgentId }).catch(() => null);
|
|
81
|
+
standingAgentUnreached = !(standing?.status === 'ready' && standing.agent);
|
|
82
|
+
if (!standingAgentUnreached) {
|
|
83
|
+
value = standing;
|
|
84
|
+
agent = projectAgentRecord(standing.agent);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
70
87
|
const employeeId = /^employee\.([a-z][a-z0-9-]{0,63})$/.exec(agent?.agentId ?? '')?.[1];
|
|
71
88
|
if (employeeId && application.employees) {
|
|
72
89
|
try { await application.employees.authorize({ templateId: employeeId, personalProjectId: resolution.personalProjectId }); }
|
|
@@ -76,7 +93,7 @@ export async function resolveTaskEntryAgent(application, resolution, input) {
|
|
|
76
93
|
!(agent.profile.allowedClients ?? []).includes(input.sourceApplication ?? 'other'))) {
|
|
77
94
|
return { status: 'agent_unavailable', worker_started: false };
|
|
78
95
|
}
|
|
79
|
-
return { ...value, agent, worker_started: false };
|
|
96
|
+
return { ...value, agent, worker_started: false, ...(standingAgentUnreached ? { standingAgentUnreached } : {}) };
|
|
80
97
|
} catch {
|
|
81
98
|
// Preferences remain useful during an older/offline Provider upgrade, but
|
|
82
99
|
// never claim that a role or its private memory was successfully restored.
|