braian 0.0.4 → 0.0.5
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/README.md +31 -7
- package/bin/braian.mjs +337 -60
- package/bin/launch-target.mjs +15 -27
- package/bin/run-state.mjs +203 -0
- package/dist/app.module.js +2 -0
- package/dist/bootstrap.js +4 -1
- package/dist/http/api-controllers.js +6 -0
- package/dist/http/vault-http-error.js +4 -1
- package/dist/http/web-app-fallback.js +37 -0
- package/dist/logging/logging.middleware.js +3 -1
- package/dist/main.js +3 -0
- package/dist/mcp/mcp-path.js +12 -0
- package/dist/mcp/mcp-settings.controller.js +78 -0
- package/dist/mcp/mcp.controller.js +147 -0
- package/dist/mcp/mcp.dto.js +53 -0
- package/dist/mcp/mcp.module.js +20 -0
- package/dist/mcp/mcp.service.js +117 -0
- package/dist/providers/model-provider.service.js +3 -3
- package/dist/rss/rss-profiles.controller.js +167 -0
- package/dist/rss/rss-profiles.dto.js +511 -0
- package/dist/rss/rss-profiles.service.js +149 -0
- package/dist/rss/rss.module.js +5 -2
- package/dist/search/search.controller.js +1 -1
- package/dist/vaults/vault.controller.js +41 -0
- package/dist/vaults/vault.dto.js +80 -6
- package/dist/vaults/vaults.module.js +2 -1
- package/dist/vaults/vaults.service.js +30 -2
- package/dist/workspace/workspace-config.js +3 -3
- package/node_modules/@braian/ai-providers/dist/index.js +4 -1
- package/node_modules/@braian/ai-providers/dist/jev-routing.js +41 -13
- package/node_modules/@braian/graph-agent/dist/agent-profiles/tool-catalog.js +4 -4
- package/node_modules/@braian/graph-agent/dist/data-workspace.js +44 -0
- package/node_modules/@braian/graph-agent/dist/demo-vaults.js +348 -0
- package/node_modules/@braian/graph-agent/dist/feature-switch.js +1 -1
- package/node_modules/@braian/graph-agent/dist/graph-agent.js +40 -7
- package/node_modules/@braian/graph-agent/dist/index.js +24 -2
- package/node_modules/@braian/graph-agent/dist/mcp-tokens.js +62 -0
- package/node_modules/@braian/graph-agent/dist/rss/index.js +43 -1
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-model.js +378 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-store.js +170 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-test.js +120 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-use-cases.js +74 -0
- package/node_modules/@braian/graph-agent/dist/vault-changes.js +3 -0
- package/node_modules/@braian/graph-agent/dist/vault-settings-operations.js +3 -1
- package/node_modules/@braian/graph-agent/dist/vault-settings-registry.js +1 -1
- package/node_modules/@braian/voice-transcription/dist/transcribe.js +1 -1
- package/package.json +3 -1
- package/public/assets/{agent-profiles-settings-I5Ux2GnH.js → agent-profiles-settings-yElCnMJo.js} +1 -1
- package/public/assets/{appearance-settings-module-CD3bJpfR.js → appearance-settings-module-BFDKE-mZ.js} +1 -1
- package/public/assets/{ar-SA-G6X2FPQ2-BPq1dwIU.js → ar-SA-G6X2FPQ2-R9ND2Rw0.js} +1 -1
- package/public/assets/{attachment-embed-BkP-B_Pa.js → attachment-embed-BX0XSPNZ.js} +1 -1
- package/public/assets/{attachments-settings-BeAekkzf.js → attachments-settings-CSEjOoFg.js} +1 -1
- package/public/assets/{az-AZ-76LH7QW2-nXEHcVXP.js → az-AZ-76LH7QW2-DpGlptKS.js} +1 -1
- package/public/assets/{bg-BG-XCXSNQG7-CpTkmSSX.js → bg-BG-XCXSNQG7-WKBfRf7q.js} +1 -1
- package/public/assets/{bn-BD-2XOGV67Q-BDMEyCuA.js → bn-BD-2XOGV67Q-BmT7jnvl.js} +1 -1
- package/public/assets/board-workspace-CmetKvXF.js +1 -0
- package/public/assets/{boards-settings-module-CCN_ZNks.js → boards-settings-module-Bh5dh9jG.js} +1 -1
- package/public/assets/{boards-view-B1B8wHHn.js → boards-view-3JR36W_w.js} +1 -1
- package/public/assets/{ca-ES-6MX7JW3Y-D0UEot-K.js → ca-ES-6MX7JW3Y-CBR9ytrG.js} +1 -1
- package/public/assets/{calendar-view-BlTCcAzD.js → calendar-view-Cr1VSpj0.js} +1 -1
- package/public/assets/calendar-workspace-B-2Himdy.js +1 -0
- package/public/assets/{calendars-settings-module-ActBZM9v.js → calendars-settings-module-BWI1k_YA.js} +1 -1
- package/public/assets/{card-fields-nzhTsBAW.js → card-fields-eo7dqj1P.js} +1 -1
- package/public/assets/{chat-composer-editor-CRtsZz3W.js → chat-composer-editor-DCmWVP16.js} +1 -1
- package/public/assets/chat-message-list-DPXjDBw1.js +1 -0
- package/public/assets/{chunk-EIO257PC-CGqfS2j0.js → chunk-EIO257PC-Bfdsn_q8.js} +1 -1
- package/public/assets/{code-editor-DnrGU9QQ.js → code-editor-CxLqzVwa.js} +1 -1
- package/public/assets/color-picker-DK8V_DI0.js +1 -0
- package/public/assets/{contents-view-C6RdJxE2.js → contents-view-DHRWEBwV.js} +1 -1
- package/public/assets/{conversation-debug-panel-DIjQShXO.js → conversation-debug-panel-zsrBEMxW.js} +1 -1
- package/public/assets/create-note-popup-C9IB_IZr.js +1 -0
- package/public/assets/{cs-CZ-2BRQDIVT-DvEBYfBD.js → cs-CZ-2BRQDIVT-fiabtlu1.js} +1 -1
- package/public/assets/{cypher-editor-Cdd9vqJj.js → cypher-editor-ef6RdDgm.js} +1 -1
- package/public/assets/{da-DK-5WZEPLOC-nBVf9B0e.js → da-DK-5WZEPLOC-C-5tRCvs.js} +1 -1
- package/public/assets/{daily-notes-settings-DG9RUcYk.js → daily-notes-settings-CCotd1Iq.js} +1 -1
- package/public/assets/{dashboard-grid-BvlcalWZ.js → dashboard-grid-DKMK4z_a.js} +1 -1
- package/public/assets/dashboard-workspace-4u-QaXby.js +4 -0
- package/public/assets/{dashboards-settings-module-CMkRnuLc.js → dashboards-settings-module-DmE0Krje.js} +1 -1
- package/public/assets/{dashboards-view-BB1CRB2G.js → dashboards-view-DxUAl6zg.js} +1 -1
- package/public/assets/{de-DE-XR44H4JA-wIoI5uHM.js → de-DE-XR44H4JA-4wneKMQi.js} +1 -1
- package/public/assets/{desktop-server-settings-j8RrUDQh.js → desktop-server-settings-DDd8PcxW.js} +1 -1
- package/public/assets/{directory-picker-columns-BDdL8yxc.js → directory-picker-columns-CqPZNMT8.js} +1 -1
- package/public/assets/{discovery-create-popup-DpDB1MTg.js → discovery-create-popup-BSOSYM4o.js} +1 -1
- package/public/assets/{discovery-import-popup-BsyONSTT.js → discovery-import-popup-NodFxSW1.js} +1 -1
- package/public/assets/{discovery-settings-module-CSz3wdqd.js → discovery-settings-module-DQMZismj.js} +1 -1
- package/public/assets/{discovery-view-DOb6HJff.js → discovery-view-PiwStXSa.js} +1 -1
- package/public/assets/discovery-workspace-BTrjBF19.js +2 -0
- package/public/assets/{dist-tLZONR8L.js → dist-B58c6eJE.js} +1 -1
- package/public/assets/drag-preview-D61OK7zr.js +1 -0
- package/public/assets/{drawing-note-BZkhWRBb.js → drawing-note-BytzAih9.js} +1 -1
- package/public/assets/{el-GR-BZB4AONW-BoxDB0UD.js → el-GR-BZB4AONW-BUDxOK9m.js} +1 -1
- package/public/assets/{en-B4ZKOASM-D3_h4H29.js → en-B4ZKOASM-jB7I34Md.js} +1 -1
- package/public/assets/{es-ES-U4NZUMDT-BTF8-J9f.js → es-ES-U4NZUMDT-gXLOOlpz.js} +1 -1
- package/public/assets/{esm-zhVSGSwY.js → esm-BSlSeh8A.js} +1 -1
- package/public/assets/{eu-ES-A7QVB2H4-PqSQa04Y.js → eu-ES-A7QVB2H4-4kiV_opo.js} +1 -1
- package/public/assets/{fa-IR-HGAKTJCU-B03HX6BC.js → fa-IR-HGAKTJCU-C7F0Dl4h.js} +1 -1
- package/public/assets/{feature-switch-section-CDTUV6B-.js → feature-switch-section-617S6UWP.js} +1 -1
- package/public/assets/{fi-FI-Z5N7JZ37-D5Rn9AGc.js → fi-FI-Z5N7JZ37-DEUSwc4a.js} +1 -1
- package/public/assets/{file-editor-DTm2a8_D.js → file-editor-DvP7rRI9.js} +3 -3
- package/public/assets/{file-language-C8bPT8Wh.js → file-language-DjeubQk3.js} +1 -1
- package/public/assets/{file-preview-Bp9k2YvK.js → file-preview-AkYowAab.js} +1 -1
- package/public/assets/{file-preview-media-CNZHdx05.js → file-preview-media-DL2hGeeZ.js} +1 -1
- package/public/assets/{file-references-api-CSyFnFFm.js → file-references-api-C2G0bSy9.js} +1 -1
- package/public/assets/{files-settings-module-D4HPlkbW.js → files-settings-module-DsylYhrR.js} +1 -1
- package/public/assets/files-view-B6_Mlm9V.css +1 -0
- package/public/assets/files-view-DPSrj_WW.js +3 -0
- package/public/assets/{folder-picker-dialog-D57Q15N4.js → folder-picker-dialog-D_VCqm_i.js} +1 -1
- package/public/assets/{format-panel-value-DYwL3ttM.js → format-panel-value-vueBm4DQ.js} +1 -1
- package/public/assets/{fr-FR-RHASNOE6-BoIuGpVa.js → fr-FR-RHASNOE6-BKLo10bn.js} +1 -1
- package/public/assets/{gl-ES-HMX3MZ6V-R9gfMkm_.js → gl-ES-HMX3MZ6V-D_nHnidC.js} +1 -1
- package/public/assets/{graph-explorer-DtYVExeD.js → graph-explorer-CHz-bFkx.js} +5 -5
- package/public/assets/{graph-settings-module-D--vzqKr.js → graph-settings-module-9hY9bkdT.js} +1 -1
- package/public/assets/{he-IL-6SHJWFNN-DLh6r8yJ.js → he-IL-6SHJWFNN-BXKK7JWx.js} +1 -1
- package/public/assets/{hi-IN-IWLTKZ5I-DsP1yUVR.js → hi-IN-IWLTKZ5I-D2utCBQM.js} +1 -1
- package/public/assets/{hu-HU-A5ZG7DT2-ttWV7_mJ.js → hu-HU-A5ZG7DT2-BENIngFF.js} +1 -1
- package/public/assets/{id-ID-SAP4L64H-DIFD1Rmb.js → id-ID-SAP4L64H-Bw77jJOj.js} +1 -1
- package/public/assets/{ide-settings-module-Dsg4tJV6.js → ide-settings-module-BbIX3okW.js} +1 -1
- package/public/assets/ide-view-0vK2duKI.js +2 -0
- package/public/assets/{image-GAAHSSAO-C38PUNrv.js → image-GAAHSSAO-D4NDL8F6.js} +1 -1
- package/public/assets/{imap-accounts-QVDGlYad.js → imap-accounts-BRbnITJv.js} +1 -1
- package/public/assets/index-BVDhmwI8.js +11 -0
- package/public/assets/index-DjUUY3gd.css +1 -0
- package/public/assets/{it-IT-JPQ66NNP-D9CIdJgS.js → it-IT-JPQ66NNP-DiG4G8vQ.js} +1 -1
- package/public/assets/{ja-JP-DBVTYXUO-CYn7dH3E.js → ja-JP-DBVTYXUO-CILN9NGs.js} +1 -1
- package/public/assets/{journal-create-popup-DnYgWgDU.js → journal-create-popup-39y9ieVG.js} +1 -1
- package/public/assets/{journal-day-route-DpsYGWU7.js → journal-day-route-CYlyL-u0.js} +1 -1
- package/public/assets/{journal-folder-field-DuvIgT6Y.js → journal-folder-field-BfO-_ied.js} +1 -1
- package/public/assets/{journal-page-BdQlNdyB.js → journal-page-TgyVFaPE.js} +2 -2
- package/public/assets/{journal-settings-Dq-9Conv.js → journal-settings-CfjXOXzF.js} +1 -1
- package/public/assets/{journal-typography-QR4z5v0X.js → journal-typography-D3O3AK2U.js} +1 -1
- package/public/assets/journal-writing-route-CYhXzipC.js +1 -0
- package/public/assets/journals-view-DNomC0nF.js +1 -0
- package/public/assets/{kaa-6HZHGXH3-DmZqyxcr.js → kaa-6HZHGXH3-BUua-YiR.js} +1 -1
- package/public/assets/{kab-KAB-ZGHBKWFO-BnEoO3f6.js → kab-KAB-ZGHBKWFO-yPJB-J7N.js} +1 -1
- package/public/assets/{kk-KZ-P5N5QNE5-DcYcuRxx.js → kk-KZ-P5N5QNE5-CAitSjw5.js} +1 -1
- package/public/assets/{km-KH-HSX4SM5Z-DO6DHT6h.js → km-KH-HSX4SM5Z-CSZjabru.js} +1 -1
- package/public/assets/{ko-KR-MTYHY66A-Ch6OwlXE.js → ko-KR-MTYHY66A-CGEXYXZz.js} +1 -1
- package/public/assets/{ku-TR-6OUDTVRD-C9KHFYbx.js → ku-TR-6OUDTVRD-DOfuZRKI.js} +1 -1
- package/public/assets/{link-file-browser-BvVwFMvC.js → link-file-browser-A_Mappx0.js} +1 -1
- package/public/assets/{link-kind-icon-r9mUfWOh.js → link-kind-icon-BMfHfR_C.js} +1 -1
- package/public/assets/{link-picker-C90irWTA.js → link-picker-BfwWXJZg.js} +2 -2
- package/public/assets/{locked-shares-prompt-CA0MuZ_G.js → locked-shares-prompt-BsM-ai_V.js} +1 -1
- package/public/assets/{logging-settings-contribution-C55dtngt.js → logging-settings-contribution-BLHCBnwO.js} +1 -1
- package/public/assets/logic-DtHJ5GlU.js +28 -0
- package/public/assets/{lt-LT-XHIRWOB4-CrK3hZ26.js → lt-LT-XHIRWOB4-CmbJTJAh.js} +1 -1
- package/public/assets/{lv-LV-5QDEKY6T-BOA9oRt-.js → lv-LV-5QDEKY6T-Br-VqxTs.js} +1 -1
- package/public/assets/{markdown-message-9f2rcF0-.js → markdown-message-BIo2pHhE.js} +2 -2
- package/public/assets/{markdown-task-toggle-DiIwYCgC.js → markdown-task-toggle-9k1EldDD.js} +3 -3
- package/public/assets/{matrices-settings-module-DPI1_WsY.js → matrices-settings-module-DKGdrCad.js} +1 -1
- package/public/assets/{matrices-view-CQlirOdv.js → matrices-view-DYF7e5ES.js} +1 -1
- package/public/assets/matrix-workspace-JZhH-HQ5.js +1 -0
- package/public/assets/{maximize-2-C6N1RKlt.js → maximize-2-DATMN9kx.js} +1 -1
- package/public/assets/{mermaid-diagram-CnzQOrTI.js → mermaid-diagram-gUL2-JyE.js} +1 -1
- package/public/assets/{mobile-file-text-B4j-_eP4.js → mobile-file-text-meniSeto.js} +1 -1
- package/public/assets/{mobile-note-content-editor-znLhIM9A.js → mobile-note-content-editor-C6TUyA4F.js} +2 -2
- package/public/assets/{mobile-panel-layer-C2OowtdM.js → mobile-panel-layer-2EcEm-JB.js} +1 -1
- package/public/assets/model-provider-settings-contribution-CfHiu3nS.js +1 -0
- package/public/assets/model-providers-cQOCMmwX.js +1 -0
- package/public/assets/{mr-IN-CRQNXWMA-GWTqYMNI.js → mr-IN-CRQNXWMA-DwF8SFQB.js} +1 -1
- package/public/assets/{my-MM-5M5IBNSE-DnqvLQeM.js → my-MM-5M5IBNSE-BEiMo9eJ.js} +1 -1
- package/public/assets/{nb-NO-T6EIAALU-DyrWt8fZ.js → nb-NO-T6EIAALU-BelWzTQs.js} +1 -1
- package/public/assets/{nl-NL-IS3SIHDZ-COWPkkr8.js → nl-NL-IS3SIHDZ-Ce06PPL4.js} +1 -1
- package/public/assets/{nn-NO-6E72VCQL-8aH2uP9Y.js → nn-NO-6E72VCQL-BbXlzJzR.js} +1 -1
- package/public/assets/note-collab-provider-B9DpnE58.js +1 -0
- package/public/assets/note-collab-transport-BHZ891IL.js +1 -0
- package/public/assets/{note-create-settings-module-CV4dWr8t.js → note-create-settings-module-rIZc1DjQ.js} +1 -1
- package/public/assets/{note-documents-DCd2HaSQ.js → note-documents-CcJDTkta.js} +2 -2
- package/public/assets/note-editor-container-DL3yLdYs.js +2 -0
- package/public/assets/{note-editor-settings-module-CbPu_40k.js → note-editor-settings-module-DI0jRyPy.js} +1 -1
- package/public/assets/{note-excalidraw-editor-RjnG4My9.js → note-excalidraw-editor-fDQ1JVBh.js} +11 -11
- package/public/assets/{note-export-api-2u0sbOpc.js → note-export-api-CwuXGV0y.js} +1 -1
- package/public/assets/{note-export-flow-B3wRdMj0.js → note-export-flow-DcBoI5Pp.js} +1 -1
- package/public/assets/{note-filter-rule-rows-BajgD2k3.js → note-filter-rule-rows-DFSWBwql.js} +1 -1
- package/public/assets/{note-folds-settings-module-DZju6Mum.js → note-folds-settings-module-CFfVg1Cp.js} +1 -1
- package/public/assets/{note-frontmatter-summary-BSKg__aS.js → note-frontmatter-summary-iubFPHA_.js} +1 -1
- package/public/assets/{note-link-list-DKU2PqtO.js → note-link-list-CI9-GM_3.js} +1 -1
- package/public/assets/{note-markdown-editor-CXelEHqr.js → note-markdown-editor-lG6gZT9i.js} +10 -10
- package/public/assets/{note-outline-CNoqBtUP.js → note-outline-BFidIp-8.js} +1 -1
- package/public/assets/note-page-content-8gzPBWMV.js +2 -0
- package/public/assets/{note-page-editor-rhBoxKYB.js → note-page-editor-DpVUxkCx.js} +4 -4
- package/public/assets/{note-path-breadcrumb-uTSXCQK4.js → note-path-breadcrumb-HmtWyYZP.js} +1 -1
- package/public/assets/{note-picker-BD8rmAOq.js → note-picker-B5i41l1u.js} +1 -1
- package/public/assets/{note-picker-popover-DI9Wc706.js → note-picker-popover-B9VTeHiM.js} +1 -1
- package/public/assets/{note-shares-popup-9sJOmL1-.js → note-shares-popup-aUO1SNLN.js} +1 -1
- package/public/assets/{note-source-editor-DWyDYMCj.js → note-source-editor-BXPR_-41.js} +1 -1
- package/public/assets/{note-type-grid-BFX3oTAC.js → note-type-grid-CRCfpYZy.js} +2 -2
- package/public/assets/{note-values-BqD4746M.js → note-values-6D6wWXPg.js} +1 -1
- package/public/assets/{notes-settings-module-C5IPmwKt.js → notes-settings-module-DcP9Hid-.js} +1 -1
- package/public/assets/{oc-FR-POXYY2M6-C_R_VP74.js → oc-FR-POXYY2M6-CyRgkETq.js} +1 -1
- package/public/assets/{open-journal-writing-Bd-CppeX.js → open-journal-writing-Bub8Zn13.js} +1 -1
- package/public/assets/{pa-IN-N4M65BXN-B21EEaul.js → pa-IN-N4M65BXN-A1_Q9748.js} +1 -1
- package/public/assets/page-content-B3fNjwr-.js +1 -0
- package/public/assets/{page-files-BMj9IzfB.js → page-files-CSqFupDZ.js} +1 -1
- package/public/assets/page-note-nmiinGCs.js +1 -0
- package/public/assets/{pane-keys-CTLoUZZR.js → pane-keys-osajBGnu.js} +1 -1
- package/public/assets/{panel-columns-fields-DPjV39xn.js → panel-columns-fields-ZlW6A4My.js} +1 -1
- package/public/assets/{pdf-view-Cm78nuSA.js → pdf-view-BATpBLO5.js} +1 -1
- package/public/assets/{pencil-DQ9fAqT6.js → pencil-xxFNyZzr.js} +1 -1
- package/public/assets/{percentages-BXMCSKIN-CUt8fyAS.js → percentages-BXMCSKIN-DzsiA6IB.js} +1 -1
- package/public/assets/{phone-numbers-CHQaYRah.js → phone-numbers-BQgyhfcH.js} +1 -1
- package/public/assets/{pl-PL-T2D74RX3-Bdo_j9QK.js → pl-PL-T2D74RX3-DaINIVjz.js} +1 -1
- package/public/assets/provider-configuration-CSnNV6ps.css +1 -0
- package/public/assets/provider-configuration-DaFovElx.js +8 -0
- package/public/assets/provider-use-select-D-lJiZ2W.js +1 -0
- package/public/assets/{pt-BR-5N22H2LF-C9DRQ7CW.js → pt-BR-5N22H2LF-ENVHjTz_.js} +1 -1
- package/public/assets/{pt-PT-UZXXM6DQ-ColydZPV.js → pt-PT-UZXXM6DQ-D5Uqv0Vz.js} +1 -1
- package/public/assets/{qr-code-Bm7I0KYt.js → qr-code-CDBCi1Cu.js} +2 -2
- package/public/assets/{qr-code-svg-D0RAuUIk.js → qr-code-svg-8ENstC8b.js} +1 -1
- package/public/assets/qr-defaults-settings-C_8ybA4R.js +1 -0
- package/public/assets/qr-settings-fields-C2-DGF6a.js +1 -0
- package/public/assets/qr-viewer-DAOzDI8d.js +1 -0
- package/public/assets/{reader-clock-22DkpiWR.js → reader-clock-7x7Yvzv1.js} +1 -1
- package/public/assets/{recording-bar-DOm-SEGc.js → recording-bar-BcuvYwhh.js} +2 -2
- package/public/assets/{recording-setup-CV3LE2_1.js → recording-setup-D_MgrYb7.js} +1 -1
- package/public/assets/{recordings-api-C-Bxpzgo.js → recordings-api-Ds77lFsk.js} +1 -1
- package/public/assets/resource-overview-card-BainFWKz.js +1 -0
- package/public/assets/{ro-RO-JPDTUUEW-iJAQDPe9.js → ro-RO-JPDTUUEW-Dq_ouOp1.js} +1 -1
- package/public/assets/{rss-preferences-Bx1Wa4ri.js → rss-preferences-BafuZ3Ku.js} +1 -1
- package/public/assets/{rss-settings-module-BmDISWDk.js → rss-settings-module-Df-YS9tr.js} +1 -1
- package/public/assets/rss-view-BORHnuIQ.js +3 -0
- package/public/assets/rss-view-DIPQBTLT.css +1 -0
- package/public/assets/{ru-RU-B4JR7IUQ-CX_CWbT7.js → ru-RU-B4JR7IUQ-CqqISqJC.js} +1 -1
- package/public/assets/{safe-block-copy-DygjvDD4.js → safe-block-copy-BOVhmncw.js} +1 -1
- package/public/assets/{safe-block-qr-button-Cn9WpEkl.js → safe-block-qr-button-CD7cJG3N.js} +1 -1
- package/public/assets/{safe-block-reader-CNfzTExh.js → safe-block-reader-BkilW4Hj.js} +1 -1
- package/public/assets/safe-folder-conversion-DWTRwvTH.js +1 -0
- package/public/assets/{safe-folders-DCf8IdrM.js → safe-folders-DmvM6dtV.js} +1 -1
- package/public/assets/{safe-move-leaving-tN-IMhDo.js → safe-move-leaving-BT5e1h3p.js} +1 -1
- package/public/assets/{safe-note-locked-B_lt0XcX.js → safe-note-locked-BDCeVwpK.js} +1 -1
- package/public/assets/{safe-notes-settings-module-CMvkyfNG.js → safe-notes-settings-module-BrZreYgf.js} +1 -1
- package/public/assets/search-settings-module-CPnculiI.js +1 -0
- package/public/assets/{secret-form-DSD348Om.js → secret-form-B-YAlbZf.js} +1 -1
- package/public/assets/{secret-popup-y9W7WIrZ.js → secret-popup-CoVpeLZV.js} +1 -1
- package/public/assets/{security-settings-contribution-B_Syg5ab.js → security-settings-contribution-BmcZq1hf.js} +1 -1
- package/public/assets/settings-CU8YR8di.js +1 -0
- package/public/assets/{settings-edit-dialog-B5emNjJi.js → settings-edit-dialog-C_AeTz9Y.js} +1 -1
- package/public/assets/settings-panel-Ds7lOtnD.js +1 -0
- package/public/assets/settings-view-BTz2XbnW.js +4 -0
- package/public/assets/{settings-view-6_hMxTXD.css → settings-view-Bd65kLGK.css} +1 -1
- package/public/assets/{setup-prompt-6JRbE0oa.js → setup-prompt-BbpHVdla.js} +1 -1
- package/public/assets/{share-access-control-C5mpELVT.js → share-access-control-CzAVEv6b.js} +1 -1
- package/public/assets/share-label-CbjQ9iMF.js +1 -0
- package/public/assets/{shared-board-lanes-UWl9klys.js → shared-board-lanes-CAbJAFk6.js} +1 -1
- package/public/assets/{shared-calendar-view-DcCO3mNo.js → shared-calendar-view-DTzDjSs0.js} +1 -1
- package/public/assets/shared-note-route-B_gfX0Nl.js +4 -0
- package/public/assets/{shared-note-text-BdCw7a9a.js → shared-note-text-DFBEyL8Z.js} +1 -1
- package/public/assets/{shares-settings-module-9oF4v70A.js → shares-settings-module-pIdBLmCq.js} +1 -1
- package/public/assets/{si-LK-N5RQ5JYF-DfLSaLm6.js → si-LK-N5RQ5JYF-DmhE8IT5.js} +1 -1
- package/public/assets/{sk-SK-C5VTKIMK-DrAaUVFC.js → sk-SK-C5VTKIMK-YiOZ-xKA.js} +1 -1
- package/public/assets/{sl-SI-NN7IZMDC-WxYLW2Uj.js → sl-SI-NN7IZMDC-BKb37Hlu.js} +1 -1
- package/public/assets/{spaces-settings-module-Dh_QfANj.js → spaces-settings-module-BLU1RsTS.js} +1 -1
- package/public/assets/spaces-view-BhWD3mAw.js +2 -0
- package/public/assets/{sqlite-browser-BfIrq_0x.js → sqlite-browser-C98PFoRG.js} +2 -2
- package/public/assets/{store-attachments-DNyH0asy.js → store-attachments-DbqF7LgE.js} +1 -1
- package/public/assets/{stored-color-picker-CYL7LYdQ.js → stored-color-picker-DLX-e5Nq.js} +1 -1
- package/public/assets/subset-shared.chunk-D8M638AI.js +1 -0
- package/public/assets/{subset-worker.chunk-BrbK91mW.js → subset-worker.chunk-B9ZhBm-P.js} +1 -1
- package/public/assets/{sv-SE-XGPEYMSR-DOB2jm3x.js → sv-SE-XGPEYMSR-VT0snW-T.js} +1 -1
- package/public/assets/{ta-IN-2NMHFXQM-DfC3wGVU.js → ta-IN-2NMHFXQM--MqIf2Jf.js} +1 -1
- package/public/assets/{text-diff-BzNG8nfy.js → text-diff-BmKfp7mY.js} +1 -1
- package/public/assets/{th-TH-HPSO5L25-BsqplWuv.js → th-TH-HPSO5L25-CTKAmQrO.js} +1 -1
- package/public/assets/{theme-colors-2LJ6VIeK.js → theme-colors-zbTaiYL0.js} +1 -1
- package/public/assets/{toolbar-items-DF7H0MSb.js → toolbar-items-DLi0bl0c.js} +1 -1
- package/public/assets/{topology-code-editor-B7zxDyT3.js → topology-code-editor-CNnSyUQ3.js} +1 -1
- package/public/assets/topology-designer-T54LYLYv.js +1 -0
- package/public/assets/topology-editor-aGtCktzA.js +8 -0
- package/public/assets/{topology-folder-migration-popup-Bj4nu8HE.js → topology-folder-migration-popup-C0Wc3ViK.js} +1 -1
- package/public/assets/{topology-settings-module-cWWujj9j.js → topology-settings-module-Dp-Sm37Z.js} +1 -1
- package/public/assets/{tr-TR-DEFEU3FU-DWO1lNTH.js → tr-TR-DEFEU3FU-BVLSiyVW.js} +1 -1
- package/public/assets/{transcription-settings-HrJHl14H.js → transcription-settings-BldPwHO7.js} +4 -4
- package/public/assets/{uk-UA-QMV73CPH-ZHBKj9kv.js → uk-UA-QMV73CPH-DQ4YsZml.js} +1 -1
- package/public/assets/{unlock-prompt-C1AEyIR_.js → unlock-prompt-CkkcVo9g.js} +1 -1
- package/public/assets/{use-candidate-notes-Du1V_uun.js → use-candidate-notes-jH4-EW29.js} +1 -1
- package/public/assets/{use-directory-listing-BaYgcuHI.js → use-directory-listing-Cn9t21ra.js} +1 -1
- package/public/assets/{use-folding-enabled-CyYip5Go.js → use-folding-enabled-DKvri2UA.js} +1 -1
- package/public/assets/{use-live-document-Ck_XPFVd.js → use-live-document-D4PkZrbU.js} +1 -1
- package/public/assets/{use-mobile-layer-navigation-CBRepW9w.js → use-mobile-layer-navigation-BIC7HlT_.js} +1 -1
- package/public/assets/{use-note-attachments-SPgAe-M0.js → use-note-attachments-Bew073Hl.js} +1 -1
- package/public/assets/{use-note-delete-Dvrzq6Pl.js → use-note-delete-fFNH1Glk.js} +1 -1
- package/public/assets/use-note-editor-session-R1wm0xDf.js +1 -0
- package/public/assets/{use-note-export-flow-0uAfXAwf.js → use-note-export-flow-Dm7yhW5s.js} +2 -2
- package/public/assets/use-provider-dialogs-CrxN9JCo.js +1 -0
- package/public/assets/{use-reflection-request-DV5-_c14.js → use-reflection-request-C1DxtaYX.js} +3 -3
- package/public/assets/{use-safe-folder-moves-0nw2jjTX.js → use-safe-folder-moves-DjQUnMvz.js} +1 -1
- package/public/assets/{use-safe-folders-apply-C9pni8YW.js → use-safe-folders-apply-B1V8l7WU.js} +1 -1
- package/public/assets/{use-screen-source-BllYITR6.js → use-screen-source-CF-48NnC.js} +1 -1
- package/public/assets/use-share-actions-kb7uFat_.js +1 -0
- package/public/assets/{use-vault-file-link-C0ZO_VPm.js → use-vault-file-link-B-ZRcKDu.js} +1 -1
- package/public/assets/{use-voice-questions-Bjgb45Dc.js → use-voice-questions-DGVQlAST.js} +1 -1
- package/public/assets/{vault-entries-api-DVVjgeZh.js → vault-entries-api-pFsJiGnJ.js} +1 -1
- package/public/assets/vault-manager-YKz_Ib18.js +1 -0
- package/public/assets/{vault-settings-module-DMjLQmKz.js → vault-settings-module-CCMMSy4B.js} +1 -1
- package/public/assets/{vault-shares-popup-CCPGkRmF.js → vault-shares-popup-CaGnEIJA.js} +1 -1
- package/public/assets/{versioning-preferences-dvxhrMo9.js → versioning-preferences-DrNq-y_0.js} +1 -1
- package/public/assets/{versioning-settings-module-CnDDngKG.js → versioning-settings-module-Ddug486c.js} +1 -1
- package/public/assets/versioning-view-PR4R4gks.js +2 -0
- package/public/assets/{vi-VN-M7AON7JQ-uUfHJEho.js → vi-VN-M7AON7JQ-B-fHV7o8.js} +1 -1
- package/public/assets/video-recording-dialog-CxRs1eLE.js +1 -0
- package/public/assets/{video-recording-settings-D6YT_FW3.js → video-recording-settings-B2iE6IdW.js} +1 -1
- package/public/assets/{widget-frame-CjlAZSUy.js → widget-frame-DiF4946k.js} +1 -1
- package/public/assets/{zh-CN-LNUGB5OW-COz3oRg3.js → zh-CN-LNUGB5OW-CUgxiiUV.js} +1 -1
- package/public/assets/{zh-HK-E62DVLB3-C8ICkLhf.js → zh-HK-E62DVLB3-D-87W8QH.js} +1 -1
- package/public/assets/{zh-TW-RAJ6MFWO-AYdVqmV8.js → zh-TW-RAJ6MFWO-BVaf47B6.js} +1 -1
- package/public/index.html +3 -3
- package/public/assets/board-workspace-DPSlmJ8w.js +0 -1
- package/public/assets/calendar-workspace-6t1kuFgj.js +0 -1
- package/public/assets/chat-message-list-ClUR56GV.js +0 -1
- package/public/assets/color-picker-ClAn42eA.js +0 -1
- package/public/assets/create-note-popup-CRi210cC.js +0 -1
- package/public/assets/dashboard-workspace-D45MA_Wf.js +0 -4
- package/public/assets/discovery-workspace-Cyc70gQ1.js +0 -2
- package/public/assets/drag-preview-Cb6aidku.js +0 -1
- package/public/assets/files-view-BIDZtZgg.js +0 -3
- package/public/assets/files-view-Bo1uBB_W.css +0 -1
- package/public/assets/ide-view-DCvwb5Bx.js +0 -2
- package/public/assets/index-B8xguO4f.css +0 -1
- package/public/assets/index-CCUyKE6q.js +0 -11
- package/public/assets/journal-writing-route-JP-jPBGZ.js +0 -1
- package/public/assets/journals-view-No5xQN8-.js +0 -1
- package/public/assets/logic-BNk_20eJ.js +0 -28
- package/public/assets/matrix-workspace-C3LhTNPX.js +0 -1
- package/public/assets/model-provider-settings-contribution-DYmNbsgA.js +0 -1
- package/public/assets/model-providers-7VKk3K9H.js +0 -8
- package/public/assets/model-providers-DgRkVmP5.css +0 -1
- package/public/assets/note-collab-provider-969Kgyu8.js +0 -1
- package/public/assets/note-collab-transport-CQDYt_Db.js +0 -1
- package/public/assets/note-editor-container-CTnEE-98.js +0 -2
- package/public/assets/note-page-content-DIqkiMvt.js +0 -2
- package/public/assets/page-content-C1jtzs7H.js +0 -1
- package/public/assets/page-note-Chw2UF0u.js +0 -1
- package/public/assets/provider-use-select-DCSwSrlz.js +0 -1
- package/public/assets/qr-defaults-settings-2_Yt9x4N.js +0 -1
- package/public/assets/qr-settings-fields-DDO4XgMl.js +0 -1
- package/public/assets/qr-viewer-CvEfRC2r.js +0 -1
- package/public/assets/resource-overview-card-Co8aU6jw.js +0 -1
- package/public/assets/rss-view-5aqCVOCs.css +0 -1
- package/public/assets/rss-view-BCEFsYtS.js +0 -1
- package/public/assets/safe-folder-conversion-BOLpnv8P.js +0 -1
- package/public/assets/search-settings-module-DmczYjcQ.js +0 -1
- package/public/assets/settings-ChT117Ke.js +0 -1
- package/public/assets/settings-panel-Cl5kUs9O.js +0 -1
- package/public/assets/settings-view-C_lfjngd.js +0 -3
- package/public/assets/share-label-BU3So3s7.js +0 -1
- package/public/assets/shared-note-route-DaI6hm83.js +0 -4
- package/public/assets/spaces-view-Dw2uxDxU.js +0 -2
- package/public/assets/subset-shared.chunk-D1nlqSEH.js +0 -1
- package/public/assets/topology-designer-CvJN6QTV.js +0 -1
- package/public/assets/topology-editor-RZ0_yLuO.js +0 -8
- package/public/assets/use-note-editor-session-CRC-natg.js +0 -1
- package/public/assets/use-share-actions-ujEMhCfl.js +0 -1
- package/public/assets/vault-manager-CMQaGDss.js +0 -1
- package/public/assets/versioning-view-BsIFugt4.js +0 -2
- package/public/assets/video-recording-dialog-7IGrQMwx.js +0 -1
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultRssTagThreshold = exports.rssTagQuestion = exports.rssProfileSystemPrompt = exports.rssProfileOutputSchema = exports.rssTagExamples = exports.rssEntryKey = exports.maximumRssProfileContext = exports.maximumRssProfileSample = exports.defaultRssProfileSample = exports.rssProfileIdPattern = exports.rssProfilePromptVersion = exports.rssProfileFormat = void 0;
|
|
4
|
+
exports.rssFeedbackItems = rssFeedbackItems;
|
|
5
|
+
exports.normalizeRssProfileSample = normalizeRssProfileSample;
|
|
6
|
+
exports.sampleRssFeedback = sampleRssFeedback;
|
|
7
|
+
exports.rssTaggedItems = rssTaggedItems;
|
|
8
|
+
exports.rssTagCounts = rssTagCounts;
|
|
9
|
+
exports.rssProfileMessages = rssProfileMessages;
|
|
10
|
+
exports.extractJsonObject = extractJsonObject;
|
|
11
|
+
exports.rssTopicWeightCap = rssTopicWeightCap;
|
|
12
|
+
exports.readRssProfileAnswer = readRssProfileAnswer;
|
|
13
|
+
exports.rssFeedAffinities = rssFeedAffinities;
|
|
14
|
+
exports.rssSignalFilter = rssSignalFilter;
|
|
15
|
+
exports.rssSignalText = rssSignalText;
|
|
16
|
+
exports.buildRssProfile = buildRssProfile;
|
|
17
|
+
exports.rssProfileId = rssProfileId;
|
|
18
|
+
exports.validateRssProfile = validateRssProfile;
|
|
19
|
+
exports.rssProfileJudgeRequest = rssProfileJudgeRequest;
|
|
20
|
+
exports.readRssJudgeAnswers = readRssJudgeAnswers;
|
|
21
|
+
// A preference profile: what a chat model distilled from the person's likes, dislikes and tags on RSS entries, kept as
|
|
22
|
+
// `.brian/rss/profiles/<yyyymmddhhmmss>.yaml`, and the questions a judge (Jev, or a chat model) answers about a new
|
|
23
|
+
// article against it: how likely the reader likes it, and which of their tags it takes. See `docs/RSS_PREFERENCE_PROFILES.md`.
|
|
24
|
+
const errors_1 = require("../errors");
|
|
25
|
+
const rss_tags_1 = require("./rss-tags");
|
|
26
|
+
/** The profile file's own format; a change of shape bumps it. */
|
|
27
|
+
exports.rssProfileFormat = 4;
|
|
28
|
+
/** The generation prompt and schema below; recorded in each profile so two profiles can be told apart by how they were made. */
|
|
29
|
+
exports.rssProfilePromptVersion = 4;
|
|
30
|
+
/** `yyyymmddhhmmss` in UTC: the file name, and the profile's ID. */
|
|
31
|
+
exports.rssProfileIdPattern = /^\d{14}$/;
|
|
32
|
+
exports.defaultRssProfileSample = { mode: 'latest', count: 50 };
|
|
33
|
+
exports.maximumRssProfileSample = 500;
|
|
34
|
+
exports.maximumRssProfileContext = 2_000;
|
|
35
|
+
/** An entry as a profile's training list names it. */
|
|
36
|
+
const rssEntryKey = (feedId, entryId) => `${feedId}/${entryId}`;
|
|
37
|
+
exports.rssEntryKey = rssEntryKey;
|
|
38
|
+
/** The rated entries, most recently rated first. */
|
|
39
|
+
function rssFeedbackItems(entries) {
|
|
40
|
+
return entries.flatMap((entry) => {
|
|
41
|
+
const rating = entry.custom?.rating;
|
|
42
|
+
if (!rating || (rating.value !== 'like' && rating.value !== 'dislike'))
|
|
43
|
+
return [];
|
|
44
|
+
const summary = entry.summary ?? entry.content?.join('\n\n');
|
|
45
|
+
return [{
|
|
46
|
+
feedId: entry.feedId, feedName: entry.feedName, entryId: entry.id, title: entry.title,
|
|
47
|
+
...(entry.link ? { link: entry.link } : {}), ...(entry.published ? { published: entry.published } : {}),
|
|
48
|
+
rating: rating.value, ...(rating.reason ? { reason: rating.reason } : {}), ratedAt: rating.at,
|
|
49
|
+
...(summary ? { summary } : {}), ...(entry.categories?.length ? { categories: entry.categories } : {}),
|
|
50
|
+
...(entry.custom?.tags?.length ? { tags: entry.custom.tags } : {}), ...(entry.custom?.starred ? { starred: true } : {}),
|
|
51
|
+
...(entry.custom?.note ? { note: entry.custom.note } : {}),
|
|
52
|
+
}];
|
|
53
|
+
}).sort((left, right) => right.ratedAt.localeCompare(left.ratedAt) || left.entryId.localeCompare(right.entryId));
|
|
54
|
+
}
|
|
55
|
+
function normalizeRssProfileSample(value) {
|
|
56
|
+
const mode = value?.mode === 'random' ? 'random' : 'latest';
|
|
57
|
+
if (value?.count === undefined || value.count === null)
|
|
58
|
+
return { mode };
|
|
59
|
+
if (!Number.isInteger(value.count) || value.count < 1 || value.count > exports.maximumRssProfileSample)
|
|
60
|
+
throw new errors_1.GraphAgentError('invalid_rss_profile', `A sample is 1 to ${exports.maximumRssProfileSample} entries, or all of them.`);
|
|
61
|
+
return { mode, count: value.count };
|
|
62
|
+
}
|
|
63
|
+
/** The draw: the first `count` of the newest-first list, or `count` of them at random, kept newest first. */
|
|
64
|
+
function sampleRssFeedback(items, sample, random = Math.random) {
|
|
65
|
+
if (sample.count === undefined || sample.count >= items.length)
|
|
66
|
+
return [...items];
|
|
67
|
+
if (sample.mode === 'latest')
|
|
68
|
+
return items.slice(0, sample.count);
|
|
69
|
+
const indexes = items.map((_item, index) => index);
|
|
70
|
+
for (let index = indexes.length - 1; index > 0; index -= 1) {
|
|
71
|
+
const other = Math.floor(random() * (index + 1));
|
|
72
|
+
[indexes[index], indexes[other]] = [indexes[other], indexes[index]];
|
|
73
|
+
}
|
|
74
|
+
return indexes.slice(0, sample.count).sort((a, b) => a - b).map((index) => items[index]);
|
|
75
|
+
}
|
|
76
|
+
const summaryLimit = 600;
|
|
77
|
+
/** What the model reads of one entry: the reaction first, then just enough of the article to reason about it. */
|
|
78
|
+
function describeItem(item, index) {
|
|
79
|
+
const clip = (text) => text.replace(/\s+/g, ' ').trim().slice(0, summaryLimit);
|
|
80
|
+
return [
|
|
81
|
+
`### ${index + 1}. ${item.title.replace(/\s+/g, ' ').trim()}`,
|
|
82
|
+
`- reaction: ${item.rating === 'like' ? 'LIKED' : 'DISLIKED'}${item.starred ? ' (also starred)' : ''}`,
|
|
83
|
+
`- reason given: ${item.reason ? clip(item.reason) : '(none)'}`,
|
|
84
|
+
`- feed: ${item.feedName}`,
|
|
85
|
+
...(item.categories?.length ? [`- feed categories: ${item.categories.join(', ')}`] : []),
|
|
86
|
+
...(item.tags?.length ? [`- reader's tags: ${item.tags.join(', ')}`] : []),
|
|
87
|
+
...(item.note ? [`- reader's note: ${clip(item.note)}`] : []),
|
|
88
|
+
...(item.summary ? [`- excerpt: ${clip(item.summary)}`] : []),
|
|
89
|
+
].join('\n');
|
|
90
|
+
}
|
|
91
|
+
/** Every tagged entry, the most recently seen first. */
|
|
92
|
+
function rssTaggedItems(entries) {
|
|
93
|
+
return entries.flatMap((entry) => {
|
|
94
|
+
const tags = (0, rss_tags_1.normalizeRssTags)(entry.custom?.tags ?? []);
|
|
95
|
+
if (!tags.length)
|
|
96
|
+
return [];
|
|
97
|
+
const summary = entry.summary ?? entry.content?.join('\n\n');
|
|
98
|
+
return [{ feedId: entry.feedId, entryId: entry.id, feedName: entry.feedName, title: entry.title, tags, ...(summary ? { summary } : {}), at: entry.custom?.readAt ?? entry.firstSeenAt }];
|
|
99
|
+
}).sort((left, right) => right.at.localeCompare(left.at));
|
|
100
|
+
}
|
|
101
|
+
/** The reader's tags with how many entries carry each, most used first; tags differing only in case are one, spelled as most entries spell it. */
|
|
102
|
+
function rssTagCounts(items) {
|
|
103
|
+
const groups = new Map();
|
|
104
|
+
for (const item of items)
|
|
105
|
+
for (const tag of item.tags) {
|
|
106
|
+
const spellings = groups.get(tag.toLowerCase()) ?? new Map();
|
|
107
|
+
spellings.set(tag, (spellings.get(tag) ?? 0) + 1);
|
|
108
|
+
groups.set(tag.toLowerCase(), spellings);
|
|
109
|
+
}
|
|
110
|
+
return [...groups.values()].map((spellings) => {
|
|
111
|
+
const ordered = [...spellings].sort((a, b) => b[1] - a[1]);
|
|
112
|
+
return { tag: ordered[0][0], count: ordered.reduce((total, [, count]) => total + count, 0) };
|
|
113
|
+
}).sort((a, b) => b.count - a.count || a.tag.localeCompare(b.tag));
|
|
114
|
+
}
|
|
115
|
+
/** How many examples of each tag a generation shows: enough to see what the tag means, not a catalogue. */
|
|
116
|
+
exports.rssTagExamples = 8;
|
|
117
|
+
const topicSchema = {
|
|
118
|
+
type: 'object', additionalProperties: false, required: ['topic', 'support', 'weight', 'signals'],
|
|
119
|
+
properties: {
|
|
120
|
+
topic: { type: 'string', description: 'A short name for the theme.' },
|
|
121
|
+
support: { type: 'integer', description: 'How many of the rated articles show this theme.' },
|
|
122
|
+
weight: { type: 'number', description: '0 to 1: how strongly the theme pulls, given its support and how consistent the reasons are.' },
|
|
123
|
+
signals: { type: 'array', items: { type: 'string' }, description: 'Lowercase words or short phrases expected in FUTURE headlines on this theme; at most 8.' },
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
/** The answer a generation asks for, as a strict JSON schema: the model's structured output, and the shape shown in the prompt. */
|
|
127
|
+
exports.rssProfileOutputSchema = {
|
|
128
|
+
type: 'object', additionalProperties: false, required: ['summary', 'likes', 'dislikes', 'style', 'judge', 'tags'],
|
|
129
|
+
properties: {
|
|
130
|
+
summary: { type: 'string', description: 'Three to five sentences on this reader: what they read news for, what they seek, what they avoid.' },
|
|
131
|
+
likes: { type: 'array', items: topicSchema, description: 'Themes the reader seeks, strongest first; at most 15.' },
|
|
132
|
+
dislikes: { type: 'array', items: topicSchema, description: 'Themes the reader avoids, strongest first; at most 15.' },
|
|
133
|
+
style: {
|
|
134
|
+
type: 'object', additionalProperties: false, required: ['likes', 'dislikes'],
|
|
135
|
+
properties: { likes: { type: 'array', items: { type: 'string' }, description: 'Kinds of writing the reader likes.' }, dislikes: { type: 'array', items: { type: 'string' }, description: 'Kinds of writing the reader dislikes.' } },
|
|
136
|
+
},
|
|
137
|
+
judge: {
|
|
138
|
+
type: 'object', additionalProperties: false, required: ['instructions', 'true', 'false'],
|
|
139
|
+
properties: {
|
|
140
|
+
instructions: { type: 'string', description: 'Two to four sentences to a classifier reading state.reader and state.article, asking whether this reader would like the article and naming the deciding factors.' },
|
|
141
|
+
true: { type: 'string', description: 'One sentence: what an article this reader likes looks like.' },
|
|
142
|
+
false: { type: 'string', description: 'One sentence: what an article this reader dislikes, or does not care about, looks like.' },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
tags: {
|
|
146
|
+
type: 'array', description: 'One item for each of the reader\'s tags listed in the request, and no other.',
|
|
147
|
+
items: {
|
|
148
|
+
type: 'object', additionalProperties: false, required: ['tag', 'meaning', 'signals'],
|
|
149
|
+
properties: {
|
|
150
|
+
tag: { type: 'string', description: 'The tag exactly as listed.' },
|
|
151
|
+
meaning: { type: 'string', description: 'One sentence: which articles the reader puts under this tag, and which they do not.' },
|
|
152
|
+
signals: { type: 'array', items: { type: 'string' }, description: 'Lowercase words or short phrases expected in future headlines that take this tag; at most 8.' },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
/** What a good answer looks like, shown in the prompt for a model that cannot take the schema as structured output. */
|
|
159
|
+
const exampleAnswer = {
|
|
160
|
+
summary: 'Follows applied AI as an engineer: wants to know what new models and tools can do and how they are built. Reads for substance and concrete results; skips business news and anything written to sell.',
|
|
161
|
+
likes: [{ topic: 'Model releases with capabilities and benchmarks', support: 6, weight: 0.8, signals: ['release', 'benchmark', 'open weights'] }],
|
|
162
|
+
dislikes: [{ topic: 'Funding rounds and valuations', support: 3, weight: 0.6, signals: ['raises', 'series b', 'valuation'] }],
|
|
163
|
+
style: { likes: ['technical write-ups with numbers'], dislikes: ['listicles', 'promotional announcements'] },
|
|
164
|
+
judge: { instructions: 'Decide whether this reader would choose to read state.article. A strong match on likes or a favoured feed points to yes; a match on dislikes or a style they avoid points to no, even on a liked topic.', true: 'A concrete, technical article on a theme the reader seeks.', false: 'Business news, promotion, or a theme the reader avoids.' },
|
|
165
|
+
tags: [{ tag: 'security', meaning: 'Vulnerabilities and fixes in software the reader runs; not general threat news.', signals: ['vulnerability', 'patch', 'cve'] }],
|
|
166
|
+
};
|
|
167
|
+
/** The system prompt: what a profile is for, how to read the evidence, and the answer's shape. */
|
|
168
|
+
exports.rssProfileSystemPrompt = `You distill a person's reactions to news articles, and the tags they file articles under, into a preference profile.
|
|
169
|
+
|
|
170
|
+
The profile is used later, without you and without the evidence, to answer two questions about each NEW article: how likely this reader is to like it, and which of their tags it should take. A classifier receives the profile as state.reader and one article as state.article (title, feed, excerpt, categories) and answers each question as yes or no with a probability. It sees nothing else, so write only what helps those decisions: concrete preferences, the words that reveal them, and how strongly each pulls. Do not quote or retell the articles, and never invent preferences the evidence does not show.
|
|
171
|
+
|
|
172
|
+
You receive, in messages: the articles the reader LIKED, the articles they DISLIKED, the articles they TAGGED (grouped by tag), and the request. The reader may also describe themselves; use that to read the evidence, but do not repeat it.
|
|
173
|
+
|
|
174
|
+
How to read the evidence:
|
|
175
|
+
- A reason the reader wrote is the strongest signal; a starred like counts more than a plain like.
|
|
176
|
+
- Look for what several articles share. Give each theme its "support": how many rated articles show it. A theme with support 1 is a hint, not a preference; keep its weight low.
|
|
177
|
+
- Separate WHAT an article is about (likes, dislikes) from HOW it is written (style: depth, format, tone, clickbait, promotion). A dislike is often about style, not topic.
|
|
178
|
+
- Name what the reader actually reacted to. If they liked an article for one angle (a region, a use, a stance), the theme is that angle, not the article's broad subject.
|
|
179
|
+
|
|
180
|
+
Signals must generalise: choose words you would expect in FUTURE headlines on the theme. Never use a name, product, number or phrase that comes from a single article, and never a word so common in these feeds that it appears in most headlines (such as "ai", "model", "agent", "security", "launches", "company").
|
|
181
|
+
|
|
182
|
+
Tags: write one item for every tag the request lists, and no others. Its meaning says which articles the reader files under it and where the line is, from the tagged examples.
|
|
183
|
+
|
|
184
|
+
Answer with one JSON object of this shape (an example, not this reader):
|
|
185
|
+
|
|
186
|
+
${JSON.stringify(exampleAnswer, null, 2)}
|
|
187
|
+
|
|
188
|
+
No prose before or after it, and no Markdown fence. Write in English, whatever the language of the articles.`;
|
|
189
|
+
/** The conversation a generation sends after the system prompt: the reader's own words, the liked entries, the disliked ones, the tagged ones by tag, then the request. */
|
|
190
|
+
function rssProfileMessages(items, tagged = [], context) {
|
|
191
|
+
const liked = items.filter((item) => item.rating === 'like'), disliked = items.filter((item) => item.rating === 'dislike');
|
|
192
|
+
const block = (heading, list) => list.length ? `## ${heading} (${list.length})\n\n${list.map(describeItem).join('\n\n')}` : `## ${heading} (0)\n\nNone.`;
|
|
193
|
+
const tags = rssTagCounts(tagged).map(({ tag }) => tag);
|
|
194
|
+
const clip = (text) => text.replace(/\s+/g, ' ').trim().slice(0, 200);
|
|
195
|
+
const tagBlock = tags.length
|
|
196
|
+
? `## Articles the reader TAGGED (${tags.length} tags)\n\n${tags.map((tag) => `### #${tag}\n${tagged.filter((item) => (0, rss_tags_1.hasRssTag)(item.tags, tag)).slice(0, exports.rssTagExamples).map((item) => `- ${item.title.replace(/\s+/g, ' ').trim()} (${item.feedName})${item.summary ? `: ${clip(item.summary)}` : ''}`).join('\n')}`).join('\n\n')}`
|
|
197
|
+
: '## Articles the reader TAGGED (0 tags)\n\nNone: answer with an empty tags list.';
|
|
198
|
+
return [
|
|
199
|
+
...(context?.trim() ? [`## The reader, in their own words\n\n${context.trim()}`] : []),
|
|
200
|
+
block('Articles the reader LIKED', liked),
|
|
201
|
+
block('Articles the reader DISLIKED', disliked),
|
|
202
|
+
tagBlock,
|
|
203
|
+
`Distill the preference profile of this reader from the ${items.length} rated articles above${tags.length ? `, with one tag item for each of: ${tags.join(', ')}` : ''}.`,
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
/** The JSON object in a model's answer: structured output as given, or found in the text (whole, fenced, or between the outermost braces). */
|
|
207
|
+
function extractJsonObject(answer) {
|
|
208
|
+
if (answer && typeof answer === 'object')
|
|
209
|
+
return answer;
|
|
210
|
+
const text = typeof answer === 'string' ? answer : '';
|
|
211
|
+
const fenced = /```(?:json)?\s*([\s\S]*?)```/i.exec(text)?.[1];
|
|
212
|
+
const candidates = [text.trim(), fenced?.trim(), text.slice(text.indexOf('{'), text.lastIndexOf('}') + 1)].filter((candidate) => Boolean(candidate));
|
|
213
|
+
for (const candidate of candidates) {
|
|
214
|
+
try {
|
|
215
|
+
return JSON.parse(candidate);
|
|
216
|
+
}
|
|
217
|
+
catch { /* try the next reading */ }
|
|
218
|
+
}
|
|
219
|
+
throw new errors_1.GraphAgentError('rss_profile_unreadable', 'The model did not answer with a JSON profile.');
|
|
220
|
+
}
|
|
221
|
+
const text = (value, limit = 2_000) => typeof value === 'string' ? value.replace(/\s+$/, '').slice(0, limit) : '';
|
|
222
|
+
const strings = (value, count, limit = 200) => Array.isArray(value) ? value.map((item) => text(item, limit).trim()).filter(Boolean).slice(0, count) : [];
|
|
223
|
+
const clamp = (value, low, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.round(Math.min(1, Math.max(low, value)) * 100) / 100 : fallback;
|
|
224
|
+
/** The most weight a theme may carry for how many rated articles show it: one is a hint, four or more can be anything. */
|
|
225
|
+
function rssTopicWeightCap(support) {
|
|
226
|
+
const count = typeof support === 'number' && Number.isFinite(support) ? Math.floor(support) : 1;
|
|
227
|
+
return count <= 1 ? 0.35 : count === 2 ? 0.55 : count === 3 ? 0.75 : 1;
|
|
228
|
+
}
|
|
229
|
+
function topics(value) {
|
|
230
|
+
if (!Array.isArray(value))
|
|
231
|
+
return [];
|
|
232
|
+
return value.flatMap((item) => {
|
|
233
|
+
const topic = text(item?.topic, 120).trim();
|
|
234
|
+
return topic ? [{ topic, weight: Math.min(clamp(item?.weight, 0, 0.5), rssTopicWeightCap(item?.support)), signals: strings(item?.signals, 8, 60).map((signal) => signal.toLowerCase()) }] : [];
|
|
235
|
+
}).sort((a, b) => b.weight - a.weight).slice(0, 15);
|
|
236
|
+
}
|
|
237
|
+
const defaultJudge = {
|
|
238
|
+
instructions: 'Decide whether the reader described in state.reader would choose to read state.article. Weigh their likes and dislikes, the feed, and the kind of writing; a match on a dislike outweighs a weak like.',
|
|
239
|
+
true: 'On a theme the reader seeks, in a kind of writing they like.',
|
|
240
|
+
false: 'On a theme the reader avoids, in a kind of writing they dislike, or on nothing they care about.',
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* The preferences (all but the feeds, which are counted, not asked), the judge and the tags from the model's answer. Weights are capped by their support, which is then
|
|
244
|
+
* dropped; tags not in `vocabulary` are dropped; what is missing becomes empty rather than failing, except the summary.
|
|
245
|
+
*/
|
|
246
|
+
function readRssProfileAnswer(answer, vocabulary = []) {
|
|
247
|
+
const value = (answer && typeof answer === 'object' && !Array.isArray(answer) ? answer : {});
|
|
248
|
+
const summary = text(value.summary, 3_000).trim();
|
|
249
|
+
if (!summary)
|
|
250
|
+
throw new errors_1.GraphAgentError('rss_profile_unreadable', 'The model\'s profile has no summary.');
|
|
251
|
+
const style = (value.style ?? {}), judge = (value.judge ?? {});
|
|
252
|
+
const known = new Map(vocabulary.map((tag) => [tag.toLowerCase(), tag]));
|
|
253
|
+
const tags = Array.isArray(value.tags) ? value.tags.flatMap((item) => {
|
|
254
|
+
const tag = known.get(text(item?.tag, 64).trim().replace(/^#/, '').toLowerCase()), meaning = text(item?.meaning, 500).trim();
|
|
255
|
+
if (!tag || !meaning)
|
|
256
|
+
return [];
|
|
257
|
+
known.delete(tag.toLowerCase());
|
|
258
|
+
return [{ tag, meaning, signals: strings(item?.signals, 8, 60).map((signal) => signal.toLowerCase()) }];
|
|
259
|
+
}) : [];
|
|
260
|
+
return {
|
|
261
|
+
preferences: { summary, likes: topics(value.likes), dislikes: topics(value.dislikes), style: { likes: strings(style.likes, 12), dislikes: strings(style.dislikes, 12) } },
|
|
262
|
+
judge: { instructions: text(judge.instructions, 1_500).trim() || defaultJudge.instructions, true: text(judge.true, 500).trim() || defaultJudge.true, false: text(judge.false, 500).trim() || defaultJudge.false },
|
|
263
|
+
tags,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* How the reader leans on each feed, counted from the ratings: (likes - dislikes) / (likes + dislikes + 2), so two likes
|
|
268
|
+
* alone are 0.5 and it takes many to near 1. Feeds with a lean under 0.2 either way are left out.
|
|
269
|
+
*/
|
|
270
|
+
function rssFeedAffinities(items) {
|
|
271
|
+
const counts = new Map();
|
|
272
|
+
for (const item of items) {
|
|
273
|
+
const count = counts.get(item.feedName) ?? { likes: 0, dislikes: 0 };
|
|
274
|
+
if (item.rating === 'like')
|
|
275
|
+
count.likes += 1;
|
|
276
|
+
else
|
|
277
|
+
count.dislikes += 1;
|
|
278
|
+
counts.set(item.feedName, count);
|
|
279
|
+
}
|
|
280
|
+
return [...counts].map(([feed, { likes, dislikes }]) => ({ feed, affinity: Math.round((likes - dislikes) / (likes + dislikes + 2) * 100) / 100 }))
|
|
281
|
+
.filter((feed) => Math.abs(feed.affinity) >= 0.2).sort((a, b) => Math.abs(b.affinity) - Math.abs(a.affinity) || a.feed.localeCompare(b.feed));
|
|
282
|
+
}
|
|
283
|
+
/** A corpus needs this many entries before a signal's frequency in it means anything. */
|
|
284
|
+
const minimumSignalCorpus = 200;
|
|
285
|
+
/** A signal found in more than this share of the vault's entries tells articles apart too little. */
|
|
286
|
+
const genericSignalShare = 0.04;
|
|
287
|
+
/**
|
|
288
|
+
* Which signals survive a look at the vault's own entries (`corpus`, each entry's title and excerpt, lowercased): one
|
|
289
|
+
* found in a large share of them is generic, one found in exactly one was lifted from that article. A signal found
|
|
290
|
+
* nowhere is kept, since signals are written for future headlines.
|
|
291
|
+
*/
|
|
292
|
+
function rssSignalFilter(corpus) {
|
|
293
|
+
if (corpus.length < minimumSignalCorpus)
|
|
294
|
+
return () => true;
|
|
295
|
+
const verdicts = new Map();
|
|
296
|
+
return (signal) => {
|
|
297
|
+
const key = signal.toLowerCase();
|
|
298
|
+
let keep = verdicts.get(key);
|
|
299
|
+
if (keep === undefined) {
|
|
300
|
+
const found = corpus.reduce((total, text) => total + (text.includes(key) ? 1 : 0), 0);
|
|
301
|
+
keep = found !== 1 && found / corpus.length <= genericSignalShare;
|
|
302
|
+
verdicts.set(key, keep);
|
|
303
|
+
}
|
|
304
|
+
return keep;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/** What a signal is looked for in: an entry's title and excerpt, lowercased. */
|
|
308
|
+
function rssSignalText(entry) {
|
|
309
|
+
return `${entry.title}\n${entry.summary ?? entry.content?.join('\n') ?? ''}`.toLowerCase();
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* A whole profile from a generation's parts, in the order the file is read: how it was made, the preferences, the
|
|
313
|
+
* judge, the tags, then what it learned from. Signals are filtered against `corpus` when one is given.
|
|
314
|
+
*/
|
|
315
|
+
function buildRssProfile(input) {
|
|
316
|
+
const tagged = input.tagged ?? [];
|
|
317
|
+
const vocabulary = rssTagCounts(tagged).map(({ tag }) => tag);
|
|
318
|
+
const { preferences, judge, tags } = readRssProfileAnswer(input.answer, vocabulary);
|
|
319
|
+
const liked = input.items.filter((item) => item.rating === 'like').length;
|
|
320
|
+
const draw = input.sample.count === undefined ? 'every rated entry' : `${input.sample.mode === 'random' ? 'a random' : 'the latest'} ${input.sample.count} rated`;
|
|
321
|
+
const context = input.context?.trim().slice(0, exports.maximumRssProfileContext);
|
|
322
|
+
const keep = rssSignalFilter(input.corpus ?? []);
|
|
323
|
+
const filtered = (list) => list.map((item) => ({ ...item, signals: item.signals.filter(keep) }));
|
|
324
|
+
const learned = tagged.filter((item, index) => vocabulary.some((tag) => tagged.filter((other) => (0, rss_tags_1.hasRssTag)(other.tags, tag)).slice(0, exports.rssTagExamples).includes(item)) && tagged.findIndex((other) => other.feedId === item.feedId && other.entryId === item.entryId) === index);
|
|
325
|
+
return {
|
|
326
|
+
format: exports.rssProfileFormat,
|
|
327
|
+
createdAt: input.createdAt,
|
|
328
|
+
generator: {
|
|
329
|
+
providerId: input.model.providerId, modelId: input.model.modelId, ...(input.model.reasoningEffort ? { reasoningEffort: input.model.reasoningEffort } : {}), promptVersion: exports.rssProfilePromptVersion,
|
|
330
|
+
basedOn: `${draw}: ${liked} liked, ${input.items.length - liked} disliked; ${vocabulary.length} tags from ${tagged.length} tagged entries`,
|
|
331
|
+
},
|
|
332
|
+
preferences: { ...(context ? { context } : {}), summary: preferences.summary, likes: filtered(preferences.likes), dislikes: filtered(preferences.dislikes), feeds: rssFeedAffinities(input.items), style: preferences.style },
|
|
333
|
+
judge,
|
|
334
|
+
tags: filtered(tags),
|
|
335
|
+
training: { rated: input.items.map((item) => `${item.rating} ${(0, exports.rssEntryKey)(item.feedId, item.entryId)}`), tagged: learned.map((item) => (0, exports.rssEntryKey)(item.feedId, item.entryId)) },
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/** `yyyymmddhhmmss` of a moment, in UTC. */
|
|
339
|
+
function rssProfileId(at) { return at.toISOString().replace(/\D/g, '').slice(0, 14); }
|
|
340
|
+
/** A profile file read back: it must say when it was made and summarise the reader; the rest is read leniently, since a person may edit it. */
|
|
341
|
+
function validateRssProfile(value, path) {
|
|
342
|
+
const record = (value && typeof value === 'object' && !Array.isArray(value) ? value : undefined);
|
|
343
|
+
if (!record || typeof record.createdAt !== 'string' || typeof record.preferences?.summary !== 'string')
|
|
344
|
+
throw new errors_1.GraphAgentError('malformed_rss_profile', `${path} needs createdAt and preferences.summary.`);
|
|
345
|
+
return record;
|
|
346
|
+
}
|
|
347
|
+
/** The question key a tag is asked under; the like question is `like`. */
|
|
348
|
+
const rssTagQuestion = (tag) => `tag:${tag}`;
|
|
349
|
+
exports.rssTagQuestion = rssTagQuestion;
|
|
350
|
+
/**
|
|
351
|
+
* The questions a judge answers about a new article against a profile, in one request of Jev's shape (`runJev` in
|
|
352
|
+
* @braian/ai-providers): `state` is the reader and the article, `like` asks whether the reader likes it, and each
|
|
353
|
+
* `tag:<name>` whether it takes that tag. `candidates` narrows the tags asked, when the caller has picked the likely ones.
|
|
354
|
+
*/
|
|
355
|
+
function rssProfileJudgeRequest(profile, article, candidates) {
|
|
356
|
+
const clip = (value, limit) => value.replace(/\s+/g, ' ').trim().slice(0, limit);
|
|
357
|
+
const judge = { ...defaultJudge, ...(profile.judge ?? {}) };
|
|
358
|
+
const asked = candidates ? new Set(candidates) : undefined;
|
|
359
|
+
const tags = (profile.tags ?? []).filter((tag) => !asked || asked.has(tag.tag));
|
|
360
|
+
return {
|
|
361
|
+
state: {
|
|
362
|
+
reader: profile.preferences,
|
|
363
|
+
article: { title: clip(article.title, 300), feed: article.feedName, ...(article.summary ? { excerpt: clip(article.summary, summaryLimit) } : {}), ...(article.categories?.length ? { categories: article.categories.slice(0, 12) } : {}) },
|
|
364
|
+
},
|
|
365
|
+
questions: {
|
|
366
|
+
like: { type: 'noul', instructions: judge.instructions, criteria: { true: judge.true, false: judge.false } },
|
|
367
|
+
...Object.fromEntries(tags.map((tag) => [(0, exports.rssTagQuestion)(tag.tag), { type: 'noul', instructions: `Would the reader file state.article under the tag #${tag.tag}? ${tag.meaning}`, criteria: { true: `The article belongs under #${tag.tag}: ${tag.meaning}`, false: `The article does not belong under #${tag.tag}.` } }])),
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
/** Tags apply from this probability up, until per-tag thresholds are learned from corrections. */
|
|
372
|
+
exports.defaultRssTagThreshold = 0.6;
|
|
373
|
+
/** The judge's verdict from its yes probabilities: the likelihood of a like, and the tags that clear the threshold, likeliest first. */
|
|
374
|
+
function readRssJudgeAnswers(answers, threshold = exports.defaultRssTagThreshold) {
|
|
375
|
+
const like = answers.like;
|
|
376
|
+
const tags = Object.entries(answers).flatMap(([key, probability]) => key.startsWith('tag:') && probability >= threshold ? [{ tag: key.slice(4), probability }] : []);
|
|
377
|
+
return { like: typeof like === 'number' && Number.isFinite(like) ? Math.min(1, Math.max(0, like)) : 0.5, tags: tags.sort((a, b) => b.probability - a.probability || a.tag.localeCompare(b.tag)) };
|
|
378
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RssProfileStore = void 0;
|
|
4
|
+
// The vault's preference profiles on disk: each one `.brian/rss/profiles/<yyyymmddhhmmss>.yaml`, written once,
|
|
5
|
+
// and `.brian/rss/profiles.yaml`, which names the active one, the model the last generation used and the reader's own context. Committed with the vault.
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const promises_1 = require("node:fs/promises");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const yaml_1 = require("yaml");
|
|
10
|
+
const errors_1 = require("../errors");
|
|
11
|
+
const resource_mutex_1 = require("../resource-mutex");
|
|
12
|
+
const rss_paths_1 = require("./rss-paths");
|
|
13
|
+
const rss_profile_model_1 = require("./rss-profile-model");
|
|
14
|
+
const profileHeader = '# A preference profile distilled from the reader\'s feedback on RSS entries; see docs/RSS_PREFERENCE_PROFILES.md.\n';
|
|
15
|
+
class RssProfileStore {
|
|
16
|
+
changes;
|
|
17
|
+
lock;
|
|
18
|
+
directory;
|
|
19
|
+
settingsPath;
|
|
20
|
+
constructor(vault, changes) {
|
|
21
|
+
this.changes = changes;
|
|
22
|
+
this.directory = (0, node_path_1.join)((0, rss_paths_1.rssDirectory)(vault), 'profiles');
|
|
23
|
+
this.settingsPath = (0, node_path_1.join)((0, rss_paths_1.rssDirectory)(vault), 'profiles.yaml');
|
|
24
|
+
this.lock = new resource_mutex_1.ResourceMutex((0, node_path_1.join)(vault.locksPath, 'rss-profiles'));
|
|
25
|
+
}
|
|
26
|
+
/** Every profile, newest first. */
|
|
27
|
+
list() {
|
|
28
|
+
return this.lock.run(async () => {
|
|
29
|
+
const ids = (await (0, promises_1.readdir)(this.directory).catch(() => [])).flatMap((name) => { const id = /^(\d{14})\.yaml$/.exec(name)?.[1]; return id ? [id] : []; }).sort().reverse();
|
|
30
|
+
return Promise.all(ids.map(async (id) => {
|
|
31
|
+
try {
|
|
32
|
+
const profile = (0, rss_profile_model_1.validateRssProfile)((0, yaml_1.parse)(await (0, promises_1.readFile)(this.path(id), 'utf8')), `${id}.yaml`);
|
|
33
|
+
const test = await this.readTest(id).catch(() => undefined);
|
|
34
|
+
return { ...(test ? { score: test.score, testedAt: test.testedAt } : {}), id, createdAt: profile.createdAt, providerId: profile.generator?.providerId, modelId: profile.generator?.modelId, basedOn: profile.generator?.basedOn, summary: profile.preferences.summary };
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return { id, error: error instanceof Error ? error.message : String(error) };
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** The profile's file as written, for reading or showing. */
|
|
43
|
+
async source(id) {
|
|
44
|
+
try {
|
|
45
|
+
return await (0, promises_1.readFile)(this.path(id), 'utf8');
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error.code === 'ENOENT')
|
|
49
|
+
throw notFound(id);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async read(id) { return (0, rss_profile_model_1.validateRssProfile)((0, yaml_1.parse)(await this.source(id)), `${id}.yaml`); }
|
|
54
|
+
/** Writes a new profile under the first free second from `id`, so two generations in one second keep both. */
|
|
55
|
+
create(id, profile) {
|
|
56
|
+
return this.lock.run(async () => {
|
|
57
|
+
await (0, promises_1.mkdir)(this.directory, { recursive: true });
|
|
58
|
+
const taken = new Set(await (0, promises_1.readdir)(this.directory).catch(() => []));
|
|
59
|
+
let free = id;
|
|
60
|
+
while (taken.has(`${free}.yaml`))
|
|
61
|
+
free = String(BigInt(free) + 1n);
|
|
62
|
+
await this.writeText(this.path(free), profileHeader + (0, yaml_1.stringify)(profile, { lineWidth: 0 }));
|
|
63
|
+
return free;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** The profile's last test, kept beside it as `<id>.test.yaml`; none before the first. */
|
|
67
|
+
async readTest(id) {
|
|
68
|
+
try {
|
|
69
|
+
return (0, yaml_1.parse)(await (0, promises_1.readFile)(this.testPath(id), 'utf8'));
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error.code === 'ENOENT')
|
|
73
|
+
return undefined;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
writeTest(id, result) {
|
|
78
|
+
return this.lock.run(async () => {
|
|
79
|
+
try {
|
|
80
|
+
await (0, promises_1.readFile)(this.path(id));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw notFound(id);
|
|
84
|
+
}
|
|
85
|
+
await this.writeText(this.testPath(id), (0, yaml_1.stringify)(result, { lineWidth: 0 }));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Deletes the profile and its last test; the active one stops being active. */
|
|
89
|
+
remove(id) {
|
|
90
|
+
return this.lock.run(async () => {
|
|
91
|
+
const path = this.path(id);
|
|
92
|
+
try {
|
|
93
|
+
await (0, promises_1.readFile)(path);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
throw notFound(id);
|
|
97
|
+
}
|
|
98
|
+
this.changes?.expectOwnWrite(path);
|
|
99
|
+
await (0, promises_1.rm)(path);
|
|
100
|
+
await (0, promises_1.rm)(this.testPath(id), { force: true });
|
|
101
|
+
const settings = await this.readSettings();
|
|
102
|
+
if (settings.active === id) {
|
|
103
|
+
const { active: _active, ...rest } = settings;
|
|
104
|
+
await this.writeSettings(rest);
|
|
105
|
+
}
|
|
106
|
+
this.changes?.record({ kind: 'rss', action: 'changed', id: 'profiles' });
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
settings() { return this.lock.run(() => this.readSettings()); }
|
|
110
|
+
/** Changes what `profiles.yaml` keeps: a field left out stays, `active: null` clears it; an active profile must exist. */
|
|
111
|
+
updateSettings(change) {
|
|
112
|
+
return this.lock.run(async () => {
|
|
113
|
+
const next = { ...(await this.readSettings()) };
|
|
114
|
+
if (change.active === null)
|
|
115
|
+
delete next.active;
|
|
116
|
+
else if (change.active !== undefined) {
|
|
117
|
+
try {
|
|
118
|
+
await (0, promises_1.readFile)(this.path(change.active));
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
throw notFound(change.active);
|
|
122
|
+
}
|
|
123
|
+
next.active = change.active;
|
|
124
|
+
}
|
|
125
|
+
if (change.context !== undefined) {
|
|
126
|
+
const context = change.context.trim();
|
|
127
|
+
if (context)
|
|
128
|
+
next.context = context;
|
|
129
|
+
else
|
|
130
|
+
delete next.context;
|
|
131
|
+
}
|
|
132
|
+
if (change.evaluatorModel)
|
|
133
|
+
next.evaluatorModel = { providerId: change.evaluatorModel.providerId, modelId: change.evaluatorModel.modelId, ...(change.evaluatorModel.reasoningEffort ? { reasoningEffort: change.evaluatorModel.reasoningEffort } : {}) };
|
|
134
|
+
if (change.model)
|
|
135
|
+
next.model = { providerId: change.model.providerId, modelId: change.model.modelId, ...(change.model.reasoningEffort ? { reasoningEffort: change.model.reasoningEffort } : {}) };
|
|
136
|
+
await this.writeSettings(next);
|
|
137
|
+
return next;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async readSettings() {
|
|
141
|
+
try {
|
|
142
|
+
const value = (0, yaml_1.parse)(await (0, promises_1.readFile)(this.settingsPath, 'utf8'));
|
|
143
|
+
return value && typeof value === 'object' ? { ...(typeof value.active === 'string' ? { active: value.active } : {}), ...(value.model && typeof value.model.providerId === 'string' && typeof value.model.modelId === 'string' ? { model: value.model } : {}), ...(typeof value.context === 'string' && value.context.trim() ? { context: value.context } : {}), ...(value.evaluatorModel && typeof value.evaluatorModel.providerId === 'string' && typeof value.evaluatorModel.modelId === 'string' ? { evaluatorModel: value.evaluatorModel } : {}) } : {};
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (error.code === 'ENOENT')
|
|
147
|
+
return {};
|
|
148
|
+
throw new errors_1.GraphAgentError('malformed_rss_profile', `profiles.yaml is invalid: ${this.settingsPath}`, {}, error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async writeSettings(settings) {
|
|
152
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(this.settingsPath), { recursive: true });
|
|
153
|
+
await this.writeText(this.settingsPath, (0, yaml_1.stringify)(settings));
|
|
154
|
+
}
|
|
155
|
+
async writeText(path, text) {
|
|
156
|
+
const temporaryPath = `${path}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
157
|
+
await (0, promises_1.writeFile)(temporaryPath, text, 'utf8');
|
|
158
|
+
this.changes?.expectOwnWrite(path);
|
|
159
|
+
await (0, promises_1.rename)(temporaryPath, path);
|
|
160
|
+
this.changes?.record({ kind: 'rss', action: 'changed', id: 'profiles' });
|
|
161
|
+
}
|
|
162
|
+
testPath(id) { return this.path(id).replace(/\.yaml$/, '.test.yaml'); }
|
|
163
|
+
path(id) {
|
|
164
|
+
if (!rss_profile_model_1.rssProfileIdPattern.test(id))
|
|
165
|
+
throw new errors_1.GraphAgentError('invalid_rss_profile', `"${id}" is not a profile ID.`);
|
|
166
|
+
return (0, node_path_1.join)(this.directory, `${id}.yaml`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.RssProfileStore = RssProfileStore;
|
|
170
|
+
function notFound(id) { return new errors_1.GraphAgentError('rss_profile_not_found', `No preference profile ${id}.`); }
|