fuli-context 0.23.0-beta.8 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{AboutPage-BHbNacTY.js → AboutPage-S8QFfzpA.js} +1 -1
- package/dist/web/assets/AboutSectionHeading-B5CzH4Zs.js +1 -0
- package/dist/web/assets/AboutSectionHeading-DjXpIV27.css +1 -0
- package/dist/web/assets/AgentAppsPage-BYXraPFM.js +1 -0
- package/dist/web/assets/{AgentHand-BGzGOjzl.js → AgentHand-BGGdVdd9.js} +1 -1
- package/dist/web/assets/AgentManagement-Bza8k5ra.js +7 -0
- package/dist/web/assets/AgentManagement-CeF4mjtg.css +1 -0
- package/dist/web/assets/AgentMentionCopy-C72hY2QL.js +1 -0
- package/dist/web/assets/{AgentName-C5HzUHaA.js → AgentName-CUjBNQ8j.js} +1 -1
- package/dist/web/assets/AgentProfilePage-D5QUzw5N.css +1 -0
- package/dist/web/assets/AgentProfilePage-kp7-gRRx.js +5 -0
- package/dist/web/assets/AgentServicesPage-IsGaz7FY.js +1 -0
- package/dist/web/assets/{AppViewerPage-N5C_6WLz.css → AppViewerPage-CJ0Zy6LA.css} +1 -1
- package/dist/web/assets/AppViewerPage-CcOlwxck.js +1 -0
- package/dist/web/assets/{BackToTop-SL4ai3_g.js → BackToTop-C3KYEoCW.js} +1 -1
- package/dist/web/assets/BoardCardFieldsMenu-BlBWT1j7.js +1 -0
- package/dist/web/assets/BoardMoveMenu-Bc7xC1Uh.js +1 -0
- package/dist/web/assets/Breadcrumb-BbwBNrG2.css +1 -0
- package/dist/web/assets/Breadcrumb-C_xMiD-Z.js +1 -0
- package/dist/web/assets/CaptureChangePage-Bekp1aWg.js +1 -0
- package/dist/web/assets/ConnectionsPage-BpvecWXD.js +1 -0
- package/dist/web/assets/{CopyFixPrompt-CCrPxN5x.js → CopyFixPrompt-Bp-UX4Hq.js} +1 -1
- package/dist/web/assets/DataFormatPage-dsy8d3oA.js +2 -0
- package/dist/web/assets/DataFormatPage-sSnjjUY4.css +1 -0
- package/dist/web/assets/DebugTurnPage-HdFAyc2D.css +1 -0
- package/dist/web/assets/DebugTurnPage-cIJV7xDW.js +1 -0
- package/dist/web/assets/DebugTurnsPage-B6Te_Alp.js +1 -0
- package/dist/web/assets/DebugTurnsPage-BFuOzyWR.css +1 -0
- package/dist/web/assets/{DialogTitle-CTKjDGQc.js → DialogTitle-Lj5s6nwG.js} +1 -1
- package/dist/web/assets/EmployeeRedirectPage-DnvwJeCN.js +1 -0
- package/dist/web/assets/EmployeeScopeDialog-CXNZ62Ab.js +1 -0
- package/dist/web/assets/EmployeeWorkbench-BhReI8l6.css +1 -0
- package/dist/web/assets/EmployeeWorkbench-DALIO-cM.js +4 -0
- package/dist/web/assets/FieldRoot-DRnAC66O.js +1 -0
- package/dist/web/assets/FlaGrowth-7wlv31Tl.js +1 -0
- package/dist/web/assets/FlaGrowth-BzXY8pcx.css +1 -0
- package/dist/web/assets/FlaTaskSheets-CNdaBy1P.js +1 -0
- package/dist/web/assets/FlasPage-BCs1Ffpf.js +1 -0
- package/dist/web/assets/{FlasPage-Cb6Q5lge.css → FlasPage-SLQDMv47.css} +1 -1
- package/dist/web/assets/{button-CaCh3Iim.css → GrowthLoading-CigPij0N.css} +1 -1
- package/dist/web/assets/GrowthLoading-Cr8xZwwO.js +1 -0
- package/dist/web/assets/HowtoPage-Cv1YQy1s.js +1 -0
- package/dist/web/assets/{HowtoPage-BRV2W1Go.css → HowtoPage-t12tDDpS.css} +1 -1
- package/dist/web/assets/{InboxPage-DSOmt6VL.js → InboxPage-CgJnymOY.js} +2 -2
- package/dist/web/assets/KnowledgeDeleteButton-FEyEvhlR.js +1 -0
- package/dist/web/assets/KnowledgeHardDeleteSection-CVwTeMEJ.js +1 -0
- package/dist/web/assets/KnowledgeItemEditPage-rwpM8cF1.js +1 -0
- package/dist/web/assets/{KnowledgeItemSummaryCard-D1h0e1Hn.js → KnowledgeItemSummaryCard-49EADY_Z.js} +1 -1
- package/dist/web/assets/KnowledgeOrganizerPage-7IdnjM3L.js +1 -0
- package/dist/web/assets/KnowledgePage-gxqOIZxf.js +1 -0
- package/dist/web/assets/KnowledgePeek-Bm5jRVA9.css +1 -0
- package/dist/web/assets/KnowledgePeek-CQyCxHFj.js +1 -0
- package/dist/web/assets/KnowledgeTurnReceiptPage-BOz7IpaK.js +1 -0
- package/dist/web/assets/KnowledgeWorkspace-A7zVb26p.js +4 -0
- package/dist/web/assets/KnowledgeWorkspace-DCoVFyf0.css +1 -0
- package/dist/web/assets/{MeAvatar-DHJA3h2E.js → MeAvatar-CYVcRiuW.js} +1 -1
- package/dist/web/assets/{MeLink-CU7zuYgD.js → MeLink-BdqkzhT6.js} +1 -1
- package/dist/web/assets/{MenuSeparator-DV3U0Y8_.js → MenuSeparator-quqkZZXY.js} +1 -1
- package/dist/web/assets/ModelSettingsPage-B8jC_uew.js +3 -0
- package/dist/web/assets/ModelSettingsPage-DhCn_SF6.css +1 -0
- package/dist/web/assets/{NotFoundPage-BMWxdf6r.js → NotFoundPage-Dmn32VWo.js} +1 -1
- package/dist/web/assets/OccupationsPage-BVREfX_R.js +1 -0
- package/dist/web/assets/OverviewPage-CHyEbdP4.js +1 -0
- package/dist/web/assets/OverviewPage-xdF5g6bZ.css +1 -0
- package/dist/web/assets/{PageColumns-D7jIeVv6.js → PageColumns-DpfaPeu7.js} +1 -1
- package/dist/web/assets/PageOutline-BKBQ1T4d.js +1 -0
- package/dist/web/assets/PageOutline-BqVgnlos.css +1 -0
- package/dist/web/assets/PersonalProfilePage-Cxp2gn6J.js +1 -0
- package/dist/web/assets/PersonalProjectsPage-821imOxR.js +1 -0
- package/dist/web/assets/{PinIcon-DzYhXU_p.js → PinIcon-B7dvh7ld.js} +1 -1
- package/dist/web/assets/{PopperContent-BnejG-fO.js → PopperContent-DNqbLkNa.js} +1 -1
- package/dist/web/assets/{Presence-o9BoSyBV.js → Presence-D3HKb5Hb.js} +1 -1
- package/dist/web/assets/ProfileAuthorChip-7HSHODdR.js +1 -0
- package/dist/web/assets/ProfileAuthorChip-C_0hzDoP.css +1 -0
- package/dist/web/assets/ProjectAgentsPage-DBsXS6Xa.js +5 -0
- package/dist/web/assets/{ProjectAgentsPage-Dt37ogX1.css → ProjectAgentsPage-RpfiV2Fm.css} +1 -1
- package/dist/web/assets/ProjectJudgmentPolicy-GA33aSRi.js +2 -0
- package/dist/web/assets/PublicProjectsPage-PJlBI8IE.js +1 -0
- package/dist/web/assets/{RoundtablesPage-C6vo4kl6.css → RoundtablesPage-DK9A9J-y.css} +1 -1
- package/dist/web/assets/{RoundtablesPage-B2mqkwwR.js → RoundtablesPage-DT5DUXsa.js} +2 -2
- package/dist/web/assets/{RovingFocusGroup-CKxT5j44.js → RovingFocusGroup-BB0d3k17.js} +1 -1
- package/dist/web/assets/{RovingFocusItem-Cr-XrVve.js → RovingFocusItem-CFd7tXzD.js} +1 -1
- package/dist/web/assets/SessionMigrationPage-BZ1lEDQr.js +1 -0
- package/dist/web/assets/SessionRecordsPage-BMAAtIAt.js +1 -0
- package/dist/web/assets/SettingsPage-BYNEk6BM.js +1 -0
- package/dist/web/assets/SettingsPage-Uj1IpZpS.css +1 -0
- package/dist/web/assets/SharedJefaReportPage-g35o6jUb.js +1 -0
- package/dist/web/assets/TagVocabularyPage-COubNJXz.js +1 -0
- package/dist/web/assets/{TaskBlockerClear-38qdj0bl.js → TaskBlockerClear-B5MpHdlh.js} +1 -1
- package/dist/web/assets/{TaskBlockerNotice--X8TtCGj.js → TaskBlockerNotice-CIN0HRiE.js} +1 -1
- package/dist/web/assets/{TaskReason-COiuiZVd.js → TaskReason-LQ0CFiKu.js} +1 -1
- package/dist/web/assets/{TeamCard-Bl4riuQt.css → TeamCard-CsmWDw2Q.css} +1 -1
- package/dist/web/assets/TeamCard-D-kLa5rT.js +1 -0
- package/dist/web/assets/TeamCardsWidget-DGX9k0S6.js +1 -0
- package/dist/web/assets/{TeamIsland-D8ycFpkZ.js → TeamIsland-BIo-l49b.js} +2 -2
- package/dist/web/assets/{Teleport-BAIkXp2z.js → Teleport-C1upABpY.js} +1 -1
- package/dist/web/assets/{TextField-BFGv0VA5.js → TextField-ZnmRqG0h.js} +1 -1
- package/dist/web/assets/{UiChip-h_SUumBM.js → UiChip-CizeOu1Q.js} +1 -1
- package/dist/web/assets/UiDialog-CGTzxn3-.js +1 -0
- package/dist/web/assets/{UiDisclosure-BO5EAYyS.js → UiDisclosure-ueMA4jl0.js} +1 -1
- package/dist/web/assets/UiIcon-sD1hUsOF.js +1 -0
- package/dist/web/assets/{UiIconButton-C0WP-F-p.js → UiIconButton-CCo4NPYv.js} +1 -1
- package/dist/web/assets/{UiNotice-NCEwjNQR.js → UiNotice-DGPFbVo7.js} +1 -1
- package/dist/web/assets/{UiSegmented-B49yYjJ3.js → UiSegmented-BZ-jqnPE.js} +1 -1
- package/dist/web/assets/{UiWeight-DRIwuLUX.js → UiWeight-BRO3oVMZ.js} +1 -1
- package/dist/web/assets/{VirtualDirectoryList-Dieq64pn.js → VirtualDirectoryList-BkV3gj5E.js} +1 -1
- package/dist/web/assets/{VisuallyHidden-DIWFV5lV.js → VisuallyHidden-B8wfJ_mU.js} +1 -1
- package/dist/web/assets/{VisuallyHiddenInput-WxcAZDj2.js → VisuallyHiddenInput-Bdcr9CwC.js} +1 -1
- package/dist/web/assets/WidgetSlot-DFojQaSo.js +2 -0
- package/dist/web/assets/_plugin-vue_export-helper-B9AJmZbc.js +9 -0
- package/dist/web/assets/{agent-apps-CXhZLNMa.js → agent-apps-CKGFfySp.js} +1 -1
- package/dist/web/assets/{agent-avatar-xTnj6P4n.js → agent-avatar-V6M_DF3r.js} +1 -1
- package/dist/web/assets/agent-occupation-PZ2YAIM8.js +1 -0
- package/dist/web/assets/{agent-pins-CMBM9w6b.js → agent-pins-8KX0ynzy.js} +1 -1
- package/dist/web/assets/agent-profile-Clb-gYu-.css +1 -0
- package/dist/web/assets/{agent-roster-records-pCYzR1as.js → agent-roster-records-PfAgndHp.js} +1 -1
- package/dist/web/assets/{agent-workflows-IeF737kp.js → agent-workflows-DQlqVOoA.js} +1 -1
- package/dist/web/assets/{attach-closest-edge-B34lttZK.js → attach-closest-edge-D2qlayPy.js} +1 -1
- package/dist/web/assets/{attention-store-BTKBC8TZ.js → attention-store-BnZ8l3kk.js} +1 -1
- package/dist/web/assets/{badge-Bnc2nVhV.js → badge-DX_xrLV6.js} +1 -1
- package/dist/web/assets/button-CEkPBC1E.js +1 -0
- package/dist/web/assets/button-CoXXgtY5.css +1 -0
- package/dist/web/assets/{card-B2JIXyum.js → card-DNQ0_6vT.js} +1 -1
- package/dist/web/assets/{catalog-C8eUDXUx.js → catalog-KnpBkv5t.js} +1 -1
- package/dist/web/assets/{checkbox-Blw3CguI.js → checkbox-DPyLHneg.js} +1 -1
- package/dist/web/assets/{client-AaxCWoEF.js → client-CSQcWFRh.js} +2 -2
- package/dist/web/assets/client-connection-model-vO2cap6a.js +1 -0
- package/dist/web/assets/{client-links-store-CmP5Qsfa.js → client-links-store-DMqe0MbK.js} +1 -1
- package/dist/web/assets/combobox-zUq9bkyM.js +1 -0
- package/dist/web/assets/{console-DtxpKdVW.js → console-DaoAO-EO.js} +1 -1
- package/dist/web/assets/{context-menu-DSGaOBX2.js → context-menu-CcGDnF_k.js} +1 -1
- package/dist/web/assets/{conversation-launcher-settings-DAL9Kf4y.js → conversation-launcher-settings-CXFE-q_A.js} +1 -1
- package/dist/web/assets/{dialog-CwFuZvhM.js → dialog-CxhKMo0D.js} +1 -1
- package/dist/web/assets/dist-B9GqMC5C.js +1 -0
- package/dist/web/assets/dist-DIJqkL4O.js +1 -0
- package/dist/web/assets/dropdown-menu-CXmMnCBh.js +1 -0
- package/dist/web/assets/field-LNsBZqam.js +1 -0
- package/dist/web/assets/{format-bytes-N7zRFzUD.js → format-bytes-Bqefdt37.js} +1 -1
- package/dist/web/assets/{identity-BUFzZs1s.js → identity-DRfhWjty.js} +1 -1
- package/dist/web/assets/index-B4AMPpl_.css +1 -0
- package/dist/web/assets/index-BYIOAXnn.js +2 -0
- package/dist/web/assets/{input-Db1wVnd4.js → input-UoZ-0Xne.js} +1 -1
- package/dist/web/assets/{label--RjFNYxb.js → label-DpjbTOxt.js} +1 -1
- package/dist/web/assets/label-table-BnWNYfyk.js +1 -0
- package/dist/web/assets/{model-crzN3PVX.js → model-13BQndfF.js} +1 -1
- package/dist/web/assets/{model-KuA63FiT.js → model-B5g0CFcM.js} +1 -1
- package/dist/web/assets/model-BYKHVgJr.js +1 -0
- package/dist/web/assets/{model-B5f68kqL.js → model-CDevUwUw.js} +1 -1
- package/dist/web/assets/model-CpuIG8Du.js +4 -0
- package/dist/web/assets/{model-B5dQs6Zt.js → model-P5fSGsiJ.js} +1 -1
- package/dist/web/assets/{model-DOf6QDiY.js → model-pJ6k3zYD.js} +1 -1
- package/dist/web/assets/{motion-CeLn8y1x.js → motion-C-ZimCUS.js} +1 -1
- package/dist/web/assets/{motion-wEp9RlID.js → motion-QY5FKKko.js} +1 -1
- package/dist/web/assets/{motion-preference-DfUreaML.js → motion-preference-BQiiwhab.js} +1 -1
- package/dist/web/assets/{occupation-catalog-Crs_Zc8R.js → occupation-catalog-uDDhZwKK.js} +1 -1
- package/dist/web/assets/{option-DCSIgajR.js → option-CcHPBOo6.js} +1 -1
- package/dist/web/assets/{orchestration-filters-Cu9KEzWE.js → orchestration-filters-DmF4Qs8E.js} +1 -1
- package/dist/web/assets/{page-title-Bvm24KbY.js → page-title-NXphgeQI.js} +1 -1
- package/dist/web/assets/{person-profile-Cf0Sytyw.js → person-profile-DXXfpvta.js} +1 -1
- package/dist/web/assets/popover-xSRzcSmY.js +1 -0
- package/dist/web/assets/popup-host-Bmvrf-2t.js +1 -0
- package/dist/web/assets/{profile-model-DkDH6Qth.js → profile-model-6gTmScHC.js} +1 -1
- package/dist/web/assets/{project-board-layout-OeuzohUI.js → project-board-layout-DBQeP_QP.js} +1 -1
- package/dist/web/assets/{project-capture-BQAqeAJf.js → project-capture-BhYsDWwJ.js} +1 -1
- package/dist/web/assets/{project-origin-CENDtRuK.js → project-origin-D8jy8EF_.js} +1 -1
- package/dist/web/assets/{quick-edit-api-Qndjqk1h.js → quick-edit-api-WLh_88w6.js} +1 -1
- package/dist/web/assets/{radio-group-pfWejLFt.js → radio-group-B4r78nDh.js} +1 -1
- package/dist/web/assets/{role-names-aIXV-sMx.js → role-names-PECaMfQo.js} +1 -1
- package/dist/web/assets/{roundtable-live-D7Asm_GB.js → roundtable-live-DFeDF56c.js} +1 -1
- package/dist/web/assets/{runtime-dom.esm-bundler-BS2lpl87.js → runtime-dom.esm-bundler-f39i44Mt.js} +1 -1
- package/dist/web/assets/save-file-rPduHi2f.js +1 -0
- package/dist/web/assets/select-_JO3Mxdp.js +1 -0
- package/dist/web/assets/{session-launch-offers-kLW-dRsW.js → session-launch-offers-X9b0DwF1.js} +1 -1
- package/dist/web/assets/settings-restart-BnwcTv3i.js +1 -0
- package/dist/web/assets/shared-report-BxNVLalR.js +3 -0
- package/dist/web/assets/shared-report-mYIyRY9C.css +1 -0
- package/dist/web/assets/{source-adapters-CUxqZHz7.js → source-adapters-aupsL146.js} +1 -1
- package/dist/web/assets/{switch-Cdz4-JcE.js → switch-B3Y3oE_n.js} +1 -1
- package/dist/web/assets/{tabs-C3w1-eMu.js → tabs-BlcZiEMY.js} +1 -1
- package/dist/web/assets/{task-board-model-DSr4P56O.js → task-board-model-CmMKsWdY.js} +1 -1
- package/dist/web/assets/task-card-fields-DAx6zMLz.js +1 -0
- package/dist/web/assets/task-labels-BdDFvSAy.js +1 -0
- package/dist/web/assets/{task-reason-BywD_kfi.js → task-reason-7WnPreht.js} +1 -1
- package/dist/web/assets/{team-sheets-D8Y--CP4.js → team-sheets-Cr0ZTPw3.js} +1 -1
- package/dist/web/assets/{textarea-C228nxbD.js → textarea-CRzFqL9a.js} +1 -1
- package/dist/web/assets/{ui-BM8jZcP6.js → ui-BopQuQfc.js} +1 -1
- package/dist/web/assets/{useAgentRecords-D7x4xQ9O.js → useAgentRecords-CMtpd3Fj.js} +1 -1
- package/dist/web/assets/{useAgentWorkSummary-pc1i6nr0.js → useAgentWorkSummary-BQbhaHov.js} +1 -1
- package/dist/web/assets/{useApi-CROJJdhE-DZtkWJZv.js → useApi-CROJJdhE-CRCgNOqq.js} +1 -1
- package/dist/web/assets/{useClipboardCopy-sTthF_MD.js → useClipboardCopy-DkqKK3wY.js} +1 -1
- package/dist/web/assets/{useFocusReturn-BoyUh5y3.js → useFocusReturn-BZpVmQnM.js} +1 -1
- package/dist/web/assets/{useForwardExpose-CqXuqZvd.js → useForwardExpose-Di-MnbTz.js} +1 -1
- package/dist/web/assets/{useForwardPropsEmits-0F_e7unJ.js → useForwardPropsEmits-L9XcB5DG.js} +1 -1
- package/dist/web/assets/useForwardScopeId-CUQFIAIj.js +1 -0
- package/dist/web/assets/useKnowledgeItemPeek-PmQJixw5.js +1 -0
- package/dist/web/assets/{useMinimumLoadingDisplay-CzfqbQPs.js → useMinimumLoadingDisplay-CWPiOaDl.js} +1 -1
- package/dist/web/assets/useProjectAgentRoster-CWVpSsQ3.js +1 -0
- package/dist/web/assets/{useRoutePeek-BDgll9Fy.js → useRoutePeek-DxLVksbJ.js} +1 -1
- package/dist/web/assets/useTeamPeople-CDISP0PM.js +1 -0
- package/dist/web/assets/{useTeamWork-BSFi27vj.js → useTeamWork-BTZd_wKs.js} +1 -1
- package/dist/web/assets/{useTypeahead-D_g4j3Xp.js → useTypeahead-pEZNpBls.js} +1 -1
- package/dist/web/assets/{utils-C6vsxGrE.js → utils-B4pBTmyh.js} +1 -1
- package/dist/web/assets/utils-BsxOjD1Q.js +1 -0
- package/dist/web/assets/version-db3QWWjt.js +1 -0
- package/dist/web/assets/{vue-router-BPhQ0Qow.js → vue-router-B79HWW1l.js} +1 -1
- package/dist/web/assets/website-YgovUEcN.js +1 -0
- package/dist/web/index.html +71 -66
- package/docs/agent-interface-architecture.md +13 -4
- package/docs/client-connections.md +3 -2
- package/docs/employee-agents.md +11 -9
- package/docs/judgment-and-autonomy.md +4 -4
- package/graph-provider/fuli_graph/app.py +4 -0
- package/graph-provider/fuli_graph/collaboration_context.py +3 -7
- package/graph-provider/fuli_graph/graph_field_contract.py +10 -2
- package/graph-provider/fuli_graph/graph_format_builtin_occupations.py +33 -1
- package/graph-provider/fuli_graph/graph_format_migrations.py +18 -0
- package/graph-provider/fuli_graph/graph_query.py +3 -12
- package/graph-provider/fuli_graph/knowledge_index_scan.py +120 -0
- package/graph-provider/fuli_graph/knowledge_outdated.py +9 -1
- package/graph-provider/fuli_graph/knowledge_retrieval_models.py +95 -0
- package/graph-provider/fuli_graph/knowledge_retrieval_terms.py +116 -0
- package/graph-provider/fuli_graph/knowledge_search.py +220 -39
- package/graph-provider/fuli_graph/knowledge_semantic.py +87 -0
- package/graph-provider/fuli_graph/knowledge_semantic_index.py +98 -0
- package/graph-provider/fuli_graph/knowledge_semantic_models.py +72 -0
- package/graph-provider/fuli_graph/knowledge_semantic_query.py +19 -0
- package/graph-provider/fuli_graph/knowledge_versions.py +14 -7
- package/graph-provider/fuli_graph/models.py +4 -0
- package/graph-provider/fuli_graph/occupation_catalog.py +6 -3
- package/graph-provider/fuli_graph/personal_global_preferences.py +3 -7
- package/graph-provider/fuli_graph/preference_versions.py +110 -0
- package/graph-provider/fuli_graph/project_agent_models.py +3 -0
- package/graph-provider/fuli_graph/project_agent_recruitment_occupation.py +1 -1
- package/graph-provider/fuli_graph/provider_values.py +7 -0
- package/graph-provider/fuli_graph/search_projection.py +2 -6
- package/graph-provider/fuli_graph/store_knowledge.py +10 -1
- package/graph-provider/fuli_graph/task_context_routes.py +1 -1
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +3 -4
- package/package.json +2 -1
- package/skills/capturing-session-knowledge/SKILL.md +14 -7
- package/skills/capturing-session-knowledge/references/capture.md +12 -2
- package/skills/capturing-session-knowledge/references/retrieval.md +13 -4
- package/skills/grilling-project/SKILL.md +2 -0
- package/skills/operating-fuli/SKILL.md +36 -8
- package/skills/operating-fuli/references/workflow-recipes.md +10 -9
- package/src/agent-apps/host-tools/catalog.js +3 -0
- package/src/agent-delegation/agent-tool.js +12 -2
- package/src/agent-delegation/delegation-header.js +32 -8
- package/src/agent-delegation/entry-prompts.js +54 -0
- package/src/agent-delegation/operation-log.js +17 -7
- package/src/agent-delegation/person-words.js +38 -0
- package/src/agent-delegation/port.js +6 -4
- package/src/agent-delegation/refusals.js +14 -0
- package/src/agent-kits/client-detection.js +7 -0
- package/src/agent-kits/client-installer.js +13 -0
- package/src/agent-tools/delegation-definitions.js +5 -3
- package/src/agent-tools/diagnostic-definitions.js +23 -0
- package/src/agent-tools/graph-definitions.js +4 -0
- package/src/agent-tools/graph-handlers.js +6 -1
- package/src/agent-tools/interface-catalog.js +47 -17
- package/src/agent-tools/model-backend-definitions.js +1 -1
- package/src/agent-tools/old-data-definitions.js +16 -0
- package/src/agent-tools/task-entry-definitions.js +1 -1
- package/src/agent-tools/work-surface-definitions.js +1 -1
- package/src/agents/claude-code/lifecycle-hook.js +19 -5
- package/src/agents/claude-code/transcript-format-probe.js +31 -0
- package/src/agents/codex/lifecycle-hook.js +27 -7
- package/src/agents/codex/transcript-format-probe.js +29 -0
- package/src/agents/cursor/lifecycle-hook.js +4 -1
- package/src/agents/lifecycle-failure.js +27 -0
- package/src/agents/lifecycle-message.js +10 -0
- package/src/agents/opencode/lifecycle-hook.js +18 -2
- package/src/agents/transcript-format-registry.js +34 -0
- package/src/agents/transcript-format-scan.js +71 -0
- package/src/cli/command-registry.js +3 -0
- package/src/cli/diagnostics-command.js +59 -0
- package/src/cli/setup-command.js +3 -0
- package/src/cli.js +5 -0
- package/src/conversations/entry-budget.js +1 -1
- package/src/conversations/entry-detail-readers.js +22 -0
- package/src/conversations/entry-inline-budget.js +24 -12
- package/src/conversations/entry-skeleton.js +27 -9
- package/src/conversations/preference-lifecycle.js +2 -1
- package/src/conversations/preference-session.js +5 -2
- package/src/conversations/preference-snapshot.js +4 -1
- package/src/conversations/preference-view.js +5 -1
- package/src/conversations/reply-citations.js +21 -0
- package/src/conversations/stop-auto-close.js +21 -9
- package/src/conversations/task-context-view.js +31 -0
- package/src/data-format/backup-retention.js +8 -0
- package/src/data-format/local-stores.js +24 -2
- package/src/debug-turns/fuli-surface.js +23 -0
- package/src/debug-turns/model-capture.js +84 -0
- package/src/debug-turns/model-request.js +97 -0
- package/src/debug-turns/record.js +178 -0
- package/src/debug-turns/recorder.js +53 -0
- package/src/debug-turns/store.js +91 -0
- package/src/debug-turns/transcript-reader.js +64 -0
- package/src/debug-turns/trigger.js +25 -0
- package/src/diagnostics/agent-tool.js +14 -0
- package/src/diagnostics/event-log.js +133 -0
- package/src/diagnostics/failure-records.js +43 -0
- package/src/diagnostics/query.js +114 -0
- package/src/diagnostics/safe-event.js +83 -0
- package/src/dreaming/run.js +310 -0
- package/src/dreaming/scheduler.js +58 -0
- package/src/employees/builtin/jefa/board-store.js +78 -19
- package/src/employees/builtin/jefa/http.js +8 -5
- package/src/employees/builtin/jefa/project-board.js +2 -0
- package/src/employees/builtin/jefa/tools.js +7 -6
- package/src/employees/recruitment.js +20 -2
- package/src/employees/service.js +11 -1
- package/src/graphiti/agent-growth.js +64 -0
- package/src/graphiti/collaboration-preference-projection.js +7 -0
- package/src/graphiti/collaboration-preference-workflow.js +3 -3
- package/src/graphiti/current-project-knowledge-search.js +24 -1
- package/src/graphiti/federated-application.js +19 -1
- package/src/graphiti/federated-search.js +8 -1
- package/src/graphiti/local-runtimes.js +13 -0
- package/src/graphiti/personal-projects.js +11 -0
- package/src/graphiti/project-agent-mapping.js +1 -0
- package/src/graphiti/project-agent-task-sheets.js +6 -2
- package/src/graphiti/project-agent-workflows.js +22 -4
- package/src/graphiti/project-profile-authors.js +14 -7
- package/src/graphiti/provider-client.js +36 -0
- package/src/graphiti/session-knowledge-migration.js +103 -3
- package/src/graphiti/session-migration-notices.js +65 -0
- package/src/graphiti/session-records.js +22 -4
- package/src/graphiti/task-context-entry.js +5 -1
- package/src/graphiti/task-entry-preferences.js +31 -2
- package/src/graphiti/task-entry-read-only.js +28 -0
- package/src/graphiti/task-knowledge-checkpoint.js +2 -0
- package/src/graphiti/task-knowledge-recall.js +96 -19
- package/src/graphiti/task-remember.js +7 -2
- package/src/graphiti/task-update-request.js +13 -0
- package/src/graphiti/temporary-project-scope.js +7 -1
- package/src/graphiti/turn-receipt-delivery.js +5 -3
- package/src/http/agent-delegation-gate.js +5 -4
- package/src/http/agent-growth-api-router.js +17 -0
- package/src/http/api-router.js +18 -2
- package/src/http/capture-onboarding-api-router.js +3 -2
- package/src/http/debug-turns-api-router.js +70 -0
- package/src/http/diagnostic-events-api-router.js +27 -0
- package/src/http/dreaming-api-router.js +32 -0
- package/src/http/graph-api-router.js +35 -1
- package/src/http/knowledge-item-api-router.js +19 -2
- package/src/http/knowledge-scope-api-router.js +3 -2
- package/src/http/old-data-api-router.js +47 -0
- package/src/http/person-profile-api-router.js +3 -2
- package/src/http/retrieval-terms-api-router.js +37 -0
- package/src/http/semantic-api-router.js +26 -0
- package/src/judgment/agent-view.js +1 -1
- package/src/judgment/backend.js +30 -0
- package/src/judgment/http.js +2 -1
- package/src/judgment/review-prompt.js +2 -0
- package/src/judgment/routing.js +10 -2
- package/src/judgment/service.js +8 -2
- package/src/judgment/store.js +17 -7
- package/src/local-runtime/lifecycle.js +3 -0
- package/src/local-runtime/windows-process-handle.js +9 -3
- package/src/mcp/create-mcp-server.js +42 -25
- package/src/mcp/process-registry.js +45 -3
- package/src/mcp/runtime.js +2 -1
- package/src/mcp/stdio-relay.js +4 -1
- package/src/mcp/tool-annotations.js +2 -0
- package/src/model-backends/adapters/anthropic-messages.js +1 -1
- package/src/model-backends/adapters/exchange.js +2 -2
- package/src/model-backends/adapters/openai-chat.js +1 -1
- package/src/model-backends/adapters/openai-embeddings.js +60 -0
- package/src/model-backends/adapters/registry.js +3 -1
- package/src/model-backends/adapters/typesafe-systemone.js +1 -1
- package/src/model-backends/budget.js +14 -8
- package/src/model-backends/config.js +49 -15
- package/src/model-backends/decision-contract.js +2 -1
- package/src/model-backends/http.js +19 -1
- package/src/model-backends/model-fetch.js +37 -0
- package/src/model-backends/port.js +165 -67
- package/src/model-backends/prompt.js +4 -3
- package/src/model-backends/request.js +42 -3
- package/src/native-runtime/runtime.js +28 -4
- package/src/old-data/agent-tools.js +17 -0
- package/src/old-data/backup-reader.js +78 -0
- package/src/old-data/console-actions.js +53 -0
- package/src/old-data/guarded-stores.js +18 -0
- package/src/old-data/inventory.js +142 -0
- package/src/old-data/port.js +53 -0
- package/src/person-profile/port.js +2 -1
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/project-change-log/port.js +65 -0
- package/src/project-change-log/store.js +60 -0
- package/src/retrieval-terms/fill.js +102 -0
- package/src/retrieval-terms/runner.js +50 -0
- package/src/retrieval-terms/terms-model.js +99 -0
- package/src/security/sensitive-content.js +11 -0
- package/src/semantic/scheduler.js +50 -0
- package/src/semantic/semantic-index.js +94 -0
- package/src/server.js +20 -1
- package/src/setup/paths.js +1 -1
- package/src/setup/setup.js +7 -0
- package/src/system/client-connection-status.js +6 -4
- package/src/system/doctor-repair.js +16 -4
- package/src/system/doctor.js +75 -3
- package/src/system/log-paths.js +11 -0
- package/src/system/log-retention.js +2 -8
- package/src/system/mcp-process-scan.js +55 -0
- package/src/system/resource-monitor.js +18 -2
- package/src/system/system-service.js +39 -7
- package/src/system/windows-data-acl.js +109 -0
- package/src/work-surfaces/port.js +17 -11
- package/src/work-surfaces/sources.js +4 -3
- package/dist/web/assets/AboutSectionHeading-BOXKE5Le.js +0 -1
- package/dist/web/assets/AboutSectionHeading-CiD3M3eG.css +0 -1
- package/dist/web/assets/AgentAppsPage-DS2X485q.js +0 -1
- package/dist/web/assets/AgentConversations-D7QJVFIo.js +0 -2
- package/dist/web/assets/AgentConversations-oZFXZE1X.css +0 -1
- package/dist/web/assets/AgentMentionCopy-O6pAjjYE.js +0 -1
- package/dist/web/assets/AgentProfilePage-CKCTcTzc.js +0 -2
- package/dist/web/assets/AgentProfilePage-D1ha8O3z.css +0 -1
- package/dist/web/assets/AgentServicesPage-C3npKkHp.js +0 -1
- package/dist/web/assets/AgentWorkbench-CJ4TYQA1.css +0 -1
- package/dist/web/assets/AgentWorkbench-D9HGRW-n.js +0 -2
- package/dist/web/assets/AppViewerPage-Al4TzYJF.js +0 -1
- package/dist/web/assets/BoardMoveMenu-ncWgEitd.js +0 -1
- package/dist/web/assets/Breadcrumb-QzjzIJdS.js +0 -1
- package/dist/web/assets/Breadcrumb-bsc0JKtG.css +0 -1
- package/dist/web/assets/CaptureChangePage-BQdqH2qC.js +0 -1
- package/dist/web/assets/ConnectionsPage-Be8jIb93.js +0 -1
- package/dist/web/assets/DataFormatPage-0Ne27K6I.css +0 -1
- package/dist/web/assets/DataFormatPage-C92rwzHa.js +0 -2
- package/dist/web/assets/EmployeeScopeDialog-DdR2DzcW.js +0 -1
- package/dist/web/assets/EmployeeTaskBoard-Bo8JT36K.js +0 -3
- package/dist/web/assets/EmployeeTaskBoard-Dljjy_L7.css +0 -1
- package/dist/web/assets/EmployeeWorkbenchPage-B249Mgle.js +0 -3
- package/dist/web/assets/EmployeeWorkbenchPage-BBjZJ6Od.css +0 -1
- package/dist/web/assets/FieldRoot-YdKVCBhW.js +0 -1
- package/dist/web/assets/FlaTaskSheets-Cm5SLq7J.js +0 -1
- package/dist/web/assets/FlasPage-C57gTN5X.js +0 -1
- package/dist/web/assets/HowtoPage-CDJScY6b.js +0 -1
- package/dist/web/assets/KnowledgeDeleteButton-5EtCPPl4.js +0 -1
- package/dist/web/assets/KnowledgeHardDeleteSection-r0lZ7ijb.js +0 -1
- package/dist/web/assets/KnowledgeItemEditPage-BStIRllM.js +0 -1
- package/dist/web/assets/KnowledgeOrganizerPage-BByk8hbw.js +0 -1
- package/dist/web/assets/KnowledgePage-DuWS3bRP.js +0 -1
- package/dist/web/assets/KnowledgePeek-BycBJ2xR.js +0 -1
- package/dist/web/assets/KnowledgePeek-EvumfJER.css +0 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-DTcDN-pG.js +0 -1
- package/dist/web/assets/KnowledgeWorkspace-CJo-6xdn.js +0 -4
- package/dist/web/assets/KnowledgeWorkspace-DPBq-At0.css +0 -1
- package/dist/web/assets/ModelSettingsPage-C1ghraAh.js +0 -1
- package/dist/web/assets/ModelSettingsPage-ConWy_ec.css +0 -1
- package/dist/web/assets/OccupationsPage-BY1jej7i.js +0 -1
- package/dist/web/assets/OverviewPage-C7YJf-Cq.css +0 -1
- package/dist/web/assets/OverviewPage-Dl-H0EBe.js +0 -1
- package/dist/web/assets/PersonalProfilePage-BcaVzKM6.js +0 -1
- package/dist/web/assets/PersonalProjectsPage-CO4ZYVAI.js +0 -1
- package/dist/web/assets/ProjectAgentDetailPage-Bgh78Mr5.js +0 -8
- package/dist/web/assets/ProjectAgentDetailPage-h7hr9iee.css +0 -1
- package/dist/web/assets/ProjectAgentDialog--T6mU-FW.css +0 -1
- package/dist/web/assets/ProjectAgentDialog-DzTor5ky.js +0 -5
- package/dist/web/assets/ProjectAgentsPage-CzN183pa.js +0 -1
- package/dist/web/assets/ProjectJudgmentPolicy-BMlEBJM3.js +0 -2
- package/dist/web/assets/PublicProjectsPage-DAHT31B8.js +0 -1
- package/dist/web/assets/SessionMigrationPage-IW07XhmD.js +0 -1
- package/dist/web/assets/SessionRecordsPage-Du76tewc.js +0 -1
- package/dist/web/assets/SettingsPage-CJNXe313.js +0 -1
- package/dist/web/assets/SettingsPage-D3AYCNTC.css +0 -1
- package/dist/web/assets/SharedJefaReportPage-dzHSSGhu.js +0 -1
- package/dist/web/assets/TagVocabularyPage-C_oV6GFs.js +0 -1
- package/dist/web/assets/TeamCard-CdO0RiNB.js +0 -1
- package/dist/web/assets/TeamCardsWidget-Cg_kJmb-.js +0 -1
- package/dist/web/assets/UiDialog-CUgrU6SQ.js +0 -1
- package/dist/web/assets/UiIcon-DPv0eZIU.js +0 -1
- package/dist/web/assets/WidgetSlot-BSU_-l_4.js +0 -2
- package/dist/web/assets/_plugin-vue_export-helper-DQENg-QE.js +0 -9
- package/dist/web/assets/agent-occupation-BvOgDW-q.js +0 -1
- package/dist/web/assets/agent-profile-BBqkfac0.css +0 -1
- package/dist/web/assets/agent-task-board-Cf9il_1i.js +0 -1
- package/dist/web/assets/button-N4FjuQuJ.js +0 -1
- package/dist/web/assets/client-connection-model-C3gpYYl7.js +0 -1
- package/dist/web/assets/combobox-DHwWXUpj.js +0 -1
- package/dist/web/assets/desktop-client-DnfjyLBX.js +0 -1
- package/dist/web/assets/dist-BInsvNsv.js +0 -1
- package/dist/web/assets/dist-Dc8jFf8M.js +0 -1
- package/dist/web/assets/field-BQLn7Hfw.js +0 -1
- package/dist/web/assets/index-CXPYDcyq.js +0 -2
- package/dist/web/assets/index-x95VDmzK.css +0 -1
- package/dist/web/assets/judgment-api-CK9yqrpU.js +0 -1
- package/dist/web/assets/label-table-KdyaCTvK.js +0 -1
- package/dist/web/assets/model-D4kKYvpj.js +0 -1
- package/dist/web/assets/popover-D4YFkL_5.js +0 -1
- package/dist/web/assets/project-board-settings-DPP6xKLz.js +0 -1
- package/dist/web/assets/project-team-api-7ybLH-uJ.js +0 -1
- package/dist/web/assets/save-file-CRxAsski.js +0 -1
- package/dist/web/assets/select-CUy1AIwE.js +0 -1
- package/dist/web/assets/settings-restart-JYH81qB-.js +0 -1
- package/dist/web/assets/shared-report-8p3nBKr-.js +0 -1
- package/dist/web/assets/source-coverage-4PsHC9TK.js +0 -1
- package/dist/web/assets/task-labels-CXBG2chm.js +0 -1
- package/dist/web/assets/useForwardScopeId-DVUFcuwO.js +0 -1
- package/dist/web/assets/useKnowledgeItemPeek-KZveY8Wz.js +0 -1
- package/dist/web/assets/useTeamPeople-Dna3Yrm3.js +0 -1
- package/dist/web/assets/utils-BX1QI2N6.js +0 -1
- package/dist/web/assets/version-CBPeq5nI.js +0 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
// Per-call and per-window limits of one role
|
|
2
|
-
// even when roles share a connection, and nothing
|
|
3
|
-
// An attempt whose usage is unknown counts at the
|
|
1
|
+
// Per-call and per-window limits of one role, none unless the person set them.
|
|
2
|
+
// Every role has its own pool, even when roles share a connection, and nothing
|
|
3
|
+
// switches to another pool. An attempt whose usage is unknown counts at the
|
|
4
|
+
// ceiling it was allowed.
|
|
4
5
|
|
|
5
6
|
// Conservative estimate: overcounts English text and gives about one token
|
|
6
7
|
// per CJK character (three UTF-8 bytes), before any provider tokenizer runs.
|
|
7
8
|
const ESTIMATED_BYTES_PER_TOKEN = 2.5;
|
|
8
9
|
const PER_MILLION = 1_000_000;
|
|
9
10
|
const COST_PRECISION = 1e10;
|
|
11
|
+
// What a request still has to name when no limit is set: a provider needs an
|
|
12
|
+
// output size, a hung connection needs an end, and usage is read over a period.
|
|
13
|
+
const DEFAULT_OUTPUT_TOKENS = 16_000;
|
|
14
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
15
|
+
const DEFAULT_WINDOW_HOURS = 24;
|
|
10
16
|
|
|
11
17
|
export function estimateTokens(value) {
|
|
12
18
|
return Math.ceil(Buffer.byteLength(JSON.stringify(value)) / ESTIMATED_BYTES_PER_TOKEN);
|
|
@@ -15,20 +21,20 @@ export function estimateTokens(value) {
|
|
|
15
21
|
// A request may tighten the role's per-call limits, never widen them.
|
|
16
22
|
export function callLimits(budget, requested = {}) {
|
|
17
23
|
return {
|
|
18
|
-
maxInputTokens: budget.maxInputTokens,
|
|
19
|
-
maxOutputTokens: Math.min(budget.maxOutputTokens, requested.maxOutputTokens ?? Infinity),
|
|
20
|
-
timeoutMs: Math.min(budget.timeoutMs, requested.timeoutMs ?? Infinity)
|
|
24
|
+
maxInputTokens: budget.maxInputTokens ?? Infinity,
|
|
25
|
+
maxOutputTokens: Math.min(budget.maxOutputTokens ?? DEFAULT_OUTPUT_TOKENS, requested.maxOutputTokens ?? Infinity),
|
|
26
|
+
timeoutMs: Math.min(budget.timeoutMs ?? DEFAULT_TIMEOUT_MS, requested.timeoutMs ?? Infinity)
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export function windowStart(budget, now) {
|
|
25
|
-
return new Date(now.getTime() - budget.windowHours * 3_600_000).toISOString();
|
|
31
|
+
return new Date(now.getTime() - (budget.windowHours ?? DEFAULT_WINDOW_HOURS) * 3_600_000).toISOString();
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
// The reason the next attempt may not start, or null.
|
|
29
35
|
export function budgetBlock({ budget, pricing, window, estimatedInputTokens, maxOutputTokens }) {
|
|
30
36
|
const ceiling = estimatedInputTokens + maxOutputTokens;
|
|
31
|
-
if (window.reportedTokens + window.reservedTokens + ceiling > budget.maxTokensPerWindow) return 'window_tokens';
|
|
37
|
+
if (budget.maxTokensPerWindow !== null && window.reportedTokens + window.reservedTokens + ceiling > budget.maxTokensPerWindow) return 'window_tokens';
|
|
32
38
|
if (budget.maxCostPerWindow === null) return null;
|
|
33
39
|
const highestPrice = Math.max(pricing.inputPerMillionTokens, pricing.outputPerMillionTokens) / PER_MILLION;
|
|
34
40
|
const spent = window.estimatedCost + window.unpricedTokens * highestPrice;
|
|
@@ -6,13 +6,19 @@ import {
|
|
|
6
6
|
} from '../validation/values.js';
|
|
7
7
|
import { secretReference } from './secret-store.js';
|
|
8
8
|
|
|
9
|
-
// Optional per-role model backends for the four built-in Agents
|
|
9
|
+
// Optional per-role model backends for the four built-in Agents and semantic
|
|
10
|
+
// search (rec#88). The file
|
|
10
11
|
// holds connections and role settings only; keys live in the secret store and
|
|
11
12
|
// are named here by secretRef. A missing file or roles section configures no
|
|
12
13
|
// role, so older installations keep using the current session.
|
|
13
14
|
|
|
14
|
-
export const MODEL_BACKEND_ROLES = Object.freeze(['assistant', 'bole', 'jefa', 'tonborg']);
|
|
15
|
-
|
|
15
|
+
export const MODEL_BACKEND_ROLES = Object.freeze(['assistant', 'bole', 'jefa', 'tonborg', 'semantic']);
|
|
16
|
+
// semantic is no Agent: the person's own model that turns knowledge text into
|
|
17
|
+
// vectors (rec#88). It takes only the embeddings protocol, which serves no other role.
|
|
18
|
+
export const SEMANTIC_ROLE = 'semantic';
|
|
19
|
+
export const KNOWLEDGE_EMBEDDING_OPERATION = 'knowledge_embedding';
|
|
20
|
+
const EMBEDDING_PROTOCOL = 'openai_embeddings';
|
|
21
|
+
const MODEL_BACKEND_PROTOCOLS = Object.freeze(['openai_chat', 'anthropic_messages', 'typesafe_systemone', EMBEDDING_PROTOCOL]);
|
|
16
22
|
export const OPERATION_PATTERN = /^[a-z][a-z0-9_.-]{0,63}$/;
|
|
17
23
|
|
|
18
24
|
const CONFIG_VERSION = 1;
|
|
@@ -27,6 +33,10 @@ const REASONING_EFFORTS = Object.freeze(['none', 'minimal', 'low', 'medium', 'hi
|
|
|
27
33
|
export const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
|
28
34
|
const MAX_OPERATIONS = 32;
|
|
29
35
|
const MAX_APPROVED_PROJECTS = 256;
|
|
36
|
+
const MAX_HEADERS = 16;
|
|
37
|
+
const MAX_HEADER_VALUE = 512;
|
|
38
|
+
const HEADER_NAME = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
|
|
39
|
+
const RESERVED_HEADERS = new Set(['authorization', 'x-api-key', 'content-type', 'accept', 'host', 'content-length', 'anthropic-version']);
|
|
30
40
|
const MIN_TIMEOUT_MS = 1000;
|
|
31
41
|
const BUDGET_LIMITS = Object.freeze({
|
|
32
42
|
maxInputTokens: 2_000_000, maxOutputTokens: 200_000, timeoutMs: 600_000,
|
|
@@ -74,14 +84,14 @@ export function normalizeConfig(raw) {
|
|
|
74
84
|
const roles = object(raw.roles ?? {}, 'roles');
|
|
75
85
|
for (const role of Object.keys(roles)) {
|
|
76
86
|
if (!MODEL_BACKEND_ROLES.includes(role)) {
|
|
77
|
-
throw new TypeError(`roles.${role} is not a
|
|
87
|
+
throw new TypeError(`roles.${role} is not a model role (${MODEL_BACKEND_ROLES.join(', ')})`);
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
return {
|
|
81
91
|
version: CONFIG_VERSION,
|
|
82
92
|
connections,
|
|
83
93
|
roles: Object.fromEntries(Object.entries(roles).map(([role, value]) =>
|
|
84
|
-
[role, normalizeRole(value, `roles.${role}`, connections)]))
|
|
94
|
+
[role, normalizeRole(value, `roles.${role}`, connections, role)]))
|
|
85
95
|
};
|
|
86
96
|
}
|
|
87
97
|
|
|
@@ -95,7 +105,7 @@ function normalizeConnections(value) {
|
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
function normalizeConnection(value, label) {
|
|
98
|
-
object(value, label, ['protocol', 'endpoint', 'model', 'secretRef', 'reasoningEffort', 'pricing']);
|
|
108
|
+
object(value, label, ['protocol', 'endpoint', 'model', 'secretRef', 'reasoningEffort', 'headers', 'pricing']);
|
|
99
109
|
if (!MODEL_BACKEND_PROTOCOLS.includes(value.protocol)) {
|
|
100
110
|
throw new TypeError(`${label}.protocol must be one of ${MODEL_BACKEND_PROTOCOLS.join(', ')}`);
|
|
101
111
|
}
|
|
@@ -114,10 +124,25 @@ function normalizeConnection(value, label) {
|
|
|
114
124
|
model: plainText(value.model, `${label}.model`, 200),
|
|
115
125
|
secretRef,
|
|
116
126
|
reasoningEffort,
|
|
127
|
+
...(value.headers == null ? {} : { headers: normalizeHeaders(value.headers, `${label}.headers`) }),
|
|
117
128
|
pricing: value.pricing == null ? null : normalizePricing(value.pricing, `${label}.pricing`)
|
|
118
129
|
};
|
|
119
130
|
}
|
|
120
131
|
|
|
132
|
+
// What a gateway asks of every request, such as a session header. Keys stay in
|
|
133
|
+
// the secret store, so a header that carries one, or that the request sets itself, is refused.
|
|
134
|
+
function normalizeHeaders(value, label) {
|
|
135
|
+
assertJsonObject(value, label);
|
|
136
|
+
const entries = Object.entries(value);
|
|
137
|
+
if (entries.length > MAX_HEADERS) throw new TypeError(`${label} may hold at most ${MAX_HEADERS} headers`);
|
|
138
|
+
for (const [name, text] of entries) {
|
|
139
|
+
if (!HEADER_NAME.test(name)) throw new TypeError(`${label} has an invalid name: ${name}`);
|
|
140
|
+
if (RESERVED_HEADERS.has(name.toLowerCase())) throw new TypeError(`${label}.${name} is set by FULI; a key goes in secretRef`);
|
|
141
|
+
if (typeof text !== 'string' || text.length > MAX_HEADER_VALUE || /[\r\n]/.test(text)) throw new TypeError(`${label}.${name} must be one short line`);
|
|
142
|
+
}
|
|
143
|
+
return Object.fromEntries(entries);
|
|
144
|
+
}
|
|
145
|
+
|
|
121
146
|
function endpointUrl(value, label) {
|
|
122
147
|
const text = requiredString(value, label, 2048);
|
|
123
148
|
let url;
|
|
@@ -128,9 +153,8 @@ function endpointUrl(value, label) {
|
|
|
128
153
|
}
|
|
129
154
|
if (url.username || url.password) throw new TypeError(`${label} must not contain credentials; use secretRef`);
|
|
130
155
|
if (url.search || url.hash) throw new TypeError(`${label} must not contain a query or fragment`);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
156
|
+
// Plain HTTP on a LAN is the person's call: a model server at home often has no certificate.
|
|
157
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') throw new TypeError(`${label} must use HTTP or HTTPS`);
|
|
134
158
|
return url.href.replace(/\/+$/, '');
|
|
135
159
|
}
|
|
136
160
|
|
|
@@ -149,13 +173,20 @@ function normalizePricing(value, label) {
|
|
|
149
173
|
};
|
|
150
174
|
}
|
|
151
175
|
|
|
152
|
-
function normalizeRole(value, label, connections) {
|
|
176
|
+
function normalizeRole(value, label, connections, role) {
|
|
153
177
|
object(value, label, ['enabled', 'connection', 'allowedOperations', 'egress', 'budget', 'fallbackToSession']);
|
|
154
178
|
if (typeof value.enabled !== 'boolean') throw new TypeError(`${label}.enabled must be a boolean`);
|
|
155
179
|
const connection = requiredString(value.connection, `${label}.connection`, 64);
|
|
156
180
|
if (!Object.hasOwn(connections, connection)) {
|
|
157
181
|
throw new TypeError(`${label}.connection names a missing connection: ${connection}`);
|
|
158
182
|
}
|
|
183
|
+
const embeds = connections[connection].protocol === EMBEDDING_PROTOCOL;
|
|
184
|
+
if (role === SEMANTIC_ROLE && !embeds) {
|
|
185
|
+
throw new TypeError(`${label}.connection must use ${EMBEDDING_PROTOCOL}: semantic search turns text into vectors and cannot use a chat model`);
|
|
186
|
+
}
|
|
187
|
+
if (role !== SEMANTIC_ROLE && embeds) {
|
|
188
|
+
throw new TypeError(`${label}.connection uses ${EMBEDDING_PROTOCOL}, which only semantic search takes; a built-in Agent needs a chat model`);
|
|
189
|
+
}
|
|
159
190
|
const allowedOperations = uniqueTextArray(value.allowedOperations, `${label}.allowedOperations`, MAX_OPERATIONS);
|
|
160
191
|
if (allowedOperations.some(operation => !OPERATION_PATTERN.test(operation))) {
|
|
161
192
|
throw new TypeError(`${label}.allowedOperations must contain lowercase operation names such as staffing_review`);
|
|
@@ -165,6 +196,7 @@ function normalizeRole(value, label, connections) {
|
|
|
165
196
|
if (value.enabled && !budget) throw new TypeError(`${label}.budget is required for an enabled role`);
|
|
166
197
|
const fallbackToSession = value.fallbackToSession ?? false;
|
|
167
198
|
if (typeof fallbackToSession !== 'boolean') throw new TypeError(`${label}.fallbackToSession must be a boolean`);
|
|
199
|
+
if (fallbackToSession && role === SEMANTIC_ROLE) throw new TypeError(`${label}.fallbackToSession must be false: a session cannot turn text into vectors`);
|
|
168
200
|
return {
|
|
169
201
|
enabled: value.enabled, connection, allowedOperations,
|
|
170
202
|
egress: normalizeEgress(value.egress, `${label}.egress`), budget, fallbackToSession
|
|
@@ -196,15 +228,17 @@ function normalizeEgress(value, label) {
|
|
|
196
228
|
}
|
|
197
229
|
|
|
198
230
|
function normalizeBudget(value, label, connection) {
|
|
199
|
-
object(value, label, [...Object.keys(BUDGET_LIMITS), 'maxCostPerWindow']);
|
|
231
|
+
object(value ?? {}, label, [...Object.keys(BUDGET_LIMITS), 'maxCostPerWindow']);
|
|
232
|
+
const given = value ?? {};
|
|
233
|
+
// No limit unless the person set one: an empty field is null.
|
|
200
234
|
const budget = Object.fromEntries(Object.entries(BUDGET_LIMITS).map(([key, maximum]) =>
|
|
201
|
-
[key, positiveInteger(
|
|
202
|
-
if (budget.timeoutMs < MIN_TIMEOUT_MS) throw new TypeError(`${label}.timeoutMs must be at least ${MIN_TIMEOUT_MS}`);
|
|
203
|
-
if (
|
|
235
|
+
[key, given[key] == null ? null : positiveInteger(given[key], `${label}.${key}`, maximum)]));
|
|
236
|
+
if (budget.timeoutMs !== null && budget.timeoutMs < MIN_TIMEOUT_MS) throw new TypeError(`${label}.timeoutMs must be at least ${MIN_TIMEOUT_MS}`);
|
|
237
|
+
if (given.maxCostPerWindow == null) return { ...budget, maxCostPerWindow: null };
|
|
204
238
|
if (!connection.pricing) {
|
|
205
239
|
throw new TypeError(`${label}.maxCostPerWindow needs unit prices on the connection; without them the cost is unknown (费用未知)`);
|
|
206
240
|
}
|
|
207
|
-
const maxCostPerWindow = price(
|
|
241
|
+
const maxCostPerWindow = price(given.maxCostPerWindow, `${label}.maxCostPerWindow`);
|
|
208
242
|
if (maxCostPerWindow === 0) throw new TypeError(`${label}.maxCostPerWindow must be greater than 0`);
|
|
209
243
|
return { ...budget, maxCostPerWindow };
|
|
210
244
|
}
|
|
@@ -43,7 +43,8 @@ export function decisionContract({ output, decisions, evidence }) {
|
|
|
43
43
|
return { ok: false, issues: ['the reply is not a single JSON object'] };
|
|
44
44
|
}
|
|
45
45
|
const checked = checkedValue(reply, value);
|
|
46
|
-
if (checked.ok
|
|
46
|
+
if (!checked.ok) return { ...checked, offSchema: true };
|
|
47
|
+
if (new Set(checked.value.evidenceIds).size !== checked.value.evidenceIds.length) {
|
|
47
48
|
return { ok: false, issues: ['evidenceIds: each ID may appear once'] };
|
|
48
49
|
}
|
|
49
50
|
return checked;
|
|
@@ -4,7 +4,8 @@ import { refuseRemoteDecision } from '../http/request-policy.js';
|
|
|
4
4
|
import { readJson, sendJson } from '../http/response.js';
|
|
5
5
|
import { confirmConsoleOwner } from '../knowledge-owner-reads/owner-proof.js';
|
|
6
6
|
import { positiveInteger } from '../validation/values.js';
|
|
7
|
-
import { MODEL_BACKEND_ROLES } from './config.js';
|
|
7
|
+
import { MODEL_BACKEND_ROLES, SEMANTIC_ROLE } from './config.js';
|
|
8
|
+
import { compactReceipt } from './receipt.js';
|
|
8
9
|
import { MAX_HISTORY_LIMIT } from './settings-history.js';
|
|
9
10
|
import { RETENTION } from './suggestion-log.js';
|
|
10
11
|
|
|
@@ -39,6 +40,7 @@ import { RETENTION } from './suggestion-log.js';
|
|
|
39
40
|
// trust change answers whether its change was recorded there.
|
|
40
41
|
const ROLE_ROUTE = /^\/api\/model-backends\/roles\/([a-z]+)$/;
|
|
41
42
|
const TRUST_ROUTE = /^\/api\/model-backends\/roles\/([a-z]+)\/trust$/;
|
|
43
|
+
const CHECK_ROUTE = /^\/api\/model-backends\/roles\/([a-z]+)\/check$/;
|
|
42
44
|
const SUGGESTIONS_ROUTE = '/api/model-backends/suggestions';
|
|
43
45
|
const HISTORY_ROUTE = '/api/model-backends/history';
|
|
44
46
|
const READ_ROUTES = ['/api/model-backends/usage', '/api/model-backends/roles', SUGGESTIONS_ROUTE, HISTORY_ROUTE];
|
|
@@ -48,11 +50,27 @@ const TRUST_EDIT = z.union([
|
|
|
48
50
|
z.object({ expectedRevision: revision, acknowledgeWarning: z.number().int().min(1) }).strict()
|
|
49
51
|
]);
|
|
50
52
|
|
|
53
|
+
// 测试连接 on the model page: one real request with the saved settings. The
|
|
54
|
+
// fixed check carries no project and nothing of the person's, as `fuli models check` does.
|
|
55
|
+
async function handleConnectionCheck({ request, response, modelBackends, role }) {
|
|
56
|
+
if (request.method !== 'POST') { sendJson(response, 405, { error: 'Method not allowed' }); return true; }
|
|
57
|
+
if (refuseRemoteDecision(request, response, 'A model is tested only on this computer')) return true;
|
|
58
|
+
if (!modelBackends) { sendJson(response, 503, { error: 'Model backends need a local FULI installation' }); return true; }
|
|
59
|
+
if (!MODEL_BACKEND_ROLES.includes(role)) throw new TypeError(`Unknown role: ${role}`);
|
|
60
|
+
const { modelReceipt, dimensions } = await modelBackends.checkConnection(role);
|
|
61
|
+
// The semantic role's check also says how long its vectors are; never the vector itself.
|
|
62
|
+
sendJson(response, 200, { ok: modelReceipt.status === 'completed', receipt: compactReceipt(modelReceipt),
|
|
63
|
+
...(role === SEMANTIC_ROLE ? { dimensions: dimensions ?? null } : {}) });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
51
67
|
export async function handleModelBackendApiRequest({
|
|
52
68
|
request, response, url, modelBackends, roleWork = null, readRoleSuggestions = null, roleSettings = null, operations = {},
|
|
53
69
|
automaticOperations = {}, modelTrust = null, settingsHistory = null, readEvaluation = null, ownerReads = null,
|
|
54
70
|
personalSpaceId = null
|
|
55
71
|
}) {
|
|
72
|
+
const checked = CHECK_ROUTE.exec(url.pathname)?.[1] ?? null;
|
|
73
|
+
if (checked) return handleConnectionCheck({ request, response, modelBackends, role: checked });
|
|
56
74
|
const roleEdit = ROLE_ROUTE.exec(url.pathname)?.[1] ?? null;
|
|
57
75
|
const trustEdit = TRUST_ROUTE.exec(url.pathname)?.[1] ?? null;
|
|
58
76
|
if (!roleEdit && !trustEdit && !READ_ROUTES.includes(url.pathname)) return false;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { request as httpRequest } from 'node:http';
|
|
2
|
+
import { request as httpsRequest } from 'node:https';
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
|
+
|
|
5
|
+
// fetch refuses the ports browsers block, such as 6665 to 6669, with "bad port".
|
|
6
|
+
// That rule protects web pages from other protocols; a model server the person
|
|
7
|
+
// set up on one of those ports is simply where their model lives. Such a call
|
|
8
|
+
// goes through node:http instead, unchanged: it follows no redirect, so the
|
|
9
|
+
// refusal in no-redirect-fetch.js still applies.
|
|
10
|
+
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
11
|
+
|
|
12
|
+
export async function modelFetch(url, init = {}) {
|
|
13
|
+
try {
|
|
14
|
+
return await globalThis.fetch(url, init);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (error?.cause?.message !== 'bad port') throw error;
|
|
17
|
+
return sendOverNodeHttp(url, init);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function sendOverNodeHttp(url, { method = 'GET', headers = {}, body, signal }) {
|
|
22
|
+
const send = new URL(url).protocol === 'https:' ? httpsRequest : httpRequest;
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
// No pooled socket: a server that closed one between calls would read as a network fault.
|
|
25
|
+
const outgoing = send(url, { method, headers, signal, agent: false }, (incoming) => {
|
|
26
|
+
const received = new Headers();
|
|
27
|
+
for (const [name, value] of Object.entries(incoming.headers)) {
|
|
28
|
+
for (const item of [value].flat()) received.append(name, item);
|
|
29
|
+
}
|
|
30
|
+
resolve(new Response(NULL_BODY_STATUSES.has(incoming.statusCode) ? null : Readable.toWeb(incoming),
|
|
31
|
+
{ status: incoming.statusCode, headers: received }));
|
|
32
|
+
});
|
|
33
|
+
// As fetch does: a cut request fails with why it was cut, which tells a timeout from a network fault.
|
|
34
|
+
outgoing.on('error', error => reject(signal?.aborted ? signal.reason : error));
|
|
35
|
+
outgoing.end(body);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { modelFetch } from './model-fetch.js';
|
|
3
4
|
|
|
4
5
|
import { MODEL_ADAPTERS } from './adapters/registry.js';
|
|
5
6
|
import { budgetBlock, callLimits, ceilingCost, estimateCost, estimateTokens, roundCost, windowStart } from './budget.js';
|
|
6
|
-
import { MODEL_BACKEND_ROLES, configRevision, connectionIdentity } from './config.js';
|
|
7
|
+
import { MODEL_BACKEND_ROLES, SEMANTIC_ROLE, configRevision, connectionIdentity } from './config.js';
|
|
7
8
|
import { decisionContract, decisionEnvelope } from './decision-contract.js';
|
|
8
9
|
import { egressAllowed } from './egress.js';
|
|
9
10
|
import { FAILURE_STATUS, isFallbackEligible, modelFailure } from './failures.js';
|
|
10
11
|
import { decisionPrompt, promptForMode, repairTurns } from './prompt.js';
|
|
11
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
CONNECTION_CHECK, connectionCheckRequest, embeddingCheckRequest, embeddingEgress, parseDecisionRequest, parseEmbeddingRequest,
|
|
14
|
+
parseUsageQuery
|
|
15
|
+
} from './request.js';
|
|
12
16
|
import { reportedUsage } from './usage.js';
|
|
13
17
|
|
|
14
|
-
// The shared model port of the four built-in Agents (rec#8, D-04)
|
|
18
|
+
// The shared model port of the four built-in Agents (rec#8, D-04), and of
|
|
19
|
+
// the person's semantic search model (rec#88), which only embeds. It owns
|
|
15
20
|
// configuration, egress, budget, bounded retry and repair, strict output
|
|
16
21
|
// validation and the usage ledger; protocol differences stay in adapters.
|
|
17
22
|
// It returns the compact decision envelope and a model receipt; it never
|
|
@@ -36,21 +41,46 @@ const USAGE_NOTES = 'One record per actual model API attempt; requests count dis
|
|
|
36
41
|
+ 'cachedInput, cacheWriteInput and reasoning are subsets of input or output as each provider defines them and are never added to totals. '
|
|
37
42
|
+ 'Costs are estimates from configured unit prices only; without prices the cost is unknown.';
|
|
38
43
|
|
|
39
|
-
export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl =
|
|
44
|
+
export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl = modelFetch, wait = delay,
|
|
40
45
|
now = () => new Date(), timeoutSignal = ms => AbortSignal.timeout(ms) }) {
|
|
41
46
|
// Endpoints that rejected json_schema output, for this process.
|
|
42
47
|
const promptOnly = new Set();
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// What every call needs before its first attempt: the role's enabled
|
|
50
|
+
// settings for this operation, its connection and adapter, the egress
|
|
51
|
+
// approval and the key, kept on the call. Answers { stop } with the result
|
|
52
|
+
// that ends the call, or { adapter, secret }.
|
|
53
|
+
async function prepare(request, call, { approved }) {
|
|
54
|
+
const loaded = readConfig();
|
|
55
|
+
if (loaded.state === 'absent') return { stop: call.notConfigured('no_config') };
|
|
56
|
+
if (loaded.state === 'invalid') return { stop: call.stop('configuration', 'invalid_config') };
|
|
57
|
+
call.roleConfig = loaded.config.roles[request.role] ?? null;
|
|
58
|
+
if (!call.roleConfig) return { stop: call.notConfigured('role_not_configured') };
|
|
59
|
+
if (!call.roleConfig.enabled) return { stop: call.notConfigured('role_disabled') };
|
|
60
|
+
if (request.operation !== CONNECTION_CHECK && !call.roleConfig.allowedOperations.includes(request.operation)) {
|
|
61
|
+
return { stop: call.notConfigured('operation_not_allowed') };
|
|
62
|
+
}
|
|
63
|
+
call.target = { id: call.roleConfig.connection, ...loaded.config.connections[call.roleConfig.connection] };
|
|
64
|
+
const adapter = MODEL_ADAPTERS[call.target.protocol];
|
|
65
|
+
if (!approved.supports(adapter)) return { stop: call.stop('configuration', 'unsupported_output') };
|
|
66
|
+
if (!approved.egress(call.roleConfig.egress)) return { stop: call.stop('refusal', 'egress_not_approved') };
|
|
67
|
+
if (!call.target.secretRef) return { adapter, secret: null };
|
|
68
|
+
let secret;
|
|
69
|
+
try {
|
|
70
|
+
secret = await secrets.read(call.target.secretRef);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return { stop: call.stop('configuration', error?.code === 'secret_store_insecure' ? 'secret_store_insecure' : 'secret_unreadable') };
|
|
73
|
+
}
|
|
74
|
+
return secret ? { adapter, secret } : { stop: call.stop('configuration', 'missing_key') };
|
|
75
|
+
}
|
|
51
76
|
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
// The receipt of one call and the results that end it. empty is the
|
|
78
|
+
// result without an answer, to which each ending adds its receipt.
|
|
79
|
+
function callRecord(empty) {
|
|
80
|
+
const call = { startedAt: now().getTime(), attempts: [], target: null, roleConfig: null, mode: null, reportedConfidence: null };
|
|
81
|
+
call.receipt = (status, { reason = null, failure = null } = {}) => {
|
|
82
|
+
const { target, attempts } = call;
|
|
83
|
+
const fallbackEligible = failure ? isFallbackEligible(failure, call.roleConfig) : false;
|
|
54
84
|
return {
|
|
55
85
|
backend: 'model_api', status, reason: failure?.reason ?? reason, failureClass: failure?.failureClass ?? null,
|
|
56
86
|
fallbackEligible, fallbackReason: fallbackEligible ? failure.reason : null,
|
|
@@ -58,44 +88,53 @@ export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl
|
|
|
58
88
|
// Which configured connection was asked (config.js connectionIdentity); a role's trust gate compares it.
|
|
59
89
|
connectionIdentity: target ? connectionIdentity(target.id, target) : null,
|
|
60
90
|
actualModel: attempts.findLast(attempt => attempt.actualModel)?.actualModel ?? null,
|
|
61
|
-
outputMode: attempts.length ? mode : null, attempts: attempts.length, usage: receiptUsage(attempts),
|
|
62
|
-
reportedConfidence, durationMs: now().getTime() - startedAt
|
|
91
|
+
outputMode: attempts.length ? call.mode : null, attempts: attempts.length, usage: receiptUsage(attempts),
|
|
92
|
+
reportedConfidence: call.reportedConfidence, durationMs: now().getTime() - call.startedAt
|
|
63
93
|
};
|
|
64
94
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
call.notConfigured = reason => ({ ...empty, modelReceipt: call.receipt('not_configured', { reason }) });
|
|
96
|
+
call.fail = failure => ({ ...empty, modelReceipt: call.receipt(FAILURE_STATUS[failure.failureClass], { failure }) });
|
|
97
|
+
call.stop = (failureClass, reason) => call.fail(modelFailure(failureClass, reason));
|
|
98
|
+
return call;
|
|
99
|
+
}
|
|
68
100
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
101
|
+
// An attempt as the ledger keeps it before it goes out: metadata only,
|
|
102
|
+
// never prompt text, texts or vectors. Reserves its ceiling in the role's
|
|
103
|
+
// window and answers the reason it may not start, or null.
|
|
104
|
+
function reserveAttempt(request, call, { purpose, inputTokens, maxOutputTokens, remainingMs }) {
|
|
105
|
+
const { target, roleConfig } = call;
|
|
106
|
+
const attemptStarted = now();
|
|
107
|
+
const pending = {
|
|
108
|
+
requestId: request.requestId, attemptId: randomUUID(), attemptNumber: call.attempts.length + 1, purpose, channel: 'model_api',
|
|
109
|
+
role: request.role, operation: request.operation, personalSpaceId: request.scope.personalSpaceId,
|
|
110
|
+
personalProjectId: request.scope.personalProjectId, connectionId: target.id, protocol: target.protocol,
|
|
111
|
+
endpointHost: new URL(target.endpoint).host, endpoint: target.endpoint, requestedModel: target.model, outputMode: call.mode,
|
|
112
|
+
startedAt: attemptStarted.toISOString(), budgetCeilingTokens: inputTokens + maxOutputTokens,
|
|
113
|
+
costCurrency: target.pricing?.currency ?? null
|
|
114
|
+
};
|
|
115
|
+
const blocked = ledger.reserve({ attempt: pending, ceilingCost: ceilingCost(target.pricing, inputTokens, maxOutputTokens),
|
|
116
|
+
expiresAt: new Date(attemptStarted.getTime() + remainingMs + RESERVATION_GRACE_MS).toISOString(),
|
|
117
|
+
since: windowStart(roleConfig.budget, attemptStarted), now: attemptStarted.toISOString(),
|
|
118
|
+
check: window => budgetBlock({ budget: roleConfig.budget, pricing: target.pricing, window,
|
|
119
|
+
estimatedInputTokens: inputTokens, maxOutputTokens }) });
|
|
120
|
+
return { pending, attemptStarted, blocked };
|
|
121
|
+
}
|
|
82
122
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
123
|
+
async function run(request) {
|
|
124
|
+
const call = callRecord({ envelope: null });
|
|
125
|
+
const { stop, fail } = call;
|
|
126
|
+
const prepared = await prepare(request, call, { approved: {
|
|
127
|
+
supports: adapter => adapter.supports(request), egress: egress => egressAllowed(request, egress) } });
|
|
128
|
+
if (prepared.stop) return prepared.stop;
|
|
129
|
+
const { adapter, secret } = prepared;
|
|
130
|
+
const { target, roleConfig, attempts, startedAt } = call;
|
|
92
131
|
|
|
93
132
|
const contract = decisionContract(request);
|
|
94
133
|
const prompt = decisionPrompt(request, contract.providerSchema);
|
|
95
134
|
const limits = callLimits(roleConfig.budget, request.budget);
|
|
96
135
|
const deadline = startedAt + limits.timeoutMs;
|
|
97
136
|
const formatKey = `${target.protocol} ${target.endpoint} ${target.model}`;
|
|
98
|
-
mode = adapter.outputMode === 'json_schema' && promptOnly.has(formatKey) ? 'prompt' : adapter.outputMode;
|
|
137
|
+
call.mode = adapter.outputMode === 'json_schema' && promptOnly.has(formatKey) ? 'prompt' : adapter.outputMode;
|
|
99
138
|
let turns = prompt.turns;
|
|
100
139
|
let purpose = 'initial';
|
|
101
140
|
let retries = 0;
|
|
@@ -106,30 +145,18 @@ export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl
|
|
|
106
145
|
if (remainingMs < MIN_ATTEMPT_MS) return stop('transient', 'timeout');
|
|
107
146
|
// Each attempt is checked as it will go out: a repair adds turns and
|
|
108
147
|
// prompt mode writes the schema into the prompt.
|
|
109
|
-
const outgoing = promptForMode({ ...prompt, turns }, mode);
|
|
148
|
+
const outgoing = promptForMode({ ...prompt, turns }, call.mode);
|
|
110
149
|
const inputTokens = estimateTokens(outgoing);
|
|
111
150
|
if (inputTokens > limits.maxInputTokens) return stop('budget_exhausted', 'per_call_input');
|
|
112
151
|
|
|
113
|
-
const attemptStarted =
|
|
114
|
-
|
|
115
|
-
requestId: request.requestId, attemptId: randomUUID(), attemptNumber: attempts.length + 1, purpose, channel: 'model_api',
|
|
116
|
-
role: request.role, operation: request.operation, personalSpaceId: request.scope.personalSpaceId,
|
|
117
|
-
personalProjectId: request.scope.personalProjectId, connectionId: target.id, protocol: target.protocol,
|
|
118
|
-
endpointHost: new URL(target.endpoint).host, endpoint: target.endpoint, requestedModel: target.model, outputMode: mode,
|
|
119
|
-
startedAt: attemptStarted.toISOString(), budgetCeilingTokens: inputTokens + limits.maxOutputTokens,
|
|
120
|
-
costCurrency: target.pricing?.currency ?? null
|
|
121
|
-
};
|
|
122
|
-
const blocked = ledger.reserve({ attempt: pending, ceilingCost: ceilingCost(target.pricing, inputTokens, limits.maxOutputTokens),
|
|
123
|
-
expiresAt: new Date(attemptStarted.getTime() + remainingMs + RESERVATION_GRACE_MS).toISOString(),
|
|
124
|
-
since: windowStart(roleConfig.budget, attemptStarted), now: attemptStarted.toISOString(),
|
|
125
|
-
check: window => budgetBlock({ budget: roleConfig.budget, pricing: target.pricing, window,
|
|
126
|
-
estimatedInputTokens: inputTokens, maxOutputTokens: limits.maxOutputTokens }) });
|
|
152
|
+
const { pending, attemptStarted, blocked } = reserveAttempt(request, call,
|
|
153
|
+
{ purpose, inputTokens, maxOutputTokens: limits.maxOutputTokens, remainingMs });
|
|
127
154
|
if (blocked) return stop('budget_exhausted', blocked);
|
|
128
155
|
|
|
129
156
|
let result;
|
|
130
157
|
const attemptSignal = timeoutSignal(remainingMs);
|
|
131
158
|
try {
|
|
132
|
-
result = await adapter.call({ connection: target, secret, request, mode, signal: attemptSignal,
|
|
159
|
+
result = await adapter.call({ connection: target, secret, request, mode: call.mode, signal: attemptSignal,
|
|
133
160
|
prompt: outgoing, maxOutputTokens: limits.maxOutputTokens, fetchImpl });
|
|
134
161
|
} catch (error) {
|
|
135
162
|
ledger.settleUnknown(pending, { durationMs: now().getTime() - attemptStarted.getTime(), failureReason: 'attempt_error' });
|
|
@@ -151,26 +178,88 @@ export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl
|
|
|
151
178
|
attempts.push(attempt);
|
|
152
179
|
|
|
153
180
|
if (verdict.ok) {
|
|
154
|
-
reportedConfidence = result.reportedConfidence ?? null;
|
|
155
|
-
return { envelope: decisionEnvelope(request, verdict.value), modelReceipt: receipt('completed') };
|
|
181
|
+
call.reportedConfidence = result.reportedConfidence ?? null;
|
|
182
|
+
return { envelope: decisionEnvelope(request, verdict.value), modelReceipt: call.receipt('completed') };
|
|
156
183
|
}
|
|
157
184
|
if (verdict.issues) {
|
|
185
|
+
// JSON outside the schema means the endpoint took the schema and ignored
|
|
186
|
+
// it, as some gateways do: later calls get it in the prompt.
|
|
187
|
+
if (verdict.offSchema && call.mode === 'json_schema') promptOnly.add(formatKey);
|
|
158
188
|
if (!adapter.repairable || repairs >= REPAIR_LIMIT) return stop('configuration', 'invalid_output');
|
|
159
189
|
repairs += 1;
|
|
160
190
|
purpose = 'repair';
|
|
161
|
-
turns = repairTurns(turns, result.reply ?? '', verdict.issues);
|
|
191
|
+
turns = repairTurns(turns, result.reply ?? '', verdict.issues, prompt.schema);
|
|
162
192
|
continue;
|
|
163
193
|
}
|
|
164
194
|
const { failure } = verdict;
|
|
165
|
-
if (failure.reason === 'unsupported_response_format' && mode === 'json_schema') {
|
|
195
|
+
if (failure.reason === 'unsupported_response_format' && call.mode === 'json_schema') {
|
|
166
196
|
promptOnly.add(formatKey);
|
|
167
|
-
mode = 'prompt';
|
|
197
|
+
call.mode = 'prompt';
|
|
168
198
|
purpose = 'format_fallback';
|
|
169
199
|
continue;
|
|
170
200
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
201
|
+
const pauseMs = retryPause(failure, retries, deadline);
|
|
202
|
+
if (pauseMs === null) return fail(failure);
|
|
203
|
+
retries += 1;
|
|
204
|
+
purpose = 'retry';
|
|
205
|
+
await wait(pauseMs);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// How long to wait before retrying a failed attempt, or null when it is
|
|
210
|
+
// not retried: not transient, out of retries, or past the deadline.
|
|
211
|
+
function retryPause(failure, retries, deadline) {
|
|
212
|
+
if (failure.failureClass !== 'transient' || retries >= TRANSIENT_RETRY_LIMIT) return null;
|
|
213
|
+
const pauseMs = failure.retryAfterMs ?? BASE_BACKOFF_MS * 2 ** retries;
|
|
214
|
+
return now().getTime() + pauseMs + MIN_ATTEMPT_MS > deadline ? null : pauseMs;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// The semantic role's call (rec#88): its texts as vectors, whole or not at
|
|
218
|
+
// all. The same settings, egress, budget, retry and ledger as a decision;
|
|
219
|
+
// no repair, and no fallback, because a session cannot embed. Texts and
|
|
220
|
+
// vectors never reach the ledger or a log.
|
|
221
|
+
async function embedTexts(request) {
|
|
222
|
+
const call = callRecord({ vectors: null, dimensions: null, model: null });
|
|
223
|
+
const { stop, fail } = call;
|
|
224
|
+
const prepared = await prepare(request, call, { approved: {
|
|
225
|
+
supports: adapter => typeof adapter.embed === 'function', egress: egress => egressAllowed(embeddingEgress(request), egress) } });
|
|
226
|
+
if (prepared.stop) return prepared.stop;
|
|
227
|
+
const { adapter, secret } = prepared;
|
|
228
|
+
const { target, roleConfig, attempts, startedAt } = call;
|
|
229
|
+
call.mode = adapter.outputMode;
|
|
230
|
+
const limits = callLimits(roleConfig.budget, request.budget);
|
|
231
|
+
const deadline = startedAt + limits.timeoutMs;
|
|
232
|
+
const inputTokens = estimateTokens(request.texts);
|
|
233
|
+
if (inputTokens > limits.maxInputTokens) return stop('budget_exhausted', 'per_call_input');
|
|
234
|
+
let purpose = 'initial';
|
|
235
|
+
let retries = 0;
|
|
236
|
+
|
|
237
|
+
for (;;) {
|
|
238
|
+
const remainingMs = deadline - now().getTime();
|
|
239
|
+
if (remainingMs < MIN_ATTEMPT_MS) return stop('transient', 'timeout');
|
|
240
|
+
const { pending, attemptStarted, blocked } = reserveAttempt(request, call, { purpose, inputTokens, maxOutputTokens: 0, remainingMs });
|
|
241
|
+
if (blocked) return stop('budget_exhausted', blocked);
|
|
242
|
+
let result;
|
|
243
|
+
try {
|
|
244
|
+
result = await adapter.embed({ connection: target, secret, texts: request.texts, signal: timeoutSignal(remainingMs), fetchImpl });
|
|
245
|
+
} catch (error) {
|
|
246
|
+
ledger.settleUnknown(pending, { durationMs: now().getTime() - attemptStarted.getTime(), failureReason: 'attempt_error' });
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
249
|
+
const failure = result.ok ? null : result.failure;
|
|
250
|
+
const attempt = {
|
|
251
|
+
...pending, actualModel: result.actualModel, durationMs: now().getTime() - attemptStarted.getTime(),
|
|
252
|
+
outcome: failure ? 'failed' : 'succeeded', failureClass: failure?.failureClass ?? null, failureReason: failure?.reason ?? null,
|
|
253
|
+
usage: result.usage, estimatedCost: estimateCost(result.usage, target.pricing)
|
|
254
|
+
};
|
|
255
|
+
ledger.settle(attempt);
|
|
256
|
+
attempts.push(attempt);
|
|
257
|
+
if (!failure) {
|
|
258
|
+
return { vectors: result.vectors, dimensions: result.dimensions, model: result.actualModel ?? target.model,
|
|
259
|
+
modelReceipt: call.receipt('completed') };
|
|
260
|
+
}
|
|
261
|
+
const pauseMs = retryPause(failure, retries, deadline);
|
|
262
|
+
if (pauseMs === null) return fail(failure);
|
|
174
263
|
retries += 1;
|
|
175
264
|
purpose = 'retry';
|
|
176
265
|
await wait(pauseMs);
|
|
@@ -191,11 +280,20 @@ export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl
|
|
|
191
280
|
return run(parseDecisionRequest(input));
|
|
192
281
|
}
|
|
193
282
|
|
|
283
|
+
// { role: 'semantic', operation: 'knowledge_embedding', requestId, scope,
|
|
284
|
+
// texts } with at most MAX_EMBEDDING_TEXTS texts, answering { vectors,
|
|
285
|
+
// dimensions, model, modelReceipt }; vectors is null unless it completed.
|
|
286
|
+
async function embed(input) {
|
|
287
|
+
return embedTexts(parseEmbeddingRequest(input));
|
|
288
|
+
}
|
|
289
|
+
|
|
194
290
|
return {
|
|
195
291
|
decide,
|
|
292
|
+
embed,
|
|
196
293
|
// A user-run check with fixed synthetic text: it carries no project or
|
|
197
294
|
// user content, so any enabled role may run it within its own budget.
|
|
198
|
-
|
|
295
|
+
// The semantic role embeds its one short text instead of deciding.
|
|
296
|
+
checkConnection: role => (role === SEMANTIC_ROLE ? embedTexts(embeddingCheckRequest()) : decide(connectionCheckRequest(role))),
|
|
199
297
|
usage(input) {
|
|
200
298
|
const query = parseUsageQuery(input);
|
|
201
299
|
const loaded = readConfig();
|
|
@@ -235,7 +333,7 @@ export function createModelBackendPort({ readConfig, secrets, ledger, fetchImpl
|
|
|
235
333
|
// disabled or no longer allowed the operation allows nothing.
|
|
236
334
|
allowsEgress(request) {
|
|
237
335
|
const settings = this.operationSettings(request.role, request.operation);
|
|
238
|
-
return Boolean(settings) && egressAllowed(request, settings.egress);
|
|
336
|
+
return Boolean(settings) && egressAllowed(request.texts ? embeddingEgress(request) : request, settings.egress);
|
|
239
337
|
},
|
|
240
338
|
// What Settings shows of the local build behind a role's latest answer
|
|
241
339
|
// on its configured endpoint and model (rec#10 D-32). An observation of
|