@xopcai/xopc 0.0.248 → 0.0.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-etpmyV7S.js → activity-store-DfBjTSo9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BmKxSM1k.js → agent-avatar-dicebear-BN6FJXkJ.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C7rZH1A2.js +1 -0
- package/dist/gateway/static/root/assets/agents-CgGaoo4z.js +1 -0
- package/dist/gateway/static/root/assets/{api-B0-hLuZ1.js → api-zxpcJfgj.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-D2gMshuS.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-wMu0jSKx.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-KF1Gnv36.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BnMSgZvR.js → archive-plugin-u6EE3JV8.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CejsQMev.js → attachment-load-DbJurnv-.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-RC8EyoAf.js → automations-page-Ew_e5HDn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ch-ldu35.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DGjppLSG.js → binary-plugins-DtDFNfPM.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CWdP4bUc.js → block-editor-CnAwmabq.js} +44 -44
- package/dist/gateway/static/root/assets/browser-settings-page-DtVhsHJW.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BQ1Ilw_o.js → browser-workflow-inputs-BX1-uM9L.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CJh4NyxT.js → browser-workflows-page-CcbUOWDF.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel--sXeylhe.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-AXSBDujZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-Ohhee4vm.js → channels-status-swr-CX-yWwLD.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BOtoKTK3.js → chat-terminal-dock-CryTDNdD.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-HBHUWohz.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DTj1V3Sw.js → cron-expression-ji5aWrjG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Yr6OCvGL.js → date-picker-Dro_w3eX.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-Ce19KKnX.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-DbGzggPF.js → desktop-pet-DsSi-3uZ.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-8WQ4woJy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DgTtk4KC.js → extension-debug-page-CgvEBfLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DtQeiP6f.js → extension-page-DkznBbMj.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BOjhchK2.js +1 -0
- package/dist/gateway/static/root/assets/files-BArWTfr7.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-OEruhhX3.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DXuXtU1w.js → gateway-config-swr-CMNbl0FZ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BgH3A0LO.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CzBzglzQ.js → gateway-startup-retry-CR7Xg8As.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C97naDkO.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BBKKme4G.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-TIgsn04n.js → image-generation-api-C5mn73ca.js} +1 -1
- package/dist/gateway/static/root/assets/index-BcaF-dgQ.js +72 -0
- package/dist/gateway/static/root/assets/index-DAryGvZ7.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-wsWuoa8p.js → keyboard-shortcuts-settings-BYhfzsqe.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DNncc2tn.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CXrbrGo8.js → local-apps-page-vBlknU7C.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BJFLQY8O.js → locale-store-CF4erhjB.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CizZInrT.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-BdJZFR7U.js → management-settings-Dnx6mSNe.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-NK3ACVG2.js → markdown-split-DtBtcHWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DTF9v1gg.js → markdown-view-CQvzsE24.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-F0jcUxyl.js → media-plugins-DrMYeHe7.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +3 -0
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-AKgGy3Kx.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-Bw3jD9Jf.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-Dpqq7Z-J.js +8 -0
- package/dist/gateway/static/root/assets/page-tabs-CX9T71by.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-DvEHoimN.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-CxGGlWA8.js → product-open-page-COcr_NUJ.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BuT6MCTs.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DXWMxOjf.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CIsNlSBi.js → registry-api-BsRBlji7.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-7rBCUWzZ.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-YkjhiQfA.js → runtime-tools-settings-panel-CQ13P-mS.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-oFGf3G3s.js → schema-form-BUVyTpZj.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-gmEOYNb4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DYYoJcl7.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-DVY-8_B9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-C7VWs0IT.js → settings-page-CdiVYyTl.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BhenBnUj.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-t5oz18rh.js → share-preview-page-C88YLKm4.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Dq7xIj0_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-MDI9Lz6z.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DLir1nM0.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-DEDTYs2W.js → skills-page.utils-BMZAfS3G.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-BM8ivYan.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-P0_RldWv.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-O597U8q_.js → theme-store-BOgkc_9D.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-DemxChjo.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-B5eUJ6Zq.js → use-autosave-CV3Ui5hu.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CxfnoRVn.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CMKSwz4C.js → voice-api-key-field-CUoCi4Sq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-q7B6fOFB.js → voice-config-api-C-ryeIxj.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-BhDlkCMB.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DZmvLZjb.js → workflow-run-setup-panel-D8CcPc_C.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bxn2Dc16.js +5 -0
- package/dist/gateway/static/root/index.html +11 -27
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/user-message-display.js +18 -0
- package/dist/src/agent/agent-instance-gateway.d.ts +3 -3
- package/dist/src/agent/agent-manager.d.ts +13 -13
- package/dist/src/agent/agent-manager.js +76 -42
- package/dist/src/agent/background-review/coordinator.d.ts +2 -4
- package/dist/src/agent/background-review/coordinator.js +5 -30
- package/dist/src/agent/background-review/prompts.d.ts +4 -2
- package/dist/src/agent/background-review/prompts.js +33 -19
- package/dist/src/agent/background-review/run-background-review.d.ts +6 -7
- package/dist/src/agent/background-review/run-background-review.js +47 -41
- package/dist/src/agent/background-review/settings.d.ts +0 -1
- package/dist/src/agent/background-review/settings.js +6 -7
- package/dist/src/agent/context/audit.d.ts +38 -0
- package/dist/src/agent/context/audit.js +123 -0
- package/dist/src/agent/context/coordinator.d.ts +31 -0
- package/dist/src/agent/context/coordinator.js +73 -0
- package/dist/src/agent/context/execution-context.d.ts +13 -0
- package/dist/src/agent/context/execution-context.js +211 -0
- package/dist/src/agent/context/execution-context.types.d.ts +50 -0
- package/dist/src/agent/context/execution-scope.d.ts +5 -1
- package/dist/src/agent/context/execution-scope.js +6 -2
- package/dist/src/agent/context/prepend.d.ts +2 -0
- package/dist/src/agent/context/prepend.js +28 -0
- package/dist/src/agent/context/project-context.d.ts +6 -3
- package/dist/src/agent/context/project-context.js +28 -23
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -0
- package/dist/src/agent/embedded/run-turn.js +22 -2
- package/dist/src/agent/embedded/types.d.ts +1 -25
- package/dist/src/agent/external-tools/composio-provider.js +87 -92
- package/dist/src/agent/external-tools/gateway-tools.d.ts +4 -1
- package/dist/src/agent/external-tools/gateway-tools.js +153 -41
- package/dist/src/agent/external-tools/index.d.ts +1 -0
- package/dist/src/agent/external-tools/index.js +2 -1
- package/dist/src/agent/external-tools/memory-provider.d.ts +1 -0
- package/dist/src/agent/external-tools/memory-provider.js +1 -0
- package/dist/src/agent/external-tools/search-error.d.ts +12 -0
- package/dist/src/agent/external-tools/search-error.js +29 -0
- package/dist/src/agent/external-tools/service.d.ts +4 -0
- package/dist/src/agent/external-tools/service.js +22 -2
- package/dist/src/agent/inbound/attachment-pipeline.js +5 -1
- package/dist/src/agent/memory/compaction-policy.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -0
- package/dist/src/agent/memory/compaction-promotion.js +52 -79
- package/dist/src/agent/memory/create-memory-manager.js +1 -3
- package/dist/src/agent/memory/index.d.ts +1 -6
- package/dist/src/agent/memory/index.js +3 -6
- package/dist/src/agent/memory/manager.d.ts +0 -16
- package/dist/src/agent/memory/manager.js +11 -40
- package/dist/src/agent/memory/memory-config.d.ts +0 -5
- package/dist/src/agent/memory/memory-config.js +2 -9
- package/dist/src/agent/memory/runtime.d.ts +2 -2
- package/dist/src/agent/memory/runtime.js +9 -19
- package/dist/src/agent/memory/types.d.ts +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +13 -21
- package/dist/src/agent/orchestration/context-overflow.js +1 -0
- package/dist/src/agent/prompt/sections/memory-skills.js +25 -36
- package/dist/src/agent/prompt/sections/tooling.js +10 -4
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -3
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +8 -25
- package/dist/src/agent/service/process-direct-streaming.js +8 -7
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/tasks/task-judge-service.js +1 -1
- package/dist/src/agent/tools/clarify-tool.d.ts +1 -0
- package/dist/src/agent/tools/delegate-tool.js +5 -2
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +68 -21
- package/dist/src/agent/tools/index.d.ts +3 -2
- package/dist/src/agent/tools/index.js +4 -3
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +15 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +184 -0
- package/dist/src/agent/tools/{dreaming-tool.d.ts → memory-maintenance-tool.d.ts} +2 -2
- package/dist/src/agent/tools/memory-maintenance-tool.js +31 -0
- package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-search-tool.js +7 -0
- package/dist/src/agent/tools/user-context-tool.d.ts +10 -0
- package/dist/src/agent/tools/user-context-tool.js +98 -0
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/automations/service/automation-service.d.ts +2 -1
- package/dist/src/automations/service/automation-service.js +6 -2
- package/dist/src/chat-commands/builtins/understanding.js +24 -6
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +68 -75
- package/dist/src/config/schema.js +29 -18
- package/dist/src/config/web-patch.d.ts +1 -1
- package/dist/src/connectors/auth-provider-registry.js +1 -1
- package/dist/src/connectors/composio-managed-client.js +6 -2
- package/dist/src/connectors/connected-source-ingestion.js +1 -1
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -3
- package/dist/src/connectors/connected-source-understanding.js +86 -99
- package/dist/src/connectors/connection-candidates.d.ts +11 -0
- package/dist/src/connectors/connection-candidates.js +58 -0
- package/dist/src/connectors/connection-capabilities.d.ts +4 -0
- package/dist/src/connectors/connection-capabilities.js +37 -0
- package/dist/src/connectors/connection-recovery-service.d.ts +43 -0
- package/dist/src/connectors/connection-recovery-service.js +420 -0
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/learning-coordinator.d.ts +0 -2
- package/dist/src/connectors/learning-coordinator.js +6 -7
- package/dist/src/connectors/principal.d.ts +5 -0
- package/dist/src/connectors/principal.js +18 -0
- package/dist/src/files/file-service.js +4 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +28 -10
- package/dist/src/gateway/agent-builtin-tools.js +30 -9
- package/dist/src/gateway/chat-stream/mapper.js +1 -28
- package/dist/src/gateway/chat-stream/protocol.d.ts +2 -24
- package/dist/src/gateway/clarify-bridge.d.ts +4 -0
- package/dist/src/gateway/clarify-bridge.js +9 -4
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +52 -30
- package/dist/src/gateway/hono/lib/config-payload.js +4 -4
- package/dist/src/gateway/hono/middleware/auth.js +1 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +72 -28
- package/dist/src/gateway/hono/routes/connection-waits.d.ts +3 -0
- package/dist/src/gateway/hono/routes/connection-waits.js +58 -0
- package/dist/src/gateway/hono/routes/connectors.js +24 -18
- package/dist/src/gateway/hono/routes/context-sources.d.ts +4 -0
- package/dist/src/gateway/hono/routes/context-sources.js +159 -0
- package/dist/src/gateway/hono/routes/files.js +23 -2
- package/dist/src/gateway/hono/routes/index.js +4 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -4
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +22 -7
- package/dist/src/gateway/hono/routes/projects.js +36 -44
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +15 -1
- package/dist/src/gateway/hono/routes/side-chats.js +13 -2
- package/dist/src/gateway/hono/routes/tasks.js +3 -3
- package/dist/src/gateway/hono/routes/user-model.d.ts +3 -0
- package/dist/src/gateway/hono/routes/user-model.js +480 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +72 -0
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/agent-runner.d.ts +9 -1
- package/dist/src/gateway/service/agent-runner.js +25 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
- package/dist/src/gateway/service/config-coordinator.js +4 -4
- package/dist/src/gateway/service/run-gateway-agent.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +18 -14
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +12 -2
- package/dist/src/gateway/service.d.ts +3 -1
- package/dist/src/gateway/service.js +52 -17
- package/dist/src/gateway/side-chat/manager.d.ts +16 -3
- package/dist/src/gateway/side-chat/manager.js +117 -28
- package/dist/src/gateway/side-chat/run-service.d.ts +2 -0
- package/dist/src/gateway/side-chat/run-service.js +28 -5
- package/dist/src/gateway/side-chat/types.d.ts +9 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +0 -2
- package/dist/src/knowledge/connected-knowledge-pipeline.js +46 -217
- package/dist/src/knowledge-memory/domain.d.ts +36 -0
- package/dist/src/knowledge-memory/index.d.ts +2 -0
- package/dist/src/knowledge-memory/index.js +2 -0
- package/dist/src/knowledge-memory/repository.d.ts +48 -0
- package/dist/src/knowledge-memory/repository.js +168 -0
- package/dist/src/memory-maintenance/index.d.ts +2 -0
- package/dist/src/memory-maintenance/index.js +3 -0
- package/dist/src/memory-maintenance/schedule.d.ts +13 -0
- package/dist/src/memory-maintenance/schedule.js +51 -0
- package/dist/src/memory-maintenance/service.d.ts +28 -0
- package/dist/src/memory-maintenance/service.js +216 -0
- package/dist/src/notes/service.d.ts +1 -0
- package/dist/src/notes/service.js +7 -1
- package/dist/src/notes/types.d.ts +16 -0
- package/dist/src/notifications/planner.js +7 -3
- package/dist/src/proactive/actions/service.d.ts +0 -1
- package/dist/src/proactive/actions/service.js +1 -10
- package/dist/src/proactive/execution/context.d.ts +8 -10
- package/dist/src/proactive/execution/context.js +93 -42
- package/dist/src/proactive/execution/insight.d.ts +4 -1
- package/dist/src/proactive/execution/insight.js +5 -2
- package/dist/src/proactive/execution/repository.d.ts +1 -0
- package/dist/src/proactive/execution/repository.js +9 -1
- package/dist/src/proactive/execution/types.d.ts +0 -1
- package/dist/src/proactive/execution/worker.js +7 -5
- package/dist/src/proactive/inbox/repository.js +8 -2
- package/dist/src/proactive/inbox/service.js +2 -2
- package/dist/src/proactive/inbox/types.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.js +7 -0
- package/dist/src/proactive/index.d.ts +2 -1
- package/dist/src/proactive/index.js +3 -2
- package/dist/src/proactive/maintenance.d.ts +4 -0
- package/dist/src/proactive/maintenance.js +21 -0
- package/dist/src/proactive/scenarios/repository.d.ts +1 -1
- package/dist/src/proactive/scenarios/repository.js +10 -3
- package/dist/src/proactive/scenarios/types.d.ts +7 -0
- package/dist/src/proactive/service.d.ts +7 -0
- package/dist/src/proactive/service.js +17 -1
- package/dist/src/projects/index.d.ts +1 -1
- package/dist/src/projects/index.js +2 -2
- package/dist/src/projects/knowledge-bind.d.ts +1 -0
- package/dist/src/projects/knowledge-bind.js +15 -0
- package/dist/src/projects/project-loop.d.ts +3 -3
- package/dist/src/projects/project-loop.js +4 -4
- package/dist/src/projects/project-service.d.ts +2 -1
- package/dist/src/projects/project-service.js +3 -2
- package/dist/src/projects/project-store.js +2 -1
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/runtime-tools/manager.js +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +5 -2
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +19 -0
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +54 -0
- package/dist/src/storage/sqlite/config-repository.js +1 -1
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +30 -0
- package/dist/src/storage/sqlite/connection-wait-repository.js +338 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +1 -1
- package/dist/src/storage/sqlite/context-evidence-repository.d.ts +24 -0
- package/dist/src/storage/sqlite/context-evidence-repository.js +52 -0
- package/dist/src/storage/sqlite/index.d.ts +3 -5
- package/dist/src/storage/sqlite/index.js +6 -8
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +0 -19
- package/dist/src/storage/sqlite/knowledge-repository.js +1 -90
- package/dist/src/storage/sqlite/migrations/148_user_model_foundation.sql +554 -0
- package/dist/src/storage/sqlite/migrations/149_separate_source_index_from_memory.sql +18 -0
- package/dist/src/storage/sqlite/migrations/150_session_connection_waits.sql +47 -0
- package/dist/src/storage/sqlite/migrations/151_proactive_scope_cleanup.sql +6 -0
- package/dist/src/storage/sqlite/migrations/152_proactive_scenario_contract.sql +140 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.d.ts +2 -1
- package/dist/src/storage/sqlite/notes-repository.js +37 -3
- package/dist/src/storage/sqlite/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +14 -2
- package/dist/src/storage/sqlite/session-input-repository.js +17 -14
- package/dist/src/storage/sqlite/session-instance-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/session-instance-repository.js +6 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-repository.js +7 -6
- package/dist/src/storage/sqlite/transcript-repository.js +3 -2
- package/dist/src/tasks/home-query-service.js +35 -13
- package/dist/src/tasks/index.js +2 -2
- package/dist/src/tasks/project-monitoring-service.d.ts +2 -0
- package/dist/src/tasks/project-monitoring-service.js +4 -1
- package/dist/src/tasks/project-operating-view-service.js +1 -1
- package/dist/src/tasks/task-application-service.js +6 -1
- package/dist/src/tasks/task-context-assembler.js +1 -1
- package/dist/src/tasks/task-context-repository.d.ts +0 -1
- package/dist/src/tasks/task-context-repository.js +1 -1
- package/dist/src/tasks/task-deletion-service.js +1 -1
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tasks/task-read-model-projector.js +1 -1
- package/dist/src/tasks/task-run-coordinator.js +1 -1
- package/dist/src/tasks/task-run-dispatcher.js +1 -1
- package/dist/src/tasks/task-run-repository.js +1 -0
- package/dist/src/tasks/task-signal-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tool-summary.js +2 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/user-context/access-policy.d.ts +11 -0
- package/dist/src/user-context/access-policy.js +26 -0
- package/dist/src/user-context/changes.d.ts +1 -1
- package/dist/src/user-context/config.d.ts +135 -153
- package/dist/src/user-context/config.js +94 -99
- package/dist/src/user-context/relationship-continuity.d.ts +2 -2
- package/dist/src/user-context/relationship-continuity.js +34 -24
- package/dist/src/user-context/sources/activity-clustering.d.ts +9 -3
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/repository.d.ts +1 -21
- package/dist/src/user-context/sources/repository.js +1 -183
- package/dist/src/user-context/sources/types.d.ts +0 -23
- package/dist/src/user-model/capture/executor.d.ts +50 -0
- package/dist/src/user-model/capture/executor.js +230 -0
- package/dist/src/user-model/capture/index.d.ts +2 -0
- package/dist/src/user-model/capture/index.js +3 -0
- package/dist/src/user-model/capture/semantic.d.ts +39 -0
- package/dist/src/user-model/capture/semantic.js +263 -0
- package/dist/src/user-model/domain.d.ts +93 -0
- package/dist/src/user-model/domain.js +33 -0
- package/dist/src/user-model/goals.d.ts +62 -0
- package/dist/src/user-model/goals.js +91 -0
- package/dist/src/user-model/importance.d.ts +11 -0
- package/dist/src/user-model/importance.js +17 -0
- package/dist/src/user-model/index.d.ts +5 -0
- package/dist/src/user-model/index.js +6 -0
- package/dist/src/user-model/repository.d.ts +23 -0
- package/dist/src/user-model/repository.js +268 -0
- package/dist/src/user-model/temporal.d.ts +10 -0
- package/dist/src/user-model/temporal.js +44 -0
- package/dist/src/voice/realtime/memory-context.d.ts +7 -2
- package/dist/src/voice/realtime/memory-context.js +39 -51
- package/dist/src/work-discovery/service.d.ts +3 -14
- package/dist/src/work-discovery/service.js +138 -99
- package/dist/src/work-discovery/types.d.ts +3 -3
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +12 -20
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CUXApfcE.js +0 -1
- package/dist/gateway/static/root/assets/agents-DNq_GKuc.js +0 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-qfwAgyhQ.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-DqQVUpCC.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-dwIqYmXk.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-SkdcSZ0i.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CKCa6TvG.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DSp--zIZ.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CMd2dDrI.js +0 -1
- package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-udWs5Kdm.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DpN3XZg9.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DinCToZh.js +0 -1
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DcguCgsH.js +0 -1
- package/dist/gateway/static/root/assets/eye-CABVeTq0.js +0 -1
- package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +0 -1
- package/dist/gateway/static/root/assets/files-D6vf3S30.js +0 -1
- package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +0 -1
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-Br7lSf6H.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CdPoDMuj.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DHk1hawP.js +0 -1
- package/dist/gateway/static/root/assets/home-page-YGipe_W6.js +0 -1
- package/dist/gateway/static/root/assets/index-D5TQQpeb.js +0 -71
- package/dist/gateway/static/root/assets/index-DReBaaTX.css +0 -2
- package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +0 -1
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CpyvYyrb.js +0 -2
- package/dist/gateway/static/root/assets/local-context-graph-BjUf7fQ9.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CXKy6E_l.js +0 -2
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +0 -1
- package/dist/gateway/static/root/assets/messages-CHNYp8EQ.js +0 -3
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +0 -1
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-3NKCniSp.js +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-nCfkBN8M.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-DuqLahi6.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-C7j9EdQk.js +0 -5
- package/dist/gateway/static/root/assets/oauth-api-8lP_qJpq.js +0 -1
- package/dist/gateway/static/root/assets/oauth-authorization-window-Cdolr2wE.js +0 -1
- package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +0 -1
- package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-CfebYVX0.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-48GvzSVa.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-64xj_s2m.js +0 -1
- package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +0 -1
- package/dist/gateway/static/root/assets/search-DA7gz22f.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CcwcdRN8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BaN84CyW.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-DjWzRk4z.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DVVOCNbr.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DUYbYLi7.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BGyD0gB9.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CjF8DTsN.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-BSYuRgFI.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-YZYSTJH7.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-FKUi9wDL.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BCyiduKd.js +0 -2
- package/dist/gateway/static/root/assets/work-discovery-overlay-jhT2EzeH.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DQC0TpMa.js +0 -5
- package/dist/src/agent/memory/builtin-provider.d.ts +0 -37
- package/dist/src/agent/memory/builtin-provider.js +0 -225
- package/dist/src/agent/memory/context/types.d.ts +0 -40
- package/dist/src/agent/memory/understanding/quality.d.ts +0 -8
- package/dist/src/agent/memory/understanding/quality.js +0 -18
- package/dist/src/agent/memory/understanding/service.d.ts +0 -19
- package/dist/src/agent/memory/understanding/service.js +0 -209
- package/dist/src/agent/memory/understanding/types.d.ts +0 -34
- package/dist/src/agent/memory/user-context-coordinator.d.ts +0 -23
- package/dist/src/agent/memory/user-context-coordinator.js +0 -113
- package/dist/src/agent/tools/dreaming-tool.js +0 -37
- package/dist/src/agent/tools/memory-tool.d.ts +0 -9
- package/dist/src/agent/tools/memory-tool.js +0 -119
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -11
- package/dist/src/gateway/dreaming-automation-reconciler.js +0 -63
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +0 -21
- package/dist/src/gateway/hono/routes/understanding-sources.js +0 -387
- package/dist/src/gateway/hono/routes/you.d.ts +0 -3
- package/dist/src/gateway/hono/routes/you.js +0 -457
- package/dist/src/projects/memory-bind.d.ts +0 -1
- package/dist/src/projects/memory-bind.js +0 -14
- package/dist/src/storage/sqlite/context-consolidation-repository.d.ts +0 -37
- package/dist/src/storage/sqlite/context-consolidation-repository.js +0 -64
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +0 -217
- package/dist/src/storage/sqlite/memory-records-repository.js +0 -715
- package/dist/src/storage/sqlite/remote-context-repository.d.ts +0 -3
- package/dist/src/storage/sqlite/remote-context-repository.js +0 -40
- package/dist/src/storage/sqlite/understanding-focus-exclusions.d.ts +0 -2
- package/dist/src/storage/sqlite/understanding-focus-exclusions.js +0 -24
- package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +0 -49
- package/dist/src/storage/sqlite/user-context-quality-repository.js +0 -118
- package/dist/src/storage/sqlite/user-context-repository.d.ts +0 -85
- package/dist/src/storage/sqlite/user-context-repository.js +0 -535
- package/dist/src/user-context/automatic-context.d.ts +0 -17
- package/dist/src/user-context/automatic-context.js +0 -85
- package/dist/src/user-context/consolidation.d.ts +0 -27
- package/dist/src/user-context/consolidation.js +0 -187
- package/dist/src/user-context/context-objects.d.ts +0 -17
- package/dist/src/user-context/context-objects.js +0 -99
- package/dist/src/user-context/evaluation/harness.d.ts +0 -13
- package/dist/src/user-context/evaluation/harness.js +0 -31
- package/dist/src/user-context/extraction/executor.d.ts +0 -22
- package/dist/src/user-context/extraction/executor.js +0 -142
- package/dist/src/user-context/extraction/repair.d.ts +0 -19
- package/dist/src/user-context/extraction/repair.js +0 -71
- package/dist/src/user-context/extraction/semantic.d.ts +0 -18
- package/dist/src/user-context/extraction/semantic.js +0 -148
- package/dist/src/user-context/focus-lifecycle.d.ts +0 -2
- package/dist/src/user-context/focus-lifecycle.js +0 -26
- package/dist/src/user-context/manual-understanding.d.ts +0 -12
- package/dist/src/user-context/manual-understanding.js +0 -37
- package/dist/src/user-context/planner.d.ts +0 -17
- package/dist/src/user-context/planner.js +0 -465
- package/dist/src/user-context/relationships/indexer.d.ts +0 -13
- package/dist/src/user-context/relationships/indexer.js +0 -185
- package/dist/src/user-context/relationships/service.d.ts +0 -22
- package/dist/src/user-context/relationships/service.js +0 -50
- package/dist/src/user-context/retriever.d.ts +0 -15
- package/dist/src/user-context/retriever.js +0 -124
- package/dist/src/user-context/scope.d.ts +0 -7
- package/dist/src/user-context/scope.js +0 -9
- package/dist/src/user-context/selection-policy.d.ts +0 -20
- package/dist/src/user-context/selection-policy.js +0 -33
- package/dist/src/user-context/understanding.d.ts +0 -15
- package/dist/src/user-context/understanding.js +0 -24
- package/dist/src/user-context/understandingQuality.d.ts +0 -5
- package/dist/src/user-context/understandingQuality.js +0 -48
- /package/dist/src/agent/{memory/context/types.js → context/execution-context.types.js} +0 -0
- /package/dist/src/{agent/memory/understanding/types.js → knowledge-memory/domain.js} +0 -0
|
@@ -10,15 +10,9 @@ function isValidTimeZone(value) {
|
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
var
|
|
13
|
+
var DEFAULT_CONTEXT_COMPACTION_POLICY, ContextCompactionPolicySchema, WritePolicySchema, MaintenanceTimeSchema, UserModelConfigSchema, KnowledgeMemoryConfigSchema, ContextPlanningConfigSchema, UserContextConfigSchema;
|
|
14
14
|
var init_config = __esmMin((() => {
|
|
15
15
|
init_response_language();
|
|
16
|
-
UserMemoryModeSchema = z.enum([
|
|
17
|
-
"off",
|
|
18
|
-
"readOnly",
|
|
19
|
-
"confirmWrite",
|
|
20
|
-
"auto"
|
|
21
|
-
]);
|
|
22
16
|
DEFAULT_CONTEXT_COMPACTION_POLICY = {
|
|
23
17
|
enabled: true,
|
|
24
18
|
triggerThreshold: .8,
|
|
@@ -54,62 +48,84 @@ var init_config = __esmMin((() => {
|
|
|
54
48
|
maxActiveTranscriptBytes: z.number().int().min(64e3).default(2e6),
|
|
55
49
|
postCompactionSections: z.array(z.string().min(1)).max(12).default(["Session Startup", "Red Lines"])
|
|
56
50
|
}).strict().default(DEFAULT_CONTEXT_COMPACTION_POLICY);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
])).default(["session"]),
|
|
65
|
-
writePolicy: z.object({
|
|
66
|
-
agentProfile: z.enum([
|
|
67
|
-
"deny",
|
|
68
|
-
"confirm",
|
|
69
|
-
"allow"
|
|
70
|
-
]).optional(),
|
|
71
|
-
understanding: z.enum([
|
|
72
|
-
"deny",
|
|
73
|
-
"confirm",
|
|
74
|
-
"allow"
|
|
75
|
-
]).optional(),
|
|
76
|
-
workspace: z.enum([
|
|
77
|
-
"deny",
|
|
78
|
-
"confirm",
|
|
79
|
-
"allow"
|
|
80
|
-
]).optional()
|
|
81
|
-
}).strict().optional(),
|
|
82
|
-
retention: z.object({
|
|
83
|
-
compaction: ContextCompactionPolicySchema,
|
|
84
|
-
maxAgeDays: z.number().int().positive().optional(),
|
|
85
|
-
maxItems: z.number().int().positive().optional(),
|
|
86
|
-
maxChars: z.number().int().positive().optional()
|
|
87
|
-
}).strict().optional()
|
|
88
|
-
}).strict().default({
|
|
89
|
-
mode: "off",
|
|
90
|
-
sources: ["session"]
|
|
91
|
-
});
|
|
92
|
-
UserUnderstandingConfigSchema = z.object({
|
|
51
|
+
WritePolicySchema = z.enum([
|
|
52
|
+
"deny",
|
|
53
|
+
"confirm",
|
|
54
|
+
"allow"
|
|
55
|
+
]);
|
|
56
|
+
MaintenanceTimeSchema = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "Expected time in HH:mm format");
|
|
57
|
+
UserModelConfigSchema = z.object({
|
|
93
58
|
enabled: z.boolean().default(true),
|
|
59
|
+
writePolicy: WritePolicySchema.default("confirm"),
|
|
60
|
+
sensitiveWritePolicy: WritePolicySchema.default("confirm"),
|
|
94
61
|
processingPolicy: z.enum(["local_only", "remote_allowed"]).default("remote_allowed"),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
62
|
+
extraction: z.object({
|
|
63
|
+
reviewIntervalTurns: z.number().int().min(1).max(1e3).default(10),
|
|
64
|
+
maxHistoryMessages: z.number().int().min(1).max(200).default(80),
|
|
65
|
+
maxDurationMs: z.number().int().min(1e3).max(6e5).default(12e4)
|
|
66
|
+
}).strict().default({
|
|
67
|
+
reviewIntervalTurns: 10,
|
|
68
|
+
maxHistoryMessages: 80,
|
|
69
|
+
maxDurationMs: 12e4
|
|
70
|
+
}),
|
|
71
|
+
maintenance: z.object({
|
|
72
|
+
enabled: z.boolean().default(true),
|
|
73
|
+
timezone: z.string().min(1).refine(isValidTimeZone, "Invalid IANA timezone").optional(),
|
|
74
|
+
temporalSweepMinutes: z.number().int().min(15).max(60).refine((value) => 60 % value === 0, "Must divide one hour evenly").default(60),
|
|
75
|
+
dailyTime: MaintenanceTimeSchema.default("03:00"),
|
|
76
|
+
weeklyDay: z.enum([
|
|
77
|
+
"sun",
|
|
78
|
+
"mon",
|
|
79
|
+
"tue",
|
|
80
|
+
"wed",
|
|
81
|
+
"thu",
|
|
82
|
+
"fri",
|
|
83
|
+
"sat"
|
|
84
|
+
]).default("sun"),
|
|
85
|
+
weeklyTime: MaintenanceTimeSchema.default("04:00"),
|
|
86
|
+
evidenceThreshold: z.number().int().min(2).max(10).default(2),
|
|
87
|
+
limit: z.number().int().positive().max(1e4).default(1e3),
|
|
88
|
+
staleRetentionDays: z.number().int().min(1).max(3650).default(30)
|
|
89
|
+
}).strict().default({
|
|
90
|
+
enabled: true,
|
|
91
|
+
temporalSweepMinutes: 60,
|
|
92
|
+
dailyTime: "03:00",
|
|
93
|
+
weeklyDay: "sun",
|
|
94
|
+
weeklyTime: "04:00",
|
|
95
|
+
evidenceThreshold: 2,
|
|
96
|
+
limit: 1e3,
|
|
97
|
+
staleRetentionDays: 30
|
|
98
|
+
})
|
|
99
99
|
}).strict().default({
|
|
100
100
|
enabled: true,
|
|
101
|
+
writePolicy: "confirm",
|
|
102
|
+
sensitiveWritePolicy: "confirm",
|
|
101
103
|
processingPolicy: "remote_allowed",
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
extraction: {
|
|
105
|
+
reviewIntervalTurns: 10,
|
|
106
|
+
maxHistoryMessages: 80,
|
|
107
|
+
maxDurationMs: 12e4
|
|
108
|
+
},
|
|
109
|
+
maintenance: {
|
|
110
|
+
enabled: true,
|
|
111
|
+
temporalSweepMinutes: 60,
|
|
112
|
+
dailyTime: "03:00",
|
|
113
|
+
weeklyDay: "sun",
|
|
114
|
+
weeklyTime: "04:00",
|
|
115
|
+
evidenceThreshold: 2,
|
|
116
|
+
limit: 1e3,
|
|
117
|
+
staleRetentionDays: 30
|
|
118
|
+
}
|
|
106
119
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"confirm",
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
120
|
+
KnowledgeMemoryConfigSchema = z.object({
|
|
121
|
+
enabled: z.boolean().default(true),
|
|
122
|
+
writePolicy: WritePolicySchema.default("confirm"),
|
|
123
|
+
sources: z.array(z.enum([
|
|
124
|
+
"session",
|
|
125
|
+
"workspace",
|
|
126
|
+
"project",
|
|
127
|
+
"connector"
|
|
128
|
+
])).default(["session", "workspace"]),
|
|
113
129
|
searchStrategy: z.enum([
|
|
114
130
|
"local-first",
|
|
115
131
|
"external-first",
|
|
@@ -128,61 +144,40 @@ var init_config = __esmMin((() => {
|
|
|
128
144
|
allowedProviderIds: z.array(z.string().min(1)).optional(),
|
|
129
145
|
autoWriteKinds: z.array(z.string().min(1)).optional()
|
|
130
146
|
}).strict().default({
|
|
147
|
+
enabled: true,
|
|
148
|
+
writePolicy: "confirm",
|
|
149
|
+
sources: ["session", "workspace"],
|
|
131
150
|
searchStrategy: "fanout",
|
|
132
151
|
writeStrategy: "local-first",
|
|
133
152
|
allowExternalWrites: false
|
|
134
153
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
limit: z.number().int().positive().max(2e3).default(500)
|
|
154
|
+
ContextPlanningConfigSchema = z.object({
|
|
155
|
+
enabled: z.boolean().default(true),
|
|
156
|
+
maxAssertions: z.number().int().min(1).max(100).default(20),
|
|
157
|
+
maxKnowledge: z.number().int().min(0).max(100).default(12),
|
|
158
|
+
maxChars: z.number().int().min(500).max(5e4).default(6e3),
|
|
159
|
+
compaction: ContextCompactionPolicySchema
|
|
142
160
|
}).strict().default({
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
enabled: true,
|
|
162
|
+
maxAssertions: 20,
|
|
163
|
+
maxKnowledge: 12,
|
|
164
|
+
maxChars: 6e3,
|
|
165
|
+
compaction: DEFAULT_CONTEXT_COMPACTION_POLICY
|
|
147
166
|
});
|
|
148
167
|
UserContextConfigSchema = z.object({
|
|
149
168
|
enabled: z.boolean().default(true),
|
|
150
169
|
preferences: z.object({ responseLanguage: ResponseLanguageSchema.default("auto") }).strict().default({ responseLanguage: "auto" }),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
providerRouting: UserContextProviderRoutingSchema,
|
|
155
|
-
dreaming: UserContextDreamingSchema
|
|
170
|
+
userModel: UserModelConfigSchema,
|
|
171
|
+
knowledgeMemory: KnowledgeMemoryConfigSchema,
|
|
172
|
+
contextPlanning: ContextPlanningConfigSchema
|
|
156
173
|
}).strict().default({
|
|
157
174
|
enabled: true,
|
|
158
175
|
preferences: { responseLanguage: "auto" },
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
writePolicy: { understanding: "confirm" }
|
|
163
|
-
},
|
|
164
|
-
understanding: {
|
|
165
|
-
enabled: true,
|
|
166
|
-
processingPolicy: "remote_allowed",
|
|
167
|
-
adaptiveCadence: true,
|
|
168
|
-
reviewIntervalTurns: 10,
|
|
169
|
-
maxHistoryMessages: 80,
|
|
170
|
-
maxDurationMs: 12e4
|
|
171
|
-
},
|
|
172
|
-
privacy: { sensitiveWritePolicy: "confirm" },
|
|
173
|
-
providerRouting: {
|
|
174
|
-
searchStrategy: "fanout",
|
|
175
|
-
writeStrategy: "local-first",
|
|
176
|
-
allowExternalWrites: false
|
|
177
|
-
},
|
|
178
|
-
dreaming: {
|
|
179
|
-
mode: "review",
|
|
180
|
-
schedule: { time: "03:00" },
|
|
181
|
-
minEvidenceSources: 2,
|
|
182
|
-
limit: 500
|
|
183
|
-
}
|
|
176
|
+
userModel: UserModelConfigSchema.parse({}),
|
|
177
|
+
knowledgeMemory: KnowledgeMemoryConfigSchema.parse({}),
|
|
178
|
+
contextPlanning: ContextPlanningConfigSchema.parse({})
|
|
184
179
|
});
|
|
185
180
|
}));
|
|
186
181
|
//#endregion
|
|
187
182
|
init_config();
|
|
188
|
-
export { ContextCompactionPolicySchema,
|
|
183
|
+
export { ContextCompactionPolicySchema, ContextPlanningConfigSchema, DEFAULT_CONTEXT_COMPACTION_POLICY, KnowledgeMemoryConfigSchema, UserContextConfigSchema, UserModelConfigSchema, init_config };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type UserAssertion } from '../user-model/index.js';
|
|
2
2
|
export interface RelationshipFollowUpRequest {
|
|
3
3
|
subject: string;
|
|
4
4
|
validFrom?: number;
|
|
@@ -8,4 +8,4 @@ export declare function recordExplicitRelationshipFollowUp(input: {
|
|
|
8
8
|
sessionKey: string;
|
|
9
9
|
message: string;
|
|
10
10
|
nowMs?: number;
|
|
11
|
-
}):
|
|
11
|
+
}): UserAssertion | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createContextEvidence
|
|
2
|
-
import "../
|
|
1
|
+
import { createContextEvidence } from "../storage/sqlite/context-evidence-repository.js";
|
|
2
|
+
import { reconcileAssertion } from "../user-model/repository.js";
|
|
3
|
+
import "../user-model/index.js";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
//#region src/user-context/relationship-continuity.ts
|
|
5
6
|
const CHINESE_FOLLOW_UP_PATTERN = /^(?:请|记得|麻烦|帮我)?\s*(?:明天|下周|之后|到时候)?\s*(?:提醒我|问问我|跟进一下|跟进)(?:关于)?[::,,\s]*(.+)$/;
|
|
@@ -24,35 +25,44 @@ function extractExplicitRelationshipFollowUp(message, nowMs = Date.now()) {
|
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
function recordExplicitRelationshipFollowUp(input) {
|
|
27
|
-
const
|
|
28
|
+
const now = input.nowMs ?? Date.now();
|
|
29
|
+
const request = extractExplicitRelationshipFollowUp(input.message, now);
|
|
28
30
|
if (!request) return null;
|
|
29
|
-
const
|
|
30
|
-
const existing = listUnderstandings().find((item) => item.canonicalKey === canonicalKey && item.scope.type === "global" && item.status !== "rejected" && item.status !== "archived");
|
|
31
|
-
if (existing) return existing;
|
|
32
|
-
const understanding = createUnderstanding({
|
|
33
|
-
kind: "relationship",
|
|
34
|
-
canonicalKey,
|
|
35
|
-
status: "active",
|
|
36
|
-
scope: { type: "global" },
|
|
37
|
-
explicitness: "explicit",
|
|
38
|
-
durability: "recurring",
|
|
39
|
-
sensitivity: "normal",
|
|
40
|
-
disclosurePolicy: "referenceable",
|
|
41
|
-
confidence: 1,
|
|
42
|
-
statement: request.subject,
|
|
43
|
-
...request.validFrom ? { validFrom: request.validFrom } : {},
|
|
44
|
-
createdBy: "user",
|
|
45
|
-
changeReason: "Explicit follow-up request"
|
|
46
|
-
});
|
|
31
|
+
const key = hash(request.subject.toLocaleLowerCase());
|
|
47
32
|
const evidence = createContextEvidence({
|
|
48
33
|
sourceType: "conversation",
|
|
49
34
|
sourceRef: `session:${input.sessionKey}:follow-up:${hash(input.message)}`,
|
|
50
35
|
redactedExcerpt: input.message.slice(0, 600),
|
|
51
36
|
trustLevel: "owner",
|
|
52
|
-
observedAt:
|
|
37
|
+
observedAt: now
|
|
53
38
|
});
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
return reconcileAssertion({
|
|
40
|
+
subject: {
|
|
41
|
+
type: "topic",
|
|
42
|
+
id: key
|
|
43
|
+
},
|
|
44
|
+
predicate: `relationship.follow_up.${key}`,
|
|
45
|
+
cardinality: "single",
|
|
46
|
+
scope: { type: "global" },
|
|
47
|
+
kind: "relationship",
|
|
48
|
+
value: request.subject,
|
|
49
|
+
normalizedValue: request.subject.toLocaleLowerCase(),
|
|
50
|
+
statement: request.subject,
|
|
51
|
+
authority: "user_explicit",
|
|
52
|
+
confidence: 1,
|
|
53
|
+
declaredImportance: .8,
|
|
54
|
+
inferredImportance: .8,
|
|
55
|
+
consequence: "medium",
|
|
56
|
+
actionability: 1,
|
|
57
|
+
volatility: "slow",
|
|
58
|
+
sensitivity: "normal",
|
|
59
|
+
disclosurePolicy: "referenceable",
|
|
60
|
+
...request.validFrom ? { validFrom: request.validFrom } : {},
|
|
61
|
+
observedAt: now,
|
|
62
|
+
createdBy: "user",
|
|
63
|
+
evidenceId: evidence.id,
|
|
64
|
+
evidenceConfidence: 1
|
|
65
|
+
}, now).assertion;
|
|
56
66
|
}
|
|
57
67
|
//#endregion
|
|
58
68
|
export { extractExplicitRelationshipFollowUp, recordExplicitRelationshipFollowUp };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { UnderstandingSourceItem
|
|
2
|
-
export
|
|
1
|
+
import type { UnderstandingSourceItem } from './types.js';
|
|
2
|
+
export interface ActivityTopic {
|
|
3
|
+
canonicalKey: string;
|
|
4
|
+
title: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
horizon: 'current' | 'ongoing' | 'long_term';
|
|
7
|
+
confidence: number;
|
|
8
|
+
evidenceRefs: string[];
|
|
3
9
|
sourceIds: string[];
|
|
4
|
-
}
|
|
10
|
+
}
|
|
5
11
|
export declare function clusterActivityTopics(items: UnderstandingSourceItem[], now?: number): ActivityTopic[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createUnderstandingSourceRun,
|
|
1
|
+
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, revokeUnderstandingSourceGrant, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "./repository.js";
|
|
2
2
|
import { clusterUnderstandingSignals, tokenizeUnderstandingSignal } from "./signal-clustering.js";
|
|
3
3
|
import { listUnderstandingSourceDefinitions } from "./catalog.js";
|
|
4
|
-
export { clusterUnderstandingSignals, createUnderstandingSourceRun,
|
|
4
|
+
export { clusterUnderstandingSignals, createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, revokeUnderstandingSourceGrant, tokenizeUnderstandingSignal, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant };
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { UnderstandingSourceGrant, UnderstandingSourceRun, UserFocus } from './types.js';
|
|
3
|
-
type UserFocusInput = Omit<UserFocus, 'id' | 'versionId' | 'principalId' | 'scope' | 'explicitness' | 'sensitivity' | 'disclosurePolicy' | 'validFrom' | 'validTo' | 'reviewAt' | 'createdAt' | 'updatedAt'> & {
|
|
4
|
-
principalId?: string;
|
|
5
|
-
scope?: UserContextScope;
|
|
6
|
-
explicitness?: UserFocus['explicitness'];
|
|
7
|
-
sensitivity?: UserFocus['sensitivity'];
|
|
8
|
-
disclosurePolicy?: UserFocus['disclosurePolicy'];
|
|
9
|
-
validFrom?: number;
|
|
10
|
-
validTo?: number;
|
|
11
|
-
reviewAt?: number;
|
|
12
|
-
changeReason?: string;
|
|
13
|
-
nowMs?: number;
|
|
14
|
-
};
|
|
15
|
-
export declare function listUserFocusEvidence(focusId: string): ContextEvidence[];
|
|
1
|
+
import type { UnderstandingSourceGrant, UnderstandingSourceRun } from './types.js';
|
|
16
2
|
export declare function listUnderstandingSourceGrants(options?: {
|
|
17
3
|
includeRevoked?: boolean;
|
|
18
4
|
}): UnderstandingSourceGrant[];
|
|
@@ -53,9 +39,3 @@ export declare function updateUnderstandingSourceRun(id: string, patch: {
|
|
|
53
39
|
completed?: boolean;
|
|
54
40
|
nowMs?: number;
|
|
55
41
|
}): UnderstandingSourceRun | null;
|
|
56
|
-
export declare function upsertUserFocus(input: UserFocusInput): UserFocus;
|
|
57
|
-
export declare function listUserFocuses(statuses?: UserFocus['status'][], limit?: number): UserFocus[];
|
|
58
|
-
export declare function getUserFocus(id: string): UserFocus | undefined;
|
|
59
|
-
export declare function updateUserFocus(id: string, patch: Partial<Pick<UserFocus, 'title' | 'summary' | 'status' | 'validFrom' | 'validTo' | 'reviewAt'>>, nowMs?: number): UserFocus | null;
|
|
60
|
-
export declare function deleteUserFocus(id: string): boolean;
|
|
61
|
-
export {};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { USER_CONTEXT_PRINCIPAL_ID } from "../domain.js";
|
|
3
2
|
import { notifyUserContextChange } from "../changes.js";
|
|
4
|
-
import { focusLifecycle } from "../focus-lifecycle.js";
|
|
5
3
|
import { randomUUID } from "node:crypto";
|
|
6
4
|
//#region src/user-context/sources/repository.ts
|
|
7
5
|
function record(value) {
|
|
@@ -11,14 +9,6 @@ function record(value) {
|
|
|
11
9
|
return {};
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
|
-
function strings(value) {
|
|
15
|
-
try {
|
|
16
|
-
const parsed = JSON.parse(value);
|
|
17
|
-
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
18
|
-
} catch {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
12
|
function grantFromRow(row) {
|
|
23
13
|
return {
|
|
24
14
|
id: row.grant_id,
|
|
@@ -53,85 +43,6 @@ function runFromRow(row) {
|
|
|
53
43
|
...row.completed_at == null ? {} : { completedAt: row.completed_at }
|
|
54
44
|
};
|
|
55
45
|
}
|
|
56
|
-
function focusFromRow(row) {
|
|
57
|
-
return {
|
|
58
|
-
id: row.focus_id,
|
|
59
|
-
versionId: row.current_version_id,
|
|
60
|
-
principalId: row.principal_id,
|
|
61
|
-
canonicalKey: row.canonical_key,
|
|
62
|
-
title: row.title,
|
|
63
|
-
summary: row.summary,
|
|
64
|
-
horizon: row.horizon,
|
|
65
|
-
status: row.status,
|
|
66
|
-
confidence: row.confidence,
|
|
67
|
-
scope: {
|
|
68
|
-
type: row.scope_type,
|
|
69
|
-
...row.scope_id ? { id: row.scope_id } : {}
|
|
70
|
-
},
|
|
71
|
-
explicitness: row.explicitness,
|
|
72
|
-
sensitivity: row.sensitivity,
|
|
73
|
-
disclosurePolicy: row.disclosure_policy,
|
|
74
|
-
...row.valid_from == null ? {} : { validFrom: row.valid_from },
|
|
75
|
-
...row.valid_to == null ? {} : { validTo: row.valid_to },
|
|
76
|
-
...row.review_at == null ? {} : { reviewAt: row.review_at },
|
|
77
|
-
evidenceRefs: strings(row.evidence_refs_json),
|
|
78
|
-
...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
|
|
79
|
-
createdAt: row.created_at,
|
|
80
|
-
updatedAt: row.updated_at
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function focusSnapshot(row) {
|
|
84
|
-
return {
|
|
85
|
-
horizon: row.horizon,
|
|
86
|
-
status: row.status,
|
|
87
|
-
confidence: row.confidence,
|
|
88
|
-
scopeType: row.scope_type,
|
|
89
|
-
scopeId: row.scope_id,
|
|
90
|
-
explicitness: row.explicitness,
|
|
91
|
-
sensitivity: row.sensitivity,
|
|
92
|
-
disclosurePolicy: row.disclosure_policy,
|
|
93
|
-
validFrom: row.valid_from,
|
|
94
|
-
validTo: row.valid_to,
|
|
95
|
-
reviewAt: row.review_at,
|
|
96
|
-
evidenceRefs: strings(row.evidence_refs_json)
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function sameFocusVersion(left, right) {
|
|
100
|
-
return Boolean(left && left.title === right.title && left.summary === right.summary && JSON.stringify(focusSnapshot(left)) === JSON.stringify(focusSnapshot(right)));
|
|
101
|
-
}
|
|
102
|
-
function linkFocusEvidence(versionId, evidenceRefs, confidence) {
|
|
103
|
-
if (!evidenceRefs.length) return;
|
|
104
|
-
const placeholders = evidenceRefs.map(() => "?").join(", ");
|
|
105
|
-
getSqliteDatabase().prepare(`INSERT OR IGNORE INTO user_focus_evidence_links (
|
|
106
|
-
version_id, evidence_id, relation, confidence
|
|
107
|
-
) SELECT ?, evidence_id, 'supports', ? FROM context_evidence WHERE source_ref IN (${placeholders})`).run(versionId, confidence, ...evidenceRefs);
|
|
108
|
-
}
|
|
109
|
-
function listUserFocusEvidence(focusId) {
|
|
110
|
-
return getSqliteDatabase().prepare(`SELECT DISTINCT e.* FROM context_evidence e
|
|
111
|
-
JOIN user_focus_evidence_links l ON l.evidence_id = e.evidence_id
|
|
112
|
-
JOIN user_focus_versions v ON v.version_id = l.version_id
|
|
113
|
-
WHERE v.focus_id = ? ORDER BY e.observed_at DESC`).all(focusId).map((row) => ({
|
|
114
|
-
id: row.evidence_id,
|
|
115
|
-
sourceType: row.source_type,
|
|
116
|
-
...row.source_instance_id ? { sourceInstanceId: row.source_instance_id } : {},
|
|
117
|
-
sourceRef: row.source_ref,
|
|
118
|
-
...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
|
|
119
|
-
...row.source_item_id ? { sourceItemId: row.source_item_id } : {},
|
|
120
|
-
...row.session_id ? { sessionId: row.session_id } : {},
|
|
121
|
-
...row.turn_id ? { turnId: row.turn_id } : {},
|
|
122
|
-
...row.message_id ? { messageId: row.message_id } : {},
|
|
123
|
-
...row.content_hash ? { contentHash: row.content_hash } : {},
|
|
124
|
-
...row.retention_policy ? { retentionPolicy: row.retention_policy } : {},
|
|
125
|
-
...row.processing_policy ? { processingPolicy: row.processing_policy } : {},
|
|
126
|
-
...row.extractor_id ? { extractorId: row.extractor_id } : {},
|
|
127
|
-
...row.extractor_version ? { extractorVersion: row.extractor_version } : {},
|
|
128
|
-
...row.redacted_excerpt ? { redactedExcerpt: row.redacted_excerpt } : {},
|
|
129
|
-
trustLevel: row.trust_level,
|
|
130
|
-
observedAt: row.observed_at,
|
|
131
|
-
ingestedAt: row.ingested_at ?? row.created_at,
|
|
132
|
-
createdAt: row.created_at
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
46
|
function listUnderstandingSourceGrants(options = {}) {
|
|
136
47
|
return getSqliteDatabase().prepare(`SELECT * FROM understanding_source_grants ${options.includeRevoked ? "" : "WHERE status = 'active'"} ORDER BY updated_at DESC`).all().map(grantFromRow);
|
|
137
48
|
}
|
|
@@ -213,98 +124,5 @@ function updateUnderstandingSourceRun(id, patch) {
|
|
|
213
124
|
`).run(patch.status ?? current.status, patch.cursorAfter ?? current.cursorAfter ?? null, patch.itemsSeen ?? current.itemsSeen, JSON.stringify(patch.metadata ?? current.metadata), patch.errorMessage ?? current.errorMessage ?? null, completedAt, id));
|
|
214
125
|
return getUnderstandingSourceRun(id);
|
|
215
126
|
}
|
|
216
|
-
function upsertUserFocus(input) {
|
|
217
|
-
const id = randomUUID();
|
|
218
|
-
const now = input.nowMs ?? Date.now();
|
|
219
|
-
const scope = input.scope ?? { type: "global" };
|
|
220
|
-
const explicitness = input.explicitness ?? "inferred";
|
|
221
|
-
const sensitivity = input.sensitivity ?? "normal";
|
|
222
|
-
const disclosurePolicy = input.disclosurePolicy ?? "referenceable";
|
|
223
|
-
const existingRow = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey);
|
|
224
|
-
if (existingRow?.explicitness === "explicit" && explicitness !== "explicit") return focusFromRow(existingRow);
|
|
225
|
-
if (existingRow) notifyUserContextChange({
|
|
226
|
-
kind: "focus",
|
|
227
|
-
id: existingRow.focus_id
|
|
228
|
-
});
|
|
229
|
-
let currentVersionId = existingRow?.current_version_id;
|
|
230
|
-
runSqliteWriteTransaction((db) => {
|
|
231
|
-
db.prepare(`
|
|
232
|
-
INSERT INTO user_focuses (
|
|
233
|
-
focus_id, principal_id, canonical_key, title, summary, horizon, status, confidence,
|
|
234
|
-
scope_type, scope_id, explicitness, sensitivity, disclosure_policy,
|
|
235
|
-
valid_from, valid_to, review_at, evidence_refs_json, source_run_id, created_at, updated_at
|
|
236
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
237
|
-
ON CONFLICT(canonical_key) DO UPDATE SET title = excluded.title, summary = excluded.summary,
|
|
238
|
-
horizon = excluded.horizon,
|
|
239
|
-
status = CASE
|
|
240
|
-
WHEN user_focuses.status IN ('active', 'paused', 'completed', 'rejected') AND excluded.status = 'candidate'
|
|
241
|
-
THEN user_focuses.status
|
|
242
|
-
ELSE excluded.status
|
|
243
|
-
END,
|
|
244
|
-
confidence = excluded.confidence,
|
|
245
|
-
scope_type = excluded.scope_type, scope_id = excluded.scope_id,
|
|
246
|
-
explicitness = excluded.explicitness, sensitivity = excluded.sensitivity,
|
|
247
|
-
disclosure_policy = excluded.disclosure_policy, valid_from = excluded.valid_from,
|
|
248
|
-
valid_to = excluded.valid_to, review_at = excluded.review_at,
|
|
249
|
-
evidence_refs_json = excluded.evidence_refs_json,
|
|
250
|
-
source_run_id = excluded.source_run_id, updated_at = excluded.updated_at
|
|
251
|
-
`).run(id, input.principalId ?? "local-owner", input.canonicalKey, input.title, input.summary, input.horizon, input.status, input.confidence, scope.type, scope.id ?? null, explicitness, sensitivity, disclosurePolicy, input.validFrom ?? null, input.validTo ?? null, input.reviewAt ?? null, JSON.stringify(input.evidenceRefs), input.sourceRunId ?? null, now, now);
|
|
252
|
-
const nextRow = db.prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey);
|
|
253
|
-
if (!sameFocusVersion(existingRow, nextRow)) {
|
|
254
|
-
currentVersionId = randomUUID();
|
|
255
|
-
db.prepare(`INSERT INTO user_focus_versions (
|
|
256
|
-
version_id, focus_id, title, summary, snapshot_json, created_by, change_reason, created_at
|
|
257
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(currentVersionId, nextRow.focus_id, nextRow.title, nextRow.summary, JSON.stringify(focusSnapshot(nextRow)), explicitness === "explicit" ? "user" : input.sourceRunId ? "connector" : "runtime", input.changeReason ?? (existingRow ? "Focus updated" : "Focus created"), now);
|
|
258
|
-
db.prepare("UPDATE user_focuses SET current_version_id = ? WHERE focus_id = ?").run(currentVersionId, nextRow.focus_id);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
if (currentVersionId) linkFocusEvidence(currentVersionId, input.evidenceRefs, input.confidence);
|
|
262
|
-
return focusFromRow(getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey));
|
|
263
|
-
}
|
|
264
|
-
function listUserFocuses(statuses, limit) {
|
|
265
|
-
const maxRows = limit === void 0 ? -1 : Math.max(1, Math.min(200, Math.floor(limit)));
|
|
266
|
-
if (!statuses?.length) return getSqliteDatabase().prepare("SELECT * FROM user_focuses ORDER BY updated_at DESC LIMIT ?").all(maxRows).map(focusFromRow);
|
|
267
|
-
const placeholders = statuses.map(() => "?").join(", ");
|
|
268
|
-
return getSqliteDatabase().prepare(`SELECT * FROM user_focuses WHERE status IN (${placeholders}) ORDER BY updated_at DESC LIMIT ?`).all(...statuses, maxRows).map(focusFromRow);
|
|
269
|
-
}
|
|
270
|
-
function getUserFocus(id) {
|
|
271
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ? AND principal_id = ?").get(id, USER_CONTEXT_PRINCIPAL_ID);
|
|
272
|
-
return row ? focusFromRow(row) : void 0;
|
|
273
|
-
}
|
|
274
|
-
function updateUserFocus(id, patch, nowMs = Date.now()) {
|
|
275
|
-
notifyUserContextChange({
|
|
276
|
-
kind: "focus",
|
|
277
|
-
id
|
|
278
|
-
});
|
|
279
|
-
const currentRow = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
|
|
280
|
-
if (!currentRow) return null;
|
|
281
|
-
const current = focusFromRow(currentRow);
|
|
282
|
-
const renewedLifecycle = patch.status === "active" && (current.status !== "active" || current.reviewAt !== void 0 && current.reviewAt <= nowMs || current.validTo !== void 0 && current.validTo <= nowMs) ? focusLifecycle(current.horizon, nowMs) : {};
|
|
283
|
-
const nextValidFrom = patch.validFrom ?? renewedLifecycle.validFrom ?? current.validFrom;
|
|
284
|
-
const nextValidTo = patch.validTo ?? renewedLifecycle.validTo ?? current.validTo;
|
|
285
|
-
const nextReviewAt = patch.reviewAt ?? renewedLifecycle.reviewAt ?? current.reviewAt;
|
|
286
|
-
if ((patch.title ?? current.title) === current.title && (patch.summary ?? current.summary) === current.summary && (patch.status ?? current.status) === current.status && nextValidFrom === current.validFrom && nextValidTo === current.validTo && nextReviewAt === current.reviewAt) return current;
|
|
287
|
-
const versionId = randomUUID();
|
|
288
|
-
runSqliteWriteTransaction((db) => {
|
|
289
|
-
db.prepare(`UPDATE user_focuses
|
|
290
|
-
SET title = ?, summary = ?, status = ?, valid_from = ?, valid_to = ?, review_at = ?, updated_at = ?
|
|
291
|
-
WHERE focus_id = ?`).run(patch.title ?? current.title, patch.summary ?? current.summary, patch.status ?? current.status, nextValidFrom ?? null, nextValidTo ?? null, nextReviewAt ?? null, nowMs, id);
|
|
292
|
-
const nextRow = db.prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
|
|
293
|
-
db.prepare(`INSERT INTO user_focus_versions (
|
|
294
|
-
version_id, focus_id, title, summary, snapshot_json, created_by, change_reason, created_at
|
|
295
|
-
) VALUES (?, ?, ?, ?, ?, ?, 'Focus updated', ?)`).run(versionId, id, nextRow.title, nextRow.summary, JSON.stringify(focusSnapshot(nextRow)), current.explicitness === "explicit" ? "user" : "runtime", nowMs);
|
|
296
|
-
db.prepare("UPDATE user_focuses SET current_version_id = ? WHERE focus_id = ?").run(versionId, id);
|
|
297
|
-
});
|
|
298
|
-
linkFocusEvidence(versionId, current.evidenceRefs, current.confidence);
|
|
299
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
|
|
300
|
-
return row ? focusFromRow(row) : null;
|
|
301
|
-
}
|
|
302
|
-
function deleteUserFocus(id) {
|
|
303
|
-
notifyUserContextChange({
|
|
304
|
-
kind: "focus",
|
|
305
|
-
id
|
|
306
|
-
});
|
|
307
|
-
return Number(getSqliteDatabase().prepare("DELETE FROM user_focuses WHERE focus_id = ?").run(id).changes) > 0;
|
|
308
|
-
}
|
|
309
127
|
//#endregion
|
|
310
|
-
export { createUnderstandingSourceRun,
|
|
128
|
+
export { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, revokeUnderstandingSourceGrant, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { UserContextScope, UserUnderstanding } from '../domain.js';
|
|
2
1
|
export type UnderstandingSourcePlatform = 'darwin' | 'win32' | 'linux' | 'all';
|
|
3
2
|
export type UnderstandingSourceCategory = 'files' | 'recent_documents' | 'calendar' | 'tasks' | 'notes' | 'mail' | 'messages' | 'code_activity';
|
|
4
3
|
export type UnderstandingSourceAccessMode = 'once' | 'continuous';
|
|
@@ -74,25 +73,3 @@ export interface UnderstandingSourceRun {
|
|
|
74
73
|
startedAt: number;
|
|
75
74
|
completedAt?: number;
|
|
76
75
|
}
|
|
77
|
-
export interface UserFocus {
|
|
78
|
-
id: string;
|
|
79
|
-
versionId: string;
|
|
80
|
-
principalId: string;
|
|
81
|
-
canonicalKey: string;
|
|
82
|
-
title: string;
|
|
83
|
-
summary: string;
|
|
84
|
-
horizon: 'current' | 'ongoing' | 'long_term';
|
|
85
|
-
status: 'candidate' | 'active' | 'paused' | 'completed' | 'rejected';
|
|
86
|
-
confidence: number;
|
|
87
|
-
scope: UserContextScope;
|
|
88
|
-
explicitness: UserUnderstanding['explicitness'];
|
|
89
|
-
sensitivity: UserUnderstanding['sensitivity'];
|
|
90
|
-
disclosurePolicy: UserUnderstanding['disclosurePolicy'];
|
|
91
|
-
validFrom?: number;
|
|
92
|
-
validTo?: number;
|
|
93
|
-
reviewAt?: number;
|
|
94
|
-
evidenceRefs: string[];
|
|
95
|
-
sourceRunId?: string;
|
|
96
|
-
createdAt: number;
|
|
97
|
-
updatedAt: number;
|
|
98
|
-
}
|