@xopcai/xopc 0.0.218 → 0.0.219
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-DF2dYXG1.js → activity-store-slG02hSm.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dw9rF5o1.js → agent-avatar-dicebear-DZ6ETNIk.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DxaIH0Ep.js +68 -0
- package/dist/gateway/static/root/assets/{api-_H0Bam-t.js → api-Tz57QxiN.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-DdR1L4LR.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-wYbwqmee.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-CyWr6KyO.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DZCOhXch.js → archive-plugin-DKXa160O.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Bjb0FH2B.js → attachment-load-CzwA9g2y.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D4N3ZDhu.js → automations-page-DwAXyWAY.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CL7ieYIt.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-uXPt0s47.js → binary-plugins-DoQ_DnT7.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-gukkIEro.js → block-editor-Bj_Uxxng.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-BYa_FNC1.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-DAhdS-XZ.js → browser-workflow-inputs-D4roXE6r.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-LKjYzXS_.js → browser-workflows-page-CleKTAKD.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DYG37N0k.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BBUkH833.js → capability-presets-api-wtEN6Ss6.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-C0Q4dFq-.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-E5mo8M3a.js → channel-recipient-api-DhuS2RJ3.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-CpO6Xg0n.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-CXhPeiNj.js +1 -0
- package/dist/gateway/static/root/assets/chat-terminal-dock-ClQMDe2n.js +36 -0
- package/dist/gateway/static/root/assets/connectors-page-BvyiPdKU.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-BGNuaqvI.js → cron-expression-4DvCFs-v.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-k7mkklMU.js → date-picker-B6FSjt4Z.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-Za18eMp1.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-p9EZyGzV.js → desktop-pet-DUUf3yyJ.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Dwx3GfB8.js +1 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-C6dfTCsl.js +1 -0
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-Cd4BMKm_.js → extension-debug-page-Cordpg4X.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CzEGCkOa.js → extension-page-Dw0dGyMl.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-B2pUMaXm.js +1 -0
- package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
- package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +1 -0
- package/dist/gateway/static/root/assets/file-code-corner-byQA1VfD.js +1 -0
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-DAZUOEQh.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DNrttVr2.js → gateway-config-swr-BIqRg-zo.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-ik2f-pmV.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B1vD3vRb.js → gateway-startup-retry-BFjWYOCS.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BE81XJ8F.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BTWXJu_m.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BTR0Wk_k.js → image-generation-api-HXAWlgm6.js} +1 -1
- package/dist/gateway/static/root/assets/index-B6gWYy08.js +108 -0
- package/dist/gateway/static/root/assets/index-CDkuz_YC.css +2 -0
- package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CYlS4RGA.js → keyboard-shortcuts-settings-ROqQ_Xlo.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Dcaf190G.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CNppYVew.js → local-apps-page-Be79cyMG.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-gf9Bg2gb.js → locale-store-DfK-Hofd.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-C2pjbXno.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-IYk9xLgt.js → management-settings-CRspx0oY.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-D8e6pRMH.js → markdown-split-G3PTpGw3.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-D0fiJjBQ.js → markdown-view-D4FPJZ91.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CCq6TtEf.js → media-plugins-DT0P7j7u.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B701TEZ5.js +3 -0
- package/dist/gateway/static/root/assets/{notes-api-BBtWnlUU.js → notes-api-q7HjYO07.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BKe1xa3U.js → notes-page-Cgl2h7AR.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-DFMQYyGJ.js +4 -0
- package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-DXe5iWI6.js → product-open-page-ComKLO4D.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DUFmQscH.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CTWxt3dv.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-xj5gOva_.js → registry-api-BBoJ7khF.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-qmG-3qjj.js +1 -0
- package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BJTvmBCA.js → runtime-tools-settings-panel-CXHQc53b.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-DvGBa_7R.js → schema-form-3jTDF2lJ.js} +1 -1
- package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-D_We4_MV.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-B_QhPgU0.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-CUDozALU.js +1 -0
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-sbef7GTm.js → settings-loading-skeleton-H3ZH6a6l.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BNGxxXZe.js → settings-page-tx29z21o.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-VunfXpTX.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-C1523ij3.js → share-preview-page-MyThymEx.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DkZvY1cr.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DVDOh1iY.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BOOyMnno.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-Ditgz7Vo.js → skills-page.utils-Bl5Yv3Cx.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-DwQ3O1ta.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-BwOyrADL.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-DgSjes3O.js → theme-store-Br4BtK4x.js} +1 -1
- package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-Bp_qFZkl.js → use-autosave-DRS3RwS9.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-ClV2r3Cr.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-hbzDfErG.js → voice-api-key-field-CGTE5156.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DZVib-04.js → work-discovery-overlay-CW-HKD7h.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C2RKay1p.js → workflow-run-setup-panel-Dtr9fDC8.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CDOyNgZf.js +5 -0
- package/dist/gateway/static/root/index.html +20 -11
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/new-session.js +99 -0
- package/dist/packages/gateway-contract/src/tasks.js +5 -0
- package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
- package/dist/src/agent/agent-manager.js +5 -4
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +2 -2
- package/dist/src/agent/background-review/run-background-review.js +144 -16
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
- package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/memory/context/types.d.ts +1 -1
- package/dist/src/agent/memory/manager.d.ts +2 -1
- package/dist/src/agent/memory/manager.js +2 -6
- package/dist/src/agent/memory/understanding/service.d.ts +1 -0
- package/dist/src/agent/memory/understanding/service.js +179 -36
- package/dist/src/agent/memory/understanding/types.d.ts +6 -0
- package/dist/src/agent/messaging/command-handler.d.ts +2 -0
- package/dist/src/agent/messaging/command-handler.js +3 -1
- package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
- package/dist/src/agent/service/direct-turn-helpers.js +13 -3
- package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
- package/dist/src/agent/service/process-direct-streaming.js +12 -11
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-config-service.d.ts +1 -0
- package/dist/src/agent/session/session-config-service.js +11 -0
- package/dist/src/agent/session/session-inspector.d.ts +1 -0
- package/dist/src/agent/session/session-inspector.js +2 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/source-context/budget.d.ts +3 -0
- package/dist/src/agent/source-context/budget.js +21 -0
- package/dist/src/agent/source-context/index.js +3 -3
- package/dist/src/agent/source-context/injector.d.ts +2 -2
- package/dist/src/agent/source-context/injector.js +19 -9
- package/dist/src/agent/source-context/types.d.ts +16 -0
- package/dist/src/agent/source-context/types.js +25 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
- package/dist/src/agent/tools/xopc-use-tool.js +62 -2
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/backend-from-config.d.ts +8 -0
- package/dist/src/browser/backend-from-config.js +16 -1
- package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
- package/dist/src/browser/providers/browser-ext-install.js +5 -3
- package/dist/src/chat-commands/builtins/review.js +11 -2
- package/dist/src/chat-commands/builtins/understanding.js +11 -4
- package/dist/src/chat-commands/types.d.ts +4 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.d.ts +20 -20
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
- package/dist/src/connectors/connected-source-understanding.js +82 -34
- package/dist/src/connectors/learning-coordinator.js +57 -11
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +18 -0
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
- package/dist/src/gateway/hono/routes/sessions.js +17 -20
- package/dist/src/gateway/hono/routes/tasks.js +25 -0
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +9 -0
- package/dist/src/gateway/hono/routes/understanding-sources.js +127 -31
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/hono/routes/you.js +71 -4
- package/dist/src/gateway/service/agent-runner.d.ts +7 -2
- package/dist/src/gateway/service/agent-runner.js +21 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
- package/dist/src/gateway/service/run-gateway-agent.js +2 -1
- package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
- package/dist/src/gateway/service/session-input-coordinator.js +62 -3
- package/dist/src/gateway/service/sessions-api.d.ts +1 -0
- package/dist/src/gateway/service.d.ts +3 -2
- package/dist/src/gateway/service.js +25 -15
- package/dist/src/gateway/user-turn-input.d.ts +2 -0
- package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
- package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
- package/dist/src/knowledge/connected-understanding-pipeline.js +4 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/retrieval/queryProfile.d.ts +1 -0
- package/dist/src/retrieval/queryProfile.js +9 -1
- package/dist/src/session/client-history.d.ts +11 -0
- package/dist/src/session/client-history.js +24 -2
- package/dist/src/session/config-types.d.ts +1 -1
- package/dist/src/session/session-title.js +2 -3
- package/dist/src/session/store.js +1 -0
- package/dist/src/session/transcript-outline.js +5 -2
- package/dist/src/session/types.d.ts +1 -0
- package/dist/src/session/user-message-display.d.ts +4 -0
- package/dist/src/session/user-message-display.js +22 -0
- package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
- package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
- package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
- package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
- package/dist/src/storage/sqlite/index.d.ts +4 -2
- package/dist/src/storage/sqlite/index.js +5 -3
- package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
- package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
- package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
- package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
- package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
- package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
- package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -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/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
- package/dist/src/storage/sqlite/session-input-repository.js +19 -7
- package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
- package/dist/src/storage/sqlite/transcript-repository.js +29 -3
- package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
- package/dist/src/storage/sqlite/user-context-repository.js +65 -29
- package/dist/src/tasks/index.d.ts +1 -0
- package/dist/src/tasks/index.js +2 -1
- package/dist/src/tasks/task-deletion-service.d.ts +21 -0
- package/dist/src/tasks/task-deletion-service.js +35 -0
- package/dist/src/tasks/task-repository.js +22 -1
- package/dist/src/tui/backends/embedded-backend.js +5 -3
- package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
- package/dist/src/tui/chat-history.js +2 -1
- package/dist/src/tui/tui-agent-events.js +4 -2
- package/dist/src/tui/tui-commands.d.ts +1 -0
- package/dist/src/tui/tui-commands.js +8 -3
- package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
- package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
- package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
- package/dist/src/tui/tui-new-session-preferences.js +32 -0
- package/dist/src/tui/tui-session-actions.d.ts +1 -0
- package/dist/src/tui/tui-session-actions.js +2 -1
- package/dist/src/tui/tui-settings.d.ts +2 -0
- package/dist/src/tui/tui-settings.js +4 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui-types.d.ts +1 -0
- package/dist/src/tui/tui.js +58 -5
- package/dist/src/tunnel/frpc-process.js +3 -0
- package/dist/src/tunnel/tunnel-service.d.ts +2 -0
- package/dist/src/tunnel/tunnel-service.js +40 -28
- package/dist/src/user-context/context-objects.d.ts +17 -0
- package/dist/src/user-context/context-objects.js +99 -0
- package/dist/src/user-context/domain.d.ts +13 -1
- package/dist/src/user-context/evaluation/harness.d.ts +13 -0
- package/dist/src/user-context/evaluation/harness.js +31 -0
- package/dist/src/user-context/extraction/registry.d.ts +26 -0
- package/dist/src/user-context/extraction/registry.js +113 -0
- package/dist/src/user-context/extraction/repair.d.ts +19 -0
- package/dist/src/user-context/extraction/repair.js +68 -0
- package/dist/src/user-context/planner.js +214 -57
- package/dist/src/user-context/retriever.js +69 -9
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
- package/dist/src/user-context/sources/processing-policy.js +7 -0
- package/dist/src/user-context/sources/repository.d.ts +23 -4
- package/dist/src/user-context/sources/repository.js +122 -12
- package/dist/src/user-context/sources/types.d.ts +10 -1
- package/dist/src/user-context/understanding.js +1 -1
- package/dist/src/work-discovery/service.js +21 -5
- package/dist/src/work-discovery/source-repository.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agents-Dj86bHkl.js +0 -68
- package/dist/gateway/static/root/assets/app-management-settings-panel-D-M6GN-8.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-XDhmzdIc.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-sfO835uz.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-PptuZgoo.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BoCmzMFV.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DhkJsU8Z.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dm7T61fE.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-dG6UFVqt.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DgJxfNyK.js +0 -1
- package/dist/gateway/static/root/assets/chat-terminal-dock-CT5yoSMD.js +0 -36
- package/dist/gateway/static/root/assets/connectors-page-BC6Ft9SU.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DZVSgLXH.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Bw4cCFzI.js +0 -1
- package/dist/gateway/static/root/assets/directory-picker-path-field-Cbst7IXR.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-C1PAKSy2.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-Bch9vO6t.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DkDxZFGG.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DXNMxy5b.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CYcpVFNT.js +0 -1
- package/dist/gateway/static/root/assets/index-Dgb1R07E.css +0 -2
- package/dist/gateway/static/root/assets/index-DlOYwVFK.js +0 -108
- package/dist/gateway/static/root/assets/local-app-workbench-page-BFrgPwGE.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-CPweLw3k.js +0 -2
- package/dist/gateway/static/root/assets/messages-B9WQcZ1V.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-wieRAd1y.js +0 -4
- package/dist/gateway/static/root/assets/page-tabs-Bsluqyfb.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-BrpTWv44.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cww6V7HJ.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D0LKhCCw.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Sf4Pde6Z.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-S5gvgfu5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-B3XvdEy8.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-CiGFtdD8.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGU_Mxjr.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-k0UQ8WxO.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DQ1GvL1w.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-OuHd9GcN.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-CERqCsz2.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BnRNL2sn.js +0 -1
- package/dist/gateway/static/root/assets/typed-models-lib-abEJNkCO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Cnkaiky5.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-B_VlcKiK.js +0 -5
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { hasIndependentExtractionOutput, listContextExtractionOutputs, listContextExtractionRuns } from "../../storage/sqlite/context-extraction-repository.js";
|
|
2
|
+
import { getUnderstanding, setUnderstandingStatus } from "../../storage/sqlite/user-context-repository.js";
|
|
3
|
+
import "../../storage/sqlite/index.js";
|
|
4
|
+
import { listUserFocuses, updateUserFocus } from "../sources/repository.js";
|
|
5
|
+
//#region src/user-context/extraction/repair.ts
|
|
6
|
+
function repairExtractedContext(filter) {
|
|
7
|
+
const runs = listContextExtractionRuns({
|
|
8
|
+
...filter.sourceRef ? { sourceRef: filter.sourceRef } : {},
|
|
9
|
+
...filter.extractorId ? { extractorId: filter.extractorId } : {},
|
|
10
|
+
...filter.extractorVersion ? { extractorVersion: filter.extractorVersion } : {},
|
|
11
|
+
limit: 500
|
|
12
|
+
}).filter((run) => !filter.runId || run.id === filter.runId);
|
|
13
|
+
const repaired = [];
|
|
14
|
+
const retained = [];
|
|
15
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16
|
+
const targetRunIds = runs.map((run) => run.id);
|
|
17
|
+
for (const run of runs) for (const output of listContextExtractionOutputs(run.id)) {
|
|
18
|
+
if (output.objectType !== "focus" && output.objectType !== "understanding" || !output.objectId) continue;
|
|
19
|
+
if (filter.objectVersionId && output.versionId !== filter.objectVersionId) continue;
|
|
20
|
+
const key = `${output.objectType}:${output.objectId}`;
|
|
21
|
+
if (seen.has(key)) continue;
|
|
22
|
+
seen.add(key);
|
|
23
|
+
if (hasIndependentExtractionOutput(targetRunIds, output.objectType, output.objectId)) {
|
|
24
|
+
retained.push({
|
|
25
|
+
objectType: output.objectType,
|
|
26
|
+
objectId: output.objectId,
|
|
27
|
+
reason: "independent_extraction"
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (output.objectType === "understanding") {
|
|
32
|
+
const understanding = getUnderstanding(output.objectId);
|
|
33
|
+
if (!understanding) continue;
|
|
34
|
+
if (understanding.explicitness === "explicit") {
|
|
35
|
+
retained.push({
|
|
36
|
+
objectType: "understanding",
|
|
37
|
+
objectId: output.objectId,
|
|
38
|
+
reason: "user_explicit"
|
|
39
|
+
});
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
setUnderstandingStatus(output.objectId, "archived");
|
|
43
|
+
} else {
|
|
44
|
+
const focus = listUserFocuses().find((item) => item.id === output.objectId);
|
|
45
|
+
if (!focus) continue;
|
|
46
|
+
if (focus.explicitness === "explicit") {
|
|
47
|
+
retained.push({
|
|
48
|
+
objectType: "focus",
|
|
49
|
+
objectId: output.objectId,
|
|
50
|
+
reason: "user_explicit"
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
updateUserFocus(output.objectId, { status: "paused" });
|
|
55
|
+
}
|
|
56
|
+
repaired.push({
|
|
57
|
+
objectType: output.objectType,
|
|
58
|
+
objectId: output.objectId
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
runIds: runs.map((run) => run.id),
|
|
63
|
+
repaired,
|
|
64
|
+
retained
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { repairExtractedContext };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { consumeContextConsent, ensureContextConsent, getUserProfile, listCollaborationRules, recordContextRun } from "../storage/sqlite/user-context-repository.js";
|
|
1
|
+
import { consumeContextConsent, ensureContextConsent, getUserProfile, listCollaborationRules, listUnderstandingEvidence, recordContextRun } from "../storage/sqlite/user-context-repository.js";
|
|
2
|
+
import { retrievalLexicalSimilarity } from "../retrieval/textFeatures.js";
|
|
3
|
+
import { buildRetrievalQueryProfile } from "../retrieval/queryProfile.js";
|
|
2
4
|
import "../storage/sqlite/index.js";
|
|
5
|
+
import { init_session_key, parseSessionKey } from "../routing/session-key.js";
|
|
3
6
|
import { readAgentMessageContent } from "../agent/memory/agent-message-access.js";
|
|
4
7
|
import { buildUserContextBlock } from "../agent/memory/context-fence.js";
|
|
5
|
-
import { listUserFocuses } from "./sources/repository.js";
|
|
8
|
+
import { getUnderstandingSourceGrant, getUnderstandingSourceRun, listUserFocuses } from "./sources/repository.js";
|
|
6
9
|
import { matchesUserContextScope } from "./scope.js";
|
|
7
10
|
import { UserUnderstandingRetriever } from "./retriever.js";
|
|
8
11
|
import { randomUUID } from "node:crypto";
|
|
9
12
|
//#region src/user-context/planner.ts
|
|
13
|
+
init_session_key();
|
|
10
14
|
const DEFAULT_MAX_CONTEXT_CHARS = 6e3;
|
|
11
15
|
const DEFAULT_MAX_RESULTS = 12;
|
|
16
|
+
const MAX_FOCUS_RESULTS = 3;
|
|
17
|
+
const MIN_RELEVANCE_SCORE = .25;
|
|
12
18
|
function prependAgentContext(message, block) {
|
|
13
19
|
if (!block) return message;
|
|
14
20
|
const prefix = `${block}\n\n`;
|
|
@@ -44,29 +50,82 @@ function sectionFor(item) {
|
|
|
44
50
|
].includes(item.kind)) return "interaction";
|
|
45
51
|
return "task";
|
|
46
52
|
}
|
|
47
|
-
function
|
|
48
|
-
if (item.explicitness === "explicit") return
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
function sourceDescription(item) {
|
|
54
|
+
if (item.explicitness === "explicit") return {
|
|
55
|
+
origin: "told_by_user",
|
|
56
|
+
label: "You told xopc"
|
|
57
|
+
};
|
|
58
|
+
const connected = listUnderstandingEvidence(item.id).find((evidence) => evidence.sourceType === "connector");
|
|
59
|
+
if (connected) return {
|
|
60
|
+
origin: "connected_source",
|
|
61
|
+
label: connected.sourceInstanceId ?? "Connected source"
|
|
62
|
+
};
|
|
63
|
+
if (item.explicitness === "observed") return {
|
|
64
|
+
origin: "observed",
|
|
65
|
+
label: "Observed across prior work"
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
origin: "inferred",
|
|
69
|
+
label: "An inference that may be wrong"
|
|
70
|
+
};
|
|
51
71
|
}
|
|
52
|
-
function
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
function focusSourceDescription(focus) {
|
|
73
|
+
if (focus.explicitness === "explicit") return {
|
|
74
|
+
origin: "told_by_user",
|
|
75
|
+
label: "You set this focus"
|
|
76
|
+
};
|
|
77
|
+
const sourceRun = focus.sourceRunId ? getUnderstandingSourceRun(focus.sourceRunId) : null;
|
|
78
|
+
const grant = sourceRun ? getUnderstandingSourceGrant(sourceRun.grantId) : null;
|
|
79
|
+
if (grant?.adapterId.startsWith("connector:")) return {
|
|
80
|
+
origin: "connected_source",
|
|
81
|
+
label: grant.displayName
|
|
82
|
+
};
|
|
83
|
+
if (focus.explicitness === "observed") return {
|
|
84
|
+
origin: "observed",
|
|
85
|
+
label: "Observed across prior work"
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
origin: "inferred",
|
|
89
|
+
label: "Suggested from prior work"
|
|
90
|
+
};
|
|
56
91
|
}
|
|
57
|
-
function rejectionReason(item, input, now) {
|
|
58
|
-
|
|
59
|
-
if (item.status === "
|
|
92
|
+
function rejectionReason(item, input, now, timeHints) {
|
|
93
|
+
const historical = timeHints.includes("historical") && item.validTo !== void 0;
|
|
94
|
+
if (item.status === "needs_review" || item.status === "candidate" || item.status === "stale" && !historical) return "needs_review";
|
|
95
|
+
if (item.status === "rejected" || item.status === "archived" && !historical) return "disabled";
|
|
60
96
|
if (!matchesUserContextScope(item.scope, input)) return "scope_mismatch";
|
|
61
|
-
if (item.validFrom && item.validFrom > now) return "not_yet_valid";
|
|
62
|
-
if (item.validTo && item.validTo < now || item.expiresAt && item.expiresAt < now) return "expired";
|
|
97
|
+
if (item.validFrom && item.validFrom > now && !timeHints.includes("future")) return "not_yet_valid";
|
|
98
|
+
if ((item.validTo && item.validTo < now || item.expiresAt && item.expiresAt < now) && !historical) return "expired";
|
|
63
99
|
if (item.sensitivity === "secret" || item.sensitivity === "regulated") return "sensitive";
|
|
64
100
|
if (item.conflictGroupId) return "conflict";
|
|
65
101
|
}
|
|
66
102
|
function ruleMatches(rule, input) {
|
|
67
103
|
if (rule.status !== "active" || !matchesUserContextScope(rule.scope, input)) return false;
|
|
68
104
|
const channel = typeof rule.conditions.channel === "string" ? rule.conditions.channel : void 0;
|
|
69
|
-
|
|
105
|
+
const agentId = typeof rule.conditions.agentId === "string" ? rule.conditions.agentId : void 0;
|
|
106
|
+
return (!channel || channel === input.channel) && (!agentId || agentId === input.agentId);
|
|
107
|
+
}
|
|
108
|
+
function focusRejectionReason(focus, input, now) {
|
|
109
|
+
if (focus.status !== "active") return "disabled";
|
|
110
|
+
if (!matchesUserContextScope(focus.scope, input)) return "scope_mismatch";
|
|
111
|
+
if (focus.validFrom && focus.validFrom > now) return "not_yet_valid";
|
|
112
|
+
if (focus.validTo && focus.validTo < now) return "expired";
|
|
113
|
+
if (focus.sensitivity === "secret" || focus.sensitivity === "regulated") return "sensitive";
|
|
114
|
+
if (focus.disclosurePolicy === "ask_before_reference") return "requires_consent";
|
|
115
|
+
}
|
|
116
|
+
function focusScore(focus, query, scopeInput) {
|
|
117
|
+
const lexical = retrievalLexicalSimilarity(buildRetrievalQueryProfile(query, scopeInput).normalized, `${focus.title} ${focus.summary}`);
|
|
118
|
+
const scoped = focus.scope.type !== "global" && matchesUserContextScope(focus.scope, scopeInput);
|
|
119
|
+
return Math.min(1, lexical * .75 + focus.confidence * .15 + (scoped ? .25 : 0));
|
|
120
|
+
}
|
|
121
|
+
function renderContextBlock(params) {
|
|
122
|
+
const understandingItems = params.items.filter((item) => item.objectType === "understanding");
|
|
123
|
+
return [
|
|
124
|
+
params.profileLines.length ? `<user-profile>\n${params.profileLines.join("\n")}\n</user-profile>` : "",
|
|
125
|
+
params.focuses.length ? `<active-focuses>\n${params.focuses.map((focus) => `- ${focus.title}: ${focus.summary} (${focus.horizon})`).join("\n")}\n</active-focuses>` : "",
|
|
126
|
+
params.rules.length ? `<collaboration-contract>\n${params.rules.map((rule) => `- ${rule.statement}`).join("\n")}\n</collaboration-contract>` : "",
|
|
127
|
+
understandingItems.length ? buildUserContextBlock(understandingItems.map((item) => `- ${item.content}\n Evidence: ${params.understandingSources.get(item.recordId) ?? "Unknown source"}`).join("\n")) : ""
|
|
128
|
+
].filter(Boolean).join("\n\n");
|
|
70
129
|
}
|
|
71
130
|
var UserContextPlanner = class {
|
|
72
131
|
retriever = new UserUnderstandingRetriever();
|
|
@@ -91,12 +150,24 @@ var UserContextPlanner = class {
|
|
|
91
150
|
workspaceId: params.workspaceId,
|
|
92
151
|
...params.projectId ? { projectId: params.projectId } : {}
|
|
93
152
|
};
|
|
153
|
+
const queryProfile = buildRetrievalQueryProfile(query, scopeInput);
|
|
94
154
|
const excluded = new Set(params.excludedRecordIds ?? []);
|
|
95
155
|
const rejected = [];
|
|
96
156
|
const consentRequests = [];
|
|
97
157
|
const traceItems = [];
|
|
98
158
|
const items = [];
|
|
159
|
+
const selectedFocuses = [];
|
|
160
|
+
const selectedRules = [];
|
|
161
|
+
const understandingSources = /* @__PURE__ */ new Map();
|
|
99
162
|
let usedChars = 0;
|
|
163
|
+
const render = (overrides = {}) => renderContextBlock({
|
|
164
|
+
profileLines,
|
|
165
|
+
focuses: selectedFocuses,
|
|
166
|
+
rules: selectedRules,
|
|
167
|
+
items,
|
|
168
|
+
understandingSources,
|
|
169
|
+
...overrides
|
|
170
|
+
});
|
|
100
171
|
const profile = getUserProfile();
|
|
101
172
|
const profileLines = [
|
|
102
173
|
profile.callName ? `Preferred name: ${profile.callName}` : "",
|
|
@@ -108,28 +179,103 @@ var UserContextPlanner = class {
|
|
|
108
179
|
].filter(Boolean);
|
|
109
180
|
if (profileLines.length) {
|
|
110
181
|
const content = profileLines.join("\n");
|
|
182
|
+
const nextChars = render().length;
|
|
183
|
+
if (nextChars <= maxChars) {
|
|
184
|
+
traceItems.push({
|
|
185
|
+
objectType: "profile",
|
|
186
|
+
objectId: "profile",
|
|
187
|
+
decision: "selected",
|
|
188
|
+
reason: "User-provided profile",
|
|
189
|
+
content,
|
|
190
|
+
sourceLabel: "You provided this directly",
|
|
191
|
+
origin: "told_by_user",
|
|
192
|
+
rank: 0,
|
|
193
|
+
score: 1,
|
|
194
|
+
injectedChars: nextChars
|
|
195
|
+
});
|
|
196
|
+
usedChars = nextChars;
|
|
197
|
+
} else {
|
|
198
|
+
profileLines.length = 0;
|
|
199
|
+
traceItems.push({
|
|
200
|
+
objectType: "profile",
|
|
201
|
+
objectId: "profile",
|
|
202
|
+
decision: "budget_exceeded",
|
|
203
|
+
reason: "Context budget reached",
|
|
204
|
+
content,
|
|
205
|
+
sourceLabel: "You provided this directly",
|
|
206
|
+
origin: "told_by_user",
|
|
207
|
+
injectedChars: 0
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const rankedFocuses = listUserFocuses(["active"]).map((focus) => ({
|
|
212
|
+
focus,
|
|
213
|
+
score: focusScore(focus, query, scopeInput)
|
|
214
|
+
})).sort((left, right) => right.score - left.score || right.focus.updatedAt - left.focus.updatedAt);
|
|
215
|
+
for (const { focus, score } of rankedFocuses) {
|
|
216
|
+
const source = focusSourceDescription(focus);
|
|
217
|
+
let reason = focusRejectionReason(focus, scopeInput, now);
|
|
218
|
+
if (!reason && score <= MIN_RELEVANCE_SCORE) reason = "low_score";
|
|
219
|
+
if (!reason && selectedFocuses.length >= MAX_FOCUS_RESULTS) reason = "budget";
|
|
220
|
+
if (!reason && items.length >= maxResults) reason = "budget";
|
|
221
|
+
const content = `${focus.title}: ${focus.summary} (${focus.horizon})`;
|
|
222
|
+
const nextChars = render({ focuses: [...selectedFocuses, focus] }).length;
|
|
223
|
+
if (!reason && nextChars > maxChars) reason = "budget";
|
|
224
|
+
if (reason) {
|
|
225
|
+
rejected.push({
|
|
226
|
+
recordId: focus.id,
|
|
227
|
+
reason
|
|
228
|
+
});
|
|
229
|
+
traceItems.push({
|
|
230
|
+
objectType: "focus",
|
|
231
|
+
objectId: focus.id,
|
|
232
|
+
versionId: focus.versionId,
|
|
233
|
+
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",
|
|
234
|
+
reason,
|
|
235
|
+
content,
|
|
236
|
+
sourceLabel: source.label,
|
|
237
|
+
origin: source.origin,
|
|
238
|
+
score,
|
|
239
|
+
injectedChars: 0
|
|
240
|
+
});
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const addedChars = nextChars - usedChars;
|
|
244
|
+
usedChars = nextChars;
|
|
245
|
+
selectedFocuses.push(focus);
|
|
246
|
+
items.push({
|
|
247
|
+
recordId: focus.id,
|
|
248
|
+
objectType: "focus",
|
|
249
|
+
versionId: focus.versionId,
|
|
250
|
+
content,
|
|
251
|
+
score,
|
|
252
|
+
section: "task",
|
|
253
|
+
citation: `user-focus://${focus.id}`,
|
|
254
|
+
origin: source.origin,
|
|
255
|
+
stability: focus.confidence
|
|
256
|
+
});
|
|
111
257
|
traceItems.push({
|
|
112
|
-
objectType: "
|
|
113
|
-
objectId:
|
|
258
|
+
objectType: "focus",
|
|
259
|
+
objectId: focus.id,
|
|
260
|
+
versionId: focus.versionId,
|
|
114
261
|
decision: "selected",
|
|
115
|
-
reason: "
|
|
262
|
+
reason: "Relevant active focus",
|
|
116
263
|
content,
|
|
117
|
-
sourceLabel:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
264
|
+
sourceLabel: source.label,
|
|
265
|
+
origin: source.origin,
|
|
266
|
+
rank: items.length,
|
|
267
|
+
score,
|
|
268
|
+
injectedChars: addedChars
|
|
121
269
|
});
|
|
122
|
-
usedChars += content.length;
|
|
123
270
|
}
|
|
124
|
-
const activeFocusLines = listUserFocuses(["active"]).slice(0, 5).map((focus) => `- ${focus.title}: ${focus.summary} (${focus.horizon})`);
|
|
125
|
-
if (activeFocusLines.length) usedChars += activeFocusLines.join("\n").length;
|
|
126
271
|
const rules = listCollaborationRules().filter((rule) => ruleMatches(rule, {
|
|
127
272
|
...scopeInput,
|
|
128
|
-
channel: params.channel
|
|
273
|
+
channel: params.channel,
|
|
274
|
+
agentId: parseSessionKey(params.sessionKey)?.agentId
|
|
129
275
|
}));
|
|
130
|
-
const selectedRules = [];
|
|
131
276
|
for (const [index, rule] of rules.entries()) {
|
|
132
|
-
|
|
277
|
+
const nextChars = render({ rules: [...selectedRules, rule] }).length;
|
|
278
|
+
if (nextChars > maxChars) {
|
|
133
279
|
traceItems.push({
|
|
134
280
|
objectType: "rule",
|
|
135
281
|
objectId: rule.id,
|
|
@@ -138,11 +284,13 @@ var UserContextPlanner = class {
|
|
|
138
284
|
reason: "Context budget reached",
|
|
139
285
|
content: rule.statement,
|
|
140
286
|
sourceLabel: "Your collaboration rule",
|
|
287
|
+
origin: "told_by_user",
|
|
141
288
|
injectedChars: 0
|
|
142
289
|
});
|
|
143
290
|
continue;
|
|
144
291
|
}
|
|
145
|
-
|
|
292
|
+
const addedChars = nextChars - usedChars;
|
|
293
|
+
usedChars = nextChars;
|
|
146
294
|
selectedRules.push(rule);
|
|
147
295
|
traceItems.push({
|
|
148
296
|
objectType: "rule",
|
|
@@ -152,9 +300,10 @@ var UserContextPlanner = class {
|
|
|
152
300
|
reason: "Active collaboration rule",
|
|
153
301
|
content: rule.statement,
|
|
154
302
|
sourceLabel: "Your collaboration rule",
|
|
303
|
+
origin: "told_by_user",
|
|
155
304
|
rank: index + 1,
|
|
156
305
|
score: 1,
|
|
157
|
-
injectedChars:
|
|
306
|
+
injectedChars: addedChars
|
|
158
307
|
});
|
|
159
308
|
}
|
|
160
309
|
const ranked = this.retriever.retrieve({
|
|
@@ -168,6 +317,7 @@ var UserContextPlanner = class {
|
|
|
168
317
|
score: result.score
|
|
169
318
|
}));
|
|
170
319
|
for (const { item, score } of ranked) {
|
|
320
|
+
const source = sourceDescription(item);
|
|
171
321
|
if (items.length >= maxResults) {
|
|
172
322
|
rejected.push({
|
|
173
323
|
recordId: item.id,
|
|
@@ -180,14 +330,15 @@ var UserContextPlanner = class {
|
|
|
180
330
|
decision: "budget_exceeded",
|
|
181
331
|
reason: "Maximum result count reached",
|
|
182
332
|
content: item.statement,
|
|
183
|
-
sourceLabel:
|
|
333
|
+
sourceLabel: source.label,
|
|
334
|
+
origin: source.origin,
|
|
184
335
|
score,
|
|
185
336
|
injectedChars: 0
|
|
186
337
|
});
|
|
187
338
|
continue;
|
|
188
339
|
}
|
|
189
|
-
let reason = rejectionReason(item, scopeInput, now);
|
|
190
|
-
if (!reason && score
|
|
340
|
+
let reason = rejectionReason(item, scopeInput, now, queryProfile.timeHints);
|
|
341
|
+
if (!reason && score <= MIN_RELEVANCE_SCORE) reason = "low_score";
|
|
191
342
|
if (!reason && item.disclosurePolicy === "ask_before_reference") {
|
|
192
343
|
const consentStatus = consumeContextConsent(item.id, params.sessionKey);
|
|
193
344
|
if (consentStatus !== "granted") {
|
|
@@ -215,13 +366,30 @@ var UserContextPlanner = class {
|
|
|
215
366
|
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",
|
|
216
367
|
reason,
|
|
217
368
|
content: item.statement,
|
|
218
|
-
sourceLabel:
|
|
369
|
+
sourceLabel: source.label,
|
|
370
|
+
origin: source.origin,
|
|
219
371
|
score,
|
|
220
372
|
injectedChars: 0
|
|
221
373
|
});
|
|
222
374
|
continue;
|
|
223
375
|
}
|
|
224
|
-
|
|
376
|
+
const plannedItem = {
|
|
377
|
+
recordId: item.id,
|
|
378
|
+
objectType: "understanding",
|
|
379
|
+
versionId: item.versionId,
|
|
380
|
+
content: item.statement,
|
|
381
|
+
score,
|
|
382
|
+
section: sectionFor(item),
|
|
383
|
+
citation: `user-context://${item.id}`,
|
|
384
|
+
origin: source.origin,
|
|
385
|
+
stability: item.confidence
|
|
386
|
+
};
|
|
387
|
+
const nextSources = new Map(understandingSources).set(item.id, source.label);
|
|
388
|
+
const nextChars = render({
|
|
389
|
+
items: [...items, plannedItem],
|
|
390
|
+
understandingSources: nextSources
|
|
391
|
+
}).length;
|
|
392
|
+
if (nextChars > maxChars) {
|
|
225
393
|
rejected.push({
|
|
226
394
|
recordId: item.id,
|
|
227
395
|
reason: "budget"
|
|
@@ -233,24 +401,17 @@ var UserContextPlanner = class {
|
|
|
233
401
|
decision: "budget_exceeded",
|
|
234
402
|
reason: "Context budget reached",
|
|
235
403
|
content: item.statement,
|
|
236
|
-
sourceLabel:
|
|
404
|
+
sourceLabel: source.label,
|
|
405
|
+
origin: source.origin,
|
|
237
406
|
score,
|
|
238
407
|
injectedChars: 0
|
|
239
408
|
});
|
|
240
409
|
continue;
|
|
241
410
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
versionId: item.versionId,
|
|
247
|
-
content: item.statement,
|
|
248
|
-
score,
|
|
249
|
-
section: sectionFor(item),
|
|
250
|
-
citation: `user-context://${item.id}`,
|
|
251
|
-
origin: originFor(item),
|
|
252
|
-
stability: item.confidence
|
|
253
|
-
});
|
|
411
|
+
const addedChars = nextChars - usedChars;
|
|
412
|
+
usedChars = nextChars;
|
|
413
|
+
understandingSources.set(item.id, source.label);
|
|
414
|
+
items.push(plannedItem);
|
|
254
415
|
traceItems.push({
|
|
255
416
|
objectType: "understanding",
|
|
256
417
|
objectId: item.id,
|
|
@@ -258,18 +419,14 @@ var UserContextPlanner = class {
|
|
|
258
419
|
decision: "selected",
|
|
259
420
|
reason: "Relevant to this request",
|
|
260
421
|
content: item.statement,
|
|
261
|
-
sourceLabel:
|
|
422
|
+
sourceLabel: source.label,
|
|
423
|
+
origin: source.origin,
|
|
262
424
|
rank: items.length,
|
|
263
425
|
score,
|
|
264
|
-
injectedChars:
|
|
426
|
+
injectedChars: addedChars
|
|
265
427
|
});
|
|
266
428
|
}
|
|
267
|
-
const block =
|
|
268
|
-
profileLines.length ? `<user-profile>\n${profileLines.join("\n")}\n</user-profile>` : "",
|
|
269
|
-
activeFocusLines.length ? `<active-focuses>\n${activeFocusLines.join("\n")}\n</active-focuses>` : "",
|
|
270
|
-
selectedRules.length ? `<collaboration-contract>\n${selectedRules.map((rule) => `- ${rule.statement}`).join("\n")}\n</collaboration-contract>` : "",
|
|
271
|
-
items.length ? buildUserContextBlock(items.map((item) => `- ${item.content}\n Evidence: ${traceItems.find((trace) => trace.objectId === item.recordId)?.sourceLabel}`).join("\n")) : ""
|
|
272
|
-
].filter(Boolean).join("\n\n");
|
|
429
|
+
const block = render();
|
|
273
430
|
recordContextRun({
|
|
274
431
|
turnId: params.turnId,
|
|
275
432
|
sessionKey: params.sessionKey,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { summarizeUnderstandingFeedback } from "../storage/sqlite/user-context-quality-repository.js";
|
|
2
|
-
import { listUnderstandings, searchActiveUnderstandings } from "../storage/sqlite/user-context-repository.js";
|
|
2
|
+
import { listUnderstandingEvidence, listUnderstandings, searchActiveUnderstandings } from "../storage/sqlite/user-context-repository.js";
|
|
3
3
|
import { normalizeRetrievalText, retrievalLexicalSimilarity } from "../retrieval/textFeatures.js";
|
|
4
4
|
import { buildRetrievalQueryProfile } from "../retrieval/queryProfile.js";
|
|
5
5
|
import "../storage/sqlite/index.js";
|
|
@@ -12,9 +12,62 @@ function authorityBonus(item) {
|
|
|
12
12
|
}
|
|
13
13
|
function baseline(item) {
|
|
14
14
|
if (item.kind === "boundary" && item.explicitness === "explicit") return .8;
|
|
15
|
-
if (item.kind === "preference" && item.explicitness === "explicit") return .
|
|
15
|
+
if (item.kind === "preference" && item.explicitness === "explicit") return .12;
|
|
16
16
|
return 0;
|
|
17
17
|
}
|
|
18
|
+
function temporalAdjustment(item, hints, now) {
|
|
19
|
+
if (!hints.length) return 0;
|
|
20
|
+
let score = 0;
|
|
21
|
+
if (hints.includes("historical")) score += item.validTo !== void 0 || item.status === "archived" || item.status === "stale" ? .14 : -.6;
|
|
22
|
+
if (hints.includes("current")) {
|
|
23
|
+
if (item.kind === "current_state" || item.validFrom !== void 0 || item.validTo !== void 0) {
|
|
24
|
+
const validNow = (item.validFrom === void 0 || item.validFrom <= now) && (item.validTo === void 0 || item.validTo > now);
|
|
25
|
+
score += validNow ? .08 : -.15;
|
|
26
|
+
if (item.kind === "current_state") score += .06;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (hints.includes("recent")) score += now - item.updatedAt <= 2160 * 60 * 6e4 ? .08 : -.04;
|
|
30
|
+
if (hints.includes("future")) {
|
|
31
|
+
if ((item.validFrom ?? 0) > now || item.kind === "long_term_goal") score += .1;
|
|
32
|
+
}
|
|
33
|
+
return score;
|
|
34
|
+
}
|
|
35
|
+
function sourceBucket(item) {
|
|
36
|
+
if (item.explicitness === "explicit") return "user";
|
|
37
|
+
const evidence = listUnderstandingEvidence(item.id)[0];
|
|
38
|
+
if (!evidence) return `unknown:${item.id}`;
|
|
39
|
+
if (evidence.sourceInstanceId) return `${evidence.sourceType}:${evidence.sourceInstanceId}`;
|
|
40
|
+
return `${evidence.sourceType}:${evidence.sourceRef.split(":entry:")[0]}`;
|
|
41
|
+
}
|
|
42
|
+
function diversify(results, limit) {
|
|
43
|
+
const remaining = [...results];
|
|
44
|
+
const selected = [];
|
|
45
|
+
const sourceCounts = /* @__PURE__ */ new Map();
|
|
46
|
+
const sourceBuckets = new Map(results.map((result) => [result.understanding.id, sourceBucket(result.understanding)]));
|
|
47
|
+
while (remaining.length && selected.length < limit) {
|
|
48
|
+
let bestIndex = 0;
|
|
49
|
+
let bestScore = Number.NEGATIVE_INFINITY;
|
|
50
|
+
for (const [index, candidate] of remaining.entries()) {
|
|
51
|
+
const redundancy = selected.reduce((maximum, chosen) => Math.max(maximum, retrievalLexicalSimilarity(candidate.understanding.statement, chosen.understanding.statement)), 0);
|
|
52
|
+
const bucket = sourceBuckets.get(candidate.understanding.id);
|
|
53
|
+
const sourcePenalty = candidate.understanding.explicitness === "explicit" ? 0 : (sourceCounts.get(bucket) ?? 0) * .04;
|
|
54
|
+
const adjusted = candidate.score - redundancy * .18 - sourcePenalty;
|
|
55
|
+
if (adjusted > bestScore) {
|
|
56
|
+
bestScore = adjusted;
|
|
57
|
+
bestIndex = index;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const candidate = remaining.splice(bestIndex, 1)[0];
|
|
61
|
+
const bucket = sourceBuckets.get(candidate.understanding.id);
|
|
62
|
+
sourceCounts.set(bucket, (sourceCounts.get(bucket) ?? 0) + 1);
|
|
63
|
+
selected.push({
|
|
64
|
+
...candidate,
|
|
65
|
+
score: Math.max(0, bestScore),
|
|
66
|
+
reasons: bestScore < candidate.score ? [...candidate.reasons, "diversified"] : candidate.reasons
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return selected;
|
|
70
|
+
}
|
|
18
71
|
function feedbackAdjustment(summary) {
|
|
19
72
|
if (!summary || summary.total < 3) return 0;
|
|
20
73
|
const helpfulRate = (summary.helpful + 1) / (summary.total + 2);
|
|
@@ -30,35 +83,42 @@ var UserUnderstandingRetriever = class {
|
|
|
30
83
|
});
|
|
31
84
|
if (!profile.normalized) return [];
|
|
32
85
|
const maxCandidates = Math.max(1, Math.min(200, Math.floor(params.maxCandidates)));
|
|
33
|
-
const fts = searchActiveUnderstandings(profile.
|
|
86
|
+
const fts = searchActiveUnderstandings(profile.expanded, Math.max(50, maxCandidates));
|
|
34
87
|
const ftsScores = new Map(fts.map((result) => [result.understanding.id, result.score]));
|
|
35
88
|
const recentLimit = Math.max(200, Math.min(500, maxCandidates * 5));
|
|
36
|
-
const recent = listUnderstandings(["
|
|
89
|
+
const recent = listUnderstandings([...profile.timeHints.includes("historical") ? [
|
|
90
|
+
"active",
|
|
91
|
+
"archived",
|
|
92
|
+
"stale"
|
|
93
|
+
] : ["active"]]).slice(0, recentLimit);
|
|
37
94
|
const candidates = /* @__PURE__ */ new Map();
|
|
38
95
|
for (const result of fts) candidates.set(result.understanding.id, result.understanding);
|
|
39
96
|
for (const item of recent) candidates.set(item.id, item);
|
|
40
97
|
const feedback = new Map(summarizeUnderstandingFeedback([...candidates.keys()]).map((summary) => [summary.understandingId, summary]));
|
|
41
|
-
|
|
42
|
-
|
|
98
|
+
const now = Date.now();
|
|
99
|
+
return diversify([...candidates.values()].map((item) => {
|
|
100
|
+
const lexical = Math.max(retrievalLexicalSimilarity(profile.normalized, item.statement), retrievalLexicalSimilarity(profile.expanded, item.statement));
|
|
43
101
|
const ftsScore = ftsScores.get(item.id) ?? 0;
|
|
44
102
|
const textScore = Math.max(lexical, ftsScore);
|
|
45
103
|
const kindMatched = profile.intentKinds.includes(item.kind);
|
|
46
104
|
const normalizedStatement = normalizeRetrievalText(item.statement);
|
|
47
105
|
const identifierMatched = profile.identifiers.some((identifier) => normalizedStatement.includes(identifier));
|
|
48
106
|
const feedbackScore = feedbackAdjustment(feedback.get(item.id));
|
|
107
|
+
const kindAdjustment = profile.intentKinds.length > 0 && !kindMatched && profile.timeHints.length === 0 ? -.35 : 0;
|
|
49
108
|
return {
|
|
50
109
|
understanding: item,
|
|
51
|
-
score: Math.min(1, Math.max(0, Math.max(baseline(item), textScore * .7 + lexical * .1 + item.confidence * .1 + authorityBonus(item) + (kindMatched ? .08 : 0) + (identifierMatched ? .12 : 0) + (matchesUserContextScope(item.scope, params) && item.scope.type !== "global" ? .05 : 0)) + feedbackScore)),
|
|
110
|
+
score: Math.min(1, Math.max(0, Math.max(baseline(item), textScore * .7 + lexical * .1 + item.confidence * .1 + authorityBonus(item) + (kindMatched ? .08 : 0) + kindAdjustment + (identifierMatched ? .12 : 0) + temporalAdjustment(item, profile.timeHints, now) + (matchesUserContextScope(item.scope, params) && item.scope.type !== "global" ? .05 : 0)) + feedbackScore)),
|
|
52
111
|
reasons: [
|
|
53
112
|
ftsScore > 0 ? "fts" : "",
|
|
54
113
|
lexical > 0 ? "lexical" : "",
|
|
55
114
|
identifierMatched ? "identifier" : "",
|
|
56
115
|
kindMatched ? "kind" : "",
|
|
57
116
|
item.explicitness === "explicit" ? "explicit" : "",
|
|
58
|
-
feedbackScore !== 0 ? "feedback" : ""
|
|
117
|
+
feedbackScore !== 0 ? "feedback" : "",
|
|
118
|
+
temporalAdjustment(item, profile.timeHints, now) !== 0 ? "temporal" : ""
|
|
59
119
|
].filter(Boolean)
|
|
60
120
|
};
|
|
61
|
-
}).sort((left, right) => Number(matchesUserContextScope(right.understanding.scope, params)) - Number(matchesUserContextScope(left.understanding.scope, params)) || right.score - left.score || right.understanding.updatedAt - left.understanding.updatedAt)
|
|
121
|
+
}).sort((left, right) => Number(matchesUserContextScope(right.understanding.scope, params)) - Number(matchesUserContextScope(left.understanding.scope, params)) || right.score - left.score || right.understanding.updatedAt - left.understanding.updatedAt), maxCandidates);
|
|
62
122
|
}
|
|
63
123
|
};
|
|
64
124
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant,
|
|
1
|
+
import { createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocusEvidence, listUserFocuses, revokeUnderstandingSourceGrant, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, updateUserFocus, upsertUnderstandingSourceGrant, upsertUserFocus } from "./repository.js";
|
|
2
2
|
import { clusterUnderstandingSignals, tokenizeUnderstandingSignal } from "./signal-clustering.js";
|
|
3
3
|
import { listUnderstandingSourceDefinitions } from "./catalog.js";
|
|
4
|
-
export { clusterUnderstandingSignals, createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant,
|
|
4
|
+
export { clusterUnderstandingSignals, createUnderstandingSourceRun, deleteUserFocus, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocusEvidence, listUserFocuses, revokeUnderstandingSourceGrant, tokenizeUnderstandingSignal, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, updateUserFocus, upsertUnderstandingSourceGrant, upsertUserFocus };
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import { type ContextEvidence, type UserContextScope } from '../domain.js';
|
|
1
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[];
|
|
2
16
|
export declare function listUnderstandingSourceGrants(options?: {
|
|
3
17
|
includeRevoked?: boolean;
|
|
4
18
|
}): UnderstandingSourceGrant[];
|
|
@@ -13,6 +27,12 @@ export declare function updateUnderstandingSourceGrantCheckpoint(id: string, inp
|
|
|
13
27
|
lastCollectedAt?: number;
|
|
14
28
|
nowMs?: number;
|
|
15
29
|
}): UnderstandingSourceGrant | null;
|
|
30
|
+
export declare function updateUnderstandingSourceGrantPolicies(id: string, patch: {
|
|
31
|
+
accessMode?: UnderstandingSourceGrant['accessMode'];
|
|
32
|
+
retentionPolicy?: UnderstandingSourceGrant['retentionPolicy'];
|
|
33
|
+
processingPolicy?: UnderstandingSourceGrant['processingPolicy'];
|
|
34
|
+
nowMs?: number;
|
|
35
|
+
}): UnderstandingSourceGrant | null;
|
|
16
36
|
export declare function revokeUnderstandingSourceGrant(id: string, nowMs?: number): UnderstandingSourceGrant | null;
|
|
17
37
|
export declare function createUnderstandingSourceRun(input: {
|
|
18
38
|
grantId: string;
|
|
@@ -33,9 +53,8 @@ export declare function updateUnderstandingSourceRun(id: string, patch: {
|
|
|
33
53
|
completed?: boolean;
|
|
34
54
|
nowMs?: number;
|
|
35
55
|
}): UnderstandingSourceRun | null;
|
|
36
|
-
export declare function upsertUserFocus(input:
|
|
37
|
-
nowMs?: number;
|
|
38
|
-
}): UserFocus;
|
|
56
|
+
export declare function upsertUserFocus(input: UserFocusInput): UserFocus;
|
|
39
57
|
export declare function listUserFocuses(statuses?: UserFocus['status'][]): UserFocus[];
|
|
40
|
-
export declare function
|
|
58
|
+
export declare function updateUserFocus(id: string, patch: Partial<Pick<UserFocus, 'title' | 'summary' | 'status'>>, nowMs?: number): UserFocus | null;
|
|
41
59
|
export declare function deleteUserFocus(id: string): boolean;
|
|
60
|
+
export {};
|