@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,101 +0,0 @@
|
|
|
1
|
-
export type UserEntityType = 'person' | 'project' | 'organization';
|
|
2
|
-
export type UserEntityHandleType = 'email' | 'provider_user' | 'display_name';
|
|
3
|
-
export type UserClaimClass = 'relationship' | 'project' | 'routine';
|
|
4
|
-
export type UserClaimState = 'provisional' | 'active' | 'rejected' | 'stale';
|
|
5
|
-
export type UserClaimUserState = 'auto' | 'confirmed' | 'rejected';
|
|
6
|
-
export type UserEntity = {
|
|
7
|
-
id: string;
|
|
8
|
-
type: UserEntityType;
|
|
9
|
-
canonicalLabel: string;
|
|
10
|
-
createdAt: string;
|
|
11
|
-
updatedAt: string;
|
|
12
|
-
};
|
|
13
|
-
export type UserClaim = {
|
|
14
|
-
id: string;
|
|
15
|
-
agentId: string;
|
|
16
|
-
class: UserClaimClass;
|
|
17
|
-
key: string;
|
|
18
|
-
subjectEntityId?: string;
|
|
19
|
-
value: Record<string, unknown>;
|
|
20
|
-
state: UserClaimState;
|
|
21
|
-
userState: UserClaimUserState;
|
|
22
|
-
confidence: number;
|
|
23
|
-
independentEvidenceCount: number;
|
|
24
|
-
activeDayCount: number;
|
|
25
|
-
firstObservedAt: string;
|
|
26
|
-
lastReinforcedAt: string;
|
|
27
|
-
memoryRecordId?: string;
|
|
28
|
-
createdAt: string;
|
|
29
|
-
updatedAt: string;
|
|
30
|
-
};
|
|
31
|
-
export declare function resolveUserEntity(input: {
|
|
32
|
-
type: UserEntityType;
|
|
33
|
-
canonicalLabel: string;
|
|
34
|
-
handles: Array<{
|
|
35
|
-
type: UserEntityHandleType;
|
|
36
|
-
value: string;
|
|
37
|
-
sourceScope: string;
|
|
38
|
-
verified: boolean;
|
|
39
|
-
}>;
|
|
40
|
-
nowMs?: number;
|
|
41
|
-
}): UserEntity;
|
|
42
|
-
export declare function reinforceUserClaim(input: {
|
|
43
|
-
agentId: string;
|
|
44
|
-
class: UserClaimClass;
|
|
45
|
-
key: string;
|
|
46
|
-
subjectEntityId?: string;
|
|
47
|
-
value: Record<string, unknown>;
|
|
48
|
-
evidence: Array<{
|
|
49
|
-
logicalEventKey: string;
|
|
50
|
-
sourceItemId: string;
|
|
51
|
-
sourceInstanceId: string;
|
|
52
|
-
relation: 'supports' | 'contradicts';
|
|
53
|
-
observedAt: string;
|
|
54
|
-
}>;
|
|
55
|
-
nowMs?: number;
|
|
56
|
-
}): UserClaim;
|
|
57
|
-
export declare function removeUserClaimEvidenceForSource(sourceInstanceId: string): {
|
|
58
|
-
deletedClaimCount: number;
|
|
59
|
-
deletedMemoryRecordIds: string[];
|
|
60
|
-
retainedClaims: Array<{
|
|
61
|
-
memoryRecordId: string;
|
|
62
|
-
state: UserClaimState;
|
|
63
|
-
}>;
|
|
64
|
-
};
|
|
65
|
-
export declare function setUserClaimDecision(claimId: string, userState: Exclude<UserClaimUserState, 'auto'>): UserClaim | undefined;
|
|
66
|
-
export declare function linkUserClaimMemoryRecord(claimId: string, memoryRecordId: string): void;
|
|
67
|
-
export declare function getUserClaim(claimId: string): UserClaim | undefined;
|
|
68
|
-
export declare function listUserClaims(options?: {
|
|
69
|
-
agentId?: string;
|
|
70
|
-
state?: UserClaimState;
|
|
71
|
-
limit?: number;
|
|
72
|
-
}): UserClaim[];
|
|
73
|
-
export declare function listUserClaimEvidence(claimId: string): Array<{
|
|
74
|
-
logicalEventKey: string;
|
|
75
|
-
sourceItemId: string;
|
|
76
|
-
sourceInstanceId: string;
|
|
77
|
-
relation: string;
|
|
78
|
-
observedAt: string;
|
|
79
|
-
}>;
|
|
80
|
-
export declare function listUserPeopleGraphRows(): {
|
|
81
|
-
people: Array<UserEntity & {
|
|
82
|
-
handles: Array<{
|
|
83
|
-
type: UserEntityHandleType;
|
|
84
|
-
value: string;
|
|
85
|
-
}>;
|
|
86
|
-
}>;
|
|
87
|
-
edges: Array<{
|
|
88
|
-
entityId: string;
|
|
89
|
-
sourceInstanceId: string;
|
|
90
|
-
mentionCount: number;
|
|
91
|
-
lastObservedAt: string;
|
|
92
|
-
}>;
|
|
93
|
-
evidenceCount: number;
|
|
94
|
-
};
|
|
95
|
-
export declare function listUserClaimStatsBySource(): Record<string, {
|
|
96
|
-
evidenceCount: number;
|
|
97
|
-
provisionalClaims: number;
|
|
98
|
-
activeClaims: number;
|
|
99
|
-
resolvedEntities: number;
|
|
100
|
-
lastEvidenceAt?: string;
|
|
101
|
-
}>;
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
//#region src/storage/sqlite/user-claims-repository.ts
|
|
4
|
-
function entityFromRow(row) {
|
|
5
|
-
return {
|
|
6
|
-
id: row.entity_id,
|
|
7
|
-
type: row.entity_type,
|
|
8
|
-
canonicalLabel: row.canonical_label,
|
|
9
|
-
createdAt: new Date(row.created_at).toISOString(),
|
|
10
|
-
updatedAt: new Date(row.updated_at).toISOString()
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function claimFromRow(row) {
|
|
14
|
-
return {
|
|
15
|
-
id: row.claim_id,
|
|
16
|
-
agentId: row.agent_id,
|
|
17
|
-
class: row.claim_class,
|
|
18
|
-
key: row.claim_key,
|
|
19
|
-
...row.subject_entity_id ? { subjectEntityId: row.subject_entity_id } : {},
|
|
20
|
-
value: JSON.parse(row.value_json),
|
|
21
|
-
state: row.state,
|
|
22
|
-
userState: row.user_state,
|
|
23
|
-
confidence: row.confidence,
|
|
24
|
-
independentEvidenceCount: row.independent_evidence_count,
|
|
25
|
-
activeDayCount: row.active_day_count,
|
|
26
|
-
firstObservedAt: new Date(row.first_observed_at).toISOString(),
|
|
27
|
-
lastReinforcedAt: new Date(row.last_reinforced_at).toISOString(),
|
|
28
|
-
...row.memory_record_id ? { memoryRecordId: row.memory_record_id } : {},
|
|
29
|
-
createdAt: new Date(row.created_at).toISOString(),
|
|
30
|
-
updatedAt: new Date(row.updated_at).toISOString()
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function resolveUserEntity(input) {
|
|
34
|
-
const now = input.nowMs ?? Date.now();
|
|
35
|
-
return runSqliteWriteTransaction((db) => {
|
|
36
|
-
const handles = input.handles.map((handle) => ({
|
|
37
|
-
...handle,
|
|
38
|
-
value: handle.value.trim().toLowerCase()
|
|
39
|
-
})).filter((handle) => handle.value);
|
|
40
|
-
const strong = handles.filter((handle) => handle.verified);
|
|
41
|
-
let row;
|
|
42
|
-
for (const handle of strong) {
|
|
43
|
-
row = db.prepare(`SELECT e.* FROM user_entities e JOIN user_entity_handles h ON h.entity_id = e.entity_id
|
|
44
|
-
WHERE h.handle_type = ? AND h.normalized_value = ? AND h.source_scope = ?`).get(handle.type, handle.value, handle.sourceScope);
|
|
45
|
-
if (row) break;
|
|
46
|
-
}
|
|
47
|
-
if (!row) {
|
|
48
|
-
const fallback = handles[0];
|
|
49
|
-
if (fallback) row = db.prepare(`SELECT e.* FROM user_entities e JOIN user_entity_handles h ON h.entity_id = e.entity_id
|
|
50
|
-
WHERE h.handle_type = ? AND h.normalized_value = ? AND h.source_scope = ?`).get(fallback.type, fallback.value, fallback.sourceScope);
|
|
51
|
-
}
|
|
52
|
-
const entityId = row?.entity_id ?? randomUUID();
|
|
53
|
-
if (!row) db.prepare(`INSERT INTO user_entities (entity_id, entity_type, canonical_label, created_at, updated_at)
|
|
54
|
-
VALUES (?, ?, ?, ?, ?)`).run(entityId, input.type, input.canonicalLabel, now, now);
|
|
55
|
-
else {
|
|
56
|
-
const incomingHumanName = input.canonicalLabel.includes(" ") && !input.canonicalLabel.includes("@");
|
|
57
|
-
const existingHumanName = row.canonical_label.includes(" ") && !row.canonical_label.includes("@");
|
|
58
|
-
if (incomingHumanName && (!existingHumanName || input.canonicalLabel.length > row.canonical_label.length)) db.prepare("UPDATE user_entities SET canonical_label = ?, updated_at = ? WHERE entity_id = ?").run(input.canonicalLabel, now, entityId);
|
|
59
|
-
}
|
|
60
|
-
for (const handle of handles) db.prepare(`INSERT OR IGNORE INTO user_entity_handles
|
|
61
|
-
(entity_id, handle_type, normalized_value, source_scope, verified, created_at)
|
|
62
|
-
VALUES (?, ?, ?, ?, ?, ?)`).run(entityId, handle.type, handle.value, handle.sourceScope, handle.verified ? 1 : 0, now);
|
|
63
|
-
return entityFromRow(db.prepare("SELECT * FROM user_entities WHERE entity_id = ?").get(entityId));
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function thresholds(claimClass) {
|
|
67
|
-
return claimClass === "routine" ? {
|
|
68
|
-
evidence: 3,
|
|
69
|
-
days: 3
|
|
70
|
-
} : {
|
|
71
|
-
evidence: 3,
|
|
72
|
-
days: 2
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function refreshUserClaim(db, row, now) {
|
|
76
|
-
const stats = db.prepare(`SELECT
|
|
77
|
-
SUM(CASE WHEN relation = 'supports' THEN 1 ELSE 0 END) AS evidence_count,
|
|
78
|
-
SUM(CASE WHEN relation = 'contradicts' THEN 1 ELSE 0 END) AS contradiction_count,
|
|
79
|
-
COUNT(DISTINCT CASE WHEN relation = 'supports' THEN date(observed_at / 1000, 'unixepoch') END) AS active_days,
|
|
80
|
-
MAX(observed_at) AS last_observed
|
|
81
|
-
FROM user_claim_evidence WHERE claim_id = ?`).get(row.claim_id);
|
|
82
|
-
const evidenceCount = stats.evidence_count ?? 0;
|
|
83
|
-
const contradictionCount = stats.contradiction_count ?? 0;
|
|
84
|
-
const limit = thresholds(row.claim_class);
|
|
85
|
-
const state = row.user_state === "rejected" ? "rejected" : row.user_state === "confirmed" ? "active" : contradictionCount >= evidenceCount && contradictionCount > 0 ? "stale" : evidenceCount >= limit.evidence && stats.active_days >= limit.days ? "active" : "provisional";
|
|
86
|
-
const confidence = Math.max(.1, Math.min(.92, .48 + Math.min(evidenceCount, 8) * .035 + Math.min(stats.active_days, 5) * .045 - Math.min(contradictionCount, 5) * .08));
|
|
87
|
-
db.prepare(`UPDATE user_claims SET state = ?, confidence = ?, independent_evidence_count = ?,
|
|
88
|
-
active_day_count = ?, last_reinforced_at = ?, updated_at = ? WHERE claim_id = ?`).run(state, confidence, evidenceCount, stats.active_days, stats.last_observed ?? row.last_reinforced_at, now, row.claim_id);
|
|
89
|
-
return claimFromRow(db.prepare("SELECT * FROM user_claims WHERE claim_id = ?").get(row.claim_id));
|
|
90
|
-
}
|
|
91
|
-
function reinforceUserClaim(input) {
|
|
92
|
-
const now = input.nowMs ?? Date.now();
|
|
93
|
-
return runSqliteWriteTransaction((db) => {
|
|
94
|
-
let row = db.prepare("SELECT * FROM user_claims WHERE agent_id = ? AND claim_class = ? AND claim_key = ?").get(input.agentId, input.class, input.key);
|
|
95
|
-
const claimId = row?.claim_id ?? randomUUID();
|
|
96
|
-
if (!row) {
|
|
97
|
-
const firstObserved = Math.min(...input.evidence.map((item) => Date.parse(item.observedAt)), now);
|
|
98
|
-
db.prepare(`INSERT INTO user_claims (
|
|
99
|
-
claim_id, agent_id, claim_class, claim_key, subject_entity_id, value_json, state, user_state,
|
|
100
|
-
confidence, independent_evidence_count, active_day_count, first_observed_at, last_reinforced_at,
|
|
101
|
-
created_at, updated_at
|
|
102
|
-
) VALUES (?, ?, ?, ?, ?, ?, 'provisional', 'auto', 0, 0, 0, ?, ?, ?, ?)`).run(claimId, input.agentId, input.class, input.key, input.subjectEntityId ?? null, JSON.stringify(input.value), firstObserved, now, now, now);
|
|
103
|
-
}
|
|
104
|
-
for (const evidence of input.evidence) db.prepare(`INSERT INTO user_claim_evidence (
|
|
105
|
-
claim_id, logical_event_key, source_item_id, source_instance_id, relation, observed_at, created_at
|
|
106
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
107
|
-
ON CONFLICT(claim_id, logical_event_key) DO UPDATE SET
|
|
108
|
-
source_item_id = excluded.source_item_id,
|
|
109
|
-
source_instance_id = excluded.source_instance_id,
|
|
110
|
-
relation = excluded.relation,
|
|
111
|
-
observed_at = excluded.observed_at`).run(claimId, evidence.logicalEventKey, evidence.sourceItemId, evidence.sourceInstanceId, evidence.relation, Date.parse(evidence.observedAt), now);
|
|
112
|
-
db.prepare("UPDATE user_claims SET subject_entity_id = ?, value_json = ? WHERE claim_id = ?").run(input.subjectEntityId ?? null, JSON.stringify(input.value), claimId);
|
|
113
|
-
row = db.prepare("SELECT * FROM user_claims WHERE claim_id = ?").get(claimId);
|
|
114
|
-
return refreshUserClaim(db, row, now);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function removeUserClaimEvidenceForSource(sourceInstanceId) {
|
|
118
|
-
return runSqliteWriteTransaction((db) => {
|
|
119
|
-
const affected = db.prepare(`SELECT DISTINCT c.* FROM user_claims c
|
|
120
|
-
JOIN user_claim_evidence e ON e.claim_id = c.claim_id
|
|
121
|
-
WHERE e.source_instance_id = ?`).all(sourceInstanceId);
|
|
122
|
-
db.prepare("DELETE FROM user_claim_evidence WHERE source_instance_id = ?").run(sourceInstanceId);
|
|
123
|
-
const deletedMemoryRecordIds = [];
|
|
124
|
-
const retainedClaims = [];
|
|
125
|
-
let deletedClaimCount = 0;
|
|
126
|
-
const now = Date.now();
|
|
127
|
-
for (const row of affected) {
|
|
128
|
-
if (db.prepare("SELECT COUNT(*) AS count FROM user_claim_evidence WHERE claim_id = ?").get(row.claim_id).count === 0) {
|
|
129
|
-
if (row.memory_record_id) deletedMemoryRecordIds.push(row.memory_record_id);
|
|
130
|
-
db.prepare("DELETE FROM user_claims WHERE claim_id = ?").run(row.claim_id);
|
|
131
|
-
deletedClaimCount += 1;
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const claim = refreshUserClaim(db, row, now);
|
|
135
|
-
if (claim.memoryRecordId) retainedClaims.push({
|
|
136
|
-
memoryRecordId: claim.memoryRecordId,
|
|
137
|
-
state: claim.state
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
deletedClaimCount,
|
|
142
|
-
deletedMemoryRecordIds,
|
|
143
|
-
retainedClaims
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function setUserClaimDecision(claimId, userState) {
|
|
148
|
-
runSqliteWriteTransaction((db) => {
|
|
149
|
-
db.prepare(`UPDATE user_claims SET user_state = ?, state = ?, updated_at = ? WHERE claim_id = ?`).run(userState, userState === "confirmed" ? "active" : "rejected", Date.now(), claimId);
|
|
150
|
-
});
|
|
151
|
-
return getUserClaim(claimId);
|
|
152
|
-
}
|
|
153
|
-
function linkUserClaimMemoryRecord(claimId, memoryRecordId) {
|
|
154
|
-
runSqliteWriteTransaction((db) => {
|
|
155
|
-
db.prepare("UPDATE user_claims SET memory_record_id = ?, updated_at = ? WHERE claim_id = ?").run(memoryRecordId, Date.now(), claimId);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function getUserClaim(claimId) {
|
|
159
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM user_claims WHERE claim_id = ?").get(claimId);
|
|
160
|
-
return row ? claimFromRow(row) : void 0;
|
|
161
|
-
}
|
|
162
|
-
function listUserClaims(options = {}) {
|
|
163
|
-
const where = [];
|
|
164
|
-
const params = [];
|
|
165
|
-
if (options.agentId) {
|
|
166
|
-
where.push("agent_id = ?");
|
|
167
|
-
params.push(options.agentId);
|
|
168
|
-
}
|
|
169
|
-
if (options.state) {
|
|
170
|
-
where.push("state = ?");
|
|
171
|
-
params.push(options.state);
|
|
172
|
-
}
|
|
173
|
-
const limit = Math.max(1, Math.min(options.limit ?? 100, 500));
|
|
174
|
-
return getSqliteDatabase().prepare(`SELECT * FROM user_claims
|
|
175
|
-
${where.length ? `WHERE ${where.join(" AND ")}` : ""}
|
|
176
|
-
ORDER BY confidence DESC, last_reinforced_at DESC LIMIT ?`).all(...params, limit).map(claimFromRow);
|
|
177
|
-
}
|
|
178
|
-
function listUserClaimEvidence(claimId) {
|
|
179
|
-
return getSqliteDatabase().prepare(`SELECT logical_event_key, source_item_id, source_instance_id, relation, observed_at
|
|
180
|
-
FROM user_claim_evidence WHERE claim_id = ? ORDER BY observed_at DESC`).all(claimId).map((row) => ({
|
|
181
|
-
logicalEventKey: row.logical_event_key,
|
|
182
|
-
sourceItemId: row.source_item_id,
|
|
183
|
-
sourceInstanceId: row.source_instance_id,
|
|
184
|
-
relation: row.relation,
|
|
185
|
-
observedAt: new Date(row.observed_at).toISOString()
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
function listUserPeopleGraphRows() {
|
|
189
|
-
const db = getSqliteDatabase();
|
|
190
|
-
const entities = db.prepare(`SELECT * FROM user_entities e WHERE entity_type = 'person'
|
|
191
|
-
AND EXISTS (SELECT 1 FROM user_claims c JOIN user_claim_evidence ce ON ce.claim_id = c.claim_id
|
|
192
|
-
WHERE c.subject_entity_id = e.entity_id)`).all();
|
|
193
|
-
const handles = db.prepare(`SELECT entity_id, handle_type, normalized_value FROM user_entity_handles
|
|
194
|
-
WHERE entity_id IN (SELECT entity_id FROM user_entities WHERE entity_type = 'person')`).all();
|
|
195
|
-
const byEntity = /* @__PURE__ */ new Map();
|
|
196
|
-
for (const handle of handles) {
|
|
197
|
-
const values = byEntity.get(handle.entity_id) ?? [];
|
|
198
|
-
values.push({
|
|
199
|
-
type: handle.handle_type,
|
|
200
|
-
value: handle.normalized_value
|
|
201
|
-
});
|
|
202
|
-
byEntity.set(handle.entity_id, values);
|
|
203
|
-
}
|
|
204
|
-
const edgeRows = db.prepare(`SELECT c.subject_entity_id AS entity_id, e.source_instance_id,
|
|
205
|
-
COUNT(*) AS mention_count, MAX(e.observed_at) AS last_observed_at
|
|
206
|
-
FROM user_claims c JOIN user_claim_evidence e ON e.claim_id = c.claim_id
|
|
207
|
-
WHERE c.claim_class = 'relationship' AND c.subject_entity_id IS NOT NULL AND e.relation = 'supports'
|
|
208
|
-
GROUP BY c.subject_entity_id, e.source_instance_id`).all();
|
|
209
|
-
return {
|
|
210
|
-
people: entities.map((row) => ({
|
|
211
|
-
...entityFromRow(row),
|
|
212
|
-
handles: byEntity.get(row.entity_id) ?? []
|
|
213
|
-
})),
|
|
214
|
-
edges: edgeRows.map((row) => ({
|
|
215
|
-
entityId: row.entity_id,
|
|
216
|
-
sourceInstanceId: row.source_instance_id,
|
|
217
|
-
mentionCount: row.mention_count,
|
|
218
|
-
lastObservedAt: new Date(row.last_observed_at).toISOString()
|
|
219
|
-
})),
|
|
220
|
-
evidenceCount: edgeRows.reduce((sum, row) => sum + row.mention_count, 0)
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function listUserClaimStatsBySource() {
|
|
224
|
-
const rows = getSqliteDatabase().prepare(`SELECT e.source_instance_id,
|
|
225
|
-
COUNT(*) AS evidence_count,
|
|
226
|
-
COUNT(DISTINCT CASE WHEN c.state = 'provisional' THEN c.claim_id END) AS provisional_claims,
|
|
227
|
-
COUNT(DISTINCT CASE WHEN c.state = 'active' THEN c.claim_id END) AS active_claims,
|
|
228
|
-
COUNT(DISTINCT c.subject_entity_id) AS resolved_entities,
|
|
229
|
-
MAX(e.observed_at) AS last_evidence_at
|
|
230
|
-
FROM user_claim_evidence e JOIN user_claims c ON c.claim_id = e.claim_id
|
|
231
|
-
GROUP BY e.source_instance_id`).all();
|
|
232
|
-
return Object.fromEntries(rows.map((row) => [row.source_instance_id, {
|
|
233
|
-
evidenceCount: row.evidence_count,
|
|
234
|
-
provisionalClaims: row.provisional_claims,
|
|
235
|
-
activeClaims: row.active_claims,
|
|
236
|
-
resolvedEntities: row.resolved_entities,
|
|
237
|
-
...row.last_evidence_at == null ? {} : { lastEvidenceAt: new Date(row.last_evidence_at).toISOString() }
|
|
238
|
-
}]));
|
|
239
|
-
}
|
|
240
|
-
//#endregion
|
|
241
|
-
export { getUserClaim, linkUserClaimMemoryRecord, listUserClaimEvidence, listUserClaimStatsBySource, listUserClaims, listUserPeopleGraphRows, reinforceUserClaim, removeUserClaimEvidenceForSource, resolveUserEntity, setUserClaimDecision };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { UserProfilePromptState } from '../../user-context/profile.js';
|
|
2
|
-
export declare function getUserProfilePromptState(principalId?: string): UserProfilePromptState;
|
|
3
|
-
export declare function setUserProfilePromptState(input: Pick<UserProfilePromptState, 'state' | 'suggestionHash' | 'snoozedUntil'>, principalId?: string): UserProfilePromptState;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
//#region src/storage/sqlite/user-profile-setup-repository.ts
|
|
3
|
-
function fromRow(row) {
|
|
4
|
-
return {
|
|
5
|
-
state: row.state,
|
|
6
|
-
suggestionHash: row.suggestion_hash ?? void 0,
|
|
7
|
-
snoozedUntil: row.snoozed_until ?? void 0,
|
|
8
|
-
updatedAt: row.updated_at
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function getUserProfilePromptState(principalId = "local-owner") {
|
|
12
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM user_profile_prompt_state WHERE principal_id = ?").get(principalId);
|
|
13
|
-
return row ? fromRow(row) : { state: "active" };
|
|
14
|
-
}
|
|
15
|
-
function setUserProfilePromptState(input, principalId = "local-owner") {
|
|
16
|
-
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
17
|
-
return runSqliteWriteTransaction((db) => {
|
|
18
|
-
db.prepare(`
|
|
19
|
-
INSERT INTO user_profile_prompt_state (
|
|
20
|
-
principal_id, state, suggestion_hash, snoozed_until, updated_at
|
|
21
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
22
|
-
ON CONFLICT(principal_id) DO UPDATE SET
|
|
23
|
-
state = excluded.state,
|
|
24
|
-
suggestion_hash = excluded.suggestion_hash,
|
|
25
|
-
snoozed_until = excluded.snoozed_until,
|
|
26
|
-
updated_at = excluded.updated_at
|
|
27
|
-
`).run(principalId, input.state, input.suggestionHash ?? null, input.snoozedUntil ?? null, updatedAt);
|
|
28
|
-
return getUserProfilePromptState(principalId);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { getUserProfilePromptState, setUserProfilePromptState };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ParsedSSEEvent } from './tui-types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Consume an SSE stream from a `ReadableStream<Uint8Array>` (Node.js 22+ fetch body).
|
|
4
|
-
*
|
|
5
|
-
* Parses the standard SSE wire format:
|
|
6
|
-
* event: <name>\n
|
|
7
|
-
* data: <json>\n
|
|
8
|
-
* id: <id>\n
|
|
9
|
-
* \n
|
|
10
|
-
*
|
|
11
|
-
* Calls `onEvent` for each complete event block.
|
|
12
|
-
*/
|
|
13
|
-
export declare function consumeSSEStream(body: ReadableStream<Uint8Array>, onEvent: (event: ParsedSSEEvent) => void, signal?: AbortSignal): Promise<void>;
|
|
14
|
-
/** Parse SSE data field as JSON, returning null on failure. */
|
|
15
|
-
export declare function parseSSEData<T = unknown>(data: string): T | null;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
//#region src/tui/sse-consumer.ts
|
|
2
|
-
/**
|
|
3
|
-
* Consume an SSE stream from a `ReadableStream<Uint8Array>` (Node.js 22+ fetch body).
|
|
4
|
-
*
|
|
5
|
-
* Parses the standard SSE wire format:
|
|
6
|
-
* event: <name>\n
|
|
7
|
-
* data: <json>\n
|
|
8
|
-
* id: <id>\n
|
|
9
|
-
* \n
|
|
10
|
-
*
|
|
11
|
-
* Calls `onEvent` for each complete event block.
|
|
12
|
-
*/
|
|
13
|
-
async function consumeSSEStream(body, onEvent, signal) {
|
|
14
|
-
const reader = body.getReader();
|
|
15
|
-
const decoder = new TextDecoder();
|
|
16
|
-
let buffer = "";
|
|
17
|
-
let currentEvent = "";
|
|
18
|
-
let currentData = "";
|
|
19
|
-
let currentId = "";
|
|
20
|
-
try {
|
|
21
|
-
while (true) {
|
|
22
|
-
if (signal?.aborted) break;
|
|
23
|
-
const { done, value } = await reader.read();
|
|
24
|
-
if (done) break;
|
|
25
|
-
buffer += decoder.decode(value, { stream: true });
|
|
26
|
-
const lines = buffer.split("\n");
|
|
27
|
-
buffer = lines.pop() ?? "";
|
|
28
|
-
for (const line of lines) {
|
|
29
|
-
if (line === "") {
|
|
30
|
-
if (currentData) onEvent({
|
|
31
|
-
event: currentEvent || "message",
|
|
32
|
-
data: currentData,
|
|
33
|
-
id: currentId || void 0
|
|
34
|
-
});
|
|
35
|
-
currentEvent = "";
|
|
36
|
-
currentData = "";
|
|
37
|
-
currentId = "";
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (line.startsWith(":")) continue;
|
|
41
|
-
const colonIndex = line.indexOf(":");
|
|
42
|
-
if (colonIndex === -1) continue;
|
|
43
|
-
const field = line.slice(0, colonIndex);
|
|
44
|
-
const valueStart = line[colonIndex + 1] === " " ? colonIndex + 2 : colonIndex + 1;
|
|
45
|
-
const fieldValue = line.slice(valueStart);
|
|
46
|
-
switch (field) {
|
|
47
|
-
case "event":
|
|
48
|
-
currentEvent = fieldValue;
|
|
49
|
-
break;
|
|
50
|
-
case "data":
|
|
51
|
-
currentData = currentData ? `${currentData}\n${fieldValue}` : fieldValue;
|
|
52
|
-
break;
|
|
53
|
-
case "id":
|
|
54
|
-
currentId = fieldValue;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} finally {
|
|
60
|
-
buffer += decoder.decode();
|
|
61
|
-
reader.releaseLock();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/** Parse SSE data field as JSON, returning null on failure. */
|
|
65
|
-
function parseSSEData(data) {
|
|
66
|
-
try {
|
|
67
|
-
return JSON.parse(data);
|
|
68
|
-
} catch {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
export { consumeSSEStream, parseSSEData };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { UserContextPlan } from '../agent/memory/context/types.js';
|
|
2
|
-
import { type RelationshipSettings } from '../storage/sqlite/index.js';
|
|
3
|
-
export interface ContextSnapshot {
|
|
4
|
-
id: string;
|
|
5
|
-
traceId: string;
|
|
6
|
-
ownerKind: 'session';
|
|
7
|
-
ownerId: string;
|
|
8
|
-
sessionKey?: string;
|
|
9
|
-
query: string;
|
|
10
|
-
selectedItems: UserContextPlan['items'];
|
|
11
|
-
rejectedItems: UserContextPlan['rejected'];
|
|
12
|
-
consentRequests: UserContextPlan['consentRequests'];
|
|
13
|
-
relationshipPolicy: RelationshipSettings;
|
|
14
|
-
estimatedTokens: number;
|
|
15
|
-
allocation?: UserContextPlan['allocation'];
|
|
16
|
-
createdAt: number;
|
|
17
|
-
}
|
|
18
|
-
export declare class ContextCompiler {
|
|
19
|
-
capture(input: {
|
|
20
|
-
sessionKey: string;
|
|
21
|
-
query: string;
|
|
22
|
-
plan: UserContextPlan;
|
|
23
|
-
now?: number;
|
|
24
|
-
}): ContextSnapshot;
|
|
25
|
-
get(id: string): ContextSnapshot | undefined;
|
|
26
|
-
latestForSession(sessionKey: string, since?: number): ContextSnapshot | undefined;
|
|
27
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { getRelationshipSettings } from "../storage/sqlite/relationship-settings-repository.js";
|
|
3
|
-
import "../storage/sqlite/index.js";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
|
-
//#region src/user-context/context-compiler.ts
|
|
6
|
-
function fromRow(row) {
|
|
7
|
-
return {
|
|
8
|
-
id: row.snapshot_id,
|
|
9
|
-
traceId: row.trace_id,
|
|
10
|
-
ownerKind: row.owner_kind,
|
|
11
|
-
ownerId: row.owner_id,
|
|
12
|
-
...row.session_key ? { sessionKey: row.session_key } : {},
|
|
13
|
-
query: row.query,
|
|
14
|
-
selectedItems: JSON.parse(row.selected_items_json),
|
|
15
|
-
rejectedItems: JSON.parse(row.rejected_items_json),
|
|
16
|
-
consentRequests: JSON.parse(row.consent_requests_json),
|
|
17
|
-
relationshipPolicy: JSON.parse(row.relationship_policy_json),
|
|
18
|
-
estimatedTokens: row.estimated_tokens,
|
|
19
|
-
...row.allocation_json ? { allocation: JSON.parse(row.allocation_json) } : {},
|
|
20
|
-
createdAt: row.created_at
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
var ContextCompiler = class {
|
|
24
|
-
capture(input) {
|
|
25
|
-
const now = input.now ?? Date.now();
|
|
26
|
-
const id = randomUUID();
|
|
27
|
-
runSqliteWriteTransaction((db) => {
|
|
28
|
-
db.prepare(`INSERT INTO context_snapshots (
|
|
29
|
-
snapshot_id, trace_id, owner_kind, owner_id, session_key, query, selected_items_json,
|
|
30
|
-
rejected_items_json, consent_requests_json, relationship_policy_json,
|
|
31
|
-
estimated_tokens, allocation_json, created_at
|
|
32
|
-
) VALUES (?, ?, 'session', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, input.plan.traceId, input.sessionKey, input.sessionKey, input.query.trim(), JSON.stringify(input.plan.items), JSON.stringify(input.plan.rejected), JSON.stringify(input.plan.consentRequests), JSON.stringify(getRelationshipSettings()), input.plan.estimatedTokens, input.plan.allocation ? JSON.stringify(input.plan.allocation) : null, now);
|
|
33
|
-
});
|
|
34
|
-
return this.get(id);
|
|
35
|
-
}
|
|
36
|
-
get(id) {
|
|
37
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM context_snapshots WHERE snapshot_id = ?").get(id);
|
|
38
|
-
return row ? fromRow(row) : void 0;
|
|
39
|
-
}
|
|
40
|
-
latestForSession(sessionKey, since = 0) {
|
|
41
|
-
const row = getSqliteDatabase().prepare(`SELECT * FROM context_snapshots
|
|
42
|
-
WHERE session_key = ? AND created_at >= ?
|
|
43
|
-
ORDER BY created_at DESC LIMIT 1`).get(sessionKey, since);
|
|
44
|
-
return row ? fromRow(row) : void 0;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { ContextCompiler };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { MemoryRecord } from '../agent/memory/types.js';
|
|
2
|
-
export type PreparedUserContextImport = {
|
|
3
|
-
statement: string;
|
|
4
|
-
kind: MemoryRecord['kind'];
|
|
5
|
-
sensitivity: NonNullable<MemoryRecord['sensitivity']>;
|
|
6
|
-
durability: MemoryRecord['durability'];
|
|
7
|
-
disclosurePolicy: MemoryRecord['disclosurePolicy'];
|
|
8
|
-
};
|
|
9
|
-
export declare function prepareUserContextImport(candidates: unknown[], existingStatements: Iterable<string>): {
|
|
10
|
-
imports: PreparedUserContextImport[];
|
|
11
|
-
skippedCount: number;
|
|
12
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isUserContextMemoryKind } from "./projection.js";
|
|
2
|
-
//#region src/user-context/import.ts
|
|
3
|
-
function prepareUserContextImport(candidates, existingStatements) {
|
|
4
|
-
const known = new Set(Array.from(existingStatements, (statement) => statement.trim().toLocaleLowerCase()));
|
|
5
|
-
const imports = [];
|
|
6
|
-
let skippedCount = 0;
|
|
7
|
-
for (const candidate of candidates) {
|
|
8
|
-
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
9
|
-
skippedCount += 1;
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const item = candidate;
|
|
13
|
-
const statement = typeof item.statement === "string" ? item.statement.trim() : "";
|
|
14
|
-
const normalized = statement.toLocaleLowerCase();
|
|
15
|
-
if (!statement || statement.length > 5e3 || known.has(normalized) || item.status === "archived" || item.status === "rejected") {
|
|
16
|
-
skippedCount += 1;
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
const kind = isUserContextMemoryKind(item.kind) ? item.kind : "preference";
|
|
20
|
-
const sensitivity = typeof item.sensitivity === "string" && [
|
|
21
|
-
"normal",
|
|
22
|
-
"personal",
|
|
23
|
-
"secret",
|
|
24
|
-
"regulated"
|
|
25
|
-
].includes(item.sensitivity) ? item.sensitivity : "normal";
|
|
26
|
-
const durability = typeof item.durability === "string" && [
|
|
27
|
-
"ephemeral",
|
|
28
|
-
"durable",
|
|
29
|
-
"recurring"
|
|
30
|
-
].includes(item.durability) ? item.durability : "durable";
|
|
31
|
-
known.add(normalized);
|
|
32
|
-
const disclosurePolicy = typeof item.disclosurePolicy === "string" && [
|
|
33
|
-
"silent",
|
|
34
|
-
"referenceable",
|
|
35
|
-
"ask_before_reference"
|
|
36
|
-
].includes(item.disclosurePolicy) ? item.disclosurePolicy : "referenceable";
|
|
37
|
-
imports.push({
|
|
38
|
-
statement,
|
|
39
|
-
kind,
|
|
40
|
-
sensitivity,
|
|
41
|
-
durability,
|
|
42
|
-
disclosurePolicy
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
imports,
|
|
47
|
-
skippedCount
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { prepareUserContextImport };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface MemoryEpisode {
|
|
2
|
-
id: string;
|
|
3
|
-
expectedRecall: string[];
|
|
4
|
-
forbiddenRecall: string[];
|
|
5
|
-
expectedLifecycle: string[];
|
|
6
|
-
expectedDreaming: string[];
|
|
7
|
-
}
|
|
8
|
-
export interface MemoryEpisodeObservation {
|
|
9
|
-
recalledRecordIds: string[];
|
|
10
|
-
lifecycleActions: string[];
|
|
11
|
-
dreamingActions: string[];
|
|
12
|
-
scopeViolations: number;
|
|
13
|
-
sensitivityViolations: number;
|
|
14
|
-
}
|
|
15
|
-
export interface MemoryEpisodeResult {
|
|
16
|
-
id: string;
|
|
17
|
-
recall: number;
|
|
18
|
-
forbiddenRecall: string[];
|
|
19
|
-
missingLifecycle: string[];
|
|
20
|
-
missingDreaming: string[];
|
|
21
|
-
safe: boolean;
|
|
22
|
-
passed: boolean;
|
|
23
|
-
}
|
|
24
|
-
export declare function evaluateMemoryEpisode(episode: MemoryEpisode, observation: MemoryEpisodeObservation): MemoryEpisodeResult;
|
|
25
|
-
export declare function evaluateMemoryEpisodeSuite(cases: Array<{
|
|
26
|
-
episode: MemoryEpisode;
|
|
27
|
-
observation: MemoryEpisodeObservation;
|
|
28
|
-
}>): {
|
|
29
|
-
releaseReady: boolean;
|
|
30
|
-
averageRecall: number;
|
|
31
|
-
results: MemoryEpisodeResult[];
|
|
32
|
-
};
|