@xopcai/xopc 0.0.248 → 0.0.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-etpmyV7S.js → activity-store-DfBjTSo9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BmKxSM1k.js → agent-avatar-dicebear-BN6FJXkJ.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C7rZH1A2.js +1 -0
- package/dist/gateway/static/root/assets/agents-CgGaoo4z.js +1 -0
- package/dist/gateway/static/root/assets/{api-B0-hLuZ1.js → api-zxpcJfgj.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-D2gMshuS.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-wMu0jSKx.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-KF1Gnv36.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BnMSgZvR.js → archive-plugin-u6EE3JV8.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CejsQMev.js → attachment-load-DbJurnv-.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-RC8EyoAf.js → automations-page-Ew_e5HDn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ch-ldu35.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DGjppLSG.js → binary-plugins-DtDFNfPM.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CWdP4bUc.js → block-editor-CnAwmabq.js} +44 -44
- package/dist/gateway/static/root/assets/browser-settings-page-DtVhsHJW.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BQ1Ilw_o.js → browser-workflow-inputs-BX1-uM9L.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CJh4NyxT.js → browser-workflows-page-CcbUOWDF.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel--sXeylhe.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-AXSBDujZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-Ohhee4vm.js → channels-status-swr-CX-yWwLD.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BOtoKTK3.js → chat-terminal-dock-CryTDNdD.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-HBHUWohz.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DTj1V3Sw.js → cron-expression-ji5aWrjG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Yr6OCvGL.js → date-picker-Dro_w3eX.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-Ce19KKnX.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-DbGzggPF.js → desktop-pet-DsSi-3uZ.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-8WQ4woJy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DgTtk4KC.js → extension-debug-page-CgvEBfLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DtQeiP6f.js → extension-page-DkznBbMj.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BOjhchK2.js +1 -0
- package/dist/gateway/static/root/assets/files-BArWTfr7.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-OEruhhX3.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DXuXtU1w.js → gateway-config-swr-CMNbl0FZ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BgH3A0LO.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CzBzglzQ.js → gateway-startup-retry-CR7Xg8As.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C97naDkO.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BBKKme4G.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-TIgsn04n.js → image-generation-api-C5mn73ca.js} +1 -1
- package/dist/gateway/static/root/assets/index-BcaF-dgQ.js +72 -0
- package/dist/gateway/static/root/assets/index-DAryGvZ7.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-wsWuoa8p.js → keyboard-shortcuts-settings-BYhfzsqe.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DNncc2tn.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CXrbrGo8.js → local-apps-page-vBlknU7C.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BJFLQY8O.js → locale-store-CF4erhjB.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CizZInrT.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-BdJZFR7U.js → management-settings-Dnx6mSNe.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-NK3ACVG2.js → markdown-split-DtBtcHWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DTF9v1gg.js → markdown-view-CQvzsE24.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-F0jcUxyl.js → media-plugins-DrMYeHe7.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +3 -0
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-AKgGy3Kx.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-Bw3jD9Jf.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-Dpqq7Z-J.js +8 -0
- package/dist/gateway/static/root/assets/page-tabs-CX9T71by.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-DvEHoimN.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-CxGGlWA8.js → product-open-page-COcr_NUJ.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BuT6MCTs.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DXWMxOjf.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CIsNlSBi.js → registry-api-BsRBlji7.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-7rBCUWzZ.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-YkjhiQfA.js → runtime-tools-settings-panel-CQ13P-mS.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-oFGf3G3s.js → schema-form-BUVyTpZj.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-gmEOYNb4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DYYoJcl7.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-DVY-8_B9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-C7VWs0IT.js → settings-page-CdiVYyTl.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BhenBnUj.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-t5oz18rh.js → share-preview-page-C88YLKm4.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Dq7xIj0_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-MDI9Lz6z.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DLir1nM0.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-DEDTYs2W.js → skills-page.utils-BMZAfS3G.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-BM8ivYan.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-P0_RldWv.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-O597U8q_.js → theme-store-BOgkc_9D.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-DemxChjo.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-B5eUJ6Zq.js → use-autosave-CV3Ui5hu.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CxfnoRVn.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CMKSwz4C.js → voice-api-key-field-CUoCi4Sq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-q7B6fOFB.js → voice-config-api-C-ryeIxj.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-BhDlkCMB.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DZmvLZjb.js → workflow-run-setup-panel-D8CcPc_C.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bxn2Dc16.js +5 -0
- package/dist/gateway/static/root/index.html +11 -27
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/user-message-display.js +18 -0
- package/dist/src/agent/agent-instance-gateway.d.ts +3 -3
- package/dist/src/agent/agent-manager.d.ts +13 -13
- package/dist/src/agent/agent-manager.js +76 -42
- package/dist/src/agent/background-review/coordinator.d.ts +2 -4
- package/dist/src/agent/background-review/coordinator.js +5 -30
- package/dist/src/agent/background-review/prompts.d.ts +4 -2
- package/dist/src/agent/background-review/prompts.js +33 -19
- package/dist/src/agent/background-review/run-background-review.d.ts +6 -7
- package/dist/src/agent/background-review/run-background-review.js +47 -41
- package/dist/src/agent/background-review/settings.d.ts +0 -1
- package/dist/src/agent/background-review/settings.js +6 -7
- package/dist/src/agent/context/audit.d.ts +38 -0
- package/dist/src/agent/context/audit.js +123 -0
- package/dist/src/agent/context/coordinator.d.ts +31 -0
- package/dist/src/agent/context/coordinator.js +73 -0
- package/dist/src/agent/context/execution-context.d.ts +13 -0
- package/dist/src/agent/context/execution-context.js +211 -0
- package/dist/src/agent/context/execution-context.types.d.ts +50 -0
- package/dist/src/agent/context/execution-scope.d.ts +5 -1
- package/dist/src/agent/context/execution-scope.js +6 -2
- package/dist/src/agent/context/prepend.d.ts +2 -0
- package/dist/src/agent/context/prepend.js +28 -0
- package/dist/src/agent/context/project-context.d.ts +6 -3
- package/dist/src/agent/context/project-context.js +28 -23
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -0
- package/dist/src/agent/embedded/run-turn.js +22 -2
- package/dist/src/agent/embedded/types.d.ts +1 -25
- package/dist/src/agent/external-tools/composio-provider.js +87 -92
- package/dist/src/agent/external-tools/gateway-tools.d.ts +4 -1
- package/dist/src/agent/external-tools/gateway-tools.js +153 -41
- package/dist/src/agent/external-tools/index.d.ts +1 -0
- package/dist/src/agent/external-tools/index.js +2 -1
- package/dist/src/agent/external-tools/memory-provider.d.ts +1 -0
- package/dist/src/agent/external-tools/memory-provider.js +1 -0
- package/dist/src/agent/external-tools/search-error.d.ts +12 -0
- package/dist/src/agent/external-tools/search-error.js +29 -0
- package/dist/src/agent/external-tools/service.d.ts +4 -0
- package/dist/src/agent/external-tools/service.js +22 -2
- package/dist/src/agent/inbound/attachment-pipeline.js +5 -1
- package/dist/src/agent/memory/compaction-policy.js +1 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -0
- package/dist/src/agent/memory/compaction-promotion.js +52 -79
- package/dist/src/agent/memory/create-memory-manager.js +1 -3
- package/dist/src/agent/memory/index.d.ts +1 -6
- package/dist/src/agent/memory/index.js +3 -6
- package/dist/src/agent/memory/manager.d.ts +0 -16
- package/dist/src/agent/memory/manager.js +11 -40
- package/dist/src/agent/memory/memory-config.d.ts +0 -5
- package/dist/src/agent/memory/memory-config.js +2 -9
- package/dist/src/agent/memory/runtime.d.ts +2 -2
- package/dist/src/agent/memory/runtime.js +9 -19
- package/dist/src/agent/memory/types.d.ts +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +13 -21
- package/dist/src/agent/orchestration/context-overflow.js +1 -0
- package/dist/src/agent/prompt/sections/memory-skills.js +25 -36
- package/dist/src/agent/prompt/sections/tooling.js +10 -4
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -3
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +8 -25
- package/dist/src/agent/service/process-direct-streaming.js +8 -7
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/tasks/task-judge-service.js +1 -1
- package/dist/src/agent/tools/clarify-tool.d.ts +1 -0
- package/dist/src/agent/tools/delegate-tool.js +5 -2
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +68 -21
- package/dist/src/agent/tools/index.d.ts +3 -2
- package/dist/src/agent/tools/index.js +4 -3
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +15 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +184 -0
- package/dist/src/agent/tools/{dreaming-tool.d.ts → memory-maintenance-tool.d.ts} +2 -2
- package/dist/src/agent/tools/memory-maintenance-tool.js +31 -0
- package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-search-tool.js +7 -0
- package/dist/src/agent/tools/user-context-tool.d.ts +10 -0
- package/dist/src/agent/tools/user-context-tool.js +98 -0
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/automations/service/automation-service.d.ts +2 -1
- package/dist/src/automations/service/automation-service.js +6 -2
- package/dist/src/chat-commands/builtins/understanding.js +24 -6
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +68 -75
- package/dist/src/config/schema.js +29 -18
- package/dist/src/config/web-patch.d.ts +1 -1
- package/dist/src/connectors/auth-provider-registry.js +1 -1
- package/dist/src/connectors/composio-managed-client.js +6 -2
- package/dist/src/connectors/connected-source-ingestion.js +1 -1
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -3
- package/dist/src/connectors/connected-source-understanding.js +86 -99
- package/dist/src/connectors/connection-candidates.d.ts +11 -0
- package/dist/src/connectors/connection-candidates.js +58 -0
- package/dist/src/connectors/connection-capabilities.d.ts +4 -0
- package/dist/src/connectors/connection-capabilities.js +37 -0
- package/dist/src/connectors/connection-recovery-service.d.ts +43 -0
- package/dist/src/connectors/connection-recovery-service.js +420 -0
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/learning-coordinator.d.ts +0 -2
- package/dist/src/connectors/learning-coordinator.js +6 -7
- package/dist/src/connectors/principal.d.ts +5 -0
- package/dist/src/connectors/principal.js +18 -0
- package/dist/src/files/file-service.js +4 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +28 -10
- package/dist/src/gateway/agent-builtin-tools.js +30 -9
- package/dist/src/gateway/chat-stream/mapper.js +1 -28
- package/dist/src/gateway/chat-stream/protocol.d.ts +2 -24
- package/dist/src/gateway/clarify-bridge.d.ts +4 -0
- package/dist/src/gateway/clarify-bridge.js +9 -4
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +52 -30
- package/dist/src/gateway/hono/lib/config-payload.js +4 -4
- package/dist/src/gateway/hono/middleware/auth.js +1 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +72 -28
- package/dist/src/gateway/hono/routes/connection-waits.d.ts +3 -0
- package/dist/src/gateway/hono/routes/connection-waits.js +58 -0
- package/dist/src/gateway/hono/routes/connectors.js +24 -18
- package/dist/src/gateway/hono/routes/context-sources.d.ts +4 -0
- package/dist/src/gateway/hono/routes/context-sources.js +159 -0
- package/dist/src/gateway/hono/routes/files.js +23 -2
- package/dist/src/gateway/hono/routes/index.js +4 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -4
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +22 -7
- package/dist/src/gateway/hono/routes/projects.js +36 -44
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +15 -1
- package/dist/src/gateway/hono/routes/side-chats.js +13 -2
- package/dist/src/gateway/hono/routes/tasks.js +3 -3
- package/dist/src/gateway/hono/routes/user-model.d.ts +3 -0
- package/dist/src/gateway/hono/routes/user-model.js +480 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +72 -0
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/agent-runner.d.ts +9 -1
- package/dist/src/gateway/service/agent-runner.js +25 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
- package/dist/src/gateway/service/config-coordinator.js +4 -4
- package/dist/src/gateway/service/run-gateway-agent.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +18 -14
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +12 -2
- package/dist/src/gateway/service.d.ts +3 -1
- package/dist/src/gateway/service.js +52 -17
- package/dist/src/gateway/side-chat/manager.d.ts +16 -3
- package/dist/src/gateway/side-chat/manager.js +117 -28
- package/dist/src/gateway/side-chat/run-service.d.ts +2 -0
- package/dist/src/gateway/side-chat/run-service.js +28 -5
- package/dist/src/gateway/side-chat/types.d.ts +9 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +0 -2
- package/dist/src/knowledge/connected-knowledge-pipeline.js +46 -217
- package/dist/src/knowledge-memory/domain.d.ts +36 -0
- package/dist/src/knowledge-memory/index.d.ts +2 -0
- package/dist/src/knowledge-memory/index.js +2 -0
- package/dist/src/knowledge-memory/repository.d.ts +48 -0
- package/dist/src/knowledge-memory/repository.js +168 -0
- package/dist/src/memory-maintenance/index.d.ts +2 -0
- package/dist/src/memory-maintenance/index.js +3 -0
- package/dist/src/memory-maintenance/schedule.d.ts +13 -0
- package/dist/src/memory-maintenance/schedule.js +51 -0
- package/dist/src/memory-maintenance/service.d.ts +28 -0
- package/dist/src/memory-maintenance/service.js +216 -0
- package/dist/src/notes/service.d.ts +1 -0
- package/dist/src/notes/service.js +7 -1
- package/dist/src/notes/types.d.ts +16 -0
- package/dist/src/notifications/planner.js +7 -3
- package/dist/src/proactive/actions/service.d.ts +0 -1
- package/dist/src/proactive/actions/service.js +1 -10
- package/dist/src/proactive/execution/context.d.ts +8 -10
- package/dist/src/proactive/execution/context.js +93 -42
- package/dist/src/proactive/execution/insight.d.ts +4 -1
- package/dist/src/proactive/execution/insight.js +5 -2
- package/dist/src/proactive/execution/repository.d.ts +1 -0
- package/dist/src/proactive/execution/repository.js +9 -1
- package/dist/src/proactive/execution/types.d.ts +0 -1
- package/dist/src/proactive/execution/worker.js +7 -5
- package/dist/src/proactive/inbox/repository.js +8 -2
- package/dist/src/proactive/inbox/service.js +2 -2
- package/dist/src/proactive/inbox/types.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.js +7 -0
- package/dist/src/proactive/index.d.ts +2 -1
- package/dist/src/proactive/index.js +3 -2
- package/dist/src/proactive/maintenance.d.ts +4 -0
- package/dist/src/proactive/maintenance.js +21 -0
- package/dist/src/proactive/scenarios/repository.d.ts +1 -1
- package/dist/src/proactive/scenarios/repository.js +10 -3
- package/dist/src/proactive/scenarios/types.d.ts +7 -0
- package/dist/src/proactive/service.d.ts +7 -0
- package/dist/src/proactive/service.js +17 -1
- package/dist/src/projects/index.d.ts +1 -1
- package/dist/src/projects/index.js +2 -2
- package/dist/src/projects/knowledge-bind.d.ts +1 -0
- package/dist/src/projects/knowledge-bind.js +15 -0
- package/dist/src/projects/project-loop.d.ts +3 -3
- package/dist/src/projects/project-loop.js +4 -4
- package/dist/src/projects/project-service.d.ts +2 -1
- package/dist/src/projects/project-service.js +3 -2
- package/dist/src/projects/project-store.js +2 -1
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/runtime-tools/manager.js +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +5 -2
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +19 -0
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +54 -0
- package/dist/src/storage/sqlite/config-repository.js +1 -1
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +30 -0
- package/dist/src/storage/sqlite/connection-wait-repository.js +338 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +1 -1
- package/dist/src/storage/sqlite/context-evidence-repository.d.ts +24 -0
- package/dist/src/storage/sqlite/context-evidence-repository.js +52 -0
- package/dist/src/storage/sqlite/index.d.ts +3 -5
- package/dist/src/storage/sqlite/index.js +6 -8
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +0 -19
- package/dist/src/storage/sqlite/knowledge-repository.js +1 -90
- package/dist/src/storage/sqlite/migrations/148_user_model_foundation.sql +554 -0
- package/dist/src/storage/sqlite/migrations/149_separate_source_index_from_memory.sql +18 -0
- package/dist/src/storage/sqlite/migrations/150_session_connection_waits.sql +47 -0
- package/dist/src/storage/sqlite/migrations/151_proactive_scope_cleanup.sql +6 -0
- package/dist/src/storage/sqlite/migrations/152_proactive_scenario_contract.sql +140 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.d.ts +2 -1
- package/dist/src/storage/sqlite/notes-repository.js +37 -3
- package/dist/src/storage/sqlite/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +14 -2
- package/dist/src/storage/sqlite/session-input-repository.js +17 -14
- package/dist/src/storage/sqlite/session-instance-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/session-instance-repository.js +6 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-repository.js +7 -6
- package/dist/src/storage/sqlite/transcript-repository.js +3 -2
- package/dist/src/tasks/home-query-service.js +35 -13
- package/dist/src/tasks/index.js +2 -2
- package/dist/src/tasks/project-monitoring-service.d.ts +2 -0
- package/dist/src/tasks/project-monitoring-service.js +4 -1
- package/dist/src/tasks/project-operating-view-service.js +1 -1
- package/dist/src/tasks/task-application-service.js +6 -1
- package/dist/src/tasks/task-context-assembler.js +1 -1
- package/dist/src/tasks/task-context-repository.d.ts +0 -1
- package/dist/src/tasks/task-context-repository.js +1 -1
- package/dist/src/tasks/task-deletion-service.js +1 -1
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tasks/task-read-model-projector.js +1 -1
- package/dist/src/tasks/task-run-coordinator.js +1 -1
- package/dist/src/tasks/task-run-dispatcher.js +1 -1
- package/dist/src/tasks/task-run-repository.js +1 -0
- package/dist/src/tasks/task-signal-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tool-summary.js +2 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/user-context/access-policy.d.ts +11 -0
- package/dist/src/user-context/access-policy.js +26 -0
- package/dist/src/user-context/changes.d.ts +1 -1
- package/dist/src/user-context/config.d.ts +135 -153
- package/dist/src/user-context/config.js +94 -99
- package/dist/src/user-context/relationship-continuity.d.ts +2 -2
- package/dist/src/user-context/relationship-continuity.js +34 -24
- package/dist/src/user-context/sources/activity-clustering.d.ts +9 -3
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/repository.d.ts +1 -21
- package/dist/src/user-context/sources/repository.js +1 -183
- package/dist/src/user-context/sources/types.d.ts +0 -23
- package/dist/src/user-model/capture/executor.d.ts +50 -0
- package/dist/src/user-model/capture/executor.js +230 -0
- package/dist/src/user-model/capture/index.d.ts +2 -0
- package/dist/src/user-model/capture/index.js +3 -0
- package/dist/src/user-model/capture/semantic.d.ts +39 -0
- package/dist/src/user-model/capture/semantic.js +263 -0
- package/dist/src/user-model/domain.d.ts +93 -0
- package/dist/src/user-model/domain.js +33 -0
- package/dist/src/user-model/goals.d.ts +62 -0
- package/dist/src/user-model/goals.js +91 -0
- package/dist/src/user-model/importance.d.ts +11 -0
- package/dist/src/user-model/importance.js +17 -0
- package/dist/src/user-model/index.d.ts +5 -0
- package/dist/src/user-model/index.js +6 -0
- package/dist/src/user-model/repository.d.ts +23 -0
- package/dist/src/user-model/repository.js +268 -0
- package/dist/src/user-model/temporal.d.ts +10 -0
- package/dist/src/user-model/temporal.js +44 -0
- package/dist/src/voice/realtime/memory-context.d.ts +7 -2
- package/dist/src/voice/realtime/memory-context.js +39 -51
- package/dist/src/work-discovery/service.d.ts +3 -14
- package/dist/src/work-discovery/service.js +138 -99
- package/dist/src/work-discovery/types.d.ts +3 -3
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +12 -20
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CUXApfcE.js +0 -1
- package/dist/gateway/static/root/assets/agents-DNq_GKuc.js +0 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-qfwAgyhQ.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-DqQVUpCC.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-dwIqYmXk.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-SkdcSZ0i.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CKCa6TvG.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DSp--zIZ.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CMd2dDrI.js +0 -1
- package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-udWs5Kdm.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DpN3XZg9.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DinCToZh.js +0 -1
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DcguCgsH.js +0 -1
- package/dist/gateway/static/root/assets/eye-CABVeTq0.js +0 -1
- package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +0 -1
- package/dist/gateway/static/root/assets/files-D6vf3S30.js +0 -1
- package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +0 -1
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-Br7lSf6H.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CdPoDMuj.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DHk1hawP.js +0 -1
- package/dist/gateway/static/root/assets/home-page-YGipe_W6.js +0 -1
- package/dist/gateway/static/root/assets/index-D5TQQpeb.js +0 -71
- package/dist/gateway/static/root/assets/index-DReBaaTX.css +0 -2
- package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +0 -1
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CpyvYyrb.js +0 -2
- package/dist/gateway/static/root/assets/local-context-graph-BjUf7fQ9.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CXKy6E_l.js +0 -2
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +0 -1
- package/dist/gateway/static/root/assets/messages-CHNYp8EQ.js +0 -3
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +0 -1
- package/dist/gateway/static/root/assets/mobile-pairing-wizard-3NKCniSp.js +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-nCfkBN8M.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-DuqLahi6.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-C7j9EdQk.js +0 -5
- package/dist/gateway/static/root/assets/oauth-api-8lP_qJpq.js +0 -1
- package/dist/gateway/static/root/assets/oauth-authorization-window-Cdolr2wE.js +0 -1
- package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +0 -1
- package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-CfebYVX0.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-48GvzSVa.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-64xj_s2m.js +0 -1
- package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +0 -1
- package/dist/gateway/static/root/assets/search-DA7gz22f.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CcwcdRN8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BaN84CyW.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-DjWzRk4z.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DVVOCNbr.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DUYbYLi7.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BGyD0gB9.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CjF8DTsN.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-BSYuRgFI.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-YZYSTJH7.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-FKUi9wDL.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BCyiduKd.js +0 -2
- package/dist/gateway/static/root/assets/work-discovery-overlay-jhT2EzeH.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DQC0TpMa.js +0 -5
- package/dist/src/agent/memory/builtin-provider.d.ts +0 -37
- package/dist/src/agent/memory/builtin-provider.js +0 -225
- package/dist/src/agent/memory/context/types.d.ts +0 -40
- package/dist/src/agent/memory/understanding/quality.d.ts +0 -8
- package/dist/src/agent/memory/understanding/quality.js +0 -18
- package/dist/src/agent/memory/understanding/service.d.ts +0 -19
- package/dist/src/agent/memory/understanding/service.js +0 -209
- package/dist/src/agent/memory/understanding/types.d.ts +0 -34
- package/dist/src/agent/memory/user-context-coordinator.d.ts +0 -23
- package/dist/src/agent/memory/user-context-coordinator.js +0 -113
- package/dist/src/agent/tools/dreaming-tool.js +0 -37
- package/dist/src/agent/tools/memory-tool.d.ts +0 -9
- package/dist/src/agent/tools/memory-tool.js +0 -119
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -11
- package/dist/src/gateway/dreaming-automation-reconciler.js +0 -63
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +0 -21
- package/dist/src/gateway/hono/routes/understanding-sources.js +0 -387
- package/dist/src/gateway/hono/routes/you.d.ts +0 -3
- package/dist/src/gateway/hono/routes/you.js +0 -457
- package/dist/src/projects/memory-bind.d.ts +0 -1
- package/dist/src/projects/memory-bind.js +0 -14
- package/dist/src/storage/sqlite/context-consolidation-repository.d.ts +0 -37
- package/dist/src/storage/sqlite/context-consolidation-repository.js +0 -64
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +0 -217
- package/dist/src/storage/sqlite/memory-records-repository.js +0 -715
- package/dist/src/storage/sqlite/remote-context-repository.d.ts +0 -3
- package/dist/src/storage/sqlite/remote-context-repository.js +0 -40
- package/dist/src/storage/sqlite/understanding-focus-exclusions.d.ts +0 -2
- package/dist/src/storage/sqlite/understanding-focus-exclusions.js +0 -24
- package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +0 -49
- package/dist/src/storage/sqlite/user-context-quality-repository.js +0 -118
- package/dist/src/storage/sqlite/user-context-repository.d.ts +0 -85
- package/dist/src/storage/sqlite/user-context-repository.js +0 -535
- package/dist/src/user-context/automatic-context.d.ts +0 -17
- package/dist/src/user-context/automatic-context.js +0 -85
- package/dist/src/user-context/consolidation.d.ts +0 -27
- package/dist/src/user-context/consolidation.js +0 -187
- package/dist/src/user-context/context-objects.d.ts +0 -17
- package/dist/src/user-context/context-objects.js +0 -99
- package/dist/src/user-context/evaluation/harness.d.ts +0 -13
- package/dist/src/user-context/evaluation/harness.js +0 -31
- package/dist/src/user-context/extraction/executor.d.ts +0 -22
- package/dist/src/user-context/extraction/executor.js +0 -142
- package/dist/src/user-context/extraction/repair.d.ts +0 -19
- package/dist/src/user-context/extraction/repair.js +0 -71
- package/dist/src/user-context/extraction/semantic.d.ts +0 -18
- package/dist/src/user-context/extraction/semantic.js +0 -148
- package/dist/src/user-context/focus-lifecycle.d.ts +0 -2
- package/dist/src/user-context/focus-lifecycle.js +0 -26
- package/dist/src/user-context/manual-understanding.d.ts +0 -12
- package/dist/src/user-context/manual-understanding.js +0 -37
- package/dist/src/user-context/planner.d.ts +0 -17
- package/dist/src/user-context/planner.js +0 -465
- package/dist/src/user-context/relationships/indexer.d.ts +0 -13
- package/dist/src/user-context/relationships/indexer.js +0 -185
- package/dist/src/user-context/relationships/service.d.ts +0 -22
- package/dist/src/user-context/relationships/service.js +0 -50
- package/dist/src/user-context/retriever.d.ts +0 -15
- package/dist/src/user-context/retriever.js +0 -124
- package/dist/src/user-context/scope.d.ts +0 -7
- package/dist/src/user-context/scope.js +0 -9
- package/dist/src/user-context/selection-policy.d.ts +0 -20
- package/dist/src/user-context/selection-policy.js +0 -33
- package/dist/src/user-context/understanding.d.ts +0 -15
- package/dist/src/user-context/understanding.js +0 -24
- package/dist/src/user-context/understandingQuality.d.ts +0 -5
- package/dist/src/user-context/understandingQuality.js +0 -48
- /package/dist/src/agent/{memory/context/types.js → context/execution-context.types.js} +0 -0
- /package/dist/src/{agent/memory/understanding/types.js → knowledge-memory/domain.js} +0 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { getSqliteDatabase } from "../../storage/sqlite/transaction.js";
|
|
2
|
+
import { listCollaborationRules } from "../../storage/sqlite/collaboration-rule-repository.js";
|
|
3
|
+
import { searchKnowledgeItems } from "../../knowledge-memory/repository.js";
|
|
4
|
+
import "../../knowledge-memory/index.js";
|
|
5
|
+
import { retrievalLexicalSimilarity } from "../../retrieval/textFeatures.js";
|
|
6
|
+
import { calculateExecutionValue } from "../../user-model/importance.js";
|
|
7
|
+
import { listUserAssertions } from "../../user-model/repository.js";
|
|
8
|
+
import { getExecutionContextFeedbackScores } from "./audit.js";
|
|
9
|
+
import { buildUserContextBlock } from "../memory/context-fence.js";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
//#region src/agent/context/execution-context.ts
|
|
12
|
+
function scopeVisible(scope, context) {
|
|
13
|
+
if (scope.type === "global") return true;
|
|
14
|
+
return scope.id === {
|
|
15
|
+
agent: context.agentId,
|
|
16
|
+
workspace: context.workspaceId,
|
|
17
|
+
project: context.projectId,
|
|
18
|
+
session: context.sessionId
|
|
19
|
+
}[scope.type];
|
|
20
|
+
}
|
|
21
|
+
function applicabilityVisible(applicability, context) {
|
|
22
|
+
const operation = applicability.operation;
|
|
23
|
+
if (typeof operation === "string" && operation !== "response") return false;
|
|
24
|
+
if (Array.isArray(operation) && !operation.some((value) => value === "response")) return false;
|
|
25
|
+
for (const [key, actual] of [
|
|
26
|
+
["agentId", context.agentId],
|
|
27
|
+
["workspaceId", context.workspaceId],
|
|
28
|
+
["projectId", context.projectId],
|
|
29
|
+
["sessionId", context.sessionId]
|
|
30
|
+
]) {
|
|
31
|
+
const expected = applicability[key];
|
|
32
|
+
if (typeof expected === "string" && expected !== actual) return false;
|
|
33
|
+
if (Array.isArray(expected) && !expected.some((value) => typeof value === "string" && value === actual)) return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
function urgency(assertion, asOf) {
|
|
38
|
+
const deadline = assertion.validTo ?? assertion.reviewAt;
|
|
39
|
+
if (deadline === void 0) return 0;
|
|
40
|
+
const remaining = deadline - asOf;
|
|
41
|
+
if (remaining <= 0) return 1;
|
|
42
|
+
return Math.max(0, 1 - remaining / (720 * 60 * 60 * 1e3));
|
|
43
|
+
}
|
|
44
|
+
function rankAssertion(assertion, query, asOf, feedbackScore) {
|
|
45
|
+
const taskRelevance = retrievalLexicalSimilarity(query, `${assertion.statement} ${assertion.normalizedValue}`);
|
|
46
|
+
return {
|
|
47
|
+
assertion,
|
|
48
|
+
score: calculateExecutionValue({
|
|
49
|
+
declaredImportance: assertion.declaredImportance,
|
|
50
|
+
inferredImportance: assertion.inferredImportance,
|
|
51
|
+
consequence: assertion.consequence,
|
|
52
|
+
actionability: assertion.actionability,
|
|
53
|
+
taskRelevance,
|
|
54
|
+
urgency: urgency(assertion, asOf)
|
|
55
|
+
}) + feedbackScore,
|
|
56
|
+
reasons: [
|
|
57
|
+
taskRelevance >= .35 ? "task_relevant" : "",
|
|
58
|
+
assertion.declaredImportance !== void 0 ? "user_declared_importance" : "",
|
|
59
|
+
assertion.consequence === "critical" || assertion.consequence === "high" ? "high_consequence" : "",
|
|
60
|
+
assertion.kind === "identity" || assertion.kind === "preference" ? "stable_personalization" : "",
|
|
61
|
+
feedbackScore > 0 ? "historically_helpful" : "",
|
|
62
|
+
feedbackScore < 0 ? "historically_irrelevant" : ""
|
|
63
|
+
].filter(Boolean)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function ruleEnforcement(conditions) {
|
|
67
|
+
const value = conditions.enforcementLevel;
|
|
68
|
+
return value === "planner" || value === "tool_gate" ? value : "prompt";
|
|
69
|
+
}
|
|
70
|
+
function loadRules(context) {
|
|
71
|
+
return listCollaborationRules().filter((rule) => rule.status === "active" && scopeVisible(rule.scope, context)).map((rule) => ({
|
|
72
|
+
id: rule.id,
|
|
73
|
+
statement: rule.statement,
|
|
74
|
+
priority: rule.priority,
|
|
75
|
+
enforcementLevel: ruleEnforcement(rule.conditions),
|
|
76
|
+
conditions: rule.conditions
|
|
77
|
+
})).sort((left, right) => left.priority - right.priority);
|
|
78
|
+
}
|
|
79
|
+
function loadGoals(context, asOf) {
|
|
80
|
+
return getSqliteDatabase().prepare(`SELECT g.goal_id, g.status, g.declared_importance,
|
|
81
|
+
g.target_at, g.scope_type, g.scope_id, r.title, r.desired_outcome
|
|
82
|
+
FROM user_goals g JOIN user_goal_revisions r ON r.revision_id = g.current_revision_id
|
|
83
|
+
WHERE g.principal_id = 'local-owner' AND g.status IN ('active', 'proposed')
|
|
84
|
+
AND (g.valid_from IS NULL OR g.valid_from <= ?)
|
|
85
|
+
AND (g.valid_to IS NULL OR g.valid_to >= ?)
|
|
86
|
+
ORDER BY COALESCE(g.declared_importance, 0) DESC, g.updated_at DESC LIMIT 30`).all(asOf, asOf).filter((row) => scopeVisible({
|
|
87
|
+
type: row.scope_type,
|
|
88
|
+
...row.scope_id ? { id: row.scope_id } : {}
|
|
89
|
+
}, context)).map((row) => ({
|
|
90
|
+
id: row.goal_id,
|
|
91
|
+
title: row.title,
|
|
92
|
+
desiredOutcome: row.desired_outcome,
|
|
93
|
+
status: row.status,
|
|
94
|
+
...row.declared_importance === null ? {} : { declaredImportance: row.declared_importance },
|
|
95
|
+
...row.target_at === null ? {} : { targetAt: row.target_at }
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
function loadPriorities(context, asOf) {
|
|
99
|
+
return getSqliteDatabase().prepare(`SELECT priority_id, target_type, target_id, rank, urgency,
|
|
100
|
+
valid_to, scope_type, scope_id FROM user_priority_windows
|
|
101
|
+
WHERE principal_id = 'local-owner' AND status = 'active' AND valid_from <= ? AND valid_to >= ?
|
|
102
|
+
ORDER BY CASE rank WHEN 'primary' THEN 0 WHEN 'secondary' THEN 1 ELSE 2 END, urgency DESC LIMIT 30`).all(asOf, asOf).filter((row) => scopeVisible({
|
|
103
|
+
type: row.scope_type,
|
|
104
|
+
...row.scope_id ? { id: row.scope_id } : {}
|
|
105
|
+
}, context)).map((row) => ({
|
|
106
|
+
id: row.priority_id,
|
|
107
|
+
targetType: row.target_type,
|
|
108
|
+
targetId: row.target_id,
|
|
109
|
+
rank: row.rank,
|
|
110
|
+
urgency: row.urgency,
|
|
111
|
+
validTo: row.valid_to
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
function buildExecutionContext(request) {
|
|
115
|
+
const asOf = request.asOf ?? Date.now();
|
|
116
|
+
const includeUserModel = request.includeUserModel !== false;
|
|
117
|
+
const feedbackScores = getExecutionContextFeedbackScores();
|
|
118
|
+
const assertions = includeUserModel ? listUserAssertions({
|
|
119
|
+
statuses: ["active"],
|
|
120
|
+
limit: 1e3
|
|
121
|
+
}).filter((item) => scopeVisible(getAssertionScope(item.slotId), request)).filter((item) => applicabilityVisible(item.applicability, request)).filter((item) => (item.validFrom === void 0 || item.validFrom <= asOf) && (item.validTo === void 0 || item.validTo >= asOf)).filter((item) => item.authority !== "external_untrusted").filter((item) => item.sensitivity !== "secret" && item.sensitivity !== "regulated" && item.disclosurePolicy !== "ask_before_reference").map((item) => rankAssertion(item, request.query, asOf, feedbackScores.get(`assertion:${item.id}`) ?? 0)).filter((item) => item.score >= .12 || item.reasons.includes("high_consequence")).sort((left, right) => right.score - left.score).slice(0, Math.max(1, Math.min(100, request.maxAssertions ?? 20))) : [];
|
|
122
|
+
const maxKnowledge = Math.max(0, Math.min(100, request.maxKnowledge ?? 12));
|
|
123
|
+
const knowledge = request.includeKnowledge === false || maxKnowledge === 0 ? [] : searchKnowledgeItems({
|
|
124
|
+
query: request.query,
|
|
125
|
+
context: request,
|
|
126
|
+
asOf,
|
|
127
|
+
trustedOnly: true,
|
|
128
|
+
sources: request.knowledgeSources,
|
|
129
|
+
limit: Math.min(100, maxKnowledge * 2)
|
|
130
|
+
}).map((item) => ({
|
|
131
|
+
item,
|
|
132
|
+
score: retrievalLexicalSimilarity(request.query, item.content) * .7 + item.importance * .3 + (feedbackScores.get(`knowledge:${item.id}`) ?? 0)
|
|
133
|
+
})).sort((left, right) => right.score - left.score).slice(0, maxKnowledge).map(({ item }) => item);
|
|
134
|
+
return {
|
|
135
|
+
traceId: randomUUID(),
|
|
136
|
+
asOf,
|
|
137
|
+
query: request.query,
|
|
138
|
+
rules: includeUserModel ? loadRules(request) : [],
|
|
139
|
+
assertions,
|
|
140
|
+
goals: includeUserModel ? loadGoals(request, asOf) : [],
|
|
141
|
+
priorities: includeUserModel ? loadPriorities(request, asOf) : [],
|
|
142
|
+
knowledge
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function getAssertionScope(slotId) {
|
|
146
|
+
const row = getSqliteDatabase().prepare(`SELECT scope_type, scope_id FROM user_assertion_slots
|
|
147
|
+
WHERE slot_id = ?`).get(slotId);
|
|
148
|
+
return {
|
|
149
|
+
type: row.scope_type,
|
|
150
|
+
...row.scope_id ? { id: row.scope_id } : {}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function renderExecutionContext(context) {
|
|
154
|
+
const sections = [];
|
|
155
|
+
if (context.rules.length) sections.push(`Collaboration rules:\n${context.rules.map((rule) => `- ${rule.statement}`).join("\n")}`);
|
|
156
|
+
if (context.assertions.length) sections.push(`Relevant user facts:\n${context.assertions.map((item) => `- ${item.assertion.statement}`).join("\n")}`);
|
|
157
|
+
if (context.goals.length) sections.push(`Active goals:\n${context.goals.map((goal) => `- ${goal.title}: ${goal.desiredOutcome}`).join("\n")}`);
|
|
158
|
+
if (context.priorities.length) sections.push(`Current priorities:\n${context.priorities.map((item) => `- ${item.rank}: ${item.targetType}/${item.targetId}`).join("\n")}`);
|
|
159
|
+
if (context.knowledge.length) sections.push(`Relevant knowledge:\n${context.knowledge.map((item) => `- ${item.content}`).join("\n")}`);
|
|
160
|
+
return sections.join("\n\n");
|
|
161
|
+
}
|
|
162
|
+
function fitExecutionContextToChars(context, maxChars) {
|
|
163
|
+
const selected = {
|
|
164
|
+
...context,
|
|
165
|
+
rules: [],
|
|
166
|
+
assertions: [],
|
|
167
|
+
goals: [],
|
|
168
|
+
priorities: [],
|
|
169
|
+
knowledge: []
|
|
170
|
+
};
|
|
171
|
+
const fits = () => buildUserContextBlock(renderExecutionContext(selected)).length <= maxChars;
|
|
172
|
+
for (const item of context.rules) {
|
|
173
|
+
selected.rules.push(item);
|
|
174
|
+
if (!fits()) selected.rules.pop();
|
|
175
|
+
}
|
|
176
|
+
for (const item of context.assertions) {
|
|
177
|
+
selected.assertions.push(item);
|
|
178
|
+
if (!fits()) selected.assertions.pop();
|
|
179
|
+
}
|
|
180
|
+
for (const item of context.goals) {
|
|
181
|
+
selected.goals.push(item);
|
|
182
|
+
if (!fits()) selected.goals.pop();
|
|
183
|
+
}
|
|
184
|
+
for (const item of context.priorities) {
|
|
185
|
+
selected.priorities.push(item);
|
|
186
|
+
if (!fits()) selected.priorities.pop();
|
|
187
|
+
}
|
|
188
|
+
for (const item of context.knowledge) {
|
|
189
|
+
selected.knowledge.push(item);
|
|
190
|
+
if (!fits()) selected.knowledge.pop();
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
context: selected,
|
|
194
|
+
rendered: buildUserContextBlock(renderExecutionContext(selected))
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function evaluateToolGate(context, operation) {
|
|
198
|
+
for (const rule of context.rules) {
|
|
199
|
+
if (rule.enforcementLevel !== "tool_gate") continue;
|
|
200
|
+
const operations = Array.isArray(rule.conditions.operationTypes) ? rule.conditions.operationTypes.filter((item) => typeof item === "string") : [];
|
|
201
|
+
if (operations.length && !operations.includes(operation)) continue;
|
|
202
|
+
if (rule.conditions.effect === "deny") return {
|
|
203
|
+
allowed: false,
|
|
204
|
+
rule,
|
|
205
|
+
reason: rule.statement
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return { allowed: true };
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
export { buildExecutionContext, evaluateToolGate, fitExecutionContextToChars, renderExecutionContext };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { KnowledgeItem, KnowledgeSource, KnowledgeVisibilityContext } from '../../knowledge-memory/index.js';
|
|
2
|
+
import type { UserAssertion } from '../../user-model/domain.js';
|
|
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
|
+
includeUserModel?: boolean;
|
|
48
|
+
includeKnowledge?: boolean;
|
|
49
|
+
knowledgeSources?: readonly KnowledgeSource[];
|
|
50
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { KnowledgeSource } from '../../knowledge-memory/index.js';
|
|
1
2
|
export type ExecutionObjective = {
|
|
2
3
|
kind: 'task';
|
|
3
4
|
id: string;
|
|
@@ -23,4 +24,7 @@ export interface ExecutionScope {
|
|
|
23
24
|
}
|
|
24
25
|
export declare function resolveExecutionScope(sessionKey: string): ExecutionScope;
|
|
25
26
|
export declare function formatCurrentWorkForPrompt(scope: ExecutionScope): string | undefined;
|
|
26
|
-
export declare function buildExecutionScopeContextForPrompt(sessionKey: string
|
|
27
|
+
export declare function buildExecutionScopeContextForPrompt(sessionKey: string, options?: {
|
|
28
|
+
includeKnowledge?: boolean;
|
|
29
|
+
knowledgeSources?: readonly KnowledgeSource[];
|
|
30
|
+
}): string | undefined;
|
|
@@ -77,9 +77,13 @@ function formatCurrentWorkForPrompt(scope) {
|
|
|
77
77
|
lines.push("", "Keep work inside this objective and its project scope. Treat the acceptance criteria and completion evidence as the definition of done.");
|
|
78
78
|
return lines.join("\n");
|
|
79
79
|
}
|
|
80
|
-
function buildExecutionScopeContextForPrompt(sessionKey) {
|
|
80
|
+
function buildExecutionScopeContextForPrompt(sessionKey, options = {}) {
|
|
81
81
|
const scope = resolveExecutionScope(sessionKey);
|
|
82
|
-
return [buildActiveProjectContextForPrompt(sessionKey, {
|
|
82
|
+
return [buildActiveProjectContextForPrompt(sessionKey, {
|
|
83
|
+
knowledgeQuery: scope.objective?.objective,
|
|
84
|
+
includeKnowledge: options.includeKnowledge,
|
|
85
|
+
knowledgeSources: options.knowledgeSources
|
|
86
|
+
}), formatCurrentWorkForPrompt(scope)].filter((section) => Boolean(section?.trim())).join("\n\n") || void 0;
|
|
83
87
|
}
|
|
84
88
|
//#endregion
|
|
85
89
|
export { buildExecutionScopeContextForPrompt, formatCurrentWorkForPrompt, resolveExecutionScope };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readAgentMessageContent } from "../memory/agent-message-access.js";
|
|
2
|
+
//#region src/agent/context/prepend.ts
|
|
3
|
+
function prependAgentContext(message, block) {
|
|
4
|
+
if (!block) return message;
|
|
5
|
+
const prefix = `${block}\n\n`;
|
|
6
|
+
const content = readAgentMessageContent(message);
|
|
7
|
+
if (typeof content === "string") return {
|
|
8
|
+
...message,
|
|
9
|
+
content: prefix + content
|
|
10
|
+
};
|
|
11
|
+
if (!Array.isArray(content)) return message;
|
|
12
|
+
const copy = [...content];
|
|
13
|
+
const first = copy[0];
|
|
14
|
+
if (first?.type === "text" && typeof first.text === "string") copy[0] = {
|
|
15
|
+
type: "text",
|
|
16
|
+
text: prefix + first.text
|
|
17
|
+
};
|
|
18
|
+
else copy.unshift({
|
|
19
|
+
type: "text",
|
|
20
|
+
text: prefix
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
...message,
|
|
24
|
+
content: copy
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { prependAgentContext };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Project } from '../../projects/types.js';
|
|
2
|
+
import { type KnowledgeSource } from '../../knowledge-memory/index.js';
|
|
2
3
|
export interface ProjectTaskContext {
|
|
3
4
|
title: string;
|
|
4
5
|
state: string;
|
|
5
6
|
priority: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function buildActiveProjectContextForPrompt(sessionKey: string, options?: {
|
|
8
|
-
|
|
9
|
+
knowledgeQuery?: string;
|
|
10
|
+
includeKnowledge?: boolean;
|
|
11
|
+
knowledgeSources?: readonly KnowledgeSource[];
|
|
9
12
|
}): string | undefined;
|
|
10
13
|
export declare function formatActiveProjectContextForPrompt(input: {
|
|
11
14
|
project: Project;
|
|
@@ -17,10 +20,10 @@ export declare function formatActiveProjectContextForPrompt(input: {
|
|
|
17
20
|
updatedAt: string;
|
|
18
21
|
agentId: string;
|
|
19
22
|
}>;
|
|
20
|
-
|
|
23
|
+
knowledgeItems?: Array<{
|
|
21
24
|
kind: string;
|
|
22
25
|
content: string;
|
|
23
|
-
updatedAt:
|
|
26
|
+
updatedAt: number;
|
|
24
27
|
}>;
|
|
25
28
|
localApp?: {
|
|
26
29
|
extensionId: string;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { listMemoryRecords, searchMemoryRecords } from "../../storage/sqlite/memory-records-repository.js";
|
|
2
|
-
import "../../storage/sqlite/index.js";
|
|
3
1
|
import { sanitizeForPromptLiteral } from "../prompt/sanitize-for-prompt.js";
|
|
4
2
|
import { TaskRepository } from "../../tasks/task-repository.js";
|
|
5
3
|
import { TaskReadModelProjector } from "../../tasks/task-read-model-projector.js";
|
|
6
4
|
import { LocalAppStore } from "../../local-apps/store.js";
|
|
7
5
|
import { ProjectStore } from "../../projects/project-store.js";
|
|
8
6
|
import { getProjectForSession, getProjectWorkspacePathForSession } from "../../projects/workspace.js";
|
|
7
|
+
import { knowledgeSourceAllowed, listKnowledgeItems, searchKnowledgeItems } from "../../knowledge-memory/repository.js";
|
|
8
|
+
import "../../knowledge-memory/index.js";
|
|
9
9
|
//#region src/agent/context/project-context.ts
|
|
10
10
|
const MAX_TEXT = 1200;
|
|
11
11
|
const MAX_TASKS = 5;
|
|
12
12
|
const MAX_SESSIONS = 5;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const MAX_RECENT_KNOWLEDGE = 5;
|
|
14
|
+
const MAX_RELEVANT_KNOWLEDGE = 5;
|
|
15
|
+
const MAX_KNOWLEDGE = 8;
|
|
16
16
|
function truncateText(value, max = MAX_TEXT) {
|
|
17
17
|
const trimmed = value?.trim();
|
|
18
18
|
if (!trimmed) return void 0;
|
|
@@ -26,11 +26,11 @@ function formatTask(task) {
|
|
|
26
26
|
`priority=${task.priority}`
|
|
27
27
|
].join(" | ");
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function selectProjectKnowledge(input) {
|
|
30
30
|
const selected = /* @__PURE__ */ new Map();
|
|
31
31
|
for (const record of [...input.relevant, ...input.recent]) {
|
|
32
32
|
if (!selected.has(record.id)) selected.set(record.id, record);
|
|
33
|
-
if (selected.size >=
|
|
33
|
+
if (selected.size >= MAX_KNOWLEDGE) break;
|
|
34
34
|
}
|
|
35
35
|
return [...selected.values()];
|
|
36
36
|
}
|
|
@@ -49,18 +49,23 @@ function buildActiveProjectContextForPrompt(sessionKey, options = {}) {
|
|
|
49
49
|
state: `${task.phase}/${new TaskReadModelProjector().project(task).operationalState}`
|
|
50
50
|
})),
|
|
51
51
|
recentSessions: new ProjectStore().getRecentSessions(project.id, MAX_SESSIONS),
|
|
52
|
-
|
|
53
|
-
relevant: options.
|
|
54
|
-
query: options.
|
|
55
|
-
|
|
52
|
+
knowledgeItems: options.includeKnowledge === false ? [] : selectProjectKnowledge({
|
|
53
|
+
relevant: options.knowledgeQuery?.trim() ? searchKnowledgeItems({
|
|
54
|
+
query: options.knowledgeQuery,
|
|
55
|
+
context: {
|
|
56
|
+
agentId: project.defaultAgentId ?? "main",
|
|
57
|
+
workspaceId: project.workspaceRoot ?? "",
|
|
58
|
+
projectId: project.id,
|
|
59
|
+
sessionId: sessionKey
|
|
60
|
+
},
|
|
61
|
+
trustedOnly: true,
|
|
62
|
+
sources: options.knowledgeSources,
|
|
63
|
+
limit: MAX_RELEVANT_KNOWLEDGE
|
|
64
|
+
}) : [],
|
|
65
|
+
recent: listKnowledgeItems({
|
|
56
66
|
statuses: ["active"],
|
|
57
|
-
|
|
58
|
-
}).
|
|
59
|
-
recent: listMemoryRecords({
|
|
60
|
-
projectId: project.id,
|
|
61
|
-
status: "active",
|
|
62
|
-
limit: MAX_RECENT_MEMORY
|
|
63
|
-
})
|
|
67
|
+
limit: 500
|
|
68
|
+
}).filter((item) => item.scope.type === "project" && item.scope.id === project.id).filter((item) => item.originClass !== "untrusted").filter((item) => !options.knowledgeSources || knowledgeSourceAllowed(item, options.knowledgeSources)).slice(0, MAX_RECENT_KNOWLEDGE)
|
|
64
69
|
}),
|
|
65
70
|
localApp: localApp ? {
|
|
66
71
|
extensionId: localApp.extensionId,
|
|
@@ -107,12 +112,12 @@ function formatActiveProjectContextForPrompt(input) {
|
|
|
107
112
|
const label = sanitizeForPromptLiteral(session.name?.trim() || session.key);
|
|
108
113
|
lines.push(`- ${label} | agent=${sanitizeForPromptLiteral(session.agentId)} | updated=${sanitizeForPromptLiteral(session.updatedAt)}`);
|
|
109
114
|
}
|
|
110
|
-
lines.push("", "## Project
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
else for (const record of
|
|
115
|
+
lines.push("", "## Project Knowledge");
|
|
116
|
+
const knowledgeItems = input.knowledgeItems ?? [];
|
|
117
|
+
if (knowledgeItems.length === 0) lines.push("- None recorded.");
|
|
118
|
+
else for (const record of knowledgeItems) {
|
|
114
119
|
const content = sanitizeForPromptLiteral(truncateText(record.content, 240) ?? "");
|
|
115
|
-
lines.push(`- ${sanitizeForPromptLiteral(record.kind)} | updated=${
|
|
120
|
+
lines.push(`- ${sanitizeForPromptLiteral(record.kind)} | updated=${new Date(record.updatedAt).toISOString()} | ${content}`);
|
|
116
121
|
}
|
|
117
122
|
return lines.join("\n");
|
|
118
123
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getEmbeddedExecutionSession, runWithEmbeddedExecutionSession } from "./execution-context.js";
|
|
1
2
|
import { abortEmbeddedRun, getEmbeddedRunBySessionKey, queueEmbeddedSteer } from "./runs.js";
|
|
2
3
|
import { DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, resolveLiveToolResultMaxChars, truncateToolResultMessage } from "./tool-result-truncation.js";
|
|
3
4
|
import { getRawSessionAppendMessage, guardSessionManager, installSessionToolResultGuard } from "./session-tool-result-guard.js";
|
|
@@ -6,7 +7,6 @@ import { repairAssistantUsageInSessionManager } from "./session-manager-init.js"
|
|
|
6
7
|
import { openSqliteHydratingSessionManager } from "./sqlite-hydrating-session-manager.js";
|
|
7
8
|
import { InMemoryTranscriptRuntime, createSqliteTranscriptRuntime } from "./transcript-runtime.js";
|
|
8
9
|
import { runXopcEmbeddedTurn } from "./run-turn.js";
|
|
9
|
-
import { getEmbeddedExecutionSession, runWithEmbeddedExecutionSession } from "./execution-context.js";
|
|
10
10
|
import { runEmbeddedTurnForSession } from "./run-for-session.js";
|
|
11
11
|
import { CURRENT_SESSION_VERSION, PiTranscriptManager } from "./pi-transcript.js";
|
|
12
12
|
export { CURRENT_SESSION_VERSION, DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, InMemoryTranscriptRuntime, PiTranscriptManager, abortEmbeddedRun, acquireEmbeddedSessionRunner, buildEmbeddedRunnerFingerprint, createSqliteTranscriptRuntime, evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner, getEmbeddedExecutionSession, getEmbeddedRunBySessionKey, getEmbeddedSessionRunnerIdleTtlMs, getEmbeddedSessionRunnerStats, getRawSessionAppendMessage, guardSessionManager, installSessionToolResultGuard, isEmbeddedSessionRunnerEnabled, openSqliteHydratingSessionManager, queueEmbeddedSteer, repairAssistantUsageInSessionManager, resetEmbeddedSessionRunnerForTest, resolveLiveToolResultMaxChars, runEmbeddedTurnForSession, runWithEmbeddedExecutionSession, runXopcEmbeddedTurn, truncateToolResultMessage };
|
|
@@ -27,6 +27,7 @@ async function runEmbeddedTurnForSession(params) {
|
|
|
27
27
|
parentSignal: params.abortSignal
|
|
28
28
|
});
|
|
29
29
|
const finish = async (result) => {
|
|
30
|
+
if (result.stopReason === "connection_required") return result;
|
|
30
31
|
try {
|
|
31
32
|
const rows = await sessionStore.loadTranscriptRows(sessionKey);
|
|
32
33
|
const hasTurn = rows.some((source) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { getConnectionResumeInput, isConnectionSuspended } from "../../storage/sqlite/connection-wait-repository.js";
|
|
3
4
|
import { EmbeddedRunConflictError, abortEmbeddedRun, acquireEmbeddedRunLease, queueEmbeddedSteer } from "./runs.js";
|
|
4
5
|
import { lastAssistantPlainText, subscribeEmbeddedSessionEvents } from "./subscribe-session.js";
|
|
5
6
|
import { isContextOverflowError } from "../orchestration/context-overflow.js";
|
|
@@ -233,8 +234,14 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
233
234
|
...await verification.summary()
|
|
234
235
|
});
|
|
235
236
|
let policyStopped = false;
|
|
237
|
+
let connectionStopped = false;
|
|
236
238
|
params.turnPolicy?.reset();
|
|
237
239
|
session.agent.beforeToolCall = async (context, signal) => {
|
|
240
|
+
if (connectionStopped) return {
|
|
241
|
+
block: true,
|
|
242
|
+
reason: "Waiting for the user to connect an app.",
|
|
243
|
+
terminate: true
|
|
244
|
+
};
|
|
238
245
|
const decision = await params.turnPolicy?.beforeToolCall(context, signal);
|
|
239
246
|
if (decision?.block) {
|
|
240
247
|
policyStopped ||= decision.terminate === true;
|
|
@@ -251,6 +258,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
251
258
|
return decision;
|
|
252
259
|
};
|
|
253
260
|
session.agent.afterToolCall = async (context) => {
|
|
261
|
+
connectionStopped ||= isConnectionSuspended(sessionKey, runId);
|
|
254
262
|
const scoped = context.toolCall.name === "read_file" ? await instructions.forTool(context.toolCall.name, context.args) : "";
|
|
255
263
|
const checked = await verification.afterTool(context);
|
|
256
264
|
if (scoped) checked.result.content.unshift({
|
|
@@ -265,7 +273,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
265
273
|
};
|
|
266
274
|
session.agent.shouldStopAfterTurn = (context) => {
|
|
267
275
|
policyStopped ||= params.turnPolicy?.shouldStopAfterTurn(context) ?? false;
|
|
268
|
-
return policyStopped;
|
|
276
|
+
return policyStopped || connectionStopped;
|
|
269
277
|
};
|
|
270
278
|
unsubscribe = subscribeEmbeddedSessionEvents(session, (event) => {
|
|
271
279
|
if (event.type === "message_end" && event.message.role === "assistant") recordPromptCacheTouch(sessionKey, resolvedModel, event.message.usage);
|
|
@@ -281,13 +289,20 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
281
289
|
runAbortSignal.addEventListener("abort", abortListener, { once: true });
|
|
282
290
|
try {
|
|
283
291
|
await runAgentTurnWithTimeout(session.agent, async () => {
|
|
284
|
-
|
|
292
|
+
const connectionResume = getConnectionResumeInput(sessionKey, runId);
|
|
293
|
+
if (connectionResume) await session.sendCustomMessage({
|
|
294
|
+
customType: "connection_resume",
|
|
295
|
+
content: connectionResume.content,
|
|
296
|
+
display: false
|
|
297
|
+
}, { triggerTurn: true });
|
|
298
|
+
else if (params.resumeLastUserMessage) await session.agent.continue();
|
|
285
299
|
else {
|
|
286
300
|
const text = userMessageToPromptText(userMessage);
|
|
287
301
|
const images = params.images ?? [];
|
|
288
302
|
await session.prompt(text, images.length > 0 ? { images } : void 0);
|
|
289
303
|
}
|
|
290
304
|
await session.agent.waitForIdle();
|
|
305
|
+
if (connectionStopped) return;
|
|
291
306
|
await maybeRetryTurnAfterTransientLlmFailure(session.agent, {
|
|
292
307
|
sessionKey,
|
|
293
308
|
log,
|
|
@@ -311,6 +326,10 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
311
326
|
await session.agent.waitForIdle();
|
|
312
327
|
}
|
|
313
328
|
}, timeoutMs);
|
|
329
|
+
if (connectionStopped) runner.piSm.appendCustomEntry("connection_required", {
|
|
330
|
+
runId,
|
|
331
|
+
sessionKey
|
|
332
|
+
});
|
|
314
333
|
runner.piSm.appendCustomEntry("coding_verification", {
|
|
315
334
|
runId,
|
|
316
335
|
workspace: workspaceDir,
|
|
@@ -337,6 +356,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
337
356
|
});
|
|
338
357
|
return {
|
|
339
358
|
ok: true,
|
|
359
|
+
...connectionStopped ? { stopReason: "connection_required" } : {},
|
|
340
360
|
lastAssistantText: lastAssistantPlainText(session)
|
|
341
361
|
};
|
|
342
362
|
} finally {
|
|
@@ -48,31 +48,6 @@ export type EmbeddedStreamEvent = {
|
|
|
48
48
|
runId?: string;
|
|
49
49
|
stage: string;
|
|
50
50
|
message: string;
|
|
51
|
-
} | {
|
|
52
|
-
type: 'memory_consent_required';
|
|
53
|
-
runId?: string;
|
|
54
|
-
requests: Array<{
|
|
55
|
-
id: string;
|
|
56
|
-
recordId: string;
|
|
57
|
-
statement: string;
|
|
58
|
-
purpose: string;
|
|
59
|
-
}>;
|
|
60
|
-
} | {
|
|
61
|
-
type: 'memory_captured';
|
|
62
|
-
runId?: string;
|
|
63
|
-
records: Array<{
|
|
64
|
-
id: string;
|
|
65
|
-
content: string;
|
|
66
|
-
kind: string;
|
|
67
|
-
}>;
|
|
68
|
-
} | {
|
|
69
|
-
type: 'memory_candidate';
|
|
70
|
-
runId?: string;
|
|
71
|
-
records: Array<{
|
|
72
|
-
id: string;
|
|
73
|
-
content: string;
|
|
74
|
-
kind: string;
|
|
75
|
-
}>;
|
|
76
51
|
} | {
|
|
77
52
|
type: 'error';
|
|
78
53
|
runId?: string;
|
|
@@ -114,6 +89,7 @@ export type RunXopcEmbeddedTurnParams = {
|
|
|
114
89
|
};
|
|
115
90
|
export type RunXopcEmbeddedTurnResult = {
|
|
116
91
|
ok: boolean;
|
|
92
|
+
stopReason?: 'connection_required';
|
|
117
93
|
/** False for harness failures that must not trigger another model attempt. */
|
|
118
94
|
retryable?: boolean;
|
|
119
95
|
errorMessage?: string;
|