fuli-context 0.20.1 → 0.21.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/dist/web/assets/{AboutPage-CjDenGS_.js → AboutPage-D0dTwKq8.js} +1 -1
  2. package/dist/web/assets/{AgentName-DdlJlpT3.js → AgentName-n4oqQUwE.js} +1 -1
  3. package/dist/web/assets/{AgentProfilePage-Cx_Uf5Vf.js → AgentProfilePage-DH54S93r.js} +1 -1
  4. package/dist/web/assets/{AgentsDirectoryPage-DylT-GSW.js → AgentsDirectoryPage-xwIRrNb8.js} +1 -1
  5. package/dist/web/assets/{BackLink-D7oAvDG5.js → BackLink-nM3e40IT.js} +1 -1
  6. package/dist/web/assets/{BoardMoveMenu-B0pA7LLx.js → BoardMoveMenu-Cxgkbwkl.js} +1 -1
  7. package/dist/web/assets/{CaptureChangePage-DEuqPb14.js → CaptureChangePage-DWdz9dEk.js} +1 -1
  8. package/dist/web/assets/{Card-BZFLZ_2I.js → Card-89NKHANE.js} +1 -1
  9. package/dist/web/assets/{CardHeader-C_c0keQn.js → CardHeader-9MwjWRxl.js} +1 -1
  10. package/dist/web/assets/{CardTitle-yXOhV577.js → CardTitle-BAhmXjAK.js} +1 -1
  11. package/dist/web/assets/{ConnectionsPage-DlnHdtwn.js → ConnectionsPage-Yf4UvjDT.js} +1 -1
  12. package/dist/web/assets/{CreateProjectDialog-BVJqWdlT.js → CreateProjectDialog-crpLTyDf.js} +1 -1
  13. package/dist/web/assets/{DataFormatPage-BdcjcyhZ.js → DataFormatPage-BPuUH0PG.js} +1 -1
  14. package/dist/web/assets/{DialogFooter-DYawfDCD.js → DialogFooter-D9A9hRP4.js} +1 -1
  15. package/dist/web/assets/{EmployeeRecruitDialog-CB4ARFkM.js → EmployeeRecruitDialog-DeB0XHeM.js} +1 -1
  16. package/dist/web/assets/EmployeeWorkbenchPage-0oK2RfIh.js +3 -0
  17. package/dist/web/assets/{EmployeeWorkbenchPage-BenZP7De.css → EmployeeWorkbenchPage-CMutwFBC.css} +1 -1
  18. package/dist/web/assets/{GrowthLoading-smW3-Gfp.js → GrowthLoading-Cs9brXcN.js} +1 -1
  19. package/dist/web/assets/{InboxPage-Crn1UU7s.js → InboxPage-CTQ425Ez.js} +1 -1
  20. package/dist/web/assets/{Input-F1oftPWh.js → Input-DGf4juEs.js} +1 -1
  21. package/dist/web/assets/{KnowledgeEditDialog-VdQwbX4E.js → KnowledgeEditDialog-Ccgj30Wu.js} +1 -1
  22. package/dist/web/assets/{KnowledgeHardDeleteSection-CXRmNnZF.js → KnowledgeHardDeleteSection-CSnqisUv.js} +1 -1
  23. package/dist/web/assets/{KnowledgeItemEditPage-CQo3TbCJ.js → KnowledgeItemEditPage-C0Y2DsHz.js} +1 -1
  24. package/dist/web/assets/{KnowledgeItemSummaryCard-Dd2McM-d.js → KnowledgeItemSummaryCard-BRvaf4Fw.js} +1 -1
  25. package/dist/web/assets/{KnowledgeOrganizerPage-BVgAyu6U.js → KnowledgeOrganizerPage-CRC3mk0j.js} +1 -1
  26. package/dist/web/assets/KnowledgePage-NsKFUWth.js +1 -0
  27. package/dist/web/assets/{KnowledgePeek-BNBkh1ey.js → KnowledgePeek-Bc0bqyZp.js} +1 -1
  28. package/dist/web/assets/{KnowledgeTurnReceiptPage-Ckw_olrt.js → KnowledgeTurnReceiptPage-Dl0KeFDe.js} +1 -1
  29. package/dist/web/assets/{KnowledgeWorkspace-pH2tAFld.js → KnowledgeWorkspace-BGlODG7G.js} +1 -1
  30. package/dist/web/assets/{Label-yDCtlpkb.js → Label-CafdTnDF.js} +1 -1
  31. package/dist/web/assets/ModelSettingsPage-Bz1tMXtW.js +1 -0
  32. package/dist/web/assets/ModelSettingsPage-DJuEaw6p.css +1 -0
  33. package/dist/web/assets/{NotFoundPage-8gVVukRR.js → NotFoundPage-TfZ2eoA2.js} +1 -1
  34. package/dist/web/assets/{OccupationsPage-PNoqE21Y.js → OccupationsPage-CnSp6362.js} +1 -1
  35. package/dist/web/assets/{OverviewPage-DiwYSnhh.js → OverviewPage-D5W-DhOz.js} +2 -2
  36. package/dist/web/assets/{PersonalProfilePage-C_v2BFee.js → PersonalProfilePage-CndOcRQ6.js} +1 -1
  37. package/dist/web/assets/{PersonalProjectsPage-DGRV8cM5.js → PersonalProjectsPage-CXBOwEqC.js} +1 -1
  38. package/dist/web/assets/{PopperContent-5zqbtnYr.js → PopperContent-BXbztFFi.js} +1 -1
  39. package/dist/web/assets/{Presence-BYfYJNMD.js → Presence-BLar6FCs.js} +1 -1
  40. package/dist/web/assets/{ProjectAgentDetailPage-BQ9ffaCX.js → ProjectAgentDetailPage-SmZ2NYTw.js} +1 -1
  41. package/dist/web/assets/{ProjectAgentDialog-BGckQDTq.js → ProjectAgentDialog-Bg0V3Zr2.js} +1 -1
  42. package/dist/web/assets/{ProjectAgentFirstTask-DrSd3nR-.js → ProjectAgentFirstTask-CbOWaP7Q.js} +1 -1
  43. package/dist/web/assets/{ProjectAgentsPage-U4Om3EPu.js → ProjectAgentsPage-Y6qCYRZj.js} +1 -1
  44. package/dist/web/assets/{ProjectScopePicker-D0oxbwOd.js → ProjectScopePicker-ClDUoUHW.js} +1 -1
  45. package/dist/web/assets/{PublicProjectsPage-CvkQ3E8I.js → PublicProjectsPage-C63vW9UZ.js} +1 -1
  46. package/dist/web/assets/{RadioGroupItem-CBpbQlHx.js → RadioGroupItem-tL_2upmD.js} +1 -1
  47. package/dist/web/assets/{RoundtablesPage-BEUaKOjI.js → RoundtablesPage-2Akxagrm.js} +1 -1
  48. package/dist/web/assets/{RovingFocusGroup-X9U-ufYr.js → RovingFocusGroup-D5mf9s6I.js} +1 -1
  49. package/dist/web/assets/{RovingFocusItem-_uA_OCLT.js → RovingFocusItem-DAumq9xD.js} +1 -1
  50. package/dist/web/assets/{SessionMigrationPage-WVFSDcUO.js → SessionMigrationPage-B5r2PWCF.js} +1 -1
  51. package/dist/web/assets/{SessionRecordsPage-Bs2eLXEi.js → SessionRecordsPage-DIc2GoCQ.js} +1 -1
  52. package/dist/web/assets/{SettingsPage-DlIwICIz.js → SettingsPage-BAxKpnBx.js} +1 -1
  53. package/dist/web/assets/{SharedJefaReportPage-B_rreEep.js → SharedJefaReportPage-B54qEdIV.js} +1 -1
  54. package/dist/web/assets/{TabsContent-8pXwYJPz.js → TabsContent-DZQE2Iq8.js} +1 -1
  55. package/dist/web/assets/{TabsTrigger-Cd6SI2yI.js → TabsTrigger-CHnq6mkI.js} +1 -1
  56. package/dist/web/assets/{TagVocabularyPage-BQiuKG-4.js → TagVocabularyPage-BIsHYk2i.js} +1 -1
  57. package/dist/web/assets/{TaskExecutionPlan-CupxJeyo.js → TaskExecutionPlan-IYG_JeuT.js} +1 -1
  58. package/dist/web/assets/{TaskSchedulesPage-zYQs7s6T.js → TaskSchedulesPage-Cxjqc8XQ.js} +1 -1
  59. package/dist/web/assets/{Teleport-BZX1Eb7R.js → Teleport-BKN3dSMk.js} +1 -1
  60. package/dist/web/assets/{TextField-CielK4l3.js → TextField-DoKtn--E.js} +1 -1
  61. package/dist/web/assets/{UiDialog-BSDblUpR.js → UiDialog-7pnZ-eQA.js} +1 -1
  62. package/dist/web/assets/{UiDisclosure-DLmVwmy1.js → UiDisclosure-COV4NwHI.js} +1 -1
  63. package/dist/web/assets/{UiIcon-B8eZeuGI.js → UiIcon-BADOYtHM.js} +1 -1
  64. package/dist/web/assets/{UiIconButton-e754Tmnq.js → UiIconButton-CkBP6pnX.js} +1 -1
  65. package/dist/web/assets/{UiSegmented-D1HD-qin.js → UiSegmented-FwOnE2IZ.js} +1 -1
  66. package/dist/web/assets/{UiSelect-CbkTsi2e.js → UiSelect-BIhr03Gk.js} +1 -1
  67. package/dist/web/assets/{UiToggle-Dz93aXFK.js → UiToggle-bpyawyIe.js} +1 -1
  68. package/dist/web/assets/{UiWeight-CUvyApSB.js → UiWeight-TyBehy3K.js} +1 -1
  69. package/dist/web/assets/{UnassignedConversationsPanel-xY7gsFot.js → UnassignedConversationsPanel-B4PqImRi.js} +1 -1
  70. package/dist/web/assets/{VirtualDirectoryList-Dv6PwLjU.js → VirtualDirectoryList-DNQP6X8j.js} +1 -1
  71. package/dist/web/assets/{Workbench3D--4N_uKzp.js → Workbench3D-DNwgymIE.js} +1 -1
  72. package/dist/web/assets/{WritingTastePage-B7KojA4r.js → WritingTastePage-D-ELo7mh.js} +1 -1
  73. package/dist/web/assets/{_plugin-vue_export-helper-BmfQlfI8.js → _plugin-vue_export-helper-RegzAV-H.js} +1 -1
  74. package/dist/web/assets/{accordion-gXElbGP_.js → accordion-DpqAdXTB.js} +1 -1
  75. package/dist/web/assets/{agent-occupation-ChN-1QjC.js → agent-occupation-Ba5Fl0ys.js} +1 -1
  76. package/dist/web/assets/{agent-pins-Chh_rdBi.js → agent-pins-Bb7-1Uoz.js} +1 -1
  77. package/dist/web/assets/{agent-profile.css_vue_type_style_index_0_src_true_lang-DWlz7UoN.js → agent-profile.css_vue_type_style_index_0_src_true_lang-wT8gjVyZ.js} +1 -1
  78. package/dist/web/assets/{agent-work-summary-C9yMf019.js → agent-work-summary-D0a836ik.js} +1 -1
  79. package/dist/web/assets/{attention-store-CG9cF6DX.js → attention-store-g2-_vAhV.js} +1 -1
  80. package/dist/web/assets/{badge-DvvDq2Wb.js → badge-BIoC0hjn.js} +1 -1
  81. package/dist/web/assets/{button-CFEnxtio.js → button-A2esxd6G.js} +1 -1
  82. package/dist/web/assets/{checkbox-DovdRz8u.js → checkbox-DxBVlC6t.js} +1 -1
  83. package/dist/web/assets/{client-lh80ewvs.js → client-DAoXcTUz.js} +1 -1
  84. package/dist/web/assets/{console-CQMgYkk9.js → console-DiNe1hFP.js} +1 -1
  85. package/dist/web/assets/{conversation-launcher-settings-B1QM-wZB.js → conversation-launcher-settings-CtOlr9uP.js} +1 -1
  86. package/dist/web/assets/{design-lab-BDKwIbI8.js → design-lab-UWXx2ZtA.js} +1 -1
  87. package/dist/web/assets/{dialog-D2mO6m3B.js → dialog-DTVE8tN1.js} +1 -1
  88. package/dist/web/assets/{dist-PmK0PfVA.js → dist-D-8b3yGa.js} +1 -1
  89. package/dist/web/assets/{dropdown-menu-YzCnvjAb.js → dropdown-menu-NcUrhhmG.js} +1 -1
  90. package/dist/web/assets/{field-BMEFEyVC.js → field-6mg5DSC8.js} +1 -1
  91. package/dist/web/assets/{identity-bK-fJdnj.js → identity-FG3YqHVj.js} +1 -1
  92. package/dist/web/assets/index-BpQe3IT5.js +2 -0
  93. package/dist/web/assets/{judgment-types-DJnAr9c0.js → judgment-types-rLsl2Cis.js} +1 -1
  94. package/dist/web/assets/{model-Cengn9fg.js → model-BCnsjEuP.js} +1 -1
  95. package/dist/web/assets/{model-rumuELTi.js → model-BcMr6R8m.js} +1 -1
  96. package/dist/web/assets/{model-DpVrfbnj.js → model-CYJ_LZ47.js} +1 -1
  97. package/dist/web/assets/{model-BwNZZZNP.js → model-CeF2BATq.js} +1 -1
  98. package/dist/web/assets/{model-CuY1vtEy.js → model-CtmCtjml.js} +1 -1
  99. package/dist/web/assets/{model-CPMYnu3S.js → model-t2ZvD7wL.js} +1 -1
  100. package/dist/web/assets/{motion-preference-A1AMssSH.js → motion-preference-DeZURhN7.js} +1 -1
  101. package/dist/web/assets/{occupation-catalog-DxwlYD1L.js → occupation-catalog-q0ZjGx2o.js} +1 -1
  102. package/dist/web/assets/{orchestration-filters-DZpJ0FN3.js → orchestration-filters-CKf_Gzdl.js} +1 -1
  103. package/dist/web/assets/{page-title-Bg-mVyrS.js → page-title-BLHrexaP.js} +1 -1
  104. package/dist/web/assets/{personal-profile-graph-tMneNj_m.js → personal-profile-graph-IYovB9sV.js} +1 -1
  105. package/dist/web/assets/{project-capture-QgMw6qvo.js → project-capture-BvIPecIS.js} +1 -1
  106. package/dist/web/assets/{project-origin-ppsYHpYL.js → project-origin-JnGPwlfA.js} +1 -1
  107. package/dist/web/assets/project-team-api-Cfn41MCR.js +1 -0
  108. package/dist/web/assets/{quick-edit-api-BiyK3ih-.js → quick-edit-api-DzpRAPsr.js} +1 -1
  109. package/dist/web/assets/{shared-report-D3Hem1t5.js → shared-report-BLmBg2FG.js} +3 -3
  110. package/dist/web/assets/{task-labels-7KyNw9id.js → task-labels-BArOYZEW.js} +1 -1
  111. package/dist/web/assets/{ui-Ck58paqr.js → ui-CtW0tAA1.js} +1 -1
  112. package/dist/web/assets/{useAgentRecords-C6RrZwwv.js → useAgentRecords-BoOqLQcf.js} +1 -1
  113. package/dist/web/assets/{useApi-CROJJdhE-BujjnKN_.js → useApi-CROJJdhE-CH5wlWTU.js} +1 -1
  114. package/dist/web/assets/{useFocusReturn-D9IOIg17.js → useFocusReturn-DX2zmPSK.js} +1 -1
  115. package/dist/web/assets/{useKnowledgeItemPeek-C6nAzvDL.js → useKnowledgeItemPeek-Cfvr5H1q.js} +1 -1
  116. package/dist/web/assets/{useMinimumLoadingDisplay-HnxkDut6.js → useMinimumLoadingDisplay-GhG1ICNJ.js} +1 -1
  117. package/dist/web/assets/{useRoutePeek-BvYFc1BA.js → useRoutePeek-DydCbUhy.js} +1 -1
  118. package/dist/web/assets/{vue-router-Bl55c88B.js → vue-router-Dad-4p7O.js} +1 -1
  119. package/dist/web/index.html +32 -32
  120. package/docs/agent-conversations-and-collaboration.md +10 -0
  121. package/docs/employee-agents.md +3 -1
  122. package/docs/judgment-and-autonomy.md +30 -1
  123. package/graph-provider/fuli_graph/agent_conversation_models.py +7 -0
  124. package/graph-provider/fuli_graph/agent_conversation_routes.py +5 -1
  125. package/graph-provider/fuli_graph/default_project_lead.py +7 -3
  126. package/graph-provider/fuli_graph/store_agent_conversations.py +66 -34
  127. package/graph-provider/pyproject.toml +1 -1
  128. package/native/win32/fuli-win-helper.exe +0 -0
  129. package/npm-shrinkwrap.json +2 -2
  130. package/package.json +1 -1
  131. package/packages/roundtable/src/host.js +5 -0
  132. package/packages/roundtable/src/peer/coordinator-service.js +20 -3
  133. package/packages/roundtable/src/roundtable/service.js +31 -5
  134. package/skills/capturing-session-knowledge/references/retrieval.md +10 -2
  135. package/skills/operating-fuli/references/workflow-recipes.md +2 -0
  136. package/src/agent-apps/host-tools/catalog.js +1 -0
  137. package/src/agent-tools/executor-routing-definitions.js +194 -0
  138. package/src/agent-tools/graph-definitions.js +20 -1279
  139. package/src/agent-tools/graph-handlers.js +6 -2
  140. package/src/agent-tools/graph-tool-fields.js +43 -0
  141. package/src/agent-tools/interface-catalog.js +5 -1
  142. package/src/agent-tools/knowledge-curation-definitions.js +167 -0
  143. package/src/agent-tools/knowledge-definitions.js +431 -0
  144. package/src/agent-tools/project-agent-tool-definitions.js +271 -0
  145. package/src/agent-tools/project-space-definitions.js +155 -0
  146. package/src/agent-tools/session-fuli-gate.js +33 -31
  147. package/src/agent-tools/standing-assignment-definitions.js +32 -0
  148. package/src/agent-tools/task-entry-definitions.js +105 -0
  149. package/src/agent-tools.js +5 -4
  150. package/src/agents/claude-code/lifecycle-hook.js +16 -2
  151. package/src/agents/claude-code/preference-evidence.js +11 -1
  152. package/src/app/application-error.js +21 -3
  153. package/src/conversations/capture-window.js +8 -3
  154. package/src/conversations/entry-budget.js +2 -10
  155. package/src/conversations/entry-inline-budget.js +144 -0
  156. package/src/conversations/entry-rules.js +1 -1
  157. package/src/conversations/entry-time.js +15 -0
  158. package/src/conversations/preference-evidence.js +19 -0
  159. package/src/conversations/preference-lifecycle.js +28 -7
  160. package/src/conversations/preference-session.js +26 -10
  161. package/src/conversations/preference-snapshot.js +12 -1
  162. package/src/conversations/sync-transcript.js +10 -6
  163. package/src/conversations/transcript-guard.js +4 -3
  164. package/src/conversations/transcript-lifecycle.js +6 -3
  165. package/src/data-format/local-stores.js +3 -0
  166. package/src/desktop/windows-installation.js +2 -1
  167. package/src/external-knowledge/connectors/feishu.js +3 -1
  168. package/src/graphiti/active-personal-space.js +5 -0
  169. package/src/graphiti/agent-conversations.js +23 -28
  170. package/src/graphiti/agent-knowledge-workflows.js +12 -1299
  171. package/src/graphiti/agent-project-resolution.js +11 -0
  172. package/src/graphiti/agent-view-records.js +19 -0
  173. package/src/graphiti/capture-notice.js +20 -6
  174. package/src/graphiti/collaboration-preference-entry.js +89 -0
  175. package/src/graphiti/collaboration-preference-workflow.js +1 -1
  176. package/src/graphiti/common-knowledge-candidates.js +222 -0
  177. package/src/graphiti/cross-project-knowledge-similarity.js +59 -0
  178. package/src/graphiti/current-project-knowledge-search.js +86 -0
  179. package/src/graphiti/decision-trace.js +136 -0
  180. package/src/graphiti/federated-application.js +158 -795
  181. package/src/graphiti/human-knowledge-changes.js +45 -0
  182. package/src/graphiti/knowledge-credential-guard.js +43 -0
  183. package/src/graphiti/knowledge-curation.js +178 -0
  184. package/src/graphiti/knowledge-feedback.js +25 -0
  185. package/src/graphiti/knowledge-graph-reads.js +62 -0
  186. package/src/graphiti/local-runtimes.js +78 -0
  187. package/src/graphiti/personal-global-preference-candidates.js +431 -0
  188. package/src/graphiti/personal-projects.js +33 -0
  189. package/src/graphiti/preference-conflict-requests.js +57 -0
  190. package/src/graphiti/preference-project-resolution.js +39 -0
  191. package/src/graphiti/preference-task-scope.js +18 -0
  192. package/src/graphiti/project-agent-control-plane.js +6 -1
  193. package/src/graphiti/project-agent-task-entry.js +18 -1
  194. package/src/graphiti/project-path-context.js +28 -9
  195. package/src/graphiti/provider-client.js +1 -1
  196. package/src/graphiti/public-project-relations.js +28 -0
  197. package/src/graphiti/public-projects.js +125 -0
  198. package/src/graphiti/publication-review-queues.js +50 -0
  199. package/src/graphiti/roundtable-host.js +35 -3
  200. package/src/graphiti/session-capture-pause-request.js +3 -2
  201. package/src/graphiti/session-fuli-switch.js +4 -3
  202. package/src/graphiti/session-knowledge-capture.js +59 -0
  203. package/src/graphiti/session-records.js +4 -3
  204. package/src/graphiti/source-marker.js +13 -3
  205. package/src/graphiti/standing-assignment-confirmation.js +66 -0
  206. package/src/graphiti/standing-assignment-correction.js +148 -0
  207. package/src/graphiti/standing-assignment-entry.js +223 -0
  208. package/src/graphiti/task-context-entry.js +114 -0
  209. package/src/graphiti/task-entry-preferences.js +4 -1
  210. package/src/graphiti/task-entry-project-mention.js +13 -2
  211. package/src/graphiti/task-entry-project-scope.js +12 -3
  212. package/src/graphiti/task-entry-standing-owner.js +141 -0
  213. package/src/graphiti/task-knowledge-checkpoint.js +212 -0
  214. package/src/graphiti/task-knowledge-guidance.js +13 -0
  215. package/src/graphiti/task-knowledge-recall.js +113 -2
  216. package/src/graphiti/task-preference-reader.js +1 -1
  217. package/src/graphiti/workflow-learning.js +38 -0
  218. package/src/graphiti/workspace-provider-client.js +10 -0
  219. package/src/http/api-router.js +13 -3
  220. package/src/http/standing-assignment-api-router.js +35 -0
  221. package/src/judgment/agent-view.js +29 -7
  222. package/src/judgment/conversation.js +8 -2
  223. package/src/judgment/engine.js +16 -4
  224. package/src/judgment/http.js +37 -5
  225. package/src/judgment/review-injection-precheck.js +97 -0
  226. package/src/judgment/review-suggestions.js +46 -0
  227. package/src/judgment/store.js +8 -0
  228. package/src/knowledge-hard-delete/delete-ledger.js +12 -3
  229. package/src/knowledge-hard-delete/recovery-gate.js +4 -4
  230. package/src/knowledge-owner-reads/console-port.js +8 -0
  231. package/src/knowledge-owner-reads/owner-proof.js +35 -0
  232. package/src/local-runtime/lifecycle.js +2 -1
  233. package/src/local-runtime/provider-readiness.js +35 -11
  234. package/src/mcp/instructions.js +3 -3
  235. package/src/mcp/preference-delivery.js +13 -3
  236. package/src/mcp/session-id.js +2 -0
  237. package/src/mcp/tool-annotations.js +3 -2
  238. package/src/model-backends/http.js +45 -8
  239. package/src/model-backends/role-settings.js +25 -3
  240. package/src/model-backends/role-trust.js +39 -6
  241. package/src/model-backends/runtime.js +10 -3
  242. package/src/model-backends/settings-history-list.js +132 -0
  243. package/src/model-backends/settings-history.js +175 -0
  244. package/src/native-runtime/java-runtime.js +4 -4
  245. package/src/presence/windows-helper-pin.js +1 -1
  246. package/src/semantic-version.js +5 -1
  247. package/src/server.js +3 -2
  248. package/src/setup/claude-code-config.js +1 -1
  249. package/src/setup/graph-runtime.js +42 -15
  250. package/src/setup/paths.js +2 -0
  251. package/src/standing-assignments/port.js +189 -44
  252. package/src/standing-assignments/store.js +12 -1
  253. package/src/standing-assignments/term-match.js +7 -0
  254. package/src/system/file-identity.js +11 -0
  255. package/src/system/platform-path.js +38 -0
  256. package/src/validation/values.js +22 -6
  257. package/dist/web/assets/EmployeeWorkbenchPage-BUMfMBc8.js +0 -3
  258. package/dist/web/assets/KnowledgePage-Bfbfz_Z8.js +0 -1
  259. package/dist/web/assets/ModelSettingsPage-C3eBDWRL.js +0 -1
  260. package/dist/web/assets/ModelSettingsPage-DZkrJw7R.css +0 -1
  261. package/dist/web/assets/index-r-WFOs21.js +0 -2
  262. package/dist/web/assets/project-team-api-DwP0O3rn.js +0 -1
