@xopcai/xopc 0.0.218 → 0.0.220
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-DF2dYXG1.js → activity-store-DeKZ36Jy.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dw9rF5o1.js → agent-avatar-dicebear-D0hZfdkn.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bu0NfWuh.js +68 -0
- package/dist/gateway/static/root/assets/{api-_H0Bam-t.js → api-yLnYUedB.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-C2kZNEHz.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-DQ7H35sN.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-Tty2xaUG.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DZCOhXch.js → archive-plugin-CBArbTPH.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Bjb0FH2B.js → attachment-load-oc6DRj4G.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D4N3ZDhu.js → automations-page-CHPEUpz8.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-9uYkHmdI.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-uXPt0s47.js → binary-plugins-BRBd0X7_.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-gukkIEro.js → block-editor-ZgM-Z4Qv.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-BT3mEm00.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-DAhdS-XZ.js → browser-workflow-inputs-DxD74a4c.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-LKjYzXS_.js → browser-workflows-page-Dpc7NqZf.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DHlfRj4M.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BBUkH833.js → capability-presets-api-B9ID97j6.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-D2FkREUX.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-E5mo8M3a.js → channel-recipient-api-DCNn6MWL.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-D4YcKMtf.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-B8XWrzKM.js +1 -0
- package/dist/gateway/static/root/assets/chat-terminal-dock-MvNpjcUs.js +36 -0
- package/dist/gateway/static/root/assets/connectors-page-Bd6K9bDk.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-BGNuaqvI.js → cron-expression-BSXX9uY0.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-k7mkklMU.js → date-picker-CiHNkkIS.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-DQyh2ZXE.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-p9EZyGzV.js → desktop-pet-DnAHU-zA.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DUdhIBBB.js +1 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-B3gFQt8x.js +1 -0
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-Cd4BMKm_.js → extension-debug-page-Lq-gRApw.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CzEGCkOa.js → extension-page-D0ROxJmY.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-B2tS6mFy.js +1 -0
- package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
- package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +1 -0
- package/dist/gateway/static/root/assets/file-code-corner-byQA1VfD.js +1 -0
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-DJqWfVi6.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DNrttVr2.js → gateway-config-swr-CnwF9Vso.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-B3thenPX.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B1vD3vRb.js → gateway-startup-retry-DdJJZR8M.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C_g-ZGSE.js +1 -0
- package/dist/gateway/static/root/assets/home-page-Cgwx66kc.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BTR0Wk_k.js → image-generation-api-Dtt9M5qz.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cf0qTkBK.css +2 -0
- package/dist/gateway/static/root/assets/index-V9g9-SWT.js +108 -0
- package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CYlS4RGA.js → keyboard-shortcuts-settings-cJqkmQdP.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CmjLMdly.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CNppYVew.js → local-apps-page-BiuP2pkl.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-gf9Bg2gb.js → locale-store-D3Q2yEAb.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BTlxGPho.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-IYk9xLgt.js → management-settings-Z1gJUwP_.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-D8e6pRMH.js → markdown-split-DuOmpGgE.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-D0fiJjBQ.js → markdown-view-WYArkdrc.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CCq6TtEf.js → media-plugins-DKPh3Mud.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BQHpB4VI.js +3 -0
- package/dist/gateway/static/root/assets/{notes-api-BBtWnlUU.js → notes-api-DMEon7Zv.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BKe1xa3U.js → notes-page-BG4gV8WG.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-D3LMBO2X.js +4 -0
- package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-DXe5iWI6.js → product-open-page-BjJf4QOB.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-C59tYJG-.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-Di7W-Fg8.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-xj5gOva_.js → registry-api-DRyvynb5.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BYOKveWT.js +1 -0
- package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BJTvmBCA.js → runtime-tools-settings-panel-DC6t_-db.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-DvGBa_7R.js → schema-form-DSTWtpjp.js} +1 -1
- package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-CJMNQsxK.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-FJxZw08y.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-ZzEMNLYS.js +1 -0
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-sbef7GTm.js → settings-loading-skeleton-D7-bkbcW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BNGxxXZe.js → settings-page-PaTpLbmi.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Bnpim6NY.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-C1523ij3.js → share-preview-page-Cxcw0ksa.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DBqmV7ZY.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-UgLQaWoz.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Dby4iAYe.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-Ditgz7Vo.js → skills-page.utils-nlzJ5Y1V.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-vOsgnzDl.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-CRy8Wl5g.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-DgSjes3O.js → theme-store-CvnEHGyP.js} +1 -1
- package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-Bp_qFZkl.js → use-autosave-BTNZHulv.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-BT8F4mh5.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-hbzDfErG.js → voice-api-key-field-DDJ2-3Tx.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DZVib-04.js → work-discovery-overlay-DV_qiKSD.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C2RKay1p.js → workflow-run-setup-panel--AcvRw1w.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CwvskVvU.js +5 -0
- package/dist/gateway/static/root/index.html +21 -12
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/new-session.js +99 -0
- package/dist/packages/gateway-contract/src/tasks.js +5 -0
- package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
- package/dist/src/agent/agent-manager.js +5 -4
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +2 -2
- package/dist/src/agent/background-review/run-background-review.js +144 -16
- 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/image/tool-model-config.js +1 -1
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
- package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/memory/context/types.d.ts +1 -1
- package/dist/src/agent/memory/manager.d.ts +2 -1
- package/dist/src/agent/memory/manager.js +2 -6
- package/dist/src/agent/memory/understanding/service.d.ts +1 -0
- package/dist/src/agent/memory/understanding/service.js +179 -36
- package/dist/src/agent/memory/understanding/types.d.ts +6 -0
- package/dist/src/agent/messaging/command-handler.d.ts +2 -0
- package/dist/src/agent/messaging/command-handler.js +3 -1
- package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
- package/dist/src/agent/service/direct-turn-helpers.js +13 -3
- package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
- package/dist/src/agent/service/process-direct-streaming.js +12 -11
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-config-service.d.ts +1 -0
- package/dist/src/agent/session/session-config-service.js +11 -0
- package/dist/src/agent/session/session-inspector.d.ts +1 -0
- package/dist/src/agent/session/session-inspector.js +2 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/source-context/budget.d.ts +3 -0
- package/dist/src/agent/source-context/budget.js +21 -0
- package/dist/src/agent/source-context/index.js +3 -3
- package/dist/src/agent/source-context/injector.d.ts +2 -2
- package/dist/src/agent/source-context/injector.js +19 -9
- package/dist/src/agent/source-context/types.d.ts +16 -0
- package/dist/src/agent/source-context/types.js +25 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
- package/dist/src/agent/tools/xopc-use-tool.js +62 -2
- 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/browser/backend-from-config.d.ts +8 -0
- package/dist/src/browser/backend-from-config.js +16 -1
- package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
- package/dist/src/browser/providers/browser-ext-install.js +5 -3
- package/dist/src/chat-commands/builtins/review.js +11 -2
- package/dist/src/chat-commands/builtins/understanding.js +11 -4
- package/dist/src/chat-commands/types.d.ts +4 -0
- 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.d.ts +20 -20
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
- package/dist/src/connectors/connected-source-understanding.js +87 -38
- package/dist/src/connectors/learning-coordinator.js +68 -13
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +18 -0
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
- package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
- package/dist/src/gateway/hono/routes/sessions.js +17 -20
- package/dist/src/gateway/hono/routes/tasks.js +25 -0
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +18 -0
- package/dist/src/gateway/hono/routes/understanding-sources.js +165 -36
- package/dist/src/gateway/hono/routes/work-discovery.js +13 -3
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/hono/routes/you.js +71 -4
- package/dist/src/gateway/service/agent-runner.d.ts +11 -2
- package/dist/src/gateway/service/agent-runner.js +27 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
- package/dist/src/gateway/service/run-gateway-agent.js +15 -9
- package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
- package/dist/src/gateway/service/session-input-coordinator.js +62 -3
- package/dist/src/gateway/service/sessions-api.d.ts +10 -0
- package/dist/src/gateway/service/sessions-api.js +3 -0
- package/dist/src/gateway/service.d.ts +3 -2
- package/dist/src/gateway/service.js +27 -16
- package/dist/src/gateway/user-turn-input.d.ts +2 -0
- package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
- package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
- package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +6 -0
- package/dist/src/knowledge/connected-knowledge-pipeline.js +35 -4
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
- package/dist/src/knowledge/connected-understanding-pipeline.js +4 -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/retrieval/queryProfile.d.ts +3 -0
- package/dist/src/retrieval/queryProfile.js +20 -2
- package/dist/src/session/client-history.d.ts +11 -0
- package/dist/src/session/client-history.js +24 -2
- package/dist/src/session/config-types.d.ts +1 -1
- package/dist/src/session/session-title.js +2 -3
- package/dist/src/session/store.js +1 -0
- package/dist/src/session/transcript-outline.js +5 -2
- package/dist/src/session/types.d.ts +1 -0
- package/dist/src/session/user-message-display.d.ts +4 -0
- package/dist/src/session/user-message-display.js +22 -0
- package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
- package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
- package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
- package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
- package/dist/src/storage/sqlite/index.d.ts +6 -4
- package/dist/src/storage/sqlite/index.js +7 -5
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +5 -1
- package/dist/src/storage/sqlite/knowledge-repository.js +16 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +21 -1
- package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
- package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
- package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
- package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
- package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
- package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
- package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -0
- package/dist/src/storage/sqlite/migrations/133_archive_legacy_work_discovery_profile_facts.sql +11 -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/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
- package/dist/src/storage/sqlite/session-input-repository.js +19 -7
- package/dist/src/storage/sqlite/session-repository.js +2 -2
- package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
- package/dist/src/storage/sqlite/transcript-repository.js +29 -3
- package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
- package/dist/src/storage/sqlite/user-context-repository.js +65 -29
- package/dist/src/tasks/home-query-service.d.ts +14 -0
- package/dist/src/tasks/home-query-service.js +19 -2
- package/dist/src/tasks/index.d.ts +1 -0
- package/dist/src/tasks/index.js +2 -1
- package/dist/src/tasks/task-deletion-service.d.ts +21 -0
- package/dist/src/tasks/task-deletion-service.js +35 -0
- package/dist/src/tasks/task-repository.js +22 -1
- package/dist/src/tui/backends/embedded-backend.js +5 -3
- package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
- package/dist/src/tui/chat-history.js +2 -1
- package/dist/src/tui/tui-agent-events.js +4 -2
- package/dist/src/tui/tui-commands.d.ts +1 -0
- package/dist/src/tui/tui-commands.js +8 -3
- package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
- package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
- package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
- package/dist/src/tui/tui-new-session-preferences.js +32 -0
- package/dist/src/tui/tui-session-actions.d.ts +1 -0
- package/dist/src/tui/tui-session-actions.js +2 -1
- package/dist/src/tui/tui-settings.d.ts +2 -0
- package/dist/src/tui/tui-settings.js +4 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui-types.d.ts +1 -0
- package/dist/src/tui/tui.js +58 -5
- package/dist/src/tunnel/frpc-process.js +3 -0
- package/dist/src/tunnel/tunnel-service.d.ts +2 -0
- package/dist/src/tunnel/tunnel-service.js +40 -28
- package/dist/src/user-context/consolidation.d.ts +1 -0
- package/dist/src/user-context/consolidation.js +62 -2
- package/dist/src/user-context/context-objects.d.ts +17 -0
- package/dist/src/user-context/context-objects.js +99 -0
- package/dist/src/user-context/domain.d.ts +13 -1
- package/dist/src/user-context/evaluation/harness.d.ts +13 -0
- package/dist/src/user-context/evaluation/harness.js +31 -0
- package/dist/src/user-context/extraction/registry.d.ts +26 -0
- package/dist/src/user-context/extraction/registry.js +113 -0
- package/dist/src/user-context/extraction/repair.d.ts +19 -0
- package/dist/src/user-context/extraction/repair.js +68 -0
- package/dist/src/user-context/focus-lifecycle.d.ts +2 -0
- package/dist/src/user-context/focus-lifecycle.js +26 -0
- package/dist/src/user-context/planner.js +252 -62
- package/dist/src/user-context/retriever.js +69 -9
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
- package/dist/src/user-context/sources/processing-policy.js +7 -0
- package/dist/src/user-context/sources/repository.d.ts +23 -4
- package/dist/src/user-context/sources/repository.js +122 -12
- package/dist/src/user-context/sources/types.d.ts +10 -1
- package/dist/src/user-context/understanding.js +1 -1
- package/dist/src/work-discovery/analyzer.js +6 -4
- package/dist/src/work-discovery/index.js +2 -2
- package/dist/src/work-discovery/service.d.ts +12 -3
- package/dist/src/work-discovery/service.js +183 -86
- package/dist/src/work-discovery/source-repository.d.ts +1 -0
- package/dist/src/work-discovery/source-repository.js +10 -4
- package/dist/src/work-discovery/types.d.ts +2 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agents-Dj86bHkl.js +0 -68
- package/dist/gateway/static/root/assets/app-management-settings-panel-D-M6GN-8.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-XDhmzdIc.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-sfO835uz.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-PptuZgoo.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BoCmzMFV.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DhkJsU8Z.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dm7T61fE.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-dG6UFVqt.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DgJxfNyK.js +0 -1
- package/dist/gateway/static/root/assets/chat-terminal-dock-CT5yoSMD.js +0 -36
- package/dist/gateway/static/root/assets/connectors-page-BC6Ft9SU.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DZVSgLXH.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Bw4cCFzI.js +0 -1
- package/dist/gateway/static/root/assets/directory-picker-path-field-Cbst7IXR.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-C1PAKSy2.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-Bch9vO6t.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DkDxZFGG.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DXNMxy5b.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CYcpVFNT.js +0 -1
- package/dist/gateway/static/root/assets/index-Dgb1R07E.css +0 -2
- package/dist/gateway/static/root/assets/index-DlOYwVFK.js +0 -108
- package/dist/gateway/static/root/assets/local-app-workbench-page-BFrgPwGE.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-CPweLw3k.js +0 -2
- package/dist/gateway/static/root/assets/messages-B9WQcZ1V.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-wieRAd1y.js +0 -4
- package/dist/gateway/static/root/assets/page-tabs-Bsluqyfb.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-BrpTWv44.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cww6V7HJ.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D0LKhCCw.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Sf4Pde6Z.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-S5gvgfu5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-B3XvdEy8.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-CiGFtdD8.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGU_Mxjr.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-k0UQ8WxO.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DQ1GvL1w.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-OuHd9GcN.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-CERqCsz2.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BnRNL2sn.js +0 -1
- package/dist/gateway/static/root/assets/typed-models-lib-abEJNkCO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Cnkaiky5.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-B_VlcKiK.js +0 -5
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { finishContextExtractionRun, getContextExtractionRun, listContextExtractionOutputs } from "../../../storage/sqlite/context-extraction-repository.js";
|
|
2
|
+
import { closeTemporalAssertions, createTemporalAssertion, linkContextObjects } from "../../../storage/sqlite/context-relation-repository.js";
|
|
3
|
+
import { closeUnderstandingValidity, createContextEvidence, createUnderstanding, getUnderstanding, isUnderstandingSuppressed, linkUnderstandingEvidence, listUnderstandings, setUnderstandingStatus } from "../../../storage/sqlite/user-context-repository.js";
|
|
2
4
|
import "../../../storage/sqlite/index.js";
|
|
3
5
|
import { extractExplicitUnderstandingCorrectionContent } from "./correction.js";
|
|
6
|
+
import { claimRegisteredExtraction, extractionInputHash, getRegisteredExtractorDefinition } from "../../../user-context/extraction/registry.js";
|
|
4
7
|
import { canonicalUnderstandingKey, findContradictoryUnderstanding, findDuplicateUnderstanding } from "../../../user-context/understanding.js";
|
|
5
8
|
import { inferMemorySensitivity, redactSensitiveMemoryText } from "../sensitivity.js";
|
|
6
9
|
//#region src/agent/memory/understanding/service.ts
|
|
@@ -32,6 +35,11 @@ function effectiveSensitivity(declared, content) {
|
|
|
32
35
|
function normalizeContent(raw) {
|
|
33
36
|
return raw.replace(/^["'“”‘’\s]+|["'“”‘’\s]+$/g, "").replace(/\s+/g, " ").trim().slice(0, MAX_CANDIDATE_CHARS);
|
|
34
37
|
}
|
|
38
|
+
function candidateTime(value) {
|
|
39
|
+
if (!value) return void 0;
|
|
40
|
+
const parsed = Date.parse(value);
|
|
41
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
42
|
+
}
|
|
35
43
|
function inferKind(content) {
|
|
36
44
|
if (/\b(don't|do not|never|avoid)\b/i.test(content) || /不要|不用|无需|别再|禁止|底线/.test(content)) return "boundary";
|
|
37
45
|
if (/\b(prefer|preference|like)\b/i.test(content) || /喜欢|偏好|习惯/.test(content)) return "preference";
|
|
@@ -96,39 +104,104 @@ var UserUnderstandingService = class {
|
|
|
96
104
|
params.assistantContent;
|
|
97
105
|
const explicitCandidates = extractExplicitUnderstandingCandidates(params.userContent);
|
|
98
106
|
const candidates = explicitCandidates.length > 0 ? explicitCandidates : extractHighSignalUnderstandingCandidates(params.userContent);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
const turnRef = params.turnId ?? `untracked-${extractionInputHash(params.userContent).slice(0, 16)}`;
|
|
108
|
+
const extraction = claimRegisteredExtraction({
|
|
109
|
+
extractorId: explicitCandidates.length > 0 ? "explicit-command" : "deterministic-signal",
|
|
110
|
+
sourceRef: params.sessionKey ? `session:${params.sessionKey}:turn:${turnRef}` : `turn:${turnRef}`,
|
|
111
|
+
contentForHash: params.userContent,
|
|
112
|
+
processingPolicy: "local_only",
|
|
113
|
+
destination: "deterministic"
|
|
114
|
+
});
|
|
115
|
+
if (!extraction.shouldExecute) {
|
|
116
|
+
const previous = listContextExtractionOutputs(extraction.run.id);
|
|
117
|
+
return {
|
|
118
|
+
proposed: candidates.length,
|
|
119
|
+
created: 0,
|
|
120
|
+
deduplicated: previous.filter((output) => output.outcome !== "rejected").length,
|
|
121
|
+
rejected: previous.filter((output) => output.outcome === "rejected").length,
|
|
122
|
+
createdRecords: []
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (candidates.length === 0) {
|
|
126
|
+
finishContextExtractionRun({
|
|
127
|
+
runId: extraction.run.id,
|
|
128
|
+
status: "completed",
|
|
129
|
+
outputs: []
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
proposed: 0,
|
|
133
|
+
created: 0,
|
|
134
|
+
deduplicated: 0,
|
|
135
|
+
rejected: 0,
|
|
136
|
+
createdRecords: []
|
|
137
|
+
};
|
|
138
|
+
}
|
|
106
139
|
const safeCandidates = candidates.filter((candidate) => {
|
|
107
140
|
const content = normalizeContent(candidate.content);
|
|
108
141
|
const sensitivity = effectiveSensitivity(candidate.sensitivity, content);
|
|
109
142
|
return sensitivity !== "secret" && sensitivity !== "regulated";
|
|
110
143
|
});
|
|
111
|
-
if (!safeCandidates.length)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
144
|
+
if (!safeCandidates.length) {
|
|
145
|
+
finishContextExtractionRun({
|
|
146
|
+
runId: extraction.run.id,
|
|
147
|
+
status: "completed",
|
|
148
|
+
outputs: candidates.map((candidate) => ({
|
|
149
|
+
candidateKey: candidate.canonicalKey ?? canonicalUnderstandingKey(candidate.kind, candidate.content),
|
|
150
|
+
outcome: "rejected"
|
|
151
|
+
}))
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
proposed: candidates.length,
|
|
155
|
+
created: 0,
|
|
156
|
+
deduplicated: 0,
|
|
157
|
+
rejected: candidates.length,
|
|
158
|
+
createdRecords: []
|
|
159
|
+
};
|
|
160
|
+
}
|
|
118
161
|
const evidence = createContextEvidence({
|
|
119
162
|
sourceType: "conversation",
|
|
120
|
-
sourceRef: params.sessionKey ? `session:${params.sessionKey}:turn:${
|
|
163
|
+
sourceRef: params.sessionKey ? `session:${params.sessionKey}:turn:${turnRef}` : `turn:${turnRef}`,
|
|
164
|
+
sourceRunId: extraction.run.id,
|
|
165
|
+
...params.sessionKey ? { sessionId: params.sessionKey } : {},
|
|
166
|
+
turnId: turnRef,
|
|
167
|
+
contentHash: extractionInputHash(params.userContent),
|
|
168
|
+
retentionPolicy: "derived_only",
|
|
169
|
+
processingPolicy: "local_only",
|
|
170
|
+
extractorId: extraction.run.extractorId,
|
|
171
|
+
extractorVersion: extraction.run.extractorVersion,
|
|
121
172
|
redactedExcerpt: redactSensitiveMemoryText(safeCandidates.map((candidate) => candidate.content).join("\n")).slice(0, MAX_CANDIDATE_CHARS),
|
|
122
173
|
trustLevel: "owner",
|
|
123
174
|
observedAt: Date.now()
|
|
124
175
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
176
|
+
let result;
|
|
177
|
+
try {
|
|
178
|
+
result = await this.applyCandidates(safeCandidates, {
|
|
179
|
+
sessionKey: params.sessionKey,
|
|
180
|
+
workspaceId: params.workspaceId,
|
|
181
|
+
projectId: params.projectId,
|
|
182
|
+
evidenceIds: [evidence.id],
|
|
183
|
+
reviewSource: "turn",
|
|
184
|
+
supersedesRecordIds: params.correctionTargetRecordIds,
|
|
185
|
+
extractionRunId: extraction.run.id
|
|
186
|
+
});
|
|
187
|
+
} catch (error) {
|
|
188
|
+
finishContextExtractionRun({
|
|
189
|
+
runId: extraction.run.id,
|
|
190
|
+
status: "failed",
|
|
191
|
+
errorCode: "write_failed"
|
|
192
|
+
});
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
finishContextExtractionRun({
|
|
196
|
+
runId: extraction.run.id,
|
|
197
|
+
status: "completed",
|
|
198
|
+
outputs: result.writeOutputs?.map((output) => ({
|
|
199
|
+
candidateKey: output.candidateKey,
|
|
200
|
+
objectType: output.objectId ? "understanding" : void 0,
|
|
201
|
+
objectId: output.objectId,
|
|
202
|
+
versionId: output.versionId,
|
|
203
|
+
outcome: output.outcome
|
|
204
|
+
})) ?? []
|
|
132
205
|
});
|
|
133
206
|
return {
|
|
134
207
|
...result,
|
|
@@ -141,24 +214,36 @@ var UserUnderstandingService = class {
|
|
|
141
214
|
let created = 0;
|
|
142
215
|
let deduplicated = 0;
|
|
143
216
|
const createdRecords = [];
|
|
217
|
+
const writeOutputs = [];
|
|
144
218
|
const correctionTarget = context.supersedesRecordIds?.length === 1 ? context.supersedesRecordIds[0] : void 0;
|
|
145
|
-
const
|
|
219
|
+
const extractionRun = context.extractionRunId ? getContextExtractionRun(context.extractionRunId) : null;
|
|
220
|
+
if (context.extractionRunId && !extractionRun) throw new Error("Context extraction run not found");
|
|
221
|
+
if (context.source?.provider && !extractionRun) throw new Error("External understanding requires an extraction run");
|
|
222
|
+
const extractionDefinition = extractionRun ? getRegisteredExtractorDefinition(extractionRun.extractorId) : void 0;
|
|
223
|
+
const prepared = candidates.slice(0, 10).map((candidate) => {
|
|
146
224
|
const content = normalizeContent(candidate.content);
|
|
147
225
|
return {
|
|
148
226
|
candidate,
|
|
149
227
|
content,
|
|
150
228
|
sensitivity: effectiveSensitivity(candidate.sensitivity, content),
|
|
151
229
|
scope: scopeForCandidate(candidate, context),
|
|
152
|
-
key: candidate.canonicalKey ?? canonicalUnderstandingKey(candidate.kind, content)
|
|
230
|
+
key: candidate.canonicalKey ?? canonicalUnderstandingKey(candidate.kind, content),
|
|
231
|
+
explicitness: extractionDefinition?.authorityCeiling === "user_explicit" ? candidate.explicitness : extractionDefinition?.authorityCeiling === "user_observed" ? candidate.explicitness === "explicit" ? "observed" : candidate.explicitness : extractionDefinition ? "inferred" : candidate.explicitness
|
|
153
232
|
};
|
|
154
|
-
})
|
|
233
|
+
});
|
|
234
|
+
const eligible = prepared.filter(({ candidate, content, sensitivity, scope, key }) => content.length >= 4 && candidate.confidence >= .55 && sensitivity !== "secret" && sensitivity !== "regulated" && (!extractionDefinition || extractionDefinition.candidateKinds.includes(candidate.kind)) && !isUnderstandingSuppressed(key, scope));
|
|
155
235
|
let rejected = candidates.length - eligible.length;
|
|
236
|
+
for (const item of prepared.filter((candidate) => !eligible.includes(candidate))) writeOutputs.push({
|
|
237
|
+
candidateKey: item.key,
|
|
238
|
+
outcome: "rejected"
|
|
239
|
+
});
|
|
156
240
|
if (!eligible.length) return {
|
|
157
241
|
proposed: candidates.length,
|
|
158
242
|
created,
|
|
159
243
|
deduplicated,
|
|
160
244
|
rejected,
|
|
161
|
-
createdRecords
|
|
245
|
+
createdRecords,
|
|
246
|
+
writeOutputs
|
|
162
247
|
};
|
|
163
248
|
const evidenceIds = [...new Set(context.evidenceIds ?? [])];
|
|
164
249
|
const sourceItemIds = [context.sourceItemId, ...context.sourceItemIds ?? []].filter((value) => Boolean(value));
|
|
@@ -167,13 +252,21 @@ var UserUnderstandingService = class {
|
|
|
167
252
|
sourceType: context.source?.provider ? "connector" : "runtime",
|
|
168
253
|
...context.source?.sourceInstanceId ? { sourceInstanceId: context.source.sourceInstanceId } : {},
|
|
169
254
|
sourceRef: sourceItemId,
|
|
255
|
+
...context.extractionRunId ? { sourceRunId: context.extractionRunId } : {},
|
|
256
|
+
sourceItemId,
|
|
257
|
+
retentionPolicy: "derived_only",
|
|
258
|
+
...extractionRun ? { processingPolicy: extractionRun.processingPolicy } : {},
|
|
259
|
+
...extractionRun ? {
|
|
260
|
+
extractorId: extractionRun.extractorId,
|
|
261
|
+
extractorVersion: extractionRun.extractorVersion
|
|
262
|
+
} : {},
|
|
170
263
|
...context.sourceText ? { redactedExcerpt: redactSensitiveMemoryText(context.sourceText).slice(0, MAX_CANDIDATE_CHARS) } : {},
|
|
171
264
|
trustLevel: context.source?.provider ? "untrusted" : "trusted",
|
|
172
265
|
observedAt: Date.now()
|
|
173
266
|
});
|
|
174
267
|
evidenceIds.push(evidence.id);
|
|
175
268
|
}
|
|
176
|
-
for (const { candidate, content, sensitivity, scope, key } of eligible) {
|
|
269
|
+
for (const { candidate, content, sensitivity, scope, key, explicitness } of eligible) {
|
|
177
270
|
const duplicate = findDuplicateUnderstanding(listUnderstandings(), {
|
|
178
271
|
kind: candidate.kind,
|
|
179
272
|
statement: content,
|
|
@@ -183,20 +276,29 @@ var UserUnderstandingService = class {
|
|
|
183
276
|
if (duplicate) {
|
|
184
277
|
for (const evidenceId of evidenceIds) linkUnderstandingEvidence(duplicate.versionId, evidenceId, "supports", candidate.confidence);
|
|
185
278
|
deduplicated += 1;
|
|
279
|
+
writeOutputs.push({
|
|
280
|
+
candidateKey: key,
|
|
281
|
+
objectId: duplicate.id,
|
|
282
|
+
versionId: duplicate.versionId,
|
|
283
|
+
outcome: "deduplicated"
|
|
284
|
+
});
|
|
186
285
|
continue;
|
|
187
286
|
}
|
|
188
|
-
const isExplicit =
|
|
189
|
-
const
|
|
287
|
+
const isExplicit = explicitness === "explicit" && extractionDefinition?.maxAutomaticStatus !== "candidate";
|
|
288
|
+
const contradiction = findContradictoryUnderstanding(listUnderstandings(), {
|
|
190
289
|
kind: candidate.kind,
|
|
191
290
|
statement: content,
|
|
192
291
|
scope
|
|
193
|
-
})
|
|
292
|
+
});
|
|
293
|
+
const supersededId = isExplicit ? correctionTarget ?? contradiction?.id : void 0;
|
|
294
|
+
const validFrom = candidateTime(candidate.validFrom);
|
|
295
|
+
const validTo = candidateTime(candidate.validTo);
|
|
194
296
|
const record = createUnderstanding({
|
|
195
297
|
kind: candidate.kind,
|
|
196
298
|
canonicalKey: key,
|
|
197
299
|
status: isExplicit ? "active" : "candidate",
|
|
198
300
|
scope,
|
|
199
|
-
explicitness
|
|
301
|
+
explicitness,
|
|
200
302
|
durability: candidate.durability,
|
|
201
303
|
sensitivity,
|
|
202
304
|
disclosurePolicy: candidate.disclosurePolicy,
|
|
@@ -204,12 +306,46 @@ var UserUnderstandingService = class {
|
|
|
204
306
|
statement: content,
|
|
205
307
|
createdBy: context.reviewSource === "background" ? "consolidation" : "runtime",
|
|
206
308
|
changeReason: context.reviewSource === "background" ? "background synthesis" : "explicit user statement",
|
|
207
|
-
...
|
|
208
|
-
...
|
|
309
|
+
...validFrom !== void 0 ? { validFrom } : {},
|
|
310
|
+
...validTo !== void 0 ? { validTo } : {},
|
|
209
311
|
...supersededId ? { supersedesId: supersededId } : {}
|
|
210
312
|
});
|
|
211
313
|
for (const evidenceId of evidenceIds) linkUnderstandingEvidence(record.versionId, evidenceId, "supports", candidate.confidence);
|
|
212
|
-
|
|
314
|
+
const relationTarget = supersededId ? getUnderstanding(supersededId) : contradiction;
|
|
315
|
+
if (relationTarget) linkContextObjects({
|
|
316
|
+
subjectType: "understanding",
|
|
317
|
+
subjectId: record.id,
|
|
318
|
+
subjectVersionId: record.versionId,
|
|
319
|
+
predicate: supersededId ? "supersedes" : "contradicts",
|
|
320
|
+
objectType: "understanding",
|
|
321
|
+
objectId: relationTarget.id,
|
|
322
|
+
objectVersionId: relationTarget.versionId,
|
|
323
|
+
factual: true,
|
|
324
|
+
...context.extractionRunId ? { extractionRunId: context.extractionRunId } : {}
|
|
325
|
+
});
|
|
326
|
+
if (supersededId && isExplicit) {
|
|
327
|
+
const closedAt = record.validFrom ?? Date.now();
|
|
328
|
+
closeUnderstandingValidity(supersededId, closedAt);
|
|
329
|
+
closeTemporalAssertions({
|
|
330
|
+
objectType: "understanding",
|
|
331
|
+
objectId: supersededId,
|
|
332
|
+
validTo: closedAt
|
|
333
|
+
});
|
|
334
|
+
setUnderstandingStatus(supersededId, "archived");
|
|
335
|
+
}
|
|
336
|
+
const assertionType = record.kind === "current_state" ? "current_state" : record.kind === "routine" ? "routine" : record.kind === "relationship" ? "relationship" : record.kind === "project_context" ? "project_status" : void 0;
|
|
337
|
+
if (assertionType) createTemporalAssertion({
|
|
338
|
+
objectType: "understanding",
|
|
339
|
+
objectId: record.id,
|
|
340
|
+
objectVersionId: record.versionId,
|
|
341
|
+
assertionType,
|
|
342
|
+
value: { statement: record.statement },
|
|
343
|
+
confidence: record.confidence,
|
|
344
|
+
...record.validFrom ? { validFrom: record.validFrom } : {},
|
|
345
|
+
...record.validTo ? { validTo: record.validTo } : {},
|
|
346
|
+
status: record.status === "active" ? "active" : "candidate",
|
|
347
|
+
...context.extractionRunId ? { extractionRunId: context.extractionRunId } : {}
|
|
348
|
+
});
|
|
213
349
|
created += 1;
|
|
214
350
|
createdRecords.push({
|
|
215
351
|
id: record.id,
|
|
@@ -217,13 +353,20 @@ var UserUnderstandingService = class {
|
|
|
217
353
|
kind: record.kind,
|
|
218
354
|
status: record.status
|
|
219
355
|
});
|
|
356
|
+
writeOutputs.push({
|
|
357
|
+
candidateKey: key,
|
|
358
|
+
objectId: record.id,
|
|
359
|
+
versionId: record.versionId,
|
|
360
|
+
outcome: "created"
|
|
361
|
+
});
|
|
220
362
|
}
|
|
221
363
|
return {
|
|
222
364
|
proposed: candidates.length,
|
|
223
365
|
created,
|
|
224
366
|
deduplicated,
|
|
225
367
|
rejected,
|
|
226
|
-
createdRecords
|
|
368
|
+
createdRecords,
|
|
369
|
+
writeOutputs
|
|
227
370
|
};
|
|
228
371
|
}
|
|
229
372
|
};
|
|
@@ -24,4 +24,10 @@ export interface UnderstandingReviewResult {
|
|
|
24
24
|
kind: UnderstandingKind;
|
|
25
25
|
status: UserUnderstanding['status'];
|
|
26
26
|
}>;
|
|
27
|
+
writeOutputs?: Array<{
|
|
28
|
+
candidateKey: string;
|
|
29
|
+
objectId?: string;
|
|
30
|
+
versionId?: string;
|
|
31
|
+
outcome: 'created' | 'deduplicated' | 'rejected';
|
|
32
|
+
}>;
|
|
27
33
|
}
|
|
@@ -8,6 +8,7 @@ import type { Config } from '../../config/schema.js';
|
|
|
8
8
|
import type { SessionConfigStore, SessionStore } from '../../session/index.js';
|
|
9
9
|
import type { ThinkLevel } from '../transcript/thinking-types.js';
|
|
10
10
|
import type { CompactionResult } from '../memory/compaction.js';
|
|
11
|
+
import type { AgentSourceContext } from '../source-context/types.js';
|
|
11
12
|
import { type BtwQueryOptions, type CommandStreamEvent } from '../../chat-commands/index.js';
|
|
12
13
|
import type { WorkflowRunServiceLike } from '../../workflows/service/workflow-run-service.types.js';
|
|
13
14
|
import type { SkillInstallToolOptions, SkillInstallToolResult } from '../tools/skill-install-tool.js';
|
|
@@ -19,6 +20,7 @@ export interface CommandContext {
|
|
|
19
20
|
isGroup: boolean;
|
|
20
21
|
/** From inbound message metadata (thread/account, etc.) for continuation routing. */
|
|
21
22
|
inboundMetadata?: Record<string, unknown>;
|
|
23
|
+
sourceContexts?: AgentSourceContext[];
|
|
22
24
|
}
|
|
23
25
|
export interface CommandHandlerConfig {
|
|
24
26
|
config: Config;
|
|
@@ -57,7 +57,7 @@ var CommandHandler = class {
|
|
|
57
57
|
*/
|
|
58
58
|
buildCommandContext(context, recorder, emitEvent) {
|
|
59
59
|
const skipBusOutbound = shouldSkipBusOutboundForChannel(context.channel);
|
|
60
|
-
|
|
60
|
+
const commandContext = createCommandContext({
|
|
61
61
|
sessionKey: context.sessionKey,
|
|
62
62
|
source: context.channel,
|
|
63
63
|
channelId: context.channel,
|
|
@@ -141,6 +141,8 @@ var CommandHandler = class {
|
|
|
141
141
|
getSessionContextReport: this.getSessionContextReport,
|
|
142
142
|
workflowRunService: this.getWorkflowRunService?.()
|
|
143
143
|
});
|
|
144
|
+
commandContext.sourceContexts = context.sourceContexts;
|
|
145
|
+
return commandContext;
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
148
|
* Execute a command using the unified command system
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
9
9
|
import type { ImageContent } from '@earendil-works/pi-ai';
|
|
10
|
+
import type { AgentSourceContext } from '../source-context/types.js';
|
|
10
11
|
import type { CommandHandler } from '../messaging/command-handler.js';
|
|
11
12
|
import type { CommandStreamEvent } from '../../chat-commands/types.js';
|
|
12
13
|
import type { SessionStore } from '../../session/index.js';
|
|
@@ -52,6 +53,7 @@ export declare function tryRunSlashCommand(deps: TryRunSlashCommandDeps, ctx: {
|
|
|
52
53
|
}, content: string, options?: {
|
|
53
54
|
skipResetCommands?: boolean;
|
|
54
55
|
emitEvent?: (event: CommandStreamEvent) => void | Promise<void>;
|
|
56
|
+
sourceContexts?: AgentSourceContext[];
|
|
55
57
|
}): Promise<SlashCommandTask>;
|
|
56
58
|
export interface RunDirectAgentTurnDeps {
|
|
57
59
|
sessionStore: SessionStore;
|
|
@@ -66,6 +68,7 @@ export interface RunDirectAgentTurnInput {
|
|
|
66
68
|
abortSignal?: AbortSignal;
|
|
67
69
|
deadlineAtMs?: number;
|
|
68
70
|
sourceImages?: ImageContent[];
|
|
71
|
+
sourceContexts?: AgentSourceContext[];
|
|
69
72
|
onEvent?: (event: EmbeddedStreamEvent) => void;
|
|
70
73
|
}
|
|
71
74
|
export interface RunDirectAgentTurnResult {
|
|
@@ -8,6 +8,7 @@ import { parseSlashCommand } from "../../chat-commands/command-parse.js";
|
|
|
8
8
|
import { commandRegistry } from "../../chat-commands/registry.js";
|
|
9
9
|
import "../../chat-commands/index.js";
|
|
10
10
|
import { runEmbeddedTurnForSession } from "../embedded/run-for-session.js";
|
|
11
|
+
import { injectSourceContextsIntoUserMessage } from "../source-context/injector.js";
|
|
11
12
|
import crypto from "node:crypto";
|
|
12
13
|
//#region src/agent/service/direct-turn-helpers.ts
|
|
13
14
|
/**
|
|
@@ -42,6 +43,12 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
42
43
|
matched: false,
|
|
43
44
|
aggregatedText: ""
|
|
44
45
|
};
|
|
46
|
+
const command = commandRegistry.findByName(parsed.command);
|
|
47
|
+
if (options?.sourceContexts?.length && !command?.acceptsContext) return {
|
|
48
|
+
matched: true,
|
|
49
|
+
aggregatedText: `Command /${parsed.command} does not accept Note context. Remove the Note reference or use it with a regular prompt.`,
|
|
50
|
+
command: parsed.command
|
|
51
|
+
};
|
|
45
52
|
try {
|
|
46
53
|
const { aggregatedText, metadata } = await deps.commandHandler.executeCommandAndAggregateReply(parsed.command, parsed.args, {
|
|
47
54
|
sessionKey: ctx.sessionKey,
|
|
@@ -49,7 +56,8 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
49
56
|
chatId: ctx.chatId,
|
|
50
57
|
senderId: ctx.senderId ?? "",
|
|
51
58
|
isGroup: ctx.isGroup ?? false,
|
|
52
|
-
inboundMetadata: ctx.inboundMetadata ?? {}
|
|
59
|
+
inboundMetadata: ctx.inboundMetadata ?? {},
|
|
60
|
+
sourceContexts: options?.sourceContexts
|
|
53
61
|
}, { emitEvent: options?.emitEvent });
|
|
54
62
|
return {
|
|
55
63
|
matched: true,
|
|
@@ -79,7 +87,8 @@ async function runDirectAgentTurn(deps, input) {
|
|
|
79
87
|
const turnId = input.runId ?? crypto.randomUUID();
|
|
80
88
|
const userPlain = extractAgentUserPlainText(input.userMessage);
|
|
81
89
|
const userContext = await deps.agentManager.prepareUserTurnContext(input.userMessage, input.sessionKey, turnId);
|
|
82
|
-
const
|
|
90
|
+
const sourceContexts = input.sourceContexts ?? [];
|
|
91
|
+
const userMessageForModel = prependAgentContext(injectSourceContextsIntoUserMessage(userContext.modelMessage, sourceContexts), buildTaskExecutionDirective(input.sessionKey));
|
|
83
92
|
if (userContext.consentRequests.length > 0) input.onEvent?.({
|
|
84
93
|
type: "memory_consent_required",
|
|
85
94
|
runId: turnId,
|
|
@@ -90,7 +99,8 @@ async function runDirectAgentTurn(deps, input) {
|
|
|
90
99
|
message: input.userMessage,
|
|
91
100
|
modelRef
|
|
92
101
|
});
|
|
93
|
-
const
|
|
102
|
+
const contextImages = sourceContexts.flatMap((context) => context.images ?? []);
|
|
103
|
+
const sourceImages = resolveImageHandlingStrategy(modelRef) === "native" ? [...input.sourceImages ?? [], ...contextImages] : [];
|
|
94
104
|
const llmImages = [...llmTurn.images, ...sourceImages];
|
|
95
105
|
const result = await runEmbeddedTurnForSession({
|
|
96
106
|
sessionKey: input.sessionKey,
|
|
@@ -6,7 +6,7 @@ import type { SessionContext } from '../session/index.js';
|
|
|
6
6
|
import type { AgentInstanceGateway } from '../agent-instance-gateway.js';
|
|
7
7
|
import type { CommandHandler } from '../messaging/command-handler.js';
|
|
8
8
|
import type { ModelManager } from '../models/index.js';
|
|
9
|
-
import { type AgentSourceContextResolver } from '../source-context/types.js';
|
|
9
|
+
import { type AgentSourceContext, type AgentSourceContextResolver } from '../source-context/types.js';
|
|
10
10
|
import { type TranscriptUserMessage } from '../inbound/attachment-pipeline.js';
|
|
11
11
|
export type DirectStreamInboundAttachment = InboundAttachmentInput;
|
|
12
12
|
export type ProcessDirectStreamLog = {
|
|
@@ -65,6 +65,7 @@ export interface ProcessDirectStreamingInput {
|
|
|
65
65
|
thinking?: string;
|
|
66
66
|
signal?: AbortSignal;
|
|
67
67
|
runId?: string;
|
|
68
|
+
sourceContexts?: AgentSourceContext[];
|
|
68
69
|
}
|
|
69
70
|
export type ProcessDirectStreamEvent = {
|
|
70
71
|
type: string;
|
|
@@ -9,8 +9,8 @@ import "../../voice/stt/index.js";
|
|
|
9
9
|
import { abortEmbeddedRun } from "../embedded/runs.js";
|
|
10
10
|
import { isVoiceLikeAttachment, mergeVoiceTranscriptsIntoUserText } from "../../channels/attachments/voice-stt-webchat.js";
|
|
11
11
|
import { applyReasoningVisibility } from "../streaming/reasoning-visibility.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { isSessionSourceBinding, summarizeSourceContext } from "../source-context/types.js";
|
|
13
|
+
import { injectSourceContextsIntoUserMessage } from "../source-context/injector.js";
|
|
14
14
|
import { AsyncQueue } from "./async-queue.js";
|
|
15
15
|
import { hydratePerTurnState, runDirectAgentTurn, tryRunSlashCommand } from "./direct-turn-helpers.js";
|
|
16
16
|
//#region src/agent/service/process-direct-streaming.ts
|
|
@@ -227,7 +227,8 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
227
227
|
});
|
|
228
228
|
const traceRow = reviewTraceContextEntryFromCommandEvent(event, input.runId);
|
|
229
229
|
if (traceRow) slashTraceRows.push(traceRow);
|
|
230
|
-
}
|
|
230
|
+
},
|
|
231
|
+
sourceContexts: input.sourceContexts
|
|
231
232
|
});
|
|
232
233
|
if (slash.matched) {
|
|
233
234
|
ranSlashCommand = true;
|
|
@@ -251,15 +252,14 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
251
252
|
const skillTurn = deps.agentManager.prepareSkillTurn(sessionKey, mergedUserText);
|
|
252
253
|
const textForAgent = skillTurn.text;
|
|
253
254
|
const userMessage = await deps.buildTranscriptUserMessage(textForAgent, prepared, sessionKey);
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
const turnSourceContexts = input.sourceContexts ?? [];
|
|
256
|
+
const sourceContexts = [...turnSourceContexts];
|
|
256
257
|
if (deps.sourceContextResolver) {
|
|
257
258
|
const metadata = await deps.sessionStore.getMetadata(sessionKey).catch(() => null);
|
|
258
259
|
const sourceBinding = metadata?.customData && typeof metadata.customData === "object" ? metadata.customData.sourceBinding : void 0;
|
|
259
260
|
if (isSessionSourceBinding(sourceBinding)) {
|
|
260
261
|
const sourceContext = await deps.sourceContextResolver(sourceBinding, sessionKey);
|
|
261
|
-
|
|
262
|
-
sourceImages = sourceContext?.images;
|
|
262
|
+
if (sourceContext && !sourceContexts.some((context) => context.kind === sourceContext.kind && context.sourceId === sourceContext.sourceId)) sourceContexts.push(sourceContext);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
if (channel === "webchat") {
|
|
@@ -267,11 +267,12 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
267
267
|
type: "user_message",
|
|
268
268
|
timestamp: userMessage.timestamp ?? Date.now(),
|
|
269
269
|
content: readAgentMessageContent(userMessage),
|
|
270
|
-
media: userMessage.media
|
|
270
|
+
media: userMessage.media,
|
|
271
|
+
metadata: turnSourceContexts.length > 0 ? { sourceContexts: turnSourceContexts.map(summarizeSourceContext) } : void 0
|
|
271
272
|
});
|
|
272
273
|
if (textForAgent.trim()) deps.enqueueProvisionalSessionTitle?.(sessionKey, textForAgent);
|
|
273
274
|
}
|
|
274
|
-
const pendingUserMessage = userMessage;
|
|
275
|
+
const pendingUserMessage = turnSourceContexts.length > 0 ? injectSourceContextsIntoUserMessage(userMessage, turnSourceContexts) : userMessage;
|
|
275
276
|
setPendingTranscriptUserMessage(sessionKey, pendingUserMessage);
|
|
276
277
|
try {
|
|
277
278
|
const result = await deps.agentManager.withSkillCapabilities(sessionKey, skillTurn.activatedCapabilityNames, () => runDirectAgentTurn({
|
|
@@ -281,9 +282,9 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
281
282
|
config: deps.getConfig()
|
|
282
283
|
}, {
|
|
283
284
|
sessionKey,
|
|
284
|
-
userMessage
|
|
285
|
+
userMessage,
|
|
285
286
|
abortSignal: signal,
|
|
286
|
-
|
|
287
|
+
sourceContexts,
|
|
287
288
|
runId: input.runId,
|
|
288
289
|
onEvent: (embeddedEvent) => {
|
|
289
290
|
const event = { ...embeddedEvent };
|
|
@@ -3,10 +3,10 @@ import { init_logger } from "../utils/logger.js";
|
|
|
3
3
|
import { getUserProfile } from "../storage/sqlite/user-context-repository.js";
|
|
4
4
|
import { parseNoteAttachmentTarget } from "../notes/attachment-ref.js";
|
|
5
5
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
6
|
-
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
7
|
-
import { init_providers, resolveModel } from "../providers/index.js";
|
|
8
6
|
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
7
|
+
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
9
8
|
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
9
|
+
import { init_providers, resolveModel } from "../providers/index.js";
|
|
10
10
|
import { extractTextContent } from "./context/workspace.js";
|
|
11
11
|
import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
|
|
12
12
|
import { getProjectForSession } from "../projects/workspace.js";
|
|
@@ -35,6 +35,7 @@ export interface PatchSessionAgentConfigInput {
|
|
|
35
35
|
verboseLevel?: string;
|
|
36
36
|
workingDirectory?: string;
|
|
37
37
|
responseLanguage?: string | null;
|
|
38
|
+
userContextMode?: 'enabled' | 'off' | 'temporary';
|
|
38
39
|
}
|
|
39
40
|
export interface PatchSessionAgentConfigResult {
|
|
40
41
|
ok: boolean;
|
|
@@ -85,6 +85,17 @@ var SessionConfigService = class {
|
|
|
85
85
|
}
|
|
86
86
|
this.opts.agentManager.removeAgent(sessionKey);
|
|
87
87
|
}
|
|
88
|
+
if (partial.userContextMode !== void 0) {
|
|
89
|
+
if (![
|
|
90
|
+
"enabled",
|
|
91
|
+
"off",
|
|
92
|
+
"temporary"
|
|
93
|
+
].includes(partial.userContextMode)) return {
|
|
94
|
+
ok: false,
|
|
95
|
+
error: "Invalid user context mode"
|
|
96
|
+
};
|
|
97
|
+
await this.opts.sessionConfigStore.update(sessionKey, { userContextMode: partial.userContextMode });
|
|
98
|
+
}
|
|
88
99
|
if (partial.workingDirectory !== void 0) {
|
|
89
100
|
if (!this.opts.getConfig()) return {
|
|
90
101
|
ok: false,
|
|
@@ -56,6 +56,7 @@ export interface SessionAgentConfigView {
|
|
|
56
56
|
effectiveWorkspacePath: string;
|
|
57
57
|
workingDirectoryLocked: boolean;
|
|
58
58
|
workspaceSource: 'project' | 'session_override' | 'agent_default_root' | 'agent_workspace';
|
|
59
|
+
userContextMode: 'enabled' | 'off' | 'temporary';
|
|
59
60
|
}
|
|
60
61
|
export declare class SessionInspector {
|
|
61
62
|
private readonly opts;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { init_workspace_defaults, resolveDefaultAgentWorkspaceDir } from "../../config/workspace-defaults.js";
|
|
4
|
-
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
5
4
|
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
6
6
|
import { effectiveWorkspacePathForSession, projectWorkspacePath } from "../../session/session-workspace.js";
|
|
7
7
|
import { getProjectForSession } from "../../projects/workspace.js";
|
|
8
8
|
import { resolveCompactionPolicy } from "../memory/compaction-policy.js";
|
|
@@ -153,6 +153,7 @@ var SessionInspector = class {
|
|
|
153
153
|
verboseLevel,
|
|
154
154
|
effectiveWorkspacePath,
|
|
155
155
|
workingDirectoryLocked: Boolean(projectWorkspace || hasSessionWorkspaceOverride),
|
|
156
|
+
userContextMode: sc?.userContextMode ?? "enabled",
|
|
156
157
|
workspaceSource: projectWorkspace ? "project" : hasSessionWorkspaceOverride ? "session_override" : isDefaultWorkspaceRoot ? "agent_default_root" : "agent_workspace"
|
|
157
158
|
};
|
|
158
159
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
2
1
|
import { init_paths, resolveSkillsLockPath } from "../../config/paths.js";
|
|
2
|
+
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
//#region src/agent/skills/hub-lock.ts
|
|
5
5
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/agent/source-context/budget.ts
|
|
2
|
+
const MAX_TURN_CONTEXT_TOKENS = 32e3;
|
|
3
|
+
const CHARS_PER_TOKEN_ESTIMATE = 4;
|
|
4
|
+
const TRUNCATION_MARKER = "\n\n[context truncated]";
|
|
5
|
+
function fitSourceContextsToBudget(contexts, maxTokens = MAX_TURN_CONTEXT_TOKENS) {
|
|
6
|
+
let remainingChars = Math.max(0, maxTokens) * CHARS_PER_TOKEN_ESTIMATE;
|
|
7
|
+
return contexts.map((context, index) => {
|
|
8
|
+
const remainingItems = contexts.length - index;
|
|
9
|
+
const quota = Math.floor(remainingChars / remainingItems);
|
|
10
|
+
const text = context.text.length <= quota ? context.text : quota <= 21 ? TRUNCATION_MARKER.slice(0, quota) : `${context.text.slice(0, quota - 21)}${TRUNCATION_MARKER}`;
|
|
11
|
+
remainingChars = Math.max(0, remainingChars - text.length);
|
|
12
|
+
return {
|
|
13
|
+
...context,
|
|
14
|
+
text,
|
|
15
|
+
tokenEstimate: Math.ceil(text.length / CHARS_PER_TOKEN_ESTIMATE),
|
|
16
|
+
truncated: context.truncated === true || text.length < context.text.length
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { MAX_TURN_CONTEXT_TOKENS, fitSourceContextsToBudget };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { isSessionSourceBinding, isTurnContextRef, parseTurnContextRefs, summarizeSourceContext } from "./types.js";
|
|
2
|
+
import { injectSourceContextsIntoUserMessage } from "./injector.js";
|
|
3
|
+
export { injectSourceContextsIntoUserMessage, isSessionSourceBinding, isTurnContextRef, parseTurnContextRefs, summarizeSourceContext };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
|
-
import type
|
|
3
|
-
export declare function
|
|
2
|
+
import { type AgentSourceContext } from './types.js';
|
|
3
|
+
export declare function injectSourceContextsIntoUserMessage(message: AgentMessage, sourceContexts: readonly AgentSourceContext[]): AgentMessage;
|