@xopcai/xopc 0.0.248 → 0.0.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-etpmyV7S.js → activity-store-DfBjTSo9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BmKxSM1k.js → agent-avatar-dicebear-BN6FJXkJ.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C7rZH1A2.js +1 -0
- package/dist/gateway/static/root/assets/agents-CgGaoo4z.js +1 -0
- package/dist/gateway/static/root/assets/{api-B0-hLuZ1.js → api-zxpcJfgj.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-D2gMshuS.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-wMu0jSKx.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-KF1Gnv36.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BnMSgZvR.js → archive-plugin-u6EE3JV8.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CejsQMev.js → attachment-load-DbJurnv-.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-RC8EyoAf.js → automations-page-Ew_e5HDn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ch-ldu35.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DGjppLSG.js → binary-plugins-DtDFNfPM.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CWdP4bUc.js → block-editor-CnAwmabq.js} +44 -44
- package/dist/gateway/static/root/assets/browser-settings-page-DtVhsHJW.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BQ1Ilw_o.js → browser-workflow-inputs-BX1-uM9L.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CJh4NyxT.js → browser-workflows-page-CcbUOWDF.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel--sXeylhe.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-AXSBDujZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-Ohhee4vm.js → channels-status-swr-CX-yWwLD.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BOtoKTK3.js → chat-terminal-dock-CryTDNdD.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-HBHUWohz.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DTj1V3Sw.js → cron-expression-ji5aWrjG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Yr6OCvGL.js → date-picker-Dro_w3eX.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-Ce19KKnX.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-DbGzggPF.js → desktop-pet-DsSi-3uZ.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-8WQ4woJy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DgTtk4KC.js → extension-debug-page-CgvEBfLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DtQeiP6f.js → extension-page-DkznBbMj.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BOjhchK2.js +1 -0
- package/dist/gateway/static/root/assets/files-BArWTfr7.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-OEruhhX3.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DXuXtU1w.js → gateway-config-swr-CMNbl0FZ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BgH3A0LO.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CzBzglzQ.js → gateway-startup-retry-CR7Xg8As.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C97naDkO.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BBKKme4G.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-TIgsn04n.js → image-generation-api-C5mn73ca.js} +1 -1
- package/dist/gateway/static/root/assets/index-BcaF-dgQ.js +72 -0
- package/dist/gateway/static/root/assets/index-DAryGvZ7.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-wsWuoa8p.js → keyboard-shortcuts-settings-BYhfzsqe.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DNncc2tn.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CXrbrGo8.js → local-apps-page-vBlknU7C.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BJFLQY8O.js → locale-store-CF4erhjB.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CizZInrT.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-BdJZFR7U.js → management-settings-Dnx6mSNe.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-NK3ACVG2.js → markdown-split-DtBtcHWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DTF9v1gg.js → markdown-view-CQvzsE24.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-F0jcUxyl.js → media-plugins-DrMYeHe7.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +3 -0
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-AKgGy3Kx.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-Bw3jD9Jf.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-Dpqq7Z-J.js +8 -0
- package/dist/gateway/static/root/assets/page-tabs-CX9T71by.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-DvEHoimN.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-CxGGlWA8.js → product-open-page-COcr_NUJ.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BuT6MCTs.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DXWMxOjf.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CIsNlSBi.js → registry-api-BsRBlji7.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-7rBCUWzZ.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-YkjhiQfA.js → runtime-tools-settings-panel-CQ13P-mS.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-oFGf3G3s.js → schema-form-BUVyTpZj.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-gmEOYNb4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DYYoJcl7.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-DVY-8_B9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-C7VWs0IT.js → settings-page-CdiVYyTl.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BhenBnUj.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-t5oz18rh.js → share-preview-page-C88YLKm4.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Dq7xIj0_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-MDI9Lz6z.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DLir1nM0.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-DEDTYs2W.js → skills-page.utils-BMZAfS3G.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-BM8ivYan.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-P0_RldWv.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-O597U8q_.js → theme-store-BOgkc_9D.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-DemxChjo.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-B5eUJ6Zq.js → use-autosave-CV3Ui5hu.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CxfnoRVn.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CMKSwz4C.js → voice-api-key-field-CUoCi4Sq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-q7B6fOFB.js → voice-config-api-C-ryeIxj.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-BhDlkCMB.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DZmvLZjb.js → workflow-run-setup-panel-D8CcPc_C.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bxn2Dc16.js +5 -0
- package/dist/gateway/static/root/index.html +11 -27
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/user-message-display.js +18 -0
- package/dist/src/agent/agent-instance-gateway.d.ts +3 -3
- package/dist/src/agent/agent-manager.d.ts +13 -13
- package/dist/src/agent/agent-manager.js +76 -42
- package/dist/src/agent/background-review/coordinator.d.ts +2 -4
- package/dist/src/agent/background-review/coordinator.js +5 -30
- package/dist/src/agent/background-review/prompts.d.ts +4 -2
- package/dist/src/agent/background-review/prompts.js +33 -19
- package/dist/src/agent/background-review/run-background-review.d.ts +6 -7
- package/dist/src/agent/background-review/run-background-review.js +47 -41
- package/dist/src/agent/background-review/settings.d.ts +0 -1
- package/dist/src/agent/background-review/settings.js +6 -7
- package/dist/src/agent/context/audit.d.ts +38 -0
- package/dist/src/agent/context/audit.js +123 -0
- package/dist/src/agent/context/coordinator.d.ts +31 -0
- package/dist/src/agent/context/coordinator.js +73 -0
- package/dist/src/agent/context/execution-context.d.ts +13 -0
- package/dist/src/agent/context/execution-context.js +211 -0
- package/dist/src/agent/context/execution-context.types.d.ts +50 -0
- package/dist/src/agent/context/execution-scope.d.ts +5 -1
- package/dist/src/agent/context/execution-scope.js +6 -2
- package/dist/src/agent/context/prepend.d.ts +2 -0
- package/dist/src/agent/context/prepend.js +28 -0
- package/dist/src/agent/context/project-context.d.ts +6 -3
- package/dist/src/agent/context/project-context.js +28 -23
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -0
- package/dist/src/agent/embedded/run-turn.js +22 -2
- package/dist/src/agent/embedded/types.d.ts +1 -25
- package/dist/src/agent/external-tools/composio-provider.js +87 -92
- package/dist/src/agent/external-tools/gateway-tools.d.ts +4 -1
- package/dist/src/agent/external-tools/gateway-tools.js +153 -41
- package/dist/src/agent/external-tools/index.d.ts +1 -0
- package/dist/src/agent/external-tools/index.js +2 -1
- package/dist/src/agent/external-tools/memory-provider.d.ts +1 -0
- package/dist/src/agent/external-tools/memory-provider.js +1 -0
- package/dist/src/agent/external-tools/search-error.d.ts +12 -0
- package/dist/src/agent/external-tools/search-error.js +29 -0
- package/dist/src/agent/external-tools/service.d.ts +4 -0
- package/dist/src/agent/external-tools/service.js +22 -2
- package/dist/src/agent/inbound/attachment-pipeline.js +5 -1
- package/dist/src/agent/memory/compaction-policy.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -0
- package/dist/src/agent/memory/compaction-promotion.js +52 -79
- package/dist/src/agent/memory/create-memory-manager.js +1 -3
- package/dist/src/agent/memory/index.d.ts +1 -6
- package/dist/src/agent/memory/index.js +3 -6
- package/dist/src/agent/memory/manager.d.ts +0 -16
- package/dist/src/agent/memory/manager.js +11 -40
- package/dist/src/agent/memory/memory-config.d.ts +0 -5
- package/dist/src/agent/memory/memory-config.js +2 -9
- package/dist/src/agent/memory/runtime.d.ts +2 -2
- package/dist/src/agent/memory/runtime.js +9 -19
- package/dist/src/agent/memory/types.d.ts +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +13 -21
- package/dist/src/agent/orchestration/context-overflow.js +1 -0
- package/dist/src/agent/prompt/sections/memory-skills.js +25 -36
- package/dist/src/agent/prompt/sections/tooling.js +10 -4
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -3
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +8 -25
- package/dist/src/agent/service/process-direct-streaming.js +8 -7
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/tasks/task-judge-service.js +1 -1
- package/dist/src/agent/tools/clarify-tool.d.ts +1 -0
- package/dist/src/agent/tools/delegate-tool.js +5 -2
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +68 -21
- package/dist/src/agent/tools/index.d.ts +3 -2
- package/dist/src/agent/tools/index.js +4 -3
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +15 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +184 -0
- package/dist/src/agent/tools/{dreaming-tool.d.ts → memory-maintenance-tool.d.ts} +2 -2
- package/dist/src/agent/tools/memory-maintenance-tool.js +31 -0
- package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-search-tool.js +7 -0
- package/dist/src/agent/tools/user-context-tool.d.ts +10 -0
- package/dist/src/agent/tools/user-context-tool.js +98 -0
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/automations/service/automation-service.d.ts +2 -1
- package/dist/src/automations/service/automation-service.js +6 -2
- package/dist/src/chat-commands/builtins/understanding.js +24 -6
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +68 -75
- package/dist/src/config/schema.js +29 -18
- package/dist/src/config/web-patch.d.ts +1 -1
- package/dist/src/connectors/auth-provider-registry.js +1 -1
- package/dist/src/connectors/composio-managed-client.js +6 -2
- package/dist/src/connectors/connected-source-ingestion.js +1 -1
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -3
- package/dist/src/connectors/connected-source-understanding.js +86 -99
- package/dist/src/connectors/connection-candidates.d.ts +11 -0
- package/dist/src/connectors/connection-candidates.js +58 -0
- package/dist/src/connectors/connection-capabilities.d.ts +4 -0
- package/dist/src/connectors/connection-capabilities.js +37 -0
- package/dist/src/connectors/connection-recovery-service.d.ts +43 -0
- package/dist/src/connectors/connection-recovery-service.js +420 -0
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/learning-coordinator.d.ts +0 -2
- package/dist/src/connectors/learning-coordinator.js +6 -7
- package/dist/src/connectors/principal.d.ts +5 -0
- package/dist/src/connectors/principal.js +18 -0
- package/dist/src/files/file-service.js +4 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +28 -10
- package/dist/src/gateway/agent-builtin-tools.js +30 -9
- package/dist/src/gateway/chat-stream/mapper.js +1 -28
- package/dist/src/gateway/chat-stream/protocol.d.ts +2 -24
- package/dist/src/gateway/clarify-bridge.d.ts +4 -0
- package/dist/src/gateway/clarify-bridge.js +9 -4
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +52 -30
- package/dist/src/gateway/hono/lib/config-payload.js +4 -4
- package/dist/src/gateway/hono/middleware/auth.js +1 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +72 -28
- package/dist/src/gateway/hono/routes/connection-waits.d.ts +3 -0
- package/dist/src/gateway/hono/routes/connection-waits.js +58 -0
- package/dist/src/gateway/hono/routes/connectors.js +24 -18
- package/dist/src/gateway/hono/routes/context-sources.d.ts +4 -0
- package/dist/src/gateway/hono/routes/context-sources.js +159 -0
- package/dist/src/gateway/hono/routes/files.js +23 -2
- package/dist/src/gateway/hono/routes/index.js +4 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -4
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +22 -7
- package/dist/src/gateway/hono/routes/projects.js +36 -44
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +15 -1
- package/dist/src/gateway/hono/routes/side-chats.js +13 -2
- package/dist/src/gateway/hono/routes/tasks.js +3 -3
- package/dist/src/gateway/hono/routes/user-model.d.ts +3 -0
- package/dist/src/gateway/hono/routes/user-model.js +480 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +72 -0
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/agent-runner.d.ts +9 -1
- package/dist/src/gateway/service/agent-runner.js +25 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
- package/dist/src/gateway/service/config-coordinator.js +4 -4
- package/dist/src/gateway/service/run-gateway-agent.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +18 -14
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +12 -2
- package/dist/src/gateway/service.d.ts +3 -1
- package/dist/src/gateway/service.js +52 -17
- package/dist/src/gateway/side-chat/manager.d.ts +16 -3
- package/dist/src/gateway/side-chat/manager.js +117 -28
- package/dist/src/gateway/side-chat/run-service.d.ts +2 -0
- package/dist/src/gateway/side-chat/run-service.js +28 -5
- package/dist/src/gateway/side-chat/types.d.ts +9 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +0 -2
- package/dist/src/knowledge/connected-knowledge-pipeline.js +46 -217
- package/dist/src/knowledge-memory/domain.d.ts +36 -0
- package/dist/src/knowledge-memory/index.d.ts +2 -0
- package/dist/src/knowledge-memory/index.js +2 -0
- package/dist/src/knowledge-memory/repository.d.ts +48 -0
- package/dist/src/knowledge-memory/repository.js +168 -0
- package/dist/src/memory-maintenance/index.d.ts +2 -0
- package/dist/src/memory-maintenance/index.js +3 -0
- package/dist/src/memory-maintenance/schedule.d.ts +13 -0
- package/dist/src/memory-maintenance/schedule.js +51 -0
- package/dist/src/memory-maintenance/service.d.ts +28 -0
- package/dist/src/memory-maintenance/service.js +216 -0
- package/dist/src/notes/service.d.ts +1 -0
- package/dist/src/notes/service.js +7 -1
- package/dist/src/notes/types.d.ts +16 -0
- package/dist/src/notifications/planner.js +7 -3
- package/dist/src/proactive/actions/service.d.ts +0 -1
- package/dist/src/proactive/actions/service.js +1 -10
- package/dist/src/proactive/execution/context.d.ts +8 -10
- package/dist/src/proactive/execution/context.js +93 -42
- package/dist/src/proactive/execution/insight.d.ts +4 -1
- package/dist/src/proactive/execution/insight.js +5 -2
- package/dist/src/proactive/execution/repository.d.ts +1 -0
- package/dist/src/proactive/execution/repository.js +9 -1
- package/dist/src/proactive/execution/types.d.ts +0 -1
- package/dist/src/proactive/execution/worker.js +7 -5
- package/dist/src/proactive/inbox/repository.js +8 -2
- package/dist/src/proactive/inbox/service.js +2 -2
- package/dist/src/proactive/inbox/types.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.js +7 -0
- package/dist/src/proactive/index.d.ts +2 -1
- package/dist/src/proactive/index.js +3 -2
- package/dist/src/proactive/maintenance.d.ts +4 -0
- package/dist/src/proactive/maintenance.js +21 -0
- package/dist/src/proactive/scenarios/repository.d.ts +1 -1
- package/dist/src/proactive/scenarios/repository.js +10 -3
- package/dist/src/proactive/scenarios/types.d.ts +7 -0
- package/dist/src/proactive/service.d.ts +7 -0
- package/dist/src/proactive/service.js +17 -1
- package/dist/src/projects/index.d.ts +1 -1
- package/dist/src/projects/index.js +2 -2
- package/dist/src/projects/knowledge-bind.d.ts +1 -0
- package/dist/src/projects/knowledge-bind.js +15 -0
- package/dist/src/projects/project-loop.d.ts +3 -3
- package/dist/src/projects/project-loop.js +4 -4
- package/dist/src/projects/project-service.d.ts +2 -1
- package/dist/src/projects/project-service.js +3 -2
- package/dist/src/projects/project-store.js +2 -1
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/runtime-tools/manager.js +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +5 -2
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +19 -0
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +54 -0
- package/dist/src/storage/sqlite/config-repository.js +1 -1
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +30 -0
- package/dist/src/storage/sqlite/connection-wait-repository.js +338 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +1 -1
- package/dist/src/storage/sqlite/context-evidence-repository.d.ts +24 -0
- package/dist/src/storage/sqlite/context-evidence-repository.js +52 -0
- package/dist/src/storage/sqlite/index.d.ts +3 -5
- package/dist/src/storage/sqlite/index.js +6 -8
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +0 -19
- package/dist/src/storage/sqlite/knowledge-repository.js +1 -90
- package/dist/src/storage/sqlite/migrations/148_user_model_foundation.sql +554 -0
- package/dist/src/storage/sqlite/migrations/149_separate_source_index_from_memory.sql +18 -0
- package/dist/src/storage/sqlite/migrations/150_session_connection_waits.sql +47 -0
- package/dist/src/storage/sqlite/migrations/151_proactive_scope_cleanup.sql +6 -0
- package/dist/src/storage/sqlite/migrations/152_proactive_scenario_contract.sql +140 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.d.ts +2 -1
- package/dist/src/storage/sqlite/notes-repository.js +37 -3
- package/dist/src/storage/sqlite/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +14 -2
- package/dist/src/storage/sqlite/session-input-repository.js +17 -14
- package/dist/src/storage/sqlite/session-instance-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/session-instance-repository.js +6 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-repository.js +7 -6
- package/dist/src/storage/sqlite/transcript-repository.js +3 -2
- package/dist/src/tasks/home-query-service.js +35 -13
- package/dist/src/tasks/index.js +2 -2
- package/dist/src/tasks/project-monitoring-service.d.ts +2 -0
- package/dist/src/tasks/project-monitoring-service.js +4 -1
- package/dist/src/tasks/project-operating-view-service.js +1 -1
- package/dist/src/tasks/task-application-service.js +6 -1
- package/dist/src/tasks/task-context-assembler.js +1 -1
- package/dist/src/tasks/task-context-repository.d.ts +0 -1
- package/dist/src/tasks/task-context-repository.js +1 -1
- package/dist/src/tasks/task-deletion-service.js +1 -1
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tasks/task-read-model-projector.js +1 -1
- package/dist/src/tasks/task-run-coordinator.js +1 -1
- package/dist/src/tasks/task-run-dispatcher.js +1 -1
- package/dist/src/tasks/task-run-repository.js +1 -0
- package/dist/src/tasks/task-signal-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tool-summary.js +2 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/user-context/access-policy.d.ts +11 -0
- package/dist/src/user-context/access-policy.js +26 -0
- package/dist/src/user-context/changes.d.ts +1 -1
- package/dist/src/user-context/config.d.ts +135 -153
- package/dist/src/user-context/config.js +94 -99
- package/dist/src/user-context/relationship-continuity.d.ts +2 -2
- package/dist/src/user-context/relationship-continuity.js +34 -24
- package/dist/src/user-context/sources/activity-clustering.d.ts +9 -3
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/repository.d.ts +1 -21
- package/dist/src/user-context/sources/repository.js +1 -183
- package/dist/src/user-context/sources/types.d.ts +0 -23
- package/dist/src/user-model/capture/executor.d.ts +50 -0
- package/dist/src/user-model/capture/executor.js +230 -0
- package/dist/src/user-model/capture/index.d.ts +2 -0
- package/dist/src/user-model/capture/index.js +3 -0
- package/dist/src/user-model/capture/semantic.d.ts +39 -0
- package/dist/src/user-model/capture/semantic.js +263 -0
- package/dist/src/user-model/domain.d.ts +93 -0
- package/dist/src/user-model/domain.js +33 -0
- package/dist/src/user-model/goals.d.ts +62 -0
- package/dist/src/user-model/goals.js +91 -0
- package/dist/src/user-model/importance.d.ts +11 -0
- package/dist/src/user-model/importance.js +17 -0
- package/dist/src/user-model/index.d.ts +5 -0
- package/dist/src/user-model/index.js +6 -0
- package/dist/src/user-model/repository.d.ts +23 -0
- package/dist/src/user-model/repository.js +268 -0
- package/dist/src/user-model/temporal.d.ts +10 -0
- package/dist/src/user-model/temporal.js +44 -0
- package/dist/src/voice/realtime/memory-context.d.ts +7 -2
- package/dist/src/voice/realtime/memory-context.js +39 -51
- package/dist/src/work-discovery/service.d.ts +3 -14
- package/dist/src/work-discovery/service.js +138 -99
- package/dist/src/work-discovery/types.d.ts +3 -3
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +12 -20
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CUXApfcE.js +0 -1
- package/dist/gateway/static/root/assets/agents-DNq_GKuc.js +0 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-qfwAgyhQ.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-DqQVUpCC.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-dwIqYmXk.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-SkdcSZ0i.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CKCa6TvG.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DSp--zIZ.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CMd2dDrI.js +0 -1
- package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-udWs5Kdm.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DpN3XZg9.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DinCToZh.js +0 -1
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DcguCgsH.js +0 -1
- package/dist/gateway/static/root/assets/eye-CABVeTq0.js +0 -1
- package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +0 -1
- package/dist/gateway/static/root/assets/files-D6vf3S30.js +0 -1
- package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +0 -1
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-Br7lSf6H.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CdPoDMuj.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DHk1hawP.js +0 -1
- package/dist/gateway/static/root/assets/home-page-YGipe_W6.js +0 -1
- package/dist/gateway/static/root/assets/index-D5TQQpeb.js +0 -71
- package/dist/gateway/static/root/assets/index-DReBaaTX.css +0 -2
- package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +0 -1
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CpyvYyrb.js +0 -2
- package/dist/gateway/static/root/assets/local-context-graph-BjUf7fQ9.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CXKy6E_l.js +0 -2
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +0 -1
- package/dist/gateway/static/root/assets/messages-CHNYp8EQ.js +0 -3
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +0 -1
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-3NKCniSp.js +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-nCfkBN8M.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-DuqLahi6.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-C7j9EdQk.js +0 -5
- package/dist/gateway/static/root/assets/oauth-api-8lP_qJpq.js +0 -1
- package/dist/gateway/static/root/assets/oauth-authorization-window-Cdolr2wE.js +0 -1
- package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +0 -1
- package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-CfebYVX0.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-48GvzSVa.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-64xj_s2m.js +0 -1
- package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +0 -1
- package/dist/gateway/static/root/assets/search-DA7gz22f.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CcwcdRN8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BaN84CyW.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-DjWzRk4z.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DVVOCNbr.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DUYbYLi7.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BGyD0gB9.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CjF8DTsN.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-BSYuRgFI.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-YZYSTJH7.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-FKUi9wDL.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BCyiduKd.js +0 -2
- package/dist/gateway/static/root/assets/work-discovery-overlay-jhT2EzeH.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DQC0TpMa.js +0 -5
- package/dist/src/agent/memory/builtin-provider.d.ts +0 -37
- package/dist/src/agent/memory/builtin-provider.js +0 -225
- package/dist/src/agent/memory/context/types.d.ts +0 -40
- package/dist/src/agent/memory/understanding/quality.d.ts +0 -8
- package/dist/src/agent/memory/understanding/quality.js +0 -18
- package/dist/src/agent/memory/understanding/service.d.ts +0 -19
- package/dist/src/agent/memory/understanding/service.js +0 -209
- package/dist/src/agent/memory/understanding/types.d.ts +0 -34
- package/dist/src/agent/memory/user-context-coordinator.d.ts +0 -23
- package/dist/src/agent/memory/user-context-coordinator.js +0 -113
- package/dist/src/agent/tools/dreaming-tool.js +0 -37
- package/dist/src/agent/tools/memory-tool.d.ts +0 -9
- package/dist/src/agent/tools/memory-tool.js +0 -119
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -11
- package/dist/src/gateway/dreaming-automation-reconciler.js +0 -63
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +0 -21
- package/dist/src/gateway/hono/routes/understanding-sources.js +0 -387
- package/dist/src/gateway/hono/routes/you.d.ts +0 -3
- package/dist/src/gateway/hono/routes/you.js +0 -457
- package/dist/src/projects/memory-bind.d.ts +0 -1
- package/dist/src/projects/memory-bind.js +0 -14
- package/dist/src/storage/sqlite/context-consolidation-repository.d.ts +0 -37
- package/dist/src/storage/sqlite/context-consolidation-repository.js +0 -64
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +0 -217
- package/dist/src/storage/sqlite/memory-records-repository.js +0 -715
- package/dist/src/storage/sqlite/remote-context-repository.d.ts +0 -3
- package/dist/src/storage/sqlite/remote-context-repository.js +0 -40
- package/dist/src/storage/sqlite/understanding-focus-exclusions.d.ts +0 -2
- package/dist/src/storage/sqlite/understanding-focus-exclusions.js +0 -24
- package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +0 -49
- package/dist/src/storage/sqlite/user-context-quality-repository.js +0 -118
- package/dist/src/storage/sqlite/user-context-repository.d.ts +0 -85
- package/dist/src/storage/sqlite/user-context-repository.js +0 -535
- package/dist/src/user-context/automatic-context.d.ts +0 -17
- package/dist/src/user-context/automatic-context.js +0 -85
- package/dist/src/user-context/consolidation.d.ts +0 -27
- package/dist/src/user-context/consolidation.js +0 -187
- package/dist/src/user-context/context-objects.d.ts +0 -17
- package/dist/src/user-context/context-objects.js +0 -99
- package/dist/src/user-context/evaluation/harness.d.ts +0 -13
- package/dist/src/user-context/evaluation/harness.js +0 -31
- package/dist/src/user-context/extraction/executor.d.ts +0 -22
- package/dist/src/user-context/extraction/executor.js +0 -142
- package/dist/src/user-context/extraction/repair.d.ts +0 -19
- package/dist/src/user-context/extraction/repair.js +0 -71
- package/dist/src/user-context/extraction/semantic.d.ts +0 -18
- package/dist/src/user-context/extraction/semantic.js +0 -148
- package/dist/src/user-context/focus-lifecycle.d.ts +0 -2
- package/dist/src/user-context/focus-lifecycle.js +0 -26
- package/dist/src/user-context/manual-understanding.d.ts +0 -12
- package/dist/src/user-context/manual-understanding.js +0 -37
- package/dist/src/user-context/planner.d.ts +0 -17
- package/dist/src/user-context/planner.js +0 -465
- package/dist/src/user-context/relationships/indexer.d.ts +0 -13
- package/dist/src/user-context/relationships/indexer.js +0 -185
- package/dist/src/user-context/relationships/service.d.ts +0 -22
- package/dist/src/user-context/relationships/service.js +0 -50
- package/dist/src/user-context/retriever.d.ts +0 -15
- package/dist/src/user-context/retriever.js +0 -124
- package/dist/src/user-context/scope.d.ts +0 -7
- package/dist/src/user-context/scope.js +0 -9
- package/dist/src/user-context/selection-policy.d.ts +0 -20
- package/dist/src/user-context/selection-policy.js +0 -33
- package/dist/src/user-context/understanding.d.ts +0 -15
- package/dist/src/user-context/understanding.js +0 -24
- package/dist/src/user-context/understandingQuality.d.ts +0 -5
- package/dist/src/user-context/understandingQuality.js +0 -48
- /package/dist/src/agent/{memory/context/types.js → context/execution-context.types.js} +0 -0
- /package/dist/src/{agent/memory/understanding/types.js → knowledge-memory/domain.js} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
//#region src/projects/knowledge-bind.ts
|
|
3
|
+
function bindKnowledgeItemToProject(knowledgeId, projectId) {
|
|
4
|
+
const db = getSqliteDatabase();
|
|
5
|
+
if (!db.prepare("SELECT 1 FROM projects WHERE project_id = ?").get(projectId)) throw new Error(`Project not found: ${projectId}`);
|
|
6
|
+
if (!db.prepare("SELECT 1 FROM knowledge_items WHERE knowledge_id = ?").get(knowledgeId)) throw new Error(`Knowledge item not found: ${knowledgeId}`);
|
|
7
|
+
runSqliteWriteTransaction((tx) => {
|
|
8
|
+
const now = Date.now();
|
|
9
|
+
tx.prepare(`UPDATE knowledge_items SET scope_type = 'project', scope_id = ?, updated_at = ?
|
|
10
|
+
WHERE knowledge_id = ?`).run(projectId, now, knowledgeId);
|
|
11
|
+
tx.prepare("UPDATE projects SET last_active_at = ?, updated_at = ? WHERE project_id = ?").run(now, now, projectId);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { bindKnowledgeItemToProject };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KnowledgeItem } from '../knowledge-memory/index.js';
|
|
2
2
|
import type { ProjectWithDetails } from './types.js';
|
|
3
3
|
export type ProjectWorkflowRunBrief = {
|
|
4
4
|
runId: string;
|
|
@@ -18,7 +18,7 @@ export type ProjectAttentionItem = {
|
|
|
18
18
|
};
|
|
19
19
|
export type ProjectTimelineItem = {
|
|
20
20
|
id: string;
|
|
21
|
-
kind: 'session' | 'task' | 'workflow' | '
|
|
21
|
+
kind: 'session' | 'task' | 'workflow' | 'knowledge';
|
|
22
22
|
title: string;
|
|
23
23
|
detail?: string;
|
|
24
24
|
timestamp: number;
|
|
@@ -60,7 +60,7 @@ export declare function buildProjectLoopOverview(input: {
|
|
|
60
60
|
tasks: ProjectTask[];
|
|
61
61
|
recentWorkflowRuns: ProjectWorkflowRunBrief[];
|
|
62
62
|
failedWorkflowRuns?: ProjectWorkflowRunBrief[];
|
|
63
|
-
|
|
63
|
+
knowledgeItems?: KnowledgeItem[];
|
|
64
64
|
nowMs?: number;
|
|
65
65
|
staleAfterMs?: number;
|
|
66
66
|
}): ProjectLoopOverview;
|
|
@@ -78,12 +78,12 @@ function buildProjectLoopOverview(input) {
|
|
|
78
78
|
status: run.status,
|
|
79
79
|
href: `/workflows?run=${encodeURIComponent(run.runId)}`
|
|
80
80
|
})),
|
|
81
|
-
...(input.
|
|
82
|
-
id: `
|
|
83
|
-
kind: "
|
|
81
|
+
...(input.knowledgeItems ?? []).slice(0, 5).map((record) => ({
|
|
82
|
+
id: `knowledge:${record.id}`,
|
|
83
|
+
kind: "knowledge",
|
|
84
84
|
title: record.kind,
|
|
85
85
|
detail: compactText(record.content),
|
|
86
|
-
timestamp:
|
|
86
|
+
timestamp: record.updatedAt,
|
|
87
87
|
status: record.status
|
|
88
88
|
}))
|
|
89
89
|
].filter((item) => Number.isFinite(item.timestamp)).sort((left, right) => right.timestamp - left.timestamp).slice(0, 12);
|
|
@@ -11,7 +11,8 @@ export type ProjectSuggestion = {
|
|
|
11
11
|
export declare class ProjectService {
|
|
12
12
|
private readonly store;
|
|
13
13
|
private readonly signals?;
|
|
14
|
-
|
|
14
|
+
private readonly workspaceId;
|
|
15
|
+
constructor(store?: ProjectStore, signals?: ProactiveSignalPublisher, workspaceId?: string);
|
|
15
16
|
private listAllProjects;
|
|
16
17
|
create(input: CreateProjectInput): Project;
|
|
17
18
|
get(id: string): Project | null;
|
|
@@ -9,9 +9,10 @@ import { bindSessionToProject, listProjectSessionKeys, unbindSessionFromProject
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
//#region src/projects/project-service.ts
|
|
11
11
|
var ProjectService = class {
|
|
12
|
-
constructor(store = new ProjectStore(), signals) {
|
|
12
|
+
constructor(store = new ProjectStore(), signals, workspaceId = "default") {
|
|
13
13
|
this.store = store;
|
|
14
14
|
this.signals = signals;
|
|
15
|
+
this.workspaceId = workspaceId;
|
|
15
16
|
}
|
|
16
17
|
listAllProjects() {
|
|
17
18
|
const items = [];
|
|
@@ -199,7 +200,7 @@ var ProjectService = class {
|
|
|
199
200
|
},
|
|
200
201
|
actor: { kind: "system" },
|
|
201
202
|
scope: {
|
|
202
|
-
workspaceId:
|
|
203
|
+
workspaceId: this.workspaceId,
|
|
203
204
|
projectId: project.id
|
|
204
205
|
},
|
|
205
206
|
occurredAt: new Date(project.updatedAt).toISOString(),
|
|
@@ -308,7 +308,8 @@ var ProjectStore = class {
|
|
|
308
308
|
db.prepare(`UPDATE tasks SET project_id = NULL WHERE project_id = ?`).run(id);
|
|
309
309
|
db.prepare(`UPDATE workflow_runs SET project_id = NULL WHERE project_id = ?`).run(id);
|
|
310
310
|
db.prepare(`UPDATE automations SET project_id = NULL WHERE project_id = ?`).run(id);
|
|
311
|
-
db.prepare(`UPDATE
|
|
311
|
+
db.prepare(`UPDATE knowledge_items SET status = 'archived', updated_at = ?
|
|
312
|
+
WHERE scope_type = 'project' AND scope_id = ?`).run(Date.now(), id);
|
|
312
313
|
db.prepare(`DELETE FROM projects_fts WHERE project_id = ?`).run(id);
|
|
313
314
|
db.prepare(`DELETE FROM projects WHERE project_id = ?`).run(id);
|
|
314
315
|
});
|
|
@@ -30,6 +30,7 @@ function isAuthorizedTopic(topic, scopes) {
|
|
|
30
30
|
if (topic === "logs") return hasGatewayScope(scopes, "gateway.admin");
|
|
31
31
|
if (topic === "sessions" || topic.startsWith("session:")) return hasGatewayScope(scopes, "sessions.read");
|
|
32
32
|
if (topic.startsWith("run:")) return hasGatewayScope(scopes, "agents.run");
|
|
33
|
+
if (topic.startsWith("side-chat:")) return hasGatewayScope(scopes, "agents.run");
|
|
33
34
|
if (topic.startsWith("workflow:")) return hasGatewayScope(scopes, "automations.read");
|
|
34
35
|
return false;
|
|
35
36
|
}
|
|
@@ -14,8 +14,8 @@ import { bundledPythonArchiveName, resolveOfflineBundleArtifact } from "./offlin
|
|
|
14
14
|
import { normalizeRuntimeVersionRequest, parseRuntimeVersion, probeSystemRuntime, resolveInstallVersion, versionSatisfies } from "./probe.js";
|
|
15
15
|
import { dirname, join } from "node:path";
|
|
16
16
|
import { randomUUID } from "node:crypto";
|
|
17
|
-
import { access, mkdir, realpath, rename, rm } from "node:fs/promises";
|
|
18
17
|
import { EventEmitter } from "node:events";
|
|
18
|
+
import { access, mkdir, realpath, rename, rm } from "node:fs/promises";
|
|
19
19
|
//#region src/runtime-tools/manager.ts
|
|
20
20
|
init_logger();
|
|
21
21
|
const log = createLogger("RuntimeManager");
|
|
@@ -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";
|
|
@@ -3,8 +3,8 @@ 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
5
|
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
6
|
-
import "./types.js";
|
|
7
6
|
import { buildSessionContextForLlm, buildSessionDisplayMessages, isRuntimeOnlyTranscriptMessage, isTranscriptCompactionEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
7
|
+
import "./types.js";
|
|
8
8
|
import { init_agent_session_key, resolveAgentIdFromSessionKey } from "../routing/agent-session-key.js";
|
|
9
9
|
import { estimateTokensFromMessages } from "../storage/sqlite/row-mappers.js";
|
|
10
10
|
import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getGlobalSessionStats, getSessionMetadata, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord } from "../storage/sqlite/session-repository.js";
|
|
@@ -13,6 +13,7 @@ import { getSessionConfig, setSessionConfig } from "../storage/sqlite/config-rep
|
|
|
13
13
|
import "../storage/sqlite/index.js";
|
|
14
14
|
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
15
15
|
import { SessionCompactor } from "../agent/memory/compaction.js";
|
|
16
|
+
import { resolveUserContextSessionAccess } from "../user-context/access-policy.js";
|
|
16
17
|
import { readPostCompactionContext } from "../agent/reply/post-compaction-context.js";
|
|
17
18
|
import { resolveCompactionPolicy } from "../agent/memory/compaction-policy.js";
|
|
18
19
|
import { promoteCompactionLedger } from "../agent/memory/compaction-promotion.js";
|
|
@@ -464,6 +465,7 @@ var SessionStore = class {
|
|
|
464
465
|
})) throw new Error(`Session changed while compaction was running: ${key}`);
|
|
465
466
|
try {
|
|
466
467
|
const metadata = getSessionMetadata(key);
|
|
468
|
+
const access = resolveUserContextSessionAccess(this.options.config, key);
|
|
467
469
|
const promoted = promoteCompactionLedger({
|
|
468
470
|
sessionKey: key,
|
|
469
471
|
sessionId: expectedSnapshot.sessionId,
|
|
@@ -472,7 +474,8 @@ var SessionStore = class {
|
|
|
472
474
|
projectId: metadata?.projectId,
|
|
473
475
|
handover: result.handover,
|
|
474
476
|
audit: result.audit,
|
|
475
|
-
sourceEntries: expectedSnapshot.entries
|
|
477
|
+
sourceEntries: expectedSnapshot.entries,
|
|
478
|
+
writePolicy: access.knowledge && this.options.config.userContext.knowledgeMemory.sources.includes("session") ? this.options.config.userContext.knowledgeMemory.writePolicy : "deny"
|
|
476
479
|
});
|
|
477
480
|
log.info({
|
|
478
481
|
sessionKey: key,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type UserModelScope } from '../../user-model/domain.js';
|
|
2
|
+
export interface CollaborationRule {
|
|
3
|
+
id: string;
|
|
4
|
+
category: 'communication' | 'execution' | 'boundary' | 'routine' | 'proactive';
|
|
5
|
+
status: 'active' | 'disabled' | 'archived';
|
|
6
|
+
priority: number;
|
|
7
|
+
scope: UserModelScope;
|
|
8
|
+
conditions: Record<string, unknown>;
|
|
9
|
+
statement: string;
|
|
10
|
+
revisionId: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function getCollaborationRule(id: string): CollaborationRule | undefined;
|
|
15
|
+
export declare function listCollaborationRules(principalId?: string): CollaborationRule[];
|
|
16
|
+
export declare function createCollaborationRule(input: Pick<CollaborationRule, 'category' | 'priority' | 'scope' | 'conditions' | 'statement'> & {
|
|
17
|
+
status?: CollaborationRule['status'];
|
|
18
|
+
}): CollaborationRule;
|
|
19
|
+
export declare function setCollaborationRuleStatus(id: string, status: CollaborationRule['status']): CollaborationRule | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
+
import { USER_MODEL_PRINCIPAL_ID } from "../../user-model/domain.js";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
//#region src/storage/sqlite/collaboration-rule-repository.ts
|
|
5
|
+
function fromRow(row) {
|
|
6
|
+
return {
|
|
7
|
+
id: row.rule_id,
|
|
8
|
+
category: row.category,
|
|
9
|
+
status: row.status,
|
|
10
|
+
priority: row.priority,
|
|
11
|
+
scope: {
|
|
12
|
+
type: row.scope_type,
|
|
13
|
+
...row.scope_id ? { id: row.scope_id } : {}
|
|
14
|
+
},
|
|
15
|
+
conditions: JSON.parse(row.conditions_json),
|
|
16
|
+
statement: row.statement,
|
|
17
|
+
revisionId: row.current_revision_id,
|
|
18
|
+
createdAt: row.created_at,
|
|
19
|
+
updatedAt: row.updated_at
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getCollaborationRule(id) {
|
|
23
|
+
const row = getSqliteDatabase().prepare(`SELECT r.*, v.statement FROM collaboration_rules r
|
|
24
|
+
JOIN collaboration_rule_revisions v ON v.revision_id = r.current_revision_id
|
|
25
|
+
WHERE r.rule_id = ?`).get(id);
|
|
26
|
+
return row ? fromRow(row) : void 0;
|
|
27
|
+
}
|
|
28
|
+
function listCollaborationRules(principalId = USER_MODEL_PRINCIPAL_ID) {
|
|
29
|
+
return getSqliteDatabase().prepare(`SELECT r.*, v.statement FROM collaboration_rules r
|
|
30
|
+
JOIN collaboration_rule_revisions v ON v.revision_id = r.current_revision_id
|
|
31
|
+
WHERE r.principal_id = ? ORDER BY r.priority, r.updated_at DESC`).all(principalId).map(fromRow);
|
|
32
|
+
}
|
|
33
|
+
function createCollaborationRule(input) {
|
|
34
|
+
if (!input.statement.trim()) throw new Error("Collaboration rule statement is required.");
|
|
35
|
+
if (input.scope.type === "agent") throw new Error("Agent-scoped collaboration rules are not supported.");
|
|
36
|
+
const id = randomUUID();
|
|
37
|
+
const revisionId = randomUUID();
|
|
38
|
+
const now = Date.now();
|
|
39
|
+
runSqliteWriteTransaction((db) => {
|
|
40
|
+
db.prepare(`INSERT INTO collaboration_rules (
|
|
41
|
+
rule_id, principal_id, category, status, priority, scope_type, scope_id,
|
|
42
|
+
conditions_json, current_revision_id, created_at, updated_at
|
|
43
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, USER_MODEL_PRINCIPAL_ID, input.category, input.status ?? "active", input.priority, input.scope.type, input.scope.id ?? null, JSON.stringify(input.conditions), revisionId, now, now);
|
|
44
|
+
db.prepare(`INSERT INTO collaboration_rule_revisions (
|
|
45
|
+
revision_id, rule_id, statement, created_by, created_at
|
|
46
|
+
) VALUES (?, ?, ?, 'user', ?)`).run(revisionId, id, input.statement.trim(), now);
|
|
47
|
+
});
|
|
48
|
+
return getCollaborationRule(id);
|
|
49
|
+
}
|
|
50
|
+
function setCollaborationRuleStatus(id, status) {
|
|
51
|
+
return getSqliteDatabase().prepare(`UPDATE collaboration_rules SET status = ?, updated_at = ? WHERE rule_id = ?`).run(status, Date.now(), id).changes ? getCollaborationRule(id) : void 0;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createCollaborationRule, getCollaborationRule, listCollaborationRules, setCollaborationRuleStatus };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
import { notifyUserContextChange } from "../../user-context/changes.js";
|
|
3
2
|
import { sessionConfigRowToConfig } from "./row-mappers.js";
|
|
3
|
+
import { notifyUserContextChange } from "../../user-context/changes.js";
|
|
4
4
|
import { ensureSessionInTransaction } from "./session-repository.js";
|
|
5
5
|
//#region src/storage/sqlite/config-repository.ts
|
|
6
6
|
function readConfigRow(db, sessionKey) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ConnectionCheckpoint, ConnectionNeed, ConnectionWait } from '@xopcai/gateway-contract';
|
|
2
|
+
import { type SessionInput } from './session-input-repository.js';
|
|
3
|
+
export declare function onConnectionWaitChanged(listener: (sessionKey: string) => void): () => void;
|
|
4
|
+
export declare function publishConnectionWait(sessionKey: string): void;
|
|
5
|
+
export declare function getConnectionWait(id: string): ConnectionWait | undefined;
|
|
6
|
+
export declare function getActiveConnectionWait(sessionKey: string): ConnectionWait | undefined;
|
|
7
|
+
export declare function isConnectionSuspended(sessionKey: string, runId: string): boolean;
|
|
8
|
+
export declare function updateConnectionWait(wait: ConnectionWait, expectedVersion: number): ConnectionWait;
|
|
9
|
+
export declare function requireSessionConnection(input: {
|
|
10
|
+
sessionKey: string;
|
|
11
|
+
principalId: string;
|
|
12
|
+
agentId: string;
|
|
13
|
+
summary: string;
|
|
14
|
+
needs: ConnectionNeed[];
|
|
15
|
+
checkpoint?: Omit<ConnectionCheckpoint, 'entryId'>;
|
|
16
|
+
}): {
|
|
17
|
+
status: 'connection_required' | 'skipped' | 'objective_conflict';
|
|
18
|
+
waitId?: string;
|
|
19
|
+
};
|
|
20
|
+
/** The input and the wait transition commit together, using the existing queue's unique key. */
|
|
21
|
+
export declare function queueConnectionResolution(wait: ConnectionWait, resolution: 'continued' | 'skipped'): ConnectionWait;
|
|
22
|
+
export declare function consumeConnectionResume(input: SessionInput): boolean;
|
|
23
|
+
export declare function connectionBindings(sessionKey: string): ConnectionNeed[];
|
|
24
|
+
export declare function connectionBinding(sessionKey: string, connectorId: string): string | undefined;
|
|
25
|
+
/** New input wins over an outstanding auto-resume intent, including an already queued resume. */
|
|
26
|
+
export declare function invalidateConnectionResumeIntent(sessionKey: string): void;
|
|
27
|
+
export declare function reviseCurrentConnectionObjective(sessionKey: string, summary: string | undefined): void;
|
|
28
|
+
export declare function cancelConnectionObjective(sessionKey: string): void;
|
|
29
|
+
export declare function getConnectionResumeInput(sessionKey: string, runId: string): SessionInput | undefined;
|
|
30
|
+
export declare function listConnectionWaitsToCheck(): ConnectionWait[];
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { isXopcDatabaseOpen } from "./connection.js";
|
|
4
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
5
|
+
import { readCurrentSessionId } from "./session-instance-repository.js";
|
|
6
|
+
import { bumpSessionInputRevision, getSessionInputById, getSessionInputState, insertSessionInput, setSessionInputStatus } from "./session-input-repository.js";
|
|
7
|
+
import { TaskRunRepository } from "../../tasks/task-run-repository.js";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
9
|
+
import { EventEmitter } from "node:events";
|
|
10
|
+
//#region src/storage/sqlite/connection-wait-repository.ts
|
|
11
|
+
init_logger();
|
|
12
|
+
const log = createLogger("Connectors:Wait");
|
|
13
|
+
const events = new EventEmitter();
|
|
14
|
+
function onConnectionWaitChanged(listener) {
|
|
15
|
+
events.on("changed", listener);
|
|
16
|
+
return () => {
|
|
17
|
+
events.off("changed", listener);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function publishConnectionWait(sessionKey) {
|
|
21
|
+
events.emit("changed", sessionKey);
|
|
22
|
+
}
|
|
23
|
+
function getConnectionWait(id) {
|
|
24
|
+
if (!isXopcDatabaseOpen()) return void 0;
|
|
25
|
+
const row = getSqliteDatabase().prepare("SELECT data_json FROM session_connection_waits WHERE id = ?").get(id);
|
|
26
|
+
return row ? JSON.parse(row.data_json) : void 0;
|
|
27
|
+
}
|
|
28
|
+
function getActiveConnectionWait(sessionKey) {
|
|
29
|
+
if (!isXopcDatabaseOpen()) return void 0;
|
|
30
|
+
const db = getSqliteDatabase();
|
|
31
|
+
const row = db.prepare(`SELECT data_json FROM session_connection_waits WHERE session_key = ? AND session_id = ?
|
|
32
|
+
AND status IN ('open','queued')`).get(sessionKey, readCurrentSessionId(db, sessionKey) ?? "");
|
|
33
|
+
return row ? JSON.parse(row.data_json) : void 0;
|
|
34
|
+
}
|
|
35
|
+
function isConnectionSuspended(sessionKey, runId) {
|
|
36
|
+
const wait = getActiveConnectionWait(sessionKey);
|
|
37
|
+
return Boolean(wait && wait.originRunId === runId);
|
|
38
|
+
}
|
|
39
|
+
function updateConnectionWait(wait, expectedVersion) {
|
|
40
|
+
return runSqliteWriteTransaction((db) => {
|
|
41
|
+
if (readCurrentSessionId(db, wait.sessionKey) !== wait.sessionId) throw new Error("SESSION_CHANGED");
|
|
42
|
+
const next = {
|
|
43
|
+
...wait,
|
|
44
|
+
version: expectedVersion + 1,
|
|
45
|
+
updatedAt: Date.now()
|
|
46
|
+
};
|
|
47
|
+
if (!db.prepare(`UPDATE session_connection_waits SET status = ?, version = ?, data_json = ? WHERE id = ? AND version = ?`).run(next.status, next.version, JSON.stringify(next), next.id, expectedVersion).changes) throw new Error("WAIT_CHANGED");
|
|
48
|
+
bumpSessionInputRevision(db, wait.sessionKey);
|
|
49
|
+
return next;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function requireSessionConnection(input) {
|
|
53
|
+
return runSqliteWriteTransaction((db) => {
|
|
54
|
+
const sessionId = readCurrentSessionId(db, input.sessionKey);
|
|
55
|
+
const runtime = getSessionInputState(input.sessionKey);
|
|
56
|
+
const origin = runtime.activeInputId ? getSessionInputById(input.sessionKey, runtime.activeInputId) : void 0;
|
|
57
|
+
if (!sessionId || !origin || !runtime.activeRunId) throw new Error("Connection recovery requires a queued chat execution.");
|
|
58
|
+
const resumed = origin.payload ? getConnectionWait(origin.payload.waitId) : void 0;
|
|
59
|
+
if (resumed?.resolution === "skipped") return { status: "skipped" };
|
|
60
|
+
const active = getActiveConnectionWait(input.sessionKey);
|
|
61
|
+
if (active) {
|
|
62
|
+
if (active.originInputId !== origin.id && active.objectiveId !== resumed?.objectiveId) return {
|
|
63
|
+
status: "objective_conflict",
|
|
64
|
+
waitId: active.id
|
|
65
|
+
};
|
|
66
|
+
const needs = new Map(active.needs.map((need) => [need.key, need]));
|
|
67
|
+
for (const need of input.needs) {
|
|
68
|
+
const previous = needs.get(need.key);
|
|
69
|
+
needs.set(need.key, previous ? {
|
|
70
|
+
...previous,
|
|
71
|
+
capabilities: [...new Set([...previous.capabilities, ...need.capabilities])]
|
|
72
|
+
} : need);
|
|
73
|
+
}
|
|
74
|
+
if (JSON.stringify([...needs.values()]) !== JSON.stringify(active.needs)) updateConnectionWait({
|
|
75
|
+
...active,
|
|
76
|
+
needs: [...needs.values()]
|
|
77
|
+
}, active.version);
|
|
78
|
+
return {
|
|
79
|
+
status: "connection_required",
|
|
80
|
+
waitId: active.id
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const lastEntry = db.prepare("SELECT entry_id FROM transcript_entries WHERE session_id = ? ORDER BY seq DESC LIMIT 1").get(sessionId);
|
|
84
|
+
const wait = {
|
|
85
|
+
...input,
|
|
86
|
+
needs: [...new Map(input.needs.map((need) => [need.key, need])).values()],
|
|
87
|
+
id: randomUUID(),
|
|
88
|
+
sessionId,
|
|
89
|
+
objectiveId: resumed?.objectiveId ?? origin.id,
|
|
90
|
+
objectiveRevision: (resumed?.objectiveRevision ?? 0) + 1,
|
|
91
|
+
objectiveUpdatedAt: resumed?.objectiveUpdatedAt ?? origin.createdAtMs,
|
|
92
|
+
originInputId: origin.id,
|
|
93
|
+
originRunId: runtime.activeRunId,
|
|
94
|
+
taskRunId: origin.taskRunId,
|
|
95
|
+
checkpoint: {
|
|
96
|
+
entryId: lastEntry?.entry_id,
|
|
97
|
+
completedSteps: input.checkpoint?.completedSteps ?? [],
|
|
98
|
+
pendingSteps: input.checkpoint?.pendingSteps ?? [input.summary],
|
|
99
|
+
timeRange: input.checkpoint?.timeRange ?? resumed?.checkpoint.timeRange
|
|
100
|
+
},
|
|
101
|
+
summary: resumed?.summary ?? origin.content,
|
|
102
|
+
status: "open",
|
|
103
|
+
version: 1,
|
|
104
|
+
createdAt: Date.now(),
|
|
105
|
+
updatedAt: Date.now()
|
|
106
|
+
};
|
|
107
|
+
db.prepare(`INSERT INTO session_connection_waits(id,principal_id,session_key,session_id,status,version,data_json) VALUES (?,?,?,?,?,?,?)`).run(wait.id, wait.principalId, wait.sessionKey, wait.sessionId, wait.status, wait.version, JSON.stringify(wait));
|
|
108
|
+
if (wait.taskRunId) {
|
|
109
|
+
const runs = new TaskRunRepository();
|
|
110
|
+
const run = runs.get(wait.taskRunId);
|
|
111
|
+
if (run) {
|
|
112
|
+
runs.createWait({
|
|
113
|
+
taskId: run.taskId,
|
|
114
|
+
taskRunId: run.id,
|
|
115
|
+
kind: "user_input",
|
|
116
|
+
reason: input.summary,
|
|
117
|
+
condition: {
|
|
118
|
+
type: "connection",
|
|
119
|
+
connectionWaitId: wait.id
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
runs.setStatus({
|
|
123
|
+
runId: run.id,
|
|
124
|
+
expectedVersion: run.version,
|
|
125
|
+
from: [run.status],
|
|
126
|
+
to: "waiting",
|
|
127
|
+
actor: { kind: "system" }
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
bumpSessionInputRevision(db, wait.sessionKey);
|
|
132
|
+
log.info({
|
|
133
|
+
sessionKey: wait.sessionKey,
|
|
134
|
+
waitId: wait.id,
|
|
135
|
+
objectiveRevision: wait.objectiveRevision,
|
|
136
|
+
runId: wait.originRunId,
|
|
137
|
+
phase: "waiting"
|
|
138
|
+
}, "Connection requirement saved");
|
|
139
|
+
return {
|
|
140
|
+
status: "connection_required",
|
|
141
|
+
waitId: wait.id
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** The input and the wait transition commit together, using the existing queue's unique key. */
|
|
146
|
+
function queueConnectionResolution(wait, resolution) {
|
|
147
|
+
return runSqliteWriteTransaction(() => {
|
|
148
|
+
const current = getConnectionWait(wait.id);
|
|
149
|
+
if (!current || current.version !== wait.version || current.status !== "open") throw new Error("WAIT_CHANGED");
|
|
150
|
+
const origin = getSessionInputById(wait.sessionKey, wait.originInputId);
|
|
151
|
+
if (!origin) throw new Error("Original input is unavailable.");
|
|
152
|
+
const input = insertSessionInput({
|
|
153
|
+
id: randomUUID(),
|
|
154
|
+
sessionKey: wait.sessionKey,
|
|
155
|
+
expectedSessionId: wait.sessionId,
|
|
156
|
+
clientMessageId: `connection:${wait.id}:${wait.objectiveRevision}:${resolution}`,
|
|
157
|
+
requestedDelivery: "next",
|
|
158
|
+
effectiveDelivery: "next",
|
|
159
|
+
status: "queued",
|
|
160
|
+
content: resolution === "skipped" ? `The user skipped the requested connection. Continue this objective using only available information: ${wait.summary}. Do not request these connections again or claim to have read their data.` : `Recovery checkpoint: ${JSON.stringify(wait.checkpoint)}. The user chose to continue the request originally made at ${new Date(wait.objectiveUpdatedAt).toISOString()}: ${wait.summary}. Interpret relative dates against that original request time, unless the user explicitly changed them. The connection requirement has been checked. Search and describe tools again before using them. Use the explicitly selected account. Do not repeat already completed actions.`,
|
|
161
|
+
origin: {
|
|
162
|
+
type: "system",
|
|
163
|
+
source: "internal"
|
|
164
|
+
},
|
|
165
|
+
thinking: origin.thinking,
|
|
166
|
+
contextRefs: origin.contextRefs,
|
|
167
|
+
contextSnapshots: origin.contextSnapshots,
|
|
168
|
+
kind: "connection_resume",
|
|
169
|
+
taskRunId: wait.taskRunId,
|
|
170
|
+
payload: {
|
|
171
|
+
waitId: wait.id,
|
|
172
|
+
objectiveRevision: wait.objectiveRevision,
|
|
173
|
+
resolution
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return updateConnectionWait({
|
|
177
|
+
...wait,
|
|
178
|
+
status: "queued",
|
|
179
|
+
resolution,
|
|
180
|
+
queuedInputId: input.id
|
|
181
|
+
}, wait.version);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function consumeConnectionResume(input) {
|
|
185
|
+
if (input.kind !== "connection_resume") return true;
|
|
186
|
+
return runSqliteWriteTransaction(() => {
|
|
187
|
+
const wait = input.payload ? getConnectionWait(input.payload.waitId) : void 0;
|
|
188
|
+
if (!wait || wait.status !== "queued" || wait.queuedInputId !== input.id || wait.objectiveRevision !== input.payload?.objectiveRevision) return false;
|
|
189
|
+
if (readCurrentSessionId(getSqliteDatabase(), input.sessionKey) !== wait.sessionId) return false;
|
|
190
|
+
if (wait.taskRunId) {
|
|
191
|
+
const runs = new TaskRunRepository();
|
|
192
|
+
const run = runs.get(wait.taskRunId);
|
|
193
|
+
if (!run || run.status !== "waiting") return false;
|
|
194
|
+
const taskWaits = runs.listActiveWaits(run.taskId);
|
|
195
|
+
if (taskWaits.some((item) => item.taskRunId === run.id && item.condition.connectionWaitId !== wait.id)) {
|
|
196
|
+
updateConnectionWait({
|
|
197
|
+
...wait,
|
|
198
|
+
status: "open",
|
|
199
|
+
intent: void 0,
|
|
200
|
+
queuedInputId: void 0,
|
|
201
|
+
objectiveRevision: wait.objectiveRevision + 1
|
|
202
|
+
}, wait.version);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
for (const taskWait of taskWaits) if (taskWait.condition.connectionWaitId === wait.id) runs.resolveWait({
|
|
206
|
+
waitId: taskWait.id,
|
|
207
|
+
actor: { kind: "system" },
|
|
208
|
+
resolution: { connectionWaitId: wait.id }
|
|
209
|
+
});
|
|
210
|
+
runs.setStatus({
|
|
211
|
+
runId: run.id,
|
|
212
|
+
expectedVersion: run.version,
|
|
213
|
+
from: ["waiting"],
|
|
214
|
+
to: "running",
|
|
215
|
+
actor: { kind: "system" }
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
updateConnectionWait({
|
|
219
|
+
...wait,
|
|
220
|
+
status: "closed"
|
|
221
|
+
}, wait.version);
|
|
222
|
+
return true;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function connectionBindings(sessionKey) {
|
|
226
|
+
if (!isXopcDatabaseOpen()) return [];
|
|
227
|
+
const state = getSessionInputState(sessionKey);
|
|
228
|
+
const input = state.activeInputId ? getSessionInputById(sessionKey, state.activeInputId) : void 0;
|
|
229
|
+
return input?.payload ? getConnectionWait(input.payload.waitId)?.needs ?? [] : [];
|
|
230
|
+
}
|
|
231
|
+
function connectionBinding(sessionKey, connectorId) {
|
|
232
|
+
const matches = connectionBindings(sessionKey).filter((need) => need.connectorId === connectorId);
|
|
233
|
+
return matches.length === 1 ? matches[0].connectionId : void 0;
|
|
234
|
+
}
|
|
235
|
+
/** New input wins over an outstanding auto-resume intent, including an already queued resume. */
|
|
236
|
+
function invalidateConnectionResumeIntent(sessionKey) {
|
|
237
|
+
const wait = getActiveConnectionWait(sessionKey);
|
|
238
|
+
if (!wait) return;
|
|
239
|
+
runSqliteWriteTransaction(() => {
|
|
240
|
+
if (wait.queuedInputId) setSessionInputStatus(wait.queuedInputId, "cancelled");
|
|
241
|
+
updateConnectionWait({
|
|
242
|
+
...wait,
|
|
243
|
+
status: "open",
|
|
244
|
+
intent: void 0,
|
|
245
|
+
queuedInputId: void 0,
|
|
246
|
+
objectiveRevision: wait.objectiveRevision + 1,
|
|
247
|
+
scopeConfirmedAt: void 0,
|
|
248
|
+
reviewRequired: true
|
|
249
|
+
}, wait.version);
|
|
250
|
+
});
|
|
251
|
+
publishConnectionWait(sessionKey);
|
|
252
|
+
}
|
|
253
|
+
function reviseCurrentConnectionObjective(sessionKey, summary) {
|
|
254
|
+
const wait = getActiveConnectionWait(sessionKey);
|
|
255
|
+
if (!wait) throw new Error("No connection objective is waiting.");
|
|
256
|
+
if (!summary) {
|
|
257
|
+
cancelConnectionObjective(sessionKey);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
runSqliteWriteTransaction(() => {
|
|
261
|
+
if (wait.queuedInputId) setSessionInputStatus(wait.queuedInputId, "cancelled");
|
|
262
|
+
updateConnectionWait({
|
|
263
|
+
...wait,
|
|
264
|
+
summary,
|
|
265
|
+
objectiveUpdatedAt: Date.now(),
|
|
266
|
+
checkpoint: {
|
|
267
|
+
...wait.checkpoint,
|
|
268
|
+
pendingSteps: [summary],
|
|
269
|
+
timeRange: void 0
|
|
270
|
+
},
|
|
271
|
+
status: "open",
|
|
272
|
+
resolution: void 0,
|
|
273
|
+
intent: void 0,
|
|
274
|
+
queuedInputId: void 0,
|
|
275
|
+
scopeConfirmedAt: void 0,
|
|
276
|
+
reviewRequired: true,
|
|
277
|
+
objectiveRevision: wait.objectiveRevision + 1
|
|
278
|
+
}, wait.version);
|
|
279
|
+
});
|
|
280
|
+
publishConnectionWait(sessionKey);
|
|
281
|
+
}
|
|
282
|
+
function cancelConnectionObjective(sessionKey) {
|
|
283
|
+
const wait = getActiveConnectionWait(sessionKey);
|
|
284
|
+
if (!wait) return;
|
|
285
|
+
runSqliteWriteTransaction(() => {
|
|
286
|
+
if (wait.queuedInputId) setSessionInputStatus(wait.queuedInputId, "cancelled");
|
|
287
|
+
if (wait.taskRunId) {
|
|
288
|
+
const runs = new TaskRunRepository();
|
|
289
|
+
const run = runs.get(wait.taskRunId);
|
|
290
|
+
if (run?.status === "waiting") {
|
|
291
|
+
for (const taskWait of runs.listActiveWaits(run.taskId)) if (taskWait.condition.connectionWaitId === wait.id) runs.resolveWait({
|
|
292
|
+
waitId: taskWait.id,
|
|
293
|
+
actor: { kind: "system" },
|
|
294
|
+
resolution: { cancelled: true }
|
|
295
|
+
});
|
|
296
|
+
runs.finalize({
|
|
297
|
+
runId: run.id,
|
|
298
|
+
expectedVersion: run.version,
|
|
299
|
+
receipt: {
|
|
300
|
+
status: "cancelled",
|
|
301
|
+
summary: "Connection objective cancelled",
|
|
302
|
+
changes: [],
|
|
303
|
+
evidence: [],
|
|
304
|
+
verification: {
|
|
305
|
+
status: "unverified",
|
|
306
|
+
checks: []
|
|
307
|
+
},
|
|
308
|
+
remainingWork: [],
|
|
309
|
+
needsUser: false,
|
|
310
|
+
completionVerdict: "not_achieved"
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
updateConnectionWait({
|
|
316
|
+
...wait,
|
|
317
|
+
status: "closed",
|
|
318
|
+
resolution: "cancelled",
|
|
319
|
+
intent: void 0
|
|
320
|
+
}, wait.version);
|
|
321
|
+
});
|
|
322
|
+
publishConnectionWait(sessionKey);
|
|
323
|
+
}
|
|
324
|
+
function getConnectionResumeInput(sessionKey, runId) {
|
|
325
|
+
if (!isXopcDatabaseOpen()) return void 0;
|
|
326
|
+
const state = getSessionInputState(sessionKey);
|
|
327
|
+
if (state.activeRunId !== runId || !state.activeInputId) return void 0;
|
|
328
|
+
const input = getSessionInputById(sessionKey, state.activeInputId);
|
|
329
|
+
return input?.kind === "connection_resume" ? input : void 0;
|
|
330
|
+
}
|
|
331
|
+
function listConnectionWaitsToCheck() {
|
|
332
|
+
if (!isXopcDatabaseOpen()) return [];
|
|
333
|
+
return getSqliteDatabase().prepare(`SELECT wait.data_json FROM session_connection_waits wait
|
|
334
|
+
JOIN sessions session ON session.session_id = wait.session_id
|
|
335
|
+
WHERE wait.status = 'open'`).all().map((row) => JSON.parse(row.data_json)).filter((wait) => wait.principalId === "local-owner" && wait.intent && wait.intent.validUntil > Date.now());
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
export { cancelConnectionObjective, connectionBinding, connectionBindings, consumeConnectionResume, getActiveConnectionWait, getConnectionResumeInput, getConnectionWait, invalidateConnectionResumeIntent, isConnectionSuspended, listConnectionWaitsToCheck, onConnectionWaitChanged, publishConnectionWait, queueConnectionResolution, requireSessionConnection, reviseCurrentConnectionObjective, updateConnectionWait };
|
|
@@ -59,7 +59,7 @@ function mergeAccountSourceData(db, connectorId, sourceAccountId, targetAccountI
|
|
|
59
59
|
`).run(targetId, sourceId);
|
|
60
60
|
db.prepare("DELETE FROM knowledge_consumer_watermarks WHERE source_instance_id = ?").run(sourceId);
|
|
61
61
|
db.prepare(`
|
|
62
|
-
UPDATE
|
|
62
|
+
UPDATE knowledge_items
|
|
63
63
|
SET source_json = json_set(source_json, '$.sourceInstanceId', ?)
|
|
64
64
|
WHERE json_extract(source_json, '$.sourceInstanceId') = ?
|
|
65
65
|
`).run(targetId, sourceId);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ContextEvidence {
|
|
2
|
+
id: string;
|
|
3
|
+
sourceType: 'conversation' | 'connector' | 'user' | 'runtime';
|
|
4
|
+
sourceInstanceId?: string;
|
|
5
|
+
sourceRef: string;
|
|
6
|
+
sourceRunId?: string;
|
|
7
|
+
sourceItemId?: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
turnId?: string;
|
|
10
|
+
messageId?: string;
|
|
11
|
+
contentHash?: string;
|
|
12
|
+
retentionPolicy?: string;
|
|
13
|
+
processingPolicy?: 'local_only' | 'remote_allowed';
|
|
14
|
+
extractorId?: string;
|
|
15
|
+
extractorVersion?: string;
|
|
16
|
+
redactedExcerpt?: string;
|
|
17
|
+
trustLevel: 'owner' | 'trusted' | 'untrusted';
|
|
18
|
+
observedAt: number;
|
|
19
|
+
ingestedAt: number;
|
|
20
|
+
createdAt: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function createContextEvidence(input: Omit<ContextEvidence, 'id' | 'ingestedAt' | 'createdAt'> & {
|
|
23
|
+
ingestedAt?: number;
|
|
24
|
+
}, principalId?: string): ContextEvidence;
|