@@ -0,0 +1,35 @@
1
+ import { readJson, sendJson } from './response.js';
2
+ import { refuseRemoteDecision } from './request-policy.js';
3
+ import { correctStandingAssignmentInConsole } from '../graphiti/standing-assignment-correction.js';
4
+ import { positiveInteger } from '../validation/values.js';
5
+
6
+ const LIST_PATH = '/api/standing-assignments';
7
+ const CHANGE_PATH = /^\/api\/standing-assignments\/([^/]+)\/(retire|reassign|terms)$/;
8
+ const ACTIONS = Object.freeze({ retire: 'retire', reassign: 'reassign', terms: 'edit_terms' });
9
+
10
+ // The person's standing assignments in the local console (rec#29 F5): the
11
+ // active ones, and ending, reassigning or editing the terms of the one the
12
+ // page shows, at the revision it showed (409 when it changed since; a change
13
+ // already in place, such as a retry, answers unchanged). Only on
14
+ // this computer; an Agent asks the person through register_standing_assignment
15
+ // instead, which previews and needs the person's yes in the conversation.
16
+ export async function handleStandingAssignmentRequest({ request, response, url, app }) {
17
+ const change = url.pathname.match(CHANGE_PATH);
18
+ const list = url.pathname === LIST_PATH && request.method === 'GET';
19
+ if (!list && !(change && request.method === 'POST')) return false;
20
+ response.setHeader('Cache-Control', 'no-store');
21
+ if (refuseRemoteDecision(request, response, 'Standing assignments are changed only on this computer')) return true;
22
+ if (!app.standingAssignments) {
23
+ sendJson(response, 503, { error: 'Standing assignments need a local FULI installation' });
24
+ return true;
25
+ }
26
+ if (list) {
27
+ sendJson(response, 200, { assignments: app.standingAssignments.list(app.config.personal.spaceId) });
28
+ return true;
29
+ }
30
+ const body = await readJson(request);
31
+ sendJson(response, 200, await correctStandingAssignmentInConsole(app, { ...body,
32
+ assignmentId: decodeURIComponent(change[1]), action: ACTIONS[change[2]],
33
+ expectedRevision: positiveInteger(body.expectedRevision, 'expectedRevision', Number.MAX_SAFE_INTEGER) }));
34
+ return true;
35
+ }
@@ -1,4 +1,5 @@
1
1
  import { judgmentHumanInteraction } from './conversation.js';
