@xopcai/xopc 0.0.247 → 0.0.249
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/src/update-offset-store.js +17 -54
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/auth/accounts.js +3 -5
- package/dist/extensions/weixin/src/monitor/monitor.js +3 -5
- package/dist/extensions/weixin/src/storage/sync-buf.d.ts +3 -6
- package/dist/extensions/weixin/src/storage/sync-buf.js +9 -22
- package/dist/gateway/static/root/assets/{activity-store-BlxqErph.js → activity-store-B759R_qf.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DmaFeojS.js → agent-avatar-dicebear-BUu7EnwM.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C1rXNUAG.js +1 -0
- package/dist/gateway/static/root/assets/agents-DK9HjHO0.js +1 -0
- package/dist/gateway/static/root/assets/{api-BbXzyQMj.js → api-Cg0v7Lpn.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-C9DkCW_d.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-CFggS95Y.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-jOvT-fzU.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DD2SweEH.js → archive-plugin-BQrilVVv.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BG82bNBQ.js → attachment-load-BG0BliqV.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CqBZ89He.js → automations-page-Bo4RiTkh.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BKjKTlW8.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B6LKm5Zv.js → binary-plugins-BCnyNU0C.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BJKvGVXd.js → block-editor-Db8DlVvg.js} +50 -50
- package/dist/gateway/static/root/assets/browser-settings-page-Dzq18pO1.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BAAc151l.js → browser-workflow-inputs-C71vfl0b.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DoE4Uuns.js → browser-workflows-page-vvmSYKsO.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DW4SBQf4.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-57OGuewD.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CCBCtLDg.js → channels-status-swr-CKyV3jY5.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BsRWnz7M.js → chat-terminal-dock-B1Xd6OFB.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-CT_I3kbR.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DdCgsH2c.js → cron-expression-D-F9vjtE.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-dt37Lt8e.js → date-picker-B2OoYvic.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-BiGx9Sbj.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-Nw_Pgkk3.js → desktop-pet-BNMRqipe.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DeYbIV7A.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BHSst0WN.js → extension-debug-page-COyn05ub.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DXbL4cQZ.js → extension-page-oH43chS2.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BMO59994.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-cimpViGk.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-826dipyU.js → gateway-config-swr-BGdHwT4e.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BHJtnSic.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DyvcAIMm.js → gateway-startup-retry-CuaM3b4c.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DNhrZHqx.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BiHwiBnQ.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D7cyfks6.js → image-generation-api-D7duj7Uj.js} +1 -1
- package/dist/gateway/static/root/assets/index-DGeGmj4k.css +2 -0
- package/dist/gateway/static/root/assets/index-aBs0EfQB.js +72 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-EY4cu-6W.js → keyboard-shortcuts-settings-D8Zw_lYd.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-eBFVWmtH.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-Dh7OxX0S.js → local-apps-page-CvPDPRwb.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CBoCuIMx.js → locale-store-zEL8bkwx.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-ClvcWlL6.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-ZjiL3A-S.js → management-settings-D8moh99U.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-B4BxkTpU.js → markdown-split-D7V3j0vE.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BXsHghJd.js → markdown-view-DGRN-8wP.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D15XBiEo.js → media-plugins-BLaE5b1Y.js} +1 -1
- package/dist/gateway/static/root/assets/messages-W5P19VTF.js +11 -0
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-DiVDuCxl.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-CEEvR-fV.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BLqgXNCx.js +8 -0
- package/dist/gateway/static/root/assets/page-tabs-BFMGjA60.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-DNEWZN7H.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-CAJeUXeU.js → product-open-page-Co5u7asH.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CIiFJ5tk.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B3UF-Pfm.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BhGKnvLP.js → registry-api-Cg92zSod.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUtpkJPG.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BhKcyEId.js → runtime-tools-settings-panel-C0ByNmlV.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-L0s7RWCi.js → schema-form-Dq_VQpuY.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-UgJmG-V4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDCzpdkl.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-CZu6FX4k.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-CTKoztlF.js → settings-page-S8ekeUZd.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BdVmwXMv.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CiiLLz5A.js → share-preview-page-D2fEidbn.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BdsqnCYj.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-ghzAQKna.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-AYiPlgZE.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-CwRekJSJ.js → skills-page.utils-DGzl-ib-.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-5Xd5mIiR.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-BQAUaCDD.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-hybK3oC9.js → theme-store-ZVClZKQ0.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-CdZN1Jin.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-DX5YZ3Nn.js → use-autosave-czRI0NBc.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-W3GTm6nA.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-ocnZbAyi.js → voice-api-key-field-8YEvA3cU.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CBbiF1T3.js → voice-config-api-CopF64lY.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-keLtqYYJ.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DaErGvxO.js → workflow-run-setup-panel-Dy5WgYMO.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BbAV3h7n.js +5 -0
- package/dist/gateway/static/root/index.html +10 -26
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-instance-gateway.d.ts +2 -2
- package/dist/src/agent/agent-manager.d.ts +4 -4
- package/dist/src/agent/agent-manager.js +31 -15
- 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 +24 -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/commands/command-registry.d.ts +1 -0
- package/dist/src/agent/commands/command-registry.js +12 -22
- package/dist/src/agent/context/audit.d.ts +36 -0
- package/dist/src/agent/context/audit.js +97 -0
- package/dist/src/agent/context/coordinator.d.ts +26 -0
- package/dist/src/agent/context/coordinator.js +72 -0
- package/dist/src/agent/context/execution-context.d.ts +54 -0
- package/dist/src/agent/context/execution-context.js +147 -0
- package/dist/src/agent/context/execution-scope.js +1 -1
- 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 +3 -3
- package/dist/src/agent/context/project-context.js +26 -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.js +1 -1
- 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/ipc/inbox.d.ts +8 -31
- package/dist/src/agent/ipc/inbox.js +64 -133
- package/dist/src/agent/memory/compaction-policy.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.js +45 -77
- package/dist/src/agent/memory/create-memory-manager.js +1 -3
- package/dist/src/agent/memory/index.d.ts +0 -5
- package/dist/src/agent/memory/index.js +2 -5
- 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.js +1 -1
- 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/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.js +6 -23
- package/dist/src/agent/service/process-direct-one-shot.js +15 -10
- package/dist/src/agent/service/process-direct-streaming.js +5 -3
- 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.js +36 -19
- 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 +9 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +129 -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/user-context-tool.d.ts +8 -0
- package/dist/src/agent/tools/user-context-tool.js +81 -0
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent/workflow/catalog.d.ts +1 -8
- package/dist/src/agent/workflow/catalog.js +44 -102
- package/dist/src/agent/workflow/index.d.ts +1 -1
- package/dist/src/agent/workflow/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/automations/service/automation-service.js +2 -2
- package/dist/src/channels/manager.d.ts +1 -1
- package/dist/src/channels/manager.js +2 -2
- package/dist/src/channels/outbound/persist-store.d.ts +2 -8
- package/dist/src/channels/outbound/persist-store.js +11 -38
- package/dist/src/channels/outbound-sender.d.ts +1 -1
- package/dist/src/channels/outbound-sender.js +2 -2
- package/dist/src/chat-commands/builtins/understanding.js +24 -6
- 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 +31 -20
- package/dist/src/config/web-patch.d.ts +1 -1
- package/dist/src/connectors/composio-managed-client.js +6 -2
- package/dist/src/connectors/composio-triggers.d.ts +2 -2
- package/dist/src/connectors/composio-triggers.js +8 -15
- 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 +42 -0
- package/dist/src/connectors/connection-recovery-service.js +396 -0
- 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/gateway/agent-builtin-tools.d.ts +28 -10
- package/dist/src/gateway/agent-builtin-tools.js +30 -9
- package/dist/src/gateway/automation-agent-session.js +3 -0
- 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/lib/extension-store.js +8 -25
- package/dist/src/gateway/hono/middleware/auth.js +1 -2
- 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 +4 -12
- 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/index.js +4 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -4
- package/dist/src/gateway/hono/routes/notes.js +22 -7
- package/dist/src/gateway/hono/routes/projects.js +37 -45
- 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 +2 -2
- 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/hono/routes/workflows.js +2 -2
- 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/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 +49 -19
- 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 +35 -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 +45 -0
- package/dist/src/knowledge-memory/repository.js +154 -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/index.d.ts +1 -1
- package/dist/src/notes/index.js +2 -2
- package/dist/src/notes/paths.d.ts +0 -3
- package/dist/src/notes/paths.js +1 -10
- package/dist/src/notes/service.d.ts +1 -1
- package/dist/src/notes/service.js +7 -4
- package/dist/src/notes/store.d.ts +0 -2
- package/dist/src/notes/store.js +33 -80
- package/dist/src/notes/types.d.ts +16 -0
- package/dist/src/proactive/execution/context.d.ts +2 -2
- package/dist/src/proactive/execution/context.js +16 -11
- package/dist/src/proactive/index.d.ts +1 -1
- package/dist/src/proactive/index.js +2 -2
- 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-store.js +2 -1
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/runtime-tools/manager.js +1 -1
- package/dist/src/share/hosted-session-share.d.ts +1 -4
- package/dist/src/share/hosted-session-share.js +14 -47
- package/dist/src/share/share-auto.d.ts +1 -1
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.d.ts +2 -7
- package/dist/src/share/share-store.js +153 -195
- package/dist/src/share/share-types.d.ts +0 -4
- package/dist/src/share/site-share-store.d.ts +3 -8
- package/dist/src/share/site-share-store.js +94 -153
- package/dist/src/share/site-share-types.d.ts +0 -4
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +54 -0
- 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/connection.d.ts +1 -2
- package/dist/src/storage/sqlite/connection.js +50 -47
- 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/durable-queue.d.ts +16 -0
- package/dist/src/storage/sqlite/durable-queue.js +52 -0
- package/dist/src/storage/sqlite/durable-state.d.ts +16 -0
- package/dist/src/storage/sqlite/durable-state.js +43 -0
- package/dist/src/storage/sqlite/index.d.ts +3 -5
- package/dist/src/storage/sqlite/index.js +4 -6
- 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/146_understanding_focus_exclusions.sql +9 -0
- package/dist/src/storage/sqlite/migrations/147_durable_application_state.sql +39 -0
- 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/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/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 +16 -13
- package/dist/src/storage/sqlite/session-repository.js +4 -1
- package/dist/src/storage/sqlite/transcript-repository.js +1 -1
- package/dist/src/tasks/index.js +2 -2
- 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/tool-summary.js +2 -1
- package/dist/src/tui/tui-scoped-models.js +9 -6
- 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 +40 -0
- package/dist/src/user-model/capture/executor.js +134 -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 +21 -0
- package/dist/src/user-model/capture/semantic.js +197 -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 +58 -0
- package/dist/src/user-model/goals.js +89 -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/agentEngine.js +63 -18
- package/dist/src/voice/realtime/conversationTurn.d.ts +20 -0
- package/dist/src/voice/realtime/conversationTurn.js +83 -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/voice/realtime/omniEngine.js +72 -18
- 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/authoring/workflow-draft-store.d.ts +1 -5
- package/dist/src/workflows/authoring/workflow-draft-store.js +23 -43
- package/dist/src/workflows/index.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +12 -20
- package/dist/src/workflows/store/event-store.d.ts +1 -2
- package/dist/src/workflows/store/event-store.js +19 -64
- package/dist/src/workflows/store/paths.d.ts +0 -2
- package/dist/src/workflows/store/paths.js +1 -7
- package/dist/src/workflows/store/run-store.d.ts +0 -1
- package/dist/src/workflows/store/run-store.js +1 -24
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-eG49pM-z.js +0 -1
- package/dist/gateway/static/root/assets/agents-CZwf1mgZ.js +0 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-BODskFTb.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-DeaVvaYZ.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BZG3BK7f.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CB7Yl2_B.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-Bu42Ljfw.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Cg7zCxEH.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-EDTZ8P3y.js +0 -1
- package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-kh7PEkSS.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-oi7cdv2C.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-D9OO-exo.js +0 -1
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-FTD7nE8v.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/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-c-8ENciH.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-BxvyTRl0.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C1S2Ccui.js +0 -1
- package/dist/gateway/static/root/assets/home-page-Bqx-SMWV.js +0 -1
- package/dist/gateway/static/root/assets/index-Cif1_3Jx.js +0 -71
- package/dist/gateway/static/root/assets/index-Dbh5SXyV.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-sDdw7Y3Q.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DUsxXdDp.js +0 -2
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +0 -1
- package/dist/gateway/static/root/assets/messages-BbdwoxVo.js +0 -3
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +0 -1
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-Dv87XewB.js +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-88f4fzYS.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-DOe0lOcQ.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-Cy0oYbWP.js +0 -4
- package/dist/gateway/static/root/assets/oauth-api-BjSUDIgq.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-fgD1xc4O.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CiTiEcOc.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Dc0GrNSp.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-BPOW3yaM.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Bz4s9BBY.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-rllj-j7k.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DMj7onCX.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DRB366nS.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-cBT9jCof.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-Byrk4DQy.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CheX3zmK.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-jKzujxFU.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CWy3Pqtk.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-DE4_YpDn.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-y4O9-BTf.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/understanding/types.js +0 -1
- 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 -443
- 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/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 → knowledge-memory/domain.js} +0 -0
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
import { consumeContextConsent, ensureContextConsent, getUserProfile, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, recordContextRun } from "../storage/sqlite/user-context-repository.js";
|
|
2
|
-
import { buildRetrievalQueryProfile } from "../retrieval/queryProfile.js";
|
|
3
|
-
import "../storage/sqlite/index.js";
|
|
4
|
-
import { init_session_key, parseSessionKey } from "../routing/session-key.js";
|
|
5
|
-
import { ProjectStore } from "../projects/project-store.js";
|
|
6
|
-
import { readAgentMessageContent } from "../agent/memory/agent-message-access.js";
|
|
7
|
-
import { buildUserContextBlock } from "../agent/memory/context-fence.js";
|
|
8
|
-
import { getUnderstandingSourceGrant, getUnderstandingSourceRun, listUserFocuses } from "./sources/repository.js";
|
|
9
|
-
import { matchesUserContextScope } from "./scope.js";
|
|
10
|
-
import { UserUnderstandingRetriever } from "./retriever.js";
|
|
11
|
-
import { focusRejectionReason, focusScore, rejectionReason } from "./selection-policy.js";
|
|
12
|
-
import { randomUUID } from "node:crypto";
|
|
13
|
-
//#region src/user-context/planner.ts
|
|
14
|
-
init_session_key();
|
|
15
|
-
const DEFAULT_MAX_CONTEXT_CHARS = 6e3;
|
|
16
|
-
const DEFAULT_MAX_RESULTS = 12;
|
|
17
|
-
const SELF_REVIEW_MAX_CONTEXT_CHARS = 16e3;
|
|
18
|
-
const SELF_REVIEW_MAX_RESULTS = 50;
|
|
19
|
-
const MAX_FOCUS_RESULTS = 3;
|
|
20
|
-
const MIN_RELEVANCE_SCORE = .25;
|
|
21
|
-
function selfReviewScore(item) {
|
|
22
|
-
const authority = item.explicitness === "explicit" ? .2 : item.explicitness === "observed" ? .1 : 0;
|
|
23
|
-
const durable = item.durability === "durable" ? .1 : item.durability === "recurring" ? .05 : 0;
|
|
24
|
-
return Math.min(1, item.confidence * .7 + authority + durable);
|
|
25
|
-
}
|
|
26
|
-
function scopeLabel(scope, projects) {
|
|
27
|
-
if (scope.type === "global") return "Global";
|
|
28
|
-
if (scope.type === "project") return `Project: ${scope.id ? projects.get(scope.id)?.name ?? scope.id : "unknown"}`;
|
|
29
|
-
if (scope.type === "workspace") return `Workspace: ${scope.id ?? "unknown"}`;
|
|
30
|
-
return "This conversation";
|
|
31
|
-
}
|
|
32
|
-
function prependAgentContext(message, block) {
|
|
33
|
-
if (!block) return message;
|
|
34
|
-
const prefix = `${block}\n\n`;
|
|
35
|
-
const content = readAgentMessageContent(message);
|
|
36
|
-
if (typeof content === "string") return {
|
|
37
|
-
...message,
|
|
38
|
-
content: prefix + content
|
|
39
|
-
};
|
|
40
|
-
if (Array.isArray(content)) {
|
|
41
|
-
const copy = [...content];
|
|
42
|
-
const first = copy[0];
|
|
43
|
-
if (first?.type === "text" && typeof first.text === "string") copy[0] = {
|
|
44
|
-
type: "text",
|
|
45
|
-
text: prefix + first.text
|
|
46
|
-
};
|
|
47
|
-
else copy.unshift({
|
|
48
|
-
type: "text",
|
|
49
|
-
text: prefix
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
...message,
|
|
53
|
-
content: copy
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return message;
|
|
57
|
-
}
|
|
58
|
-
function sectionFor(item) {
|
|
59
|
-
if (item.kind === "boundary") return "safety";
|
|
60
|
-
if ([
|
|
61
|
-
"preference",
|
|
62
|
-
"relationship",
|
|
63
|
-
"routine"
|
|
64
|
-
].includes(item.kind)) return "interaction";
|
|
65
|
-
return "task";
|
|
66
|
-
}
|
|
67
|
-
function sourceDescription(item) {
|
|
68
|
-
if (item.explicitness === "explicit") return {
|
|
69
|
-
origin: "told_by_user",
|
|
70
|
-
label: "You told xopc"
|
|
71
|
-
};
|
|
72
|
-
const connected = listUnderstandingEvidence(item.id).find((evidence) => evidence.sourceType === "connector");
|
|
73
|
-
if (connected) return {
|
|
74
|
-
origin: "connected_source",
|
|
75
|
-
label: connected.sourceInstanceId ?? "Connected source"
|
|
76
|
-
};
|
|
77
|
-
if (item.explicitness === "observed") return {
|
|
78
|
-
origin: "observed",
|
|
79
|
-
label: "Observed across prior work"
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
origin: "inferred",
|
|
83
|
-
label: "An inference that may be wrong"
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function focusSourceDescription(focus) {
|
|
87
|
-
if (focus.explicitness === "explicit") return {
|
|
88
|
-
origin: "told_by_user",
|
|
89
|
-
label: "You set this focus"
|
|
90
|
-
};
|
|
91
|
-
const sourceRun = focus.sourceRunId ? getUnderstandingSourceRun(focus.sourceRunId) : null;
|
|
92
|
-
const grant = sourceRun ? getUnderstandingSourceGrant(sourceRun.grantId) : null;
|
|
93
|
-
if (grant?.adapterId.startsWith("connector:")) return {
|
|
94
|
-
origin: "connected_source",
|
|
95
|
-
label: grant.displayName
|
|
96
|
-
};
|
|
97
|
-
if (focus.explicitness === "observed") return {
|
|
98
|
-
origin: "observed",
|
|
99
|
-
label: "Observed across prior work"
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
origin: "inferred",
|
|
103
|
-
label: "Suggested from prior work"
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function ruleMatches(rule, input) {
|
|
107
|
-
if (rule.status !== "active" || !matchesUserContextScope(rule.scope, input)) return false;
|
|
108
|
-
const channel = typeof rule.conditions.channel === "string" ? rule.conditions.channel : void 0;
|
|
109
|
-
const agentId = typeof rule.conditions.agentId === "string" ? rule.conditions.agentId : void 0;
|
|
110
|
-
return (!channel || channel === input.channel) && (!agentId || agentId === input.agentId);
|
|
111
|
-
}
|
|
112
|
-
function renderContextBlock(params) {
|
|
113
|
-
const understandingItems = params.items.filter((item) => item.objectType === "understanding");
|
|
114
|
-
return [
|
|
115
|
-
params.selfReview ? [
|
|
116
|
-
"<user-context-review>",
|
|
117
|
-
"The user explicitly asked what xopc understands about them. This is a review of active, non-sensitive structured understanding across scopes.",
|
|
118
|
-
"Scope labels describe where each item applies. Do not present project facts as global personality traits.",
|
|
119
|
-
"An empty memory_search result does not mean structured user understanding is empty.",
|
|
120
|
-
"</user-context-review>"
|
|
121
|
-
].join("\n") : "",
|
|
122
|
-
params.profileLines.length ? `<user-profile>\n${params.profileLines.join("\n")}\n</user-profile>` : "",
|
|
123
|
-
params.focuses.length ? `<active-focuses>\n${params.focuses.map((focus) => `- ${params.selfReview ? `[${scopeLabel(focus.scope, params.projects)}] ` : ""}${focus.title}: ${focus.summary} (${focus.horizon})`).join("\n")}\n</active-focuses>` : "",
|
|
124
|
-
params.rules.length ? `<collaboration-contract>\n${params.rules.map((rule) => `- ${rule.statement}`).join("\n")}\n</collaboration-contract>` : "",
|
|
125
|
-
understandingItems.length ? buildUserContextBlock(understandingItems.map((item) => `- ${item.content}\n Evidence: ${params.understandingSources.get(item.recordId) ?? "Unknown source"}`).join("\n")) : ""
|
|
126
|
-
].filter(Boolean).join("\n\n");
|
|
127
|
-
}
|
|
128
|
-
var UserContextPlanner = class {
|
|
129
|
-
retriever = new UserUnderstandingRetriever();
|
|
130
|
-
plan(params) {
|
|
131
|
-
const traceId = randomUUID();
|
|
132
|
-
const query = params.query.trim();
|
|
133
|
-
if (!query) return {
|
|
134
|
-
traceId,
|
|
135
|
-
modelMessage: params.userMessage,
|
|
136
|
-
items: [],
|
|
137
|
-
rejected: [],
|
|
138
|
-
consentRequests: [],
|
|
139
|
-
estimatedTokens: 0,
|
|
140
|
-
contextChars: 0,
|
|
141
|
-
contextItemCount: 0,
|
|
142
|
-
allocation: params.allocation
|
|
143
|
-
};
|
|
144
|
-
const started = Date.now();
|
|
145
|
-
const now = Date.now();
|
|
146
|
-
const requestedMaxResults = params.allocation?.maxResults;
|
|
147
|
-
const requestedMaxChars = params.allocation?.maxChars;
|
|
148
|
-
const scopeInput = {
|
|
149
|
-
sessionKey: params.sessionKey,
|
|
150
|
-
workspaceId: params.workspaceId,
|
|
151
|
-
...params.projectId ? { projectId: params.projectId } : {}
|
|
152
|
-
};
|
|
153
|
-
const queryProfile = buildRetrievalQueryProfile(query, scopeInput);
|
|
154
|
-
const selfReview = queryProfile.selfReview;
|
|
155
|
-
const maxResults = requestedMaxResults ?? (selfReview ? SELF_REVIEW_MAX_RESULTS : DEFAULT_MAX_RESULTS);
|
|
156
|
-
const budgetChars = requestedMaxChars ?? (selfReview ? SELF_REVIEW_MAX_CONTEXT_CHARS : DEFAULT_MAX_CONTEXT_CHARS);
|
|
157
|
-
const maxChars = Math.max(0, budgetChars - 2);
|
|
158
|
-
const projects = new ProjectStore();
|
|
159
|
-
const excluded = new Set(params.excludedRecordIds ?? []);
|
|
160
|
-
const rejected = [];
|
|
161
|
-
const consentRequests = [];
|
|
162
|
-
const traceItems = [];
|
|
163
|
-
const items = [];
|
|
164
|
-
const selectedFocuses = [];
|
|
165
|
-
const selectedRules = [];
|
|
166
|
-
const understandingSources = /* @__PURE__ */ new Map();
|
|
167
|
-
let usedChars = 0;
|
|
168
|
-
const render = (overrides = {}) => renderContextBlock({
|
|
169
|
-
profileLines,
|
|
170
|
-
focuses: selectedFocuses,
|
|
171
|
-
rules: selectedRules,
|
|
172
|
-
items,
|
|
173
|
-
understandingSources,
|
|
174
|
-
selfReview,
|
|
175
|
-
projects,
|
|
176
|
-
...overrides
|
|
177
|
-
});
|
|
178
|
-
const profile = getUserProfile();
|
|
179
|
-
const profileLines = [
|
|
180
|
-
profile.callName ? `Preferred name: ${profile.callName}` : "",
|
|
181
|
-
profile.role ? `Primary role: ${profile.role}` : "",
|
|
182
|
-
profile.primaryGoal ? `Primary goal for xopc: ${profile.primaryGoal}` : "",
|
|
183
|
-
profile.pronouns ? `Pronouns: ${profile.pronouns}` : "",
|
|
184
|
-
profile.timezone ? `Timezone: ${profile.timezone}` : "",
|
|
185
|
-
profile.locale ? `Language/locale: ${profile.locale}` : ""
|
|
186
|
-
].filter(Boolean);
|
|
187
|
-
if (profileLines.length) {
|
|
188
|
-
const content = profileLines.join("\n");
|
|
189
|
-
const nextChars = render().length;
|
|
190
|
-
if (nextChars <= maxChars) {
|
|
191
|
-
traceItems.push({
|
|
192
|
-
objectType: "profile",
|
|
193
|
-
objectId: "profile",
|
|
194
|
-
decision: "selected",
|
|
195
|
-
reason: "User-provided profile",
|
|
196
|
-
content,
|
|
197
|
-
sourceLabel: "You provided this directly",
|
|
198
|
-
origin: "told_by_user",
|
|
199
|
-
rank: 0,
|
|
200
|
-
score: 1,
|
|
201
|
-
injectedChars: nextChars
|
|
202
|
-
});
|
|
203
|
-
usedChars = nextChars;
|
|
204
|
-
} else {
|
|
205
|
-
profileLines.length = 0;
|
|
206
|
-
traceItems.push({
|
|
207
|
-
objectType: "profile",
|
|
208
|
-
objectId: "profile",
|
|
209
|
-
decision: "budget_exceeded",
|
|
210
|
-
reason: "Context budget reached",
|
|
211
|
-
content,
|
|
212
|
-
sourceLabel: "You provided this directly",
|
|
213
|
-
origin: "told_by_user",
|
|
214
|
-
injectedChars: 0
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
const rankedFocuses = listUserFocuses(["active"]).map((focus) => ({
|
|
219
|
-
focus,
|
|
220
|
-
score: focusScore(focus, query, scopeInput)
|
|
221
|
-
})).sort((left, right) => selfReview ? right.focus.confidence - left.focus.confidence || right.focus.updatedAt - left.focus.updatedAt : right.score - left.score || right.focus.updatedAt - left.focus.updatedAt);
|
|
222
|
-
for (const { focus, score } of rankedFocuses) {
|
|
223
|
-
const source = focusSourceDescription(focus);
|
|
224
|
-
let reason = focusRejectionReason(focus, scopeInput, now);
|
|
225
|
-
if (selfReview && reason === "scope_mismatch") reason = void 0;
|
|
226
|
-
if (!reason && !selfReview && score <= MIN_RELEVANCE_SCORE) reason = "low_score";
|
|
227
|
-
if (!reason && selectedFocuses.length >= (selfReview ? maxResults : MAX_FOCUS_RESULTS)) reason = "budget";
|
|
228
|
-
if (!reason && items.length >= maxResults) reason = "budget";
|
|
229
|
-
const focusScope = scopeLabel(focus.scope, projects);
|
|
230
|
-
const content = `${selfReview ? `[${focusScope}] ` : ""}${focus.title}: ${focus.summary} (${focus.horizon})`;
|
|
231
|
-
const nextChars = render({ focuses: [...selectedFocuses, focus] }).length;
|
|
232
|
-
if (!reason && nextChars > maxChars) reason = "budget";
|
|
233
|
-
if (reason) {
|
|
234
|
-
rejected.push({
|
|
235
|
-
recordId: focus.id,
|
|
236
|
-
reason
|
|
237
|
-
});
|
|
238
|
-
traceItems.push({
|
|
239
|
-
objectType: "focus",
|
|
240
|
-
objectId: focus.id,
|
|
241
|
-
versionId: focus.versionId,
|
|
242
|
-
decision: reason === "budget" ? "budget_exceeded" : reason === "requires_consent" ? "needs_consent" : reason === "scope_mismatch" ? "scope_mismatch" : reason === "expired" ? "expired" : reason === "sensitive" ? "sensitive" : reason === "disabled" ? "disabled" : "irrelevant",
|
|
243
|
-
reason,
|
|
244
|
-
content,
|
|
245
|
-
sourceLabel: source.label,
|
|
246
|
-
origin: source.origin,
|
|
247
|
-
score,
|
|
248
|
-
injectedChars: 0
|
|
249
|
-
});
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
const addedChars = nextChars - usedChars;
|
|
253
|
-
usedChars = nextChars;
|
|
254
|
-
selectedFocuses.push(focus);
|
|
255
|
-
items.push({
|
|
256
|
-
recordId: focus.id,
|
|
257
|
-
objectType: "focus",
|
|
258
|
-
versionId: focus.versionId,
|
|
259
|
-
content,
|
|
260
|
-
score,
|
|
261
|
-
section: "task",
|
|
262
|
-
citation: `user-focus://${focus.id}`,
|
|
263
|
-
origin: source.origin,
|
|
264
|
-
stability: focus.confidence
|
|
265
|
-
});
|
|
266
|
-
traceItems.push({
|
|
267
|
-
objectType: "focus",
|
|
268
|
-
objectId: focus.id,
|
|
269
|
-
versionId: focus.versionId,
|
|
270
|
-
decision: "selected",
|
|
271
|
-
reason: "Relevant active focus",
|
|
272
|
-
content,
|
|
273
|
-
sourceLabel: source.label,
|
|
274
|
-
origin: source.origin,
|
|
275
|
-
rank: items.length,
|
|
276
|
-
score,
|
|
277
|
-
injectedChars: addedChars
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
const rules = listCollaborationRules().filter((rule) => ruleMatches(rule, {
|
|
281
|
-
...scopeInput,
|
|
282
|
-
channel: params.channel,
|
|
283
|
-
agentId: parseSessionKey(params.sessionKey)?.agentId
|
|
284
|
-
}));
|
|
285
|
-
for (const [index, rule] of rules.entries()) {
|
|
286
|
-
const nextChars = render({ rules: [...selectedRules, rule] }).length;
|
|
287
|
-
if (nextChars > maxChars) {
|
|
288
|
-
traceItems.push({
|
|
289
|
-
objectType: "rule",
|
|
290
|
-
objectId: rule.id,
|
|
291
|
-
versionId: rule.revisionId,
|
|
292
|
-
decision: "budget_exceeded",
|
|
293
|
-
reason: "Context budget reached",
|
|
294
|
-
content: rule.statement,
|
|
295
|
-
sourceLabel: "Your collaboration rule",
|
|
296
|
-
origin: "told_by_user",
|
|
297
|
-
injectedChars: 0
|
|
298
|
-
});
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
const addedChars = nextChars - usedChars;
|
|
302
|
-
usedChars = nextChars;
|
|
303
|
-
selectedRules.push(rule);
|
|
304
|
-
traceItems.push({
|
|
305
|
-
objectType: "rule",
|
|
306
|
-
objectId: rule.id,
|
|
307
|
-
versionId: rule.revisionId,
|
|
308
|
-
decision: "selected",
|
|
309
|
-
reason: "Active collaboration rule",
|
|
310
|
-
content: rule.statement,
|
|
311
|
-
sourceLabel: "Your collaboration rule",
|
|
312
|
-
origin: "told_by_user",
|
|
313
|
-
rank: index + 1,
|
|
314
|
-
score: 1,
|
|
315
|
-
injectedChars: addedChars
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
const ranked = (selfReview ? listUnderstandings(["active"]).map((item) => ({
|
|
319
|
-
item,
|
|
320
|
-
score: selfReviewScore(item)
|
|
321
|
-
})).sort((left, right) => right.score - left.score || right.item.updatedAt - left.item.updatedAt) : this.retriever.retrieve({
|
|
322
|
-
query,
|
|
323
|
-
sessionKey: params.sessionKey,
|
|
324
|
-
workspaceId: params.workspaceId,
|
|
325
|
-
...params.projectId ? { projectId: params.projectId } : {},
|
|
326
|
-
maxCandidates: Math.max(maxResults * 5, 50)
|
|
327
|
-
}).map((result) => ({
|
|
328
|
-
item: result.understanding,
|
|
329
|
-
score: result.score
|
|
330
|
-
}))).filter(({ item }) => !excluded.has(item.id));
|
|
331
|
-
for (const { item, score } of ranked) {
|
|
332
|
-
const source = sourceDescription(item);
|
|
333
|
-
if (items.length >= maxResults) {
|
|
334
|
-
rejected.push({
|
|
335
|
-
recordId: item.id,
|
|
336
|
-
reason: "budget"
|
|
337
|
-
});
|
|
338
|
-
traceItems.push({
|
|
339
|
-
objectType: "understanding",
|
|
340
|
-
objectId: item.id,
|
|
341
|
-
versionId: item.versionId,
|
|
342
|
-
decision: "budget_exceeded",
|
|
343
|
-
reason: "Maximum result count reached",
|
|
344
|
-
content: item.statement,
|
|
345
|
-
sourceLabel: source.label,
|
|
346
|
-
origin: source.origin,
|
|
347
|
-
score,
|
|
348
|
-
injectedChars: 0
|
|
349
|
-
});
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
let reason = rejectionReason(item, scopeInput, now, queryProfile.timeHints);
|
|
353
|
-
if (selfReview && reason === "scope_mismatch") reason = void 0;
|
|
354
|
-
if (!reason && !selfReview && score <= MIN_RELEVANCE_SCORE) reason = "low_score";
|
|
355
|
-
if (!reason && item.disclosurePolicy === "ask_before_reference") {
|
|
356
|
-
const consentStatus = consumeContextConsent(item.id, params.sessionKey);
|
|
357
|
-
if (consentStatus !== "granted") {
|
|
358
|
-
reason = consentStatus === "denied" ? "disabled" : "requires_consent";
|
|
359
|
-
if (consentStatus === "missing") {
|
|
360
|
-
const consent = ensureContextConsent(item.id, params.sessionKey, query);
|
|
361
|
-
consentRequests.push({
|
|
362
|
-
id: consent.id,
|
|
363
|
-
recordId: item.id,
|
|
364
|
-
statement: item.statement,
|
|
365
|
-
purpose: consent.purpose
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (reason) {
|
|
371
|
-
rejected.push({
|
|
372
|
-
recordId: item.id,
|
|
373
|
-
reason
|
|
374
|
-
});
|
|
375
|
-
traceItems.push({
|
|
376
|
-
objectType: "understanding",
|
|
377
|
-
objectId: item.id,
|
|
378
|
-
versionId: item.versionId,
|
|
379
|
-
decision: reason === "budget" ? "budget_exceeded" : reason === "requires_consent" ? "needs_consent" : reason === "conflict" ? "conflicted" : reason === "expired" ? "expired" : reason === "sensitive" ? "sensitive" : reason === "scope_mismatch" ? "scope_mismatch" : reason === "disabled" ? "disabled" : "irrelevant",
|
|
380
|
-
reason,
|
|
381
|
-
content: item.statement,
|
|
382
|
-
sourceLabel: source.label,
|
|
383
|
-
origin: source.origin,
|
|
384
|
-
score,
|
|
385
|
-
injectedChars: 0
|
|
386
|
-
});
|
|
387
|
-
continue;
|
|
388
|
-
}
|
|
389
|
-
const plannedItem = {
|
|
390
|
-
recordId: item.id,
|
|
391
|
-
objectType: "understanding",
|
|
392
|
-
versionId: item.versionId,
|
|
393
|
-
content: selfReview ? `[${scopeLabel(item.scope, projects)}] ${item.statement}` : item.statement,
|
|
394
|
-
score,
|
|
395
|
-
section: sectionFor(item),
|
|
396
|
-
citation: `user-context://${item.id}`,
|
|
397
|
-
origin: source.origin,
|
|
398
|
-
stability: item.confidence
|
|
399
|
-
};
|
|
400
|
-
const nextSources = new Map(understandingSources).set(item.id, source.label);
|
|
401
|
-
const nextChars = render({
|
|
402
|
-
items: [...items, plannedItem],
|
|
403
|
-
understandingSources: nextSources
|
|
404
|
-
}).length;
|
|
405
|
-
if (nextChars > maxChars) {
|
|
406
|
-
rejected.push({
|
|
407
|
-
recordId: item.id,
|
|
408
|
-
reason: "budget"
|
|
409
|
-
});
|
|
410
|
-
traceItems.push({
|
|
411
|
-
objectType: "understanding",
|
|
412
|
-
objectId: item.id,
|
|
413
|
-
versionId: item.versionId,
|
|
414
|
-
decision: "budget_exceeded",
|
|
415
|
-
reason: "Context budget reached",
|
|
416
|
-
content: item.statement,
|
|
417
|
-
sourceLabel: source.label,
|
|
418
|
-
origin: source.origin,
|
|
419
|
-
score,
|
|
420
|
-
injectedChars: 0
|
|
421
|
-
});
|
|
422
|
-
continue;
|
|
423
|
-
}
|
|
424
|
-
const addedChars = nextChars - usedChars;
|
|
425
|
-
usedChars = nextChars;
|
|
426
|
-
understandingSources.set(item.id, source.label);
|
|
427
|
-
items.push(plannedItem);
|
|
428
|
-
traceItems.push({
|
|
429
|
-
objectType: "understanding",
|
|
430
|
-
objectId: item.id,
|
|
431
|
-
versionId: item.versionId,
|
|
432
|
-
decision: "selected",
|
|
433
|
-
reason: "Relevant to this request",
|
|
434
|
-
content: item.statement,
|
|
435
|
-
sourceLabel: source.label,
|
|
436
|
-
origin: source.origin,
|
|
437
|
-
rank: items.length,
|
|
438
|
-
score,
|
|
439
|
-
injectedChars: addedChars
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
const block = render();
|
|
443
|
-
recordContextRun({
|
|
444
|
-
turnId: params.turnId,
|
|
445
|
-
sessionKey: params.sessionKey,
|
|
446
|
-
query,
|
|
447
|
-
budget: budgetChars,
|
|
448
|
-
durationMs: Date.now() - started,
|
|
449
|
-
items: traceItems
|
|
450
|
-
});
|
|
451
|
-
return {
|
|
452
|
-
traceId,
|
|
453
|
-
modelMessage: prependAgentContext(params.userMessage, block),
|
|
454
|
-
items,
|
|
455
|
-
rejected,
|
|
456
|
-
consentRequests,
|
|
457
|
-
estimatedTokens: Math.ceil((block.length + (block ? 2 : 0)) / 4),
|
|
458
|
-
contextChars: block.length + (block ? 2 : 0),
|
|
459
|
-
contextItemCount: traceItems.filter((item) => item.decision === "selected").length,
|
|
460
|
-
allocation: params.allocation
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
//#endregion
|
|
465
|
-
export { UserContextPlanner, prependAgentContext };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { KnowledgeSourceItem } from '../../knowledge/types.js';
|
|
2
|
-
import type { UserPersonIndexEntry } from './types.js';
|
|
3
|
-
type PersonSignal = {
|
|
4
|
-
name?: string;
|
|
5
|
-
email?: string;
|
|
6
|
-
username?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function personIdentityKey(signal: PersonSignal, sourceInstanceId: string): string | undefined;
|
|
9
|
-
export declare function personIdForIdentity(signal: PersonSignal, sourceInstanceId: string): string | undefined;
|
|
10
|
-
export declare function buildUserPeopleIndex(items: KnowledgeSourceItem[]): UserPersonIndexEntry[];
|
|
11
|
-
export declare function rebuildUserPeopleIndex(): UserPersonIndexEntry[];
|
|
12
|
-
export declare function ensureUserPeopleIndex(): void;
|
|
13
|
-
export {};
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { getUserPeopleIndexState, replaceUserPeopleIndex } from "../../storage/sqlite/user-people-repository.js";
|
|
3
|
-
import { listKnowledgeSourceItems } from "../../storage/sqlite/knowledge-repository.js";
|
|
4
|
-
import "../../storage/sqlite/index.js";
|
|
5
|
-
import { listUnderstandingSourceGrants } from "../sources/repository.js";
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
7
|
-
//#region src/user-context/relationships/indexer.ts
|
|
8
|
-
function hash(value) {
|
|
9
|
-
return createHash("sha256").update(value).digest("hex").slice(0, 20);
|
|
10
|
-
}
|
|
11
|
-
function normalized(value) {
|
|
12
|
-
return value?.trim().toLocaleLowerCase() || void 0;
|
|
13
|
-
}
|
|
14
|
-
function readSignal(value) {
|
|
15
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
16
|
-
const row = value;
|
|
17
|
-
const read = (key) => typeof row[key] === "string" && row[key].trim() ? row[key].trim().slice(0, 160) : void 0;
|
|
18
|
-
const signal = {
|
|
19
|
-
name: read("name"),
|
|
20
|
-
email: read("email"),
|
|
21
|
-
username: read("username")
|
|
22
|
-
};
|
|
23
|
-
return signal.name || signal.email || signal.username ? signal : void 0;
|
|
24
|
-
}
|
|
25
|
-
function providerScope(sourceInstanceId) {
|
|
26
|
-
if (!sourceInstanceId.startsWith("composio:")) return sourceInstanceId.toLocaleLowerCase();
|
|
27
|
-
return sourceInstanceId.split(":")[1]?.toLocaleLowerCase() ?? sourceInstanceId.toLocaleLowerCase();
|
|
28
|
-
}
|
|
29
|
-
function personIdentityKey(signal, sourceInstanceId) {
|
|
30
|
-
const email = normalized(signal.email);
|
|
31
|
-
if (email) return `email:${email}`;
|
|
32
|
-
const username = normalized(signal.username);
|
|
33
|
-
if (username) return `provider:${providerScope(sourceInstanceId)}:${username}`;
|
|
34
|
-
const name = normalized(signal.name);
|
|
35
|
-
return name ? `name:${sourceInstanceId.toLocaleLowerCase()}:${name}` : void 0;
|
|
36
|
-
}
|
|
37
|
-
function personIdForIdentity(signal, sourceInstanceId) {
|
|
38
|
-
const key = personIdentityKey(signal, sourceInstanceId);
|
|
39
|
-
return key ? `person_${hash(key)}` : void 0;
|
|
40
|
-
}
|
|
41
|
-
function inferredKind(signal) {
|
|
42
|
-
const name = normalized(signal.name) ?? "";
|
|
43
|
-
const username = normalized(signal.username) ?? "";
|
|
44
|
-
const emailLocal = (normalized(signal.email) ?? "").split("@")[0] ?? "";
|
|
45
|
-
if (/\[bot\]|(?:^|[-_.])bot(?:$|[-_.])|bot$/.test(`${name} ${username}`)) return "bot";
|
|
46
|
-
if (/^(?:no[-_.]?reply|do[-_.]?not[-_.]?reply|notifications?|alerts?|mailer[-_.]?daemon)(?:$|[-+_.])/.test(emailLocal)) return "service";
|
|
47
|
-
if (/^(?:team|group|all|everyone|support|help|sales|contact)(?:$|[-+_.])/.test(emailLocal)) return "group";
|
|
48
|
-
if (!signal.name && !signal.email && signal.username) return "unknown";
|
|
49
|
-
return "person";
|
|
50
|
-
}
|
|
51
|
-
function confidence(signal) {
|
|
52
|
-
if (signal.email) return signal.name ? .95 : .88;
|
|
53
|
-
if (signal.username) return signal.name ? .86 : .72;
|
|
54
|
-
return .55;
|
|
55
|
-
}
|
|
56
|
-
function observedAt(item) {
|
|
57
|
-
const value = Date.parse(item.occurredAt ?? item.sourceUpdatedAt ?? item.updatedAt);
|
|
58
|
-
return Number.isFinite(value) ? value : Date.now();
|
|
59
|
-
}
|
|
60
|
-
function handle(personId, type, value, sourceInstanceId, time) {
|
|
61
|
-
return {
|
|
62
|
-
id: `handle_${hash(`${type}:${normalized(value)}:${sourceInstanceId}`)}`,
|
|
63
|
-
type,
|
|
64
|
-
value,
|
|
65
|
-
sourceInstanceId,
|
|
66
|
-
verification: type === "display_name" ? "inferred" : "observed",
|
|
67
|
-
firstObservedAt: time,
|
|
68
|
-
lastObservedAt: time
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function activeConnectorSources() {
|
|
72
|
-
return new Set(listUnderstandingSourceGrants().flatMap((grant) => {
|
|
73
|
-
const sourceInstanceId = typeof grant.config.sourceInstanceId === "string" ? grant.config.sourceInstanceId.trim() : "";
|
|
74
|
-
if (sourceInstanceId) return [sourceInstanceId];
|
|
75
|
-
const connectorId = typeof grant.config.connectorId === "string" ? grant.config.connectorId.trim() : "";
|
|
76
|
-
const accountId = typeof grant.config.accountId === "string" ? grant.config.accountId.trim() : "";
|
|
77
|
-
return connectorId && accountId ? [`composio:${connectorId}:${accountId}`] : [];
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
function loadActiveSourceItems() {
|
|
81
|
-
const activeSources = activeConnectorSources();
|
|
82
|
-
const items = [];
|
|
83
|
-
let offset = 0;
|
|
84
|
-
while (true) {
|
|
85
|
-
const page = listKnowledgeSourceItems({
|
|
86
|
-
includeDeleted: false,
|
|
87
|
-
limit: 500,
|
|
88
|
-
offset
|
|
89
|
-
});
|
|
90
|
-
items.push(...page.filter((item) => item.synthesisPipeline === "connected_knowledge" && item.sensitivity !== "secret" && item.sensitivity !== "regulated" && item.metadata.observationKind !== "inventory" && (!item.sourceInstanceId.startsWith("composio:") || activeSources.has(item.sourceInstanceId))));
|
|
91
|
-
if (page.length < 500) break;
|
|
92
|
-
offset += page.length;
|
|
93
|
-
}
|
|
94
|
-
return items;
|
|
95
|
-
}
|
|
96
|
-
function currentIndexRevision() {
|
|
97
|
-
const db = getSqliteDatabase();
|
|
98
|
-
return {
|
|
99
|
-
sourceChangeSequence: Number(db.prepare("SELECT COALESCE(MAX(sequence), 0) AS value FROM knowledge_source_changes").get().value),
|
|
100
|
-
sourceGrantsUpdatedAt: Number(db.prepare("SELECT COALESCE(MAX(updated_at), 0) AS value FROM understanding_source_grants").get().value)
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function buildUserPeopleIndex(items) {
|
|
104
|
-
const owners = new Set(items.flatMap((item) => Array.isArray(item.metadata.ownerIdentities) ? item.metadata.ownerIdentities.filter((value) => typeof value === "string").map((value) => value.trim().toLocaleLowerCase()).filter(Boolean) : []));
|
|
105
|
-
const people = /* @__PURE__ */ new Map();
|
|
106
|
-
for (const item of items) {
|
|
107
|
-
const values = Array.isArray(item.metadata.personEntities) ? item.metadata.personEntities : [];
|
|
108
|
-
const seenInItem = /* @__PURE__ */ new Set();
|
|
109
|
-
for (const value of values) {
|
|
110
|
-
const signal = readSignal(value);
|
|
111
|
-
if (!signal) continue;
|
|
112
|
-
const strongIdentity = normalized(signal.email) ?? normalized(signal.username);
|
|
113
|
-
if (strongIdentity && owners.has(strongIdentity)) continue;
|
|
114
|
-
const identityKey = personIdentityKey(signal, item.sourceInstanceId);
|
|
115
|
-
const id = personIdForIdentity(signal, item.sourceInstanceId);
|
|
116
|
-
if (!identityKey || !id || seenInItem.has(identityKey)) continue;
|
|
117
|
-
seenInItem.add(identityKey);
|
|
118
|
-
const time = observedAt(item);
|
|
119
|
-
const name = signal.name ?? signal.email ?? signal.username;
|
|
120
|
-
const current = people.get(identityKey) ?? {
|
|
121
|
-
id,
|
|
122
|
-
displayName: name,
|
|
123
|
-
inferredKind: inferredKind(signal),
|
|
124
|
-
confidence: confidence(signal),
|
|
125
|
-
firstObservedAt: time,
|
|
126
|
-
lastObservedAt: time,
|
|
127
|
-
handles: /* @__PURE__ */ new Map(),
|
|
128
|
-
sources: /* @__PURE__ */ new Map()
|
|
129
|
-
};
|
|
130
|
-
if (signal.name && (!current.displayName || current.displayName.includes("@"))) current.displayName = signal.name;
|
|
131
|
-
current.inferredKind = current.inferredKind === "unknown" ? inferredKind(signal) : current.inferredKind;
|
|
132
|
-
current.confidence = Math.max(current.confidence, confidence(signal));
|
|
133
|
-
current.firstObservedAt = Math.min(current.firstObservedAt, time);
|
|
134
|
-
current.lastObservedAt = Math.max(current.lastObservedAt, time);
|
|
135
|
-
for (const [type, displayValue] of [
|
|
136
|
-
["email", signal.email],
|
|
137
|
-
["username", signal.username],
|
|
138
|
-
["display_name", signal.name]
|
|
139
|
-
]) {
|
|
140
|
-
if (!displayValue) continue;
|
|
141
|
-
const next = handle(id, type, displayValue, item.sourceInstanceId, time);
|
|
142
|
-
const key = `${type}:${normalized(displayValue)}:${item.sourceInstanceId}`;
|
|
143
|
-
const previous = current.handles.get(key);
|
|
144
|
-
if (previous) {
|
|
145
|
-
previous.firstObservedAt = Math.min(previous.firstObservedAt, time);
|
|
146
|
-
previous.lastObservedAt = Math.max(previous.lastObservedAt, time);
|
|
147
|
-
} else current.handles.set(key, next);
|
|
148
|
-
}
|
|
149
|
-
const source = current.sources.get(item.sourceInstanceId) ?? {
|
|
150
|
-
sourceInstanceId: item.sourceInstanceId,
|
|
151
|
-
interactionCount: 0,
|
|
152
|
-
firstObservedAt: time,
|
|
153
|
-
lastObservedAt: time
|
|
154
|
-
};
|
|
155
|
-
source.interactionCount += 1;
|
|
156
|
-
source.firstObservedAt = Math.min(source.firstObservedAt, time);
|
|
157
|
-
source.lastObservedAt = Math.max(source.lastObservedAt, time);
|
|
158
|
-
current.sources.set(item.sourceInstanceId, source);
|
|
159
|
-
people.set(identityKey, current);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return [...people.values()].map((person) => ({
|
|
163
|
-
id: person.id,
|
|
164
|
-
displayName: person.displayName,
|
|
165
|
-
inferredKind: person.inferredKind,
|
|
166
|
-
confidence: person.confidence,
|
|
167
|
-
firstObservedAt: person.firstObservedAt,
|
|
168
|
-
lastObservedAt: person.lastObservedAt,
|
|
169
|
-
handles: [...person.handles.values()],
|
|
170
|
-
sources: [...person.sources.values()]
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
function rebuildUserPeopleIndex() {
|
|
174
|
-
const revision = currentIndexRevision();
|
|
175
|
-
const entries = buildUserPeopleIndex(loadActiveSourceItems());
|
|
176
|
-
replaceUserPeopleIndex(entries, revision);
|
|
177
|
-
return entries;
|
|
178
|
-
}
|
|
179
|
-
function ensureUserPeopleIndex() {
|
|
180
|
-
const revision = currentIndexRevision();
|
|
181
|
-
const state = getUserPeopleIndexState();
|
|
182
|
-
if (!state || state.sourceChangeSequence !== revision.sourceChangeSequence || state.sourceGrantsUpdatedAt !== revision.sourceGrantsUpdatedAt) rebuildUserPeopleIndex();
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
export { buildUserPeopleIndex, ensureUserPeopleIndex, personIdForIdentity, personIdentityKey, rebuildUserPeopleIndex };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { UserPerson, UserPersonKind } from './types.js';
|
|
2
|
-
export declare function listUserRelationships(options?: {
|
|
3
|
-
query?: string;
|
|
4
|
-
kind?: UserPersonKind;
|
|
5
|
-
sourceInstanceId?: string;
|
|
6
|
-
includeHidden?: boolean;
|
|
7
|
-
hiddenOnly?: boolean;
|
|
8
|
-
cursor?: string;
|
|
9
|
-
limit?: number;
|
|
10
|
-
}): {
|
|
11
|
-
nextCursor?: string;
|
|
12
|
-
items: UserPerson[];
|
|
13
|
-
summary: import("./types.js").UserRelationshipSummary;
|
|
14
|
-
total: number;
|
|
15
|
-
};
|
|
16
|
-
export declare function getUserRelationship(personId: string): UserPerson | null;
|
|
17
|
-
export declare function patchUserRelationship(personId: string, patch: {
|
|
18
|
-
displayName?: string | null;
|
|
19
|
-
kind?: UserPersonKind | null;
|
|
20
|
-
hidden?: boolean;
|
|
21
|
-
}): UserPerson | null;
|
|
22
|
-
export declare function mergeUserRelationships(sourcePersonId: string, targetPersonId: string): UserPerson | null;
|