@xopcai/xopc 0.0.249 → 0.0.251
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-B759R_qf.js → activity-store-DfBjTSo9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BUu7EnwM.js → agent-avatar-dicebear-Bo_dmLv8.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-kILWelNb.js +1 -0
- package/dist/gateway/static/root/assets/{agents-DK9HjHO0.js → agents-yuUn8n-f.js} +1 -1
- package/dist/gateway/static/root/assets/{api-Cg0v7Lpn.js → api-zxpcJfgj.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C9DkCW_d.js → app-management-settings-panel-Cz56nrVF.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CFggS95Y.js → appearance-settings-DxSws5U4.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BnizTdgs.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BQrilVVv.js → archive-plugin-7k15-hqo.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BG0BliqV.js → attachment-load-B-SFpjd9.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Bo4RiTkh.js → automations-page-Qy36j19q.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CZRKqSqY.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BCnyNU0C.js → binary-plugins-CPOZQt8F.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Db8DlVvg.js → block-editor-DhvVlIp9.js} +4 -4
- package/dist/gateway/static/root/assets/browser-settings-page-pN5LbChY.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-C71vfl0b.js → browser-workflow-inputs-BX1-uM9L.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-vvmSYKsO.js → browser-workflows-page-C65MI57t.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CJw2e16J.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-CRgjb4Ck.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CKyV3jY5.js → channels-status-swr-CX-yWwLD.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B1Xd6OFB.js → chat-terminal-dock-1PJoxRuV.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-Dcpdy06y.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-D-F9vjtE.js → cron-expression-CBCc6zFA.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B2OoYvic.js → date-picker-u8K5Kt_N.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BiGx9Sbj.js → dependency-picker-y_i_cnpz.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BNMRqipe.js → desktop-pet-DyL0JxLm.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DeYbIV7A.js → desktop-pet-settings-d2d_IsyP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-COyn05ub.js → extension-debug-page-DqIBKJwl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-oH43chS2.js → extension-page-DUW1xxj2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BMO59994.js → extension-settings-page-BHY9qaNw.js} +1 -1
- package/dist/gateway/static/root/assets/files-BArWTfr7.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-cimpViGk.js → gateway-config-api-e3BRcgDx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BGdHwT4e.js → gateway-config-swr-CMNbl0FZ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BHJtnSic.js → gateway-settings-Cheo0Rkc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CuaM3b4c.js → gateway-startup-retry-CR7Xg8As.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DNhrZHqx.js → heartbeat-settings-7CD9iPR7.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-DVrTRqNc.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D7duj7Uj.js → image-generation-api-C5mn73ca.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DGeGmj4k.css → index-B7CX4Qob.css} +1 -1
- package/dist/gateway/static/root/assets/index-BHrpyJ4t.js +72 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D8Zw_lYd.js → keyboard-shortcuts-settings-BtlqMleF.js} +1 -1
- package/dist/gateway/static/root/assets/languages-5WaOu0Lf.js +2 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-BjxfkjxE.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CvPDPRwb.js → local-apps-page-B7xqQe2s.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-zEL8bkwx.js → locale-store-CF4erhjB.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-kACaPZKL.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-D8moh99U.js → management-settings-A432siER.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-editor-BjMTIM-m.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DGRN-8wP.js → markdown-view-CQvzsE24.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BLaE5b1Y.js → media-plugins-CpvYiauZ.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DiVDuCxl.js → mobile-pairing-wizard-DyjVGngO.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CUd8O4K7.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BLQwd39W.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-BFMGjA60.js → page-tabs-B3FKzjR6.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DNEWZN7H.js → preview-open-alternatives-DnjrwAHD.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Co5u7asH.js → product-open-page-COcr_NUJ.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-NttW338u.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BzH8pjEz.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-Cg92zSod.js → registry-api-BsRBlji7.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BxpjSDnL.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-C0ByNmlV.js → runtime-tools-settings-panel-LO4wZ_dO.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dq_VQpuY.js → schema-form-crcj4-Pm.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BLMaibOb.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRvvKhoH.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CZu6FX4k.js → settings-form-section-Bl4MvTmq.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-S8ekeUZd.js → settings-page-DplrjZ6x.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BdVmwXMv.js → setup-status-panel-DTOsxQC1.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D2fEidbn.js → share-preview-page-CJP1kURj.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CemgzEi4.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BWYanBlQ.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-AYiPlgZE.js → skills-page-DsjcKg9Q.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DGzl-ib-.js → skills-page.utils-D6gWBbvy.js} +1 -1
- package/dist/gateway/static/root/assets/source-workspace-editor-CVWzt0oT.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-5Xd5mIiR.js → system-settings-panel-_eCXfqCo.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BQAUaCDD.js → task-detail-page-D0Z_K5JT.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-ZVClZKQ0.js → theme-store-BOgkc_9D.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CdZN1Jin.js → tunnel-api-W5mktxl1.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-czRI0NBc.js → use-autosave-Na2DYzT3.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-B_-SNat-.js +2 -0
- package/dist/gateway/static/root/assets/{vendor-codemirror--gTq3YAI.js → vendor-codemirror-Qdcjid65.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-8YEvA3cU.js → voice-api-key-field-OXweUxS_.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CopF64lY.js → voice-config-api-C-ryeIxj.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-keLtqYYJ.js → work-discovery-overlay-BqOsO47I.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dy5WgYMO.js → workflow-run-setup-panel-B9S_lfT1.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CNOT2Coo.js +5 -0
- package/dist/gateway/static/root/index.html +11 -11
- 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 +1 -1
- package/dist/src/agent/agent-manager.d.ts +9 -9
- package/dist/src/agent/agent-manager.js +50 -32
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +11 -2
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/context/audit.d.ts +3 -1
- package/dist/src/agent/context/audit.js +32 -6
- package/dist/src/agent/context/coordinator.d.ts +6 -1
- package/dist/src/agent/context/coordinator.js +14 -13
- package/dist/src/agent/context/execution-context.d.ts +6 -47
- package/dist/src/agent/context/execution-context.js +79 -15
- package/dist/src/agent/context/execution-context.types.d.ts +50 -0
- package/dist/src/agent/context/execution-context.types.js +1 -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/project-context.d.ts +3 -0
- package/dist/src/agent/context/project-context.js +5 -3
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/external-tools/index.d.ts +1 -0
- package/dist/src/agent/external-tools/index.js +1 -0
- 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/image/tool-model-config.js +1 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +5 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -0
- package/dist/src/agent/memory/compaction-promotion.js +7 -2
- package/dist/src/agent/memory/index.d.ts +1 -1
- package/dist/src/agent/memory/index.js +3 -3
- package/dist/src/agent/memory/memory-config.d.ts +0 -5
- package/dist/src/agent/memory/memory-config.js +1 -8
- package/dist/src/agent/orchestration/context-overflow.js +1 -0
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +3 -4
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +37 -7
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +6 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +81 -26
- 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 +2 -0
- package/dist/src/agent/tools/user-context-tool.js +21 -4
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/automations/service/automation-service.d.ts +2 -1
- package/dist/src/automations/service/automation-service.js +6 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +1 -0
- package/dist/src/connectors/connection-recovery-service.js +46 -22
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/files/file-service.js +142 -14
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +17 -3
- package/dist/src/gateway/hono/routes/files.js +23 -2
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +1 -1
- package/dist/src/gateway/service.js +12 -8
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/knowledge-memory/domain.d.ts +1 -0
- package/dist/src/knowledge-memory/index.js +2 -2
- package/dist/src/knowledge-memory/repository.d.ts +4 -1
- package/dist/src/knowledge-memory/repository.js +16 -2
- 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 +6 -8
- package/dist/src/proactive/execution/context.js +78 -32
- 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 +1 -0
- package/dist/src/proactive/index.js +2 -1
- 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/project-service.d.ts +2 -1
- package/dist/src/projects/project-service.js +3 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +5 -2
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +3 -1
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +1 -1
- package/dist/src/storage/sqlite/config-repository.js +1 -1
- package/dist/src/storage/sqlite/connection-wait-repository.js +2 -2
- package/dist/src/storage/sqlite/index.js +2 -2
- 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/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.js +1 -1
- 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 +3 -5
- package/dist/src/storage/sqlite/transcript-repository.js +2 -1
- package/dist/src/tasks/home-query-service.js +35 -13
- package/dist/src/tasks/project-monitoring-service.d.ts +2 -0
- package/dist/src/tasks/project-monitoring-service.js +4 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.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-model/capture/executor.d.ts +10 -0
- package/dist/src/user-model/capture/executor.js +99 -3
- package/dist/src/user-model/capture/semantic.d.ts +18 -0
- package/dist/src/user-model/capture/semantic.js +72 -6
- package/dist/src/user-model/goals.d.ts +4 -0
- package/dist/src/user-model/goals.js +4 -2
- package/dist/src/voice/realtime/agentEngine.js +0 -1
- package/dist/src/work-discovery/service.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C1rXNUAG.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-jOvT-fzU.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BKjKTlW8.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-Dzq18pO1.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DW4SBQf4.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-57OGuewD.js +0 -1
- package/dist/gateway/static/root/assets/code-editor-D4_k-6QN.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CT_I3kbR.js +0 -2
- package/dist/gateway/static/root/assets/files-D6vf3S30.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BiHwiBnQ.js +0 -1
- package/dist/gateway/static/root/assets/html-workspace-editor-C3DKAkMc.js +0 -1
- package/dist/gateway/static/root/assets/index-aBs0EfQB.js +0 -72
- package/dist/gateway/static/root/assets/local-app-workbench-page-eBFVWmtH.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-ClvcWlL6.js +0 -2
- package/dist/gateway/static/root/assets/markdown-editor-nDLmA_LF.js +0 -2
- package/dist/gateway/static/root/assets/markdown-split-D7V3j0vE.js +0 -1
- package/dist/gateway/static/root/assets/messages-W5P19VTF.js +0 -11
- package/dist/gateway/static/root/assets/note-detail-panel-CEEvR-fV.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BLqgXNCx.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-CIiFJ5tk.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B3UF-Pfm.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUtpkJPG.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-UgJmG-V4.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDCzpdkl.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BdsqnCYj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-ghzAQKna.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-W3GTm6nA.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-BbAV3h7n.js +0 -5
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths-state.js";
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
|
+
import { isXopcDatabaseOpen } from "../storage/sqlite/connection.js";
|
|
5
|
+
import { getInteractionState } from "../storage/sqlite/interaction-state-repository.js";
|
|
4
6
|
import { getSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
5
|
-
import { getSessionConfig } from "../storage/sqlite/config-repository.js";
|
|
6
7
|
import "../storage/sqlite/index.js";
|
|
7
8
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
8
|
-
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
9
9
|
import { expandWorkspacePathString, init_workspace_path } from "../config/workspace-path.js";
|
|
10
10
|
import { init_agent_scope, resolveAgentProfileDir } from "./agent-scope.js";
|
|
11
|
-
import { init_session_key, parseSessionKey } from "../routing/session-key.js";
|
|
12
|
-
import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
13
11
|
import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
|
|
14
|
-
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../auth/sync-provider-auth.js";
|
|
15
12
|
import { CredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
13
|
+
import { init_session_key, parseSessionKey } from "../routing/session-key.js";
|
|
14
|
+
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../auth/sync-provider-auth.js";
|
|
16
15
|
import { getApiKeySync, getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
17
16
|
import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
|
|
17
|
+
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
18
|
+
import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
18
19
|
import { extractTextContent } from "./context/workspace.js";
|
|
19
20
|
import { buildExecutionScopeContextForPrompt } from "./context/execution-scope.js";
|
|
20
21
|
import { clearBootstrapSnapshot } from "./bootstrap/bootstrap-cache.js";
|
|
@@ -30,6 +31,7 @@ import { loadSkillsLock } from "./skills/hub-lock.js";
|
|
|
30
31
|
import { isUnderManagedSkillsDir } from "./skills/managed-store.js";
|
|
31
32
|
import { evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner } from "./embedded/session-runner.js";
|
|
32
33
|
import { createAgentTurnPolicy } from "./orchestration/agent-turn-policy.js";
|
|
34
|
+
import { resolveUserContextSessionAccess } from "../user-context/access-policy.js";
|
|
33
35
|
import { createAgentCapabilitySessionState, resolveAgentCapabilityCatalog } from "./capabilities/registry.js";
|
|
34
36
|
import "./capabilities/index.js";
|
|
35
37
|
import { sortToolsForPromptCache } from "./tools/cache-stability.js";
|
|
@@ -133,7 +135,7 @@ var AgentManager = class {
|
|
|
133
135
|
});
|
|
134
136
|
this.executionContext = new ExecutionContextCoordinator({
|
|
135
137
|
getConfig: () => this.config.config,
|
|
136
|
-
|
|
138
|
+
getAccessForSession: (sessionKey) => resolveUserContextSessionAccess(this.config.config, sessionKey),
|
|
137
139
|
getWorkspaceIdForSession: (sk) => this.getResolvedWorkspaceForSession(sk),
|
|
138
140
|
getProjectIdForSession: (sk) => getSessionMetadata(sk)?.projectId
|
|
139
141
|
});
|
|
@@ -150,8 +152,7 @@ var AgentManager = class {
|
|
|
150
152
|
});
|
|
151
153
|
}
|
|
152
154
|
isUserContextEnabledForSession(sessionKey) {
|
|
153
|
-
|
|
154
|
-
return Boolean(this.config.config?.userContext.enabled && this.config.config.userContext.userModel.enabled && (mode === void 0 || mode === "enabled"));
|
|
155
|
+
return resolveUserContextSessionAccess(this.config.config, sessionKey).userModel;
|
|
155
156
|
}
|
|
156
157
|
computeBaseWorkspacePath() {
|
|
157
158
|
const cfg = this.config.config;
|
|
@@ -290,10 +291,7 @@ var AgentManager = class {
|
|
|
290
291
|
prepareUserTurnContext(userMessage, sessionKey, turnId) {
|
|
291
292
|
return this.executionContext.prepare(userMessage, sessionKey, turnId);
|
|
292
293
|
}
|
|
293
|
-
/**
|
|
294
|
-
* After a completed turn: sync external providers and queue next-turn prefetch.
|
|
295
|
-
* Delegates to {@link UserContextCoordinator}.
|
|
296
|
-
*/
|
|
294
|
+
/** Capture durable structured user context after a completed turn. */
|
|
297
295
|
async afterAgentTurn(sessionKey, userPlainText, turnId) {
|
|
298
296
|
if (!this.isUserContextEnabledForSession(sessionKey)) return void 0;
|
|
299
297
|
const parsed = parseSessionKey(sessionKey);
|
|
@@ -317,10 +315,7 @@ var AgentManager = class {
|
|
|
317
315
|
if (!this.agents.get(sessionKey) || !this.isUserContextEnabledForSession(sessionKey)) return;
|
|
318
316
|
this.backgroundReview.beginUserTurn(sessionKey);
|
|
319
317
|
}
|
|
320
|
-
/**
|
|
321
|
-
* After a successful main turn (after memory sync via `afterAgentTurn`), may run a quiet follow-up for memory/skills.
|
|
322
|
-
* Delegates to {@link BackgroundReviewCoordinator}.
|
|
323
|
-
*/
|
|
318
|
+
/** After a successful main turn, may run a quiet follow-up for context review and skills. */
|
|
324
319
|
scheduleBackgroundReviewAfterUserTurn(sessionKey) {
|
|
325
320
|
const inst = this.agents.get(sessionKey);
|
|
326
321
|
if (!inst || !this.isUserContextEnabledForSession(sessionKey)) return;
|
|
@@ -404,7 +399,7 @@ var AgentManager = class {
|
|
|
404
399
|
const modelRef = instance.effectiveProfile.primaryModelRef?.trim() || this.defaultModel;
|
|
405
400
|
const thinkingLevel = instance.agent.state.thinkingLevel ?? this.config.thinkingLevel ?? "medium";
|
|
406
401
|
return rt.systemPromptBuilder.build(contextFiles, {
|
|
407
|
-
externalMemoryInstructions:
|
|
402
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(instance.sessionKey, rt),
|
|
408
403
|
workspaceOverride: resolvedWorkspacePath,
|
|
409
404
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
410
405
|
customInstructions: instance.effectiveProfile.customInstructions,
|
|
@@ -610,9 +605,9 @@ var AgentManager = class {
|
|
|
610
605
|
const resolvedWorkspacePath = this.getResolvedWorkspaceForSession(instance.sessionKey);
|
|
611
606
|
const rt = this.workspaceRuntimes.getOrCreate(resolvedWorkspacePath, instance.effectiveProfile.agentId);
|
|
612
607
|
const contextFiles = this.resolveContextFilesForSession(instance.sessionKey, instance.effectiveProfile);
|
|
613
|
-
instance.activeProjectContext =
|
|
608
|
+
instance.activeProjectContext = this.buildExecutionScopeContext(instance.sessionKey);
|
|
614
609
|
const newPrompt = rt.systemPromptBuilder.build(contextFiles, {
|
|
615
|
-
externalMemoryInstructions:
|
|
610
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(instance.sessionKey, rt),
|
|
616
611
|
workspaceOverride: resolvedWorkspacePath,
|
|
617
612
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
618
613
|
customInstructions: instance.effectiveProfile.customInstructions,
|
|
@@ -685,9 +680,9 @@ var AgentManager = class {
|
|
|
685
680
|
const resolvedWorkspacePath = this.getResolvedWorkspaceForSession(instance.sessionKey);
|
|
686
681
|
const rt = this.workspaceRuntimes.getOrCreate(resolvedWorkspacePath, instance.effectiveProfile.agentId);
|
|
687
682
|
const contextFiles = this.resolveContextFilesForSession(instance.sessionKey, instance.effectiveProfile);
|
|
688
|
-
instance.activeProjectContext =
|
|
683
|
+
instance.activeProjectContext = this.buildExecutionScopeContext(instance.sessionKey);
|
|
689
684
|
const newPrompt = rt.systemPromptBuilder.rebuild(contextFiles, {
|
|
690
|
-
externalMemoryInstructions:
|
|
685
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(instance.sessionKey, rt),
|
|
691
686
|
workspaceOverride: resolvedWorkspacePath,
|
|
692
687
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
693
688
|
customInstructions: instance.effectiveProfile.customInstructions,
|
|
@@ -712,7 +707,7 @@ var AgentManager = class {
|
|
|
712
707
|
const existing = this.agents.get(sessionKey);
|
|
713
708
|
if (existing) if (existing.resolvedWorkspacePath !== targetPath) this.removeAgent(sessionKey);
|
|
714
709
|
else {
|
|
715
|
-
this.
|
|
710
|
+
this.refreshDynamicContextIfChanged(existing);
|
|
716
711
|
existing.lastUsedAt = Date.now();
|
|
717
712
|
log.debug({ sessionKey }, "Reusing existing agent instance");
|
|
718
713
|
return existing.agent;
|
|
@@ -728,7 +723,7 @@ var AgentManager = class {
|
|
|
728
723
|
err,
|
|
729
724
|
sessionKey
|
|
730
725
|
}, "memory initializeAll failed"));
|
|
731
|
-
const activeProjectContext =
|
|
726
|
+
const activeProjectContext = this.buildExecutionScopeContext(sessionKey);
|
|
732
727
|
const profileModelRef = profile.primaryModelRef?.trim() || this.defaultModel;
|
|
733
728
|
const modelManager = this.config.getModelManager?.();
|
|
734
729
|
const initialModelRef = modelManager?.resolveInitialModelForSession(sessionKey, profileModelRef, profile.fallbacks) ?? profileModelRef;
|
|
@@ -750,6 +745,8 @@ var AgentManager = class {
|
|
|
750
745
|
registeredToolNames,
|
|
751
746
|
activeCapabilities: /* @__PURE__ */ new Map(),
|
|
752
747
|
activeProjectContext,
|
|
748
|
+
interactionStateVersion: this.getInteractionStateVersion(sessionKey),
|
|
749
|
+
userContextAccessVersion: this.getUserContextAccessVersion(sessionKey),
|
|
753
750
|
skillEnvPassthroughKeys: /* @__PURE__ */ new Set()
|
|
754
751
|
});
|
|
755
752
|
log.debug({
|
|
@@ -827,9 +824,9 @@ var AgentManager = class {
|
|
|
827
824
|
const contextFiles = this.resolveContextFilesForSession(sessionKey, instance.effectiveProfile);
|
|
828
825
|
const modelRef = instance.effectiveProfile.primaryModelRef?.trim() || this.defaultModel;
|
|
829
826
|
const thinkingLevel = this.config.thinkingLevel ?? "medium";
|
|
830
|
-
const activeProjectContext =
|
|
827
|
+
const activeProjectContext = this.buildExecutionScopeContext(sessionKey);
|
|
831
828
|
instance.agent.state.systemPrompt = rt.systemPromptBuilder.build(contextFiles, {
|
|
832
|
-
externalMemoryInstructions:
|
|
829
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(sessionKey, rt),
|
|
833
830
|
workspaceOverride: resolvedWorkspacePath,
|
|
834
831
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
835
832
|
customInstructions: instance.effectiveProfile.customInstructions,
|
|
@@ -905,6 +902,22 @@ var AgentManager = class {
|
|
|
905
902
|
composeDynamicProjectContext(...sections) {
|
|
906
903
|
return sections.map((section) => section?.trim()).filter((section) => Boolean(section)).join("\n\n") || void 0;
|
|
907
904
|
}
|
|
905
|
+
buildExecutionScopeContext(sessionKey) {
|
|
906
|
+
const access = resolveUserContextSessionAccess(this.config.config, sessionKey);
|
|
907
|
+
return buildExecutionScopeContextForPrompt(sessionKey, {
|
|
908
|
+
includeKnowledge: access.knowledge,
|
|
909
|
+
knowledgeSources: access.knowledgeSources
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
getInteractionStateVersion(sessionKey) {
|
|
913
|
+
return isXopcDatabaseOpen() ? getInteractionState(sessionKey)?.updatedAt : void 0;
|
|
914
|
+
}
|
|
915
|
+
getUserContextAccessVersion(sessionKey) {
|
|
916
|
+
return JSON.stringify(resolveUserContextSessionAccess(this.config.config, sessionKey));
|
|
917
|
+
}
|
|
918
|
+
buildExternalMemoryInstructions(sessionKey, rt) {
|
|
919
|
+
return resolveUserContextSessionAccess(this.config.config, sessionKey).knowledge ? rt.memoryManager.buildExternalSystemPrompt() : "";
|
|
920
|
+
}
|
|
908
921
|
getCapabilityCatalogForSession(sessionKey) {
|
|
909
922
|
const inst = sessionKey?.trim() ? this.agents.get(sessionKey.trim()) : void 0;
|
|
910
923
|
return this.resolveCapabilityCatalogForInstance(inst);
|
|
@@ -917,6 +930,7 @@ var AgentManager = class {
|
|
|
917
930
|
workspace: resolvedWorkspacePath,
|
|
918
931
|
profileMarkdownRoot: resolveAgentProfileDir(this.config.config, profile.agentId),
|
|
919
932
|
agentId: profile.agentId,
|
|
933
|
+
sessionKey,
|
|
920
934
|
disabledTools: profile.tools.denied,
|
|
921
935
|
getPrimaryModel: () => agent?.state.model ?? model,
|
|
922
936
|
getMemoryManager: () => rt.memoryManager,
|
|
@@ -928,7 +942,7 @@ var AgentManager = class {
|
|
|
928
942
|
agent = new Agent({
|
|
929
943
|
initialState: {
|
|
930
944
|
systemPrompt: rt.systemPromptBuilder.build(contextFiles, {
|
|
931
|
-
externalMemoryInstructions:
|
|
945
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(sessionKey, rt),
|
|
932
946
|
workspaceOverride: resolvedWorkspacePath,
|
|
933
947
|
profileMarkdownPathRoot: resolveAgentProfileDir(this.config.config, profile.agentId),
|
|
934
948
|
customInstructions: profile.customInstructions,
|
|
@@ -1060,9 +1074,11 @@ var AgentManager = class {
|
|
|
1060
1074
|
default: "Deny"
|
|
1061
1075
|
}).catch(() => "Deny") === "Allow once";
|
|
1062
1076
|
}
|
|
1063
|
-
|
|
1064
|
-
const nextProjectContext =
|
|
1065
|
-
|
|
1077
|
+
refreshDynamicContextIfChanged(instance) {
|
|
1078
|
+
const nextProjectContext = this.buildExecutionScopeContext(instance.sessionKey);
|
|
1079
|
+
const interactionStateVersion = this.getInteractionStateVersion(instance.sessionKey);
|
|
1080
|
+
const userContextAccessVersion = this.getUserContextAccessVersion(instance.sessionKey);
|
|
1081
|
+
if (nextProjectContext === instance.activeProjectContext && interactionStateVersion === instance.interactionStateVersion && userContextAccessVersion === instance.userContextAccessVersion) return;
|
|
1066
1082
|
const cfg = this.config.config;
|
|
1067
1083
|
const resolvedWorkspacePath = this.getResolvedWorkspaceForSession(instance.sessionKey);
|
|
1068
1084
|
const rt = this.workspaceRuntimes.getOrCreate(resolvedWorkspacePath, instance.effectiveProfile.agentId);
|
|
@@ -1070,7 +1086,7 @@ var AgentManager = class {
|
|
|
1070
1086
|
const modelRef = instance.effectiveProfile.primaryModelRef?.trim() || this.defaultModel;
|
|
1071
1087
|
const thinkingLevel = instance.agent.state.thinkingLevel ?? this.config.thinkingLevel ?? "medium";
|
|
1072
1088
|
instance.agent.state.systemPrompt = rt.systemPromptBuilder.build(contextFiles, {
|
|
1073
|
-
externalMemoryInstructions:
|
|
1089
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(instance.sessionKey, rt),
|
|
1074
1090
|
workspaceOverride: resolvedWorkspacePath,
|
|
1075
1091
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
1076
1092
|
customInstructions: instance.effectiveProfile.customInstructions,
|
|
@@ -1083,6 +1099,8 @@ var AgentManager = class {
|
|
|
1083
1099
|
activeProjectContext: nextProjectContext
|
|
1084
1100
|
});
|
|
1085
1101
|
instance.activeProjectContext = nextProjectContext;
|
|
1102
|
+
instance.interactionStateVersion = interactionStateVersion;
|
|
1103
|
+
instance.userContextAccessVersion = userContextAccessVersion;
|
|
1086
1104
|
log.debug({ sessionKey: instance.sessionKey }, "Dynamic agent context changed; system prompt refreshed");
|
|
1087
1105
|
}
|
|
1088
1106
|
/**
|
|
@@ -1106,9 +1124,9 @@ var AgentManager = class {
|
|
|
1106
1124
|
const rt = this.workspaceRuntimes.getOrCreate(resolvedWorkspacePath, instance.effectiveProfile.agentId);
|
|
1107
1125
|
const contextFiles = this.resolveContextFilesForSession(sessionKey, instance.effectiveProfile);
|
|
1108
1126
|
const thinkingLevel = instance.agent.state.thinkingLevel ?? this.config.thinkingLevel ?? "medium";
|
|
1109
|
-
const activeProjectContext =
|
|
1127
|
+
const activeProjectContext = this.buildExecutionScopeContext(sessionKey);
|
|
1110
1128
|
instance.agent.state.systemPrompt = rt.systemPromptBuilder.build(contextFiles, {
|
|
1111
|
-
externalMemoryInstructions:
|
|
1129
|
+
externalMemoryInstructions: this.buildExternalMemoryInstructions(sessionKey, rt),
|
|
1112
1130
|
workspaceOverride: resolvedWorkspacePath,
|
|
1113
1131
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
1114
1132
|
customInstructions: instance.effectiveProfile.customInstructions,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const USER_MODEL_INTERPRETER_SYSTEM_PROMPT = "You are xopc's user-model interpreter. You do not chat with the user and cannot write storage. Distinguish explicit memory commands, corrections, forgetting, durable user assertions, and ordinary task requests. Return strict JSON only. Assistant text is never evidence about the user.";
|
|
1
|
+
export declare const USER_MODEL_INTERPRETER_SYSTEM_PROMPT = "You are xopc's user-model interpreter. You do not chat with the user and cannot write storage. Distinguish explicit memory commands, corrections, forgetting, durable user assertions, durable goals, collaboration rules, and ordinary task requests. Return strict JSON only. Assistant text is never evidence about the user.";
|
|
2
2
|
export declare function buildUserModelInterpreterPrompt(options: {
|
|
3
3
|
mode: 'turn' | 'transcript';
|
|
4
4
|
evidenceTimestamp: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/agent/background-review/prompts.ts
|
|
2
|
-
const USER_MODEL_INTERPRETER_SYSTEM_PROMPT = `You are xopc's user-model interpreter. You do not chat with the user and cannot write storage. Distinguish explicit memory commands, corrections, forgetting, durable user assertions, and ordinary task requests. Return strict JSON only. Assistant text is never evidence about the user.`;
|
|
2
|
+
const USER_MODEL_INTERPRETER_SYSTEM_PROMPT = `You are xopc's user-model interpreter. You do not chat with the user and cannot write storage. Distinguish explicit memory commands, corrections, forgetting, durable user assertions, durable goals, collaboration rules, and ordinary task requests. Return strict JSON only. Assistant text is never evidence about the user.`;
|
|
3
3
|
function buildUserModelInterpreterPrompt(options) {
|
|
4
4
|
const targets = options.availableTargets?.length ? `\nThese assertion IDs may be targeted for confirm, correction, or forgetting:\n${options.availableTargets.map((item) => `- ${item.id}: ${item.statement}`).join("\n")}` : "\nNo existing assertion IDs are available to target.";
|
|
5
5
|
return `Interpret the evidence-tagged conversation above for ${options.mode === "turn" ? "the latest user turn" : "durable transcript synthesis"}.
|
|
@@ -8,11 +8,17 @@ Evidence time: ${options.evidenceTimestamp}
|
|
|
8
8
|
User timezone: ${options.timezone}
|
|
9
9
|
|
|
10
10
|
Return exactly this top-level shape:
|
|
11
|
-
{"intent":"none","candidates":[],"targetAssertionIds":[],"abstentionReason":"..."}
|
|
11
|
+
{"intent":"none","candidates":[],"goals":[],"collaborationRules":[],"targetAssertionIds":[],"abstentionReason":"..."}
|
|
12
12
|
|
|
13
13
|
Candidate shape:
|
|
14
14
|
{"subject":{"type":"user","id":"self"},"predicate":"preference.response.detail","cardinality":"single","scope":{"type":"global"},"kind":"preference","value":"concise","normalizedValue":"concise","statement":"The user prefers concise answers.","authority":"user_observed","confidence":0.9,"declaredImportance":0.8,"inferredImportance":0.6,"consequence":"medium","actionability":1,"volatility":"stable","sensitivity":"normal","disclosurePolicy":"referenceable","applicability":{"operation":"response"},"temporalResolution":"exact","evidence":[{"ref":"entry-id","quote":"exact quote"}],"selfContained":true,"unresolvedReferences":[]}
|
|
15
15
|
|
|
16
|
+
Goal shape:
|
|
17
|
+
{"title":"Ship Atlas","desiredOutcome":"Atlas is released with all acceptance checks passing.","scope":{"type":"project","id":"exact-project-id"},"declaredImportance":0.9,"targetAt":"2026-09-30T18:00:00+08:00","evidence":[{"ref":"entry-id","quote":"exact quote"}],"selfContained":true,"unresolvedReferences":[]}
|
|
18
|
+
|
|
19
|
+
Collaboration rule shape:
|
|
20
|
+
{"category":"communication","priority":10,"scope":{"type":"global"},"conditions":{"enforcementLevel":"prompt"},"statement":"Keep status updates concise.","evidence":[{"ref":"entry-id","quote":"exact quote"}],"selfContained":true,"unresolvedReferences":[]}
|
|
21
|
+
|
|
16
22
|
Allowed intents: remember, query, confirm, correct, forget, user_assertion, task, none.
|
|
17
23
|
Allowed subject types: user, person, goal, project, topic.
|
|
18
24
|
Allowed kinds: identity, preference, value, routine, capability, relationship, current_state, derived_insight.
|
|
@@ -23,6 +29,9 @@ Rules:
|
|
|
23
29
|
- A request to create, summarize, update, investigate, or track work uses task, not a user assertion.
|
|
24
30
|
- Every candidate needs an exact quote from a user message. Assistant messages can resolve context but are never evidence.
|
|
25
31
|
- Extract zero to eight independent candidates. Each candidate represents one stable predicate and one value.
|
|
32
|
+
- Extract a goal only when the user explicitly describes a durable desired outcome, not a one-off task request.
|
|
33
|
+
- Extract a collaboration rule only when the user explicitly states an ongoing way the assistant should communicate, execute, or respect a boundary.
|
|
34
|
+
- Use only prompt enforcement for inferred collaboration rules. Never invent tool gates or deny effects.
|
|
26
35
|
- predicate is a stable language-neutral lowercase identifier. The value is excluded from predicate identity.
|
|
27
36
|
- Preserve importance stated by the user in declaredImportance; estimate inferredImportance separately.
|
|
28
37
|
- Use current_state or event volatility only with a bounded validTo. If relative time cannot be resolved, use temporalResolution=unresolved and omit resolved time fields.
|
|
@@ -4,10 +4,10 @@ import { finishContextExtractionRun } from "../../storage/sqlite/context-extract
|
|
|
4
4
|
import { getSessionMetadata } from "../../storage/sqlite/session-repository.js";
|
|
5
5
|
import { loadCompactionSourceSnapshot } from "../../storage/sqlite/transcript-repository.js";
|
|
6
6
|
import "../../storage/sqlite/index.js";
|
|
7
|
-
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
8
7
|
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
|
|
9
8
|
import { getApiKeySync, init_providers, resolveModel } from "../../providers/index.js";
|
|
10
9
|
import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
|
|
10
|
+
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
11
11
|
import { extractTextContent } from "../context/workspace.js";
|
|
12
12
|
import { listUserAssertions } from "../../user-model/repository.js";
|
|
13
13
|
import { readAgentMessageContent } from "../memory/agent-message-access.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecutionContext } from './execution-context.js';
|
|
1
|
+
import type { ExecutionContext } from './execution-context.types.js';
|
|
2
2
|
export interface ExecutionContextBudget {
|
|
3
3
|
maxAssertions: number;
|
|
4
4
|
maxKnowledge: number;
|
|
@@ -27,6 +27,7 @@ export declare function recordExecutionContext(context: ExecutionContext, input:
|
|
|
27
27
|
sessionId: string;
|
|
28
28
|
budget: ExecutionContextBudget;
|
|
29
29
|
renderedChars: number;
|
|
30
|
+
includedContext?: ExecutionContext;
|
|
30
31
|
}): void;
|
|
31
32
|
export declare function getExecutionContextAudit(turnId: string): ExecutionContextAudit | undefined;
|
|
32
33
|
export declare function recordExecutionContextFeedback(input: {
|
|
@@ -34,3 +35,4 @@ export declare function recordExecutionContextFeedback(input: {
|
|
|
34
35
|
rating: 'helpful' | 'irrelevant';
|
|
35
36
|
reason?: string;
|
|
36
37
|
}): boolean;
|
|
38
|
+
export declare function getExecutionContextFeedbackScores(): Map<string, number>;
|
|
@@ -3,39 +3,46 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
//#region src/agent/context/audit.ts
|
|
4
4
|
function recordExecutionContext(context, input) {
|
|
5
5
|
const createdAt = Date.now();
|
|
6
|
+
const included = /* @__PURE__ */ new Set();
|
|
7
|
+
const selected = input.includedContext ?? context;
|
|
8
|
+
for (const item of selected.rules) included.add(`rule:${item.id}`);
|
|
9
|
+
for (const item of selected.assertions) included.add(`assertion:${item.assertion.id}`);
|
|
10
|
+
for (const item of selected.goals) included.add(`goal:${item.id}`);
|
|
11
|
+
for (const item of selected.priorities) included.add(`priority:${item.id}`);
|
|
12
|
+
for (const item of selected.knowledge) included.add(`knowledge:${item.id}`);
|
|
6
13
|
const items = [
|
|
7
14
|
...context.rules.map((item) => ({
|
|
8
15
|
objectType: "rule",
|
|
9
16
|
objectId: item.id,
|
|
10
17
|
reasons: [`${item.enforcementLevel}_rule`],
|
|
11
|
-
included:
|
|
18
|
+
included: included.has(`rule:${item.id}`)
|
|
12
19
|
})),
|
|
13
20
|
...context.assertions.map((item) => ({
|
|
14
21
|
objectType: "assertion",
|
|
15
22
|
objectId: item.assertion.id,
|
|
16
23
|
score: item.score,
|
|
17
24
|
reasons: item.reasons,
|
|
18
|
-
included:
|
|
25
|
+
included: included.has(`assertion:${item.assertion.id}`)
|
|
19
26
|
})),
|
|
20
27
|
...context.goals.map((item) => ({
|
|
21
28
|
objectType: "goal",
|
|
22
29
|
objectId: item.id,
|
|
23
30
|
reasons: ["active_goal"],
|
|
24
|
-
included:
|
|
31
|
+
included: included.has(`goal:${item.id}`)
|
|
25
32
|
})),
|
|
26
33
|
...context.priorities.map((item) => ({
|
|
27
34
|
objectType: "priority",
|
|
28
35
|
objectId: item.id,
|
|
29
36
|
score: item.urgency,
|
|
30
37
|
reasons: [`${item.rank}_priority`],
|
|
31
|
-
included:
|
|
38
|
+
included: included.has(`priority:${item.id}`)
|
|
32
39
|
})),
|
|
33
40
|
...context.knowledge.map((item) => ({
|
|
34
41
|
objectType: "knowledge",
|
|
35
42
|
objectId: item.id,
|
|
36
43
|
score: item.importance,
|
|
37
44
|
reasons: ["task_relevant_knowledge"],
|
|
38
|
-
included:
|
|
45
|
+
included: included.has(`knowledge:${item.id}`)
|
|
39
46
|
}))
|
|
40
47
|
];
|
|
41
48
|
const metrics = {
|
|
@@ -44,6 +51,11 @@ function recordExecutionContext(context, input) {
|
|
|
44
51
|
goals: context.goals.length,
|
|
45
52
|
priorities: context.priorities.length,
|
|
46
53
|
knowledge: context.knowledge.length,
|
|
54
|
+
includedRules: selected.rules.length,
|
|
55
|
+
includedAssertions: selected.assertions.length,
|
|
56
|
+
includedGoals: selected.goals.length,
|
|
57
|
+
includedPriorities: selected.priorities.length,
|
|
58
|
+
includedKnowledge: selected.knowledge.length,
|
|
47
59
|
renderedChars: input.renderedChars
|
|
48
60
|
};
|
|
49
61
|
runSqliteWriteTransaction((db) => {
|
|
@@ -93,5 +105,19 @@ function recordExecutionContextFeedback(input) {
|
|
|
93
105
|
rating = excluded.rating, reason = excluded.reason, updated_at = excluded.updated_at`).run(input.turnId, input.rating, input.reason ?? null, now, now, input.turnId);
|
|
94
106
|
return Number(result.changes) > 0;
|
|
95
107
|
}
|
|
108
|
+
function getExecutionContextFeedbackScores() {
|
|
109
|
+
const rows = getSqliteDatabase().prepare(`SELECT i.object_type, i.object_id,
|
|
110
|
+
COUNT(*) AS samples,
|
|
111
|
+
SUM(CASE f.rating WHEN 'helpful' THEN 1 ELSE -1 END) AS balance
|
|
112
|
+
FROM execution_context_items i
|
|
113
|
+
JOIN execution_context_runs r ON r.run_id = i.run_id
|
|
114
|
+
JOIN (
|
|
115
|
+
SELECT turn_id, rating FROM execution_context_feedback
|
|
116
|
+
ORDER BY updated_at DESC LIMIT 500
|
|
117
|
+
) f ON f.turn_id = r.turn_id
|
|
118
|
+
WHERE i.included = 1
|
|
119
|
+
GROUP BY i.object_type, i.object_id`).all();
|
|
120
|
+
return new Map(rows.flatMap((row) => row.samples < 2 ? [] : [[`${row.object_type}:${row.object_id}`, Math.max(-.1, Math.min(.1, row.balance / row.samples * .1))]]));
|
|
121
|
+
}
|
|
96
122
|
//#endregion
|
|
97
|
-
export { getExecutionContextAudit, recordExecutionContext, recordExecutionContextFeedback };
|
|
123
|
+
export { getExecutionContextAudit, getExecutionContextFeedbackScores, recordExecutionContext, recordExecutionContextFeedback };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
2
|
import type { Config } from '../../config/schema.js';
|
|
3
|
+
import type { KnowledgeSource } from '../../knowledge-memory/index.js';
|
|
3
4
|
import { type ExecutionContext } from './execution-context.js';
|
|
4
5
|
export interface ExecutionContextPlan {
|
|
5
6
|
traceId: string;
|
|
@@ -11,7 +12,11 @@ export interface ExecutionContextPlan {
|
|
|
11
12
|
}
|
|
12
13
|
export interface ExecutionContextCoordinatorOptions {
|
|
13
14
|
getConfig: () => Config | undefined;
|
|
14
|
-
|
|
15
|
+
getAccessForSession: (sessionKey: string) => {
|
|
16
|
+
userModel: boolean;
|
|
17
|
+
knowledge: boolean;
|
|
18
|
+
knowledgeSources: readonly KnowledgeSource[];
|
|
19
|
+
};
|
|
15
20
|
getWorkspaceIdForSession: (sessionKey: string) => string;
|
|
16
21
|
getProjectIdForSession: (sessionKey: string) => string | undefined;
|
|
17
22
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { init_session_key, parseSessionKey } from "../../routing/session-key.js";
|
|
2
1
|
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
3
2
|
import { assembleTaskContext } from "../../tasks/task-context-assembler.js";
|
|
4
3
|
import { recordExecutionContext } from "./audit.js";
|
|
5
4
|
import { prependAgentContext } from "./prepend.js";
|
|
6
5
|
import { extractAgentUserPlainText } from "../memory/user-message-text.js";
|
|
7
|
-
import { buildExecutionContext,
|
|
6
|
+
import { buildExecutionContext, fitExecutionContextToChars } from "./execution-context.js";
|
|
8
7
|
//#region src/agent/context/coordinator.ts
|
|
9
|
-
init_session_key();
|
|
10
|
-
function isPrivateSession(sessionKey) {
|
|
11
|
-
const parsed = parseSessionKey(sessionKey);
|
|
12
|
-
return !parsed || parsed.peerKind === "direct";
|
|
13
|
-
}
|
|
14
8
|
var ExecutionContextCoordinator = class {
|
|
15
9
|
currentBySession = /* @__PURE__ */ new Map();
|
|
16
10
|
constructor(options) {
|
|
@@ -34,7 +28,8 @@ var ExecutionContextCoordinator = class {
|
|
|
34
28
|
contextItemCount: 0
|
|
35
29
|
});
|
|
36
30
|
const config = this.options.getConfig();
|
|
37
|
-
|
|
31
|
+
const access = this.options.getAccessForSession(sessionKey);
|
|
32
|
+
if (!config || !config.userContext.contextPlanning.enabled || !access.userModel && !access.knowledge) return empty();
|
|
38
33
|
const task = assembleTaskContext(sessionKey, extractAgentUserPlainText(userMessage));
|
|
39
34
|
const context = buildExecutionContext({
|
|
40
35
|
query: task.retrievalQuery,
|
|
@@ -43,20 +38,26 @@ var ExecutionContextCoordinator = class {
|
|
|
43
38
|
projectId: this.options.getProjectIdForSession(sessionKey),
|
|
44
39
|
sessionId: sessionKey,
|
|
45
40
|
maxAssertions: Math.min(config.userContext.contextPlanning.maxAssertions, task.allocation.maxResults),
|
|
46
|
-
maxKnowledge: Math.min(config.userContext.contextPlanning.maxKnowledge, task.allocation.maxResults)
|
|
41
|
+
maxKnowledge: Math.min(config.userContext.contextPlanning.maxKnowledge, task.allocation.maxResults),
|
|
42
|
+
includeUserModel: access.userModel,
|
|
43
|
+
includeKnowledge: access.knowledge,
|
|
44
|
+
knowledgeSources: access.knowledgeSources
|
|
47
45
|
});
|
|
48
46
|
this.currentBySession.set(sessionKey, context);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
47
|
+
const maxChars = Math.min(config.userContext.contextPlanning.maxChars, task.allocation.maxChars);
|
|
48
|
+
const fitted = fitExecutionContextToChars(context, maxChars);
|
|
49
|
+
const rendered = fitted.rendered;
|
|
50
|
+
const contextItemCount = fitted.context.rules.length + fitted.context.assertions.length + fitted.context.goals.length + fitted.context.priorities.length + fitted.context.knowledge.length;
|
|
51
51
|
recordExecutionContext(context, {
|
|
52
52
|
turnId,
|
|
53
53
|
sessionId: sessionKey,
|
|
54
54
|
budget: {
|
|
55
55
|
maxAssertions: Math.min(config.userContext.contextPlanning.maxAssertions, task.allocation.maxResults),
|
|
56
56
|
maxKnowledge: Math.min(config.userContext.contextPlanning.maxKnowledge, task.allocation.maxResults),
|
|
57
|
-
maxChars
|
|
57
|
+
maxChars
|
|
58
58
|
},
|
|
59
|
-
renderedChars: rendered.length
|
|
59
|
+
renderedChars: rendered.length,
|
|
60
|
+
includedContext: fitted.context
|
|
60
61
|
});
|
|
61
62
|
return {
|
|
62
63
|
traceId: context.traceId,
|
|
@@ -1,52 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export type RuleEnforcementLevel = 'prompt' | 'planner' | 'tool_gate';
|
|
4
|
-
export interface ExecutionRule {
|
|
5
|
-
id: string;
|
|
6
|
-
statement: string;
|
|
7
|
-
priority: number;
|
|
8
|
-
enforcementLevel: RuleEnforcementLevel;
|
|
9
|
-
conditions: Record<string, unknown>;
|
|
10
|
-
}
|
|
11
|
-
export interface RankedExecutionAssertion {
|
|
12
|
-
assertion: UserAssertion;
|
|
13
|
-
score: number;
|
|
14
|
-
reasons: string[];
|
|
15
|
-
}
|
|
16
|
-
export interface ExecutionGoal {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
desiredOutcome: string;
|
|
20
|
-
status: string;
|
|
21
|
-
declaredImportance?: number;
|
|
22
|
-
targetAt?: number;
|
|
23
|
-
}
|
|
24
|
-
export interface ExecutionPriority {
|
|
25
|
-
id: string;
|
|
26
|
-
targetType: string;
|
|
27
|
-
targetId: string;
|
|
28
|
-
rank: 'primary' | 'secondary' | 'background';
|
|
29
|
-
urgency: number;
|
|
30
|
-
validTo: number;
|
|
31
|
-
}
|
|
32
|
-
export interface ExecutionContext {
|
|
33
|
-
traceId: string;
|
|
34
|
-
asOf: number;
|
|
35
|
-
query: string;
|
|
36
|
-
rules: ExecutionRule[];
|
|
37
|
-
assertions: RankedExecutionAssertion[];
|
|
38
|
-
goals: ExecutionGoal[];
|
|
39
|
-
priorities: ExecutionPriority[];
|
|
40
|
-
knowledge: KnowledgeItem[];
|
|
41
|
-
}
|
|
42
|
-
export interface ExecutionContextRequest extends KnowledgeVisibilityContext {
|
|
43
|
-
query: string;
|
|
44
|
-
asOf?: number;
|
|
45
|
-
maxAssertions?: number;
|
|
46
|
-
maxKnowledge?: number;
|
|
47
|
-
}
|
|
1
|
+
import type { ExecutionContext, ExecutionContextRequest, ExecutionRule } from './execution-context.types.js';
|
|
2
|
+
export type { ExecutionContext, ExecutionContextRequest, ExecutionGoal, ExecutionPriority, ExecutionRule, RankedExecutionAssertion, RuleEnforcementLevel, } from './execution-context.types.js';
|
|
48
3
|
export declare function buildExecutionContext(request: ExecutionContextRequest): ExecutionContext;
|
|
49
4
|
export declare function renderExecutionContext(context: ExecutionContext): string;
|
|
5
|
+
export declare function fitExecutionContextToChars(context: ExecutionContext, maxChars: number): {
|
|
6
|
+
context: ExecutionContext;
|
|
7
|
+
rendered: string;
|
|
8
|
+
};
|
|
50
9
|
export declare function evaluateToolGate(context: ExecutionContext, operation: string): {
|
|
51
10
|
allowed: boolean;
|
|
52
11
|
rule?: ExecutionRule;
|