2
+ import { INJECTION_SIGNALS } from './review-injection-precheck.js';
2
3
  import { KNOWLEDGE_KEY, visibleKnowledgeKeys } from './visible-items.js';
3
4
 
4
5
  // What an Agent reads of Tonborg's local records (rec#50). A record keeps what
@@ -16,9 +17,16 @@ import { KNOWLEDGE_KEY, visibleKnowledgeKeys } from './visible-items.js';
16
17
  const RECEIPT = ['status', 'outcome', 'reason', 'reviewId', 'taskId', 'revision', 'decisionId', 'recovered'];
17
18
  const FEEDBACK = ['revision', 'vote', 'createdAt'];
18
19
  const EXECUTION = { status: true, createdAt: true, receipt: RECEIPT };
20
+ // What the host did with a review verdict (engine.js reviewDisposition): the
21
+ // model's schema-checked outcome, the host's fixed interception and gate
22
+ // codes, and the pre-check's signal names, only those the detector reports.
23
+ const AI_REVIEW = {
24
+ state: true, modelOutcome: true, interceptions: true, gate: ['status', 'reason', 'modelId'],
25
+ injectionSignals: new Set(INJECTION_SIGNALS), injectionInBatch: true
26
+ };
19
27
  const KEPT = Object.freeze({
20
28
  id: true, kind: true, personalProjectId: true, createdAt: true, outcome: true, proposedOutcome: true,
21
- confidence: true, aiReview: true, disposition: true, selection: true, conversationId: true,
29
+ confidence: true, aiReview: AI_REVIEW, disposition: true, selection: true, conversationId: true,
22
30
  executionRequired: true, agentId: true, workKind: true, taskRevision: true, artifactRevision: true,
23
31
  evaluationId: true, requestFingerprint: true, evidenceFingerprint: true, policy: true, policyVersion: true,
24
32
  memoryRevision: true, client: true, model: true, sessionId: true, judgedBy: true, modelReceipt: true,
@@ -52,7 +60,8 @@ function agentRecord(record, targets) {
52
60
  const { target, title, ...rest } = record;
53
61
  const shown = project(rest, KEPT, '', withheld);
54
62
  const knowledge = record.kind === 'review' && KNOWLEDGE_KEY.test(target ?? '');
55
- if (knowledge ? targets.visible.has(target) : PLAIN_TARGETS[record.kind]?.(target)) {
63
+ const plain = Object.hasOwn(PLAIN_TARGETS, record.kind) && PLAIN_TARGETS[record.kind](target);
64
+ if (knowledge ? targets.visible.has(target) : plain) {
56
65
  shown.target = target;
57
66
  // A review's title is its candidate's own name (engine.js); any other title is withheld.
58
67
  if (knowledge && title !== undefined) shown.title = title;
@@ -66,20 +75,33 @@ function agentRecord(record, targets) {
66
75
  }
67
76
 
68
77
  // rule: true keeps a value as it is; a list keeps those keys of an object; a
69
- // map keeps its keys by their own rules. Arrays take the rule per element.
78
+ // map keeps its keys by their own rules; a Set keeps only its own values, of
79
+ // a list too. Arrays take the rule per element. Only a rule's own keys name
80
+ // fields, so `constructor`, `toString` or `__proto__` in a record is withheld
81
+ // like any other unnamed field, and a list or map rule never keeps a bare value.
70
82
  function project(value, rule, path, withheld) {
71
- if (rule === true || value === null || typeof value !== 'object') return value;
83
+ if (rule instanceof Set) return knownValues(value, rule, path, withheld);
84
+ if (rule === true || value === null) return value;
72
85
  if (Array.isArray(value)) return value.map(item => project(item, rule, path, withheld));
86
+ if (typeof value !== 'object') { if (present(value)) withheld.add(path); return undefined; }
73
87
  const kept = {};
74
88
  for (const [key, field] of Object.entries(value)) {
75
89
  const name = path ? `${path}.${key}` : key;
76
- const fieldRule = Array.isArray(rule) ? rule.includes(key) : rule[key];
77
- if (fieldRule) kept[key] = project(field, fieldRule, name, withheld);
78
- else if (present(field)) withheld.add(name);
90
+ const fieldRule = Array.isArray(rule) ? rule.includes(key) : Object.hasOwn(rule, key) && rule[key];
91
+ if (!fieldRule) { if (present(field)) withheld.add(name); continue; }
92
+ const shown = project(field, fieldRule, name, withheld);
93
+ if (shown !== undefined) Object.defineProperty(kept, key, { value: shown, enumerable: true, writable: true, configurable: true });
79
94
  }
80
95
  return kept;
81
96
  }
82
97
 
98
+ function knownValues(value, known, path, withheld) {
99
+ const values = Array.isArray(value) ? value : [value];
100
+ const kept = values.filter(item => known.has(item));
101
+ if (kept.length < values.length) withheld.add(path);
102
+ return Array.isArray(value) ? kept : kept[0];
103
+ }
104
+
83
105
  function present(value) {
84
106
  return value !== undefined && value !== null && value !== '' && !(Array.isArray(value) && !value.length);
85
107
  }
@@ -3,6 +3,10 @@ import { nativeChoiceInteraction } from '../conversations/human-interaction.js';
3
3
  // rec#10 D-24: a model's review that may not apply itself reaches the person
4
4
  // as a suggestion, with the model's own conclusion and reason as reference.
5
5
  const SUGGESTION = 'AI 建议,待你确认 / AI suggestion, awaiting your decision';
6
+ // rec#26: why the host escalated, whatever the model concluded. It names a
7
+ // pattern match only; a candidate without one is not thereby safe (D-56).
8
+ const INJECTION_NOTE = '宿主预检:候选文本匹配已知注入格式 / Host pre-check: the candidate\'s text matches a known injection pattern';
9
+ const BATCH_NOTE = '宿主预检:同批候选匹配已知注入格式 / Host pre-check: another candidate reviewed in the same request matches a known injection pattern. ';
6
10
  const NEEDS_DECISION = 'Tonborg 需要你判断 / Tonborg needs your decision';
7
11
  // rec#50: an Agent's view carries no reason (agent-view.js); the person reads it in the console.
8
12
  const REASON_IN_CONSOLE = 'Tonborg 的理由只在 FULI 控制台的 Tonborg 记录里显示 / Tonborg\'s reason is shown only in the FULI console\'s Tonborg records';
@@ -14,13 +18,15 @@ export function judgmentHumanInteraction(records, personalSpaceId) {
14
18
  && !['stale', 'failed'].includes(item.execution?.status) && !item.target_withheld);
15
19
  if (!record) return {};
16
20
  const suggestion = record.aiReview?.state === 'ai_suggested';
21
+ const signals = record.aiReview?.injectionSignals ?? [];
22
+ const note = signals.length ? `${INJECTION_NOTE} (${signals.join(', ')}). ` : record.aiReview?.injectionInBatch ? BATCH_NOTE : '';
17
23
  const conclusion = suggestion ? `${SUGGESTION} (model: ${record.aiReview.modelOutcome})` : null;
18
24
  return { human_interaction: nativeChoiceInteraction({
19
25
  source: { kind: 'tonborg_review', id: record.id, revision: record.evidenceFingerprint ?? record.createdAt,
20
26
  target: record.target, personalSpaceId, personalProjectId: record.personalProjectId ?? null },
21
27
  title: record.title ?? '需要补充判断',
22
28
  question: record.content_withheld
23
- ? `${conclusion ?? NEEDS_DECISION}. ${REASON_IN_CONSOLE}`
24
- : conclusion ? `${conclusion} ${record.summary}` : record.summary
29
+ ? `${note}${conclusion ?? NEEDS_DECISION}. ${REASON_IN_CONSOLE}`
30
+ : conclusion ? `${note}${conclusion} ${record.summary}` : record.summary
25
31
  }) };
26
32
  }
@@ -14,6 +14,7 @@ import { jsonSchemaToZod } from '../mcp/tool-schema.js';
14
14
  import { PREFERENCE_RECEIPT_VERSION, preferenceDeliveryRecord, preferenceHold,
15
15
  readJudgmentPreferences } from './preference-receipt.js';
16
16
  import { REVIEW_EXAMPLE, reviewInstructions } from './review-prompt.js';
17
+ import { injectionSignals } from './review-injection-precheck.js';
17
18
  import { automaticWriteDecision } from '../graphiti/capture-decision.js';
18
19
 
19
20
  const id = z.string().min(1).max(256);
@@ -126,13 +127,17 @@ export function createJudgmentEngine({ app, judge = createJudgmentBackend(), tru
126
127
  }
127
128
  const trustKey = answer.pending ? null : reviewTrustKey(answer, { personalSpaceId: space, personalProjectId: project || null });
128
129
  const gate = trustKey && gateOf(trustKey);
130
+ // rec#26: one model request judges the whole batch, so injected text in
131
+ // any candidate may have steered every verdict of that answer.
132
+ const signals = new Map(candidates.map(c => [c.candidate_key, injectionSignals(c)]));
133
+ const batchInjected = [...signals.values()].some(found => found.length);
129
134
  for (const decision of answer.pending ? [] : reviewDecisions(answer.value, schema, candidates)) {
130
135
  const candidate = candidates.find(c => c.candidate_key === decision.target);
131
136
  // The person may have permanently deleted it while the model answered (rec#5 C9).
132
137
  if (store.forgets(decision.target, space)) continue;
133
138
  const protectedItem = Boolean(candidate.requires_attention || candidate.negative_evidence_count > 0
134
139
  || candidate.reasons?.includes('conflict_or_attention'));
135
- const aiReview = reviewDisposition(decision, { protectedItem, gate, policy });
140
+ const aiReview = reviewDisposition(decision, { protectedItem, injection: signals.get(decision.target), batchInjected, gate, policy });
136
141
  const outcome = aiReview.interceptions.some(reason => reason !== 'manual_policy') ? 'escalate' : decision.outcome;
137
142
  let record = store.record(space, { personalProjectId: project || null, kind: 'review', target: decision.target,
138
143
  title: candidate.title, summary: decision.summary, evidence: decision.evidence, confidence: decision.confidence,
@@ -280,13 +285,20 @@ function reviewTrustKey(answer, scope) {
280
285
  // decides. A manual policy keeps the approval as the outcome it shows but
281
286
  // still applies nothing. gate_not_passed keeps its D-24 name (the evaluation
282
287
  // harness scores by it); since D-36 it means the role trust gate refused, and
283
- // gate.reason says why.
284
- function reviewDisposition(decision, { protectedItem, gate, policy }) {
288
+ // gate.reason says why. injection: the host pre-check's signals for the
289
+ // candidate (rec#26); batchInjected: some candidate of the same model request
290
+ // had signals, so no approval of that answer applies (batch_contaminated for
291
+ // a candidate without its own). The person sees both whatever the model answered.
292
+ function reviewDisposition(decision, { protectedItem, injection, batchInjected, gate, policy }) {
293
+ const contaminated = batchInjected && !injection.length;
285
294
  const interceptions = decision.outcome !== 'approve' ? [] : [
286
295
  ...(protectedItem ? ['needs_attention'] : []),
296
+ ...(injection.length ? ['injection_suspected'] : []),
297
+ ...(contaminated ? ['batch_contaminated'] : []),
287
298
  ...(decision.confidence < REVIEW_CONFIDENCE_FLOOR ? ['below_confidence'] : []),
288
299
  ...(gate.status !== 'passed' ? ['gate_not_passed'] : []),
289
300
  ...(policy.mode === 'manual' ? ['manual_policy'] : [])];
290
301
  const applies = decision.outcome === 'approve' && !interceptions.length;
291
- return { state: applies ? 'ai_reviewed' : 'ai_suggested', modelOutcome: decision.outcome, interceptions, gate };
302
+ return { state: applies ? 'ai_reviewed' : 'ai_suggested', modelOutcome: decision.outcome, interceptions, gate,
303
+ ...(injection.length ? { injectionSignals: injection } : {}), ...(contaminated ? { injectionInBatch: true } : {}) };
292
304
  }
@@ -1,22 +1,52 @@
1
1
  import { readJson, sendJson } from '../http/response.js';
2
2
  import { refuseRemoteDecision } from '../http/request-policy.js';
3
3
  import { EmployeeError } from '../employees/manifest.js';
4
+ import { confirmConsoleOwner } from '../knowledge-owner-reads/owner-proof.js';
4
5
  import { undoAutomaticReview } from './review-undo.js';
6
+ import { tonborgReviewSuggestions } from './review-suggestions.js';
5
7
 
6
8
  const UNDO_PATH = '/api/judgment/undo';
9
+ const SUGGESTIONS_PATH = '/api/judgment/suggestions';
10
+ const PATHS = ['/api/agent-pins', '/api/judgment/policy', '/api/judgment/records', '/api/judgment/feedback',
11
+ '/api/judgment/review', '/api/judgment/assess', '/api/judgment/accept', UNDO_PATH, SUGGESTIONS_PATH];
12
+ // The routes that answer with Tonborg's full records (summary, evidence,
13
+ // receipts, feedback reasons) or its suggestions (rec#11 D-60): a judgment
14
+ // keeps an item's title and key from when Tonborg read it, the item may be
15
+ // one FLA's own since, and the model's words were written with Tonborg's
16
+ // scoped preferences, memory and earlier feedback. Like the console's other
17
+ // full reads, each is loopback only, a LAN device with its LAN code included,
18
+ // and answers only after the console server confirmed its own human-review
19
+ // proof (owner-proof.js), before anything is read, run or written. A refused
20
+ // request gets 403 and no data. The server attaches that proof itself and
21
+ // trusts local HTTP callers, so a local process can still read these routes
22
+ // over loopback; caller authentication is rec#11 D-61.
23
+ // Agents read and ask Tonborg through their MCP tools (list_judgments,
24
+ // review_with_tonborg, assess_agent_action, assess_task_completion); no MCP
25
+ // or Agent tool module imports this one (test/judgment-console-owner.test.js).
26
+ // Pins and policy hold no history and stay readable as before.
27
+ const OWNER_ROUTES = new Set(['GET /api/judgment/records', 'POST /api/judgment/feedback', 'POST /api/judgment/review',
28
+ 'POST /api/judgment/assess', 'POST /api/judgment/accept', `GET ${SUGGESTIONS_PATH}`]);
7
29
 
8
30
  // undoConsole: the human-review channel the person's undo is sent on
9
- // (review-undo.js); null without a local installation.
10
- export async function handleJudgmentApiRequest({ request, response, url, app, undoConsole = null }) {
11
- if (!['/api/agent-pins', '/api/judgment/policy', '/api/judgment/records', '/api/judgment/feedback', '/api/judgment/review', '/api/judgment/assess', '/api/judgment/accept', UNDO_PATH].includes(url.pathname)) return false;
31
+ // (review-undo.js); ownerReads: the console's human-review read port
32
+ // (src/knowledge-owner-reads) that confirms the proof of an owner route.
33
+ // Both are null without a local installation.
34
+ export async function handleJudgmentApiRequest({ request, response, url, app, undoConsole = null, ownerReads = null }) {
35
+ if (!PATHS.includes(url.pathname)) return false;
12
36
  if (!app.judgment) throw new EmployeeError('Judgment runtime unavailable', 503);
13
- if (url.pathname === UNDO_PATH && request.method === 'POST') {
37
+ const route = `${request.method} ${url.pathname}`;
38
+ if (route === `POST ${UNDO_PATH}`) {
14
39
  response.setHeader('Cache-Control', 'no-store');
15
40
  if (refuseRemoteDecision(request, response, 'Undoing Tonborg\'s review is done only on this computer')) return true;
16
41
  if (!undoConsole) sendJson(response, 503, { error: 'Undoing Tonborg\'s review needs a local FULI installation' });
17
42
  else sendJson(response, 200, await undoAutomaticReview({ judgment: app.judgment, undoConsole, input: await readJson(request) }));
18
43
  return true;
19
44
  }
45
+ if (OWNER_ROUTES.has(route)) {
46
+ response.setHeader('Cache-Control', 'no-store');
47
+ if (refuseRemoteDecision(request, response, 'Tonborg\'s judgments are read only on this computer')) return true;
48
+ await confirmConsoleOwner(ownerReads, app.config?.personal?.spaceId, 'Tonborg\'s judgments');
49
+ }
20
50
  const query = { personalSpaceId: url.searchParams.get('personalSpaceId'),
21
51
  ...(url.searchParams.has('personalProjectId') ? { personalProjectId: url.searchParams.get('personalProjectId') || null } : {}) };
22
52
  const actions = {
@@ -29,8 +59,10 @@ export async function handleJudgmentApiRequest({ request, response, url, app, un
29
59
  'POST /api/judgment/review': async () => app.judgment.review(await readJson(request)),
30
60
  'POST /api/judgment/assess': async () => app.judgment.assess(await readJson(request)),
31
61
  'POST /api/judgment/accept': async () => app.judgment.accept(await readJson(request)),
62
+ [`GET ${SUGGESTIONS_PATH}`]: async () => ({ suggestions: await tonborgReviewSuggestions({ judgment: app.judgment,
63
+ input: { personalSpaceId: query.personalSpaceId } }) }),
32
64
  };
33
- const action = actions[`${request.method} ${url.pathname}`];
65
+ const action = actions[route];
34
66
  if (!action) sendJson(response, 405, { error: 'Method not allowed' });
35
67
  else sendJson(response, 200, await action());
36
68
  return true;
@@ -0,0 +1,97 @@
1
+ // A narrow, deterministic pattern check of a knowledge review candidate
2
+ // (rec#26). Tonborg's review model reads candidate text as data, but a small
3
+ // model can still follow text that speaks to it. Whatever the model answers,
4
+ // an approval of a candidate whose text matches one of these known injection
5
+ // patterns is not applied: the engine escalates it to the person and names
6
+ // the matched signals.
7
+ //
8
+ // It matches fixed text shapes only (who the text addresses, whether it sets
9
+ // the review's outcome, review or chat syntax, tool-call syntax, hidden
10
+ // characters), with no model and no Agent. It catches only the shapes it was
11
+ // written against and is not injection protection: on a 40-sample synthetic
12
+ // blind set (20 injection, 20 ordinary) written without reading these
13
+ // patterns, recall was 6/20 and false positives 1/20 (D-56); that is not a
14
+ // real-world attack recall rate. The confidence floor, the trust gate and the
15
+ // person's decision stay the safeguards; this adds one more reason to escalate.
16
+
17
+ const CJK = '\\u3400-\\u9fff';
18
+
19
+ const PATTERNS = Object.freeze({
20
+ // Text that speaks to the reviewer or the model, or replaces its instructions.
21
+ reviewer_instruction: [
22
+ /\b(?:ignore|disregard|forget|override)\b[^.\n]{0,30}\b(?:previous|prior|above|earlier|system|original)\b[^.\n]{0,20}\b(?:instructions?|rules?|prompts?|directions?)\b/i,
23
+ /\b(?:ignore|disregard|forget|override)\s+(?:all|any|every|your)\s+(?:of\s+(?:the|your)\s+)?(?:instructions?|rules?|prompts?|directions?|guidelines?|policies)\b/i,
24
+ /(?:忽略|无视|忘记|忘掉|覆盖)[^。\n]{0,12}(?:之前|以上|上面|前面|先前|原有|所有|全部|系统)[^。\n]{0,8}(?:指令|指示|规则|提示|要求|设定)/,
25
+ /\b(?:tonborg|the model|the ai|llm|ai reviewer|knowledge reviewer)\b[^.\n]{0,20}\b(?:must|should|shall|needs? to|has to|is required to|please)\b[^.\n]{0,20}\b(?:approve|escalate|output|answer)\b/i,
26
+ /\breviewer\s*:/i,
27
+ /(?:审核员|审核人|审阅人|审查员|评审员|tonborg|模型|\bAI\b)[^。\n]{0,8}(?:请|必须|务必|应当|应该|需要|直接|只需)[^。\n]{0,8}(?:通过|批准|放行|approve|输出|保存)/i,
28
+ /\b(?:all|every|each)\s+(?:of the\s+)?candidates?\b[^.\n]{0,30}\b(?:approve|save)/i,
29
+ /(?:所有|全部|每条|每个|凡是|一切)[^。\n]{0,6}候选[^。\n]{0,12}(?:保存|通过|批准|放行|approve)/i
30
+ ],
31
+ // A claim that a system, host, administrator or the user already approved this item.
32
+ authority_claim: [
33
+ /\b(?:system|host|admin|administrator|developer)\s+(?:override|notice|instruction|message|note|approval|prompt)\s*:/i,
34
+ /\b(?:pre-?approved|already\s+(?:been\s+)?(?:approved|confirmed|reviewed))\b/i,
35
+ /\bhuman\s+(?:confirmation|approval|review)\s+(?:is\s+|was\s+|has been\s+)?(?:already\s+)?(?:recorded|given|granted|done|complete)/i,
36
+ /(?:系统|宿主)(?:提示|通知|消息|指令|公告)\s*:/,
37
+ /管理员(?:已经?)?(?:批准|审批|确认|通知|指令)\s*:|已经?(?:过|经|获|被)?管理员(?:批准|审批|确认)/,
38
+ /(?:本条|此条|该条|这条)(?:候选|记录|内容)?[^。\n]{0,8}已经?(?:过|被|获|经)?(?:管理员|用户|人工|系统)?(?:审批|批准|确认|审核)/,
39
+ /(?:本候选|此候选|该候选|这个候选)[^。\n]{0,8}(?:已|无需|不需要?|不必|不用)/
40
+ ],
41
+ // An attempt to set the review's outcome or confidence.
42
+ outcome_directive: [
43
+ /\b(?:do not|don't|never|no need to|without)\s+(?:escalat|ask(?:ing)?\s+the\s+(?:user|person|human))/i,
44
+ new RegExp(`(?:无需|不需要?|不必|不用|别|勿|不要)\\s*(?:再)?\\s*(?:升级|上报)(?![${CJK}A-Za-z])`),
45
+ /(?:无需|不需要?|不必|不用)\s*(?:再)?\s*(?:询问|征求|人工)/,
46
+ /\boutcome\b["']?\s*[:=]?\s*["']?(?:approve|escalate)\b/i,
47
+ /\b(?:output|return|respond with|answer with|reply with)\s+(?:only\s+)?["']?(?:approve|escalate)\b/i,
48
+ /\bapprove\s+(?:this|the following|every|all|each)\s+(?:candidates?|items?|entr(?:y|ies)|records?)\b/i,
49
+ /(?:请|直接|输出|返回|回答|给出)\s*["'“]?\s*(?:approve|escalate|通过|批准|放行)/i,
50
+ /\bconfidence\b\s*(?:score\s*)?(?:[:=]|to|of|is|as|填|设为|设成|写成?|为)?\s*["']?(?:1(?:\.0+)?|0?\.\d+|100\s*%)(?![\d.])/i,
51
+ /(?:置信度|信心|确信度)\s*(?:填|设为|设成|写成?|为|[:=])\s*["']?(?:1(?:\.0+)?|0?\.\d+|100\s*%)(?![\d.])/
52
+ ],
53
+ // Review prompt sections, chat-template turns or the review's own JSON.
54
+ boundary_or_format: [
55
+ /<\s*\/?\s*(?:data|task|decisions|system|assistant|instructions?)\s*>/i,
56
+ /\b(?:TASK|DATA|DECISIONS)\s*:/,
57
+ /<\|[a-z_]{2,30}\|>|\[\/?INST\]|<<\/?SYS>>/i,
58
+ /"(?:decisions|outcome|confidence)"\s*:/i
59
+ ],
60
+ // Tool or function call syntax.
61
+ tool_call: [
62
+ /<\s*\/?\s*(?:tool_call|tool_use|function_calls?|invoke)\b/i,
63
+ /"(?:tool_calls|function_call|tool_use)"\s*:/i,
64
+ /\{\s*"name"\s*:\s*"[^"]{1,80}"\s*,\s*"(?:arguments|parameters|input)"\s*:/i
65
+ ]
66
+ });
67
+
68
+ // Characters that hide or reorder text: zero-width spaces and non-joiners
69
+ // (the emoji joiner U+200D is ordinary), word joiners, byte order marks,
70
+ // bidirectional controls and Unicode tag characters.
71
+ const HIDDEN = /[​‌⁠-⁤‪-‮⁦-⁩]|[\u{E0000}-\u{E007F}]/u;
72
+
73
+ // Every signal name injectionSignals can report; an Agent view keeps no other (agent-view.js).
74
+ export const INJECTION_SIGNALS = Object.freeze([...Object.keys(PATTERNS), 'hidden_characters']);
75
+ const INVISIBLE = /[­​-‏‪-‮⁠-⁤⁦-⁩]|[\u{E0000}-\u{E007F}]/gu;
76
+
77
+ // The text a reader sees: invisible characters removed and full-width forms
78
+ // folded (NFKC), so neither splits or disguises a phrase.
79
+ function readableText(text) {
80
+ return text.replace(INVISIBLE, '').normalize('NFKC').replace(/[ \t ]+/g, ' ');
81
+ }
82
+
83
+ function stringsOf(value) {
84
+ if (typeof value === 'string') return [value];
85
+ if (Array.isArray(value)) return value.flatMap(stringsOf);
86
+ return value && typeof value === 'object' ? Object.values(value).flatMap(stringsOf) : [];
87
+ }
88
+
89
+ // The injection signals in any text of the candidate, in a fixed order; empty when none.
90
+ export function injectionSignals(candidate) {
91
+ const texts = stringsOf(candidate);
92
+ const readable = texts.map(readableText);
93
+ const found = Object.entries(PATTERNS)
94
+ .filter(([, patterns]) => readable.some(text => patterns.some(pattern => pattern.test(text))))
95
+ .map(([signal]) => signal);
96
+ return texts.some(text => HIDDEN.test(text)) ? [...found, 'hidden_characters'] : found;
97
+ }
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+
3
+ import { parse } from './service.js';
4
+
5
+ // The console's list of Tonborg's knowledge review suggestions (rec#8): the
6
+ // verdicts the host did not apply and left to the person (ai_suggested,
7
+ // rec#10 D-24, D-36), shown under 「建议记录」 beside what Astro, Bole and
8
+ // Jefa suggested. Like that log (rec#10 D-30) each one is what Tonborg said
9
+ // at the time, never a to-do: whether the item still waits is answered by
10
+ // the knowledge item the action opens.
11
+ //
12
+ // A verdict keeps the item's title and key from when Tonborg read it, and its
13
+ // summary is the model's free text, written with Tonborg's scoped
14
+ // preferences, memory and earlier feedback in the same request. The item may
15
+ // have become one FLA's own since, and the summary may quote any of that. So
16
+ // this list is the person's owner read and nothing less, like every full
17
+ // judgment read (rec#11 D-60): its console route answers only a loopback
18
+ // request, after the console server confirmed its own human-review proof with
19
+ // the Provider (src/judgment/http.js, src/knowledge-owner-reads/owner-proof.js).
20
+ // There is no filtered view for anyone else. Only that route uses this
21
+ // module; no MCP or Agent tool module imports it
22
+ // (test/tonborg-review-suggestions.test.js). Agents get Tonborg's verdicts
23
+ // from review_with_tonborg and list_judgments as before.
24
+
25
+ // The newest suggestions the section can show; older ones stay on Tonborg's page.
26
+ const SUGGESTION_LIMIT = 50;
27
+ const id = z.string().trim().min(1).max(256);
28
+ const listInput = z.object({ personalSpaceId: id }).strict();
29
+
30
+ // A suggestion followed by a newer one for the same item in the same project
31
+ // reads stale: 'newer' (as the role suggestion log, D-30.3).
32
+ export async function tonborgReviewSuggestions({ judgment, input }) {
33
+ const { personalSpaceId } = parse(listInput, input);
34
+ await judgment.scope({ personalSpaceId });
35
+ const seen = new Set();
36
+ return judgment.store().reviewSuggestions(personalSpaceId, SUGGESTION_LIMIT).map(record => {
37
+ const subject = `${record.personalProjectId ?? ''}\u0000${record.target}`;
38
+ const newer = seen.has(subject);
39
+ seen.add(subject);
40
+ return { id: record.id, createdAt: record.createdAt, personalSpaceId, personalProjectId: record.personalProjectId ?? null,
41
+ target: record.target, title: record.title ?? null, summary: record.summary, confidence: record.confidence ?? null,
42
+ aiReview: record.aiReview, model: record.model ?? null, client: record.client ?? null,
43
+ judgedBy: record.judgedBy ?? null, ...(record.hard_deleted ? { hard_deleted: true } : {}),
44
+ ...(newer ? { stale: 'newer' } : {}) };
45
+ });
46
+ }
@@ -107,6 +107,14 @@ export class JudgmentStore {
107
107
  : this.db.prepare('SELECT id FROM judgment_records WHERE space=? AND project=? ORDER BY rowid DESC LIMIT ?').all(space, personalProjectId ?? '', limit);
108
108
  return rows.map(({ id }) => this.get(space, id));
109
109
  }
110
+ // Knowledge review verdicts the host left to the person (ai_suggested,
111
+ // rec#10 D-24, D-36), newest first, in every project of the space.
112
+ reviewSuggestions(space, limit) {
113
+ this.#assertRecovery(space);
114
+ return this.db.prepare(`SELECT id FROM judgment_records WHERE space=? AND json_extract(body,'$.kind')='review'
115
+ AND json_extract(body,'$.aiReview.state')='ai_suggested' ORDER BY rowid DESC LIMIT ?`)
116
+ .all(space, limit).map(({ id }) => this.get(space, id));
117
+ }
110
118
  acceptances(space, agentId, personalProjectId = null) {
111
119
  this.#assertRecovery(space);
112
120
  return this.db.prepare(`SELECT id FROM judgment_records WHERE space=? AND json_extract(body,'$.kind')='acceptance'
@@ -3,6 +3,7 @@ import { readFileSync, statSync } from 'node:fs';
3
3
  import { dirname, join } from 'node:path';
4
4
 
5
5
  import { DataFormatError } from '../../packages/roundtable/src/storage/data-format-error.js';
6
+ import { fileIdentity } from '../system/file-identity.js';
6
7
  import { jsonFormat, requireJsonFormatVersion, updateVersionedJsonFileAtomic, withJsonFormatDirectory } from '../storage/json-format.js';
7
8
  import { knowledgeReferences } from './forget-references.js';
8
9
  import { hardDeleteLedgerSchema, HARD_DELETE_LEDGER_FINGERPRINT, ledgerDocument } from './ledger-format.js';
@@ -91,9 +92,18 @@ export function hardDeleteLedger(dataDir, { now = () => new Date() } = {}) {
91
92
  };
92
93
  }
93
94
 
95
+ // What says the ledger file changed since it was last read: its exact
96
+ // identity (rec#49), size and nanosecond times. A stamp lives only in process
97
+ // memory and is never written, so no stamp of an older format is compared
98
+ // with it; any difference reads the ledger again.
99
+ export function ledgerStamp(path, statFile = statSync) {
100
+ const stat = statFile(path, { bigint: true });
101
+ return `${fileIdentity(stat)}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
102
+ }
103
+
94
104
  // The fence for a store file in a data directory, read again whenever the
95
105
  // ledger beside it changes. A store in memory has none.
96
- export function deletedKnowledgeBeside(storePath) {
106
+ export function deletedKnowledgeBeside(storePath, { statFile = statSync } = {}) {
97
107
  if (!storePath || storePath === ':memory:') return () => knowledgeReferences({});
98
108
  const path = join(dirname(storePath), HARD_DELETE_LEDGER_FILE);
99
109
  let seen = null;
@@ -102,8 +112,7 @@ export function deletedKnowledgeBeside(storePath) {
102
112
  return (spaceId = undefined) => {
103
113
  let stamp;
104
114
  try {
105
- const stat = statSync(path);
106
- stamp = `${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}:${stat.ino}`;
115
+ stamp = ledgerStamp(path, statFile);
107
116
  } catch (error) {
108
117
  if (error?.code !== 'ENOENT') throw error;
109
118
  stamp = 'missing';
@@ -1,7 +1,7 @@
1
1
  import { statSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { ApplicationError } from '../app/application-error.js';
4
- import { HARD_DELETE_LEDGER_FILE, readHardDeleteProof } from './delete-ledger.js';
4
+ import { HARD_DELETE_LEDGER_FILE, ledgerStamp, readHardDeleteProof } from './delete-ledger.js';
5
5
 
6
6
  const WAIT = '等待图谱确认删除记录;请启动控制台或运行 fuli migrate reconcile-knowledge。 '
7
7
  + 'Waiting for deletion recovery; start the console or run fuli migrate reconcile-knowledge.';
@@ -22,15 +22,15 @@ export async function prepareKnowledgeRecovery(gate, spaceId, storeName) {
22
22
  // One process's proof of the current graph watermark, never a recovery writer.
23
23
  // No timer opens a gate. A stale/mutated proof closes synchronously; a successful
24
24
  // ordinary-token aggregate read must establish it again before any body access.
25
- export function createKnowledgeRecoveryGate({ dataDir, readWatermark, now = () => performance.now(), maxAgeMs = 60_000 }) {
25
+ export function createKnowledgeRecoveryGate({ dataDir, readWatermark, now = () => performance.now(), maxAgeMs = 60_000,
26
+ statFile = statSync }) {
26
27
  if (!Number.isFinite(maxAgeMs) || maxAgeMs < 0 || maxAgeMs > 60_000) throw new TypeError('Recovery proof lasts at most 60 seconds');
27
28
  const proofs = new Map();
28
29
  const pending = new Map();
29
30
  const file = join(dataDir, HARD_DELETE_LEDGER_FILE);
30
31
  function snapshot() {
31
32
  try {
32
- const stat = statSync(file);
33
- const stamp = `${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}:${stat.ino}`;
33
+ const stamp = ledgerStamp(file, statFile);
34
34
  return { stamp, document: readHardDeleteProof(dataDir) };
35
35
  } catch (error) {
36
36
  if (error.code === 'ENOENT') return { stamp: 'missing', document: null };
@@ -25,6 +25,14 @@ export function knowledgeOwnerReads(dataDir, { send = personalHumanReviewChannel
25
25
  return {
26
26
  graph: ({ spaceId, limit, personalProjectId, offset }) =>
27
27
  request(graphReadPath(spaceId, { limit, personalProjectId, offset }), null, 'GET'),
28
+ // Confirms the console's proof with the Provider before a local store shows
29
+ // text that may name any FLA's knowledge (Tonborg's judgments and
30
+ // suggestions, the built-in Agents' suggestion log; owner-proof.js): one
31
+ // bounded read whose answer is not used. A refused proof throws the
32
+ // Provider's refusal.
33
+ confirmOwner: async (personalSpaceId) => {
34
+ await request(graphReadPath(personalSpaceId, { limit: 1 }), null, 'GET');
35
+ },
28
36
  itemView: (body) => request('/v1/knowledge/item-views', body),
29
37
  turnReceipt: (body) => request('/v1/knowledge/turn-receipts', body),
30
38
  sessionRecords: (body) => request('/v1/session-records', body),
@@ -0,0 +1,35 @@
1
+ import { ApplicationError } from '../app/application-error.js';
2
+ import { ProviderRequestError } from '../graphiti/provider-client.js';
3
+
4
+ // The one check a console route makes before it shows the person's full
5
+ // history or a model's free text that may name any FLA's knowledge: Tonborg's
6
+ // judgments and suggestions (src/judgment/http.js) and the built-in Agents'
7
+ // suggestion log (src/model-backends/http.js) (rec#11 D-60), consistent with
8
+ // the console's other full reads. The route first refuses any request that is
9
+ // not loopback (refuseRemoteDecision), a LAN device with a valid LAN code
10
+ // included; then this confirms the console server's own human-review proof
11
+ // with the Provider through the owner-read port (console-port.js
12
+ // confirmOwner: one bounded read whose answer is not used).
13
+ //
14
+ // The Provider's answer decides: its refusal of the proof (401, 403) and its
15
+ // own failures pass on as they are. A port that could not send a proof at all
16
+ // (no local installation, no human-review token) is no proof: 403
17
+ // human_review_proof_required.
18
+ //
19
+ // The HTTP caller does not supply the proof: the server reads the token from
20
+ // its provider env and attaches it itself, trusting every local HTTP caller.
21
+ // So any local process, an Agent with a shell included, can still read these
22
+ // routes over loopback without reading any token. Authenticating the caller
23
+ // with a console session is a separate change (rec#11 D-61).
24
+ // what: what the route shows, for the refusal's message.
25
+ export async function confirmConsoleOwner(ownerReads, personalSpaceId, what) {
26
+ const proofRequired = () => new ApplicationError('human_review_proof_required',
27
+ `${what} are read only by the local console with its human-review proof`, { status: 403 });
28
+ if (!ownerReads || !personalSpaceId) throw proofRequired();
29
+ try {
30
+ await ownerReads.confirmOwner(personalSpaceId);
31
+ } catch (error) {
32
+ if (error instanceof ProviderRequestError) throw error;
33
+ throw proofRequired();
34
+ }
35
+ }
@@ -1,5 +1,6 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { existsSync, unlinkSync } from 'node:fs';
3
+ import { setTimeout as delay } from 'node:timers/promises';
3
4
 
4
5
  import {
5
6
  checkLocalConsoleHealth,
@@ -323,7 +324,7 @@ async function waitForExit(pid, timeoutMs = CONSOLE_EXIT_TIMEOUT_MS) {
323
324
  const deadline = Date.now() + timeoutMs;
324
325
  while (Date.now() < deadline) {
325
326
  if (!isProcessAlive(pid)) return true;
326
- await new Promise((resolve) => setTimeout(resolve, 100));
327
+ await delay(100);
327
328
  }
328
329
  return !isProcessAlive(pid);
329
330
  }
@@ -1,32 +1,56 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
2
 
3
- const PROVIDER_READY_ATTEMPTS = 120;
3
+ const PROVIDER_READY_TIMEOUT_MS = 120_000;
4
4
  const PROVIDER_READY_INTERVAL_MS = 1000;
5
5
  const PROVIDER_HEALTH_TIMEOUT_MS = 2500;
6
6
  const MANAGED_PROVIDER_PORT = '8788';
7
7
  const LOOPBACK_HOSTS = Object.freeze(['127.0.0.1', 'localhost', '::1', '[::1]']);
8
8
 
9
+ // Polls `isReady(budgetMs)` until it answers true or `timeoutMs` of wall-clock
10
+ // time has passed, pausing `intervalMs` between probes. Each probe gets at most
11
+ // `probeTimeoutMs` and never more than the time left, so a slow probe cannot run
12
+ // past the deadline. `abandon` is checked before each probe, so a wait on a
13
+ // process that exits stops at the next check. Answers 'ready', 'abandoned' or
14
+ // 'timed_out' so each caller words the failure for its own service.
15
+ export async function waitUntilReady(isReady, {
16
+ timeoutMs,
17
+ intervalMs,
18
+ probeTimeoutMs,
19
+ wait = delay,
20
+ now = Date.now,
21
+ abandon = () => false
22
+ }) {
23
+ const deadline = now() + timeoutMs;
24
+ for (;;) {
25
+ if (await abandon()) return 'abandoned';
26
+ const remainingMs = deadline - now();
27
+ if (remainingMs <= 0) return 'timed_out';
28
+ if (await isReady(Math.min(probeTimeoutMs, remainingMs))) return 'ready';
29
+ const leftMs = deadline - now();
30
+ if (leftMs <= 0) return 'timed_out';
31
+ await wait(Math.min(intervalMs, leftMs));
32
+ }
33
+ }
34
+
9
35
  // Polls the Provider health route until it answers. Neo4j recovery and index
10
36
  // initialization can take a while after a cold start, so failures are retried.
11
37
  export async function waitForProviderHealth(url, {
12
38
  fetchImpl = fetch,
13
39
  wait = delay,
14
- attempts = PROVIDER_READY_ATTEMPTS,
40
+ now = Date.now,
41
+ timeoutMs = PROVIDER_READY_TIMEOUT_MS,
15
42
  failureMessage
16
43
  }) {
17
44
  const healthUrl = `${String(url).replace(/\/$/, '')}/health`;
18
- for (let attempt = 0; attempt < attempts; attempt += 1) {
45
+ const outcome = await waitUntilReady(async (budgetMs) => {
19
46
  try {
20
- const response = await fetchImpl(healthUrl, {
21
- signal: AbortSignal.timeout(PROVIDER_HEALTH_TIMEOUT_MS)
22
- });
23
- if (response.ok) return;
47
+ const response = await fetchImpl(healthUrl, { signal: AbortSignal.timeout(budgetMs) });
48
+ return response.ok;
24
49
  } catch {
25
- // The Provider is still starting.
50
+ return false; // The Provider is still starting.
26
51
  }
27
- if (attempt < attempts - 1) await wait(PROVIDER_READY_INTERVAL_MS);
28
- }
29
- throw new Error(failureMessage);
52
+ }, { timeoutMs, intervalMs: PROVIDER_READY_INTERVAL_MS, probeTimeoutMs: PROVIDER_HEALTH_TIMEOUT_MS, wait, now });
53
+ if (outcome !== 'ready') throw new Error(failureMessage);
30
54
  }
31
55
 
32
56
  // A workspace whose Provider is the locally managed development instance.