@xopcai/xopc 0.0.208 → 0.0.211
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-D0mYZqhc.js → activity-store-BzjFoSr0.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-MWLQWL_i.js → agent-avatar-dicebear-DTfjhfVE.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CjhgfuVJ.js +68 -0
- package/dist/gateway/static/root/assets/{api-DZA1yVzM.js → api-D269PnU9.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B2X6quAF.js → app-management-settings-panel-BFpfQDWc.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BZW-c38q.js → appearance-settings-DLxFdqhY.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CjmlGB5V.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CK-gsjsJ.js → archive-plugin-DPlH4dnc.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-EJGP4rCw.js → attachment-load-xqfLLd0I.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-4m6Ey6wG.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Tbss_4P-.js → binary-plugins-C0tuoPXk.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C-dOWigw.js → block-editor-Deyphj1o.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CAGCYx8U.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-DW06Zo1N.js → browser-workflow-inputs-CYEbXyRF.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-B6RnRGwm.js → browser-workflows-page-Bf0tPbGi.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CKfLsxTI.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-Cc3BtQar.js → capability-presets-api-DPkFA_-R.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CpipKNqX.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-BvZO5FaO.js → channel-recipient-api-DqKaAcnZ.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Bvq-O4pt.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-CrMld2l7.js +1 -0
- package/dist/gateway/static/root/assets/chat-terminal-dock-CTDRZa7e.js +36 -0
- package/dist/gateway/static/root/assets/{connectors-api-CUl6_EQJ.js → connectors-api-Buu8fif8.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CSQRzaVn.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-BD9MgoE_.js → cron-expression-DTLR82NB.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-ChqNmoxw.js → date-picker-DyNogHQH.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CDUmFs6H.js → dependency-picker-BpnCuo7B.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-D61gqxaD.js → desktop-pet-CDKI4gVB.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-QvuJvIX_.js → desktop-pet-settings-DjT5C2a3.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DvXMvDNY.js → directory-picker-path-field-DlJY90TM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DMdVTAQ3.js → extension-debug-page-DWf2z7q5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BNzxZtaK.js → extension-page-Dorx0kf9.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DoEfyizU.js → extension-settings-page-B1wU9ZOB.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-o7AKvthC.js → gateway-config-api-B1lG4dNr.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BQbkUP5X.js → gateway-config-swr-BIxuwPQi.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-TO5YYZ9a.js → gateway-settings-DqIOqJjM.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DIgdpHgk.js → gateway-startup-retry-BpZgd4U-.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DG4Kmgkc.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BhqItS_s.js +1 -0
- package/dist/gateway/static/root/assets/image-generation-api-PkhYohDa.js +1 -0
- package/dist/gateway/static/root/assets/index-DLhvsU9B.css +2 -0
- package/dist/gateway/static/root/assets/index-_cuTcWjB.js +107 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-4xaM3jjU.js → keyboard-shortcuts-settings-6OQT3gQF.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DWjTmzxw.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-C1xDicdr.js → local-apps-page-DfruRAmE.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-pByvK12G.js → locale-store-C5MK9WcP.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BA5efZ8B.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-D1XdHm7v.js → management-settings-L1VYkywO.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-B_Ijq1Fr.js → markdown-split-oqgHbqt-.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-DD_PgVue.css +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-CyJlGUxB.js → markdown-view-V4rcPPH0.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CXXNRROJ.js → media-plugins-Bb6gSX2o.js} +1 -1
- package/dist/gateway/static/root/assets/messages-ctG2e-ix.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-rkePB4CB.js → notes-page-B1rOXjpT.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CkHXVmKP.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-gw-RMQCV.js → page-tabs-CBuCKeyy.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B8aMScJ2.js → preview-open-alternatives-BQ0tLfPO.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CjcpkWAz.js → product-open-page-DPeFn7Hu.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DCqet9-L.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D0t_AjzG.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BUWPoBvw.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Ch5qq86o.js → runtime-tools-settings-panel-BCfQNzjG.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-DHYWYUFt.js → schema-form-Bo7YbHYN.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-vLhrrM3m.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-OP1y0Y8M.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DlzZx0-i.js → settings-form-section-B9dnKr3M.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BVLhreQi.js → settings-loading-skeleton-CYDV2JtY.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BJU-kUnN.js → settings-page-DbrIYfS9.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Cxc-Ejl5.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-hvIuZXMe.js → share-preview-page-olgr7LLN.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-ZOqC6-aA.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DwvC3Iuf.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Dlvuh7D-.js → skills-page-PE16CNw5.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-B6ddOpnf.js → skills-page.utils-nXmBcBxt.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BdbCAyoA.js → system-settings-panel-C3qPwAdY.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DCRB-5q-.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BtdGacMI.js → theme-store-KR5Otp5w.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CL6qHYJA.js → typed-models-lib-lMZodtDF.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DysNnqCS.js → use-autosave-CKpatP3S.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-CoiedRuA.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-UEsO9Jr-.js → voice-api-key-field-CDcv0Wbh.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B9disASf.js → work-discovery-overlay-CGdT22un.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BwaU1RqI.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-A0zTQHFQ.js → workflow-run-setup-panel-BAHYNlQt.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DHYmh9G7.js +5 -0
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/background-review/coordinator.d.ts +1 -1
- package/dist/src/agent/background-review/coordinator.js +4 -5
- package/dist/src/agent/background-review/run-background-review.js +0 -1
- package/dist/src/agent/background-review/settings.d.ts +1 -2
- package/dist/src/agent/background-review/settings.js +3 -4
- package/dist/src/agent/external-tools/composio-provider.js +8 -4
- package/dist/src/agent/image/generation/providers/xopc-cloud.js +2 -1
- package/dist/src/agent/image/tool-model-config.js +15 -9
- package/dist/src/agent/memory/builtin-provider.js +1 -2
- package/dist/src/agent/memory/manager.js +2 -0
- package/dist/src/agent/memory/sensitivity.js +1 -1
- package/dist/src/agent/memory/understanding/service.js +43 -19
- package/dist/src/agent/memory/user-context-coordinator.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +23 -7
- package/dist/src/automations/domain/validation.d.ts +7 -7
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
- package/dist/src/capabilities/readiness/from-config.d.ts +10 -0
- package/dist/src/capabilities/readiness/from-config.js +128 -0
- package/dist/src/capabilities/readiness/index.d.ts +3 -0
- package/dist/src/capabilities/readiness/index.js +3 -0
- package/dist/src/capabilities/readiness/planner.d.ts +3 -0
- package/dist/src/capabilities/readiness/planner.js +56 -0
- package/dist/src/capabilities/readiness/types.d.ts +35 -0
- package/dist/src/capabilities/readiness/types.js +1 -0
- package/dist/src/cli/commands/agent.js +9 -0
- package/dist/src/cli/commands/auth.js +4 -3
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/models.js +2 -1
- package/dist/src/cli/commands/onboard/model.d.ts +3 -21
- package/dist/src/cli/commands/onboard/model.js +10 -86
- package/dist/src/cli/utils/oauth-login.d.ts +2 -0
- package/dist/src/cli/utils/oauth-login.js +9 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/paths-state.d.ts +2 -0
- package/dist/src/config/paths-state.js +5 -1
- package/dist/src/config/paths.d.ts +1 -1
- package/dist/src/config/paths.js +2 -2
- package/dist/src/config/schema.js +1 -1
- package/dist/src/connectors/auth-provider-registry.d.ts +2 -1
- package/dist/src/connectors/auth-provider-registry.js +5 -2
- package/dist/src/connectors/composio-sessions.d.ts +39 -0
- package/dist/src/connectors/composio-sessions.js +66 -7
- package/dist/src/connectors/composio.d.ts +4 -1
- package/dist/src/connectors/composio.js +34 -7
- package/dist/src/connectors/connected-source-cursor.d.ts +9 -0
- package/dist/src/connectors/connected-source-cursor.js +30 -0
- package/dist/src/connectors/connected-source-ingestion.js +67 -46
- package/dist/src/connectors/connected-source-normalizers.d.ts +1 -0
- package/dist/src/connectors/connected-source-normalizers.js +33 -2
- package/dist/src/connectors/connected-source-sanitization.d.ts +1 -0
- package/dist/src/connectors/connected-source-sanitization.js +21 -0
- package/dist/src/connectors/connector-identity.js +10 -2
- package/dist/src/connectors/content-enrichment.d.ts +29 -0
- package/dist/src/connectors/content-enrichment.js +273 -0
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/learning-coordinator.js +1 -2
- package/dist/src/connectors/learning-recipes.js +28 -33
- package/dist/src/connectors/runtime-adapter-registry.js +14 -1
- package/dist/src/discussions/live-worker.d.ts +1 -0
- package/dist/src/discussions/live-worker.js +7 -1
- package/dist/src/discussions/repository.js +11 -1
- package/dist/src/discussions/sealer.d.ts +1 -1
- package/dist/src/discussions/sealer.js +16 -7
- package/dist/src/discussions/transcript.js +27 -1
- package/dist/src/discussions/types.d.ts +4 -0
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/app.js +8 -3
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
- package/dist/src/gateway/hono/oauth-async.d.ts +11 -5
- package/dist/src/gateway/hono/oauth-async.js +29 -16
- package/dist/src/gateway/hono/oauth.d.ts +1 -3
- package/dist/src/gateway/hono/oauth.js +22 -22
- package/dist/src/gateway/hono/routes/agent-stream.js +4 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +16 -3
- package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
- package/dist/src/gateway/hono/routes/discussions.js +2 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +2 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +59 -5
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +60 -0
- package/dist/src/gateway/hono/routes/session-input-handler.js +75 -1
- package/dist/src/gateway/hono/routes/understanding-sources.js +29 -0
- package/dist/src/gateway/hono/routes/voice.d.ts +1 -2
- package/dist/src/gateway/hono/routes/voice.js +16 -35
- package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
- package/dist/src/gateway/rate-limit/buckets.js +12 -0
- package/dist/src/gateway/service/agent-runner.d.ts +9 -1
- package/dist/src/gateway/service/agent-runner.js +9 -0
- package/dist/src/gateway/service/session-input-coordinator.d.ts +12 -0
- package/dist/src/gateway/service/session-input-coordinator.js +63 -6
- package/dist/src/gateway/service.d.ts +8 -0
- package/dist/src/gateway/service.js +18 -0
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
- package/dist/src/knowledge/connected-understanding-pipeline.js +74 -25
- package/dist/src/knowledge/ingestion-service.js +33 -15
- package/dist/src/knowledge/types.d.ts +2 -0
- package/dist/src/media-understanding/audio-transcription-runner.d.ts +2 -0
- package/dist/src/media-understanding/audio-transcription-runner.js +3 -1
- package/dist/src/media-understanding/runner.js +3 -1
- package/dist/src/media-understanding/types.d.ts +2 -0
- package/dist/src/providers/model-catalog-persistence.d.ts +9 -0
- package/dist/src/providers/model-catalog-persistence.js +172 -0
- package/dist/src/providers/model-catalog-ranking.d.ts +2 -0
- package/dist/src/providers/model-catalog-ranking.js +17 -0
- package/dist/src/providers/model-catalog-store.d.ts +13 -3
- package/dist/src/providers/model-catalog-store.js +24 -5
- package/dist/src/providers/model-catalog-sync-service.d.ts +3 -3
- package/dist/src/providers/model-catalog-sync-service.js +12 -7
- package/dist/src/providers/provider-auth-service.d.ts +1 -0
- package/dist/src/providers/provider-auth-service.js +3 -0
- package/dist/src/providers/provider-disconnect.d.ts +11 -0
- package/dist/src/providers/provider-disconnect.js +33 -0
- package/dist/src/providers/xopc-cloud-catalog-coordinator.d.ts +56 -0
- package/dist/src/providers/xopc-cloud-catalog-coordinator.js +182 -0
- package/dist/src/providers/xopc-cloud-model-source.d.ts +6 -10
- package/dist/src/providers/xopc-cloud-model-source.js +49 -27
- package/dist/src/retrieval/audit.d.ts +1 -0
- package/dist/src/retrieval/audit.js +8 -0
- package/dist/src/retrieval/candidateFusion.d.ts +5 -0
- package/dist/src/retrieval/candidateFusion.js +20 -0
- package/dist/src/retrieval/queryProfile.d.ts +16 -0
- package/dist/src/retrieval/queryProfile.js +66 -0
- package/dist/src/retrieval/textFeatures.d.ts +5 -0
- package/dist/src/retrieval/textFeatures.js +71 -0
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +4 -0
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/storage/sqlite/fts.d.ts +0 -4
- package/dist/src/storage/sqlite/fts.js +2 -49
- package/dist/src/storage/sqlite/index.d.ts +3 -2
- package/dist/src/storage/sqlite/index.js +6 -5
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/knowledge-repository.js +4 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +60 -38
- package/dist/src/storage/sqlite/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/session-repository.js +2 -2
- package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +34 -0
- package/dist/src/storage/sqlite/session-turn-replace-repository.js +110 -0
- package/dist/src/storage/sqlite/transcript-repository.js +1 -1
- package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +15 -0
- package/dist/src/storage/sqlite/user-context-quality-repository.js +46 -2
- package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -0
- package/dist/src/storage/sqlite/user-context-repository.js +29 -3
- package/dist/src/tasks/home-query-service.d.ts +3 -1
- package/dist/src/tasks/home-query-service.js +73 -70
- package/dist/src/tui/backends/embedded-backend.js +12 -4
- package/dist/src/tui/tui-oauth-login.js +5 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/user-context/planner.d.ts +1 -0
- package/dist/src/user-context/planner.js +16 -29
- package/dist/src/user-context/retriever.d.ts +15 -0
- package/dist/src/user-context/retriever.js +65 -0
- package/dist/src/user-context/scope.d.ts +7 -0
- package/dist/src/user-context/scope.js +9 -0
- package/dist/src/user-context/sources/activity-clustering.js +30 -117
- package/dist/src/user-context/sources/index.d.ts +1 -0
- package/dist/src/user-context/sources/index.js +2 -1
- package/dist/src/user-context/sources/signal-clustering.d.ts +18 -0
- package/dist/src/user-context/sources/signal-clustering.js +131 -0
- package/dist/src/voice/audio/normalize.d.ts +17 -0
- package/dist/src/voice/audio/normalize.js +155 -0
- package/dist/src/voice/language-profile.d.ts +1 -4
- package/dist/src/voice/language-profile.js +2 -25
- package/dist/src/voice/local/runtime-client.d.ts +2 -0
- package/dist/src/voice/local/runtime-client.js +20 -1
- package/dist/src/voice/local/runtime-worker.js +7 -13
- package/dist/src/voice/local/wav.js +1 -1
- package/dist/src/voice/stt/availability.d.ts +1 -4
- package/dist/src/voice/stt/availability.js +3 -15
- package/dist/src/voice/stt/config.js +1 -0
- package/dist/src/voice/stt/factory.js +23 -0
- package/dist/src/voice/stt/index.d.ts +1 -0
- package/dist/src/voice/stt/index.js +2 -2
- package/dist/src/voice/stt/list-providers.js +1 -1
- package/dist/src/voice/stt/providers/local-transcription.js +7 -3
- package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +3 -1
- package/dist/src/voice/stt/transcribe-core.d.ts +5 -1
- package/dist/src/voice/stt/transcribe-core.js +13 -5
- package/dist/src/voice/stt/types.d.ts +2 -0
- package/dist/src/voice/tts/factory.d.ts +1 -1
- package/dist/src/voice/tts/factory.js +23 -1
- package/dist/src/voice/tts/merge-config.js +5 -3
- package/dist/src/voice/tts/providers/xopc-cloud-speech.js +3 -1
- package/dist/src/voice/tts/types.d.ts +2 -0
- package/dist/src/voice/tts/types.js +4 -2
- package/dist/src/work-discovery/evaluation.d.ts +23 -0
- package/dist/src/work-discovery/evaluation.js +18 -1
- package/dist/src/work-discovery/index.js +2 -2
- package/package.json +4 -3
- package/dist/gateway/static/root/assets/agents-Bl8FQZxW.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-CRUgTO10.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-DrSwolhG.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-NlvDyMwD.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BWXUznw5.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-D0loEbzq.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-CcivCw8U.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DkHAD2Zn.js +0 -1
- package/dist/gateway/static/root/assets/chat-terminal-dock-DVedGAeX.js +0 -36
- package/dist/gateway/static/root/assets/connectors-page-DlBSlfkv.js +0 -2
- package/dist/gateway/static/root/assets/heartbeat-settings-UZAn1aAQ.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CRJDpy5E.js +0 -3
- package/dist/gateway/static/root/assets/index-BSjP0Wsx.css +0 -2
- package/dist/gateway/static/root/assets/index-C2ZYFBGL.js +0 -85
- package/dist/gateway/static/root/assets/local-app-workbench-page-D9bguWRo.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-Gr-nE4nW.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-B12xeflb.css +0 -1
- package/dist/gateway/static/root/assets/messages-yG5P43Q9.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-CpbD4XG2.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-GvSYDbjR.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DPRxKGbs.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-WIzeu-gB.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-2XEJM0YE.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-g1GThZ0O.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C6qj2L-q.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BBpE1bep.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DXORBJNk.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DC0hc8hp.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Bwg4KV8B.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CmPfOfHl.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DhQNh7W6.js +0 -5
- package/dist/src/voice/local/runtime-dispatcher.d.ts +0 -9
- package/dist/src/voice/local/runtime-dispatcher.js +0 -20
|
@@ -3,6 +3,7 @@ import type { TranscriptStoredRow } from './session-context-for-llm.js';
|
|
|
3
3
|
/** Transcript row for TUI and HTTP clients (flattened from persisted session messages). */
|
|
4
4
|
export interface ClientHistoryMessage {
|
|
5
5
|
id?: string;
|
|
6
|
+
turnId?: string;
|
|
6
7
|
role: 'user' | 'assistant' | 'system';
|
|
7
8
|
content: string;
|
|
8
9
|
displayIndex?: number;
|
|
@@ -110,6 +110,7 @@ function messagesToClientHistory(messages, opts) {
|
|
|
110
110
|
const text = flattenMessageContent(m.content);
|
|
111
111
|
out.push({
|
|
112
112
|
role: m.role,
|
|
113
|
+
...typeof m.turnId === "string" ? { turnId: m.turnId } : {},
|
|
113
114
|
content: text,
|
|
114
115
|
...m.media?.length ? { media: m.media } : {},
|
|
115
116
|
timestamp: parseTimestamp(m.timestamp)
|
|
@@ -121,6 +122,7 @@ function messagesToClientHistory(messages, opts) {
|
|
|
121
122
|
const toolCalls = toolCallsWithResults(collectMessageToolCalls(m.content, m.tool_calls), results);
|
|
122
123
|
out.push({
|
|
123
124
|
role: "assistant",
|
|
125
|
+
...typeof m.turnId === "string" ? { turnId: m.turnId } : {},
|
|
124
126
|
content: text,
|
|
125
127
|
timestamp: parseTimestamp(m.timestamp),
|
|
126
128
|
toolCalls
|
|
@@ -408,6 +410,7 @@ function transcriptRowsToClientHistory(rows, opts) {
|
|
|
408
410
|
if (messageRow.role === "user" || messageRow.role === "system") {
|
|
409
411
|
out.push({
|
|
410
412
|
id,
|
|
413
|
+
...messageRow.turnId ? { turnId: messageRow.turnId } : {},
|
|
411
414
|
role: messageRow.role,
|
|
412
415
|
kind: "message",
|
|
413
416
|
content: flattenMessageContent(messageRow.content ?? ""),
|
|
@@ -420,6 +423,7 @@ function transcriptRowsToClientHistory(rows, opts) {
|
|
|
420
423
|
const rawContent = rawAssistantContent(messageRow.content);
|
|
421
424
|
out.push({
|
|
422
425
|
id,
|
|
426
|
+
...messageRow.turnId ? { turnId: messageRow.turnId } : {},
|
|
423
427
|
role: "assistant",
|
|
424
428
|
kind: "message",
|
|
425
429
|
content: flattenMessageContent(messageRow.content ?? ""),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SessionStatus } from "./types.js";
|
|
2
1
|
import { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
2
|
+
import { SessionStatus } from "./types.js";
|
|
3
3
|
import { effectiveWorkspacePathForSession, normalizeWorkingDirectoryInput, projectWorkspacePath } from "./session-workspace.js";
|
|
4
4
|
import { emitSessionTranscriptUpdate, onSessionTranscriptUpdate } from "./transcript-events.js";
|
|
5
5
|
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
@@ -2,8 +2,8 @@ import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
|
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
4
|
import { requireXopcDatabase } from "../storage/sqlite/connection.js";
|
|
5
|
-
import "./types.js";
|
|
6
5
|
import { buildSessionContextForLlm, buildSessionDisplayMessages, isRuntimeOnlyTranscriptMessage, isTranscriptCompactionEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
6
|
+
import "./types.js";
|
|
7
7
|
import { estimateTokensFromMessages } from "../storage/sqlite/row-mappers.js";
|
|
8
8
|
import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getGlobalSessionStats, getSessionMetadata, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord } from "../storage/sqlite/session-repository.js";
|
|
9
9
|
import { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "../storage/sqlite/transcript-repository.js";
|
|
@@ -4,7 +4,3 @@ export declare function escapeFts5Query(raw: string): string;
|
|
|
4
4
|
export declare function buildFts5SearchQuery(raw: string): string;
|
|
5
5
|
/** Normalize FTS5 BM25 ranks, where a more-negative rank is a better match. */
|
|
6
6
|
export declare function fts5RankToScore(rank: number, bestRank: number, worstRank: number): number;
|
|
7
|
-
/** Bounded lexical fallback for reformulations unsupported by unicode61 tokenization. */
|
|
8
|
-
export declare function memoryLexicalSimilarity(query: string, content: string): number;
|
|
9
|
-
/** Local deterministic embedding used to complement FTS without network or model coupling. */
|
|
10
|
-
export declare function memoryVectorSimilarity(query: string, content: string): number;
|
|
@@ -40,7 +40,7 @@ const FTS_SEARCH_STOP_WORDS = new Set([
|
|
|
40
40
|
]);
|
|
41
41
|
/** Build a syntax-safe, recall-oriented query for natural-language memory search. */
|
|
42
42
|
function buildFts5SearchQuery(raw) {
|
|
43
|
-
const terms = raw.normalize("NFKC").match(/[\p{L}\p{N}_]+/gu)?.map((term) => term.
|
|
43
|
+
const terms = raw.normalize("NFKC").match(/[\p{L}\p{N}_]+/gu)?.map((term) => term.toLowerCase()).filter((term) => term.length > 1 && !FTS_SEARCH_STOP_WORDS.has(term));
|
|
44
44
|
if (!terms?.length) return escapeFts5Query(raw);
|
|
45
45
|
return [...new Set(terms)].slice(0, 12).map((term) => escapeFts5Query(term)).join(" OR ");
|
|
46
46
|
}
|
|
@@ -55,52 +55,5 @@ function fts5RankToScore(rank, bestRank, worstRank) {
|
|
|
55
55
|
const normalized = (worstRank - rank) / (worstRank - bestRank);
|
|
56
56
|
return .5 + .5 * Math.max(0, Math.min(1, normalized));
|
|
57
57
|
}
|
|
58
|
-
function lexicalFeatures(raw) {
|
|
59
|
-
const normalized = raw.normalize("NFKC").toLocaleLowerCase();
|
|
60
|
-
const features = /* @__PURE__ */ new Set();
|
|
61
|
-
for (const term of normalized.match(/[\p{L}\p{N}_]+/gu) ?? []) if (term.length > 1 && !FTS_SEARCH_STOP_WORDS.has(term)) features.add(`word:${term}`);
|
|
62
|
-
for (const sequence of normalized.match(/\p{Script=Han}+/gu) ?? []) {
|
|
63
|
-
const chars = [...sequence];
|
|
64
|
-
for (let index = 0; index < chars.length - 1; index += 1) features.add(`han:${chars[index]}${chars[index + 1]}`);
|
|
65
|
-
}
|
|
66
|
-
return features;
|
|
67
|
-
}
|
|
68
|
-
/** Bounded lexical fallback for reformulations unsupported by unicode61 tokenization. */
|
|
69
|
-
function memoryLexicalSimilarity(query, content) {
|
|
70
|
-
const queryFeatures = lexicalFeatures(query);
|
|
71
|
-
const contentFeatures = lexicalFeatures(content);
|
|
72
|
-
if (queryFeatures.size === 0 || contentFeatures.size === 0) return 0;
|
|
73
|
-
let shared = 0;
|
|
74
|
-
for (const feature of queryFeatures) if (contentFeatures.has(feature)) shared += 1;
|
|
75
|
-
return 2 * shared / (queryFeatures.size + contentFeatures.size);
|
|
76
|
-
}
|
|
77
|
-
const VECTOR_SIZE = 128;
|
|
78
|
-
function featureVector(raw) {
|
|
79
|
-
const vector = new Float64Array(VECTOR_SIZE);
|
|
80
|
-
const normalized = raw.normalize("NFKC").toLocaleLowerCase();
|
|
81
|
-
const features = [...(normalized.match(/[\p{L}\p{N}_]+/gu) ?? []).map((term) => `w:${term}`), ...[...normalized].map((char, index, chars) => chars.slice(index, index + 3).join("")).filter((value) => value.trim().length >= 2).map((value) => `c:${value}`)];
|
|
82
|
-
for (const feature of features) {
|
|
83
|
-
let hash = 2166136261;
|
|
84
|
-
for (const char of feature) hash = Math.imul(hash ^ char.codePointAt(0), 16777619);
|
|
85
|
-
const index = (hash >>> 0) % VECTOR_SIZE;
|
|
86
|
-
vector[index] += (hash & 1) === 0 ? 1 : -1;
|
|
87
|
-
}
|
|
88
|
-
return vector;
|
|
89
|
-
}
|
|
90
|
-
/** Local deterministic embedding used to complement FTS without network or model coupling. */
|
|
91
|
-
function memoryVectorSimilarity(query, content) {
|
|
92
|
-
const left = featureVector(query);
|
|
93
|
-
const right = featureVector(content);
|
|
94
|
-
let dot = 0;
|
|
95
|
-
let leftNorm = 0;
|
|
96
|
-
let rightNorm = 0;
|
|
97
|
-
for (let index = 0; index < VECTOR_SIZE; index += 1) {
|
|
98
|
-
dot += left[index] * right[index];
|
|
99
|
-
leftNorm += left[index] ** 2;
|
|
100
|
-
rightNorm += right[index] ** 2;
|
|
101
|
-
}
|
|
102
|
-
if (leftNorm === 0 || rightNorm === 0) return 0;
|
|
103
|
-
return Math.max(0, dot / Math.sqrt(leftNorm * rightNorm));
|
|
104
|
-
}
|
|
105
58
|
//#endregion
|
|
106
|
-
export { buildFts5SearchQuery, escapeFts5Query, fts5RankToScore
|
|
59
|
+
export { buildFts5SearchQuery, escapeFts5Query, fts5RankToScore };
|
|
@@ -6,9 +6,10 @@ export { discoverSqlMigrations, listRegisteredMigrationTargets } from './migrati
|
|
|
6
6
|
export { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest, type OpenXopcDatabaseOptions, type XopcDatabase, } from './connection.js';
|
|
7
7
|
export { getSqliteDatabase, runSqliteWriteTransaction } from './transaction.js';
|
|
8
8
|
export { finishContextConsolidationRun, getContextConsolidationRun, listContextConsolidationDecisions, listContextConsolidationRuns, recordContextConsolidationDecision, startContextConsolidationRun, type ContextConsolidationDecision, type ContextConsolidationRun, } from './context-consolidation-repository.js';
|
|
9
|
-
export { summarizeUserUnderstandingQuality, type UserUnderstandingQualityMetrics, } from './user-context-quality-repository.js';
|
|
10
|
-
export { createCollaborationRule, createContextEvidence, createUnderstanding, consumeContextConsent, deleteCollaborationRule, deleteUnderstanding, decideContextConsent, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, linkUnderstandingEvidence, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile, type CreateUnderstandingInput, } from './user-context-repository.js';
|
|
9
|
+
export { summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, type UnderstandingFeedbackSummary, type UserUnderstandingQualityMetrics, } from './user-context-quality-repository.js';
|
|
10
|
+
export { createCollaborationRule, createContextEvidence, createUnderstanding, consumeContextConsent, deleteCollaborationRule, deleteUnderstanding, decideContextConsent, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, linkUnderstandingEvidence, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile, type CreateUnderstandingInput, } from './user-context-repository.js';
|
|
11
11
|
export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus, type SessionInput, type SessionInputDelivery, type SessionInputState, type SessionInputStatus, } from './session-input-repository.js';
|
|
12
|
+
export { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget, type ReplaceLatestSessionTurnInput, type ReplaceLatestSessionTurnResult, } from './session-turn-replace-repository.js';
|
|
12
13
|
export { acknowledgeHomeAttention, isHomeAttentionAcknowledged, type HomeAttentionSubjectKind, } from './home-attention-repository.js';
|
|
13
14
|
export { claimNextConnectorLearningJob, enqueueConnectorLearningJob, listConnectorLearningJobs, recoverStaleConnectorLearningJobs, setConnectorLearningPaused, updateConnectorLearningJob, type ConnectorLearningJob, type ConnectorLearningMode, type ConnectorLearningPhase, type ConnectorLearningStatus, } from './connector-learning-repository.js';
|
|
14
15
|
export { appendComposerInputHistory, clearComposerInputHistory, listComposerInputHistory, COMPOSER_INPUT_HISTORY_LIMIT, type ComposerInputHistoryItem, } from './composer-input-history-repository.js';
|
|
@@ -7,17 +7,18 @@ import { ensureXopcDatabaseSchema } from "./schema.js";
|
|
|
7
7
|
import { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest } from "./connection.js";
|
|
8
8
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
9
9
|
import { finishContextConsolidationRun, getContextConsolidationRun, listContextConsolidationDecisions, listContextConsolidationRuns, recordContextConsolidationDecision, startContextConsolidationRun } from "./context-consolidation-repository.js";
|
|
10
|
-
import { summarizeUserUnderstandingQuality } from "./user-context-quality-repository.js";
|
|
11
|
-
import { consumeContextConsent, createCollaborationRule, createContextEvidence, createUnderstanding, decideContextConsent, deleteCollaborationRule, deleteUnderstanding, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, linkUnderstandingEvidence, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile } from "./user-context-repository.js";
|
|
10
|
+
import { summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality } from "./user-context-quality-repository.js";
|
|
11
|
+
import { consumeContextConsent, createCollaborationRule, createContextEvidence, createUnderstanding, decideContextConsent, deleteCollaborationRule, deleteUnderstanding, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, linkUnderstandingEvidence, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile } from "./user-context-repository.js";
|
|
12
12
|
import { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, insertSessionInput, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus } from "./session-input-repository.js";
|
|
13
|
+
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
14
|
+
import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
15
|
+
import { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget } from "./session-turn-replace-repository.js";
|
|
13
16
|
import { acknowledgeHomeAttention, isHomeAttentionAcknowledged } from "./home-attention-repository.js";
|
|
14
17
|
import { claimNextConnectorLearningJob, enqueueConnectorLearningJob, listConnectorLearningJobs, recoverStaleConnectorLearningJobs, setConnectorLearningPaused, updateConnectorLearningJob } from "./connector-learning-repository.js";
|
|
15
18
|
import { COMPOSER_INPUT_HISTORY_LIMIT, appendComposerInputHistory, clearComposerInputHistory, listComposerInputHistory } from "./composer-input-history-repository.js";
|
|
16
19
|
import { bindEndpointPrincipal, createEndpointPrincipal, getEndpointPrincipal, listEndpointPrincipals, revokeEndpointPrincipal, touchEndpointPrincipal } from "./endpoint-principal-repository.js";
|
|
17
20
|
import { finishEndpointToolInvocationAudit, listEndpointToolInvocationAudits, startEndpointToolInvocationAudit } from "./endpoint-tool-invocation-repository.js";
|
|
18
21
|
import { getInteractionState, setInteractionState, updateInteractionStateFromMessage } from "./interaction-state-repository.js";
|
|
19
|
-
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
20
|
-
import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
21
22
|
import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getCurrentSessionId, getGlobalSessionStats, getSessionMetadata, getSessionPersistedLevels, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
|
|
22
23
|
import { getSessionTaskPlan, setSessionTaskPlan } from "./session-task-plan-repository.js";
|
|
23
24
|
import { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings } from "./relationship-settings-repository.js";
|
|
@@ -32,4 +33,4 @@ import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeC
|
|
|
32
33
|
import { getConnectorAccount, listConnectorAccounts, reconcileConnectorAccount, refreshConnectorAccountCurrent } from "./connector-account-repository.js";
|
|
33
34
|
import { getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, listConnectorSyncPolicies, upsertConnectorSyncPolicy } from "./connector-sync-policy-repository.js";
|
|
34
35
|
import { getUserTrustPolicy, setUserTrustPolicy } from "./user-trust-repository.js";
|
|
35
|
-
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeContextConsent, createCollaborationRule, createConnectorApproval, createContextEvidence, createEndpointPrincipal, createObjectLinkRecord, createUnderstanding, decideConnectorApproval, decideContextConsent, deleteCollaborationRule, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, deleteUnderstanding, discoverSqlMigrations, enqueueConnectorLearningJob, ensureContextConsent, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findSessionInput, findSessionKeyBySessionId, finishContextConsolidationRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextConsolidationRun, getCurrentSessionId, getEndpointPrincipal, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getTurnPersonalization, getUnderstanding, getUserProfile, getUserTrustPolicy, getXopcDatabase, hasContextConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isUnderstandingSuppressed, isXopcDatabaseOpen, linkUnderstandingEvidence, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextConsolidationDecisions, listContextConsolidationRuns, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listUnderstandingEvidence, listUnderstandings, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recordContextConsolidationDecision, recordContextFeedback, recordContextRun, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, rejectUnderstanding, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, reviseCollaborationRule, reviseUnderstanding, revokeEndpointPrincipal, runSqliteWriteTransaction, searchMemoryRecords, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setCollaborationRuleStatus, setConnectorLearningPaused, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUnderstandingStatus, setUserTrustPolicy, startContextConsolidationRun, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUserUnderstandingQuality, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserProfile, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord };
|
|
36
|
+
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeContextConsent, createCollaborationRule, createConnectorApproval, createContextEvidence, createEndpointPrincipal, createObjectLinkRecord, createUnderstanding, decideConnectorApproval, decideContextConsent, deleteCollaborationRule, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, deleteUnderstanding, discoverSqlMigrations, enqueueConnectorLearningJob, ensureContextConsent, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findSessionInput, findSessionKeyBySessionId, finishContextConsolidationRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextConsolidationRun, getCurrentSessionId, getEndpointPrincipal, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getTurnPersonalization, getUnderstanding, getUserProfile, getUserTrustPolicy, getXopcDatabase, hasContextConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isUnderstandingSuppressed, isXopcDatabaseOpen, linkUnderstandingEvidence, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextConsolidationDecisions, listContextConsolidationRuns, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listUnderstandingEvidence, listUnderstandings, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recordContextConsolidationDecision, recordContextFeedback, recordContextRun, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, rejectUnderstanding, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, reviseCollaborationRule, reviseUnderstanding, revokeEndpointPrincipal, runSqliteWriteTransaction, searchActiveUnderstandings, searchMemoryRecords, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setCollaborationRuleStatus, setConnectorLearningPaused, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUnderstandingStatus, setUserTrustPolicy, startContextConsolidationRun, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserProfile, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
|
|
@@ -40,6 +40,7 @@ export declare function getKnowledgeConsumerWatermark(consumerId: string, source
|
|
|
40
40
|
export declare function setKnowledgeConsumerWatermark(consumerId: string, sourceInstanceId: string, sequence: number, nowMs?: number): void;
|
|
41
41
|
export declare function listKnowledgeSourceItems(options?: {
|
|
42
42
|
sourceInstanceId?: string;
|
|
43
|
+
agentId?: string;
|
|
43
44
|
collectionScope?: string;
|
|
44
45
|
itemType?: string;
|
|
45
46
|
synthesisStatus?: KnowledgeSynthesisStatus;
|
|
@@ -240,6 +240,10 @@ function listKnowledgeSourceItems(options = {}) {
|
|
|
240
240
|
where.push("source_instance_id = ?");
|
|
241
241
|
params.push(options.sourceInstanceId);
|
|
242
242
|
}
|
|
243
|
+
if (options.agentId) {
|
|
244
|
+
where.push("json_extract(metadata_json, '$.agentId') = ?");
|
|
245
|
+
params.push(options.agentId);
|
|
246
|
+
}
|
|
243
247
|
if (options.collectionScope) {
|
|
244
248
|
where.push("collection_scope = ?");
|
|
245
249
|
params.push(options.collectionScope);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
import { buildFts5SearchQuery
|
|
2
|
+
import { buildFts5SearchQuery } from "./fts.js";
|
|
3
3
|
import { LOCAL_USER_ID } from "../../user-context/owner.js";
|
|
4
|
+
import { fuseRankedCandidates } from "../../retrieval/candidateFusion.js";
|
|
5
|
+
import { normalizeRetrievalText, retrievalLexicalSimilarity } from "../../retrieval/textFeatures.js";
|
|
6
|
+
import { buildRetrievalQueryProfile } from "../../retrieval/queryProfile.js";
|
|
4
7
|
import { listMemoryEvidence, listMemoryEvidenceForRecords, replaceMemoryEvidenceForRecord } from "./knowledge-repository.js";
|
|
5
8
|
import { randomUUID } from "node:crypto";
|
|
6
9
|
//#region src/storage/sqlite/memory-records-repository.ts
|
|
10
|
+
function memoryFeedbackAdjustment(summary) {
|
|
11
|
+
if (!summary || summary.total < 3) return 0;
|
|
12
|
+
const helpfulRate = (summary.helpful + 1) / (summary.total + 2);
|
|
13
|
+
const relevancePenalty = summary.irrelevant >= 3 ? .05 : 0;
|
|
14
|
+
return Math.max(-.1, Math.min(.05, (helpfulRate - .5) * .1 - relevancePenalty));
|
|
15
|
+
}
|
|
7
16
|
function parseStringArray(json) {
|
|
8
17
|
try {
|
|
9
18
|
const parsed = JSON.parse(json);
|
|
@@ -285,7 +294,12 @@ function listMemoryRecords(options = {}) {
|
|
|
285
294
|
LIMIT ? OFFSET ?`).all(...params, limit, offset));
|
|
286
295
|
}
|
|
287
296
|
function searchMemoryRecords(options) {
|
|
288
|
-
const
|
|
297
|
+
const profile = buildRetrievalQueryProfile(options.query, {
|
|
298
|
+
...options.visibleToSessionKey ? { sessionKey: options.visibleToSessionKey } : {},
|
|
299
|
+
...options.visibleToWorkspaceId ?? options.workspaceId ? { workspaceId: options.visibleToWorkspaceId ?? options.workspaceId } : {},
|
|
300
|
+
...options.visibleToProjectId ?? options.projectId ? { projectId: options.visibleToProjectId ?? options.projectId } : {}
|
|
301
|
+
});
|
|
302
|
+
const query = buildFts5SearchQuery(profile.normalized);
|
|
289
303
|
if (!query) return [];
|
|
290
304
|
const filters = ["memory_records_fts MATCH ?"];
|
|
291
305
|
const params = [query];
|
|
@@ -330,6 +344,7 @@ function searchMemoryRecords(options) {
|
|
|
330
344
|
params.push(...statuses);
|
|
331
345
|
const maxResults = Math.max(1, Math.min(50, options.maxResults ?? 5));
|
|
332
346
|
const minScore = options.minScore ?? 0;
|
|
347
|
+
const candidateLimit = Math.max(50, Math.min(200, maxResults * 10));
|
|
333
348
|
const rows = getSqliteDatabase().prepare(`SELECT
|
|
334
349
|
r.*,
|
|
335
350
|
bm25(memory_records_fts) AS rank
|
|
@@ -337,7 +352,7 @@ function searchMemoryRecords(options) {
|
|
|
337
352
|
JOIN memory_records r ON r.record_id = f.record_id
|
|
338
353
|
WHERE ${filters.join(" AND ")}
|
|
339
354
|
ORDER BY rank
|
|
340
|
-
LIMIT ?`).all(...params,
|
|
355
|
+
LIMIT ?`).all(...params, candidateLimit);
|
|
341
356
|
const candidateRecords = listMemoryRecords({
|
|
342
357
|
providerId: options.providerId,
|
|
343
358
|
userId: options.userId,
|
|
@@ -352,40 +367,44 @@ function searchMemoryRecords(options) {
|
|
|
352
367
|
unscopedWorkspaceOnly: options.unscopedWorkspaceOnly,
|
|
353
368
|
limit: 500
|
|
354
369
|
}).filter((record) => statuses.includes(record.status ?? "active") && (!options.kinds?.length || options.kinds.includes(record.kind)));
|
|
355
|
-
const byId = /* @__PURE__ */ new Map();
|
|
356
370
|
const candidateById = new Map(candidateRecords.map((record) => [record.id, record]));
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
371
|
+
const missingRows = rows.filter((row) => !candidateById.has(row.record_id));
|
|
372
|
+
const missingEvidence = listMemoryEvidenceForRecords(missingRows.map((row) => row.record_id));
|
|
373
|
+
const recordById = new Map(candidateRecords.map((record) => [record.id, record]));
|
|
374
|
+
for (const row of missingRows) recordById.set(row.record_id, rowToRecord(row, missingEvidence.get(row.record_id) ?? []));
|
|
375
|
+
const lexical = candidateRecords.map((record) => ({
|
|
376
|
+
id: record.id,
|
|
377
|
+
score: retrievalLexicalSimilarity(profile.normalized, record.content)
|
|
378
|
+
})).filter((result) => result.score > 0).sort((left, right) => right.score - left.score).slice(0, candidateLimit);
|
|
379
|
+
const fused = fuseRankedCandidates([
|
|
380
|
+
{
|
|
381
|
+
weight: 1.4,
|
|
382
|
+
ids: (profile.identifiers.length ? candidateRecords.map((record) => {
|
|
383
|
+
const content = normalizeRetrievalText(record.content);
|
|
384
|
+
return {
|
|
385
|
+
id: record.id,
|
|
386
|
+
matches: profile.identifiers.filter((identifier) => content.includes(identifier)).length
|
|
387
|
+
};
|
|
388
|
+
}).filter((result) => result.matches > 0).sort((left, right) => right.matches - left.matches).slice(0, candidateLimit) : []).map((result) => result.id)
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
weight: 1,
|
|
392
|
+
ids: rows.map((row) => row.record_id)
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
weight: .8,
|
|
396
|
+
ids: lexical.map((result) => result.id)
|
|
376
397
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
score
|
|
386
|
-
} : {
|
|
398
|
+
]);
|
|
399
|
+
const feedback = new Map(summarizeMemoryRecallFeedback({ limit: 1e3 }).map((summary) => [summary.recordId, summary]));
|
|
400
|
+
return [...fused.entries()].map(([id, fusionScore]) => {
|
|
401
|
+
const record = recordById.get(id);
|
|
402
|
+
if (!record) return null;
|
|
403
|
+
const kindBonus = profile.intentKinds.includes(record.kind) ? .08 : 0;
|
|
404
|
+
const authorityBonus = record.explicitness === "explicit" ? .03 : 0;
|
|
405
|
+
return {
|
|
387
406
|
record,
|
|
388
|
-
score,
|
|
407
|
+
score: Math.max(0, Math.min(1, fusionScore * .85 + kindBonus + authorityBonus + record.importance * .04 + memoryFeedbackAdjustment(feedback.get(record.id)))),
|
|
389
408
|
snippet: record.content,
|
|
390
409
|
citation: {
|
|
391
410
|
providerId: record.providerId,
|
|
@@ -395,9 +414,8 @@ function searchMemoryRecords(options) {
|
|
|
395
414
|
lineEnd: record.source.lineEnd,
|
|
396
415
|
createdAt: record.createdAt
|
|
397
416
|
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return [...byId.values()].filter((result) => result.score >= minScore).sort((left, right) => right.score - left.score).slice(0, maxResults);
|
|
417
|
+
};
|
|
418
|
+
}).filter((result) => Boolean(result)).filter((result) => result.score >= minScore).sort((left, right) => right.score - left.score).slice(0, maxResults);
|
|
401
419
|
}
|
|
402
420
|
function deleteMemoryRecord(recordId) {
|
|
403
421
|
return runSqliteWriteTransaction((db) => {
|
|
@@ -566,7 +584,11 @@ function setMemoryTurnFeedback(input) {
|
|
|
566
584
|
ON CONFLICT DO UPDATE SET rating = excluded.rating, score = excluded.score,
|
|
567
585
|
reason_code = excluded.reason_code, note = excluded.note, updated_at = excluded.updated_at`);
|
|
568
586
|
upsert.run(randomUUID(), trace.trace_id, turnId, null, "response", input.rating, typeof input.score === "number" ? Math.max(-1, Math.min(1, input.score)) : null, input.reasonCode?.trim().slice(0, 200) || null, input.note?.trim().slice(0, 2e3) || null, source, nowMs, nowMs);
|
|
569
|
-
for (const item of records)
|
|
587
|
+
for (const item of records) {
|
|
588
|
+
upsert.run(randomUUID(), trace.trace_id, turnId, item.recordId, "record", item.rating, null, item.reasonCode?.trim().slice(0, 200) || null, item.note?.trim().slice(0, 2e3) || null, source, nowMs, nowMs);
|
|
589
|
+
if (item.rating === "incorrect" || item.rating === "sensitive") db.prepare("UPDATE memory_records SET status = 'needs_review', updated_at = ? WHERE record_id = ?").run(nowMs, item.recordId);
|
|
590
|
+
else if (item.rating === "outdated") db.prepare("UPDATE memory_records SET status = 'stale', updated_at = ? WHERE record_id = ?").run(nowMs, item.recordId);
|
|
591
|
+
}
|
|
570
592
|
});
|
|
571
593
|
return memoryTraceRowToPayload(trace);
|
|
572
594
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../../session/types.js";
|
|
2
|
-
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
3
1
|
import { isTranscriptContextEntry } from "../../session/session-context-for-llm.js";
|
|
2
|
+
import "../../session/types.js";
|
|
4
3
|
import { init_agent_session_key, resolveAgentIdFromSessionKey } from "../../routing/agent-session-key.js";
|
|
4
|
+
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
5
5
|
//#region src/storage/sqlite/row-mappers.ts
|
|
6
6
|
init_agent_session_key();
|
|
7
7
|
function parseJson(raw) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
import {
|
|
2
|
+
import { escapeFts5Query } from "./fts.js";
|
|
3
3
|
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
4
4
|
import { buildGlobalSessionStats, metadataToSessionInsert, sessionRowToMetadata } from "./row-mappers.js";
|
|
5
|
-
import {
|
|
5
|
+
import { validateSessionId } from "../../session/session-id.js";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
//#region src/storage/sqlite/session-repository.ts
|
|
8
8
|
const SESSION_COLUMNS = `
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
3
|
+
export type ReplaceLatestSessionTurnInput = {
|
|
4
|
+
sessionKey: string;
|
|
5
|
+
targetTurnId: string;
|
|
6
|
+
clientMessageId: string;
|
|
7
|
+
content: string;
|
|
8
|
+
attachments?: unknown[];
|
|
9
|
+
thinking?: string;
|
|
10
|
+
origin: TurnOrigin;
|
|
11
|
+
};
|
|
12
|
+
export type ReplaceLatestSessionTurnResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
idempotent: boolean;
|
|
15
|
+
inputId: string;
|
|
16
|
+
removedMessages: AgentMessage[];
|
|
17
|
+
remainingMessages: AgentMessage[];
|
|
18
|
+
} | {
|
|
19
|
+
ok: false;
|
|
20
|
+
code: 'TARGET_NOT_FOUND' | 'NOT_LATEST' | 'SESSION_BUSY';
|
|
21
|
+
};
|
|
22
|
+
/** Validate before aborting a run; the transactional mutation validates again. */
|
|
23
|
+
export declare function validateLatestSessionTurnTarget(sessionKey: string, targetTurnId: string): {
|
|
24
|
+
ok: true;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
code: 'TARGET_NOT_FOUND' | 'NOT_LATEST';
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Replace the latest persisted user turn with a durable queued input.
|
|
31
|
+
* Transcript deletion and input insertion share one SQLite transaction so a
|
|
32
|
+
* failed enqueue cannot leave the conversation without the original turn.
|
|
33
|
+
*/
|
|
34
|
+
export declare function replaceLatestSessionTurnAndQueueInput(input: ReplaceLatestSessionTurnInput): ReplaceLatestSessionTurnResult;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { getXopcDatabase } from "./connection.js";
|
|
2
|
+
import { runSqliteWriteTransaction } from "./transaction.js";
|
|
3
|
+
import { buildSessionContextForLlm, buildSessionDisplayMessages } from "../../session/session-context-for-llm.js";
|
|
4
|
+
import { estimateTokensFromMessages, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
//#region src/storage/sqlite/session-turn-replace-repository.ts
|
|
7
|
+
function isUserRow(row) {
|
|
8
|
+
return row.role === "user";
|
|
9
|
+
}
|
|
10
|
+
function rowTurnId(row) {
|
|
11
|
+
const value = row.turnId;
|
|
12
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
13
|
+
}
|
|
14
|
+
function validateTargetRows(rows, targetTurnId) {
|
|
15
|
+
const targetIndex = rows.findIndex((row) => row.role === "user" && rowTurnId(row) === targetTurnId);
|
|
16
|
+
if (targetIndex < 0) return {
|
|
17
|
+
ok: false,
|
|
18
|
+
code: "TARGET_NOT_FOUND"
|
|
19
|
+
};
|
|
20
|
+
if (rows.slice(targetIndex + 1).some(isUserRow)) return {
|
|
21
|
+
ok: false,
|
|
22
|
+
code: "NOT_LATEST"
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
ok: true,
|
|
26
|
+
targetIndex
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Validate before aborting a run; the transactional mutation validates again. */
|
|
30
|
+
function validateLatestSessionTurnTarget(sessionKey, targetTurnId) {
|
|
31
|
+
const { db } = getXopcDatabase();
|
|
32
|
+
const session = db.prepare(`SELECT session_id FROM sessions WHERE session_key = ?`).get(sessionKey);
|
|
33
|
+
if (!session) return {
|
|
34
|
+
ok: false,
|
|
35
|
+
code: "TARGET_NOT_FOUND"
|
|
36
|
+
};
|
|
37
|
+
const result = validateTargetRows(db.prepare(`SELECT entry_id, session_id, seq, entry_kind, role, payload_json, created_at
|
|
38
|
+
FROM transcript_entries WHERE session_id = ? ORDER BY seq ASC`).all(session.session_id).map(transcriptEntryRowToStoredRow), targetTurnId);
|
|
39
|
+
return result.ok ? { ok: true } : result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Replace the latest persisted user turn with a durable queued input.
|
|
43
|
+
* Transcript deletion and input insertion share one SQLite transaction so a
|
|
44
|
+
* failed enqueue cannot leave the conversation without the original turn.
|
|
45
|
+
*/
|
|
46
|
+
function replaceLatestSessionTurnAndQueueInput(input) {
|
|
47
|
+
return runSqliteWriteTransaction((db) => {
|
|
48
|
+
const existing = db.prepare(`SELECT id FROM session_inputs WHERE session_key = ? AND client_message_id = ?`).get(input.sessionKey, input.clientMessageId);
|
|
49
|
+
if (existing) return {
|
|
50
|
+
ok: true,
|
|
51
|
+
idempotent: true,
|
|
52
|
+
inputId: existing.id,
|
|
53
|
+
removedMessages: [],
|
|
54
|
+
remainingMessages: []
|
|
55
|
+
};
|
|
56
|
+
const session = db.prepare(`SELECT session_id FROM sessions WHERE session_key = ?`).get(input.sessionKey);
|
|
57
|
+
if (!session) return {
|
|
58
|
+
ok: false,
|
|
59
|
+
code: "TARGET_NOT_FOUND"
|
|
60
|
+
};
|
|
61
|
+
db.prepare(`INSERT INTO session_input_runtime(session_key, revision, updated_at_ms)
|
|
62
|
+
VALUES (?, 0, ?) ON CONFLICT(session_key) DO NOTHING`).run(input.sessionKey, Date.now());
|
|
63
|
+
const runtime = db.prepare(`SELECT active_run_id FROM session_input_runtime WHERE session_key = ?`).get(input.sessionKey);
|
|
64
|
+
const pending = db.prepare(`SELECT 1 AS found FROM session_inputs
|
|
65
|
+
WHERE session_key = ? AND status IN ('queued', 'running', 'injecting', 'interrupted')
|
|
66
|
+
LIMIT 1`).get(input.sessionKey);
|
|
67
|
+
if (runtime?.active_run_id || pending) return {
|
|
68
|
+
ok: false,
|
|
69
|
+
code: "SESSION_BUSY"
|
|
70
|
+
};
|
|
71
|
+
const entries = db.prepare(`SELECT entry_id, session_id, seq, entry_kind, role, payload_json, created_at
|
|
72
|
+
FROM transcript_entries WHERE session_id = ? ORDER BY seq ASC`).all(session.session_id);
|
|
73
|
+
const target = validateTargetRows(entries.map(transcriptEntryRowToStoredRow), input.targetTurnId);
|
|
74
|
+
if (target.ok === false) return target;
|
|
75
|
+
const targetSeq = entries[target.targetIndex].seq;
|
|
76
|
+
const removedEntries = entries.filter((entry) => entry.seq >= targetSeq && entry.entry_kind !== "compaction");
|
|
77
|
+
const remainingEntries = entries.filter((entry) => entry.seq < targetSeq && entry.entry_kind !== "compaction");
|
|
78
|
+
const deleteEntries = entries.filter((entry) => entry.seq >= targetSeq || entry.entry_kind === "compaction");
|
|
79
|
+
const removedRows = removedEntries.map(transcriptEntryRowToStoredRow);
|
|
80
|
+
const remainingRows = remainingEntries.map(transcriptEntryRowToStoredRow);
|
|
81
|
+
const deleteFts = db.prepare(`DELETE FROM transcript_fts WHERE entry_id = ?`);
|
|
82
|
+
const deleteEntry = db.prepare(`DELETE FROM transcript_entries WHERE entry_id = ?`);
|
|
83
|
+
for (const entry of deleteEntries) {
|
|
84
|
+
deleteFts.run(entry.entry_id);
|
|
85
|
+
deleteEntry.run(entry.entry_id);
|
|
86
|
+
}
|
|
87
|
+
const llm = buildSessionContextForLlm(remainingRows);
|
|
88
|
+
const now = Date.now();
|
|
89
|
+
db.prepare(`UPDATE sessions SET message_count = ?, estimated_tokens = ?, compacted_count = 0,
|
|
90
|
+
updated_at = ?, last_accessed_at = ?, last_interaction_at = ? WHERE session_key = ?`).run(llm.length, estimateTokensFromMessages(llm), now, now, now, input.sessionKey);
|
|
91
|
+
const maxPosition = db.prepare(`SELECT COALESCE(MAX(position), 0) AS value FROM session_inputs
|
|
92
|
+
WHERE session_key = ? AND status IN ('queued', 'running', 'injecting', 'interrupted')`).get(input.sessionKey);
|
|
93
|
+
const inputId = randomUUID();
|
|
94
|
+
db.prepare(`INSERT INTO session_inputs(id, session_key, client_message_id,
|
|
95
|
+
requested_delivery, effective_delivery, status, content, attachments_json,
|
|
96
|
+
thinking, origin_json, position, target_run_id, version, created_at_ms, updated_at_ms)
|
|
97
|
+
VALUES (?, ?, ?, 'next', 'next', 'queued', ?, ?, ?, ?, ?, NULL, 1, ?, ?)`).run(inputId, input.sessionKey, input.clientMessageId, input.content, input.attachments ? JSON.stringify(input.attachments) : null, input.thinking ?? null, JSON.stringify(input.origin), maxPosition.value + 1, now, now);
|
|
98
|
+
db.prepare(`UPDATE session_input_runtime SET revision = revision + 1, updated_at_ms = ?
|
|
99
|
+
WHERE session_key = ?`).run(now, input.sessionKey);
|
|
100
|
+
return {
|
|
101
|
+
ok: true,
|
|
102
|
+
idempotent: false,
|
|
103
|
+
inputId,
|
|
104
|
+
removedMessages: buildSessionDisplayMessages(removedRows),
|
|
105
|
+
remainingMessages: buildSessionDisplayMessages(remainingRows)
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
+
import { escapeFts5Query } from "./fts.js";
|
|
2
3
|
import { buildSessionContextForLlm, isRuntimeOnlyTranscriptMessage } from "../../session/session-context-for-llm.js";
|
|
3
4
|
import { classifyStoredRow, estimateTokensFromMessages, extractFtsContent, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
4
|
-
import { escapeFts5Query } from "./fts.js";
|
|
5
5
|
import { getCurrentSessionId, readCurrentSessionId } from "./session-repository.js";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
//#region src/storage/sqlite/transcript-repository.ts
|
|
@@ -26,7 +26,22 @@ export type UserUnderstandingQualityMetrics = {
|
|
|
26
26
|
irrelevant: number;
|
|
27
27
|
helpfulRate: number | null;
|
|
28
28
|
};
|
|
29
|
+
quickUnderstanding: {
|
|
30
|
+
sourcesAuthorized: number;
|
|
31
|
+
sourcesCollected: number;
|
|
32
|
+
sourceCoverage: number | null;
|
|
33
|
+
bootstrapJobs: number;
|
|
34
|
+
successfulBootstrapRate: number | null;
|
|
35
|
+
medianBootstrapDurationMs: number | null;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type UnderstandingFeedbackSummary = {
|
|
39
|
+
understandingId: string;
|
|
40
|
+
helpful: number;
|
|
41
|
+
irrelevant: number;
|
|
42
|
+
total: number;
|
|
29
43
|
};
|
|
44
|
+
export declare function summarizeUnderstandingFeedback(understandingIds: string[]): UnderstandingFeedbackSummary[];
|
|
30
45
|
export declare function summarizeUserUnderstandingQuality(options?: {
|
|
31
46
|
windowDays?: number;
|
|
32
47
|
agingCandidateDays?: number;
|