@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,50 @@
|
|
|
1
|
+
import type { AssertionStatus } from '../domain.js';
|
|
2
|
+
import type { CaptureEvidence, UserModelInterpretation } from './semantic.js';
|
|
3
|
+
export interface UserModelCapturePolicy {
|
|
4
|
+
write: 'deny' | 'confirm' | 'allow';
|
|
5
|
+
sensitiveWrite: 'deny' | 'confirm' | 'allow';
|
|
6
|
+
processing: 'local_only' | 'remote_allowed';
|
|
7
|
+
}
|
|
8
|
+
export interface CaptureScopeContext {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
projectId?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface UserModelCaptureResult {
|
|
15
|
+
proposed: number;
|
|
16
|
+
created: number;
|
|
17
|
+
deduplicated: number;
|
|
18
|
+
rejected: number;
|
|
19
|
+
createdAssertions: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
content: string;
|
|
22
|
+
kind: string;
|
|
23
|
+
status: AssertionStatus;
|
|
24
|
+
}>;
|
|
25
|
+
createdGoals: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
status: 'proposed' | 'active';
|
|
29
|
+
}>;
|
|
30
|
+
createdRules: Array<{
|
|
31
|
+
id: string;
|
|
32
|
+
statement: string;
|
|
33
|
+
status: 'active' | 'disabled';
|
|
34
|
+
}>;
|
|
35
|
+
outputs: Array<{
|
|
36
|
+
candidateKey: string;
|
|
37
|
+
assertionId?: string;
|
|
38
|
+
outcome: 'created' | 'deduplicated' | 'superseded' | 'conflicted' | 'rejected';
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export declare function emptyUserModelCaptureResult(): UserModelCaptureResult;
|
|
42
|
+
export declare function executeUserModelInterpretation(input: {
|
|
43
|
+
interpretation: UserModelInterpretation;
|
|
44
|
+
evidence: CaptureEvidence[];
|
|
45
|
+
extractionRunId: string;
|
|
46
|
+
extractorId: string;
|
|
47
|
+
scopeContext: CaptureScopeContext;
|
|
48
|
+
policy: UserModelCapturePolicy;
|
|
49
|
+
turnId?: string;
|
|
50
|
+
}): UserModelCaptureResult;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { createCollaborationRule, listCollaborationRules } from "../../storage/sqlite/collaboration-rule-repository.js";
|
|
2
|
+
import { createContextEvidence } from "../../storage/sqlite/context-evidence-repository.js";
|
|
3
|
+
import { createUserGoal, listUserGoals } from "../goals.js";
|
|
4
|
+
import { getUserAssertion, linkAssertionEvidence, reconcileAssertion, setAssertionStatus } from "../repository.js";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
//#region src/user-model/capture/executor.ts
|
|
7
|
+
function emptyUserModelCaptureResult() {
|
|
8
|
+
return {
|
|
9
|
+
proposed: 0,
|
|
10
|
+
created: 0,
|
|
11
|
+
deduplicated: 0,
|
|
12
|
+
rejected: 0,
|
|
13
|
+
createdAssertions: [],
|
|
14
|
+
createdGoals: [],
|
|
15
|
+
createdRules: [],
|
|
16
|
+
outputs: []
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function scopeAllowed(type, id, context) {
|
|
20
|
+
if (type === "global") return id === void 0;
|
|
21
|
+
return id === {
|
|
22
|
+
agent: context.agentId,
|
|
23
|
+
workspace: context.workspaceId,
|
|
24
|
+
project: context.projectId,
|
|
25
|
+
session: context.sessionId
|
|
26
|
+
}[type];
|
|
27
|
+
}
|
|
28
|
+
function candidateKey(predicate, scopeType, scopeId) {
|
|
29
|
+
return `${scopeType}:${scopeId ?? ""}:${predicate}`;
|
|
30
|
+
}
|
|
31
|
+
function executeUserModelInterpretation(input) {
|
|
32
|
+
const result = emptyUserModelCaptureResult();
|
|
33
|
+
const targets = input.interpretation.targetAssertionIds.flatMap((id) => getUserAssertion(id) ?? []);
|
|
34
|
+
if (input.interpretation.intent === "forget") {
|
|
35
|
+
for (const target of targets) {
|
|
36
|
+
setAssertionStatus(target.id, "rejected", {
|
|
37
|
+
actor: "user",
|
|
38
|
+
reason: "Explicit user forget request."
|
|
39
|
+
});
|
|
40
|
+
result.outputs.push({
|
|
41
|
+
candidateKey: target.id,
|
|
42
|
+
assertionId: target.id,
|
|
43
|
+
outcome: "rejected"
|
|
44
|
+
});
|
|
45
|
+
result.rejected += 1;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
if (input.interpretation.intent === "confirm" && input.policy.write !== "deny") for (const target of targets) {
|
|
50
|
+
const confirmed = setAssertionStatus(target.id, "active", {
|
|
51
|
+
actor: "user",
|
|
52
|
+
reason: "Explicit user confirmation."
|
|
53
|
+
});
|
|
54
|
+
result.createdAssertions.push({
|
|
55
|
+
id: confirmed.id,
|
|
56
|
+
content: confirmed.statement,
|
|
57
|
+
kind: confirmed.kind,
|
|
58
|
+
status: confirmed.status
|
|
59
|
+
});
|
|
60
|
+
result.outputs.push({
|
|
61
|
+
candidateKey: confirmed.id,
|
|
62
|
+
assertionId: confirmed.id,
|
|
63
|
+
outcome: "deduplicated"
|
|
64
|
+
});
|
|
65
|
+
result.deduplicated += 1;
|
|
66
|
+
}
|
|
67
|
+
if (input.interpretation.intent === "correct" && targets.length && input.interpretation.candidates.length === 0) {
|
|
68
|
+
for (const target of targets) setAssertionStatus(target.id, "needs_review", {
|
|
69
|
+
actor: "user",
|
|
70
|
+
reason: "Correction requested without a grounded replacement."
|
|
71
|
+
});
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
const goals = input.interpretation.goals ?? [];
|
|
75
|
+
const collaborationRules = input.interpretation.collaborationRules ?? [];
|
|
76
|
+
if (!input.interpretation.candidates.length && !goals.length && !collaborationRules.length) return result;
|
|
77
|
+
const evidenceByRef = new Map(input.evidence.map((entry) => [entry.ref, entry]));
|
|
78
|
+
const evidenceIds = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const ref of new Set([
|
|
80
|
+
...input.interpretation.candidates.flatMap((item) => item.evidenceRefs),
|
|
81
|
+
...goals.flatMap((item) => item.evidenceRefs),
|
|
82
|
+
...collaborationRules.flatMap((item) => item.evidenceRefs)
|
|
83
|
+
])) {
|
|
84
|
+
const item = evidenceByRef.get(ref);
|
|
85
|
+
if (!item || item.role !== "user") continue;
|
|
86
|
+
const evidence = createContextEvidence({
|
|
87
|
+
sourceType: "conversation",
|
|
88
|
+
sourceRef: `session:${input.scopeContext.sessionId}:entry:${ref}`,
|
|
89
|
+
sourceRunId: input.extractionRunId,
|
|
90
|
+
sessionId: input.scopeContext.sessionId,
|
|
91
|
+
...input.turnId ? { turnId: input.turnId } : {},
|
|
92
|
+
messageId: ref,
|
|
93
|
+
contentHash: createHash("sha256").update(item.text).digest("hex"),
|
|
94
|
+
retentionPolicy: "derived_only",
|
|
95
|
+
processingPolicy: input.policy.processing,
|
|
96
|
+
extractorId: input.extractorId,
|
|
97
|
+
extractorVersion: "user-model-v1",
|
|
98
|
+
trustLevel: "owner",
|
|
99
|
+
observedAt: item.createdAt
|
|
100
|
+
});
|
|
101
|
+
evidenceIds.set(ref, evidence.id);
|
|
102
|
+
}
|
|
103
|
+
const explicitCommand = input.interpretation.intent === "remember" || input.interpretation.intent === "correct";
|
|
104
|
+
for (const source of input.interpretation.candidates) {
|
|
105
|
+
result.proposed += 1;
|
|
106
|
+
const key = candidateKey(source.predicate, source.scope.type, source.scope.id);
|
|
107
|
+
const sensitive = source.sensitivity === "secret" || source.sensitivity === "regulated";
|
|
108
|
+
if (input.policy.write === "deny" || sensitive && input.policy.sensitiveWrite === "deny" || !scopeAllowed(source.scope.type, source.scope.id, input.scopeContext)) {
|
|
109
|
+
result.rejected += 1;
|
|
110
|
+
result.outputs.push({
|
|
111
|
+
candidateKey: key,
|
|
112
|
+
outcome: "rejected"
|
|
113
|
+
});
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const requiresConfirmation = !explicitCommand && (input.policy.write === "confirm" || sensitive && input.policy.sensitiveWrite === "confirm");
|
|
117
|
+
const refs = source.evidenceRefs.flatMap((ref) => evidenceIds.get(ref) ?? []);
|
|
118
|
+
const applied = reconcileAssertion({
|
|
119
|
+
...source,
|
|
120
|
+
authority: requiresConfirmation && source.authority === "user_explicit" ? "user_observed" : source.authority,
|
|
121
|
+
createdBy: source.authority === "user_explicit" ? "user" : "runtime",
|
|
122
|
+
...refs[0] ? {
|
|
123
|
+
evidenceId: refs[0],
|
|
124
|
+
evidenceConfidence: source.confidence
|
|
125
|
+
} : {}
|
|
126
|
+
});
|
|
127
|
+
for (const evidenceId of refs.slice(1)) linkAssertionEvidence(applied.assertion.id, evidenceId, "supports", source.confidence);
|
|
128
|
+
result.createdAssertions.push({
|
|
129
|
+
id: applied.assertion.id,
|
|
130
|
+
content: applied.assertion.statement,
|
|
131
|
+
kind: applied.assertion.kind,
|
|
132
|
+
status: applied.assertion.status
|
|
133
|
+
});
|
|
134
|
+
result.outputs.push({
|
|
135
|
+
candidateKey: key,
|
|
136
|
+
assertionId: applied.assertion.id,
|
|
137
|
+
outcome: applied.action
|
|
138
|
+
});
|
|
139
|
+
if (applied.action === "deduplicated") result.deduplicated += 1;
|
|
140
|
+
else result.created += 1;
|
|
141
|
+
}
|
|
142
|
+
for (const source of goals) {
|
|
143
|
+
result.proposed += 1;
|
|
144
|
+
const key = candidateKey(`goal:${source.title.toLocaleLowerCase()}`, source.scope.type, source.scope.id);
|
|
145
|
+
if (input.policy.write === "deny" || !scopeAllowed(source.scope.type, source.scope.id, input.scopeContext)) {
|
|
146
|
+
result.rejected += 1;
|
|
147
|
+
result.outputs.push({
|
|
148
|
+
candidateKey: key,
|
|
149
|
+
outcome: "rejected"
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (listUserGoals().find((goal) => goal.scope.type === source.scope.type && goal.scope.id === source.scope.id && goal.title.toLocaleLowerCase() === source.title.toLocaleLowerCase() && goal.status !== "achieved" && goal.status !== "abandoned")) {
|
|
154
|
+
result.deduplicated += 1;
|
|
155
|
+
result.outputs.push({
|
|
156
|
+
candidateKey: key,
|
|
157
|
+
outcome: "deduplicated"
|
|
158
|
+
});
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const active = explicitCommand || input.policy.write === "allow";
|
|
162
|
+
const goal = createUserGoal({
|
|
163
|
+
title: source.title,
|
|
164
|
+
desiredOutcome: source.desiredOutcome,
|
|
165
|
+
scope: source.scope,
|
|
166
|
+
...source.declaredImportance === void 0 ? {} : { declaredImportance: source.declaredImportance },
|
|
167
|
+
...source.targetAt === void 0 ? {} : { targetAt: source.targetAt },
|
|
168
|
+
status: active ? "active" : "proposed",
|
|
169
|
+
authority: active ? "user_explicit" : "user_observed",
|
|
170
|
+
confidence: active ? 1 : .8,
|
|
171
|
+
createdBy: "runtime"
|
|
172
|
+
});
|
|
173
|
+
result.created += 1;
|
|
174
|
+
result.createdGoals.push({
|
|
175
|
+
id: goal.id,
|
|
176
|
+
title: goal.title,
|
|
177
|
+
status: goal.status
|
|
178
|
+
});
|
|
179
|
+
result.outputs.push({
|
|
180
|
+
candidateKey: key,
|
|
181
|
+
outcome: "created"
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
for (const source of collaborationRules) {
|
|
185
|
+
result.proposed += 1;
|
|
186
|
+
const key = candidateKey(`rule:${source.category}:${source.statement.toLocaleLowerCase()}`, source.scope.type, source.scope.id);
|
|
187
|
+
if (input.policy.write === "deny" || !scopeAllowed(source.scope.type, source.scope.id, input.scopeContext) || source.scope.type === "agent") {
|
|
188
|
+
result.rejected += 1;
|
|
189
|
+
result.outputs.push({
|
|
190
|
+
candidateKey: key,
|
|
191
|
+
outcome: "rejected"
|
|
192
|
+
});
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (listCollaborationRules().find((rule) => rule.scope.type === source.scope.type && rule.scope.id === source.scope.id && rule.statement.toLocaleLowerCase() === source.statement.toLocaleLowerCase() && rule.status !== "archived")) {
|
|
196
|
+
result.deduplicated += 1;
|
|
197
|
+
result.outputs.push({
|
|
198
|
+
candidateKey: key,
|
|
199
|
+
outcome: "deduplicated"
|
|
200
|
+
});
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const active = explicitCommand || input.policy.write === "allow";
|
|
204
|
+
const rule = createCollaborationRule({
|
|
205
|
+
category: source.category,
|
|
206
|
+
priority: source.priority,
|
|
207
|
+
scope: source.scope,
|
|
208
|
+
conditions: {
|
|
209
|
+
...source.conditions,
|
|
210
|
+
enforcementLevel: "prompt",
|
|
211
|
+
...active ? {} : { reviewRequired: true }
|
|
212
|
+
},
|
|
213
|
+
statement: source.statement,
|
|
214
|
+
status: active ? "active" : "disabled"
|
|
215
|
+
});
|
|
216
|
+
result.created += 1;
|
|
217
|
+
result.createdRules.push({
|
|
218
|
+
id: rule.id,
|
|
219
|
+
statement: rule.statement,
|
|
220
|
+
status: rule.status
|
|
221
|
+
});
|
|
222
|
+
result.outputs.push({
|
|
223
|
+
candidateKey: key,
|
|
224
|
+
outcome: "created"
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
export { emptyUserModelCaptureResult, executeUserModelInterpretation };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { emptyUserModelCaptureResult, executeUserModelInterpretation } from "./executor.js";
|
|
2
|
+
import { USER_MODEL_CAPTURE_INTENTS, parseUserModelInterpretation } from "./semantic.js";
|
|
3
|
+
export { USER_MODEL_CAPTURE_INTENTS, emptyUserModelCaptureResult, executeUserModelInterpretation, parseUserModelInterpretation };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AssertionCandidate } from '../domain.js';
|
|
2
|
+
export declare const USER_MODEL_CAPTURE_INTENTS: readonly ["remember", "query", "confirm", "correct", "forget", "user_assertion", "task", "none"];
|
|
3
|
+
export type UserModelCaptureIntent = typeof USER_MODEL_CAPTURE_INTENTS[number];
|
|
4
|
+
export interface CaptureEvidence {
|
|
5
|
+
ref: string;
|
|
6
|
+
role: 'user' | 'assistant';
|
|
7
|
+
text: string;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ParsedAssertionCandidate extends AssertionCandidate {
|
|
11
|
+
evidenceRefs: string[];
|
|
12
|
+
temporalResolution: 'exact' | 'relative_resolved' | 'unresolved';
|
|
13
|
+
originalTimePhrase?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ParsedGoalCandidate {
|
|
16
|
+
title: string;
|
|
17
|
+
desiredOutcome: string;
|
|
18
|
+
scope: AssertionCandidate['scope'];
|
|
19
|
+
declaredImportance?: number;
|
|
20
|
+
targetAt?: number;
|
|
21
|
+
evidenceRefs: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface ParsedCollaborationRuleCandidate {
|
|
24
|
+
category: 'communication' | 'execution' | 'boundary' | 'routine' | 'proactive';
|
|
25
|
+
priority: number;
|
|
26
|
+
scope: AssertionCandidate['scope'];
|
|
27
|
+
conditions: Record<string, unknown>;
|
|
28
|
+
statement: string;
|
|
29
|
+
evidenceRefs: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface UserModelInterpretation {
|
|
32
|
+
intent: UserModelCaptureIntent;
|
|
33
|
+
candidates: ParsedAssertionCandidate[];
|
|
34
|
+
goals?: ParsedGoalCandidate[];
|
|
35
|
+
collaborationRules?: ParsedCollaborationRuleCandidate[];
|
|
36
|
+
targetAssertionIds: string[];
|
|
37
|
+
abstentionReason?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function parseUserModelInterpretation(raw: string, evidence: CaptureEvidence[], allowedTargetIds?: string[]): UserModelInterpretation | null;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/user-model/capture/semantic.ts
|
|
3
|
+
const USER_MODEL_CAPTURE_INTENTS = [
|
|
4
|
+
"remember",
|
|
5
|
+
"query",
|
|
6
|
+
"confirm",
|
|
7
|
+
"correct",
|
|
8
|
+
"forget",
|
|
9
|
+
"user_assertion",
|
|
10
|
+
"task",
|
|
11
|
+
"none"
|
|
12
|
+
];
|
|
13
|
+
const ScopeSchema = z.object({
|
|
14
|
+
type: z.enum([
|
|
15
|
+
"global",
|
|
16
|
+
"agent",
|
|
17
|
+
"workspace",
|
|
18
|
+
"project",
|
|
19
|
+
"session"
|
|
20
|
+
]),
|
|
21
|
+
id: z.string().min(1).optional()
|
|
22
|
+
}).strict().superRefine((scope, ctx) => {
|
|
23
|
+
if (scope.type === "global" && scope.id) ctx.addIssue({
|
|
24
|
+
code: "custom",
|
|
25
|
+
message: "Global scope has no id."
|
|
26
|
+
});
|
|
27
|
+
if (scope.type !== "global" && !scope.id) ctx.addIssue({
|
|
28
|
+
code: "custom",
|
|
29
|
+
message: `${scope.type} scope needs an id.`
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
const CandidateSchema = z.object({
|
|
33
|
+
subject: z.object({
|
|
34
|
+
type: z.enum([
|
|
35
|
+
"user",
|
|
36
|
+
"person",
|
|
37
|
+
"goal",
|
|
38
|
+
"project",
|
|
39
|
+
"topic"
|
|
40
|
+
]),
|
|
41
|
+
id: z.string().min(1).max(160)
|
|
42
|
+
}).strict(),
|
|
43
|
+
predicate: z.string().regex(/^[a-z][a-z0-9_.-]{2,119}$/),
|
|
44
|
+
cardinality: z.enum(["single", "multiple"]),
|
|
45
|
+
scope: ScopeSchema,
|
|
46
|
+
kind: z.enum([
|
|
47
|
+
"identity",
|
|
48
|
+
"preference",
|
|
49
|
+
"value",
|
|
50
|
+
"routine",
|
|
51
|
+
"capability",
|
|
52
|
+
"relationship",
|
|
53
|
+
"current_state",
|
|
54
|
+
"derived_insight"
|
|
55
|
+
]),
|
|
56
|
+
value: z.unknown(),
|
|
57
|
+
normalizedValue: z.string().min(1).max(600),
|
|
58
|
+
statement: z.string().min(4).max(600),
|
|
59
|
+
authority: z.enum([
|
|
60
|
+
"user_explicit",
|
|
61
|
+
"user_observed",
|
|
62
|
+
"system_inferred",
|
|
63
|
+
"external_untrusted"
|
|
64
|
+
]),
|
|
65
|
+
confidence: z.number().min(0).max(1),
|
|
66
|
+
declaredImportance: z.number().min(0).max(1).optional(),
|
|
67
|
+
inferredImportance: z.number().min(0).max(1),
|
|
68
|
+
consequence: z.enum([
|
|
69
|
+
"low",
|
|
70
|
+
"medium",
|
|
71
|
+
"high",
|
|
72
|
+
"critical"
|
|
73
|
+
]),
|
|
74
|
+
actionability: z.number().min(0).max(1),
|
|
75
|
+
volatility: z.enum([
|
|
76
|
+
"stable",
|
|
77
|
+
"slow",
|
|
78
|
+
"dynamic",
|
|
79
|
+
"event"
|
|
80
|
+
]),
|
|
81
|
+
sensitivity: z.enum([
|
|
82
|
+
"normal",
|
|
83
|
+
"personal",
|
|
84
|
+
"secret",
|
|
85
|
+
"regulated"
|
|
86
|
+
]),
|
|
87
|
+
disclosurePolicy: z.enum([
|
|
88
|
+
"silent",
|
|
89
|
+
"referenceable",
|
|
90
|
+
"ask_before_reference"
|
|
91
|
+
]),
|
|
92
|
+
applicability: z.record(z.string(), z.unknown()).default({}),
|
|
93
|
+
validFrom: z.string().datetime({ offset: true }).optional(),
|
|
94
|
+
validTo: z.string().datetime({ offset: true }).optional(),
|
|
95
|
+
reviewAt: z.string().datetime({ offset: true }).optional(),
|
|
96
|
+
temporalResolution: z.enum([
|
|
97
|
+
"exact",
|
|
98
|
+
"relative_resolved",
|
|
99
|
+
"unresolved"
|
|
100
|
+
]),
|
|
101
|
+
originalTimePhrase: z.string().max(200).optional(),
|
|
102
|
+
correctionOfAssertionId: z.string().min(1).optional(),
|
|
103
|
+
evidence: z.array(z.object({
|
|
104
|
+
ref: z.string().min(1),
|
|
105
|
+
quote: z.string().min(1)
|
|
106
|
+
}).strict()).min(1).max(8),
|
|
107
|
+
selfContained: z.boolean(),
|
|
108
|
+
unresolvedReferences: z.array(z.string()).max(8)
|
|
109
|
+
}).strict();
|
|
110
|
+
const GroundingSchema = z.object({
|
|
111
|
+
evidence: z.array(z.object({
|
|
112
|
+
ref: z.string().min(1),
|
|
113
|
+
quote: z.string().min(1)
|
|
114
|
+
}).strict()).min(1).max(8),
|
|
115
|
+
selfContained: z.boolean(),
|
|
116
|
+
unresolvedReferences: z.array(z.string()).max(8)
|
|
117
|
+
});
|
|
118
|
+
const GoalSchema = z.object({
|
|
119
|
+
title: z.string().min(1).max(200),
|
|
120
|
+
desiredOutcome: z.string().min(1).max(600),
|
|
121
|
+
scope: ScopeSchema,
|
|
122
|
+
declaredImportance: z.number().min(0).max(1).optional(),
|
|
123
|
+
targetAt: z.string().datetime({ offset: true }).optional()
|
|
124
|
+
}).merge(GroundingSchema).strict();
|
|
125
|
+
const CollaborationRuleSchema = z.object({
|
|
126
|
+
category: z.enum([
|
|
127
|
+
"communication",
|
|
128
|
+
"execution",
|
|
129
|
+
"boundary",
|
|
130
|
+
"routine",
|
|
131
|
+
"proactive"
|
|
132
|
+
]),
|
|
133
|
+
priority: z.number().int().min(0).max(100),
|
|
134
|
+
scope: ScopeSchema,
|
|
135
|
+
conditions: z.record(z.string(), z.unknown()).default({}),
|
|
136
|
+
statement: z.string().min(4).max(600)
|
|
137
|
+
}).merge(GroundingSchema).strict();
|
|
138
|
+
const InterpretationSchema = z.object({
|
|
139
|
+
intent: z.enum(USER_MODEL_CAPTURE_INTENTS),
|
|
140
|
+
candidates: z.array(CandidateSchema).max(8),
|
|
141
|
+
goals: z.array(GoalSchema).max(4).default([]),
|
|
142
|
+
collaborationRules: z.array(CollaborationRuleSchema).max(4).default([]),
|
|
143
|
+
targetAssertionIds: z.array(z.string().min(1)).max(8),
|
|
144
|
+
abstentionReason: z.string().max(500).optional()
|
|
145
|
+
}).strict();
|
|
146
|
+
function extractJson(raw) {
|
|
147
|
+
const fenced = /```(?:json)?\s*([\s\S]*?)```/i.exec(raw)?.[1];
|
|
148
|
+
const start = raw.indexOf("{");
|
|
149
|
+
const end = raw.lastIndexOf("}");
|
|
150
|
+
return JSON.parse(fenced ?? (start >= 0 && end > start ? raw.slice(start, end + 1) : raw));
|
|
151
|
+
}
|
|
152
|
+
function comparable(value) {
|
|
153
|
+
return value.normalize("NFKC").toLocaleLowerCase().replace(/\s+/g, " ").trim();
|
|
154
|
+
}
|
|
155
|
+
function effectiveAuthority(intent, authority) {
|
|
156
|
+
if (intent === "remember" || intent === "correct" || intent === "confirm") return authority;
|
|
157
|
+
return authority === "user_explicit" ? "user_observed" : authority;
|
|
158
|
+
}
|
|
159
|
+
function parseTime(value) {
|
|
160
|
+
return value === void 0 ? void 0 : Date.parse(value);
|
|
161
|
+
}
|
|
162
|
+
function groundedEvidenceRefs(item, evidenceByRef) {
|
|
163
|
+
if (!item.selfContained || item.unresolvedReferences.length) return void 0;
|
|
164
|
+
return item.evidence.every((claim) => {
|
|
165
|
+
const source = evidenceByRef.get(claim.ref);
|
|
166
|
+
return source?.role === "user" && comparable(source.text).includes(comparable(claim.quote));
|
|
167
|
+
}) ? [...new Set(item.evidence.map((claim) => claim.ref))] : void 0;
|
|
168
|
+
}
|
|
169
|
+
function parseUserModelInterpretation(raw, evidence, allowedTargetIds = []) {
|
|
170
|
+
let parsed;
|
|
171
|
+
try {
|
|
172
|
+
const result = InterpretationSchema.safeParse(extractJson(raw));
|
|
173
|
+
if (!result.success) return null;
|
|
174
|
+
parsed = result.data;
|
|
175
|
+
} catch {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const evidenceByRef = new Map(evidence.map((item) => [item.ref, item]));
|
|
179
|
+
const candidateIntents = new Set([
|
|
180
|
+
"remember",
|
|
181
|
+
"correct",
|
|
182
|
+
"confirm",
|
|
183
|
+
"user_assertion"
|
|
184
|
+
]);
|
|
185
|
+
const candidates = [];
|
|
186
|
+
if (candidateIntents.has(parsed.intent)) for (const item of parsed.candidates) {
|
|
187
|
+
const evidenceRefs = groundedEvidenceRefs(item, evidenceByRef);
|
|
188
|
+
if (!evidenceRefs) continue;
|
|
189
|
+
const observedAt = Math.max(...item.evidence.map((claim) => evidenceByRef.get(claim.ref).createdAt));
|
|
190
|
+
candidates.push({
|
|
191
|
+
subject: item.subject,
|
|
192
|
+
predicate: item.predicate,
|
|
193
|
+
cardinality: item.cardinality,
|
|
194
|
+
scope: item.scope,
|
|
195
|
+
kind: item.kind,
|
|
196
|
+
value: item.value,
|
|
197
|
+
normalizedValue: item.normalizedValue,
|
|
198
|
+
statement: item.statement,
|
|
199
|
+
authority: effectiveAuthority(parsed.intent, item.authority),
|
|
200
|
+
confidence: item.confidence,
|
|
201
|
+
...item.declaredImportance === void 0 ? {} : { declaredImportance: item.declaredImportance },
|
|
202
|
+
inferredImportance: item.inferredImportance,
|
|
203
|
+
consequence: item.consequence,
|
|
204
|
+
actionability: item.actionability,
|
|
205
|
+
volatility: item.volatility,
|
|
206
|
+
sensitivity: item.sensitivity,
|
|
207
|
+
disclosurePolicy: item.disclosurePolicy,
|
|
208
|
+
applicability: item.applicability,
|
|
209
|
+
...item.temporalResolution === "unresolved" ? {} : {
|
|
210
|
+
...item.validFrom ? { validFrom: parseTime(item.validFrom) } : {},
|
|
211
|
+
...item.validTo ? { validTo: parseTime(item.validTo) } : {},
|
|
212
|
+
...item.reviewAt ? { reviewAt: parseTime(item.reviewAt) } : {}
|
|
213
|
+
},
|
|
214
|
+
temporalResolution: item.temporalResolution,
|
|
215
|
+
...item.originalTimePhrase ? { originalTimePhrase: item.originalTimePhrase } : {},
|
|
216
|
+
...item.correctionOfAssertionId && allowedTargetIds.includes(item.correctionOfAssertionId) ? { correctionOfAssertionId: item.correctionOfAssertionId } : {},
|
|
217
|
+
observedAt,
|
|
218
|
+
createdBy: "runtime",
|
|
219
|
+
evidenceRefs
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const structuredIntents = new Set([
|
|
223
|
+
"remember",
|
|
224
|
+
"confirm",
|
|
225
|
+
"correct",
|
|
226
|
+
"user_assertion"
|
|
227
|
+
]);
|
|
228
|
+
const goals = structuredIntents.has(parsed.intent) ? parsed.goals.flatMap((item) => {
|
|
229
|
+
const evidenceRefs = groundedEvidenceRefs(item, evidenceByRef);
|
|
230
|
+
if (!evidenceRefs) return [];
|
|
231
|
+
return [{
|
|
232
|
+
title: item.title,
|
|
233
|
+
desiredOutcome: item.desiredOutcome,
|
|
234
|
+
scope: item.scope,
|
|
235
|
+
...item.declaredImportance === void 0 ? {} : { declaredImportance: item.declaredImportance },
|
|
236
|
+
...item.targetAt === void 0 ? {} : { targetAt: parseTime(item.targetAt) },
|
|
237
|
+
evidenceRefs
|
|
238
|
+
}];
|
|
239
|
+
}) : [];
|
|
240
|
+
const collaborationRules = structuredIntents.has(parsed.intent) ? parsed.collaborationRules.flatMap((item) => {
|
|
241
|
+
const evidenceRefs = groundedEvidenceRefs(item, evidenceByRef);
|
|
242
|
+
if (!evidenceRefs || item.scope.type === "agent") return [];
|
|
243
|
+
return [{
|
|
244
|
+
category: item.category,
|
|
245
|
+
priority: item.priority,
|
|
246
|
+
scope: item.scope,
|
|
247
|
+
conditions: item.conditions,
|
|
248
|
+
statement: item.statement,
|
|
249
|
+
evidenceRefs
|
|
250
|
+
}];
|
|
251
|
+
}) : [];
|
|
252
|
+
const allowed = new Set(allowedTargetIds);
|
|
253
|
+
return {
|
|
254
|
+
intent: parsed.intent,
|
|
255
|
+
candidates,
|
|
256
|
+
goals,
|
|
257
|
+
collaborationRules,
|
|
258
|
+
targetAssertionIds: [...new Set(parsed.targetAssertionIds.filter((id) => allowed.has(id)))],
|
|
259
|
+
...parsed.abstentionReason ? { abstentionReason: parsed.abstentionReason } : {}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
export { USER_MODEL_CAPTURE_INTENTS, parseUserModelInterpretation };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare const USER_MODEL_PRINCIPAL_ID = "local-owner";
|
|
2
|
+
export type UserModelScopeType = 'global' | 'agent' | 'workspace' | 'project' | 'session';
|
|
3
|
+
export type AssertionSubjectType = 'user' | 'person' | 'goal' | 'project' | 'topic';
|
|
4
|
+
export type AssertionCardinality = 'single' | 'multiple';
|
|
5
|
+
export type AssertionKind = 'identity' | 'preference' | 'value' | 'routine' | 'capability' | 'relationship' | 'current_state' | 'derived_insight';
|
|
6
|
+
export type AssertionAuthority = 'user_explicit' | 'user_observed' | 'system_inferred' | 'external_untrusted';
|
|
7
|
+
export type AssertionStatus = 'candidate' | 'active' | 'needs_review' | 'conflicted' | 'stale' | 'archived' | 'rejected';
|
|
8
|
+
export type AssertionConsequence = 'low' | 'medium' | 'high' | 'critical';
|
|
9
|
+
export type AssertionVolatility = 'stable' | 'slow' | 'dynamic' | 'event';
|
|
10
|
+
export type AssertionCreator = 'user' | 'runtime' | 'connector' | 'maintenance' | 'migration';
|
|
11
|
+
export type AssertionSensitivity = 'normal' | 'personal' | 'secret' | 'regulated';
|
|
12
|
+
export type AssertionDisclosurePolicy = 'silent' | 'referenceable' | 'ask_before_reference';
|
|
13
|
+
export interface UserModelScope {
|
|
14
|
+
type: UserModelScopeType;
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AssertionSubject {
|
|
18
|
+
type: AssertionSubjectType;
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AssertionSlot {
|
|
22
|
+
id: string;
|
|
23
|
+
principalId: string;
|
|
24
|
+
subject: AssertionSubject;
|
|
25
|
+
predicate: string;
|
|
26
|
+
cardinality: AssertionCardinality;
|
|
27
|
+
scope: UserModelScope;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
export interface UserAssertion {
|
|
31
|
+
id: string;
|
|
32
|
+
slotId: string;
|
|
33
|
+
kind: AssertionKind;
|
|
34
|
+
value: unknown;
|
|
35
|
+
normalizedValue: string;
|
|
36
|
+
statement: string;
|
|
37
|
+
authority: AssertionAuthority;
|
|
38
|
+
status: AssertionStatus;
|
|
39
|
+
confidence: number;
|
|
40
|
+
declaredImportance?: number;
|
|
41
|
+
inferredImportance: number;
|
|
42
|
+
consequence: AssertionConsequence;
|
|
43
|
+
actionability: number;
|
|
44
|
+
volatility: AssertionVolatility;
|
|
45
|
+
sensitivity: AssertionSensitivity;
|
|
46
|
+
disclosurePolicy: AssertionDisclosurePolicy;
|
|
47
|
+
applicability: Record<string, unknown>;
|
|
48
|
+
validFrom?: number;
|
|
49
|
+
validTo?: number;
|
|
50
|
+
observedAt: number;
|
|
51
|
+
recordedAt: number;
|
|
52
|
+
reviewAt?: number;
|
|
53
|
+
supersedesAssertionId?: string;
|
|
54
|
+
createdBy: AssertionCreator;
|
|
55
|
+
createdAt: number;
|
|
56
|
+
}
|
|
57
|
+
export interface AssertionCandidate {
|
|
58
|
+
principalId?: string;
|
|
59
|
+
subject: AssertionSubject;
|
|
60
|
+
predicate: string;
|
|
61
|
+
cardinality: AssertionCardinality;
|
|
62
|
+
scope: UserModelScope;
|
|
63
|
+
kind: AssertionKind;
|
|
64
|
+
value: unknown;
|
|
65
|
+
normalizedValue: string;
|
|
66
|
+
statement: string;
|
|
67
|
+
authority: AssertionAuthority;
|
|
68
|
+
confidence: number;
|
|
69
|
+
declaredImportance?: number;
|
|
70
|
+
inferredImportance: number;
|
|
71
|
+
consequence: AssertionConsequence;
|
|
72
|
+
actionability: number;
|
|
73
|
+
volatility: AssertionVolatility;
|
|
74
|
+
sensitivity: AssertionSensitivity;
|
|
75
|
+
disclosurePolicy: AssertionDisclosurePolicy;
|
|
76
|
+
applicability?: Record<string, unknown>;
|
|
77
|
+
validFrom?: number;
|
|
78
|
+
validTo?: number;
|
|
79
|
+
observedAt: number;
|
|
80
|
+
reviewAt?: number;
|
|
81
|
+
createdBy: AssertionCreator;
|
|
82
|
+
evidenceId?: string;
|
|
83
|
+
evidenceConfidence?: number;
|
|
84
|
+
correctionOfAssertionId?: string;
|
|
85
|
+
}
|
|
86
|
+
export type ReconciliationAction = 'created' | 'deduplicated' | 'superseded' | 'conflicted';
|
|
87
|
+
export interface ReconciliationResult {
|
|
88
|
+
action: ReconciliationAction;
|
|
89
|
+
assertion: UserAssertion;
|
|
90
|
+
previousAssertion?: UserAssertion;
|
|
91
|
+
}
|
|
92
|
+
export declare function validateScope(scope: UserModelScope): void;
|
|
93
|
+
export declare function validateCandidate(candidate: AssertionCandidate): void;
|