@xopcai/xopc 0.0.188 → 0.0.190
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/README.md +1 -4
- package/README.zh-CN.md +0 -3
- 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--QoUGhiS.js → activity-store-DstnJCS5.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0yweLNQ.js → agent-avatar-dicebear-9vAbkroX.js} +1 -1
- package/dist/gateway/static/root/assets/agents-D1t4SfMQ.js +68 -0
- package/dist/gateway/static/root/assets/{api-5laWqfiE.js → api-BTL9kayv.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BXJ8Jiv_.js → app-management-settings-panel-DkFeIdBf.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DG9n9D1M.js → appearance-settings-Bxs8Fpaj.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-Cgrgu5OW.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Ceh5qrZf.js → archive-plugin-Ch2RmLCC.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-jFW7uYf7.js → attachment-load-BhMQM_Ky.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-CtJxstKh.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-XDlkI1r4.js → binary-plugins-D6CqlymH.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-kyKc2IhE.js → block-editor-ClL6HEg9.js} +56 -56
- package/dist/gateway/static/root/assets/browser-settings-page-DW99iDmD.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BJa5Iz_v.js → browser-workflow-inputs-BYy48VhN.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CTQQOsn5.js → browser-workflows-page-zgLibuMH.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CHUrT9EB.js +7 -0
- package/dist/gateway/static/root/assets/capability-presets-api-BB8t4Ja7.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Cycrv0YV.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-BgIkWq01.js → channel-recipient-api-BThDGiO3.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-V96gPUAU.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-Cz7SAAkm.js +1 -0
- package/dist/gateway/static/root/assets/connectors-api-DS9ED-EL.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BhlyQoQI.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-CkgsvhtW.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-CSwd00CV.js → desktop-pet-Cv8rGhYW.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CuNQvHGu.js → desktop-pet-settings-CIeJdwfV.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ct0n5Rje.js → directory-picker-path-field-D8jXEiAY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BeRBuMUU.js → extension-debug-page-CCZ9u6TZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DbK-Cwao.js → extension-page-CV36ILRG.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-IyQrSILY.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-CC7EvEFp.js → gateway-config-api-D4_r5iJM.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-CYlntpBH.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B2DmdlwO.js → gateway-startup-retry-EO9mKvzE.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-D4SyWob8.js +1 -0
- package/dist/gateway/static/root/assets/home-page-B2Kagoh8.js +3 -0
- package/dist/gateway/static/root/assets/{image-generation-api-GMTaS6eI.js → image-generation-api-Bu7PyVSh.js} +1 -1
- package/dist/gateway/static/root/assets/index-CYT5DOzr.js +150 -0
- package/dist/gateway/static/root/assets/index-D6e3tPL-.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DhGYddbI.js → keyboard-shortcuts-settings-BMhCuVBZ.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BHYbFjqy.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CmnrBmWi.js → local-apps-page-ijIe7_y2.js} +1 -1
- package/dist/gateway/static/root/assets/locale-store-deR2zRaE.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-IIn8Tess.js +2 -0
- package/dist/gateway/static/root/assets/management-settings--V_fovKD.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-split-CZaBPOVn.js → markdown-split-Dt9-in6W.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CiKvSgCv.js → media-plugins-B3pj_iO0.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B4XqB8I6.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-Bisbzqlz.js → notes-page-DZ366lIT.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-S2sBVOLw.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BxlwhAbH.js → page-tabs-C5ge434C.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-RM8wXxfT.js → preview-open-alternatives-BFa9DgSV.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-tRr-7IxY.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-DdBlibek.js → product-open-page-Dc9CcWdu.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BilzoCJ7.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BoQUyacP.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DUyUaCRF.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-BDKbpmXv.js → schema-form-B84DckWe.js} +1 -1
- package/dist/gateway/static/root/assets/{schemas-C6onAggk.js → schemas-zIBW3wiV.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-Dzxlq1F0.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-TzwlZxU6.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-Dp9itvdy.js +1 -0
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DgIp8_S6.js → settings-loading-skeleton-CCtlhoy7.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-DQmMKf8r.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-97LmwrzC.js → settings-page-layout-EQIOJa_L.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Cwi-SPja.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BH7i3g1S.js → share-preview-page-C4_B2jvf.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CkyuGlZK.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BJCePQK5.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BYWLfmJi.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-s-a5WV9j.js → skills-page.utils-Jhm24i4h.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BxjeMT5k.js → system-settings-panel-Dpx2ags2.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BahycnfW.js → task-detail-page-DLAdxI6e.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BRxdsmic.js → theme-store-DnBOcGXi.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-39MjwPSq.js → typed-models-lib-DULmTHUB.js} +1 -1
- package/dist/gateway/static/root/assets/use-autosave-BrjVk5VH.js +1 -0
- package/dist/gateway/static/root/assets/user-context-page-9AAFpGAL.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-XU-7sBSg.js → voice-api-key-field-BISTPfq_.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CJqu8UHq.js → work-discovery-overlay-Wr-uF7VA.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BWds95sL.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DXtg8Qxl.js → workflow-run-setup-panel-DHqHP8_6.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-0b4_DFHr.js +11 -0
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/packages/endpoint-tools-protocol/src/index.js +184 -0
- package/dist/packages/gateway-contract/src/tool-activity.js +0 -36
- package/dist/packages/realtime-client/src/index.js +256 -0
- package/dist/packages/realtime-protocol/src/index.js +88 -0
- package/dist/src/agent/agent-manager.d.ts +1 -1
- package/dist/src/agent/agent-manager.js +7 -13
- package/dist/src/agent/background-review/coordinator.js +1 -1
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +3 -1
- package/dist/src/agent/background-review/run-background-review.d.ts +2 -0
- package/dist/src/agent/background-review/run-background-review.js +10 -9
- package/dist/src/agent/bootstrap/bootstrap-cache.d.ts +0 -1
- package/dist/src/agent/bootstrap/bootstrap-cache.js +3 -4
- package/dist/src/agent/bootstrap/bootstrap-files.d.ts +0 -4
- package/dist/src/agent/bootstrap/bootstrap-files.js +3 -4
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -4
- package/dist/src/agent/bootstrap/load-bootstrap-files.d.ts +0 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -14
- package/dist/src/agent/bootstrap/types.d.ts +1 -1
- package/dist/src/agent/client-error-format.d.ts +1 -1
- package/dist/src/agent/client-error-format.js +1 -1
- package/dist/src/agent/context/workspace-templates/SOUL.md +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.d.ts +17 -0
- package/dist/src/agent/external-tools/endpoint-provider.js +93 -0
- package/dist/src/agent/external-tools/gateway-tools.js +1 -1
- package/dist/src/agent/external-tools/index.d.ts +4 -5
- package/dist/src/agent/external-tools/index.js +8 -2
- package/dist/src/agent/external-tools/types.d.ts +8 -1
- package/dist/src/agent/external-tools/types.js +2 -1
- package/dist/src/agent/inbound/inbound-loop.js +4 -0
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +9 -8
- package/dist/src/agent/inbound/turn-dispatcher.js +13 -11
- package/dist/src/agent/memory/builtin-provider.d.ts +2 -4
- package/dist/src/agent/memory/builtin-provider.js +35 -15
- package/dist/src/agent/memory/context/types.d.ts +3 -1
- package/dist/src/agent/memory/create-memory-manager.js +2 -0
- package/dist/src/agent/memory/index.d.ts +1 -1
- package/dist/src/agent/memory/index.js +1 -1
- package/dist/src/agent/memory/manager.d.ts +9 -1
- package/dist/src/agent/memory/manager.js +39 -9
- package/dist/src/agent/memory/memory-config.d.ts +1 -1
- package/dist/src/agent/memory/memory-config.js +1 -1
- package/dist/src/agent/memory/source-origin.js +0 -2
- package/dist/src/agent/memory/types.d.ts +5 -1
- package/dist/src/agent/memory/understanding/service.d.ts +10 -10
- package/dist/src/agent/memory/understanding/service.js +108 -176
- package/dist/src/agent/memory/understanding/types.d.ts +7 -8
- package/dist/src/agent/memory/user-context-coordinator.d.ts +2 -1
- package/dist/src/agent/memory/user-context-coordinator.js +27 -41
- package/dist/src/agent/messaging/command-handler.d.ts +2 -2
- package/dist/src/agent/messaging/command-handler.js +3 -3
- package/dist/src/agent/orchestration/agent-orchestrator.js +4 -7
- package/dist/src/agent/prompt/sections/memory-skills.js +4 -4
- package/dist/src/agent/prompt/sections/tooling.js +0 -10
- package/dist/src/agent/prompt/service-prompt-builder.d.ts +0 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -33
- package/dist/src/agent/prompt/system-prompt.js +1 -2
- package/dist/src/agent/service/async-queue.d.ts +1 -1
- package/dist/src/agent/service/async-queue.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +2 -2
- package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -1
- package/dist/src/agent/service/process-direct-one-shot.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.d.ts +7 -5
- package/dist/src/agent/service/process-direct-streaming.js +5 -5
- package/dist/src/agent/service.d.ts +2 -3
- package/dist/src/agent/service.js +10 -21
- package/dist/src/agent/service.types.d.ts +2 -0
- package/dist/src/agent/session/index.d.ts +1 -1
- package/dist/src/agent/session/session-context.d.ts +2 -0
- package/dist/src/agent/session/session-context.js +4 -0
- package/dist/src/agent/session/session-state-bag.d.ts +4 -4
- package/dist/src/agent/session/session-state-bag.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js +1 -1
- package/dist/src/agent/streaming/reasoning-visibility.d.ts +6 -0
- package/dist/src/agent/streaming/{reasoning-visibility-sse.js → reasoning-visibility.js} +3 -6
- package/dist/src/agent/tools/dreaming-tool.d.ts +0 -2
- package/dist/src/agent/tools/dreaming-tool.js +13 -38
- package/dist/src/agent/tools/factory.d.ts +4 -3
- package/dist/src/agent/tools/factory.js +2 -10
- package/dist/src/agent/tools/index.d.ts +0 -1
- package/dist/src/agent/tools/index.js +1 -2
- package/dist/src/agent/tools/memory-tool.js +1 -1
- package/dist/src/agent/workspace-runtime/registry.d.ts +3 -5
- package/dist/src/agent/workspace-runtime/registry.js +2 -15
- package/dist/src/agent-manifest/schema.d.ts +17 -17
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/memory-runtime.d.ts +2 -2
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/automations/domain/types.d.ts +2 -1
- package/dist/src/automations/domain/validation.d.ts +29 -29
- package/dist/src/automations/draft/automation-draft-validator.d.ts +3 -3
- package/dist/src/automations/service/action-executor.js +4 -1
- package/dist/src/channels/pairing/pairing-challenge.d.ts +1 -1
- package/dist/src/channels/pairing/pairing-challenge.js +1 -1
- package/dist/src/chat-commands/builtins/understanding.js +2 -5
- package/dist/src/cli/commands/agent/stream-renderer.js +4 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/init.js +3 -22
- package/dist/src/cli/templates.js +1 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/paths.d.ts +0 -5
- package/dist/src/config/paths.js +2 -11
- package/dist/src/config/rules.js +0 -5
- package/dist/src/config/schema.d.ts +27 -122
- package/dist/src/config/schema.js +9 -42
- package/dist/src/config/web-patch.js +0 -1
- package/dist/src/connectors/learning-coordinator.js +75 -3
- package/dist/src/endpoint-tools/auth.d.ts +20 -0
- package/dist/src/endpoint-tools/auth.js +51 -0
- package/dist/src/endpoint-tools/index.d.ts +5 -0
- package/dist/src/endpoint-tools/index.js +6 -0
- package/dist/src/endpoint-tools/invocation-service.d.ts +68 -0
- package/dist/src/endpoint-tools/invocation-service.js +190 -0
- package/dist/src/endpoint-tools/policy.d.ts +10 -0
- package/dist/src/endpoint-tools/policy.js +18 -0
- package/dist/src/endpoint-tools/registry.d.ts +45 -0
- package/dist/src/endpoint-tools/registry.js +121 -0
- package/dist/src/endpoint-tools/runtime.d.ts +23 -0
- package/dist/src/endpoint-tools/runtime.js +86 -0
- package/dist/src/endpoint-tools/upload-service.d.ts +41 -0
- package/dist/src/endpoint-tools/upload-service.js +103 -0
- package/dist/src/extensions/types/hooks.d.ts +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +0 -5
- package/dist/src/gateway/agents-admin.d.ts +0 -7
- package/dist/src/gateway/agents-admin.js +3 -32
- package/dist/src/gateway/chat-stream/protocol.d.ts +0 -1
- package/dist/src/gateway/clarify-bridge.d.ts +5 -4
- package/dist/src/gateway/clarify-bridge.js +3 -4
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +3 -3
- package/dist/src/gateway/dreaming-automation-reconciler.js +48 -88
- package/dist/src/gateway/heartbeat/service.js +4 -1
- package/dist/src/gateway/hono/app.js +1 -5
- package/dist/src/gateway/hono/index.d.ts +0 -1
- package/dist/src/gateway/hono/index.js +1 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +20 -9
- package/dist/src/gateway/hono/lib/config-payload.js +3 -2
- package/dist/src/gateway/hono/middleware/auth.js +3 -5
- package/dist/src/gateway/hono/oauth-async.d.ts +1 -0
- package/dist/src/gateway/hono/oauth-async.js +17 -2
- package/dist/src/gateway/hono/routes/agent-stream.js +49 -6
- package/dist/src/gateway/hono/routes/agents.js +1 -33
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +0 -19
- package/dist/src/gateway/hono/routes/config-patch/misc.js +17 -1
- package/dist/src/gateway/hono/routes/connectors.js +13 -12
- package/dist/src/gateway/hono/routes/deps.d.ts +0 -2
- package/dist/src/gateway/hono/routes/endpoint-tools.d.ts +3 -0
- package/dist/src/gateway/hono/routes/endpoint-tools.js +196 -0
- package/dist/src/gateway/hono/routes/index.js +6 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -5
- package/dist/src/gateway/hono/routes/logs.js +0 -4
- package/dist/src/gateway/hono/routes/public-gateway.js +2 -2
- package/dist/src/gateway/hono/routes/realtime.d.ts +3 -0
- package/dist/src/gateway/hono/routes/realtime.js +35 -0
- package/dist/src/gateway/hono/routes/status.js +0 -7
- package/dist/src/gateway/hono/routes/understanding-sources.d.ts +3 -0
- package/dist/src/gateway/hono/routes/understanding-sources.js +203 -0
- package/dist/src/gateway/hono/routes/work-discovery.d.ts +2 -0
- package/dist/src/gateway/hono/routes/work-discovery.js +3 -134
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/you.d.ts +0 -31
- package/dist/src/gateway/hono/routes/you.js +230 -1161
- package/dist/src/gateway/index.d.ts +1 -1
- package/dist/src/gateway/index.js +1 -2
- package/dist/src/gateway/protocol.d.ts +1 -7
- package/dist/src/gateway/security/index.js +1 -1
- package/dist/src/gateway/security/operator-scopes.js +1 -1
- package/dist/src/gateway/server.js +4 -4
- package/dist/src/gateway/service/agent-runner.d.ts +11 -9
- package/dist/src/gateway/service/agent-runner.js +18 -18
- package/dist/src/gateway/service/config-coordinator.d.ts +3 -3
- package/dist/src/gateway/service/run-gateway-agent.d.ts +4 -3
- package/dist/src/gateway/service/run-gateway-agent.js +15 -17
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +4 -2
- package/dist/src/gateway/service/types.d.ts +0 -5
- package/dist/src/gateway/service.d.ts +7 -6
- package/dist/src/gateway/service.js +43 -26
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +2 -4
- package/dist/src/knowledge/connected-understanding-pipeline.js +31 -81
- package/dist/src/knowledge/index.js +2 -2
- package/dist/src/knowledge/people-graph.d.ts +22 -25
- package/dist/src/knowledge/people-graph.js +76 -43
- package/dist/src/mcp/channel-bridge.d.ts +6 -9
- package/dist/src/mcp/channel-bridge.js +48 -76
- package/dist/src/mcp/channel-server.js +2 -6
- package/dist/src/proactive/execution/context.js +8 -13
- package/dist/src/realtime/broker.d.ts +31 -0
- package/dist/src/realtime/broker.js +114 -0
- package/dist/src/realtime/runtime.d.ts +20 -0
- package/dist/src/realtime/runtime.js +263 -0
- package/dist/src/realtime/tickets.d.ts +15 -0
- package/dist/src/realtime/tickets.js +38 -0
- package/dist/src/realtime/writer.d.ts +15 -0
- package/dist/src/realtime/writer.js +78 -0
- package/dist/src/share/share-config.js +0 -1
- package/dist/src/share/site-share-config.js +0 -1
- package/dist/src/storage/sqlite/connector-account-repository.js +0 -1
- package/dist/src/storage/sqlite/context-consolidation-repository.d.ts +37 -0
- package/dist/src/storage/sqlite/context-consolidation-repository.js +64 -0
- package/dist/src/storage/sqlite/endpoint-principal-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/endpoint-principal-repository.js +54 -0
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +25 -0
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +42 -0
- package/dist/src/storage/sqlite/fts.d.ts +2 -0
- package/dist/src/storage/sqlite/fts.js +29 -1
- package/dist/src/storage/sqlite/index.d.ts +6 -6
- package/dist/src/storage/sqlite/index.js +7 -7
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +9 -2
- package/dist/src/storage/sqlite/knowledge-repository.js +58 -10
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +7 -56
- package/dist/src/storage/sqlite/memory-records-repository.js +68 -218
- package/dist/src/storage/sqlite/migrations/109_endpoint_principals.sql +14 -0
- package/dist/src/storage/sqlite/migrations/110_session_input_origin.sql +43 -0
- package/dist/src/storage/sqlite/migrations/111_endpoint_tool_invocations.sql +18 -0
- package/dist/src/storage/sqlite/migrations/112_endpoint_instance_bindings.sql +8 -0
- package/dist/src/storage/sqlite/migrations/113_memory_evidence_single_source.sql +54 -0
- package/dist/src/storage/sqlite/migrations/114_user_context_domain.sql +193 -0
- package/dist/src/storage/sqlite/migrations/115_remove_legacy_user_context.sql +6 -0
- package/dist/src/storage/sqlite/migrations/116_structured_context_consolidation.sql +38 -0
- package/dist/src/storage/sqlite/migrations/117_unified_understanding_sources.sql +110 -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/schema.sql +0 -20
- package/dist/src/storage/sqlite/session-input-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/session-input-repository.js +5 -3
- package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +34 -0
- package/dist/src/storage/sqlite/user-context-quality-repository.js +74 -0
- package/dist/src/storage/sqlite/user-context-repository.d.ts +64 -0
- package/dist/src/storage/sqlite/user-context-repository.js +383 -0
- package/dist/src/tasks/home-query-service.d.ts +1 -1
- package/dist/src/tui/backends/embedded-backend.js +5 -2
- package/dist/src/tui/backends/{gateway-sse-backend.d.ts → gateway-realtime-backend.d.ts} +13 -10
- package/dist/src/tui/backends/{gateway-sse-backend.js → gateway-realtime-backend.js} +114 -151
- package/dist/src/tui/tool-summary.js +1 -7
- package/dist/src/tui/tui-agent-events.d.ts +0 -1
- package/dist/src/tui/tui-agent-events.js +2 -15
- package/dist/src/tui/tui-backend.d.ts +4 -4
- package/dist/src/tui/tui-run-state.js +0 -4
- package/dist/src/tui/tui-startup-resources.js +1 -2
- package/dist/src/tui/tui-types.d.ts +2 -9
- package/dist/src/tui/tui-types.js +0 -1
- package/dist/src/tui/tui.js +5 -5
- package/dist/src/tunnel/gateway-lifecycle.d.ts +1 -1
- package/dist/src/tunnel/gateway-lifecycle.js +1 -1
- package/dist/src/user-context/config.d.ts +17 -210
- package/dist/src/user-context/config.js +19 -85
- package/dist/src/user-context/consolidation.d.ts +26 -0
- package/dist/src/user-context/consolidation.js +115 -0
- package/dist/src/user-context/domain.d.ts +75 -0
- package/dist/src/user-context/domain.js +4 -0
- package/dist/src/user-context/manual-understanding.d.ts +7 -14
- package/dist/src/user-context/manual-understanding.js +19 -49
- package/dist/src/{agent/memory/context → user-context}/planner.d.ts +5 -6
- package/dist/src/user-context/planner.js +311 -0
- package/dist/src/user-context/relationship-continuity.d.ts +3 -6
- package/dist/src/user-context/relationship-continuity.js +39 -32
- package/dist/src/user-context/sources/catalog.d.ts +2 -0
- package/dist/src/user-context/sources/catalog.js +149 -0
- package/dist/src/user-context/sources/index.d.ts +3 -0
- package/dist/src/user-context/sources/index.js +3 -0
- package/dist/src/user-context/sources/repository.d.ts +40 -0
- package/dist/src/user-context/sources/repository.js +164 -0
- package/dist/src/user-context/sources/types.d.ts +83 -0
- package/dist/src/user-context/understandingQuality.d.ts +5 -0
- package/dist/src/user-context/understandingQuality.js +44 -0
- package/dist/src/utils/logger/log-stream.d.ts +3 -10
- package/dist/src/utils/logger/log-stream.js +2 -73
- package/dist/src/utils/logger/pino-record.d.ts +1 -1
- package/dist/src/utils/logger/streams.js +1 -1
- package/dist/src/work-discovery/analyzer.d.ts +4 -3
- package/dist/src/work-discovery/analyzer.js +21 -16
- package/dist/src/work-discovery/incremental-repository.js +42 -40
- package/dist/src/work-discovery/index.js +3 -3
- package/dist/src/work-discovery/service.d.ts +7 -7
- package/dist/src/work-discovery/service.js +241 -190
- package/dist/src/work-discovery/source-repository.js +42 -53
- package/dist/src/work-discovery/types.d.ts +2 -14
- package/package.json +5 -7
- package/dist/gateway/static/root/assets/agents-C6OV-gMm.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-Ci14lDeO.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Q1xmb4Rh.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DbowrHXD.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DoZPFdKF.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-api-Dn-7MMEo.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Bt8Hnx0h.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-Bpsebsru.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DFmdYRE5.js +0 -1
- package/dist/gateway/static/root/assets/connector-logo-TRr9ybf6.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Tg5kl22i.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-B3B1eqnr.js +0 -2
- package/dist/gateway/static/root/assets/extension-settings-page-C9ag5tb5.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-9g8uIry9.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-fl1oC_-5.js +0 -1
- package/dist/gateway/static/root/assets/home-page-Bao9jq_z.js +0 -3
- package/dist/gateway/static/root/assets/index-Cl5n1f_U.css +0 -1
- package/dist/gateway/static/root/assets/index-OJgiMh07.js +0 -223
- package/dist/gateway/static/root/assets/local-app-workbench-page-B69NvtvH.js +0 -2
- package/dist/gateway/static/root/assets/locale-store-D6hs74o5.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-Cq3cABqg.js +0 -7
- package/dist/gateway/static/root/assets/messages-D02NNLCZ.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-BOZfJFhE.js +0 -4
- package/dist/gateway/static/root/assets/product-delivery-C8JbSj5Y.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-TSKFb2tN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BokeBrTT.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C56anxCX.js +0 -1
- package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-C7TQADrD.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BDOPKeAX.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-zxo5ZGOu.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-BUPSIa9P.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BRg766eW.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DhEAviQ_.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Ct7AV8ls.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DoVuprZm.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-BGk_Tbsj.js +0 -1
- package/dist/gateway/static/root/assets/use-save-bar-registration-5aVSjTjO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-B9K41qmy.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BBVnRHju.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-Bs_tYfst.js +0 -11
- package/dist/src/agent/code-intelligence/binary.d.ts +0 -15
- package/dist/src/agent/code-intelligence/binary.js +0 -372
- package/dist/src/agent/code-intelligence/index.d.ts +0 -4
- package/dist/src/agent/code-intelligence/index.js +0 -4
- package/dist/src/agent/code-intelligence/runtime.d.ts +0 -34
- package/dist/src/agent/code-intelligence/runtime.js +0 -280
- package/dist/src/agent/code-intelligence/tool-gating.d.ts +0 -5
- package/dist/src/agent/code-intelligence/tool-gating.js +0 -6
- package/dist/src/agent/code-intelligence/tools.d.ts +0 -6
- package/dist/src/agent/code-intelligence/tools.js +0 -266
- package/dist/src/agent/code-intelligence/types.d.ts +0 -22
- package/dist/src/agent/memory/context/planner.js +0 -286
- package/dist/src/agent/memory/dreaming/config.d.ts +0 -48
- package/dist/src/agent/memory/dreaming/config.js +0 -98
- package/dist/src/agent/memory/dreaming/constants.d.ts +0 -12
- package/dist/src/agent/memory/dreaming/constants.js +0 -18
- package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +0 -19
- package/dist/src/agent/memory/dreaming/deep-promotion.js +0 -152
- package/dist/src/agent/memory/dreaming/light-sweep.d.ts +0 -16
- package/dist/src/agent/memory/dreaming/light-sweep.js +0 -115
- package/dist/src/agent/memory/dreaming/preview.d.ts +0 -23
- package/dist/src/agent/memory/dreaming/preview.js +0 -52
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.d.ts +0 -16
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +0 -44
- package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +0 -19
- package/dist/src/agent/memory/dreaming/rem-patterns.js +0 -150
- package/dist/src/agent/memory/dreaming/runner.d.ts +0 -10
- package/dist/src/agent/memory/dreaming/runner.js +0 -78
- package/dist/src/agent/memory/dreaming/schedule.d.ts +0 -23
- package/dist/src/agent/memory/dreaming/schedule.js +0 -38
- package/dist/src/agent/memory/dreaming/scope.d.ts +0 -11
- package/dist/src/agent/memory/dreaming/scope.js +0 -33
- package/dist/src/agent/memory/dreaming/utils.d.ts +0 -3
- package/dist/src/agent/memory/dreaming/utils.js +0 -31
- package/dist/src/agent/streaming/reasoning-visibility-sse.d.ts +0 -15
- package/dist/src/gateway/agent-run-relay.d.ts +0 -19
- package/dist/src/gateway/agent-run-relay.js +0 -169
- package/dist/src/gateway/hono/routes/memory.d.ts +0 -3
- package/dist/src/gateway/hono/routes/memory.js +0 -460
- package/dist/src/gateway/hono/sse.d.ts +0 -53
- package/dist/src/gateway/hono/sse.js +0 -207
- package/dist/src/gateway/service/sse-hub.d.ts +0 -10
- package/dist/src/gateway/service/sse-hub.js +0 -53
- package/dist/src/storage/sqlite/dreaming-repository.d.ts +0 -61
- package/dist/src/storage/sqlite/dreaming-repository.js +0 -88
- package/dist/src/storage/sqlite/memory-readiness-repository.d.ts +0 -7
- package/dist/src/storage/sqlite/memory-readiness-repository.js +0 -30
- package/dist/src/storage/sqlite/memory-reference-consent-repository.d.ts +0 -27
- package/dist/src/storage/sqlite/memory-reference-consent-repository.js +0 -107
- package/dist/src/storage/sqlite/user-claims-repository.d.ts +0 -101
- package/dist/src/storage/sqlite/user-claims-repository.js +0 -241
- package/dist/src/storage/sqlite/user-profile-setup-repository.d.ts +0 -3
- package/dist/src/storage/sqlite/user-profile-setup-repository.js +0 -32
- package/dist/src/tui/sse-consumer.d.ts +0 -15
- package/dist/src/tui/sse-consumer.js +0 -73
- package/dist/src/user-context/context-compiler.d.ts +0 -27
- package/dist/src/user-context/context-compiler.js +0 -48
- package/dist/src/user-context/import.d.ts +0 -12
- package/dist/src/user-context/import.js +0 -51
- package/dist/src/user-context/memory-episode-evaluator.d.ts +0 -32
- package/dist/src/user-context/memory-episode-evaluator.js +0 -35
- package/dist/src/user-context/memory-readiness.d.ts +0 -33
- package/dist/src/user-context/memory-readiness.js +0 -41
- package/dist/src/user-context/memory-use-audit.d.ts +0 -10
- package/dist/src/user-context/memory-use-audit.js +0 -26
- package/dist/src/user-context/personal-playbook.d.ts +0 -11
- package/dist/src/user-context/personal-playbook.js +0 -41
- package/dist/src/user-context/profile.d.ts +0 -37
- package/dist/src/user-context/profile.js +0 -163
- package/dist/src/user-context/projection.d.ts +0 -120
- package/dist/src/user-context/projection.js +0 -262
- package/dist/src/user-context/source-recommendations.d.ts +0 -13
- package/dist/src/user-context/source-recommendations.js +0 -85
- /package/dist/src/{agent/code-intelligence → user-context/sources}/types.js +0 -0
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
import { buildFts5SearchQuery, fts5RankToScore, memoryLexicalSimilarity } from "./fts.js";
|
|
2
|
+
import { buildFts5SearchQuery, fts5RankToScore, memoryLexicalSimilarity, memoryVectorSimilarity } from "./fts.js";
|
|
3
3
|
import { LOCAL_USER_ID } from "../../user-context/owner.js";
|
|
4
|
+
import { listMemoryEvidence, listMemoryEvidenceForRecords, replaceMemoryEvidenceForRecord } from "./knowledge-repository.js";
|
|
4
5
|
import { randomUUID } from "node:crypto";
|
|
5
6
|
//#region src/storage/sqlite/memory-records-repository.ts
|
|
6
|
-
const USER_UNDERSTANDING_REMEDIATION_POLICY = {
|
|
7
|
-
minNotHelpful: 2,
|
|
8
|
-
confidencePenalty: .2
|
|
9
|
-
};
|
|
10
7
|
function parseStringArray(json) {
|
|
11
8
|
try {
|
|
12
9
|
const parsed = JSON.parse(json);
|
|
@@ -15,15 +12,6 @@ function parseStringArray(json) {
|
|
|
15
12
|
return [];
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
function parseEvidence(json) {
|
|
19
|
-
try {
|
|
20
|
-
const parsed = JSON.parse(json);
|
|
21
|
-
if (!Array.isArray(parsed)) return [];
|
|
22
|
-
return parsed.filter((item) => Boolean(item) && typeof item === "object");
|
|
23
|
-
} catch {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
15
|
function memoryFeedbackRowToPayload(row) {
|
|
28
16
|
return {
|
|
29
17
|
feedbackId: row.feedback_id,
|
|
@@ -76,7 +64,7 @@ function parseSource(json) {
|
|
|
76
64
|
return {};
|
|
77
65
|
}
|
|
78
66
|
}
|
|
79
|
-
function rowToRecord(row) {
|
|
67
|
+
function rowToRecord(row, evidence = []) {
|
|
80
68
|
return {
|
|
81
69
|
id: row.record_id,
|
|
82
70
|
providerId: row.provider_id,
|
|
@@ -98,7 +86,7 @@ function rowToRecord(row) {
|
|
|
98
86
|
durability: row.durability,
|
|
99
87
|
importance: row.importance,
|
|
100
88
|
disclosurePolicy: row.disclosure_policy,
|
|
101
|
-
evidence
|
|
89
|
+
evidence,
|
|
102
90
|
...timestampToIso(row.valid_from) ? { validFrom: timestampToIso(row.valid_from) } : {},
|
|
103
91
|
...timestampToIso(row.valid_to) ? { validTo: timestampToIso(row.valid_to) } : {},
|
|
104
92
|
...timestampToIso(row.review_after) ? { reviewAfter: timestampToIso(row.review_after) } : {},
|
|
@@ -110,6 +98,10 @@ function rowToRecord(row) {
|
|
|
110
98
|
tags: parseStringArray(row.tags_json)
|
|
111
99
|
};
|
|
112
100
|
}
|
|
101
|
+
function rowsToRecords(rows) {
|
|
102
|
+
const evidenceByRecord = listMemoryEvidenceForRecords(rows.map((row) => row.record_id));
|
|
103
|
+
return rows.map((row) => rowToRecord(row, evidenceByRecord.get(row.record_id) ?? []));
|
|
104
|
+
}
|
|
113
105
|
function upsertMemoryRecordFts(db, row) {
|
|
114
106
|
db.prepare(`DELETE FROM memory_records_fts WHERE record_id = ?`).run(row.id);
|
|
115
107
|
if (!row.content.trim()) return;
|
|
@@ -138,10 +130,10 @@ function upsertMemoryRecord(input) {
|
|
|
138
130
|
db.prepare(`INSERT INTO memory_records (
|
|
139
131
|
record_id, provider_id, kind, user_id, source_agent_id, workspace_id, session_key, project_id,
|
|
140
132
|
content, source_json, confidence, tags_json, status, sensitivity,
|
|
141
|
-
|
|
133
|
+
canonical_key, explicitness, durability, importance,
|
|
142
134
|
disclosure_policy, valid_from, valid_to, review_after, expires_at,
|
|
143
135
|
supersedes_record_id, conflict_group_id, created_at, updated_at
|
|
144
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
136
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
145
137
|
ON CONFLICT(record_id) DO UPDATE SET
|
|
146
138
|
provider_id = excluded.provider_id,
|
|
147
139
|
kind = excluded.kind,
|
|
@@ -156,7 +148,6 @@ function upsertMemoryRecord(input) {
|
|
|
156
148
|
tags_json = excluded.tags_json,
|
|
157
149
|
status = excluded.status,
|
|
158
150
|
sensitivity = excluded.sensitivity,
|
|
159
|
-
evidence_json = excluded.evidence_json,
|
|
160
151
|
canonical_key = excluded.canonical_key,
|
|
161
152
|
explicitness = excluded.explicitness,
|
|
162
153
|
durability = excluded.durability,
|
|
@@ -168,11 +159,12 @@ function upsertMemoryRecord(input) {
|
|
|
168
159
|
expires_at = excluded.expires_at,
|
|
169
160
|
supersedes_record_id = excluded.supersedes_record_id,
|
|
170
161
|
conflict_group_id = excluded.conflict_group_id,
|
|
171
|
-
updated_at = excluded.updated_at`).run(id, input.providerId, input.kind, input.userId ?? "local-owner", input.sourceAgentId, input.workspaceId ?? null, input.sessionKey ?? null, input.projectId ?? null, input.content, JSON.stringify(source), input.confidence ?? null, JSON.stringify(input.tags ?? []), status, sensitivity,
|
|
162
|
+
updated_at = excluded.updated_at`).run(id, input.providerId, input.kind, input.userId ?? "local-owner", input.sourceAgentId, input.workspaceId ?? null, input.sessionKey ?? null, input.projectId ?? null, input.content, JSON.stringify(source), input.confidence ?? null, JSON.stringify(input.tags ?? []), status, sensitivity, input.canonicalKey ?? null, explicitness, durability, importance, disclosurePolicy, validFrom, validTo, reviewAfter, expiresAt, input.supersedesRecordId ?? null, input.conflictGroupId ?? null, now, now);
|
|
172
163
|
upsertMemoryRecordFts(db, {
|
|
173
164
|
...input,
|
|
174
165
|
id
|
|
175
166
|
});
|
|
167
|
+
if (input.evidence) replaceMemoryEvidenceForRecord(db, id, input.evidence, now);
|
|
176
168
|
if (input.supersedesRecordId && input.supersedesRecordId !== id) {
|
|
177
169
|
if (db.prepare(`SELECT 1 FROM memory_records WHERE record_id = ?`).get(input.supersedesRecordId)) {
|
|
178
170
|
db.prepare(`INSERT INTO memory_relations (
|
|
@@ -190,6 +182,7 @@ function upsertMemoryRecord(input) {
|
|
|
190
182
|
}
|
|
191
183
|
}
|
|
192
184
|
});
|
|
185
|
+
const storedEvidence = input.evidence ?? listMemoryEvidence(id);
|
|
193
186
|
return {
|
|
194
187
|
id,
|
|
195
188
|
providerId: input.providerId,
|
|
@@ -211,7 +204,7 @@ function upsertMemoryRecord(input) {
|
|
|
211
204
|
durability,
|
|
212
205
|
importance,
|
|
213
206
|
disclosurePolicy,
|
|
214
|
-
evidence:
|
|
207
|
+
evidence: storedEvidence,
|
|
215
208
|
...validFrom != null ? { validFrom: new Date(validFrom).toISOString() } : {},
|
|
216
209
|
...validTo != null ? { validTo: new Date(validTo).toISOString() } : {},
|
|
217
210
|
...reviewAfter != null ? { reviewAfter: new Date(reviewAfter).toISOString() } : {},
|
|
@@ -225,7 +218,7 @@ function upsertMemoryRecord(input) {
|
|
|
225
218
|
}
|
|
226
219
|
function getMemoryRecord(recordId) {
|
|
227
220
|
const row = getSqliteDatabase().prepare(`SELECT * FROM memory_records WHERE record_id = ?`).get(recordId);
|
|
228
|
-
return row ? rowToRecord(row) : null;
|
|
221
|
+
return row ? rowToRecord(row, listMemoryEvidence(recordId)) : null;
|
|
229
222
|
}
|
|
230
223
|
function hasUnresolvedMemoryConflict(conflictGroupId) {
|
|
231
224
|
if (!conflictGroupId.trim()) return false;
|
|
@@ -256,6 +249,10 @@ function listMemoryRecords(options = {}) {
|
|
|
256
249
|
where.push("workspace_id = ?");
|
|
257
250
|
params.push(options.workspaceId);
|
|
258
251
|
}
|
|
252
|
+
if (options.visibleToWorkspaceId) {
|
|
253
|
+
where.push("(workspace_id IS NULL OR workspace_id = ?)");
|
|
254
|
+
params.push(options.visibleToWorkspaceId);
|
|
255
|
+
} else if (options.unscopedWorkspaceOnly) where.push("workspace_id IS NULL");
|
|
259
256
|
if (options.projectId) {
|
|
260
257
|
where.push("project_id = ?");
|
|
261
258
|
params.push(options.projectId);
|
|
@@ -282,10 +279,10 @@ function listMemoryRecords(options = {}) {
|
|
|
282
279
|
}
|
|
283
280
|
const limit = Math.max(1, Math.min(500, options.limit ?? 100));
|
|
284
281
|
const offset = Math.max(0, options.offset ?? 0);
|
|
285
|
-
return getSqliteDatabase().prepare(`SELECT * FROM memory_records
|
|
282
|
+
return rowsToRecords(getSqliteDatabase().prepare(`SELECT * FROM memory_records
|
|
286
283
|
${where.length > 0 ? `WHERE ${where.join(" AND ")}` : ""}
|
|
287
284
|
ORDER BY updated_at DESC
|
|
288
|
-
LIMIT ? OFFSET ?`).all(...params, limit, offset)
|
|
285
|
+
LIMIT ? OFFSET ?`).all(...params, limit, offset));
|
|
289
286
|
}
|
|
290
287
|
function searchMemoryRecords(options) {
|
|
291
288
|
const query = buildFts5SearchQuery(options.query);
|
|
@@ -304,6 +301,10 @@ function searchMemoryRecords(options) {
|
|
|
304
301
|
filters.push("f.workspace_id = ?");
|
|
305
302
|
params.push(options.workspaceId);
|
|
306
303
|
}
|
|
304
|
+
if (options.visibleToWorkspaceId) {
|
|
305
|
+
filters.push("(r.workspace_id IS NULL OR r.workspace_id = ?)");
|
|
306
|
+
params.push(options.visibleToWorkspaceId);
|
|
307
|
+
} else if (options.unscopedWorkspaceOnly) filters.push("r.workspace_id IS NULL");
|
|
307
308
|
if (options.projectId) {
|
|
308
309
|
filters.push("r.project_id = ?");
|
|
309
310
|
params.push(options.projectId);
|
|
@@ -337,7 +338,7 @@ function searchMemoryRecords(options) {
|
|
|
337
338
|
WHERE ${filters.join(" AND ")}
|
|
338
339
|
ORDER BY rank
|
|
339
340
|
LIMIT ?`).all(...params, maxResults * 3);
|
|
340
|
-
|
|
341
|
+
const candidateRecords = listMemoryRecords({
|
|
341
342
|
providerId: options.providerId,
|
|
342
343
|
userId: options.userId,
|
|
343
344
|
sourceAgentId: options.sourceAgentId,
|
|
@@ -347,38 +348,56 @@ function searchMemoryRecords(options) {
|
|
|
347
348
|
unscopedSessionOnly: options.unscopedSessionOnly,
|
|
348
349
|
visibleToProjectId: options.visibleToProjectId,
|
|
349
350
|
unscopedProjectOnly: options.unscopedProjectOnly,
|
|
351
|
+
visibleToWorkspaceId: options.visibleToWorkspaceId,
|
|
352
|
+
unscopedWorkspaceOnly: options.unscopedWorkspaceOnly,
|
|
350
353
|
limit: 500
|
|
351
|
-
}).filter((record) => statuses.includes(record.status ?? "active") && (!options.kinds?.length || options.kinds.includes(record.kind)))
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
354
|
+
}).filter((record) => statuses.includes(record.status ?? "active") && (!options.kinds?.length || options.kinds.includes(record.kind)));
|
|
355
|
+
const byId = /* @__PURE__ */ new Map();
|
|
356
|
+
const candidateById = new Map(candidateRecords.map((record) => [record.id, record]));
|
|
357
|
+
const missingEvidence = listMemoryEvidenceForRecords(rows.filter((row) => !candidateById.has(row.record_id)).map((row) => row.record_id));
|
|
358
|
+
if (rows.length > 0) {
|
|
359
|
+
const bestRank = Math.min(...rows.map((row) => row.rank));
|
|
360
|
+
const worstRank = Math.max(...rows.map((row) => row.rank));
|
|
361
|
+
for (const row of rows) {
|
|
362
|
+
const record = candidateById.get(row.record_id) ?? rowToRecord(row, missingEvidence.get(row.record_id) ?? []);
|
|
363
|
+
byId.set(record.id, {
|
|
364
|
+
record,
|
|
365
|
+
score: fts5RankToScore(row.rank, bestRank, worstRank) * .65,
|
|
366
|
+
snippet: record.content,
|
|
367
|
+
citation: {
|
|
368
|
+
providerId: row.provider_id,
|
|
369
|
+
recordId: row.record_id,
|
|
370
|
+
path: record.source.path,
|
|
371
|
+
lineStart: record.source.lineStart,
|
|
372
|
+
lineEnd: record.source.lineEnd,
|
|
373
|
+
createdAt: record.createdAt
|
|
374
|
+
}
|
|
375
|
+
});
|
|
362
376
|
}
|
|
363
|
-
}
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
377
|
+
}
|
|
378
|
+
for (const record of candidateRecords) {
|
|
379
|
+
const vector = memoryVectorSimilarity(options.query, record.content);
|
|
380
|
+
const lexical = memoryLexicalSimilarity(options.query, record.content);
|
|
381
|
+
const existing = byId.get(record.id);
|
|
382
|
+
const score = existing ? Math.min(1, existing.score + vector * .25 + lexical * .1) : Math.max(vector, lexical);
|
|
383
|
+
byId.set(record.id, existing ? {
|
|
384
|
+
...existing,
|
|
385
|
+
score
|
|
386
|
+
} : {
|
|
369
387
|
record,
|
|
370
|
-
score
|
|
388
|
+
score,
|
|
371
389
|
snippet: record.content,
|
|
372
390
|
citation: {
|
|
373
|
-
providerId:
|
|
374
|
-
recordId:
|
|
391
|
+
providerId: record.providerId,
|
|
392
|
+
recordId: record.id,
|
|
375
393
|
path: record.source.path,
|
|
376
394
|
lineStart: record.source.lineStart,
|
|
377
395
|
lineEnd: record.source.lineEnd,
|
|
378
396
|
createdAt: record.createdAt
|
|
379
397
|
}
|
|
380
|
-
};
|
|
381
|
-
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
return [...byId.values()].filter((result) => result.score >= minScore).sort((left, right) => right.score - left.score).slice(0, maxResults);
|
|
382
401
|
}
|
|
383
402
|
function deleteMemoryRecord(recordId) {
|
|
384
403
|
return runSqliteWriteTransaction((db) => {
|
|
@@ -530,56 +549,6 @@ function listMemoryTraceEvents(options = {}) {
|
|
|
530
549
|
ORDER BY created_at DESC
|
|
531
550
|
LIMIT ?`).all(...params, limit).map(memoryTraceRowToPayload);
|
|
532
551
|
}
|
|
533
|
-
function reconcileUserUnderstandingFeedback(db, trace, recordFeedback, nowMs) {
|
|
534
|
-
if (trace.phase !== "inject" || recordFeedback.length === 0) return void 0;
|
|
535
|
-
const evaluatedRecordIds = [];
|
|
536
|
-
const needsReviewRecordIds = [];
|
|
537
|
-
const actions = [];
|
|
538
|
-
const selected = new Set(parseStringArray(trace.selected_record_ids_json));
|
|
539
|
-
for (const feedback of recordFeedback) {
|
|
540
|
-
const recordId = feedback.record_id;
|
|
541
|
-
if (!recordId || !selected.has(recordId)) continue;
|
|
542
|
-
const record = db.prepare(`SELECT * FROM memory_records
|
|
543
|
-
WHERE record_id = ? AND status = 'active'
|
|
544
|
-
AND tags_json LIKE '%\"user-understanding\"%'`).get(recordId);
|
|
545
|
-
if (!record) continue;
|
|
546
|
-
evaluatedRecordIds.push(recordId);
|
|
547
|
-
const rows = db.prepare(`SELECT rating FROM memory_feedback WHERE record_id = ?`).all(recordId);
|
|
548
|
-
const helpful = rows.filter((row) => row.rating === "helpful").length;
|
|
549
|
-
const notHelpful = rows.filter((row) => row.rating !== "helpful" && row.rating !== "mixed").length;
|
|
550
|
-
if (!(feedback.source === "system" && feedback.reason_code === "detected_explicit_user_correction") && (notHelpful < USER_UNDERSTANDING_REMEDIATION_POLICY.minNotHelpful || notHelpful <= helpful)) continue;
|
|
551
|
-
const nextConfidence = record.confidence == null ? null : Math.round(Math.max(.1, record.confidence - USER_UNDERSTANDING_REMEDIATION_POLICY.confidencePenalty) * 1e3) / 1e3;
|
|
552
|
-
if (db.prepare(`UPDATE memory_records
|
|
553
|
-
SET status = 'needs_review', confidence = ?, review_after = ?, updated_at = ?
|
|
554
|
-
WHERE record_id = ? AND status = 'active'`).run(nextConfidence, nowMs, nowMs, recordId).changes === 0) continue;
|
|
555
|
-
needsReviewRecordIds.push(recordId);
|
|
556
|
-
actions.push({
|
|
557
|
-
recordId,
|
|
558
|
-
previousStatus: record.status,
|
|
559
|
-
nextStatus: "needs_review",
|
|
560
|
-
previousConfidence: record.confidence,
|
|
561
|
-
nextConfidence,
|
|
562
|
-
helpful,
|
|
563
|
-
notHelpful
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
const result = {
|
|
567
|
-
triggerTraceId: trace.trace_id,
|
|
568
|
-
evaluatedRecordIds,
|
|
569
|
-
needsReviewRecordIds
|
|
570
|
-
};
|
|
571
|
-
if (needsReviewRecordIds.length > 0) db.prepare(`INSERT INTO memory_trace_events (
|
|
572
|
-
trace_id, session_key, turn_id, phase, provider_id, request_json,
|
|
573
|
-
result_count, selected_record_ids_json, skipped_reason, error,
|
|
574
|
-
duration_ms, created_at, user_id, source_agent_id
|
|
575
|
-
) VALUES (?, ?, ?, 'remediation', 'user-understanding', ?, ?, ?, NULL, NULL, 0, ?, ?, ?)`).run(randomUUID(), trace.session_key, trace.turn_id, JSON.stringify({
|
|
576
|
-
triggerTraceId: trace.trace_id,
|
|
577
|
-
reason: "record_feedback_threshold",
|
|
578
|
-
policy: USER_UNDERSTANDING_REMEDIATION_POLICY,
|
|
579
|
-
actions
|
|
580
|
-
}), needsReviewRecordIds.length, JSON.stringify(needsReviewRecordIds), nowMs, LOCAL_USER_ID, trace.source_agent_id);
|
|
581
|
-
return result;
|
|
582
|
-
}
|
|
583
552
|
function setMemoryTurnFeedback(input) {
|
|
584
553
|
const turnId = input.turnId.trim();
|
|
585
554
|
if (!turnId) return null;
|
|
@@ -589,7 +558,6 @@ function setMemoryTurnFeedback(input) {
|
|
|
589
558
|
const source = input.source ?? "user";
|
|
590
559
|
const selected = new Set(parseStringArray(trace.selected_record_ids_json));
|
|
591
560
|
const records = (input.records ?? []).filter((item) => selected.has(item.recordId));
|
|
592
|
-
let remediation;
|
|
593
561
|
runSqliteWriteTransaction((db) => {
|
|
594
562
|
const upsert = db.prepare(`INSERT INTO memory_feedback (
|
|
595
563
|
feedback_id, trace_id, turn_id, record_id, level, rating, score,
|
|
@@ -599,12 +567,8 @@ function setMemoryTurnFeedback(input) {
|
|
|
599
567
|
reason_code = excluded.reason_code, note = excluded.note, updated_at = excluded.updated_at`);
|
|
600
568
|
upsert.run(randomUUID(), trace.trace_id, turnId, null, "response", input.rating, typeof input.score === "number" ? Math.max(-1, Math.min(1, input.score)) : null, input.reasonCode?.trim().slice(0, 200) || null, input.note?.trim().slice(0, 2e3) || null, source, nowMs, nowMs);
|
|
601
569
|
for (const item of records) upsert.run(randomUUID(), trace.trace_id, turnId, item.recordId, "record", item.rating, null, item.reasonCode?.trim().slice(0, 200) || null, item.note?.trim().slice(0, 2e3) || null, source, nowMs, nowMs);
|
|
602
|
-
remediation = reconcileUserUnderstandingFeedback(db, trace, db.prepare(`SELECT * FROM memory_feedback WHERE trace_id = ? AND level = 'record' AND source = ?`).all(trace.trace_id, source), nowMs);
|
|
603
570
|
});
|
|
604
|
-
return
|
|
605
|
-
...memoryTraceRowToPayload(trace),
|
|
606
|
-
...remediation ? { remediation } : {}
|
|
607
|
-
};
|
|
571
|
+
return memoryTraceRowToPayload(trace);
|
|
608
572
|
}
|
|
609
573
|
function getMemoryTurnFeedback(turnId) {
|
|
610
574
|
const normalized = turnId.trim();
|
|
@@ -664,120 +628,6 @@ function summarizeMemoryRecallFeedback(options = {}) {
|
|
|
664
628
|
}
|
|
665
629
|
return [...summaries.values()].map(({ scoreTotal: _scoreTotal, scoreCount: _scoreCount, ...summary }) => summary).sort((a, b) => b.total - a.total);
|
|
666
630
|
}
|
|
667
|
-
function boundedMetricCount(value) {
|
|
668
|
-
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 0;
|
|
669
|
-
}
|
|
670
|
-
function metricRate(numerator, denominator) {
|
|
671
|
-
return denominator > 0 ? Math.round(numerator / denominator * 1e4) / 1e4 : null;
|
|
672
|
-
}
|
|
673
|
-
function summarizeUserUnderstandingQuality(options = {}) {
|
|
674
|
-
const nowMs = options.nowMs ?? Date.now();
|
|
675
|
-
const windowDays = Math.max(1, Math.min(365, Math.floor(options.windowDays ?? 30)));
|
|
676
|
-
const sinceMs = nowMs - windowDays * 24 * 60 * 60 * 1e3;
|
|
677
|
-
const agingCutoffMs = nowMs - Math.max(1, Math.min(windowDays, Math.floor(options.agingCandidateDays ?? 7))) * 24 * 60 * 60 * 1e3;
|
|
678
|
-
const db = getSqliteDatabase();
|
|
679
|
-
const recordRows = db.prepare(`SELECT record_id, status, explicitness, confidence, created_at, updated_at
|
|
680
|
-
FROM memory_records
|
|
681
|
-
WHERE tags_json LIKE '%"user-understanding"%'
|
|
682
|
-
AND user_id = ?`).all(LOCAL_USER_ID);
|
|
683
|
-
const records = {
|
|
684
|
-
total: recordRows.length,
|
|
685
|
-
candidate: 0,
|
|
686
|
-
active: 0,
|
|
687
|
-
rejected: 0,
|
|
688
|
-
needsReview: 0,
|
|
689
|
-
stale: 0,
|
|
690
|
-
archived: 0,
|
|
691
|
-
agingCandidates: 0,
|
|
692
|
-
explicit: 0,
|
|
693
|
-
inferred: 0,
|
|
694
|
-
averageConfidence: null
|
|
695
|
-
};
|
|
696
|
-
let confidenceTotal = 0;
|
|
697
|
-
let confidenceCount = 0;
|
|
698
|
-
const understandingRecordIds = /* @__PURE__ */ new Set();
|
|
699
|
-
for (const row of recordRows) {
|
|
700
|
-
understandingRecordIds.add(row.record_id);
|
|
701
|
-
if (row.status === "candidate") records.candidate += 1;
|
|
702
|
-
if (row.status === "active") records.active += 1;
|
|
703
|
-
if (row.status === "rejected") records.rejected += 1;
|
|
704
|
-
if (row.status === "needs_review") records.needsReview += 1;
|
|
705
|
-
if (row.status === "stale") records.stale += 1;
|
|
706
|
-
if (row.status === "archived") records.archived += 1;
|
|
707
|
-
if (row.status === "candidate" && row.created_at <= agingCutoffMs) records.agingCandidates += 1;
|
|
708
|
-
if (row.explicitness === "explicit") records.explicit += 1;
|
|
709
|
-
if (row.explicitness === "inferred") records.inferred += 1;
|
|
710
|
-
if (typeof row.confidence === "number") {
|
|
711
|
-
confidenceTotal += row.confidence;
|
|
712
|
-
confidenceCount += 1;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
records.averageConfidence = confidenceCount > 0 ? Math.round(confidenceTotal / confidenceCount * 1e4) / 1e4 : null;
|
|
716
|
-
const attempts = {
|
|
717
|
-
total: 0,
|
|
718
|
-
turn: 0,
|
|
719
|
-
background: 0
|
|
720
|
-
};
|
|
721
|
-
const candidates = {
|
|
722
|
-
proposed: 0,
|
|
723
|
-
created: 0,
|
|
724
|
-
deduplicated: 0,
|
|
725
|
-
rejectedByPolicy: 0
|
|
726
|
-
};
|
|
727
|
-
const understandingTraces = db.prepare(`SELECT request_json FROM memory_trace_events
|
|
728
|
-
WHERE phase = 'understanding' AND created_at >= ?`).all(sinceMs);
|
|
729
|
-
for (const row of understandingTraces) {
|
|
730
|
-
const parsed = parseJsonValue(row.request_json, {});
|
|
731
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) continue;
|
|
732
|
-
const request = parsed;
|
|
733
|
-
attempts.total += 1;
|
|
734
|
-
if (request.source === "turn") attempts.turn += 1;
|
|
735
|
-
if (request.source === "background") attempts.background += 1;
|
|
736
|
-
candidates.proposed += boundedMetricCount(request.proposed);
|
|
737
|
-
candidates.created += boundedMetricCount(request.created);
|
|
738
|
-
candidates.deduplicated += boundedMetricCount(request.deduplicated);
|
|
739
|
-
candidates.rejectedByPolicy += boundedMetricCount(request.rejected);
|
|
740
|
-
}
|
|
741
|
-
const recall = {
|
|
742
|
-
total: 0,
|
|
743
|
-
helpful: 0,
|
|
744
|
-
notHelpful: 0,
|
|
745
|
-
mixed: 0,
|
|
746
|
-
irrelevant: 0,
|
|
747
|
-
helpfulRate: null
|
|
748
|
-
};
|
|
749
|
-
if (understandingRecordIds.size > 0) {
|
|
750
|
-
const recallRows = db.prepare(`SELECT feedback.rating, trace.selected_record_ids_json
|
|
751
|
-
FROM memory_feedback AS feedback
|
|
752
|
-
JOIN memory_trace_events AS trace ON trace.trace_id = feedback.trace_id
|
|
753
|
-
WHERE feedback.level = 'response' AND trace.phase IN ('search', 'inject')
|
|
754
|
-
AND feedback.updated_at >= ?`).all(sinceMs);
|
|
755
|
-
for (const row of recallRows) {
|
|
756
|
-
if (!parseStringArray(row.selected_record_ids_json).some((id) => understandingRecordIds.has(id))) continue;
|
|
757
|
-
recall.total += 1;
|
|
758
|
-
if (row.rating === "helpful") recall.helpful += 1;
|
|
759
|
-
if (row.rating === "not_helpful" || row.rating === "incorrect" || row.rating === "outdated" || row.rating === "sensitive") recall.notHelpful += 1;
|
|
760
|
-
if (row.rating === "mixed") recall.mixed += 1;
|
|
761
|
-
if (row.rating === "irrelevant") recall.irrelevant += 1;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
recall.helpfulRate = metricRate(recall.helpful, recall.total);
|
|
765
|
-
const recentDecisions = recordRows.filter((row) => (row.status === "active" || row.status === "rejected") && row.updated_at >= sinceMs);
|
|
766
|
-
const acceptedDecisions = recentDecisions.filter((row) => row.status === "active").length;
|
|
767
|
-
const decisionTotal = recentDecisions.length;
|
|
768
|
-
return {
|
|
769
|
-
windowDays,
|
|
770
|
-
since: new Date(sinceMs).toISOString(),
|
|
771
|
-
attempts,
|
|
772
|
-
candidates,
|
|
773
|
-
records,
|
|
774
|
-
decisions: {
|
|
775
|
-
total: decisionTotal,
|
|
776
|
-
acceptanceRate: metricRate(acceptedDecisions, decisionTotal)
|
|
777
|
-
},
|
|
778
|
-
recall
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
631
|
function parseJsonValue(json, fallback) {
|
|
782
632
|
try {
|
|
783
633
|
return JSON.parse(json);
|
|
@@ -786,4 +636,4 @@ function parseJsonValue(json, fallback) {
|
|
|
786
636
|
}
|
|
787
637
|
}
|
|
788
638
|
//#endregion
|
|
789
|
-
export {
|
|
639
|
+
export { appendMemorySignal, appendMemoryTraceEvent, deleteMemoryRecord, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, hasUnresolvedMemoryConflict, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, markMemoryRecordsConflicted, searchMemoryRecords, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, summarizeMemoryRecallFeedback, upsertMemoryRecord };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE TABLE endpoint_principals (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
kind TEXT NOT NULL CHECK(kind IN ('web', 'desktop', 'mobile')),
|
|
4
|
+
display_name TEXT NOT NULL,
|
|
5
|
+
platform TEXT NOT NULL,
|
|
6
|
+
public_key TEXT NOT NULL,
|
|
7
|
+
created_at INTEGER NOT NULL,
|
|
8
|
+
last_seen_at INTEGER,
|
|
9
|
+
revoked_at INTEGER
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX idx_endpoint_principals_active
|
|
13
|
+
ON endpoint_principals(kind, last_seen_at DESC)
|
|
14
|
+
WHERE revoked_at IS NULL;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
DROP INDEX idx_session_inputs_pending;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE session_inputs_v110 (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
session_key TEXT NOT NULL,
|
|
6
|
+
client_message_id TEXT NOT NULL,
|
|
7
|
+
requested_delivery TEXT NOT NULL CHECK (requested_delivery IN ('next', 'steer')),
|
|
8
|
+
effective_delivery TEXT NOT NULL CHECK (effective_delivery IN ('next', 'steer')),
|
|
9
|
+
status TEXT NOT NULL CHECK (status IN (
|
|
10
|
+
'queued', 'running', 'injecting',
|
|
11
|
+
'completed', 'cancelled', 'failed', 'interrupted'
|
|
12
|
+
)),
|
|
13
|
+
content TEXT NOT NULL,
|
|
14
|
+
attachments_json TEXT,
|
|
15
|
+
thinking TEXT,
|
|
16
|
+
origin_json TEXT NOT NULL,
|
|
17
|
+
position INTEGER NOT NULL,
|
|
18
|
+
target_run_id TEXT,
|
|
19
|
+
run_id TEXT,
|
|
20
|
+
version INTEGER NOT NULL DEFAULT 1,
|
|
21
|
+
error TEXT,
|
|
22
|
+
created_at_ms INTEGER NOT NULL,
|
|
23
|
+
updated_at_ms INTEGER NOT NULL,
|
|
24
|
+
UNIQUE(session_key, client_message_id)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
INSERT INTO session_inputs_v110 (
|
|
28
|
+
id, session_key, client_message_id, requested_delivery, effective_delivery,
|
|
29
|
+
status, content, attachments_json, thinking, origin_json, position,
|
|
30
|
+
target_run_id, run_id, version, error, created_at_ms, updated_at_ms
|
|
31
|
+
)
|
|
32
|
+
SELECT
|
|
33
|
+
id, session_key, client_message_id, requested_delivery, effective_delivery,
|
|
34
|
+
status, content, attachments_json, thinking,
|
|
35
|
+
'{"type":"system","source":"internal"}', position,
|
|
36
|
+
target_run_id, run_id, version, error, created_at_ms, updated_at_ms
|
|
37
|
+
FROM session_inputs;
|
|
38
|
+
|
|
39
|
+
DROP TABLE session_inputs;
|
|
40
|
+
ALTER TABLE session_inputs_v110 RENAME TO session_inputs;
|
|
41
|
+
|
|
42
|
+
CREATE INDEX idx_session_inputs_pending
|
|
43
|
+
ON session_inputs(session_key, status, position, created_at_ms);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CREATE TABLE endpoint_tool_invocations (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
principal_id TEXT NOT NULL,
|
|
4
|
+
endpoint_id TEXT NOT NULL,
|
|
5
|
+
tool_call_id TEXT NOT NULL,
|
|
6
|
+
tool_name TEXT NOT NULL,
|
|
7
|
+
effect TEXT NOT NULL CHECK(effect IN ('read', 'write', 'destructive')),
|
|
8
|
+
confirmation_required INTEGER NOT NULL CHECK(confirmation_required IN (0, 1)),
|
|
9
|
+
arguments_sha256 TEXT NOT NULL,
|
|
10
|
+
status TEXT NOT NULL CHECK(status IN ('running', 'succeeded', 'failed')),
|
|
11
|
+
error_code TEXT,
|
|
12
|
+
error_message TEXT,
|
|
13
|
+
started_at INTEGER NOT NULL,
|
|
14
|
+
completed_at INTEGER
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE INDEX idx_endpoint_tool_invocations_endpoint_started
|
|
18
|
+
ON endpoint_tool_invocations(endpoint_id, started_at DESC);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
CREATE TABLE endpoint_instance_bindings (
|
|
2
|
+
endpoint_id TEXT PRIMARY KEY,
|
|
3
|
+
principal_id TEXT NOT NULL REFERENCES endpoint_principals(id),
|
|
4
|
+
bound_at INTEGER NOT NULL
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
CREATE INDEX idx_endpoint_instance_bindings_principal
|
|
8
|
+
ON endpoint_instance_bindings(principal_id);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
ALTER TABLE memory_evidence ADD COLUMN session_key TEXT;
|
|
2
|
+
ALTER TABLE memory_evidence ADD COLUMN turn_id TEXT;
|
|
3
|
+
ALTER TABLE memory_evidence ADD COLUMN tool_call_id TEXT;
|
|
4
|
+
|
|
5
|
+
WITH legacy AS (
|
|
6
|
+
SELECT
|
|
7
|
+
r.record_id,
|
|
8
|
+
json_extract(j.value, '$.sourceItemId') AS source_item_id,
|
|
9
|
+
COALESCE(json_extract(j.value, '$.relation'), 'supports') AS relation,
|
|
10
|
+
MAX(CAST(strftime('%s', json_extract(j.value, '$.observedAt')) AS INTEGER) * 1000) AS observed_at,
|
|
11
|
+
MAX(json_extract(j.value, '$.sessionKey')) AS session_key,
|
|
12
|
+
MAX(json_extract(j.value, '$.turnId')) AS turn_id,
|
|
13
|
+
MAX(json_extract(j.value, '$.toolCallId')) AS tool_call_id
|
|
14
|
+
FROM memory_records r, json_each(r.evidence_json) j
|
|
15
|
+
WHERE json_valid(r.evidence_json)
|
|
16
|
+
GROUP BY r.record_id, source_item_id, relation
|
|
17
|
+
)
|
|
18
|
+
UPDATE memory_evidence AS evidence
|
|
19
|
+
SET
|
|
20
|
+
observed_at = COALESCE(evidence.observed_at, legacy.observed_at),
|
|
21
|
+
session_key = COALESCE(evidence.session_key, legacy.session_key),
|
|
22
|
+
turn_id = COALESCE(evidence.turn_id, legacy.turn_id),
|
|
23
|
+
tool_call_id = COALESCE(evidence.tool_call_id, legacy.tool_call_id)
|
|
24
|
+
FROM legacy
|
|
25
|
+
WHERE evidence.record_id = legacy.record_id
|
|
26
|
+
AND COALESCE(evidence.source_item_id, '') = COALESCE(legacy.source_item_id, '')
|
|
27
|
+
AND evidence.relation = legacy.relation;
|
|
28
|
+
|
|
29
|
+
INSERT INTO memory_evidence (
|
|
30
|
+
evidence_id, record_id, source_item_id, relation, excerpt, confidence,
|
|
31
|
+
observed_at, session_key, turn_id, tool_call_id, created_at
|
|
32
|
+
)
|
|
33
|
+
SELECT
|
|
34
|
+
lower(hex(randomblob(16))),
|
|
35
|
+
r.record_id,
|
|
36
|
+
json_extract(j.value, '$.sourceItemId'),
|
|
37
|
+
COALESCE(json_extract(j.value, '$.relation'), 'supports'),
|
|
38
|
+
json_extract(j.value, '$.sourceText'),
|
|
39
|
+
json_extract(j.value, '$.confidence'),
|
|
40
|
+
CAST(strftime('%s', json_extract(j.value, '$.observedAt')) AS INTEGER) * 1000,
|
|
41
|
+
json_extract(j.value, '$.sessionKey'),
|
|
42
|
+
json_extract(j.value, '$.turnId'),
|
|
43
|
+
json_extract(j.value, '$.toolCallId'),
|
|
44
|
+
r.created_at
|
|
45
|
+
FROM memory_records r, json_each(r.evidence_json) j
|
|
46
|
+
WHERE json_valid(r.evidence_json)
|
|
47
|
+
AND NOT EXISTS (
|
|
48
|
+
SELECT 1 FROM memory_evidence e
|
|
49
|
+
WHERE e.record_id = r.record_id
|
|
50
|
+
AND COALESCE(e.source_item_id, '') = COALESCE(json_extract(j.value, '$.sourceItemId'), '')
|
|
51
|
+
AND e.relation = COALESCE(json_extract(j.value, '$.relation'), 'supports')
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
ALTER TABLE memory_records DROP COLUMN evidence_json;
|