@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,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multicast buffer for a single web agent run so multiple HTTP SSE consumers can
|
|
3
|
-
* attach through POST /api/agent/resume while one
|
|
4
|
-
* background pump drains processDirectStreaming.
|
|
5
|
-
*/
|
|
6
|
-
export type RelayEvent = {
|
|
7
|
-
type: string;
|
|
8
|
-
} & Record<string, unknown>;
|
|
9
|
-
export declare class AgentRunRelay {
|
|
10
|
-
private readonly maxEvents;
|
|
11
|
-
private runs;
|
|
12
|
-
constructor(maxEvents?: number);
|
|
13
|
-
ensureRun(runId: string, sessionKey: string): void;
|
|
14
|
-
getSessionKey(runId: string): string | undefined;
|
|
15
|
-
hasRun(runId: string): boolean;
|
|
16
|
-
publish(runId: string, event: RelayEvent): RelayEvent | undefined;
|
|
17
|
-
complete(runId: string): void;
|
|
18
|
-
subscribe(runId: string): AsyncGenerator<RelayEvent>;
|
|
19
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
//#region src/gateway/agent-run-relay.ts
|
|
4
|
-
init_logger();
|
|
5
|
-
const log = createLogger("Gateway:AgentRunRelay");
|
|
6
|
-
const COMPLETE_TTL_MS = 5 * 6e4;
|
|
7
|
-
const MAX_EVENTS = 8e3;
|
|
8
|
-
const COMPACT_TO_RATIO = .75;
|
|
9
|
-
const MAX_MERGED_DELTA_CHARS = 16 * 1024;
|
|
10
|
-
const REPLAY_DELTA_TYPES = new Set([
|
|
11
|
-
"assistant_delta",
|
|
12
|
-
"thinking_delta",
|
|
13
|
-
"command_output_delta",
|
|
14
|
-
"review_delta"
|
|
15
|
-
]);
|
|
16
|
-
function eventSeq(event) {
|
|
17
|
-
return typeof event.seq === "number" ? event.seq : void 0;
|
|
18
|
-
}
|
|
19
|
-
function findEventAtOrAfter(events, seq) {
|
|
20
|
-
let low = 0;
|
|
21
|
-
let high = events.length;
|
|
22
|
-
while (low < high) {
|
|
23
|
-
const middle = low + Math.floor((high - low) / 2);
|
|
24
|
-
if ((eventSeq(events[middle]) ?? Number.MAX_SAFE_INTEGER) < seq) low = middle + 1;
|
|
25
|
-
else high = middle;
|
|
26
|
-
}
|
|
27
|
-
return events[low];
|
|
28
|
-
}
|
|
29
|
-
function recordValue(value) {
|
|
30
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
31
|
-
}
|
|
32
|
-
function sameDeltaStream(left, right) {
|
|
33
|
-
if (left.type !== right.type || !REPLAY_DELTA_TYPES.has(left.type)) return false;
|
|
34
|
-
const leftPayload = recordValue(left.payload);
|
|
35
|
-
const rightPayload = recordValue(right.payload);
|
|
36
|
-
if (!leftPayload || !rightPayload) return false;
|
|
37
|
-
return [
|
|
38
|
-
"messageId",
|
|
39
|
-
"toolCallId",
|
|
40
|
-
"reviewId",
|
|
41
|
-
"stream"
|
|
42
|
-
].every((key) => leftPayload[key] === rightPayload[key]);
|
|
43
|
-
}
|
|
44
|
-
function mergeReplayDelta(events, event) {
|
|
45
|
-
const previous = events.at(-1);
|
|
46
|
-
if (!previous || !sameDeltaStream(previous, event)) return false;
|
|
47
|
-
const previousPayload = recordValue(previous.payload);
|
|
48
|
-
const payload = recordValue(event.payload);
|
|
49
|
-
const previousDelta = previousPayload?.delta;
|
|
50
|
-
const delta = payload?.delta;
|
|
51
|
-
if (typeof previousDelta !== "string" || typeof delta !== "string") return false;
|
|
52
|
-
if (previousDelta.length + delta.length > MAX_MERGED_DELTA_CHARS) return false;
|
|
53
|
-
events[events.length - 1] = {
|
|
54
|
-
...previous,
|
|
55
|
-
payload: {
|
|
56
|
-
...previousPayload,
|
|
57
|
-
delta: previousDelta + delta
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
function compactEvents(events, targetSize) {
|
|
63
|
-
let remaining = Math.max(0, events.length - targetSize);
|
|
64
|
-
const retained = [];
|
|
65
|
-
const removedByType = {};
|
|
66
|
-
for (const event of events) {
|
|
67
|
-
if (remaining > 0 && REPLAY_DELTA_TYPES.has(event.type)) {
|
|
68
|
-
remaining -= 1;
|
|
69
|
-
removedByType[event.type] = (removedByType[event.type] ?? 0) + 1;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
retained.push(event);
|
|
73
|
-
}
|
|
74
|
-
if (remaining > 0) for (const event of retained.splice(0, remaining)) removedByType[event.type] = (removedByType[event.type] ?? 0) + 1;
|
|
75
|
-
return {
|
|
76
|
-
events: retained,
|
|
77
|
-
removedByType
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
var AgentRunRelay = class {
|
|
81
|
-
runs = /* @__PURE__ */ new Map();
|
|
82
|
-
constructor(maxEvents = MAX_EVENTS) {
|
|
83
|
-
this.maxEvents = maxEvents;
|
|
84
|
-
if (!Number.isInteger(maxEvents) || maxEvents < 2) throw new Error("AgentRunRelay maxEvents must be an integer greater than 1");
|
|
85
|
-
}
|
|
86
|
-
ensureRun(runId, sessionKey) {
|
|
87
|
-
if (this.runs.has(runId)) return;
|
|
88
|
-
this.runs.set(runId, {
|
|
89
|
-
sessionKey,
|
|
90
|
-
events: [],
|
|
91
|
-
nextSeq: 1,
|
|
92
|
-
done: false,
|
|
93
|
-
waiters: [],
|
|
94
|
-
subscriberCount: 0,
|
|
95
|
-
compactionWarned: false
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
getSessionKey(runId) {
|
|
99
|
-
return this.runs.get(runId)?.sessionKey;
|
|
100
|
-
}
|
|
101
|
-
hasRun(runId) {
|
|
102
|
-
return this.runs.has(runId);
|
|
103
|
-
}
|
|
104
|
-
publish(runId, event) {
|
|
105
|
-
const state = this.runs.get(runId);
|
|
106
|
-
if (!state) return void 0;
|
|
107
|
-
const relayed = {
|
|
108
|
-
...event,
|
|
109
|
-
runId,
|
|
110
|
-
seq: state.nextSeq++
|
|
111
|
-
};
|
|
112
|
-
const merged = state.subscriberCount === 0 && mergeReplayDelta(state.events, relayed);
|
|
113
|
-
if (!merged && state.events.length >= this.maxEvents) {
|
|
114
|
-
const targetSize = Math.max(1, Math.floor(this.maxEvents * COMPACT_TO_RATIO));
|
|
115
|
-
const compacted = compactEvents(state.events, targetSize);
|
|
116
|
-
state.events = compacted.events;
|
|
117
|
-
if (!state.compactionWarned) {
|
|
118
|
-
state.compactionWarned = true;
|
|
119
|
-
log.warn({
|
|
120
|
-
runId,
|
|
121
|
-
max: this.maxEvents,
|
|
122
|
-
retained: state.events.length,
|
|
123
|
-
removedByType: compacted.removedByType
|
|
124
|
-
}, "Relay replay buffer compacted; old delta events are no longer resumable");
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (!merged) state.events.push(relayed);
|
|
128
|
-
const waiters = state.waiters.splice(0);
|
|
129
|
-
for (const w of waiters) w();
|
|
130
|
-
return relayed;
|
|
131
|
-
}
|
|
132
|
-
complete(runId) {
|
|
133
|
-
const state = this.runs.get(runId);
|
|
134
|
-
if (!state) return;
|
|
135
|
-
state.done = true;
|
|
136
|
-
const waiters = state.waiters.splice(0);
|
|
137
|
-
for (const w of waiters) w();
|
|
138
|
-
if (state.cleanupTimer) clearTimeout(state.cleanupTimer);
|
|
139
|
-
state.cleanupTimer = setTimeout(() => {
|
|
140
|
-
this.runs.delete(runId);
|
|
141
|
-
}, COMPLETE_TTL_MS);
|
|
142
|
-
}
|
|
143
|
-
async *subscribe(runId) {
|
|
144
|
-
const state = this.runs.get(runId);
|
|
145
|
-
if (!state) throw new Error("UNKNOWN_RUN");
|
|
146
|
-
state.subscriberCount += 1;
|
|
147
|
-
try {
|
|
148
|
-
let nextSeq = eventSeq(state.events[0]) ?? state.nextSeq;
|
|
149
|
-
while (true) {
|
|
150
|
-
const earliestSeq = eventSeq(state.events[0]);
|
|
151
|
-
if (earliestSeq !== void 0 && nextSeq < earliestSeq) nextSeq = earliestSeq;
|
|
152
|
-
const available = findEventAtOrAfter(state.events, nextSeq);
|
|
153
|
-
if (available) {
|
|
154
|
-
nextSeq = (eventSeq(available) ?? nextSeq) + 1;
|
|
155
|
-
yield available;
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
if (state.done) break;
|
|
159
|
-
await new Promise((resolve) => {
|
|
160
|
-
state.waiters.push(resolve);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
} finally {
|
|
164
|
-
state.subscriberCount -= 1;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
//#endregion
|
|
169
|
-
export { AgentRunRelay };
|
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
import { LOCAL_USER_ID } from "../../../user-context/owner.js";
|
|
2
|
-
import { appendMemorySignal, appendMemoryTraceEvent, deleteMemoryRecord, getMemoryRecord, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, searchMemoryRecords, summarizeMemoryRecallFeedback, summarizeUserUnderstandingQuality, upsertMemoryRecord } from "../../../storage/sqlite/memory-records-repository.js";
|
|
3
|
-
import { listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns } from "../../../storage/sqlite/knowledge-repository.js";
|
|
4
|
-
import "../../../storage/sqlite/index.js";
|
|
5
|
-
import { ResponseLanguageSchema, init_response_language } from "../../../i18n/response-language.js";
|
|
6
|
-
import { UserContextConfigSchema, init_config } from "../../../user-context/config.js";
|
|
7
|
-
import { init_agent_scope, resolveDefaultAgentId } from "../../../agent/agent-scope.js";
|
|
8
|
-
import { discoverMemoryPlugins } from "../../../agent/memory/plugin-discovery.js";
|
|
9
|
-
import { createMemoryManagerFromConfig } from "../../../agent/memory/create-memory-manager.js";
|
|
10
|
-
import { resolveAdaptiveUnderstandingCadence } from "../../../agent/memory/understanding/quality.js";
|
|
11
|
-
import { summarizeMemoryUseAudit } from "../../../user-context/memory-use-audit.js";
|
|
12
|
-
//#region src/gateway/hono/routes/memory.ts
|
|
13
|
-
init_agent_scope();
|
|
14
|
-
init_config();
|
|
15
|
-
init_response_language();
|
|
16
|
-
const MEMORY_KINDS = new Set([
|
|
17
|
-
"user_profile",
|
|
18
|
-
"preference",
|
|
19
|
-
"boundary",
|
|
20
|
-
"relationship",
|
|
21
|
-
"project_context",
|
|
22
|
-
"commitment",
|
|
23
|
-
"routine",
|
|
24
|
-
"personal_logistics",
|
|
25
|
-
"open_question",
|
|
26
|
-
"milestone",
|
|
27
|
-
"current_state",
|
|
28
|
-
"user_note",
|
|
29
|
-
"workspace_fact",
|
|
30
|
-
"daily_note",
|
|
31
|
-
"session_summary",
|
|
32
|
-
"derived_insight",
|
|
33
|
-
"task_lesson",
|
|
34
|
-
"tool_preference",
|
|
35
|
-
"long_term_goal"
|
|
36
|
-
]);
|
|
37
|
-
const MEMORY_EXPLICITNESS = new Set([
|
|
38
|
-
"explicit",
|
|
39
|
-
"observed",
|
|
40
|
-
"inferred"
|
|
41
|
-
]);
|
|
42
|
-
const MEMORY_DURABILITY = new Set([
|
|
43
|
-
"ephemeral",
|
|
44
|
-
"durable",
|
|
45
|
-
"recurring"
|
|
46
|
-
]);
|
|
47
|
-
const MEMORY_DISCLOSURE_POLICIES = new Set([
|
|
48
|
-
"silent",
|
|
49
|
-
"referenceable",
|
|
50
|
-
"ask_before_reference"
|
|
51
|
-
]);
|
|
52
|
-
const MEMORY_STATUSES = new Set([
|
|
53
|
-
"candidate",
|
|
54
|
-
"active",
|
|
55
|
-
"needs_review",
|
|
56
|
-
"stale",
|
|
57
|
-
"archived",
|
|
58
|
-
"rejected"
|
|
59
|
-
]);
|
|
60
|
-
const MEMORY_SENSITIVITIES = new Set([
|
|
61
|
-
"normal",
|
|
62
|
-
"personal",
|
|
63
|
-
"secret",
|
|
64
|
-
"regulated"
|
|
65
|
-
]);
|
|
66
|
-
const KNOWLEDGE_SYNTHESIS_STATUSES = new Set([
|
|
67
|
-
"pending",
|
|
68
|
-
"processing",
|
|
69
|
-
"completed",
|
|
70
|
-
"failed",
|
|
71
|
-
"ignored"
|
|
72
|
-
]);
|
|
73
|
-
function parseLimit(raw, fallback = 100) {
|
|
74
|
-
const parsed = raw ? Number.parseInt(raw, 10) : fallback;
|
|
75
|
-
return Number.isFinite(parsed) ? Math.max(1, Math.min(500, parsed)) : fallback;
|
|
76
|
-
}
|
|
77
|
-
function parseFeedbackSummaryLimit(raw) {
|
|
78
|
-
const parsed = raw ? Number.parseInt(raw, 10) : 1e3;
|
|
79
|
-
return Number.isFinite(parsed) ? Math.max(1, Math.min(5e3, parsed)) : 1e3;
|
|
80
|
-
}
|
|
81
|
-
function parseWindowDays(raw) {
|
|
82
|
-
const parsed = raw ? Number.parseInt(raw, 10) : 30;
|
|
83
|
-
return Number.isFinite(parsed) ? Math.max(1, Math.min(365, parsed)) : 30;
|
|
84
|
-
}
|
|
85
|
-
function parseKind(raw) {
|
|
86
|
-
return typeof raw === "string" && MEMORY_KINDS.has(raw) ? raw : void 0;
|
|
87
|
-
}
|
|
88
|
-
function parseStatus(raw) {
|
|
89
|
-
return typeof raw === "string" && MEMORY_STATUSES.has(raw) ? raw : void 0;
|
|
90
|
-
}
|
|
91
|
-
function parseSensitivity(raw) {
|
|
92
|
-
return typeof raw === "string" && MEMORY_SENSITIVITIES.has(raw) ? raw : void 0;
|
|
93
|
-
}
|
|
94
|
-
function parseEnum(raw, allowed) {
|
|
95
|
-
return typeof raw === "string" && allowed.has(raw) ? raw : void 0;
|
|
96
|
-
}
|
|
97
|
-
function registerMemoryRoutes(authenticated, deps) {
|
|
98
|
-
authenticated.get("/api/you/providers", async (c) => {
|
|
99
|
-
const cfg = deps.service.currentConfig;
|
|
100
|
-
const plugins = await discoverMemoryPlugins(cfg);
|
|
101
|
-
return c.json({ providers: [{
|
|
102
|
-
id: "local",
|
|
103
|
-
displayName: "Local Knowledge Store",
|
|
104
|
-
available: true,
|
|
105
|
-
configured: true,
|
|
106
|
-
capabilities: {
|
|
107
|
-
search: true,
|
|
108
|
-
read: true,
|
|
109
|
-
write: true,
|
|
110
|
-
update: true,
|
|
111
|
-
delete: true,
|
|
112
|
-
keywordSearch: true,
|
|
113
|
-
semanticSearch: false,
|
|
114
|
-
hybridSearch: false,
|
|
115
|
-
citations: true,
|
|
116
|
-
sync: false,
|
|
117
|
-
local: true
|
|
118
|
-
}
|
|
119
|
-
}, ...plugins.map((plugin) => ({
|
|
120
|
-
id: plugin.manifest?.id ?? plugin.name,
|
|
121
|
-
displayName: plugin.manifest?.displayName ?? plugin.name,
|
|
122
|
-
available: plugin.available,
|
|
123
|
-
configured: false,
|
|
124
|
-
capabilities: plugin.manifest?.capabilities ?? {}
|
|
125
|
-
}))] });
|
|
126
|
-
});
|
|
127
|
-
authenticated.get("/api/you/config", (c) => {
|
|
128
|
-
const cfg = deps.service.currentConfig;
|
|
129
|
-
return c.json({ userContext: cfg.userContext });
|
|
130
|
-
});
|
|
131
|
-
authenticated.put("/api/you/config", deps.strictRateLimitMiddleware, async (c) => {
|
|
132
|
-
const cfg = deps.service.currentConfig;
|
|
133
|
-
const body = await c.req.json().catch(() => ({}));
|
|
134
|
-
const parsed = UserContextConfigSchema.safeParse(body);
|
|
135
|
-
if (!parsed.success) return c.json({ error: `userContext ${parsed.error.issues[0]?.message ?? "is invalid"}` }, 400);
|
|
136
|
-
const save = await deps.service.saveConfig({
|
|
137
|
-
...cfg,
|
|
138
|
-
userContext: parsed.data
|
|
139
|
-
});
|
|
140
|
-
if (!save.saved) return c.json({ error: save.error ?? "save failed" }, 500);
|
|
141
|
-
deps.service.refreshUserProfileContext();
|
|
142
|
-
return c.json({ userContext: deps.service.currentConfig.userContext });
|
|
143
|
-
});
|
|
144
|
-
authenticated.patch("/api/you/preferences", deps.strictRateLimitMiddleware, async (c) => {
|
|
145
|
-
const cfg = deps.service.currentConfig;
|
|
146
|
-
const body = await c.req.json().catch(() => ({}));
|
|
147
|
-
const responseLanguage = ResponseLanguageSchema.safeParse(body.responseLanguage);
|
|
148
|
-
if (!responseLanguage.success) return c.json({ error: "Invalid responseLanguage" }, 400);
|
|
149
|
-
const userContext = UserContextConfigSchema.parse({
|
|
150
|
-
...cfg.userContext,
|
|
151
|
-
preferences: { responseLanguage: responseLanguage.data }
|
|
152
|
-
});
|
|
153
|
-
const save = await deps.service.saveConfig({
|
|
154
|
-
...cfg,
|
|
155
|
-
userContext
|
|
156
|
-
});
|
|
157
|
-
if (!save.saved) return c.json({ error: save.error ?? "save failed" }, 500);
|
|
158
|
-
deps.service.refreshUserProfileContext();
|
|
159
|
-
return c.json({ preferences: userContext.preferences });
|
|
160
|
-
});
|
|
161
|
-
authenticated.get("/api/you/memories", (c) => {
|
|
162
|
-
if (c.req.query("agentId")) return c.json({ error: "agentId is not supported" }, 400);
|
|
163
|
-
const records = listMemoryRecords({
|
|
164
|
-
providerId: c.req.query("providerId") || void 0,
|
|
165
|
-
userId: LOCAL_USER_ID,
|
|
166
|
-
workspaceId: c.req.query("workspaceId") || void 0,
|
|
167
|
-
projectId: c.req.query("projectId") || void 0,
|
|
168
|
-
kind: parseKind(c.req.query("kind")),
|
|
169
|
-
status: parseStatus(c.req.query("status")),
|
|
170
|
-
limit: parseLimit(c.req.query("limit")),
|
|
171
|
-
offset: c.req.query("offset") ? Number.parseInt(c.req.query("offset"), 10) : 0
|
|
172
|
-
});
|
|
173
|
-
return c.json({ records });
|
|
174
|
-
});
|
|
175
|
-
authenticated.post("/api/you/memories/search", async (c) => {
|
|
176
|
-
const body = await c.req.json().catch(() => ({}));
|
|
177
|
-
const query = typeof body.query === "string" ? body.query.trim() : "";
|
|
178
|
-
if (!query) return c.json({ error: "Missing required field: query" }, 400);
|
|
179
|
-
if (Object.hasOwn(body, "agentId") || Object.hasOwn(body, "userId")) return c.json({ error: "agentId and userId are not accepted" }, 400);
|
|
180
|
-
const records = searchMemoryRecords({
|
|
181
|
-
query,
|
|
182
|
-
providerId: typeof body.providerId === "string" ? body.providerId : void 0,
|
|
183
|
-
userId: LOCAL_USER_ID,
|
|
184
|
-
workspaceId: typeof body.workspaceId === "string" ? body.workspaceId : void 0,
|
|
185
|
-
projectId: typeof body.projectId === "string" ? body.projectId : void 0,
|
|
186
|
-
kinds: Array.isArray(body.kinds) ? body.kinds.map(parseKind).filter((v) => Boolean(v)) : void 0,
|
|
187
|
-
statuses: Array.isArray(body.statuses) ? body.statuses.map(parseStatus).filter((v) => Boolean(v)) : void 0,
|
|
188
|
-
maxResults: typeof body.maxResults === "number" ? body.maxResults : void 0,
|
|
189
|
-
minScore: typeof body.minScore === "number" ? body.minScore : void 0
|
|
190
|
-
});
|
|
191
|
-
return c.json({ results: records });
|
|
192
|
-
});
|
|
193
|
-
authenticated.post("/api/you/memories", async (c) => {
|
|
194
|
-
const body = await c.req.json().catch(() => ({}));
|
|
195
|
-
const kind = parseKind(body.kind);
|
|
196
|
-
const content = typeof body.content === "string" ? body.content.trim() : "";
|
|
197
|
-
if (Object.hasOwn(body, "agentId") || Object.hasOwn(body, "userId")) return c.json({ error: "agentId and userId are not accepted" }, 400);
|
|
198
|
-
if (!kind || !content) return c.json({ error: "Missing required fields: kind, content" }, 400);
|
|
199
|
-
const record = upsertMemoryRecord({
|
|
200
|
-
id: typeof body.id === "string" && body.id.trim() ? body.id.trim() : void 0,
|
|
201
|
-
providerId: typeof body.providerId === "string" && body.providerId.trim() ? body.providerId.trim() : "local",
|
|
202
|
-
kind,
|
|
203
|
-
sourceAgentId: resolveDefaultAgentId(deps.service.currentConfig),
|
|
204
|
-
workspaceId: typeof body.workspaceId === "string" ? body.workspaceId : deps.service.currentWorkspacePath,
|
|
205
|
-
sessionKey: typeof body.sessionKey === "string" ? body.sessionKey : void 0,
|
|
206
|
-
projectId: typeof body.projectId === "string" ? body.projectId : void 0,
|
|
207
|
-
content,
|
|
208
|
-
source: body.source && typeof body.source === "object" ? body.source : void 0,
|
|
209
|
-
confidence: typeof body.confidence === "number" ? body.confidence : void 0,
|
|
210
|
-
tags: Array.isArray(body.tags) ? body.tags.filter((tag) => typeof tag === "string") : void 0,
|
|
211
|
-
status: parseStatus(body.status),
|
|
212
|
-
sensitivity: parseSensitivity(body.sensitivity),
|
|
213
|
-
canonicalKey: typeof body.canonicalKey === "string" ? body.canonicalKey : void 0,
|
|
214
|
-
explicitness: parseEnum(body.explicitness, MEMORY_EXPLICITNESS),
|
|
215
|
-
durability: parseEnum(body.durability, MEMORY_DURABILITY),
|
|
216
|
-
importance: typeof body.importance === "number" ? body.importance : void 0,
|
|
217
|
-
disclosurePolicy: parseEnum(body.disclosurePolicy, MEMORY_DISCLOSURE_POLICIES),
|
|
218
|
-
evidence: Array.isArray(body.evidence) ? body.evidence.filter((item) => Boolean(item) && typeof item === "object") : void 0,
|
|
219
|
-
reviewAfter: typeof body.reviewAfter === "string" ? body.reviewAfter : void 0,
|
|
220
|
-
expiresAt: typeof body.expiresAt === "string" ? body.expiresAt : void 0,
|
|
221
|
-
validFrom: typeof body.validFrom === "string" ? body.validFrom : void 0,
|
|
222
|
-
validTo: typeof body.validTo === "string" ? body.validTo : void 0,
|
|
223
|
-
supersedesRecordId: typeof body.supersedesRecordId === "string" ? body.supersedesRecordId : void 0,
|
|
224
|
-
conflictGroupId: typeof body.conflictGroupId === "string" ? body.conflictGroupId : void 0
|
|
225
|
-
});
|
|
226
|
-
return c.json({ record }, 201);
|
|
227
|
-
});
|
|
228
|
-
authenticated.put("/api/you/memories/:id", async (c) => {
|
|
229
|
-
const existing = getMemoryRecord(c.req.param("id"));
|
|
230
|
-
if (!existing) return c.json({ error: "Memory record not found" }, 404);
|
|
231
|
-
if (c.req.query("agentId")) return c.json({ error: "agentId is not supported" }, 400);
|
|
232
|
-
const body = await c.req.json().catch(() => ({}));
|
|
233
|
-
const record = upsertMemoryRecord({
|
|
234
|
-
id: existing.id,
|
|
235
|
-
providerId: existing.source.provider ?? "local",
|
|
236
|
-
kind: parseKind(body.kind) ?? existing.kind,
|
|
237
|
-
sourceAgentId: existing.provenance.sourceAgentId,
|
|
238
|
-
workspaceId: existing.scope.workspaceId,
|
|
239
|
-
sessionKey: existing.scope.sessionKey,
|
|
240
|
-
projectId: typeof body.projectId === "string" ? body.projectId : existing.scope.projectId,
|
|
241
|
-
content: typeof body.content === "string" ? body.content : existing.content,
|
|
242
|
-
source: body.source && typeof body.source === "object" ? body.source : existing.source,
|
|
243
|
-
confidence: typeof body.confidence === "number" ? body.confidence : existing.confidence,
|
|
244
|
-
tags: Array.isArray(body.tags) ? body.tags.filter((tag) => typeof tag === "string") : existing.tags,
|
|
245
|
-
status: parseStatus(body.status) ?? existing.status,
|
|
246
|
-
sensitivity: parseSensitivity(body.sensitivity) ?? existing.sensitivity,
|
|
247
|
-
canonicalKey: typeof body.canonicalKey === "string" ? body.canonicalKey : existing.canonicalKey,
|
|
248
|
-
explicitness: parseEnum(body.explicitness, MEMORY_EXPLICITNESS) ?? existing.explicitness,
|
|
249
|
-
durability: parseEnum(body.durability, MEMORY_DURABILITY) ?? existing.durability,
|
|
250
|
-
importance: typeof body.importance === "number" ? body.importance : existing.importance,
|
|
251
|
-
disclosurePolicy: parseEnum(body.disclosurePolicy, MEMORY_DISCLOSURE_POLICIES) ?? existing.disclosurePolicy,
|
|
252
|
-
evidence: Array.isArray(body.evidence) ? body.evidence.filter((item) => Boolean(item) && typeof item === "object") : existing.evidence,
|
|
253
|
-
reviewAfter: typeof body.reviewAfter === "string" ? body.reviewAfter : existing.reviewAfter,
|
|
254
|
-
expiresAt: typeof body.expiresAt === "string" ? body.expiresAt : existing.expiresAt,
|
|
255
|
-
validFrom: typeof body.validFrom === "string" ? body.validFrom : existing.validFrom,
|
|
256
|
-
validTo: typeof body.validTo === "string" ? body.validTo : existing.validTo,
|
|
257
|
-
supersedesRecordId: typeof body.supersedesRecordId === "string" ? body.supersedesRecordId : existing.supersedesRecordId,
|
|
258
|
-
conflictGroupId: typeof body.conflictGroupId === "string" ? body.conflictGroupId : existing.conflictGroupId
|
|
259
|
-
});
|
|
260
|
-
return c.json({ record });
|
|
261
|
-
});
|
|
262
|
-
authenticated.delete("/api/you/memories/:id", (c) => {
|
|
263
|
-
const existing = getMemoryRecord(c.req.param("id"));
|
|
264
|
-
if (c.req.query("agentId")) return c.json({ error: "agentId is not supported" }, 400);
|
|
265
|
-
if (!existing || existing.scope.userId !== "local-owner") return c.json({ error: "Memory record not found" }, 404);
|
|
266
|
-
if (!deleteMemoryRecord(c.req.param("id"))) return c.json({ error: "Memory record not found" }, 404);
|
|
267
|
-
return c.json({ ok: true });
|
|
268
|
-
});
|
|
269
|
-
authenticated.get("/api/you/signals", (c) => {
|
|
270
|
-
if (c.req.query("agentId")) return c.json({ error: "agentId is not supported" }, 400);
|
|
271
|
-
const signals = listMemorySignals({
|
|
272
|
-
recordId: c.req.query("recordId") || void 0,
|
|
273
|
-
providerId: c.req.query("providerId") || void 0,
|
|
274
|
-
userId: LOCAL_USER_ID,
|
|
275
|
-
workspaceId: c.req.query("workspaceId") || void 0,
|
|
276
|
-
limit: parseLimit(c.req.query("limit"))
|
|
277
|
-
});
|
|
278
|
-
return c.json({ signals });
|
|
279
|
-
});
|
|
280
|
-
authenticated.get("/api/knowledge/source-items", (c) => {
|
|
281
|
-
const sourceItems = listKnowledgeSourceItems({
|
|
282
|
-
sourceInstanceId: c.req.query("sourceInstanceId") || void 0,
|
|
283
|
-
synthesisStatus: parseEnum(c.req.query("synthesisStatus"), KNOWLEDGE_SYNTHESIS_STATUSES),
|
|
284
|
-
includeDeleted: c.req.query("includeDeleted") === "true",
|
|
285
|
-
limit: parseLimit(c.req.query("limit")),
|
|
286
|
-
offset: c.req.query("offset") ? Number.parseInt(c.req.query("offset"), 10) : 0
|
|
287
|
-
});
|
|
288
|
-
return c.json({ sourceItems });
|
|
289
|
-
});
|
|
290
|
-
authenticated.get("/api/knowledge/source-changes", (c) => {
|
|
291
|
-
const afterSequenceQuery = c.req.query("afterSequence");
|
|
292
|
-
const afterSequence = afterSequenceQuery ? Number.parseInt(afterSequenceQuery, 10) : void 0;
|
|
293
|
-
const sourceChanges = listKnowledgeSourceChanges({
|
|
294
|
-
sourceInstanceId: c.req.query("sourceInstanceId") || void 0,
|
|
295
|
-
afterSequence: Number.isFinite(afterSequence) ? afterSequence : void 0,
|
|
296
|
-
limit: parseLimit(c.req.query("limit"))
|
|
297
|
-
});
|
|
298
|
-
return c.json({ sourceChanges });
|
|
299
|
-
});
|
|
300
|
-
authenticated.get("/api/knowledge/sync-runs", (c) => {
|
|
301
|
-
const syncRuns = listKnowledgeSyncRuns({
|
|
302
|
-
sourceInstanceId: c.req.query("sourceInstanceId") || void 0,
|
|
303
|
-
limit: parseLimit(c.req.query("limit"))
|
|
304
|
-
});
|
|
305
|
-
return c.json({ syncRuns });
|
|
306
|
-
});
|
|
307
|
-
authenticated.get("/api/you/traces", (c) => {
|
|
308
|
-
const traces = listMemoryTraceEvents({
|
|
309
|
-
providerId: c.req.query("providerId") || void 0,
|
|
310
|
-
sessionKey: c.req.query("sessionKey") || void 0,
|
|
311
|
-
phase: c.req.query("phase") || void 0,
|
|
312
|
-
limit: parseLimit(c.req.query("limit"))
|
|
313
|
-
});
|
|
314
|
-
return c.json({ traces });
|
|
315
|
-
});
|
|
316
|
-
authenticated.get("/api/you/memory-use-audit", (c) => {
|
|
317
|
-
const traces = listMemoryTraceEvents({
|
|
318
|
-
sessionKey: c.req.query("sessionKey") || void 0,
|
|
319
|
-
limit: parseLimit(c.req.query("limit"))
|
|
320
|
-
});
|
|
321
|
-
return c.json({ audit: summarizeMemoryUseAudit(traces) });
|
|
322
|
-
});
|
|
323
|
-
authenticated.get("/api/you/feedback-summary", (c) => {
|
|
324
|
-
const summaries = summarizeMemoryRecallFeedback({
|
|
325
|
-
recordId: c.req.query("recordId") || void 0,
|
|
326
|
-
providerId: c.req.query("providerId") || void 0,
|
|
327
|
-
sessionKey: c.req.query("sessionKey") || void 0,
|
|
328
|
-
limit: parseFeedbackSummaryLimit(c.req.query("limit"))
|
|
329
|
-
});
|
|
330
|
-
return c.json({ summaries });
|
|
331
|
-
});
|
|
332
|
-
authenticated.get("/api/you/quality", (c) => {
|
|
333
|
-
const cfg = deps.service.currentConfig;
|
|
334
|
-
const metrics = summarizeUserUnderstandingQuality({ windowDays: parseWindowDays(c.req.query("windowDays")) });
|
|
335
|
-
const baseIntervalTurns = cfg.userContext.understanding.reviewIntervalTurns;
|
|
336
|
-
const cadence = resolveAdaptiveUnderstandingCadence(baseIntervalTurns, metrics, cfg.userContext.understanding.adaptiveCadence);
|
|
337
|
-
return c.json({
|
|
338
|
-
metrics,
|
|
339
|
-
cadence
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
authenticated.post("/api/you/signals", async (c) => {
|
|
343
|
-
const body = await c.req.json().catch(() => ({}));
|
|
344
|
-
const source = typeof body.source === "string" ? body.source : "";
|
|
345
|
-
if (!source) return c.json({ error: "Missing required field: source" }, 400);
|
|
346
|
-
const signalId = appendMemorySignal({
|
|
347
|
-
providerId: typeof body.providerId === "string" ? body.providerId : void 0,
|
|
348
|
-
sourceAgentId: resolveDefaultAgentId(deps.service.currentConfig),
|
|
349
|
-
workspaceId: typeof body.workspaceId === "string" ? body.workspaceId : void 0,
|
|
350
|
-
sessionKey: typeof body.sessionKey === "string" ? body.sessionKey : void 0,
|
|
351
|
-
signal: {
|
|
352
|
-
source,
|
|
353
|
-
recordId: typeof body.recordId === "string" ? body.recordId : void 0,
|
|
354
|
-
score: typeof body.score === "number" ? body.score : void 0,
|
|
355
|
-
content: typeof body.content === "string" ? body.content : void 0,
|
|
356
|
-
metadata: body.metadata && typeof body.metadata === "object" ? body.metadata : void 0
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
return c.json({ signalId }, 201);
|
|
360
|
-
});
|
|
361
|
-
authenticated.post("/api/you/providers/:id/test", deps.strictRateLimitMiddleware, async (c) => {
|
|
362
|
-
const providerId = c.req.param("id");
|
|
363
|
-
const cfg = deps.service.currentConfig;
|
|
364
|
-
const workspace = deps.service.currentWorkspacePath;
|
|
365
|
-
const manager = createMemoryManagerFromConfig(cfg);
|
|
366
|
-
await manager.initializeAll(`memory-provider-test-${Date.now()}`, {
|
|
367
|
-
workspace,
|
|
368
|
-
agentId: resolveDefaultAgentId(cfg)
|
|
369
|
-
});
|
|
370
|
-
const provider = manager.providersList.find((p) => p.id === providerId);
|
|
371
|
-
if (!provider) return c.json({
|
|
372
|
-
providerId,
|
|
373
|
-
available: false,
|
|
374
|
-
checks: [{
|
|
375
|
-
name: "load",
|
|
376
|
-
ok: false,
|
|
377
|
-
message: "Provider not loaded"
|
|
378
|
-
}]
|
|
379
|
-
}, 404);
|
|
380
|
-
const token = `xopc-memory-smoke-${Date.now()}`;
|
|
381
|
-
const checks = [{
|
|
382
|
-
name: "load",
|
|
383
|
-
ok: true
|
|
384
|
-
}, {
|
|
385
|
-
name: "available",
|
|
386
|
-
ok: provider.isAvailable()
|
|
387
|
-
}];
|
|
388
|
-
const started = Date.now();
|
|
389
|
-
try {
|
|
390
|
-
const write = await manager.write({
|
|
391
|
-
kind: "workspace_fact",
|
|
392
|
-
content: `Smoke test record for ${providerId}: ${token}`,
|
|
393
|
-
scope: { userId: LOCAL_USER_ID },
|
|
394
|
-
tags: ["xopc-smoke-test"]
|
|
395
|
-
});
|
|
396
|
-
checks.push({
|
|
397
|
-
name: "write",
|
|
398
|
-
ok: write.success,
|
|
399
|
-
message: write.error ?? write.message
|
|
400
|
-
});
|
|
401
|
-
const ownResults = (await manager.search({
|
|
402
|
-
query: token,
|
|
403
|
-
scope: { userId: LOCAL_USER_ID },
|
|
404
|
-
maxResults: 10
|
|
405
|
-
})).filter((result) => result.citation.providerId === providerId);
|
|
406
|
-
checks.push({
|
|
407
|
-
name: "search",
|
|
408
|
-
ok: ownResults.length > 0,
|
|
409
|
-
resultCount: ownResults.length
|
|
410
|
-
});
|
|
411
|
-
const recordId = ownResults[0]?.record.id ?? write.record?.id;
|
|
412
|
-
if (recordId) {
|
|
413
|
-
const read = await manager.read({
|
|
414
|
-
id: recordId,
|
|
415
|
-
scope: { userId: LOCAL_USER_ID }
|
|
416
|
-
});
|
|
417
|
-
checks.push({
|
|
418
|
-
name: "read",
|
|
419
|
-
ok: Boolean(read),
|
|
420
|
-
message: read ? void 0 : "Record was not readable"
|
|
421
|
-
});
|
|
422
|
-
} else checks.push({
|
|
423
|
-
name: "read",
|
|
424
|
-
ok: false,
|
|
425
|
-
message: "No record id available"
|
|
426
|
-
});
|
|
427
|
-
manager.recordSignal({
|
|
428
|
-
source: "search_recall",
|
|
429
|
-
content: `Smoke signal for ${providerId}: ${token}`
|
|
430
|
-
});
|
|
431
|
-
checks.push({
|
|
432
|
-
name: "sync",
|
|
433
|
-
ok: true
|
|
434
|
-
});
|
|
435
|
-
} catch (err) {
|
|
436
|
-
checks.push({
|
|
437
|
-
name: "error",
|
|
438
|
-
ok: false,
|
|
439
|
-
message: err instanceof Error ? err.message : String(err)
|
|
440
|
-
});
|
|
441
|
-
} finally {
|
|
442
|
-
appendMemoryTraceEvent({
|
|
443
|
-
phase: "test",
|
|
444
|
-
providerId,
|
|
445
|
-
request: { token },
|
|
446
|
-
resultCount: checks.filter((check) => check.ok).length,
|
|
447
|
-
error: checks.some((check) => !check.ok) ? "one or more checks failed" : void 0,
|
|
448
|
-
durationMs: Date.now() - started
|
|
449
|
-
});
|
|
450
|
-
await manager.shutdownAll();
|
|
451
|
-
}
|
|
452
|
-
return c.json({
|
|
453
|
-
providerId,
|
|
454
|
-
available: provider.isAvailable(),
|
|
455
|
-
checks
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
//#endregion
|
|
460
|
-
export { registerMemoryRoutes };
|