@xopcai/xopc 0.0.248 → 0.0.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-etpmyV7S.js → activity-store-B759R_qf.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BmKxSM1k.js → agent-avatar-dicebear-BUu7EnwM.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C1rXNUAG.js +1 -0
- package/dist/gateway/static/root/assets/agents-DK9HjHO0.js +1 -0
- package/dist/gateway/static/root/assets/{api-B0-hLuZ1.js → api-Cg0v7Lpn.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-C9DkCW_d.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-CFggS95Y.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-jOvT-fzU.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BnMSgZvR.js → archive-plugin-BQrilVVv.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CejsQMev.js → attachment-load-BG0BliqV.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-RC8EyoAf.js → automations-page-Bo4RiTkh.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BKjKTlW8.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DGjppLSG.js → binary-plugins-BCnyNU0C.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CWdP4bUc.js → block-editor-Db8DlVvg.js} +50 -50
- package/dist/gateway/static/root/assets/browser-settings-page-Dzq18pO1.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BQ1Ilw_o.js → browser-workflow-inputs-C71vfl0b.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CJh4NyxT.js → browser-workflows-page-vvmSYKsO.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DW4SBQf4.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-57OGuewD.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-Ohhee4vm.js → channels-status-swr-CKyV3jY5.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BOtoKTK3.js → chat-terminal-dock-B1Xd6OFB.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-CT_I3kbR.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DTj1V3Sw.js → cron-expression-D-F9vjtE.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Yr6OCvGL.js → date-picker-B2OoYvic.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-BiGx9Sbj.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-DbGzggPF.js → desktop-pet-BNMRqipe.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DeYbIV7A.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DgTtk4KC.js → extension-debug-page-COyn05ub.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DtQeiP6f.js → extension-page-oH43chS2.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BMO59994.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-cimpViGk.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DXuXtU1w.js → gateway-config-swr-BGdHwT4e.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BHJtnSic.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CzBzglzQ.js → gateway-startup-retry-CuaM3b4c.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DNhrZHqx.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BiHwiBnQ.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-TIgsn04n.js → image-generation-api-D7duj7Uj.js} +1 -1
- package/dist/gateway/static/root/assets/index-DGeGmj4k.css +2 -0
- package/dist/gateway/static/root/assets/index-aBs0EfQB.js +72 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-wsWuoa8p.js → keyboard-shortcuts-settings-D8Zw_lYd.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CpyvYyrb.js → local-app-workbench-page-eBFVWmtH.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-CXrbrGo8.js → local-apps-page-CvPDPRwb.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BJFLQY8O.js → locale-store-zEL8bkwx.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-ClvcWlL6.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-BdJZFR7U.js → management-settings-D8moh99U.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-NK3ACVG2.js → markdown-split-D7V3j0vE.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DTF9v1gg.js → markdown-view-DGRN-8wP.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-F0jcUxyl.js → media-plugins-BLaE5b1Y.js} +1 -1
- package/dist/gateway/static/root/assets/messages-W5P19VTF.js +11 -0
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-DiVDuCxl.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-CEEvR-fV.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BLqgXNCx.js +8 -0
- package/dist/gateway/static/root/assets/page-tabs-BFMGjA60.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-DNEWZN7H.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-CxGGlWA8.js → product-open-page-Co5u7asH.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CIiFJ5tk.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B3UF-Pfm.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CIsNlSBi.js → registry-api-Cg92zSod.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUtpkJPG.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-YkjhiQfA.js → runtime-tools-settings-panel-C0ByNmlV.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-oFGf3G3s.js → schema-form-Dq_VQpuY.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-UgJmG-V4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDCzpdkl.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-CZu6FX4k.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-C7VWs0IT.js → settings-page-S8ekeUZd.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BdVmwXMv.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-t5oz18rh.js → share-preview-page-D2fEidbn.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BdsqnCYj.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-ghzAQKna.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-AYiPlgZE.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-DEDTYs2W.js → skills-page.utils-DGzl-ib-.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-5Xd5mIiR.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-BQAUaCDD.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-O597U8q_.js → theme-store-ZVClZKQ0.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-CdZN1Jin.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-B5eUJ6Zq.js → use-autosave-czRI0NBc.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-W3GTm6nA.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CMKSwz4C.js → voice-api-key-field-8YEvA3cU.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-q7B6fOFB.js → voice-config-api-CopF64lY.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-keLtqYYJ.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DZmvLZjb.js → workflow-run-setup-panel-Dy5WgYMO.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BbAV3h7n.js +5 -0
- package/dist/gateway/static/root/index.html +10 -26
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-instance-gateway.d.ts +2 -2
- package/dist/src/agent/agent-manager.d.ts +4 -4
- package/dist/src/agent/agent-manager.js +31 -15
- package/dist/src/agent/background-review/coordinator.d.ts +2 -4
- package/dist/src/agent/background-review/coordinator.js +5 -30
- package/dist/src/agent/background-review/prompts.d.ts +4 -2
- package/dist/src/agent/background-review/prompts.js +24 -19
- package/dist/src/agent/background-review/run-background-review.d.ts +6 -7
- package/dist/src/agent/background-review/run-background-review.js +47 -41
- package/dist/src/agent/background-review/settings.d.ts +0 -1
- package/dist/src/agent/background-review/settings.js +6 -7
- package/dist/src/agent/context/audit.d.ts +36 -0
- package/dist/src/agent/context/audit.js +97 -0
- package/dist/src/agent/context/coordinator.d.ts +26 -0
- package/dist/src/agent/context/coordinator.js +72 -0
- package/dist/src/agent/context/execution-context.d.ts +54 -0
- package/dist/src/agent/context/execution-context.js +147 -0
- package/dist/src/agent/context/execution-scope.js +1 -1
- package/dist/src/agent/context/prepend.d.ts +2 -0
- package/dist/src/agent/context/prepend.js +28 -0
- package/dist/src/agent/context/project-context.d.ts +3 -3
- package/dist/src/agent/context/project-context.js +26 -23
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -0
- package/dist/src/agent/embedded/run-turn.js +22 -2
- package/dist/src/agent/embedded/types.d.ts +1 -25
- package/dist/src/agent/external-tools/composio-provider.js +87 -92
- package/dist/src/agent/external-tools/gateway-tools.d.ts +4 -1
- package/dist/src/agent/external-tools/gateway-tools.js +153 -41
- package/dist/src/agent/external-tools/index.js +1 -1
- package/dist/src/agent/external-tools/search-error.d.ts +12 -0
- package/dist/src/agent/external-tools/search-error.js +29 -0
- package/dist/src/agent/external-tools/service.d.ts +4 -0
- package/dist/src/agent/external-tools/service.js +22 -2
- package/dist/src/agent/memory/compaction-policy.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.js +45 -77
- package/dist/src/agent/memory/create-memory-manager.js +1 -3
- package/dist/src/agent/memory/index.d.ts +0 -5
- package/dist/src/agent/memory/index.js +2 -5
- package/dist/src/agent/memory/manager.d.ts +0 -16
- package/dist/src/agent/memory/manager.js +11 -40
- package/dist/src/agent/memory/memory-config.js +1 -1
- package/dist/src/agent/memory/runtime.d.ts +2 -2
- package/dist/src/agent/memory/runtime.js +9 -19
- package/dist/src/agent/memory/types.d.ts +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +13 -21
- package/dist/src/agent/prompt/sections/memory-skills.js +25 -36
- package/dist/src/agent/prompt/sections/tooling.js +10 -4
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -3
- package/dist/src/agent/service/direct-turn-helpers.js +6 -23
- package/dist/src/agent/service/process-direct-streaming.js +5 -3
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/tasks/task-judge-service.js +1 -1
- package/dist/src/agent/tools/clarify-tool.d.ts +1 -0
- package/dist/src/agent/tools/delegate-tool.js +5 -2
- package/dist/src/agent/tools/factory.js +36 -19
- package/dist/src/agent/tools/index.d.ts +3 -2
- package/dist/src/agent/tools/index.js +4 -3
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +9 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +129 -0
- package/dist/src/agent/tools/{dreaming-tool.d.ts → memory-maintenance-tool.d.ts} +2 -2
- package/dist/src/agent/tools/memory-maintenance-tool.js +31 -0
- package/dist/src/agent/tools/user-context-tool.d.ts +8 -0
- package/dist/src/agent/tools/user-context-tool.js +81 -0
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/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 +42 -0
- package/dist/src/connectors/connection-recovery-service.js +396 -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/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 +7 -15
- package/dist/src/gateway/hono/routes/context-sources.d.ts +4 -0
- package/dist/src/gateway/hono/routes/context-sources.js +159 -0
- package/dist/src/gateway/hono/routes/index.js +4 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -4
- package/dist/src/gateway/hono/routes/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 +2 -2
- package/dist/src/gateway/hono/routes/user-model.d.ts +3 -0
- package/dist/src/gateway/hono/routes/user-model.js +480 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +72 -0
- package/dist/src/gateway/service/agent-runner.d.ts +9 -1
- package/dist/src/gateway/service/agent-runner.js +25 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
- package/dist/src/gateway/service/config-coordinator.js +4 -4
- package/dist/src/gateway/service/run-gateway-agent.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +18 -14
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +12 -2
- package/dist/src/gateway/service.d.ts +3 -1
- package/dist/src/gateway/service.js +45 -14
- package/dist/src/gateway/side-chat/manager.d.ts +16 -3
- package/dist/src/gateway/side-chat/manager.js +117 -28
- package/dist/src/gateway/side-chat/run-service.d.ts +2 -0
- package/dist/src/gateway/side-chat/run-service.js +28 -5
- package/dist/src/gateway/side-chat/types.d.ts +9 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +0 -2
- package/dist/src/knowledge/connected-knowledge-pipeline.js +46 -217
- package/dist/src/knowledge-memory/domain.d.ts +35 -0
- package/dist/src/knowledge-memory/index.d.ts +2 -0
- package/dist/src/knowledge-memory/index.js +2 -0
- package/dist/src/knowledge-memory/repository.d.ts +45 -0
- package/dist/src/knowledge-memory/repository.js +154 -0
- package/dist/src/memory-maintenance/index.d.ts +2 -0
- package/dist/src/memory-maintenance/index.js +3 -0
- package/dist/src/memory-maintenance/schedule.d.ts +13 -0
- package/dist/src/memory-maintenance/schedule.js +51 -0
- package/dist/src/memory-maintenance/service.d.ts +28 -0
- package/dist/src/memory-maintenance/service.js +216 -0
- package/dist/src/notes/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/proactive/execution/context.d.ts +2 -2
- package/dist/src/proactive/execution/context.js +16 -11
- package/dist/src/proactive/index.d.ts +1 -1
- package/dist/src/proactive/index.js +2 -2
- package/dist/src/projects/index.d.ts +1 -1
- package/dist/src/projects/index.js +2 -2
- package/dist/src/projects/knowledge-bind.d.ts +1 -0
- package/dist/src/projects/knowledge-bind.js +15 -0
- package/dist/src/projects/project-loop.d.ts +3 -3
- package/dist/src/projects/project-loop.js +4 -4
- package/dist/src/projects/project-store.js +2 -1
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/runtime-tools/manager.js +1 -1
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +54 -0
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +30 -0
- package/dist/src/storage/sqlite/connection-wait-repository.js +338 -0
- package/dist/src/storage/sqlite/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 +4 -6
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +0 -19
- package/dist/src/storage/sqlite/knowledge-repository.js +1 -90
- package/dist/src/storage/sqlite/migrations/148_user_model_foundation.sql +554 -0
- package/dist/src/storage/sqlite/migrations/149_separate_source_index_from_memory.sql +18 -0
- package/dist/src/storage/sqlite/migrations/150_session_connection_waits.sql +47 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.d.ts +2 -1
- package/dist/src/storage/sqlite/notes-repository.js +37 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +14 -2
- package/dist/src/storage/sqlite/session-input-repository.js +16 -13
- package/dist/src/storage/sqlite/session-repository.js +4 -1
- package/dist/src/storage/sqlite/transcript-repository.js +1 -1
- package/dist/src/tasks/index.js +2 -2
- package/dist/src/tasks/project-operating-view-service.js +1 -1
- package/dist/src/tasks/task-application-service.js +6 -1
- package/dist/src/tasks/task-context-assembler.js +1 -1
- package/dist/src/tasks/task-context-repository.d.ts +0 -1
- package/dist/src/tasks/task-context-repository.js +1 -1
- package/dist/src/tasks/task-deletion-service.js +1 -1
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tasks/task-read-model-projector.js +1 -1
- package/dist/src/tasks/task-run-coordinator.js +1 -1
- package/dist/src/tasks/task-run-dispatcher.js +1 -1
- package/dist/src/tasks/task-run-repository.js +1 -0
- package/dist/src/tasks/task-signal-service.js +1 -1
- package/dist/src/tui/tool-summary.js +2 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/user-context/changes.d.ts +1 -1
- package/dist/src/user-context/config.d.ts +135 -153
- package/dist/src/user-context/config.js +94 -99
- package/dist/src/user-context/relationship-continuity.d.ts +2 -2
- package/dist/src/user-context/relationship-continuity.js +34 -24
- package/dist/src/user-context/sources/activity-clustering.d.ts +9 -3
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/repository.d.ts +1 -21
- package/dist/src/user-context/sources/repository.js +1 -183
- package/dist/src/user-context/sources/types.d.ts +0 -23
- package/dist/src/user-model/capture/executor.d.ts +40 -0
- package/dist/src/user-model/capture/executor.js +134 -0
- package/dist/src/user-model/capture/index.d.ts +2 -0
- package/dist/src/user-model/capture/index.js +3 -0
- package/dist/src/user-model/capture/semantic.d.ts +21 -0
- package/dist/src/user-model/capture/semantic.js +197 -0
- package/dist/src/user-model/domain.d.ts +93 -0
- package/dist/src/user-model/domain.js +33 -0
- package/dist/src/user-model/goals.d.ts +58 -0
- package/dist/src/user-model/goals.js +89 -0
- package/dist/src/user-model/importance.d.ts +11 -0
- package/dist/src/user-model/importance.js +17 -0
- package/dist/src/user-model/index.d.ts +5 -0
- package/dist/src/user-model/index.js +6 -0
- package/dist/src/user-model/repository.d.ts +23 -0
- package/dist/src/user-model/repository.js +268 -0
- package/dist/src/user-model/temporal.d.ts +10 -0
- package/dist/src/user-model/temporal.js +44 -0
- package/dist/src/voice/realtime/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 +1 -1
- 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/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-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/understanding/types.js +0 -1
- package/dist/src/agent/memory/user-context-coordinator.d.ts +0 -23
- package/dist/src/agent/memory/user-context-coordinator.js +0 -113
- package/dist/src/agent/tools/dreaming-tool.js +0 -37
- package/dist/src/agent/tools/memory-tool.d.ts +0 -9
- package/dist/src/agent/tools/memory-tool.js +0 -119
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -11
- package/dist/src/gateway/dreaming-automation-reconciler.js +0 -63
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +0 -21
- package/dist/src/gateway/hono/routes/understanding-sources.js +0 -387
- package/dist/src/gateway/hono/routes/you.d.ts +0 -3
- package/dist/src/gateway/hono/routes/you.js +0 -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 → knowledge-memory/domain.js} +0 -0
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import { createCollaborationRule, getCollaborationRule, listCollaborationRules, setCollaborationRuleStatus } from "../../../storage/sqlite/collaboration-rule-repository.js";
|
|
2
|
+
import { getKnowledgeItem, listKnowledgeItems, searchKnowledgeItems, setKnowledgeStatus } from "../../../knowledge-memory/repository.js";
|
|
3
|
+
import "../../../knowledge-memory/index.js";
|
|
4
|
+
import { createPriorityWindow, createUserGoal, listPriorityWindows, listUserGoals, setUserGoalStatus } from "../../../user-model/goals.js";
|
|
5
|
+
import { getActiveAssertionForSlot, getAssertionSlot, getUserAssertion, listUserAssertions, reconcileAssertion, setAssertionStatus } from "../../../user-model/repository.js";
|
|
6
|
+
import "../../../user-model/index.js";
|
|
7
|
+
import { listMemoryMaintenanceRuns } from "../../../memory-maintenance/service.js";
|
|
8
|
+
import "../../../memory-maintenance/index.js";
|
|
9
|
+
import { getExecutionContextAudit, recordExecutionContextFeedback } from "../../../agent/context/audit.js";
|
|
10
|
+
//#region src/gateway/hono/routes/user-model.ts
|
|
11
|
+
function object(value) {
|
|
12
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
13
|
+
}
|
|
14
|
+
async function body(c) {
|
|
15
|
+
try {
|
|
16
|
+
return object(await c.req.json());
|
|
17
|
+
} catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function scope(value) {
|
|
22
|
+
const input = object(value);
|
|
23
|
+
if (!input || ![
|
|
24
|
+
"global",
|
|
25
|
+
"agent",
|
|
26
|
+
"workspace",
|
|
27
|
+
"project",
|
|
28
|
+
"session"
|
|
29
|
+
].includes(String(input.type))) return void 0;
|
|
30
|
+
if (input.type === "global") return { type: "global" };
|
|
31
|
+
return typeof input.id === "string" && input.id.trim() ? {
|
|
32
|
+
type: input.type,
|
|
33
|
+
id: input.id.trim()
|
|
34
|
+
} : void 0;
|
|
35
|
+
}
|
|
36
|
+
function subject(value) {
|
|
37
|
+
const input = object(value);
|
|
38
|
+
if (!input || ![
|
|
39
|
+
"user",
|
|
40
|
+
"person",
|
|
41
|
+
"goal",
|
|
42
|
+
"project",
|
|
43
|
+
"topic"
|
|
44
|
+
].includes(String(input.type)) || typeof input.id !== "string" || !input.id.trim()) return void 0;
|
|
45
|
+
return {
|
|
46
|
+
type: input.type,
|
|
47
|
+
id: input.id.trim()
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function errorMessage(error) {
|
|
51
|
+
return error instanceof Error ? error.message : String(error);
|
|
52
|
+
}
|
|
53
|
+
const ASSERTION_STATUSES = new Set([
|
|
54
|
+
"candidate",
|
|
55
|
+
"active",
|
|
56
|
+
"needs_review",
|
|
57
|
+
"conflicted",
|
|
58
|
+
"stale",
|
|
59
|
+
"archived",
|
|
60
|
+
"rejected"
|
|
61
|
+
]);
|
|
62
|
+
const GOAL_STATUSES = new Set([
|
|
63
|
+
"proposed",
|
|
64
|
+
"active",
|
|
65
|
+
"paused",
|
|
66
|
+
"achieved",
|
|
67
|
+
"abandoned"
|
|
68
|
+
]);
|
|
69
|
+
const KNOWLEDGE_STATUSES = new Set([
|
|
70
|
+
"candidate",
|
|
71
|
+
"active",
|
|
72
|
+
"needs_review",
|
|
73
|
+
"stale",
|
|
74
|
+
"archived",
|
|
75
|
+
"rejected"
|
|
76
|
+
]);
|
|
77
|
+
const RULE_CATEGORIES = new Set([
|
|
78
|
+
"communication",
|
|
79
|
+
"execution",
|
|
80
|
+
"boundary",
|
|
81
|
+
"routine",
|
|
82
|
+
"proactive"
|
|
83
|
+
]);
|
|
84
|
+
const RULE_STATUSES = new Set([
|
|
85
|
+
"active",
|
|
86
|
+
"disabled",
|
|
87
|
+
"archived"
|
|
88
|
+
]);
|
|
89
|
+
function profileAssertion(predicate) {
|
|
90
|
+
return getActiveAssertionForSlot({
|
|
91
|
+
subject: {
|
|
92
|
+
type: "user",
|
|
93
|
+
id: "self"
|
|
94
|
+
},
|
|
95
|
+
predicate,
|
|
96
|
+
scope: { type: "global" }
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function profileValue(predicate) {
|
|
100
|
+
return profileAssertion(predicate)?.value;
|
|
101
|
+
}
|
|
102
|
+
function profileSnapshot() {
|
|
103
|
+
return {
|
|
104
|
+
callName: profileValue("identity.call_name"),
|
|
105
|
+
pronouns: profileValue("identity.pronouns"),
|
|
106
|
+
timezone: profileValue("preference.timezone"),
|
|
107
|
+
locale: profileValue("preference.locale"),
|
|
108
|
+
role: profileValue("identity.role")
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const PROFILE_FIELDS = {
|
|
112
|
+
callName: {
|
|
113
|
+
predicate: "identity.call_name",
|
|
114
|
+
kind: "identity",
|
|
115
|
+
volatility: "stable",
|
|
116
|
+
importance: .95,
|
|
117
|
+
statement: (value) => `The user prefers to be called ${value}.`
|
|
118
|
+
},
|
|
119
|
+
role: {
|
|
120
|
+
predicate: "identity.role",
|
|
121
|
+
kind: "identity",
|
|
122
|
+
volatility: "slow",
|
|
123
|
+
importance: .9,
|
|
124
|
+
statement: (value) => `The user's role is ${value}.`
|
|
125
|
+
},
|
|
126
|
+
pronouns: {
|
|
127
|
+
predicate: "identity.pronouns",
|
|
128
|
+
kind: "identity",
|
|
129
|
+
volatility: "stable",
|
|
130
|
+
importance: .75,
|
|
131
|
+
statement: (value) => `The user's pronouns are ${value}.`
|
|
132
|
+
},
|
|
133
|
+
timezone: {
|
|
134
|
+
predicate: "preference.timezone",
|
|
135
|
+
kind: "preference",
|
|
136
|
+
volatility: "slow",
|
|
137
|
+
importance: .85,
|
|
138
|
+
statement: (value) => `The user's timezone is ${value}.`
|
|
139
|
+
},
|
|
140
|
+
locale: {
|
|
141
|
+
predicate: "preference.locale",
|
|
142
|
+
kind: "preference",
|
|
143
|
+
volatility: "slow",
|
|
144
|
+
importance: .85,
|
|
145
|
+
statement: (value) => `The user's language and locale are ${value}.`
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function assertionView(assertion) {
|
|
149
|
+
const slot = getAssertionSlot(assertion.slotId);
|
|
150
|
+
if (!slot) throw new Error(`Assertion slot not found: ${assertion.slotId}`);
|
|
151
|
+
return {
|
|
152
|
+
...assertion,
|
|
153
|
+
predicate: slot.predicate,
|
|
154
|
+
subject: slot.subject,
|
|
155
|
+
scope: slot.scope
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function registerUserModelRoutes(authenticated, deps) {
|
|
159
|
+
const write = deps.strictRateLimitMiddleware;
|
|
160
|
+
authenticated.get("/api/user-model", (c) => {
|
|
161
|
+
const assertions = listUserAssertions({
|
|
162
|
+
statuses: [
|
|
163
|
+
"active",
|
|
164
|
+
"candidate",
|
|
165
|
+
"needs_review",
|
|
166
|
+
"conflicted",
|
|
167
|
+
"stale"
|
|
168
|
+
],
|
|
169
|
+
limit: 1e3
|
|
170
|
+
}).map(assertionView);
|
|
171
|
+
const goals = listUserGoals();
|
|
172
|
+
const priorities = listPriorityWindows();
|
|
173
|
+
const knowledge = listKnowledgeItems({
|
|
174
|
+
recordClass: "memory",
|
|
175
|
+
limit: 1e3
|
|
176
|
+
});
|
|
177
|
+
return c.json({
|
|
178
|
+
assertions,
|
|
179
|
+
goals,
|
|
180
|
+
priorities,
|
|
181
|
+
rules: listCollaborationRules(),
|
|
182
|
+
knowledge,
|
|
183
|
+
maintenance: { lastRun: listMemoryMaintenanceRuns(1)[0] ?? null },
|
|
184
|
+
profile: profileSnapshot(),
|
|
185
|
+
counts: {
|
|
186
|
+
activeAssertions: assertions.filter((item) => item.status === "active").length,
|
|
187
|
+
reviewAssertions: assertions.filter((item) => item.status === "needs_review" || item.status === "conflicted").length,
|
|
188
|
+
activeGoals: goals.filter((item) => item.status === "active").length,
|
|
189
|
+
activePriorities: priorities.filter((item) => item.status === "active").length,
|
|
190
|
+
activeKnowledge: knowledge.filter((item) => item.status === "active").length
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
authenticated.patch("/api/user-model/profile", write, async (c) => {
|
|
195
|
+
const input = await body(c);
|
|
196
|
+
if (!input) return c.json({ error: "A profile patch is required" }, 400);
|
|
197
|
+
const entries = Object.entries(PROFILE_FIELDS).filter(([key]) => Object.hasOwn(input, key));
|
|
198
|
+
if (!entries.length || entries.some(([key]) => typeof input[key] !== "string")) return c.json({ error: "Profile fields must be strings" }, 400);
|
|
199
|
+
try {
|
|
200
|
+
const now = Date.now();
|
|
201
|
+
for (const [key, field] of entries) {
|
|
202
|
+
const value = input[key].trim();
|
|
203
|
+
const current = profileAssertion(field.predicate);
|
|
204
|
+
if (!value) {
|
|
205
|
+
if (current) setAssertionStatus(current.id, "archived", {
|
|
206
|
+
actor: "user",
|
|
207
|
+
reason: "Profile field cleared by user.",
|
|
208
|
+
now
|
|
209
|
+
});
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
reconcileAssertion({
|
|
213
|
+
subject: {
|
|
214
|
+
type: "user",
|
|
215
|
+
id: "self"
|
|
216
|
+
},
|
|
217
|
+
predicate: field.predicate,
|
|
218
|
+
cardinality: "single",
|
|
219
|
+
scope: { type: "global" },
|
|
220
|
+
kind: field.kind,
|
|
221
|
+
value,
|
|
222
|
+
normalizedValue: value.toLocaleLowerCase(),
|
|
223
|
+
statement: field.statement(value),
|
|
224
|
+
authority: "user_explicit",
|
|
225
|
+
confidence: 1,
|
|
226
|
+
declaredImportance: field.importance,
|
|
227
|
+
inferredImportance: field.importance,
|
|
228
|
+
consequence: "medium",
|
|
229
|
+
actionability: .9,
|
|
230
|
+
volatility: field.volatility,
|
|
231
|
+
sensitivity: "normal",
|
|
232
|
+
disclosurePolicy: "referenceable",
|
|
233
|
+
observedAt: now,
|
|
234
|
+
createdBy: "user",
|
|
235
|
+
...current ? { correctionOfAssertionId: current.id } : {}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return c.json({ profile: profileSnapshot() });
|
|
239
|
+
} catch (error) {
|
|
240
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
authenticated.get("/api/user-model/assertions", (c) => {
|
|
244
|
+
const requested = c.req.query("status")?.split(",").filter(Boolean);
|
|
245
|
+
if (requested?.some((status) => !ASSERTION_STATUSES.has(status))) return c.json({ error: "Invalid assertion status" }, 400);
|
|
246
|
+
return c.json({ assertions: listUserAssertions({
|
|
247
|
+
...requested ? { statuses: requested } : {},
|
|
248
|
+
limit: 1e3
|
|
249
|
+
}).map(assertionView) });
|
|
250
|
+
});
|
|
251
|
+
authenticated.get("/api/user-model/assertions/:id", (c) => {
|
|
252
|
+
const assertion = getUserAssertion(c.req.param("id"));
|
|
253
|
+
return assertion ? c.json({ assertion: assertionView(assertion) }) : c.json({ error: "Assertion not found" }, 404);
|
|
254
|
+
});
|
|
255
|
+
authenticated.post("/api/user-model/assertions", write, async (c) => {
|
|
256
|
+
const input = await body(c);
|
|
257
|
+
const assertionScope = scope(input?.scope);
|
|
258
|
+
if (!input || !assertionScope || typeof input.statement !== "string" || typeof input.predicate !== "string" || typeof input.value === "undefined") return c.json({ error: "statement, predicate, value, and a valid scope are required" }, 400);
|
|
259
|
+
try {
|
|
260
|
+
const now = Date.now();
|
|
261
|
+
const assertionSubject = input.subject === void 0 ? {
|
|
262
|
+
type: "user",
|
|
263
|
+
id: "self"
|
|
264
|
+
} : subject(input.subject);
|
|
265
|
+
if (!assertionSubject) return c.json({ error: "Invalid assertion subject" }, 400);
|
|
266
|
+
const candidate = {
|
|
267
|
+
subject: assertionSubject,
|
|
268
|
+
predicate: input.predicate,
|
|
269
|
+
cardinality: input.cardinality === "multiple" ? "multiple" : "single",
|
|
270
|
+
scope: assertionScope,
|
|
271
|
+
kind: input.kind ?? "derived_insight",
|
|
272
|
+
value: input.value,
|
|
273
|
+
normalizedValue: typeof input.normalizedValue === "string" ? input.normalizedValue : JSON.stringify(input.value).toLocaleLowerCase(),
|
|
274
|
+
statement: input.statement,
|
|
275
|
+
authority: "user_explicit",
|
|
276
|
+
confidence: 1,
|
|
277
|
+
...typeof input.declaredImportance === "number" ? { declaredImportance: input.declaredImportance } : {},
|
|
278
|
+
inferredImportance: typeof input.inferredImportance === "number" ? input.inferredImportance : .7,
|
|
279
|
+
consequence: input.consequence ?? "medium",
|
|
280
|
+
actionability: typeof input.actionability === "number" ? input.actionability : .7,
|
|
281
|
+
volatility: input.volatility ?? "stable",
|
|
282
|
+
sensitivity: input.sensitivity ?? "normal",
|
|
283
|
+
disclosurePolicy: input.disclosurePolicy ?? "referenceable",
|
|
284
|
+
...object(input.applicability) ? { applicability: object(input.applicability) } : {},
|
|
285
|
+
...typeof input.validFrom === "number" ? { validFrom: input.validFrom } : {},
|
|
286
|
+
...typeof input.validTo === "number" ? { validTo: input.validTo } : {},
|
|
287
|
+
observedAt: typeof input.observedAt === "number" ? input.observedAt : now,
|
|
288
|
+
...typeof input.reviewAt === "number" ? { reviewAt: input.reviewAt } : {},
|
|
289
|
+
createdBy: "user",
|
|
290
|
+
...typeof input.correctionOfAssertionId === "string" ? { correctionOfAssertionId: input.correctionOfAssertionId } : {}
|
|
291
|
+
};
|
|
292
|
+
return c.json(reconcileAssertion(candidate), 201);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
authenticated.patch("/api/user-model/assertions/:id/status", write, async (c) => {
|
|
298
|
+
const input = await body(c);
|
|
299
|
+
const status = input?.status;
|
|
300
|
+
if (!ASSERTION_STATUSES.has(status)) return c.json({ error: "Invalid assertion status" }, 400);
|
|
301
|
+
try {
|
|
302
|
+
return c.json({ assertion: setAssertionStatus(c.req.param("id"), status, {
|
|
303
|
+
actor: "user",
|
|
304
|
+
reason: typeof input?.reason === "string" ? input.reason : "Status changed by user."
|
|
305
|
+
}) });
|
|
306
|
+
} catch (error) {
|
|
307
|
+
return c.json({ error: errorMessage(error) }, 404);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
authenticated.patch("/api/user-model/assertions/:id", write, async (c) => {
|
|
311
|
+
const current = getUserAssertion(c.req.param("id"));
|
|
312
|
+
const input = await body(c);
|
|
313
|
+
const statement = typeof input?.statement === "string" ? input.statement.trim() : "";
|
|
314
|
+
const slot = current ? getAssertionSlot(current.slotId) : void 0;
|
|
315
|
+
if (!current || !slot) return c.json({ error: "Assertion not found" }, 404);
|
|
316
|
+
if (!statement) return c.json({ error: "statement is required" }, 400);
|
|
317
|
+
try {
|
|
318
|
+
return c.json(reconcileAssertion({
|
|
319
|
+
subject: slot.subject,
|
|
320
|
+
predicate: slot.predicate,
|
|
321
|
+
cardinality: slot.cardinality,
|
|
322
|
+
scope: slot.scope,
|
|
323
|
+
kind: current.kind,
|
|
324
|
+
value: input?.value ?? statement,
|
|
325
|
+
normalizedValue: typeof input?.normalizedValue === "string" ? input.normalizedValue : String(input?.value ?? statement).trim().toLocaleLowerCase(),
|
|
326
|
+
statement,
|
|
327
|
+
authority: "user_explicit",
|
|
328
|
+
confidence: 1,
|
|
329
|
+
...current.declaredImportance === void 0 ? {} : { declaredImportance: current.declaredImportance },
|
|
330
|
+
inferredImportance: current.inferredImportance,
|
|
331
|
+
consequence: current.consequence,
|
|
332
|
+
actionability: current.actionability,
|
|
333
|
+
volatility: current.volatility,
|
|
334
|
+
sensitivity: current.sensitivity,
|
|
335
|
+
disclosurePolicy: current.disclosurePolicy,
|
|
336
|
+
applicability: current.applicability,
|
|
337
|
+
...current.validFrom === void 0 ? {} : { validFrom: current.validFrom },
|
|
338
|
+
...current.validTo === void 0 ? {} : { validTo: current.validTo },
|
|
339
|
+
observedAt: Date.now(),
|
|
340
|
+
...current.reviewAt === void 0 ? {} : { reviewAt: current.reviewAt },
|
|
341
|
+
createdBy: "user",
|
|
342
|
+
correctionOfAssertionId: current.id
|
|
343
|
+
}));
|
|
344
|
+
} catch (error) {
|
|
345
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
authenticated.get("/api/user-model/goals", (c) => c.json({ goals: listUserGoals() }));
|
|
349
|
+
authenticated.post("/api/user-model/goals", write, async (c) => {
|
|
350
|
+
const input = await body(c);
|
|
351
|
+
const goalScope = scope(input?.scope);
|
|
352
|
+
if (!input || !goalScope || typeof input.title !== "string" || typeof input.desiredOutcome !== "string") return c.json({ error: "title, desiredOutcome, and a valid scope are required" }, 400);
|
|
353
|
+
try {
|
|
354
|
+
return c.json({ goal: createUserGoal({
|
|
355
|
+
title: input.title,
|
|
356
|
+
desiredOutcome: input.desiredOutcome,
|
|
357
|
+
scope: goalScope,
|
|
358
|
+
...typeof input.declaredImportance === "number" ? { declaredImportance: input.declaredImportance } : {},
|
|
359
|
+
...typeof input.targetAt === "number" ? { targetAt: input.targetAt } : {}
|
|
360
|
+
}) }, 201);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
authenticated.patch("/api/user-model/goals/:id/status", write, async (c) => {
|
|
366
|
+
const status = (await body(c))?.status;
|
|
367
|
+
if (!GOAL_STATUSES.has(status)) return c.json({ error: "Invalid goal status" }, 400);
|
|
368
|
+
const goal = setUserGoalStatus(c.req.param("id"), status);
|
|
369
|
+
return goal ? c.json({ goal }) : c.json({ error: "Goal not found" }, 404);
|
|
370
|
+
});
|
|
371
|
+
authenticated.get("/api/user-model/rules", (c) => c.json({ rules: listCollaborationRules() }));
|
|
372
|
+
authenticated.post("/api/user-model/rules", write, async (c) => {
|
|
373
|
+
const input = await body(c);
|
|
374
|
+
const ruleScope = scope(input?.scope);
|
|
375
|
+
const category = input?.category;
|
|
376
|
+
if (!input || !ruleScope || !RULE_CATEGORIES.has(category) || typeof input.statement !== "string" || typeof input.priority !== "number") return c.json({ error: "category, statement, priority, and a valid scope are required" }, 400);
|
|
377
|
+
try {
|
|
378
|
+
return c.json({ rule: createCollaborationRule({
|
|
379
|
+
category,
|
|
380
|
+
statement: input.statement,
|
|
381
|
+
priority: input.priority,
|
|
382
|
+
scope: ruleScope,
|
|
383
|
+
conditions: object(input.conditions) ?? {}
|
|
384
|
+
}) }, 201);
|
|
385
|
+
} catch (error) {
|
|
386
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
authenticated.patch("/api/user-model/rules/:id/status", write, async (c) => {
|
|
390
|
+
const status = (await body(c))?.status;
|
|
391
|
+
if (!RULE_STATUSES.has(status)) return c.json({ error: "Invalid collaboration rule status" }, 400);
|
|
392
|
+
const rule = setCollaborationRuleStatus(c.req.param("id"), status);
|
|
393
|
+
return rule ? c.json({ rule }) : c.json({ error: "Collaboration rule not found" }, 404);
|
|
394
|
+
});
|
|
395
|
+
authenticated.get("/api/user-model/priorities", (c) => c.json({ priorities: listPriorityWindows() }));
|
|
396
|
+
authenticated.post("/api/user-model/priorities", write, async (c) => {
|
|
397
|
+
const input = await body(c);
|
|
398
|
+
const priorityScope = scope(input?.scope);
|
|
399
|
+
if (!input || !priorityScope || typeof input.targetId !== "string" || typeof input.validFrom !== "number" || typeof input.validTo !== "number" || typeof input.urgency !== "number") return c.json({ error: "targetId, urgency, validFrom, validTo, and a valid scope are required" }, 400);
|
|
400
|
+
try {
|
|
401
|
+
return c.json({ priority: createPriorityWindow({
|
|
402
|
+
targetType: input.targetType,
|
|
403
|
+
targetId: input.targetId,
|
|
404
|
+
rank: input.rank,
|
|
405
|
+
urgency: input.urgency,
|
|
406
|
+
scope: priorityScope,
|
|
407
|
+
validFrom: input.validFrom,
|
|
408
|
+
validTo: input.validTo,
|
|
409
|
+
...typeof input.reviewAt === "number" ? { reviewAt: input.reviewAt } : {},
|
|
410
|
+
...typeof input.declaredImportance === "number" ? { declaredImportance: input.declaredImportance } : {}
|
|
411
|
+
}) }, 201);
|
|
412
|
+
} catch (error) {
|
|
413
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
authenticated.get("/api/knowledge-memory", (c) => {
|
|
417
|
+
const query = c.req.query("q")?.trim();
|
|
418
|
+
if (!query) return c.json({ items: listKnowledgeItems({
|
|
419
|
+
recordClass: "memory",
|
|
420
|
+
limit: 500
|
|
421
|
+
}) });
|
|
422
|
+
return c.json({ items: searchKnowledgeItems({
|
|
423
|
+
query,
|
|
424
|
+
context: {
|
|
425
|
+
agentId: c.req.query("agentId") ?? "main",
|
|
426
|
+
workspaceId: c.req.query("workspaceId") ?? "",
|
|
427
|
+
sessionId: c.req.query("sessionId") ?? "",
|
|
428
|
+
...c.req.query("projectId") ? { projectId: c.req.query("projectId") } : {}
|
|
429
|
+
},
|
|
430
|
+
recordClass: "memory",
|
|
431
|
+
limit: 100
|
|
432
|
+
}) });
|
|
433
|
+
});
|
|
434
|
+
authenticated.get("/api/knowledge-memory/:id", (c) => {
|
|
435
|
+
const item = getKnowledgeItem(c.req.param("id"));
|
|
436
|
+
return item ? c.json({ item }) : c.json({ error: "Knowledge item not found" }, 404);
|
|
437
|
+
});
|
|
438
|
+
authenticated.patch("/api/knowledge-memory/:id/status", write, async (c) => {
|
|
439
|
+
const input = await body(c);
|
|
440
|
+
const status = String(input?.status ?? "");
|
|
441
|
+
if (!KNOWLEDGE_STATUSES.has(status)) return c.json({ error: "Invalid knowledge status" }, 400);
|
|
442
|
+
const item = setKnowledgeStatus(c.req.param("id"), status);
|
|
443
|
+
return item ? c.json({ item }) : c.json({ error: "Knowledge item not found" }, 404);
|
|
444
|
+
});
|
|
445
|
+
authenticated.get("/api/memory-maintenance/runs", (c) => c.json({ runs: listMemoryMaintenanceRuns(Math.max(1, Math.min(100, Number(c.req.query("limit") ?? 20)))) }));
|
|
446
|
+
authenticated.get("/api/turns/:turnId/execution-context", (c) => {
|
|
447
|
+
const audit = getExecutionContextAudit(c.req.param("turnId"));
|
|
448
|
+
if (!audit) return c.json({ error: "Execution context not found" }, 404);
|
|
449
|
+
const goals = new Map(listUserGoals().map((item) => [item.id, item]));
|
|
450
|
+
const priorities = new Map(listPriorityWindows().map((item) => [item.id, item]));
|
|
451
|
+
const resolvedItems = audit.items.flatMap((item) => {
|
|
452
|
+
const value = item.objectType === "assertion" ? getUserAssertion(item.objectId) : item.objectType === "knowledge" ? getKnowledgeItem(item.objectId) : item.objectType === "rule" ? getCollaborationRule(item.objectId) : item.objectType === "goal" ? goals.get(item.objectId) : priorities.get(item.objectId);
|
|
453
|
+
if (!value) return [];
|
|
454
|
+
const content = "statement" in value ? value.statement : "content" in value ? value.content : "desiredOutcome" in value ? `${value.title}: ${value.desiredOutcome}` : `${value.targetType}: ${value.targetId}`;
|
|
455
|
+
const origin = item.objectType === "assertion" && "authority" in value ? value.authority === "user_explicit" ? "told_by_user" : value.authority === "system_inferred" ? "inferred" : "observed" : item.objectType === "knowledge" && "originClass" in value && value.originClass === "untrusted" ? "connected_source" : "observed";
|
|
456
|
+
return [{
|
|
457
|
+
...item,
|
|
458
|
+
content,
|
|
459
|
+
origin,
|
|
460
|
+
sourceLabel: item.objectType
|
|
461
|
+
}];
|
|
462
|
+
});
|
|
463
|
+
return c.json({
|
|
464
|
+
audit,
|
|
465
|
+
resolvedItems
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
authenticated.post("/api/turns/:turnId/execution-context/feedback", write, async (c) => {
|
|
469
|
+
const input = await body(c);
|
|
470
|
+
const rating = input?.rating;
|
|
471
|
+
if (rating !== "helpful" && rating !== "irrelevant") return c.json({ error: "Invalid feedback rating" }, 400);
|
|
472
|
+
return recordExecutionContextFeedback({
|
|
473
|
+
turnId: c.req.param("turnId"),
|
|
474
|
+
rating,
|
|
475
|
+
...typeof input?.reason === "string" ? { reason: input.reason } : {}
|
|
476
|
+
}) ? c.json({ ok: true }) : c.json({ error: "Execution context not found" }, 404);
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
export { registerUserModelRoutes };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AutomationService } from '../automations/index.js';
|
|
2
|
+
import type { Config } from '../config/schema.js';
|
|
3
|
+
export interface MemoryMaintenanceAutomationReconcileResult {
|
|
4
|
+
created: number;
|
|
5
|
+
updated: number;
|
|
6
|
+
disabled: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function reconcileMemoryMaintenanceAutomations(input: {
|
|
9
|
+
config: Config;
|
|
10
|
+
automationService: AutomationService;
|
|
11
|
+
}): Promise<MemoryMaintenanceAutomationReconcileResult>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { init_agent_scope, normalizeAgentId, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
2
|
+
import { maintenanceInstruction, resolveMemoryMaintenanceSchedules } from "../memory-maintenance/schedule.js";
|
|
3
|
+
import "../memory-maintenance/index.js";
|
|
4
|
+
//#region src/gateway/memory-maintenance-automation-reconciler.ts
|
|
5
|
+
init_agent_scope();
|
|
6
|
+
const AUTOMATION_IDS = [
|
|
7
|
+
"system-memory-temporal-sweep",
|
|
8
|
+
"system-memory-daily-reconciliation",
|
|
9
|
+
"system-memory-weekly-knowledge"
|
|
10
|
+
];
|
|
11
|
+
async function reconcileMemoryMaintenanceAutomations(input) {
|
|
12
|
+
const result = {
|
|
13
|
+
created: 0,
|
|
14
|
+
updated: 0,
|
|
15
|
+
disabled: 0
|
|
16
|
+
};
|
|
17
|
+
const schedules = resolveMemoryMaintenanceSchedules(input.config);
|
|
18
|
+
const enabledIds = new Set(schedules.map((item) => item.automationId));
|
|
19
|
+
const agentId = normalizeAgentId(resolveDefaultAgentId(input.config));
|
|
20
|
+
const workingDirectory = resolveAgentWorkspaceDir(input.config, agentId);
|
|
21
|
+
for (const id of AUTOMATION_IDS) {
|
|
22
|
+
if (enabledIds.has(id)) continue;
|
|
23
|
+
if ((await input.automationService.get(id))?.enabled) {
|
|
24
|
+
await input.automationService.update(id, { enabled: false });
|
|
25
|
+
result.disabled += 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const schedule of schedules) {
|
|
29
|
+
const trigger = {
|
|
30
|
+
kind: "schedule",
|
|
31
|
+
schedule: {
|
|
32
|
+
kind: "cron",
|
|
33
|
+
expr: schedule.cron,
|
|
34
|
+
tz: schedule.timezone
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const action = {
|
|
38
|
+
kind: "agent",
|
|
39
|
+
agentId,
|
|
40
|
+
instruction: maintenanceInstruction(schedule.jobType),
|
|
41
|
+
workingDirectory,
|
|
42
|
+
timeoutSeconds: 300
|
|
43
|
+
};
|
|
44
|
+
const next = {
|
|
45
|
+
name: schedule.name,
|
|
46
|
+
description: `Run deterministic ${schedule.jobType} without model inference.`,
|
|
47
|
+
enabled: true,
|
|
48
|
+
trigger,
|
|
49
|
+
action,
|
|
50
|
+
safety: { mode: "auto_apply" },
|
|
51
|
+
conversationMode: "continuous",
|
|
52
|
+
notificationPolicy: "none",
|
|
53
|
+
reliability: { disableAfterConsecutiveFailures: 3 }
|
|
54
|
+
};
|
|
55
|
+
const current = await input.automationService.get(schedule.automationId);
|
|
56
|
+
if (!current) {
|
|
57
|
+
await input.automationService.create({
|
|
58
|
+
id: schedule.automationId,
|
|
59
|
+
...next
|
|
60
|
+
});
|
|
61
|
+
result.created += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (current.name !== next.name || current.description !== next.description || !current.enabled || JSON.stringify(current.trigger) !== JSON.stringify(trigger) || JSON.stringify(current.action) !== JSON.stringify(action) || current.safety?.mode !== "auto_apply" || current.notificationPolicy !== "none") {
|
|
65
|
+
await input.automationService.update(schedule.automationId, next);
|
|
66
|
+
result.updated += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { reconcileMemoryMaintenanceAutomations };
|
|
@@ -30,6 +30,7 @@ import type { UserTurnAttachment, UserTurnInput } from '../user-turn-input.js';
|
|
|
30
30
|
import type { AgentSourceContext, TurnContextRef } from '../../agent/source-context/types.js';
|
|
31
31
|
import { SessionInputCoordinator, type ReplaceLatestTurnInput, type SubmitSessionInput } from './session-input-coordinator.js';
|
|
32
32
|
export interface GatewayAgentRunnerOptions {
|
|
33
|
+
validateConnectionResume?: (input: import('../../storage/sqlite/session-input-repository.js').SessionInput) => Promise<boolean>;
|
|
33
34
|
bus: MessageBus;
|
|
34
35
|
sessionIndex: SessionIndex;
|
|
35
36
|
/** Resolved lazily — the runner is constructed before AgentService exists. */
|
|
@@ -52,7 +53,10 @@ export declare class GatewayAgentRunner {
|
|
|
52
53
|
/** Maps webchat session key → active `runId` for `clarify` tool routing. */
|
|
53
54
|
private readonly activeWebchatRunBySession;
|
|
54
55
|
private readonly externalStreamBySession;
|
|
56
|
+
private readonly externalClarificationTimeouts;
|
|
57
|
+
private readonly externalClarificationResponses;
|
|
55
58
|
readonly inputs: SessionInputCoordinator;
|
|
59
|
+
private readonly unsubscribeConnectionWait;
|
|
56
60
|
constructor(opts: GatewayAgentRunnerOptions);
|
|
57
61
|
/** True when a webchat agent run is currently in-flight for `sessionKey`. */
|
|
58
62
|
hasActiveRun(sessionKey: string): boolean;
|
|
@@ -64,12 +68,16 @@ export declare class GatewayAgentRunner {
|
|
|
64
68
|
getClarifyBridge(): ClarifyBridge;
|
|
65
69
|
/** Called from `GatewayService.stop()` so the bridge gets cleaned up. */
|
|
66
70
|
disposeClarifyBridge(): void;
|
|
67
|
-
registerExternalWebchatRun(sessionKey: string, runId: string, publish: (event: ClarifyStreamEvent) => void
|
|
71
|
+
registerExternalWebchatRun(sessionKey: string, runId: string, publish: (event: ClarifyStreamEvent) => void, options?: {
|
|
72
|
+
clarificationTimeoutMs?: number | null;
|
|
73
|
+
beforeClarificationResponse?: () => boolean;
|
|
74
|
+
}): void;
|
|
68
75
|
unregisterExternalWebchatRun(sessionKey: string, runId: string): void;
|
|
69
76
|
cancelClarificationForRun(runId: string): void;
|
|
70
77
|
runAgent(message: string, channel: string, chatId: string, origin: TurnOrigin, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
|
|
71
78
|
signal?: AbortSignal;
|
|
72
79
|
runId?: string;
|
|
80
|
+
taskRunId?: string;
|
|
73
81
|
sourceContexts?: AgentSourceContext[];
|
|
74
82
|
presentation?: 'voice';
|
|
75
83
|
}): AsyncGenerator<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { onConnectionWaitChanged } from "../../storage/sqlite/connection-wait-repository.js";
|
|
3
4
|
import { listActiveSessionInputRuns } from "../../storage/sqlite/session-input-repository.js";
|
|
4
5
|
import "../../storage/sqlite/index.js";
|
|
5
6
|
import { ClarifyBridge } from "../clarify-bridge.js";
|
|
@@ -21,14 +22,30 @@ var GatewayAgentRunner = class {
|
|
|
21
22
|
/** Maps webchat session key → active `runId` for `clarify` tool routing. */
|
|
22
23
|
activeWebchatRunBySession = /* @__PURE__ */ new Map();
|
|
23
24
|
externalStreamBySession = /* @__PURE__ */ new Map();
|
|
25
|
+
externalClarificationTimeouts = /* @__PURE__ */ new Map();
|
|
26
|
+
externalClarificationResponses = /* @__PURE__ */ new Map();
|
|
24
27
|
inputs;
|
|
28
|
+
unsubscribeConnectionWait;
|
|
25
29
|
constructor(opts) {
|
|
26
30
|
this.opts = opts;
|
|
31
|
+
this.unsubscribeConnectionWait = onConnectionWaitChanged((sessionKey) => {
|
|
32
|
+
const revision = this.inputs.snapshot(sessionKey).revision;
|
|
33
|
+
opts.emit("session.connection-wait.changed", {
|
|
34
|
+
sessionKey,
|
|
35
|
+
revision
|
|
36
|
+
});
|
|
37
|
+
opts.publishRealtime("sessions", "session.connection-wait.changed", {
|
|
38
|
+
sessionKey,
|
|
39
|
+
revision
|
|
40
|
+
});
|
|
41
|
+
});
|
|
27
42
|
this.inputs = new SessionInputCoordinator({
|
|
43
|
+
beforeExecute: opts.validateConnectionResume,
|
|
28
44
|
sessionExists: async (sessionKey) => Boolean(await opts.sessionIndex.getSessionMetadata(sessionKey)),
|
|
29
45
|
execute: async (input) => {
|
|
30
46
|
const generator = this.runAgent(input.content, "webchat", input.sessionKey, input.origin, input.attachments, input.thinking, {
|
|
31
47
|
runId: input.runId,
|
|
48
|
+
taskRunId: input.taskRunId,
|
|
32
49
|
sourceContexts: input.sourceContexts
|
|
33
50
|
});
|
|
34
51
|
let result;
|
|
@@ -93,15 +110,20 @@ var GatewayAgentRunner = class {
|
|
|
93
110
|
/** Called from `GatewayService.stop()` so the bridge gets cleaned up. */
|
|
94
111
|
disposeClarifyBridge() {
|
|
95
112
|
this.clarifyBridge.dispose();
|
|
113
|
+
this.unsubscribeConnectionWait();
|
|
96
114
|
}
|
|
97
|
-
registerExternalWebchatRun(sessionKey, runId, publish) {
|
|
115
|
+
registerExternalWebchatRun(sessionKey, runId, publish, options) {
|
|
98
116
|
this.activeWebchatRunBySession.set(sessionKey, runId);
|
|
99
117
|
this.externalStreamBySession.set(sessionKey, publish);
|
|
118
|
+
if (options?.clarificationTimeoutMs !== void 0) this.externalClarificationTimeouts.set(sessionKey, options.clarificationTimeoutMs);
|
|
119
|
+
if (options?.beforeClarificationResponse) this.externalClarificationResponses.set(sessionKey, options.beforeClarificationResponse);
|
|
100
120
|
}
|
|
101
121
|
unregisterExternalWebchatRun(sessionKey, runId) {
|
|
102
122
|
if (this.activeWebchatRunBySession.get(sessionKey) === runId) {
|
|
103
123
|
this.activeWebchatRunBySession.delete(sessionKey);
|
|
104
124
|
this.externalStreamBySession.delete(sessionKey);
|
|
125
|
+
this.externalClarificationTimeouts.delete(sessionKey);
|
|
126
|
+
this.externalClarificationResponses.delete(sessionKey);
|
|
105
127
|
}
|
|
106
128
|
}
|
|
107
129
|
cancelClarificationForRun(runId) {
|
|
@@ -238,6 +260,8 @@ var GatewayAgentRunner = class {
|
|
|
238
260
|
} : void 0;
|
|
239
261
|
if (!runId && !deliver) return Promise.reject(/* @__PURE__ */ new Error("Clarify is not available for this session (use webchat, Telegram, or CLI)"));
|
|
240
262
|
return this.clarifyBridge.startRequest({
|
|
263
|
+
timeoutMs: this.externalClarificationTimeouts.get(sessionKey),
|
|
264
|
+
beforeResponse: this.externalClarificationResponses.get(sessionKey),
|
|
241
265
|
sessionKey,
|
|
242
266
|
runId,
|
|
243
267
|
publishStream,
|
|
@@ -43,8 +43,8 @@ export interface GatewayConfigCoordinatorOptions {
|
|
|
43
43
|
getExtensionLoader: () => ExtensionLoader | null;
|
|
44
44
|
/** Re-evaluate browser-extension server attachment after agent defaults change. */
|
|
45
45
|
reconcileBrowserExtensionServer: () => Promise<void>;
|
|
46
|
-
/** Sync
|
|
47
|
-
|
|
46
|
+
/** Sync deterministic user-model maintenance automations after config changes. */
|
|
47
|
+
reconcileMemoryMaintenanceAutomations: () => Promise<void>;
|
|
48
48
|
/** Latest channel status snapshot for the `channels.status` event. */
|
|
49
49
|
getChannelsStatus: () => unknown;
|
|
50
50
|
/** Realtime emit used for `config.reload` and `channels.status`. */
|