fuli-context 0.27.0 → 0.27.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-Bp2Edkdg.js → AboutPage-Bgcf03U0.js} +1 -1
- package/dist/web/assets/{AboutSectionHeading-DFfY2f_Z.js → AboutSectionHeading-BaQBY_Xs.js} +1 -1
- package/dist/web/assets/AgentAppsPage-DNuujLT2.js +1 -0
- package/dist/web/assets/{AgentAvatar-w-2A3nsJ.js → AgentAvatar-DGXedNUs.js} +1 -1
- package/dist/web/assets/{AgentHand-BGGU49Jt.js → AgentHand-BwE2VGth.js} +1 -1
- package/dist/web/assets/AgentManagement-2r8DUS1N.js +7 -0
- package/dist/web/assets/AgentManagement-hRkMpjvY.css +1 -0
- package/dist/web/assets/{AgentMentionCopy-BAHZjubz.js → AgentMentionCopy-y3JD1Cef.js} +1 -1
- package/dist/web/assets/{AgentName-CXlsC-4o.js → AgentName-XrBcHq4R.js} +1 -1
- package/dist/web/assets/AgentProfilePage-DE7z980p.js +5 -0
- package/dist/web/assets/AgentServicesPage-CWfGSxcb.js +1 -0
- package/dist/web/assets/{AppViewerPage-6gWP6nAf.js → AppViewerPage-BaKMk9pp.js} +1 -1
- package/dist/web/assets/{BackToTop-Cs5_rV99.js → BackToTop-DITd9y7X.js} +1 -1
- package/dist/web/assets/{BoardCardFieldsMenu-CvFrsIgy.js → BoardCardFieldsMenu-CWtHiVR-.js} +1 -1
- package/dist/web/assets/{BoardMoveMenu-B5isxIcK.js → BoardMoveMenu-CEDdltY7.js} +1 -1
- package/dist/web/assets/Breadcrumb-C98voz9V.js +1 -0
- package/dist/web/assets/{CaptureChangePage-Ca72_PHc.js → CaptureChangePage-CE8tJfiQ.js} +1 -1
- package/dist/web/assets/{CopyFixPrompt-wGATZKOq.js → CopyFixPrompt-C2hC04lV.js} +1 -1
- package/dist/web/assets/DataFormatPage-BjZkck9o.js +2 -0
- package/dist/web/assets/DebugTurnPage-B82geu1y.js +1 -0
- package/dist/web/assets/DebugTurnsPage-BlDDz1Fk.js +1 -0
- package/dist/web/assets/DialogTitle-fpANsAcy.js +1 -0
- package/dist/web/assets/{EmployeeRedirectPage-C2SHpAEF.js → EmployeeRedirectPage-CSSuvAqx.js} +1 -1
- package/dist/web/assets/EmployeeScopeDialog-BoEMQOEj.js +1 -0
- package/dist/web/assets/EmployeeWorkbench-DvEojWb7.js +4 -0
- package/dist/web/assets/{EmployeeWorkbench-Bp9pUkfS.css → EmployeeWorkbench-rhY970vW.css} +1 -1
- package/dist/web/assets/FieldRoot-D3lnRut5.js +1 -0
- package/dist/web/assets/{FlaGrowth-DGnUPN7D.js → FlaGrowth-OdlmgEVi.js} +1 -1
- package/dist/web/assets/{FlaOccupationKit-DAJjSrmL.js → FlaOccupationKit-CnouVWnU.js} +1 -1
- package/dist/web/assets/{FlaTaskSheets-DRLgfrVC.js → FlaTaskSheets-rSIdCtzz.js} +1 -1
- package/dist/web/assets/FlasPage-BZ791caF.js +1 -0
- package/dist/web/assets/{FlasPage-H99IZ9M6.css → FlasPage-D3CcJcvN.css} +1 -1
- package/dist/web/assets/{GrowthLoading-NLj2W4jj.js → GrowthLoading-BYOSvxZY.js} +1 -1
- package/dist/web/assets/{HowtoPage-CrvMmT6K.css → HowtoPage-DNTwYQCD.css} +1 -1
- package/dist/web/assets/HowtoPage-lYwzi4Vm.js +1 -0
- package/dist/web/assets/InboxPage-C3cSvJjB.js +6 -0
- package/dist/web/assets/{KnowledgeDeleteButton-DaT-gTmm.js → KnowledgeDeleteButton-yc8Gi-BH.js} +1 -1
- package/dist/web/assets/{KnowledgeHardDeleteSection-C9d7DVLa.js → KnowledgeHardDeleteSection-D9Ktc-uC.js} +1 -1
- package/dist/web/assets/KnowledgeItemEditPage-Csy4oOxD.js +1 -0
- package/dist/web/assets/{KnowledgeItemSummaryCard-eLzjKvgN.js → KnowledgeItemSummaryCard-BH5UYmde.js} +1 -1
- package/dist/web/assets/KnowledgeOrganizerPage-BTeQX0gH.js +1 -0
- package/dist/web/assets/KnowledgePage-BuukvNxz.js +1 -0
- package/dist/web/assets/KnowledgePeek-D0pcU7U5.js +1 -0
- package/dist/web/assets/KnowledgeTurnReceiptPage-Bd_LIdCc.js +1 -0
- package/dist/web/assets/{KnowledgeWorkspace-DDg3tUb3.css → KnowledgeWorkspace-Be2gUul5.css} +1 -1
- package/dist/web/assets/KnowledgeWorkspace-Dr-zYpDQ.js +4 -0
- package/dist/web/assets/{MeAvatar-f6qxg9dN.js → MeAvatar-CmhuRFOf.js} +1 -1
- package/dist/web/assets/{MeLink-DTvFYaYE.js → MeLink-BesUihiS.js} +1 -1
- package/dist/web/assets/MenuSeparator-BGo0DgyF.js +1 -0
- package/dist/web/assets/{ModelSettingsPage-B38R-kBZ.css → ModelSettingsPage-BZcyT7Vy.css} +1 -1
- package/dist/web/assets/ModelSettingsPage-CBPwuIBM.js +1 -0
- package/dist/web/assets/{NewSessionPanel-9yINjwyx.js → NewSessionPanel-Bvp9ElzU.js} +1 -1
- package/dist/web/assets/{NotFoundPage-CqevPz0_.js → NotFoundPage-BrolI2fz.js} +1 -1
- package/dist/web/assets/{workbench-card-Dt0820yW.css → NoticeRow-DD-J76Yo.css} +1 -1
- package/dist/web/assets/NoticeRow-Q9QT5NqB.js +1 -0
- package/dist/web/assets/OccupationsPage-CZCeeihl.js +1 -0
- package/dist/web/assets/{PageOutline-HHUlu2x3.js → PageOutline-DULpqEwg.js} +1 -1
- package/dist/web/assets/PageStack-BMzrkyV4.css +1 -0
- package/dist/web/assets/PageStack-DTzWJuae.js +1 -0
- package/dist/web/assets/{PersonalProfilePage-DnjNX2xK.css → PersonalProfilePage-BE5q2bqc.css} +1 -1
- package/dist/web/assets/PersonalProfilePage-DbXWycCQ.js +1 -0
- package/dist/web/assets/PersonalProjectsPage-pdAJpnZd.js +1 -0
- package/dist/web/assets/{PinIcon-DP-9Iisk.js → PinIcon-YYoaYKTx.js} +1 -1
- package/dist/web/assets/PopperContent-CnNwFMIA.js +1 -0
- package/dist/web/assets/Presence-CuIoA2sH.js +3 -0
- package/dist/web/assets/{ProfileAuthorChip-BKZJC_N2.js → ProfileAuthorChip-BEfiuJbm.js} +1 -1
- package/dist/web/assets/ProjectAgentsPage-BPf2RLsw.js +5 -0
- package/dist/web/assets/{ProjectJudgmentPolicy-BJ5sVuFI.js → ProjectJudgmentPolicy-CCzHtmOb.js} +1 -1
- package/dist/web/assets/{RoundtablesPage-D5Xc3yun.js → RoundtablesPage-BDU4W-bg.js} +1 -1
- package/dist/web/assets/RovingFocusGroup-DS4v3bEq.js +1 -0
- package/dist/web/assets/RovingFocusItem-bLEnnw2Y.js +1 -0
- package/dist/web/assets/SessionMigrationPage-DrK4df0L.js +1 -0
- package/dist/web/assets/{SessionRecordsPage-C6U5YGSt.js → SessionRecordsPage-CFAgM65g.js} +1 -1
- package/dist/web/assets/SettingsPage-CsJxhhsu.js +1 -0
- package/dist/web/assets/SettingsPage-VX_e4ty2.css +1 -0
- package/dist/web/assets/SharedJefaReportPage-DbTPYwa_.js +1 -0
- package/dist/web/assets/StatementCalendarPage-CIo5R14R.js +1 -0
- package/dist/web/assets/StatementCalendarPage-t8pJI4G6.css +1 -0
- package/dist/web/assets/StatementRows-CubaC9KG.js +1 -0
- package/dist/web/assets/StatementRows-TQ2i_uXU.css +1 -0
- package/dist/web/assets/{TagVocabularyPage-Brpr-Q-y.js → TagVocabularyPage-BVlLmKv2.js} +1 -1
- package/dist/web/assets/TaskBlockerNotice-YSvmy6B4.js +1 -0
- package/dist/web/assets/{TaskReason-RKKs4Kb5.js → TaskReason-CrLPeiOg.js} +1 -1
- package/dist/web/assets/{TeamCard-8hjo1h0x.js → TeamCard-SBMJMd7P.js} +1 -1
- package/dist/web/assets/TeamCardsWidget-CGLW04TH.js +1 -0
- package/dist/web/assets/TeamIsland-jJKTwCJD.js +9 -0
- package/dist/web/assets/Teleport-CRjWb-eC.js +1 -0
- package/dist/web/assets/{TextField-G2fJ4aFQ.js → TextField-Cd8UOHKv.js} +1 -1
- package/dist/web/assets/TodayPage-BvbZCEFJ.js +1 -0
- package/dist/web/assets/TodayPage-EJ8SWFE0.css +1 -0
- package/dist/web/assets/TonborgDelegationSwitch-BFb1JkWe.css +1 -0
- package/dist/web/assets/TonborgDelegationSwitch-BOidSjkk.js +1 -0
- package/dist/web/assets/{UiChip-BHEJVA6L.js → UiChip-B2z0UERX.js} +1 -1
- package/dist/web/assets/{UiDisclosure-B1pd8qXW.js → UiDisclosure-Bw4Wu0Dm.js} +1 -1
- package/dist/web/assets/{UiIcon-K7OhYTSy.js → UiIcon-BuaIQ57Z.js} +1 -1
- package/dist/web/assets/UiSegmented-DlI1vR3k.js +1 -0
- package/dist/web/assets/{UiWeight-eAw682rH.js → UiWeight-DpBexUUy.js} +1 -1
- package/dist/web/assets/{VirtualDirectoryList-BGum1GZc.js → VirtualDirectoryList-RV2XtTPO.js} +1 -1
- package/dist/web/assets/{VisuallyHidden-Ck6D7rq-.js → VisuallyHidden-DciDIEua.js} +1 -1
- package/dist/web/assets/{VisuallyHiddenInput-DXWhIUlB.js → VisuallyHiddenInput-mfi7gVBu.js} +1 -1
- package/dist/web/assets/WidgetSlot-xFZKjZ5z.js +2 -0
- package/dist/web/assets/WorkbenchListPage-BKT03RRO.css +1 -0
- package/dist/web/assets/WorkbenchListPage-suawrzji.js +1 -0
- package/dist/web/assets/_plugin-vue_export-helper-CYsAcErn.js +9 -0
- package/dist/web/assets/{agent-apps-D0eG1aMx.js → agent-apps-B_0syRPr.js} +1 -1
- package/dist/web/assets/agent-occupation-C-9THmIG.js +1 -0
- package/dist/web/assets/{agent-pins-OYjJQ38F.js → agent-pins-B9wMvxGh.js} +1 -1
- package/dist/web/assets/{agent-roster-records-CsYjmaNn.js → agent-roster-records-CY0aSUNq.js} +1 -1
- package/dist/web/assets/{agent-work-summary-BOeJ4JXc.js → agent-work-summary-Cs8jPFL0.js} +1 -1
- package/dist/web/assets/{attach-closest-edge-C75rKXiz.js → attach-closest-edge-BRDsvYPn.js} +1 -1
- package/dist/web/assets/{attention-store-k4mPCefZ.js → attention-store-HMiJ1K6M.js} +1 -1
- package/dist/web/assets/{badge-B2rll-68.js → badge-jafr8Jg1.js} +1 -1
- package/dist/web/assets/{button-q6JhonlL.js → button-d6TCVE0s.js} +1 -1
- package/dist/web/assets/{card-CPQiMHSu.js → card-ebnaJXQA.js} +1 -1
- package/dist/web/assets/{catalog-CBPcEkXC.js → catalog-CvdvPGYk.js} +1 -1
- package/dist/web/assets/checkbox-CdIozFRY.js +1 -0
- package/dist/web/assets/{client-KFFphxpK.js → client--hZxcKYo.js} +1 -1
- package/dist/web/assets/{client-links-store-Cw9c8MWc.js → client-links-store-XyR0EzJi.js} +1 -1
- package/dist/web/assets/combobox-DzLSYxyO.js +1 -0
- package/dist/web/assets/{console-BCR2S3AF.js → console-D597wx3f.js} +1 -1
- package/dist/web/assets/conversation-launcher-settings-CFFH9C2y.js +1 -0
- package/dist/web/assets/copy-mention-CWsw8po1.js +1 -0
- package/dist/web/assets/dialog-SLa8cPbS.js +1 -0
- package/dist/web/assets/{dist-CaVgk2QB.js → dist-B78L06NL.js} +1 -1
- package/dist/web/assets/{dist-D73EXNtz.js → dist-Dy5JoHWF.js} +1 -1
- package/dist/web/assets/dropdown-menu-C-PcZxRY.js +1 -0
- package/dist/web/assets/{field-BaUOZtN5.js → field-DeguT8it.js} +1 -1
- package/dist/web/assets/{format-bytes-D5eCtdg1.js → format-bytes-Br4RwHnA.js} +1 -1
- package/dist/web/assets/hover-card-B-H7mMvg.js +1 -0
- package/dist/web/assets/identity-V8oA_IuB.js +1 -0
- package/dist/web/assets/{index-HRZACEmh.css → index-CHDkJLQR.css} +1 -1
- package/dist/web/assets/index-DdAVEwQV.js +24 -0
- package/dist/web/assets/{input-Dxh25T4M.js → input-CRCpCN_c.js} +1 -1
- package/dist/web/assets/label-DwMBzI2m.js +1 -0
- package/dist/web/assets/label-table-DiaZlHIp.js +1 -0
- package/dist/web/assets/{model-ZwOxwk2m.js → model-B4AuKvPj.js} +1 -1
- package/dist/web/assets/model-BwOv-HBS.js +1 -0
- package/dist/web/assets/{model-Blk5Wgg2.js → model-C-60EMcI.js} +1 -1
- package/dist/web/assets/{model-Bgh75q3j.js → model-CB4ObIOH.js} +1 -1
- package/dist/web/assets/{model--lR9icA_.js → model-CUAxIOXR.js} +1 -1
- package/dist/web/assets/{model-jC3F-J2F.js → model-CjQPAeCy.js} +1 -1
- package/dist/web/assets/{model-D4DkvMH-.js → model-CwFZ_IgV.js} +1 -1
- package/dist/web/assets/{model-CWMP5GOL.js → model-D-vak-m0.js} +1 -1
- package/dist/web/assets/{motion-BL3lek9c.js → motion-Cr9JChF9.js} +1 -1
- package/dist/web/assets/motion-D5Fs3-ut.js +1 -0
- package/dist/web/assets/{motion-preference-D3UMHojT.js → motion-preference-DgdzdVh8.js} +1 -1
- package/dist/web/assets/{occupation-catalog-BeJ2O9nm.js → occupation-catalog-DHsjkd_q.js} +1 -1
- package/dist/web/assets/{occupation-kits-Bkiu6MzD.js → occupation-kits-BVLLRN4V.js} +1 -1
- package/dist/web/assets/{option-Crs2MA88.js → option-DhAwzags.js} +1 -1
- package/dist/web/assets/{orchestration-filters-3AfjDoHQ.js → orchestration-filters-lhR2CHlQ.js} +1 -1
- package/dist/web/assets/overview-data-QDnygL-x.js +1 -0
- package/dist/web/assets/{page-refresh-Bz5r7A_Q.js → page-refresh-BVRlo-dI.js} +1 -1
- package/dist/web/assets/{page-title-KYZApNys.js → page-title-ReSXziuS.js} +1 -1
- package/dist/web/assets/{person-profile-mhLxWtq7.js → person-profile-BgUfg57K.js} +1 -1
- package/dist/web/assets/popover-UYksnAeH.js +1 -0
- package/dist/web/assets/popup-host-DMoMkD3v.js +1 -0
- package/dist/web/assets/preference-conflicts-a-H51vUw.js +1 -0
- package/dist/web/assets/{profile-model-DWutKuCZ.js → profile-model-CM98TJsj.js} +1 -1
- package/dist/web/assets/{project-board-layout-CWMHQuUA.js → project-board-layout-RH6UXkCA.js} +1 -1
- package/dist/web/assets/{project-capture-CebFSnn0.js → project-capture-DcQ8cXIt.js} +1 -1
- package/dist/web/assets/{project-origin-BnUVE0be.js → project-origin-BNzeAazi.js} +1 -1
- package/dist/web/assets/{quick-edit-api-YwzoODMc.js → quick-edit-api-COKVNuPk.js} +1 -1
- package/dist/web/assets/radio-group-DfegNkLG.js +1 -0
- package/dist/web/assets/review-api-CAKGInLD.js +1 -0
- package/dist/web/assets/{review-list-_PN7ljSY.js → review-list-CbpXvBp-.js} +1 -1
- package/dist/web/assets/{review-store-CobX9No6.js → review-store-BzrmqVoj.js} +1 -1
- package/dist/web/assets/{role-names-wD9l8uz5.js → role-names-Ba0c6AbS.js} +1 -1
- package/dist/web/assets/{roundtable-live-Dm4Vwo75.js → roundtable-live-CoKmaXKd.js} +1 -1
- package/dist/web/assets/{runtime-dom.esm-bundler-DzfwnSj8.js → runtime-dom.esm-bundler-CaYBCU9Y.js} +1 -1
- package/dist/web/assets/select-Bq2TQ0Gw.js +1 -0
- package/dist/web/assets/{session-launch-offers-C9UkoKUJ.js → session-launch-offers-C-oBkMKe.js} +1 -1
- package/dist/web/assets/{settings-autosave-L0zSXnBO.js → settings-autosave-C3bTildI.js} +1 -1
- package/dist/web/assets/settings-tabs-DFZcxOaQ.js +1 -0
- package/dist/web/assets/shared-report-Ci1jBiYV.js +3 -0
- package/dist/web/assets/{source-adapters-r-NIqO77.js → source-adapters-CunVF9JG.js} +1 -1
- package/dist/web/assets/switch-DaUSEDq0.js +1 -0
- package/dist/web/assets/tabs-B_7xQRfl.js +1 -0
- package/dist/web/assets/{task-card-fields-B1z1PmTT.js → task-card-fields-Ce11pWnv.js} +1 -1
- package/dist/web/assets/{task-evidence-DydhKn9x.js → task-evidence-D0XkNnb8.js} +1 -1
- package/dist/web/assets/{task-labels-DTc5OuFF.js → task-labels-BulIuDQB.js} +1 -1
- package/dist/web/assets/{task-reason-CneTZWRv.js → task-reason-gHlp8KHO.js} +1 -1
- package/dist/web/assets/{team-sheets-CUt3Vp2s.js → team-sheets-BzV1WjjK.js} +1 -1
- package/dist/web/assets/{textarea-DJ0ucCir.js → textarea-D6czUY3a.js} +1 -1
- package/dist/web/assets/ui-BCHzwL4X.js +1 -0
- package/dist/web/assets/ui-CgwSWg1F.css +1 -0
- package/dist/web/assets/{useAgentRecords-CwkwZy8H.js → useAgentRecords-DijrJ79w.js} +1 -1
- package/dist/web/assets/{useAgentWorkSummary-DoiCqME7.js → useAgentWorkSummary-CUv88AVP.js} +1 -1
- package/dist/web/assets/{useApi-CROJJdhE-CenjhnR5.js → useApi-CROJJdhE-CxqsMZ6P.js} +1 -1
- package/dist/web/assets/{useClipboardCopy-Ba86PzjA.js → useClipboardCopy-uGyNKuWB.js} +1 -1
- package/dist/web/assets/useDirection-Bi78LycK.js +1 -0
- package/dist/web/assets/{useFocusReturn-B0ErBkt_.js → useFocusReturn-7BKdKvqF.js} +1 -1
- package/dist/web/assets/{useForwardPropsEmits-D1vvIUcB.js → useForwardPropsEmits-BMeknK03.js} +1 -1
- package/dist/web/assets/useForwardScopeId-DHGSyWlZ.js +1 -0
- package/dist/web/assets/{useKnowledgeConfirm-781LUhoU.js → useKnowledgeConfirm-mFWI8EbK.js} +1 -1
- package/dist/web/assets/{useKnowledgeItemPeek-CnuCvJKQ.js → useKnowledgeItemPeek-DtazLM2s.js} +1 -1
- package/dist/web/assets/{useMinimumLoadingDisplay-DCC9EfQ9.js → useMinimumLoadingDisplay-D5UC2KRz.js} +1 -1
- package/dist/web/assets/{usePageTools-BaB021q0.js → usePageTools-BXkR_gpB.js} +1 -1
- package/dist/web/assets/usePrimitiveElement-BxOn-Fn_.js +1 -0
- package/dist/web/assets/{useProjectAgentRoster-M3wbWpS-.js → useProjectAgentRoster-blZ5REnH.js} +1 -1
- package/dist/web/assets/{useRoutePeek-CYg5JyYt.js → useRoutePeek-D_j5KVFv.js} +1 -1
- package/dist/web/assets/useTeamWork-e57CKhLW.js +1 -0
- package/dist/web/assets/{useTypeahead-DYb5kVkH.js → useTypeahead-6a1q-4Oq.js} +1 -1
- package/dist/web/assets/{utils-Cli0RsEd.js → utils-BQtZ8ZUw.js} +1 -1
- package/dist/web/assets/{utils-B7sUn8rD.js → utils-DBsOpQt4.js} +1 -1
- package/dist/web/assets/{verification-DY7kllTI.js → verification-BlF0avgs.js} +1 -1
- package/dist/web/assets/{version-CBgUEmnM.js → version-oG6VyAd6.js} +1 -1
- package/dist/web/assets/{vue-router-ab7kABlJ.js → vue-router-CCvxNose.js} +1 -1
- package/dist/web/index.html +75 -79
- package/docs/agent-roundtable.md +45 -3
- package/docs/judgment-and-autonomy.md +2 -0
- package/graph-provider/fuli_graph/app.py +6 -0
- package/graph-provider/fuli_graph/knowledge_duplicates.py +27 -14
- package/graph-provider/fuli_graph/knowledge_search.py +31 -32
- package/graph-provider/fuli_graph/knowledge_semantic.py +38 -11
- package/graph-provider/fuli_graph/knowledge_statement.py +230 -0
- package/graph-provider/fuli_graph/knowledge_statement_days.py +109 -0
- package/graph-provider/fuli_graph/models.py +15 -0
- package/graph-provider/fuli_graph/preference_organizing.py +162 -0
- package/graph-provider/fuli_graph/project_agent_routes.py +22 -0
- package/graph-provider/fuli_graph/project_agent_task_models.py +26 -2
- package/graph-provider/fuli_graph/store_project_agent_task_activity.py +51 -11
- package/graph-provider/fuli_graph/store_project_agent_task_blockers.py +13 -6
- package/graph-provider/fuli_graph/store_project_agent_task_person_close.py +82 -0
- package/graph-provider/fuli_graph/store_project_agent_tasks.py +18 -1
- package/graph-provider/fuli_graph/task_blocker.py +10 -0
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +57 -9
- package/package.json +4 -3
- package/packages/roundtable/package.json +1 -0
- package/packages/roundtable/src/agents/claude-code/wake.js +4 -2
- package/packages/roundtable/src/agents/codex/wake.js +1 -0
- package/packages/roundtable/src/host.js +4 -1
- package/packages/roundtable/src/peer/control-cli.js +103 -2
- package/packages/roundtable/src/peer/control.js +29 -3
- package/packages/roundtable/src/peer/coordinator-http.js +23 -2
- package/packages/roundtable/src/peer/coordinator-service.js +92 -14
- package/packages/roundtable/src/peer/coordinator-store.js +2 -1
- package/packages/roundtable/src/peer/lan-addresses.js +43 -0
- package/packages/roundtable/src/peer/nearby-attempts.js +73 -0
- package/packages/roundtable/src/peer/nearby-discovery.js +132 -0
- package/packages/roundtable/src/peer/nearby-pairing.js +422 -0
- package/packages/roundtable/src/peer/nearby-presence.js +93 -0
- package/packages/roundtable/src/peer/node-store.js +10 -0
- package/packages/roundtable/src/peer/pairing-share.js +139 -0
- package/packages/roundtable/src/peer/peer-runtime.js +684 -89
- package/packages/roundtable/src/peer/peer-transport.js +58 -3
- package/packages/roundtable/src/peer/protocol.js +24 -1
- package/packages/roundtable/src/roundtable/chat-service.js +14 -3
- package/packages/roundtable/src/roundtable/chat.js +1 -0
- package/packages/roundtable/src/roundtable/delivery-state.js +2 -1
- package/packages/roundtable/src/roundtable/group-discussion-store.js +130 -5
- package/packages/roundtable/src/roundtable/group-discussion.js +596 -111
- package/packages/roundtable/src/roundtable/service.js +10 -2
- package/packages/roundtable/src/roundtable/store.js +11 -1
- package/packages/roundtable/src/roundtable/wake.js +3 -1
- package/packages/roundtable/src/standalone/cli.js +1 -1
- package/skills/capturing-session-knowledge/SKILL.md +1 -1
- package/skills/capturing-session-knowledge/references/coordination.md +28 -4
- package/skills/grilling-project/references/project-profile.md +13 -5
- package/skills/operating-fuli/SKILL.md +30 -5
- package/skills/operating-fuli/references/workflow-recipes.md +6 -2
- package/src/agent-apps/host-tools/catalog.js +2 -0
- package/src/agent-delegation/operation-log.js +15 -1
- package/src/agent-delegation/port.js +2 -3
- package/src/agent-delegation/refusals.js +12 -4
- package/src/agent-roundtable/task-context.js +1 -1
- package/src/agent-roundtable/tools.js +5 -2
- package/src/agent-tools/graph-definitions.js +2 -0
- package/src/agent-tools/graph-handlers.js +6 -3
- package/src/agent-tools/interface-catalog.js +11 -1
- package/src/agent-tools/interface-definitions.js +3 -2
- package/src/agent-tools/project-agent-definitions.js +2 -1
- package/src/agent-tools/project-organizing-definitions.js +7 -4
- package/src/agent-tools/project-space-definitions.js +2 -0
- package/src/agent-tools/session-fuli-gate.js +6 -1
- package/src/agent-tools/statement-definitions.js +18 -0
- package/src/agents/codex/lifecycle-hook.js +3 -1
- package/src/agents/identity-receipt.js +3 -1
- package/src/agents/native-session-env.js +7 -0
- package/src/conversations/entry-budget.js +3 -2
- package/src/conversations/entry-inline-budget.js +40 -10
- package/src/conversations/preference-lifecycle.js +3 -3
- package/src/conversations/turn-findings.js +9 -2
- package/src/graphiti/agent-project-resolution.js +18 -0
- package/src/graphiti/collaboration-preference-entry.js +5 -2
- package/src/graphiti/current-project-knowledge-search.js +3 -3
- package/src/graphiti/fla-mention.js +48 -9
- package/src/graphiti/local-runtimes.js +5 -0
- package/src/graphiti/project-agent-task-sessions.js +49 -0
- package/src/graphiti/project-agent-task-summaries.js +82 -0
- package/src/graphiti/project-agent-workflows.js +8 -5
- package/src/graphiti/project-path-context.js +23 -9
- package/src/graphiti/provider-client.js +23 -1
- package/src/graphiti/repository-remote.js +34 -8
- package/src/graphiti/roundtable-host.js +13 -1
- package/src/graphiti/task-context-entry.js +14 -7
- package/src/graphiti/task-entry-group-discussion.js +111 -25
- package/src/graphiti/task-entry-owner-change.js +22 -2
- package/src/graphiti/task-entry-preferences.js +9 -4
- package/src/graphiti/task-entry-project-scope.js +19 -0
- package/src/graphiti/task-preference-pages.js +3 -3
- package/src/graphiti/task-preference-reader.js +44 -9
- package/src/graphiti/worker-task-context.js +1 -1
- package/src/http/api-router.js +5 -0
- package/src/http/graph-api-router.js +5 -2
- package/src/http/statement-api-router.js +27 -0
- package/src/http/task-blocker-api-router.js +11 -1
- package/src/http/task-close-api-router.js +59 -0
- package/src/judgment/engine.js +6 -1
- package/src/judgment/http.js +2 -2
- package/src/judgment/review-delegation.js +16 -4
- package/src/judgment/review-egress.js +25 -0
- package/src/judgment/service.js +1 -1
- package/src/judgment/store.js +9 -0
- package/src/knowledge-impressions/store.js +72 -9
- package/src/mcp/create-mcp-server.js +2 -2
- package/src/mcp/direct-call.js +3 -2
- package/src/mcp/preference-delivery.js +64 -6
- package/src/mcp/session-id.js +12 -4
- package/src/mcp/tool-annotations.js +1 -0
- package/src/mcp/tool-result.js +8 -6
- package/src/model-backends/config.js +7 -0
- package/src/model-backends/egress.js +8 -0
- package/src/model-backends/failures.js +8 -0
- package/src/model-backends/port.js +39 -16
- package/src/model-backends/role-trust.js +3 -9
- package/src/model-backends/usage-ledger.js +20 -9
- package/src/notices/recent-notices.js +2 -1
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/project-organizing/agent-tool.js +34 -7
- package/src/server.js +7 -0
- package/src/statement/agent-tool.js +29 -0
- package/src/statement/compounding-statement.js +134 -0
- package/src/task-blockers/agent-resume.js +73 -0
- package/src/task-blockers/console-port.js +5 -2
- package/src/task-blockers/resume-status.js +2 -0
- package/src/task-closing/console-port.js +26 -0
- package/src/whats-new/lines/0.27.1.json +13 -0
- package/src/whats-new/lines/0.27.2.json +13 -0
- package/dist/web/assets/AgentAppsPage-CjyvPZSs.js +0 -1
- package/dist/web/assets/AgentManagement-Cc00RLSO.css +0 -1
- package/dist/web/assets/AgentManagement-MMGrwdD2.js +0 -7
- package/dist/web/assets/AgentProfilePage-eDKbJJwY.js +0 -5
- package/dist/web/assets/AgentServicesPage-CZwsN5U2.js +0 -1
- package/dist/web/assets/Breadcrumb-BXTA4e-W.js +0 -1
- package/dist/web/assets/DataFormatPage-CQKkFhcH.js +0 -2
- package/dist/web/assets/DebugTurnPage-CUqbuhgX.js +0 -1
- package/dist/web/assets/DebugTurnsPage-HwaTG8Fa.js +0 -1
- package/dist/web/assets/DialogTitle-HYzAHbGg.js +0 -1
- package/dist/web/assets/EmployeeScopeDialog-yUCgujKT.js +0 -1
- package/dist/web/assets/EmployeeWorkbench-CbRJhkJO.js +0 -4
- package/dist/web/assets/FieldRoot-BLcsuPMA.js +0 -1
- package/dist/web/assets/FlasPage-CMv2awKJ.js +0 -1
- package/dist/web/assets/HowtoPage-CkGRrKpf.js +0 -1
- package/dist/web/assets/InboxPage-DfQvtnyq.js +0 -6
- package/dist/web/assets/KnowledgeItemEditPage-BUKQK37o.js +0 -1
- package/dist/web/assets/KnowledgeOrganizerPage-CiZ9JlNX.js +0 -1
- package/dist/web/assets/KnowledgePage-C3_Cvz4g.js +0 -1
- package/dist/web/assets/KnowledgePeek-DtOOiARX.js +0 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-Dne5NQ9q.js +0 -1
- package/dist/web/assets/KnowledgeWorkspace-Cq_XYcma.js +0 -4
- package/dist/web/assets/MenuSeparator-CLmsZ9rj.js +0 -1
- package/dist/web/assets/ModelSettingsPage-COVaW4eh.js +0 -1
- package/dist/web/assets/NoticeRow-D5MWTeBY.js +0 -1
- package/dist/web/assets/NoticeRow-ktVO_9Es.css +0 -1
- package/dist/web/assets/OccupationsPage-BKd051j1.js +0 -1
- package/dist/web/assets/OverviewPage-C90G_adj.js +0 -1
- package/dist/web/assets/OverviewPage-KVt4LcE-.css +0 -1
- package/dist/web/assets/PageColumns-DEideeB7.css +0 -1
- package/dist/web/assets/PageColumns-Df60nEzj.js +0 -1
- package/dist/web/assets/PersonalProfilePage-DIDgG3NH.js +0 -1
- package/dist/web/assets/PersonalProjectsPage-DwhlEpNg.js +0 -1
- package/dist/web/assets/PopperContent-DWCMeKSL.js +0 -1
- package/dist/web/assets/Presence-Ba3jqPYx.js +0 -3
- package/dist/web/assets/ProjectAgentsPage-BefVF9ZP.js +0 -5
- package/dist/web/assets/RecentNotices-CDHGIky1.js +0 -1
- package/dist/web/assets/RovingFocusGroup-DoGybG5V.js +0 -1
- package/dist/web/assets/RovingFocusItem-B455TzUI.js +0 -1
- package/dist/web/assets/SessionMigrationPage-BAzXqxxO.js +0 -1
- package/dist/web/assets/SettingsPage-7mNL3bwe.js +0 -1
- package/dist/web/assets/SettingsPage-Cku8SoLk.css +0 -1
- package/dist/web/assets/SharedJefaReportPage-rH6I4cI9.js +0 -1
- package/dist/web/assets/TaskBlockerClear-BBmPbomO.css +0 -1
- package/dist/web/assets/TaskBlockerClear-BHOMZYwm.js +0 -1
- package/dist/web/assets/TaskBlockerNotice-POmS2neR.js +0 -1
- package/dist/web/assets/TeamCardsWidget-DIHFUDrF.js +0 -1
- package/dist/web/assets/TeamIsland-DdhEcVOZ.js +0 -9
- package/dist/web/assets/Teleport-CukHuRhz.js +0 -1
- package/dist/web/assets/TonborgDelegationSwitch-BA3Qb8Wr.js +0 -1
- package/dist/web/assets/TonborgDelegationSwitch-DeqERWoo.css +0 -1
- package/dist/web/assets/UiDialog-bUwGQz96.js +0 -1
- package/dist/web/assets/UiIconButton-D3R6WwwI.css +0 -1
- package/dist/web/assets/UiIconButton-DlLZ5_Yc.js +0 -1
- package/dist/web/assets/UiSegmented-CYrTxDn1.js +0 -1
- package/dist/web/assets/WidgetSlot-D6vCSWaz.js +0 -2
- package/dist/web/assets/WorkbenchListHead-CR_fDYYr.js +0 -1
- package/dist/web/assets/WorkbenchListPage-BX6Z9gkB.css +0 -1
- package/dist/web/assets/WorkbenchListPage-Zr5PW-cf.js +0 -1
- package/dist/web/assets/_plugin-vue_export-helper-BRS32yXs.js +0 -9
- package/dist/web/assets/agent-occupation-CEd3bAhb.js +0 -1
- package/dist/web/assets/agent-workflows-D3VeY6Yz.js +0 -1
- package/dist/web/assets/checkbox-C67upxzl.js +0 -1
- package/dist/web/assets/combobox-yHRJ-zN-.js +0 -1
- package/dist/web/assets/conversation-launcher-settings-28CqC1Gn.js +0 -1
- package/dist/web/assets/copy-mention-C4Nos381.js +0 -1
- package/dist/web/assets/dialog-Cjoy4nsv.js +0 -1
- package/dist/web/assets/dropdown-menu-Dto6hjoc.js +0 -1
- package/dist/web/assets/hover-card-Bg0dulGq.js +0 -1
- package/dist/web/assets/index-B-aRUs9w.js +0 -24
- package/dist/web/assets/label-CbrduZla.js +0 -1
- package/dist/web/assets/label-table-_YAtPkRI.js +0 -1
- package/dist/web/assets/model-DcsCYhXk.js +0 -1
- package/dist/web/assets/motion-_MepnmMC.js +0 -1
- package/dist/web/assets/overview-data-BIeNATEJ.js +0 -1
- package/dist/web/assets/popover-CMahoDLo.js +0 -1
- package/dist/web/assets/popup-host-DKN99Od3.js +0 -1
- package/dist/web/assets/radio-group-vRt8y8mF.js +0 -1
- package/dist/web/assets/review-api-WhNB3ppo.js +0 -1
- package/dist/web/assets/select-B9mVptgx.js +0 -1
- package/dist/web/assets/settings-tabs-DTbgqX8g.js +0 -1
- package/dist/web/assets/shared-report-0FO_y0sa.js +0 -3
- package/dist/web/assets/switch-BCzrGc4W.js +0 -1
- package/dist/web/assets/tabs-CB38D8N0.js +0 -1
- package/dist/web/assets/ui-D4nAhcmu.css +0 -1
- package/dist/web/assets/ui-M_UKzb_A.js +0 -1
- package/dist/web/assets/useForwardExpose-DJ6fcpI2.js +0 -1
- package/dist/web/assets/useForwardScopeId-CoSQtoUU.js +0 -1
- package/dist/web/assets/usePrimitiveElement-iRKqOVuY.js +0 -1
- package/dist/web/assets/useTeamPeople-CPC62La3.js +0 -1
- package/dist/web/assets/useTeamWork-Dql3_qLV.js +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHmac } from 'node:crypto';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
1
3
|
import { networkInterfaces } from 'node:os';
|
|
2
4
|
import { join as joinPath } from 'node:path';
|
|
3
5
|
|
|
@@ -5,18 +7,44 @@ import { startCoordinatorServer } from './coordinator-http.js';
|
|
|
5
7
|
import { cleanName, createCoordinatorService } from './coordinator-service.js';
|
|
6
8
|
import { createCoordinatorStore } from './coordinator-store.js';
|
|
7
9
|
import { loadDeviceIdentity } from './device-identity.js';
|
|
8
|
-
import {
|
|
10
|
+
import { announcedAddresses, discoveryAdapters, lanAddresses, virtualAddresses } from './lan-addresses.js';
|
|
11
|
+
import { createAttemptLedger } from './nearby-attempts.js';
|
|
12
|
+
import { createBonjourDiscovery } from './nearby-discovery.js';
|
|
13
|
+
import { createNearbyPairing } from './nearby-pairing.js';
|
|
14
|
+
import { createNearbyPresence } from './nearby-presence.js';
|
|
15
|
+
import { createPairingShare } from './pairing-share.js';
|
|
16
|
+
import { answersAs, connectNearby, createPeerClient, pairWithCoordinator } from './peer-transport.js';
|
|
9
17
|
import { coordinatorUrl, decodeInvitation, PeerError, shortFingerprint } from './protocol.js';
|
|
10
18
|
import { createPeerRunner } from './runner.js';
|
|
11
19
|
|
|
12
20
|
const PUBLISH_MS = 60_000;
|
|
21
|
+
const DIRECTORY_READ_MS = 3_000;
|
|
13
22
|
const WAKE_CLIENTS = new Set(['codex', 'claude_code']);
|
|
23
|
+
// While nearby pairing is on, its listener answers on every IPv4 interface:
|
|
24
|
+
// the address another computer reaches comes from discovery, not from the
|
|
25
|
+
// person. Afterwards it narrows to the address its paired devices use.
|
|
26
|
+
const NEARBY_LISTEN_HOST = '0.0.0.0';
|
|
27
|
+
// Nearby pairing turns itself off this long after the person turned it on,
|
|
28
|
+
// and shortly after a pairing finished (the other computer may still ask once).
|
|
29
|
+
const NEARBY_SESSION_MS = 30 * 60_000;
|
|
30
|
+
const PAIRED_GRACE_MS = 5_000;
|
|
31
|
+
// A device this computer trusted through nearby pairing that never connects
|
|
32
|
+
// within this time did not finish its side: the trust is taken back.
|
|
33
|
+
const TRUST_USE_MS = 60_000;
|
|
34
|
+
const LOOPBACK = /^(127\.|::1$)/;
|
|
35
|
+
// The search for projects to add answers with this many by default, at most SEARCH_MAX.
|
|
36
|
+
const SEARCH_LIMIT = 20;
|
|
37
|
+
const SEARCH_MAX = 50;
|
|
14
38
|
const teamPeople = team => team?.people ?? [];
|
|
39
|
+
// A project another computer can ask: never an archived, temporary or session-only one.
|
|
40
|
+
const pickable = project => !project.temporary && !project.sessionOnly && !project.archived;
|
|
15
41
|
|
|
16
42
|
// The local owner's LAN roundtable controls, run only by the console process.
|
|
17
43
|
// Nothing here starts unless the owner turned it on; console LAN access does not.
|
|
18
44
|
export function createPeerRuntime({ host, roundtable, port, interfaces = networkInterfaces, allowLoopback = false,
|
|
19
|
-
claimWaitMs,
|
|
45
|
+
claimWaitMs, createDiscovery = createBonjourDiscovery, startServer = startCoordinatorServer, nearbyListenHost = NEARBY_LISTEN_HOST, clock = Date.now,
|
|
46
|
+
nearbySessionMs = NEARBY_SESSION_MS, pairedGraceMs = PAIRED_GRACE_MS, trustUseMs = TRUST_USE_MS, autoShareRetryMs, autoShareAttempts,
|
|
47
|
+
publishMs = PUBLISH_MS, onError = () => {} }) {
|
|
20
48
|
const store = () => port.nodeStore();
|
|
21
49
|
let coordinator = null;
|
|
22
50
|
let runner = null;
|
|
@@ -25,53 +53,102 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
25
53
|
let leaveRetry = null;
|
|
26
54
|
let leaveWork = null;
|
|
27
55
|
let leaveAbort = null;
|
|
56
|
+
let lastPublish = null;
|
|
57
|
+
let repositoryKey = null;
|
|
58
|
+
let nearbyNotice = null;
|
|
59
|
+
let nearbyTimer = null;
|
|
60
|
+
let listenFailure = null;
|
|
61
|
+
const trustChecks = new Set();
|
|
28
62
|
const spaceId = () => host.spaceId();
|
|
63
|
+
const identity = () => loadDeviceIdentity(port.directory);
|
|
64
|
+
const discovery = createDiscovery({ adapters: () => discoveryAdapters(interfaces),
|
|
65
|
+
onFailure: (error) => endNearby({ kind: 'discovery_failed', reason: failureCode(error) }).catch(onError) });
|
|
66
|
+
const presence = createNearbyPresence({ discovery, clock });
|
|
67
|
+
const attempts = createAttemptLedger({ clock, read: () => (port.configured() ? store().setting('nearbyAttempts') : null),
|
|
68
|
+
update: (change) => store().updateSetting('nearbyAttempts', change) });
|
|
69
|
+
const pairing = createNearbyPairing({ attempts, local: {
|
|
70
|
+
identity, authority: () => port.localAuthority(),
|
|
71
|
+
answersOn: (address) => !virtualAddresses(interfaces).includes(address),
|
|
72
|
+
leaveCoordinator: async (peer) => {
|
|
73
|
+
if (store().setting('membership')?.coordinator?.fingerprint === peer.fingerprint) await disable();
|
|
74
|
+
},
|
|
75
|
+
name: () => store().setting('nearby')?.name ?? 'FULI',
|
|
76
|
+
role: nearbyRole,
|
|
77
|
+
trusted: (fingerprint) => trustedFingerprints().includes(fingerprint),
|
|
78
|
+
trustDevice: (peer) => {
|
|
79
|
+
if (!coordinator) throw new PeerError('not_coordinator', 'This computer stopped coordinating', 409);
|
|
80
|
+
coordinator.service.trustNearbyDevice(peer);
|
|
81
|
+
watchTrustUse(peer);
|
|
82
|
+
},
|
|
83
|
+
untrustDevice: async (fingerprint) => { withdrawTrust(fingerprint); },
|
|
84
|
+
joinCoordinator: async (peer) => adoptCoordinator({ url: coordinatorUrl(peer.address, peer.port), certPem: peer.certPem,
|
|
85
|
+
fingerprint: peer.fingerprint, name: peer.name, authority: peer.authority }),
|
|
86
|
+
reachable: async (peer) => answersAs({ identity: await identity(), address: peer.address, port: peer.port, fingerprint: peer.fingerprint }),
|
|
87
|
+
}, connect: async (target) => connectNearby({ identity: await identity(), target }), clock,
|
|
88
|
+
onPaired: (peer) => afterPairing(peer), onError });
|
|
29
89
|
|
|
30
|
-
|
|
31
|
-
return Object.values(interfaces()).flat().filter((entry) => entry && !entry.internal
|
|
32
|
-
&& (entry.family === 'IPv4' || entry.family === 4)).map((entry) => entry.address);
|
|
33
|
-
}
|
|
90
|
+
const localAddresses = () => lanAddresses(interfaces);
|
|
34
91
|
|
|
35
92
|
async function resume() {
|
|
36
93
|
if (!port.configured()) return;
|
|
37
94
|
await finishLeaving();
|
|
38
95
|
const settings = store().setting('coordinator');
|
|
39
|
-
|
|
40
|
-
if (
|
|
96
|
+
// An address that is gone (a new network, DHCP) is said, not replaced: nothing listens until the person acts.
|
|
97
|
+
if (settings) await startCoordinator(settings).catch((error) => { onError(error); });
|
|
98
|
+
if (store().setting('membership') && (coordinator || !settings)) await startRunner();
|
|
99
|
+
checkPendingTrust();
|
|
100
|
+
pairingShare.resume();
|
|
101
|
+
const nearby = store().setting('nearby');
|
|
102
|
+
if (!nearby) return;
|
|
103
|
+
if (!(nearby.until > clock())) await endNearby({ kind: 'timeout' });
|
|
104
|
+
else if (settings && !coordinator) await endNearby(null);
|
|
105
|
+
else await startNearby();
|
|
41
106
|
}
|
|
42
107
|
|
|
43
108
|
async function startCoordinator({ host: address, port: listenPort, name }) {
|
|
44
|
-
const
|
|
109
|
+
const device = await identity();
|
|
45
110
|
const authority = await port.localAuthority();
|
|
46
111
|
const coordinatorStore = createCoordinatorStore(joinPath(port.directory, 'coordinator.sqlite'));
|
|
47
112
|
let server = null;
|
|
48
|
-
const service = createCoordinatorService({ store: coordinatorStore, identity, authority, name,
|
|
49
|
-
onTrustChange: () => server?.refreshTrust()
|
|
113
|
+
const service = createCoordinatorService({ store: coordinatorStore, identity: device, authority, name,
|
|
114
|
+
onTrustChange: () => server?.refreshTrust(),
|
|
115
|
+
// A device that left (or was revoked) ends its pairing's share, as a revoke here does.
|
|
116
|
+
onRevoked: (nodeId) => pairingShare.forget(nodeId),
|
|
117
|
+
repositoryChanges: { read: () => store().setting('repositoryChanges'), write: (value) => store().setSetting('repositoryChanges', value) } });
|
|
50
118
|
try {
|
|
51
|
-
server = await
|
|
119
|
+
server = await startServer({ service, identity: device, host: address, port: listenPort, claimWaitMs,
|
|
120
|
+
nearby: { listening: (address) => nearbyRole().listening && !virtualAddresses(interfaces).includes(address),
|
|
121
|
+
handle: (...args) => pairing.handle(...args) },
|
|
122
|
+
onReached: rememberReached });
|
|
52
123
|
} catch (error) {
|
|
53
124
|
coordinatorStore.close();
|
|
54
|
-
|
|
125
|
+
listenFailure = { address, port: listenPort, code: failureCode(error), at: new Date(clock()).toISOString() };
|
|
126
|
+
throw new PeerError('listen_failed', `Could not listen on ${address}:${listenPort}: ${failureCode(error)}`, 409);
|
|
55
127
|
}
|
|
128
|
+
listenFailure = null;
|
|
56
129
|
coordinator = { service, server, store: coordinatorStore, host: address, name };
|
|
57
|
-
|
|
130
|
+
// A wildcard listener answers this computer on loopback.
|
|
131
|
+
const url = coordinatorUrl(address === NEARBY_LISTEN_HOST ? '127.0.0.1' : address, server.address.port);
|
|
58
132
|
store().setSetting('coordinator', { host: address, port: server.address.port, name });
|
|
59
|
-
store().setSetting('membership', { role: 'coordinator', coordinator: { url, certPem:
|
|
60
|
-
fingerprint:
|
|
61
|
-
store().forgetAuthority(
|
|
62
|
-
store().bindAuthority(
|
|
133
|
+
store().setSetting('membership', { role: 'coordinator', coordinator: { url, certPem: device.certPem,
|
|
134
|
+
fingerprint: device.fingerprint, name } });
|
|
135
|
+
store().forgetAuthority(device.fingerprint);
|
|
136
|
+
store().bindAuthority(device.fingerprint, authority, 'self');
|
|
63
137
|
}
|
|
64
138
|
|
|
65
139
|
async function startRunner() {
|
|
66
140
|
if (runner) return;
|
|
67
141
|
const membership = store().setting('membership');
|
|
68
|
-
const
|
|
69
|
-
runnerClient = createPeerClient({ identity, coordinator: membership.coordinator });
|
|
142
|
+
const device = await identity();
|
|
143
|
+
runnerClient = createPeerClient({ identity: device, coordinator: membership.coordinator });
|
|
70
144
|
runner = createPeerRunner({ store: store(), client: runnerClient, roundtable, host,
|
|
71
|
-
nodeId:
|
|
145
|
+
nodeId: device.fingerprint, spaceId, onError });
|
|
72
146
|
runner.start().catch(onError);
|
|
73
147
|
await publish().catch(onError);
|
|
74
|
-
publisher = setInterval(() =>
|
|
148
|
+
publisher = setInterval(() => {
|
|
149
|
+
publish().catch(onError);
|
|
150
|
+
narrowListener().catch(onError);
|
|
151
|
+
}, publishMs);
|
|
75
152
|
publisher.unref();
|
|
76
153
|
}
|
|
77
154
|
|
|
@@ -82,81 +159,260 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
82
159
|
await leaveWork?.catch(onError);
|
|
83
160
|
clearInterval(publisher);
|
|
84
161
|
publisher = null;
|
|
85
|
-
|
|
162
|
+
// Taken before awaiting, so two stops at once (a discovery failure during
|
|
163
|
+
// another change) never close the same listener twice.
|
|
164
|
+
const [stoppingRunner, stoppingClient, stoppingCoordinator] = [runner, runnerClient, coordinator];
|
|
86
165
|
runner = null;
|
|
87
|
-
runnerClient?.close();
|
|
88
166
|
runnerClient = null;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
167
|
+
coordinator = null;
|
|
168
|
+
repositoryKey = null;
|
|
169
|
+
await stoppingRunner?.stop();
|
|
170
|
+
stoppingClient?.close();
|
|
171
|
+
if (stoppingCoordinator) {
|
|
172
|
+
await stoppingCoordinator.server.close();
|
|
173
|
+
stoppingCoordinator.store.close();
|
|
93
174
|
}
|
|
94
175
|
}
|
|
95
176
|
|
|
96
177
|
// Each share names the lead it was made for; after a handoff the old share
|
|
97
|
-
// is withheld until the owner shares the project's new lead.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
178
|
+
// is withheld until the owner shares the project's new lead. A team that
|
|
179
|
+
// cannot be read right now is no handoff: its share stays as last published.
|
|
180
|
+
async function shareStates({ projects = null, team: readTeam = teamReader() } = {}) {
|
|
181
|
+
const listed = projects ?? await host.listProjects().catch(() => []);
|
|
182
|
+
const names = new Map(listed.map((project) => [project.projectId, project.name]));
|
|
101
183
|
return Promise.all(store().shares().filter((share) => share.spaceId === spaceId()).map(async (share) => {
|
|
102
|
-
const
|
|
184
|
+
const projectName = names.get(share.projectId) ?? share.projectId;
|
|
185
|
+
let team;
|
|
186
|
+
try { team = await readTeam(share.projectId); }
|
|
187
|
+
catch (error) { return { ...share, projectName, lead: null, state: 'team_unreadable', reason: error.code ?? 'team_unreadable' }; }
|
|
103
188
|
const person = share.communicationOnly ? teamPeople(team).find(a => a.agentId === share.agentId) : team?.lead;
|
|
104
189
|
const current = person?.agentId === share.agentId;
|
|
105
|
-
return { ...share, projectName
|
|
190
|
+
return { ...share, projectName, lead: person ?? null,
|
|
106
191
|
state: current ? 'shared' : team?.lead ? 'lead_changed' : 'lead_unavailable' };
|
|
107
192
|
}));
|
|
108
193
|
}
|
|
109
194
|
|
|
195
|
+
const published = new Map();
|
|
196
|
+
|
|
197
|
+
// What this device offers, sent to the coordinator now and every minute.
|
|
198
|
+
// The outcome is kept for status, so a list the coordinator never got is
|
|
199
|
+
// visible on the card and in `fuli peer status` instead of only in a log.
|
|
110
200
|
async function publish() {
|
|
111
201
|
if (!runnerClient) return;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
202
|
+
try {
|
|
203
|
+
const profiles = await host.listAgents();
|
|
204
|
+
const agents = (await shareStates()).flatMap((share) => {
|
|
205
|
+
if (share.state === 'team_unreadable') return published.has(share.bindingId) ? [published.get(share.bindingId)] : [];
|
|
206
|
+
if (share.state !== 'shared') return [];
|
|
207
|
+
const profile = profiles.find(a => a.agentId === share.agentId);
|
|
208
|
+
return [{ bindingId: share.bindingId, agentId: share.agentId, name: share.lead.name, employeeNumber: share.lead.employeeNumber,
|
|
209
|
+
responsibility: share.lead.responsibility, projectName: share.projectName, projectId: share.projectId,
|
|
210
|
+
occupation: profile?.occupation?.role ?? null, capabilities: profile?.profile.capabilities ?? [],
|
|
211
|
+
...(share.communicationOnly ? { communicationOnly: true } : {}), clients: share.clients }];
|
|
212
|
+
});
|
|
213
|
+
await runner?.reconcileShares(new Set(agents.map((agent) => agent.bindingId)));
|
|
214
|
+
const sent = repositoryKey;
|
|
215
|
+
const answer = await runnerClient.post('/peer/1/directory/publish', { agents,
|
|
216
|
+
...(sent ? { repositories: { keyId: sent.id, digests: await repositoryDigests(sent) } } : {}) });
|
|
217
|
+
published.clear();
|
|
218
|
+
for (const agent of agents) published.set(agent.bindingId, agent);
|
|
219
|
+
lastPublish = { at: new Date().toISOString(), agents: agents.length, error: null };
|
|
220
|
+
// The group's repository key comes with the answer; a new one means sending the digests again.
|
|
221
|
+
if (validKey(answer.repositoryKey) && answer.repositoryKey.id !== sent?.id) {
|
|
222
|
+
repositoryKey = answer.repositoryKey;
|
|
223
|
+
await runnerClient.post('/peer/1/directory/publish', { agents,
|
|
224
|
+
repositories: { keyId: repositoryKey.id, digests: await repositoryDigests(repositoryKey) } });
|
|
225
|
+
}
|
|
226
|
+
} catch (error) {
|
|
227
|
+
// Only a known word reaches the card and CLI: the coordinator's own text never does.
|
|
228
|
+
lastPublish = { at: new Date().toISOString(), agents: null, error: failureCode(error) };
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// This device's own repository addresses, keyed with the paired group's
|
|
234
|
+
// secret (from the coordinator, only after pairing): the coordinator matches
|
|
235
|
+
// them between devices, and no device sees another device's digests. Only
|
|
236
|
+
// projects another computer can ask count: never archived, temporary or session-only ones.
|
|
237
|
+
async function repositoryDigests(key) {
|
|
238
|
+
const projects = await host.listProjects().catch(() => []);
|
|
239
|
+
return [...new Set(projects.filter(pickable).flatMap((project) => projectDigests(project, key)))];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// The coordinator's directory as this device sees it: the other devices and
|
|
243
|
+
// whether it holds this device's own digests under its current key.
|
|
244
|
+
async function readDirectory() {
|
|
245
|
+
if (!runnerClient) return { devices: [] };
|
|
246
|
+
try {
|
|
247
|
+
const { devices, ownRepositoriesKnown } = await runnerClient.post('/peer/1/directory', {}, { timeoutMs: DIRECTORY_READ_MS });
|
|
248
|
+
return { ownRepositoriesKnown,
|
|
249
|
+
devices: (Array.isArray(devices) ? devices : []).map((entry) => ({ ...entry, name: cleanName(entry?.name) || 'FULI' })) };
|
|
250
|
+
}
|
|
251
|
+
catch { return { devices: [] }; }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const pairedDirectory = async () => (await readDirectory()).devices;
|
|
255
|
+
|
|
256
|
+
// One read per project team within one answer, however many parts of it ask.
|
|
257
|
+
function teamReader() {
|
|
258
|
+
const teams = new Map();
|
|
259
|
+
return (projectId) => {
|
|
260
|
+
if (!teams.has(projectId)) teams.set(projectId, host.projectTeam(projectId));
|
|
261
|
+
return teams.get(projectId);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const sharedProjectIds = () => new Set(store().shares().filter((share) => share.spaceId === spaceId()).map((share) => share.projectId));
|
|
266
|
+
|
|
267
|
+
// The paired devices that registered this project with the same own repository.
|
|
268
|
+
function sameProjectOn(project, paired) {
|
|
269
|
+
const digests = new Set(repositoryKey ? projectDigests(project, repositoryKey) : []);
|
|
270
|
+
return paired.filter((device) => (device.sameRepositories ?? []).some((digest) => digests.has(digest)))
|
|
271
|
+
.map(({ nodeId, name }) => ({ nodeId, name }));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// The short list the card and `fuli peer` show: projects shared now (an
|
|
275
|
+
// already-shared one stays listed so it can be taken back, whatever it has
|
|
276
|
+
// become since) and the suggestions, projects a paired device registered
|
|
277
|
+
// with the same own repository. Every other project is found by searchShareable.
|
|
278
|
+
async function shareable({ projects, paired, team = teamReader() }) {
|
|
279
|
+
const shared = sharedProjectIds();
|
|
126
280
|
const agents = await host.listAgents().catch(() => []);
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
281
|
+
const listed = projects.flatMap((project) => {
|
|
282
|
+
const same = sameProjectOn(project, paired);
|
|
283
|
+
return shared.has(project.projectId) || (pickable(project) && same.length) ? [{ project, same }] : [];
|
|
284
|
+
});
|
|
285
|
+
return Promise.all(listed.map(({ project, same }) => shareEntry(project, same, { agents, team })));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// One project as the card shows it: its current lead, the clients that lead
|
|
289
|
+
// may use and the paired devices with the same own repository. A folder is
|
|
290
|
+
// offered only when this computer knows one whose Git remote is that repository.
|
|
291
|
+
async function shareEntry(project, same, { agents, team }) {
|
|
292
|
+
const projectId = project.projectId;
|
|
293
|
+
const projectTeam = await team(projectId).catch(() => null);
|
|
294
|
+
const lead = projectTeam?.lead ?? null;
|
|
295
|
+
return { projectId, projectName: project.name ?? projectId,
|
|
296
|
+
lead: lead ? { agentId: lead.agentId, name: lead.name } : null, clients: wakeClients(agents, lead?.agentId),
|
|
297
|
+
communicationAgents: teamPeople(projectTeam).map(person => ({ agentId: person.agentId, name: person.name,
|
|
298
|
+
occupation: agents.find(a => a.agentId === person.agentId)?.occupation?.role ?? null })),
|
|
299
|
+
sameProjectOn: same, knownFolder: same.length && lead ? await repositoryFolder(project, lead.agentId) : null };
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const wakeClients = (agents, agentId) => (agents.find((agent) => agent.agentId === agentId)?.profile.allowedClients ?? [])
|
|
303
|
+
.filter((client) => WAKE_CLIENTS.has(client));
|
|
304
|
+
|
|
305
|
+
// The other projects the person may add, found by name (no team reads): never
|
|
306
|
+
// archived, temporary or session-only ones (another computer has nothing to
|
|
307
|
+
// ask them), and none the short list already shows. An empty query lists the
|
|
308
|
+
// host's order, most recently changed first.
|
|
309
|
+
async function searchShareable({ query = '', limit = SEARCH_LIMIT } = {}) {
|
|
310
|
+
if (!store().setting('membership')) throw new PeerError('peer_not_paired', 'Pair this computer before sharing a project', 409);
|
|
311
|
+
const size = Number.isSafeInteger(limit) ? Math.min(Math.max(limit, 1), SEARCH_MAX) : SEARCH_LIMIT;
|
|
312
|
+
const needle = String(query ?? '').trim().toLowerCase();
|
|
313
|
+
const projects = await host.listProjects().catch(() => []);
|
|
314
|
+
const shared = sharedProjectIds();
|
|
315
|
+
const paired = repositoryKey ? await pairedDirectory() : [];
|
|
316
|
+
const found = projects.filter((project) => pickable(project) && !shared.has(project.projectId)
|
|
317
|
+
&& !sameProjectOn(project, paired).length && (project.name ?? project.projectId).toLowerCase().includes(needle));
|
|
318
|
+
return { projects: found.slice(0, size).map((project) => ({ projectId: project.projectId, projectName: project.name ?? project.projectId })),
|
|
319
|
+
more: found.length > size };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// The full entry of one project the person just picked from the search.
|
|
323
|
+
async function shareableProject(projectId) {
|
|
324
|
+
if (!store().setting('membership')) throw new PeerError('peer_not_paired', 'Pair this computer before sharing a project', 409);
|
|
325
|
+
const project = (await host.listProjects().catch(() => [])).find((entry) => entry.projectId === projectId);
|
|
326
|
+
if (!project || !(pickable(project) || sharedProjectIds().has(projectId))) {
|
|
327
|
+
throw new PeerError('project_not_found', 'No project of this computer can be shared under that id', 404);
|
|
328
|
+
}
|
|
329
|
+
const paired = repositoryKey ? await pairedDirectory() : [];
|
|
330
|
+
return shareEntry(project, sameProjectOn(project, paired), { agents: await host.listAgents().catch(() => []), team: teamReader() });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ---- Sharing the projects both computers have, once per pairing (pairing-share.js) ----
|
|
334
|
+
|
|
335
|
+
// What the coordinator answers about one paired device: whether both
|
|
336
|
+
// computers' digests under its current key are there (settled), how many
|
|
337
|
+
// other devices the group has, and the projects here the device reports too.
|
|
338
|
+
// Publishing first sends this computer's digests under the current key.
|
|
339
|
+
async function pairingMatch(fingerprint) {
|
|
340
|
+
await publish().catch(onError);
|
|
341
|
+
const answer = await readDirectory();
|
|
342
|
+
const other = answer.devices.find((entry) => entry.nodeId === fingerprint);
|
|
343
|
+
const projects = await host.listProjects().catch(() => []);
|
|
344
|
+
const common = other ? projects.filter((project) => pickable(project) && sameProjectOn(project, [other]).length) : [];
|
|
345
|
+
// A coordinator from before these flags settles only on a match.
|
|
346
|
+
const known = answer.ownRepositoriesKnown === undefined ? common.length > 0
|
|
347
|
+
: answer.ownRepositoriesKnown === true && other?.repositoriesKnown === true;
|
|
348
|
+
return { settled: Boolean(other) && known, others: answer.devices.filter((entry) => entry.nodeId !== fingerprint).length, common };
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Each project's share as a manual save makes it: the current lead, its first
|
|
352
|
+
// allowed wake client, and the folder only when the host maps it to this project.
|
|
353
|
+
async function pairingShares(projects) {
|
|
354
|
+
const agents = await host.listAgents().catch(() => []);
|
|
355
|
+
const shares = [];
|
|
356
|
+
for (const project of projects) {
|
|
357
|
+
const lead = (await host.projectTeam(project.projectId).catch(() => null))?.lead;
|
|
358
|
+
const [client] = wakeClients(agents, lead?.agentId);
|
|
359
|
+
if (!client) continue;
|
|
360
|
+
const folder = await repositoryFolder(project, lead.agentId);
|
|
361
|
+
shares.push({ projectName: project.name ?? project.projectId, share: { spaceId: spaceId(), projectId: project.projectId,
|
|
362
|
+
agentId: lead.agentId, clients: [client],
|
|
363
|
+
workingDirectory: folder ? await confirmedFolder(folder, project.projectId).catch(() => null) : null } });
|
|
364
|
+
}
|
|
365
|
+
return shares;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// The projects whose share the person changed (added or removed) in a save, and when.
|
|
369
|
+
const touchedSince = (projectId, since) => (store().setting('shareTouches')?.[projectId] ?? 0) >= since;
|
|
370
|
+
|
|
371
|
+
const pairingShare = createPairingShare({ clock, attemptMs: autoShareRetryMs, attempts: autoShareAttempts, onError, port: {
|
|
372
|
+
setting: (key) => store().setting(key), setSetting: (key, value) => store().setSetting(key, value),
|
|
373
|
+
paired: () => Boolean(port.configured() && store().setting('membership')),
|
|
374
|
+
match: pairingMatch, prepare: pairingShares, sharedProjectIds, touchedSince,
|
|
375
|
+
writeShares: (shares) => store().replaceShares([...store().shares(), ...shares], port.idFactory),
|
|
376
|
+
afterWrite: async () => { await runner?.reconcileShares(); await publish().catch(onError); },
|
|
377
|
+
} });
|
|
378
|
+
|
|
379
|
+
async function repositoryFolder(project, agentId) {
|
|
380
|
+
const folder = await roundtable.knownProjectFolder({ agentId, projectId: project.projectId }).catch(() => null);
|
|
381
|
+
if (!folder || !host.folderRepository) return null;
|
|
382
|
+
const remote = await Promise.resolve().then(() => host.folderRepository(folder)).catch(() => null);
|
|
383
|
+
return remote && (project.repositories ?? []).includes(remote) ? folder : null;
|
|
137
384
|
}
|
|
138
385
|
|
|
139
386
|
async function status() {
|
|
140
387
|
if (!port.configured()) {
|
|
141
388
|
return { beta: true, role: null, device: null, coordinator: null, addresses: localAddresses(), devices: [],
|
|
142
|
-
openInvitations: 0, shares: [], shareable: [] };
|
|
389
|
+
openInvitations: 0, shares: [], shareable: [], groupSize: 0, autoShared: [], autoSharePending: false, lastPublish: null, nearby: await nearbyView() };
|
|
143
390
|
}
|
|
144
391
|
const membership = store().setting('membership');
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
392
|
+
const device = membership ? await identity() : null;
|
|
393
|
+
const devices = membership?.role === 'coordinator' ? storedDevices() : [];
|
|
394
|
+
const projects = membership ? await host.listProjects().catch(() => []) : [];
|
|
395
|
+
const paired = membership ? await pairedDirectory() : [];
|
|
396
|
+
const team = teamReader();
|
|
148
397
|
return {
|
|
149
398
|
beta: true,
|
|
150
399
|
remoteRemovalPending: Boolean(store().setting('pendingLeave')),
|
|
151
400
|
role: membership?.role ?? null,
|
|
152
|
-
device:
|
|
401
|
+
device: device ? { fingerprint: device.fingerprint, shortFingerprint: shortFingerprint(device.fingerprint) } : null,
|
|
153
402
|
coordinator: membership ? { name: membership.coordinator.name, url: membership.coordinator.url,
|
|
154
|
-
shortFingerprint: shortFingerprint(membership.coordinator.fingerprint), listening: Boolean(coordinator)
|
|
403
|
+
shortFingerprint: shortFingerprint(membership.coordinator.fingerprint), listening: Boolean(coordinator),
|
|
404
|
+
listenFailure: membership.role === 'coordinator' && !coordinator ? listenFailure : null } : null,
|
|
155
405
|
addresses: localAddresses(),
|
|
156
|
-
devices: devices.map((
|
|
406
|
+
devices: devices.map((entry) => ({ ...entry, shortFingerprint: shortFingerprint(entry.nodeId) })),
|
|
157
407
|
openInvitations: coordinator ? coordinator.service.openInvitations() : 0,
|
|
158
|
-
shares: membership ? (await shareStates()).map(({ lead: _lead, ...share }) => share) : [],
|
|
159
|
-
shareable: membership ? await shareable() : [],
|
|
408
|
+
shares: membership ? (await shareStates({ projects, team })).map(({ lead: _lead, ...share }) => share) : [],
|
|
409
|
+
shareable: membership ? await shareable({ projects, paired, team }) : [],
|
|
410
|
+
// This computer and the paired devices it sees: a share reaches every one of them.
|
|
411
|
+
groupSize: membership ? paired.length + 1 : 0,
|
|
412
|
+
autoShared: membership ? pairingShare.view() : [],
|
|
413
|
+
autoSharePending: membership ? pairingShare.waiting() : false,
|
|
414
|
+
lastPublish: membership ? lastPublish : null,
|
|
415
|
+
nearby: await nearbyView(),
|
|
160
416
|
};
|
|
161
417
|
}
|
|
162
418
|
|
|
@@ -169,13 +425,20 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
169
425
|
if (!Number.isSafeInteger(listenPort) || listenPort < 0 || listenPort > 65535) throw new PeerError('invalid_address', 'Invalid port', 422);
|
|
170
426
|
await startCoordinator({ host: address, port: listenPort, name: cleanName(name) || 'FULI coordinator' });
|
|
171
427
|
await startRunner();
|
|
428
|
+
await startNearby();
|
|
172
429
|
return status();
|
|
173
430
|
}
|
|
174
431
|
|
|
432
|
+
// A wildcard listener invites on the address paired devices already reach,
|
|
433
|
+
// else the first physical LAN address, never a VPN or virtual adapter first.
|
|
175
434
|
function createInvitation() {
|
|
176
435
|
if (!coordinator) throw new PeerError('not_coordinator', 'Only the coordinator device creates invitations', 409);
|
|
177
436
|
const settings = store().setting('coordinator');
|
|
178
|
-
|
|
437
|
+
const known = store().setting('reachedAddresses') ?? {};
|
|
438
|
+
const reached = trustedFingerprints().map((nodeId) => known[nodeId]).find((address) => address && !LOOPBACK.test(address));
|
|
439
|
+
const address = settings.host === NEARBY_LISTEN_HOST ? reached ?? localAddresses()[0] : settings.host;
|
|
440
|
+
if (!address) throw new PeerError('invalid_address', 'This computer has no LAN address to invite from', 409);
|
|
441
|
+
return coordinator.service.createInvitation({ url: coordinatorUrl(address, settings.port) });
|
|
179
442
|
}
|
|
180
443
|
|
|
181
444
|
function previewInvitation(text) {
|
|
@@ -185,25 +448,49 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
185
448
|
}
|
|
186
449
|
|
|
187
450
|
async function join({ invitation: text, name }) {
|
|
188
|
-
|
|
451
|
+
const membership = store().setting('membership');
|
|
452
|
+
// A listener nearby pairing opened, with nobody paired through it, gives way to the invitation.
|
|
453
|
+
if (membership && !(membership.role === 'coordinator' && store().setting('nearby')?.openedListener && !coordinatesOthers())) {
|
|
454
|
+
throw new PeerError('already_paired', 'This device is already paired', 409);
|
|
455
|
+
}
|
|
189
456
|
await finishLeaving();
|
|
190
457
|
if (store().setting('pendingLeave')) throw new PeerError('leave_pending', 'The previous coordinator is offline. Retry after it is available, or revoke this device there.', 409);
|
|
191
458
|
const invitation = decodeInvitation(text);
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
const result = await pairWithCoordinator({ identity, authority, invitation, name: cleanName(name) || 'FULI device' });
|
|
459
|
+
const result = await pairWithCoordinator({ identity: await identity(), authority: await port.localAuthority(), invitation,
|
|
460
|
+
name: cleanName(name) || store().setting('nearby')?.name || 'FULI device' });
|
|
195
461
|
if (result.coordinatorNodeId !== invitation.fingerprint) throw new PeerError('invalid_pairing', 'The coordinator answered with another identity', 502);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
await
|
|
462
|
+
await adoptCoordinator({ url: invitation.url, certPem: invitation.certificatePem, fingerprint: invitation.fingerprint,
|
|
463
|
+
name: invitation.name, authority: invitation.authority });
|
|
464
|
+
// Joining is the consent, as the 6 digits are nearby: the console says so
|
|
465
|
+
// under the previewed invitation, `fuli peer join` prints it before it joins.
|
|
466
|
+
await pairingShare.start(invitation.fingerprint)?.catch(onError);
|
|
201
467
|
return status();
|
|
202
468
|
}
|
|
203
469
|
|
|
470
|
+
// Joins a coordinator: an invitation's, or the computer nearby pairing chose.
|
|
471
|
+
// A listener without other paired devices closes first, so this computer
|
|
472
|
+
// stops advertising itself as a place to pair.
|
|
473
|
+
async function adoptCoordinator({ url, certPem, fingerprint, name, authority }) {
|
|
474
|
+
const membership = store().setting('membership');
|
|
475
|
+
if (membership?.role === 'member') throw new PeerError('already_paired', 'This device is already paired', 409);
|
|
476
|
+
if (membership?.role === 'coordinator') {
|
|
477
|
+
if (coordinatesOthers()) throw new PeerError('already_coordinating', 'This computer coordinates other devices', 409);
|
|
478
|
+
await stopAll();
|
|
479
|
+
store().setSetting('coordinator', null);
|
|
480
|
+
const nearby = store().setting('nearby');
|
|
481
|
+
if (nearby) store().setSetting('nearby', { ...nearby, openedListener: false });
|
|
482
|
+
}
|
|
483
|
+
store().forgetAuthority(fingerprint);
|
|
484
|
+
store().bindAuthority(fingerprint, authority, 'pairing');
|
|
485
|
+
store().setSetting('membership', { role: 'member', coordinator: { url, certPem, fingerprint, name: name || 'FULI coordinator' } });
|
|
486
|
+
await startRunner();
|
|
487
|
+
await startNearby();
|
|
488
|
+
}
|
|
489
|
+
|
|
204
490
|
// The owner picks each project, the clients it may be woken in and,
|
|
205
491
|
// optionally, its folder; each share is bound to that project's current lead.
|
|
206
492
|
async function setShares({ shares: wanted }) {
|
|
493
|
+
if (!store().setting('membership')) throw new PeerError('peer_not_paired', 'Pair this computer before sharing a project', 409);
|
|
207
494
|
if (!Array.isArray(wanted) || wanted.length > 50) throw new PeerError('invalid_shares', 'Choose up to 50 projects', 422);
|
|
208
495
|
const agents = await host.listAgents();
|
|
209
496
|
const shares = [];
|
|
@@ -226,9 +513,21 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
226
513
|
...(communicationOnly ? { communicationOnly: true } : {}),
|
|
227
514
|
workingDirectory: entry.workingDirectory ? await confirmedFolder(entry.workingDirectory, projectId) : null });
|
|
228
515
|
}
|
|
516
|
+
// A project the person shared or took back here keeps that choice: sharing at pairing never overrides it.
|
|
517
|
+
const before = sharedProjectIds();
|
|
518
|
+
const after = new Set(shares.map((share) => share.projectId));
|
|
519
|
+
const changed = [...before, ...after].filter((projectId) => before.has(projectId) !== after.has(projectId));
|
|
520
|
+
if (changed.length) {
|
|
521
|
+
store().setSetting('shareTouches', { ...(store().setting('shareTouches') ?? {}),
|
|
522
|
+
...Object.fromEntries(changed.map((projectId) => [projectId, clock()])) });
|
|
523
|
+
}
|
|
229
524
|
store().replaceShares(shares, port.idFactory);
|
|
230
525
|
await runner?.reconcileShares();
|
|
231
|
-
|
|
526
|
+
// A list the coordinator did not get is said here, not only in the log.
|
|
527
|
+
try { await publish(); }
|
|
528
|
+
catch (error) {
|
|
529
|
+
throw new PeerError('share_not_published', `Saved here, but the coordinator did not get the list (${failureCode(error)}); FULI retries every minute`, 502);
|
|
530
|
+
}
|
|
232
531
|
return status();
|
|
233
532
|
}
|
|
234
533
|
|
|
@@ -245,28 +544,290 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
245
544
|
|
|
246
545
|
async function revokeDevice(nodeId) {
|
|
247
546
|
if (!coordinator) throw new PeerError('not_coordinator', 'Only the coordinator device revokes devices', 409);
|
|
248
|
-
|
|
249
|
-
store().forgetAuthority(nodeId);
|
|
547
|
+
revokeStored(nodeId);
|
|
250
548
|
return status();
|
|
251
549
|
}
|
|
252
550
|
|
|
253
|
-
// Leaves the LAN roundtable. History stays; trust, sharing and
|
|
551
|
+
// Leaves the LAN roundtable. History stays; trust, sharing, listening and nearby discovery end.
|
|
254
552
|
async function disable() {
|
|
553
|
+
stopNearby();
|
|
255
554
|
const membership = store().setting('membership');
|
|
256
|
-
// A coordinator turned on again later must not silently trust old devices
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
555
|
+
// A coordinator turned on again later must not silently trust old devices,
|
|
556
|
+
// even when its listener could not start: the store itself is revoked.
|
|
557
|
+
for (const device of storedDevices()) if (!device.self && device.status === 'active') revokeStored(device.nodeId);
|
|
260
558
|
await stopAll();
|
|
261
559
|
store().replaceShares([], port.idFactory);
|
|
262
560
|
store().forgetAuthorities();
|
|
263
561
|
store().setSetting('membership', null);
|
|
264
562
|
store().setSetting('coordinator', null);
|
|
563
|
+
store().setSetting('reachedAddresses', null);
|
|
564
|
+
store().setSetting('pendingTrust', null);
|
|
565
|
+
pairingShare.clear();
|
|
566
|
+
store().setSetting('shareTouches', null);
|
|
567
|
+
listenFailure = null;
|
|
265
568
|
if (membership?.role === 'member') store().setSetting('pendingLeave', membership.coordinator);
|
|
266
569
|
await finishLeaving();
|
|
267
570
|
return status();
|
|
268
571
|
}
|
|
269
572
|
|
|
573
|
+
// ---- Coordinator trust, also while its listener is not running ----
|
|
574
|
+
|
|
575
|
+
// The devices this computer's coordinator store trusts, read from the running
|
|
576
|
+
// service or, when its listener could not start, from the store file itself.
|
|
577
|
+
function storedDevices() {
|
|
578
|
+
if (coordinator) return coordinator.service.devices();
|
|
579
|
+
const path = joinPath(port.directory, 'coordinator.sqlite');
|
|
580
|
+
if (!port.configured() || !existsSync(path) || store().setting('membership')?.role !== 'coordinator') return [];
|
|
581
|
+
const selfId = store().setting('membership').coordinator.fingerprint;
|
|
582
|
+
const coordinatorStore = createCoordinatorStore(path);
|
|
583
|
+
try {
|
|
584
|
+
return coordinatorStore.nodes().map((node) => ({ nodeId: node.id, name: node.name, status: node.status, self: node.id === selfId,
|
|
585
|
+
pairedAt: node.paired_at, revokedAt: node.revoked_at, lastSeenAt: node.last_seen_at ?? null, online: false,
|
|
586
|
+
sharedAgents: JSON.parse(node.directory_json).length }));
|
|
587
|
+
} finally { coordinatorStore.close(); }
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function revokeStored(nodeId) {
|
|
591
|
+
if (coordinator) coordinator.service.revoke(nodeId);
|
|
592
|
+
else {
|
|
593
|
+
const coordinatorStore = createCoordinatorStore(joinPath(port.directory, 'coordinator.sqlite'));
|
|
594
|
+
try { coordinatorStore.revokeNode(nodeId, new Date(clock()).toISOString()); } finally { coordinatorStore.close(); }
|
|
595
|
+
}
|
|
596
|
+
store().forgetAuthority(nodeId);
|
|
597
|
+
pairingShare.forget(nodeId);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// ---- Nearby pairing (rec issue 127) ----
|
|
601
|
+
|
|
602
|
+
const coordinatesOthers = () => storedDevices().some((device) => !device.self && device.status === 'active');
|
|
603
|
+
|
|
604
|
+
function trustedFingerprints() {
|
|
605
|
+
if (store().setting('membership')?.role === 'coordinator') {
|
|
606
|
+
return storedDevices().filter((device) => !device.self && device.status === 'active').map((device) => device.nodeId);
|
|
607
|
+
}
|
|
608
|
+
const membership = store().setting('membership');
|
|
609
|
+
return membership?.role === 'member' ? [membership.coordinator.fingerprint] : [];
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function nearbyRole() {
|
|
613
|
+
const settings = port.configured() ? store().setting('nearby') : null;
|
|
614
|
+
if (!settings) return { listening: false, reason: 'Turn nearby pairing on first' };
|
|
615
|
+
const membership = store().setting('membership');
|
|
616
|
+
if (membership?.role === 'member') {
|
|
617
|
+
return { listening: false, reason: `This computer is paired through ${membership.coordinator.name}; pair other computers there` };
|
|
618
|
+
}
|
|
619
|
+
if (!coordinator) return { listening: false, reason: 'This computer is not listening for nearby pairing' };
|
|
620
|
+
return { listening: true, coordinatesOthers: coordinatesOthers(), listenPort: coordinator.server.address.port };
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
async function nearbyView() {
|
|
624
|
+
const settings = port.configured() ? store().setting('nearby') : null;
|
|
625
|
+
const trusted = settings ? trustedFingerprints() : [];
|
|
626
|
+
const role = nearbyRole();
|
|
627
|
+
const budget = attempts.summary();
|
|
628
|
+
return { on: Boolean(settings), name: settings?.name ?? null,
|
|
629
|
+
suggestedName: port.configured() ? defaultName(await identity()) : null,
|
|
630
|
+
canPair: role.listening && !budget.limited, reason: settings && !role.listening ? role.reason : null,
|
|
631
|
+
until: settings?.until ? new Date(settings.until).toISOString() : null,
|
|
632
|
+
attempts: budget, limited: budget.limited,
|
|
633
|
+
devices: settings ? presence.list().map((entry) => ({ ...entry,
|
|
634
|
+
paired: trusted.some((fingerprint) => fingerprint.startsWith(entry.fingerprint)) })) : [],
|
|
635
|
+
...honestOutcome(pairing.view(), nearbyNotice) };
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// Paired means the other computer used the trust this one wrote: until its
|
|
639
|
+
// first connection the card says waiting, and after a withdrawal it says so.
|
|
640
|
+
function honestOutcome(view, notice) {
|
|
641
|
+
if (!port.configured()) return { pairing: view, ended: notice };
|
|
642
|
+
const pending = new Set((store().setting('pendingTrust') ?? []).map((entry) => entry.fingerprint));
|
|
643
|
+
const devices = store().setting('membership')?.role === 'coordinator' ? storedDevices() : [];
|
|
644
|
+
const outcome = (fingerprint) => {
|
|
645
|
+
const device = devices.find((entry) => entry.nodeId === fingerprint);
|
|
646
|
+
if (device?.status === 'revoked') return 'trust_withdrawn';
|
|
647
|
+
const used = device?.lastSeenAt && Date.parse(device.lastSeenAt) >= Date.parse(device.pairedAt);
|
|
648
|
+
return pending.has(fingerprint) && device?.status === 'active' && !used ? 'waiting' : null;
|
|
649
|
+
};
|
|
650
|
+
const viewOutcome = view?.state === 'paired' && view.device.fingerprint ? outcome(view.device.fingerprint) : null;
|
|
651
|
+
const noticeOutcome = notice?.kind === 'paired' && notice.fingerprint ? outcome(notice.fingerprint) : null;
|
|
652
|
+
return { pairing: viewOutcome ? { ...view, state: viewOutcome } : view,
|
|
653
|
+
ended: noticeOutcome === 'waiting' ? { ...notice, kind: 'waiting' } : notice };
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
async function startNearby() {
|
|
657
|
+
const settings = store().setting('nearby');
|
|
658
|
+
if (!settings) return;
|
|
659
|
+
const device = await identity();
|
|
660
|
+
presence.browse(device.fingerprint);
|
|
661
|
+
if (coordinator) {
|
|
662
|
+
presence.advertise({ name: settings.name, port: coordinator.server.address.port, fingerprint: device.fingerprint,
|
|
663
|
+
addresses: coordinator.host === NEARBY_LISTEN_HOST ? announcedAddresses(interfaces) : [coordinator.host] });
|
|
664
|
+
} else presence.stopAdvertising();
|
|
665
|
+
clearTimeout(nearbyTimer);
|
|
666
|
+
nearbyTimer = setTimeout(() => endNearby({ kind: 'timeout' }).catch(onError), Math.max(0, settings.until - clock()));
|
|
667
|
+
nearbyTimer.unref?.();
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function stopNearby() {
|
|
671
|
+
clearTimeout(nearbyTimer);
|
|
672
|
+
nearbyTimer = null;
|
|
673
|
+
pairing.close();
|
|
674
|
+
presence.stop();
|
|
675
|
+
if (port.configured()) store().setSetting('nearby', null);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Turns nearby pairing on: advertise, list the others, and listen for a
|
|
679
|
+
// pairing request. A computer not yet paired opens its own listener for it;
|
|
680
|
+
// one that listens on an address the person chose listens everywhere for now
|
|
681
|
+
// and returns to that address when nearby pairing turns off. Turning it on
|
|
682
|
+
// again while on keeps its end time.
|
|
683
|
+
async function nearbyOn({ name } = {}) {
|
|
684
|
+
const previous = store().setting('nearby');
|
|
685
|
+
const chosen = cleanName(name) || previous?.name || defaultName(await identity());
|
|
686
|
+
const opened = !store().setting('membership');
|
|
687
|
+
let previousHost = previous?.previousHost ?? null;
|
|
688
|
+
if (opened) {
|
|
689
|
+
if (store().setting('pendingLeave')) throw new PeerError('leave_pending', 'The previous coordinator is offline. Retry after it is available, or revoke this device there.', 409);
|
|
690
|
+
await startCoordinator({ host: nearbyListenHost, port: 0, name: chosen });
|
|
691
|
+
} else if (!previous && coordinator && coordinator.host !== NEARBY_LISTEN_HOST && coordinator.host !== nearbyListenHost) {
|
|
692
|
+
previousHost = coordinator.host;
|
|
693
|
+
await rebindCoordinator(nearbyListenHost);
|
|
694
|
+
} else if (!previous && !coordinator && store().setting('membership')?.role === 'coordinator') {
|
|
695
|
+
throw new PeerError('listen_failed', 'The LAN roundtable is not listening; turn it off and on again first', 409);
|
|
696
|
+
}
|
|
697
|
+
nearbyNotice = null;
|
|
698
|
+
store().setSetting('nearby', { name: chosen, openedListener: opened || Boolean(previous?.openedListener), previousHost,
|
|
699
|
+
until: previous?.until > clock() ? previous.until : clock() + nearbySessionMs });
|
|
700
|
+
if (opened) await startRunner();
|
|
701
|
+
await startNearby();
|
|
702
|
+
return status();
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
async function nearbyOff() {
|
|
706
|
+
await endNearby(null);
|
|
707
|
+
return status();
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// Stops advertising and listing. A listener nearby pairing opened, with no
|
|
711
|
+
// device paired through it, closes too, so nothing listens while off; one
|
|
712
|
+
// that had an address the person chose returns to it; otherwise it narrows
|
|
713
|
+
// to the address its paired devices use.
|
|
714
|
+
async function endNearby(notice) {
|
|
715
|
+
const settings = port.configured() ? store().setting('nearby') : null;
|
|
716
|
+
stopNearby();
|
|
717
|
+
if (notice) nearbyNotice = { ...notice, at: new Date(clock()).toISOString() };
|
|
718
|
+
if (settings?.openedListener && store().setting('membership')?.role === 'coordinator' && !coordinatesOthers()) await disable();
|
|
719
|
+
else if (settings?.previousHost && coordinator?.host !== settings.previousHost) await rebindCoordinator(settings.previousHost);
|
|
720
|
+
else await narrowListener();
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function afterPairing(peer) {
|
|
724
|
+
nearbyNotice = { kind: 'paired', name: peer.name, fingerprint: peer.fingerprint, at: new Date(clock()).toISOString() };
|
|
725
|
+
pairingShare.start(peer.fingerprint)?.catch(onError);
|
|
726
|
+
const timer = setTimeout(() => endNearby({ kind: 'paired', name: peer.name, fingerprint: peer.fingerprint }).catch(onError), pairedGraceMs);
|
|
727
|
+
timer.unref?.();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// Where each paired device last reached this listener, kept across restarts.
|
|
731
|
+
function rememberReached(nodeId, address) {
|
|
732
|
+
store().setSetting('reachedAddresses', { ...(store().setting('reachedAddresses') ?? {}), [nodeId]: address });
|
|
733
|
+
if (!store().setting('nearby')) narrowListener().catch(onError);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// While nearby pairing is off, a wildcard listener moves to the one address
|
|
737
|
+
// its paired devices reached it on, or, when none has connected yet, to this
|
|
738
|
+
// computer's first physical LAN address; devices on several addresses keep it everywhere.
|
|
739
|
+
async function narrowListener() {
|
|
740
|
+
if (!coordinator || coordinator.host !== NEARBY_LISTEN_HOST || store().setting('nearby')) return;
|
|
741
|
+
const reached = store().setting('reachedAddresses') ?? {};
|
|
742
|
+
const addresses = new Set(trustedFingerprints().map((nodeId) => reached[nodeId]).filter((address) => address && !LOOPBACK.test(address)));
|
|
743
|
+
const address = addresses.size === 1 ? [...addresses][0] : addresses.size === 0 ? localAddresses()[0] : null;
|
|
744
|
+
if (address) await rebindCoordinator(address);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// Moves the listener to another address on the same port. When that fails it
|
|
748
|
+
// tries the address it had; when that fails too nothing listens and the
|
|
749
|
+
// card and `fuli peer status` say why. Trust never changes here.
|
|
750
|
+
async function rebindCoordinator(address) {
|
|
751
|
+
const settings = store().setting('coordinator');
|
|
752
|
+
await stopAll();
|
|
753
|
+
try { await startCoordinator({ host: address, port: settings.port, name: settings.name }); }
|
|
754
|
+
catch (error) {
|
|
755
|
+
onError(error);
|
|
756
|
+
const failure = listenFailure;
|
|
757
|
+
try { await startCoordinator({ host: settings.host, port: settings.port, name: settings.name }); }
|
|
758
|
+
catch (again) { onError(again); return; }
|
|
759
|
+
listenFailure = failure;
|
|
760
|
+
}
|
|
761
|
+
await startRunner();
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// Trust written for a nearby pairing is kept only once the other computer
|
|
765
|
+
// used it; a side that never finished leaves nothing trusted here. The
|
|
766
|
+
// deadline is stored, so a restart inside it still checks.
|
|
767
|
+
function watchTrustUse(peer) {
|
|
768
|
+
const pending = (store().setting('pendingTrust') ?? []).filter((entry) => entry.fingerprint !== peer.fingerprint);
|
|
769
|
+
store().setSetting('pendingTrust', [...pending, { fingerprint: peer.fingerprint, name: peer.name, deadline: clock() + trustUseMs }]);
|
|
770
|
+
scheduleTrustCheck(trustUseMs);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function scheduleTrustCheck(delayMs) {
|
|
774
|
+
const timer = setTimeout(() => { trustChecks.delete(timer); checkPendingTrust(); }, delayMs);
|
|
775
|
+
timer.unref?.();
|
|
776
|
+
trustChecks.add(timer);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function checkPendingTrust() {
|
|
780
|
+
if (!port.configured()) return;
|
|
781
|
+
const pending = store().setting('pendingTrust') ?? [];
|
|
782
|
+
if (!pending.length) return;
|
|
783
|
+
const now = clock();
|
|
784
|
+
const devices = storedDevices();
|
|
785
|
+
const waiting = [];
|
|
786
|
+
for (const entry of pending) {
|
|
787
|
+
const device = devices.find((candidate) => candidate.nodeId === entry.fingerprint && candidate.status === 'active');
|
|
788
|
+
const used = device?.lastSeenAt && Date.parse(device.lastSeenAt) >= Date.parse(device.pairedAt);
|
|
789
|
+
if (!device || used) continue;
|
|
790
|
+
if (entry.deadline > now) { waiting.push(entry); continue; }
|
|
791
|
+
revokeStored(entry.fingerprint);
|
|
792
|
+
nearbyNotice = { kind: 'trust_withdrawn', name: entry.name, at: new Date(now).toISOString() };
|
|
793
|
+
}
|
|
794
|
+
store().setSetting('pendingTrust', waiting.length ? waiting : null);
|
|
795
|
+
if (waiting.length) scheduleTrustCheck(Math.max(0, Math.min(...waiting.map((entry) => entry.deadline)) - now));
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
function withdrawTrust(fingerprint) {
|
|
799
|
+
if (!storedDevices().some((entry) => entry.nodeId === fingerprint && entry.status === 'active')) return;
|
|
800
|
+
revokeStored(fingerprint);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
async function pairNearby({ fingerprint }) {
|
|
804
|
+
const prefix = String(fingerprint ?? '').replace(/\s+/g, '').toLowerCase();
|
|
805
|
+
if (!/^[0-9a-f]{4,64}$/.test(prefix)) {
|
|
806
|
+
throw new PeerError('invalid_fingerprint', 'Pass at least the first 4 characters of a fingerprint from the nearby list', 422);
|
|
807
|
+
}
|
|
808
|
+
const matches = presence.list().filter((entry) => prefix.startsWith(entry.fingerprint) || entry.fingerprint.startsWith(prefix));
|
|
809
|
+
if (!matches.length) throw new PeerError('nearby_not_found', 'No nearby FULI has that fingerprint; list them again', 404);
|
|
810
|
+
if (matches.length > 1) throw new PeerError('nearby_ambiguous', 'Several nearby FULI start with that fingerprint; pass more of it', 409);
|
|
811
|
+
await pairing.start(matches[0]);
|
|
812
|
+
return status();
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
async function confirmPairing({ requestId, code }) {
|
|
816
|
+
pairing.confirm({ requestId, code });
|
|
817
|
+
return status();
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
async function cancelPairing() {
|
|
821
|
+
pairing.cancel();
|
|
822
|
+
return status();
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// The person on this computer clears the pairing attempts (local only, never an Agent).
|
|
826
|
+
async function clearPairingAttempts() {
|
|
827
|
+
if (port.configured()) attempts.clear();
|
|
828
|
+
return status();
|
|
829
|
+
}
|
|
830
|
+
|
|
270
831
|
// Local execution stops even if the coordinator is offline. Keep only the
|
|
271
832
|
// unpairing request until it can be delivered, without resuming any shares.
|
|
272
833
|
function finishLeaving() {
|
|
@@ -281,8 +842,7 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
281
842
|
const previous = store().setting('pendingLeave');
|
|
282
843
|
if (!previous) return;
|
|
283
844
|
leaveAbort = new AbortController();
|
|
284
|
-
const
|
|
285
|
-
const client = createPeerClient({ identity, coordinator: previous });
|
|
845
|
+
const client = createPeerClient({ identity: await identity(), coordinator: previous });
|
|
286
846
|
try {
|
|
287
847
|
await client.post('/peer/1/leave', {}, { timeoutMs: 2_000, signal: leaveAbort.signal });
|
|
288
848
|
store().setSetting('pendingLeave', null);
|
|
@@ -297,6 +857,41 @@ export function createPeerRuntime({ host, roundtable, port, interfaces = network
|
|
|
297
857
|
} finally { client.close(); }
|
|
298
858
|
}
|
|
299
859
|
|
|
300
|
-
|
|
301
|
-
|
|
860
|
+
async function close() {
|
|
861
|
+
clearTimeout(nearbyTimer);
|
|
862
|
+
for (const timer of trustChecks) clearTimeout(timer);
|
|
863
|
+
trustChecks.clear();
|
|
864
|
+
pairingShare.close();
|
|
865
|
+
pairing.close();
|
|
866
|
+
presence.stop();
|
|
867
|
+
await stopAll();
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
return { resume, status, searchShareable, shareableProject, enableCoordinator, createInvitation, previewInvitation, join, setShares, revokeDevice, disable,
|
|
871
|
+
nearbyOn, nearbyOff, pairNearby, confirmPairing, cancelPairing, clearPairingAttempts, publish, close, runnerActive: () => Boolean(runner) };
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// The name another computer sees until the person types one: never this computer's own name.
|
|
875
|
+
function defaultName(device) {
|
|
876
|
+
return `FULI ${device.fingerprint.slice(12, 16).toUpperCase()}`;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// A failure's code as shown to the person: a known word, never free text.
|
|
880
|
+
// Codes the coordinator answers with that this computer knows; any other word it sends reads as coordinator_error.
|
|
881
|
+
const COORDINATOR_CODES = new Set(['invalid_directory', 'device_not_trusted', 'payload_too_large', 'invalid_json',
|
|
882
|
+
'unsupported_media_type', 'certificate_required', 'not_found', 'internal_error', 'queue_full']);
|
|
883
|
+
function failureCode(error) {
|
|
884
|
+
const code = typeof error?.code === 'string' ? error.code : 'error';
|
|
885
|
+
if (error?.remote) return COORDINATOR_CODES.has(code) ? code : 'coordinator_error';
|
|
886
|
+
return /^[A-Za-z0-9_]{1,40}$/.test(code) ? code : 'error';
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
function validKey(value) {
|
|
890
|
+
return typeof value?.id === 'string' && typeof value?.key === 'string' && value.key.length >= 32;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// One project's own repository addresses (host Project.repositories) keyed
|
|
894
|
+
// with the paired group's secret; the same address gives the same digest.
|
|
895
|
+
function projectDigests(project, key) {
|
|
896
|
+
return (project.repositories ?? []).map((address) => createHmac('sha256', key.key).update(`fuli-repository:${address}`).digest('hex').slice(0, 32));
|
|
302
897
|
}
|