@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 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type ManualUnderstandingScope = {
|
|
3
|
-
type: 'global';
|
|
4
|
-
} | {
|
|
5
|
-
type: 'session';
|
|
6
|
-
sessionKey: string;
|
|
7
|
-
};
|
|
1
|
+
import type { UnderstandingKind, UserContextScope, UserUnderstanding } from './domain.js';
|
|
8
2
|
export declare function createManualUnderstanding(input: {
|
|
9
|
-
agentId: string;
|
|
10
3
|
content: string;
|
|
11
|
-
kind:
|
|
12
|
-
scope:
|
|
13
|
-
sensitivity:
|
|
14
|
-
durability:
|
|
15
|
-
disclosurePolicy:
|
|
4
|
+
kind: UnderstandingKind;
|
|
5
|
+
scope: UserContextScope;
|
|
6
|
+
sensitivity: UserUnderstanding['sensitivity'];
|
|
7
|
+
durability: UserUnderstanding['durability'];
|
|
8
|
+
disclosurePolicy: UserUnderstanding['disclosurePolicy'];
|
|
16
9
|
}): {
|
|
17
|
-
|
|
10
|
+
understanding: UserUnderstanding;
|
|
18
11
|
created: boolean;
|
|
19
12
|
};
|
|
@@ -1,66 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createUnderstanding, listUnderstandings } from "../storage/sqlite/user-context-repository.js";
|
|
2
2
|
import "../storage/sqlite/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { isUserContextRecord } from "./projection.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
5
4
|
//#region src/user-context/manual-understanding.ts
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"needs_review",
|
|
10
|
-
"stale",
|
|
11
|
-
"archived",
|
|
12
|
-
"rejected"
|
|
13
|
-
];
|
|
14
|
-
function sameScope(record, scope) {
|
|
15
|
-
if (scope.type === "session") return record.scope.sessionKey === scope.sessionKey;
|
|
16
|
-
return !record.scope.sessionKey && !record.scope.projectId && !record.scope.workspaceId;
|
|
5
|
+
function canonicalKey(kind, statement) {
|
|
6
|
+
const normalized = statement.toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
7
|
+
return `${kind}:${createHash("sha256").update(normalized).digest("hex").slice(0, 20)}`;
|
|
17
8
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
for (const status of STATUSES) {
|
|
21
|
-
let offset = 0;
|
|
22
|
-
while (true) {
|
|
23
|
-
const page = listMemoryRecords({
|
|
24
|
-
status,
|
|
25
|
-
limit: 500,
|
|
26
|
-
offset
|
|
27
|
-
});
|
|
28
|
-
const duplicate = page.find((record) => isUserContextRecord(record) && sameScope(record, scope) && record.content.trim().toLocaleLowerCase() === normalized);
|
|
29
|
-
if (duplicate) return duplicate;
|
|
30
|
-
if (page.length < 500) break;
|
|
31
|
-
offset += page.length;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
9
|
+
function sameScope(left, right) {
|
|
10
|
+
return left.type === right.type && left.id === right.id;
|
|
34
11
|
}
|
|
35
12
|
function createManualUnderstanding(input) {
|
|
36
|
-
const
|
|
13
|
+
const statement = input.content.trim();
|
|
14
|
+
const key = canonicalKey(input.kind, statement);
|
|
15
|
+
const duplicate = listUnderstandings().find((item) => item.canonicalKey === key && item.status !== "archived" && item.status !== "rejected" && sameScope(item.scope, input.scope));
|
|
37
16
|
if (duplicate) return {
|
|
38
|
-
|
|
17
|
+
understanding: duplicate,
|
|
39
18
|
created: false
|
|
40
19
|
};
|
|
41
20
|
return {
|
|
42
|
-
|
|
43
|
-
providerId: "local",
|
|
21
|
+
understanding: createUnderstanding({
|
|
44
22
|
kind: input.kind,
|
|
45
|
-
|
|
46
|
-
...input.scope.type === "session" ? { sessionKey: input.scope.sessionKey } : {},
|
|
47
|
-
content: input.content,
|
|
48
|
-
source: {
|
|
49
|
-
provider: "local",
|
|
50
|
-
path: "you://manual"
|
|
51
|
-
},
|
|
52
|
-
confidence: 1,
|
|
53
|
-
tags: ["user-understanding", "explicit-user-memory"],
|
|
23
|
+
canonicalKey: key,
|
|
54
24
|
status: "active",
|
|
55
|
-
|
|
25
|
+
scope: input.scope,
|
|
56
26
|
explicitness: "explicit",
|
|
57
27
|
durability: input.durability,
|
|
58
|
-
|
|
28
|
+
sensitivity: input.sensitivity,
|
|
59
29
|
disclosurePolicy: input.disclosurePolicy,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
30
|
+
confidence: 1,
|
|
31
|
+
statement,
|
|
32
|
+
createdBy: "user",
|
|
33
|
+
changeReason: "Created with /remember"
|
|
64
34
|
}),
|
|
65
35
|
created: true
|
|
66
36
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
|
-
import type {
|
|
3
|
-
import type { UserContextPlan } from './types.js';
|
|
4
|
-
export declare function isUserSelfSummaryQuery(query: string): boolean;
|
|
2
|
+
import type { UserContextPlan } from '../agent/memory/context/types.js';
|
|
5
3
|
export declare function prependAgentContext(message: AgentMessage, block: string): AgentMessage;
|
|
6
4
|
export declare class UserContextPlanner {
|
|
7
5
|
plan(params: {
|
|
8
|
-
memoryManager: MemoryManager;
|
|
9
|
-
agentId: string;
|
|
10
6
|
sessionKey: string;
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
projectId?: string;
|
|
9
|
+
channel?: string;
|
|
11
10
|
turnId: string;
|
|
12
11
|
query: string;
|
|
13
12
|
userMessage: AgentMessage;
|
|
14
13
|
excludedRecordIds?: string[];
|
|
15
14
|
allocation?: UserContextPlan['allocation'];
|
|
16
|
-
}):
|
|
15
|
+
}): UserContextPlan;
|
|
17
16
|
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { consumeContextConsent, ensureContextConsent, getUserProfile, listCollaborationRules, listUnderstandings, recordContextRun } from "../storage/sqlite/user-context-repository.js";
|
|
2
|
+
import "../storage/sqlite/index.js";
|
|
3
|
+
import { readAgentMessageContent } from "../agent/memory/agent-message-access.js";
|
|
4
|
+
import { buildUserContextBlock } from "../agent/memory/context-fence.js";
|
|
5
|
+
import { listUserFocuses } from "./sources/repository.js";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
//#region src/user-context/planner.ts
|
|
8
|
+
const DEFAULT_MAX_CONTEXT_CHARS = 6e3;
|
|
9
|
+
const DEFAULT_MAX_RESULTS = 12;
|
|
10
|
+
function prependAgentContext(message, block) {
|
|
11
|
+
if (!block) return message;
|
|
12
|
+
const prefix = `${block}\n\n`;
|
|
13
|
+
const content = readAgentMessageContent(message);
|
|
14
|
+
if (typeof content === "string") return {
|
|
15
|
+
...message,
|
|
16
|
+
content: prefix + content
|
|
17
|
+
};
|
|
18
|
+
if (Array.isArray(content)) {
|
|
19
|
+
const copy = [...content];
|
|
20
|
+
const first = copy[0];
|
|
21
|
+
if (first?.type === "text" && typeof first.text === "string") copy[0] = {
|
|
22
|
+
type: "text",
|
|
23
|
+
text: prefix + first.text
|
|
24
|
+
};
|
|
25
|
+
else copy.unshift({
|
|
26
|
+
type: "text",
|
|
27
|
+
text: prefix
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
...message,
|
|
31
|
+
content: copy
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return message;
|
|
35
|
+
}
|
|
36
|
+
function scopeMatches(scope, input) {
|
|
37
|
+
if (scope.type === "global") return true;
|
|
38
|
+
if (scope.type === "session") return scope.id === input.sessionKey;
|
|
39
|
+
if (scope.type === "workspace") return scope.id === input.workspaceId;
|
|
40
|
+
return Boolean(input.projectId && scope.id === input.projectId);
|
|
41
|
+
}
|
|
42
|
+
function terms(value) {
|
|
43
|
+
const normalized = value.toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
44
|
+
const words = normalized.split(/\s+/).filter((word) => word.length > 1);
|
|
45
|
+
const cjk = [...normalized.replace(/[^\p{Script=Han}]/gu, "")];
|
|
46
|
+
for (let index = 0; index < cjk.length - 1; index += 1) words.push(`${cjk[index]}${cjk[index + 1]}`);
|
|
47
|
+
return new Set(words);
|
|
48
|
+
}
|
|
49
|
+
function relevance(query, item) {
|
|
50
|
+
const queryTerms = terms(query);
|
|
51
|
+
const itemTerms = terms(item.statement);
|
|
52
|
+
const shared = [...queryTerms].filter((term) => itemTerms.has(term)).length;
|
|
53
|
+
const lexical = queryTerms.size ? shared / queryTerms.size : 0;
|
|
54
|
+
const baseline = item.kind === "boundary" && item.explicitness === "explicit" ? .8 : item.kind === "preference" && item.explicitness === "explicit" ? .35 : 0;
|
|
55
|
+
const explicitness = item.explicitness === "explicit" ? .1 : item.explicitness === "observed" ? .05 : 0;
|
|
56
|
+
return Math.min(1, Math.max(baseline, lexical * .75 + item.confidence * .15 + explicitness));
|
|
57
|
+
}
|
|
58
|
+
function sectionFor(item) {
|
|
59
|
+
if (item.kind === "boundary") return "safety";
|
|
60
|
+
if ([
|
|
61
|
+
"preference",
|
|
62
|
+
"relationship",
|
|
63
|
+
"routine"
|
|
64
|
+
].includes(item.kind)) return "interaction";
|
|
65
|
+
return "task";
|
|
66
|
+
}
|
|
67
|
+
function originFor(item) {
|
|
68
|
+
if (item.explicitness === "explicit") return "told_by_user";
|
|
69
|
+
if (item.explicitness === "observed") return "observed";
|
|
70
|
+
return "inferred";
|
|
71
|
+
}
|
|
72
|
+
function sourceLabel(item) {
|
|
73
|
+
if (item.explicitness === "explicit") return "You told xopc";
|
|
74
|
+
if (item.explicitness === "observed") return "Observed across prior work";
|
|
75
|
+
return "An inference that may be wrong";
|
|
76
|
+
}
|
|
77
|
+
function rejectionReason(item, input, now) {
|
|
78
|
+
if (item.status === "needs_review" || item.status === "stale" || item.status === "candidate") return "needs_review";
|
|
79
|
+
if (item.status === "archived" || item.status === "rejected") return "disabled";
|
|
80
|
+
if (!scopeMatches(item.scope, input)) return "scope_mismatch";
|
|
81
|
+
if (item.validFrom && item.validFrom > now) return "not_yet_valid";
|
|
82
|
+
if (item.validTo && item.validTo < now || item.expiresAt && item.expiresAt < now) return "expired";
|
|
83
|
+
if (item.sensitivity === "secret" || item.sensitivity === "regulated") return "sensitive";
|
|
84
|
+
if (item.conflictGroupId) return "conflict";
|
|
85
|
+
}
|
|
86
|
+
function ruleMatches(rule, input) {
|
|
87
|
+
if (rule.status !== "active" || !scopeMatches(rule.scope, input)) return false;
|
|
88
|
+
const channel = typeof rule.conditions.channel === "string" ? rule.conditions.channel : void 0;
|
|
89
|
+
return !channel || channel === input.channel;
|
|
90
|
+
}
|
|
91
|
+
var UserContextPlanner = class {
|
|
92
|
+
plan(params) {
|
|
93
|
+
const traceId = randomUUID();
|
|
94
|
+
const query = params.query.trim();
|
|
95
|
+
if (!query) return {
|
|
96
|
+
traceId,
|
|
97
|
+
modelMessage: params.userMessage,
|
|
98
|
+
items: [],
|
|
99
|
+
rejected: [],
|
|
100
|
+
consentRequests: [],
|
|
101
|
+
estimatedTokens: 0,
|
|
102
|
+
allocation: params.allocation
|
|
103
|
+
};
|
|
104
|
+
const started = Date.now();
|
|
105
|
+
const now = Date.now();
|
|
106
|
+
const maxResults = params.allocation?.maxResults ?? DEFAULT_MAX_RESULTS;
|
|
107
|
+
const maxChars = params.allocation?.maxChars ?? DEFAULT_MAX_CONTEXT_CHARS;
|
|
108
|
+
const scopeInput = {
|
|
109
|
+
sessionKey: params.sessionKey,
|
|
110
|
+
workspaceId: params.workspaceId,
|
|
111
|
+
...params.projectId ? { projectId: params.projectId } : {}
|
|
112
|
+
};
|
|
113
|
+
const excluded = new Set(params.excludedRecordIds ?? []);
|
|
114
|
+
const rejected = [];
|
|
115
|
+
const consentRequests = [];
|
|
116
|
+
const traceItems = [];
|
|
117
|
+
const items = [];
|
|
118
|
+
let usedChars = 0;
|
|
119
|
+
const profile = getUserProfile();
|
|
120
|
+
const profileLines = [
|
|
121
|
+
profile.callName ? `Preferred name: ${profile.callName}` : "",
|
|
122
|
+
profile.role ? `Primary role: ${profile.role}` : "",
|
|
123
|
+
profile.primaryGoal ? `Primary goal for xopc: ${profile.primaryGoal}` : "",
|
|
124
|
+
profile.pronouns ? `Pronouns: ${profile.pronouns}` : "",
|
|
125
|
+
profile.timezone ? `Timezone: ${profile.timezone}` : "",
|
|
126
|
+
profile.locale ? `Language/locale: ${profile.locale}` : ""
|
|
127
|
+
].filter(Boolean);
|
|
128
|
+
if (profileLines.length) {
|
|
129
|
+
const content = profileLines.join("\n");
|
|
130
|
+
traceItems.push({
|
|
131
|
+
objectType: "profile",
|
|
132
|
+
objectId: "profile",
|
|
133
|
+
decision: "selected",
|
|
134
|
+
reason: "User-provided profile",
|
|
135
|
+
content,
|
|
136
|
+
sourceLabel: "You provided this directly",
|
|
137
|
+
rank: 0,
|
|
138
|
+
score: 1,
|
|
139
|
+
injectedChars: content.length
|
|
140
|
+
});
|
|
141
|
+
usedChars += content.length;
|
|
142
|
+
}
|
|
143
|
+
const activeFocusLines = listUserFocuses(["active"]).slice(0, 5).map((focus) => `- ${focus.title}: ${focus.summary} (${focus.horizon})`);
|
|
144
|
+
if (activeFocusLines.length) usedChars += activeFocusLines.join("\n").length;
|
|
145
|
+
const rules = listCollaborationRules().filter((rule) => ruleMatches(rule, {
|
|
146
|
+
...scopeInput,
|
|
147
|
+
channel: params.channel
|
|
148
|
+
}));
|
|
149
|
+
const selectedRules = [];
|
|
150
|
+
for (const [index, rule] of rules.entries()) {
|
|
151
|
+
if (usedChars + rule.statement.length > maxChars) {
|
|
152
|
+
traceItems.push({
|
|
153
|
+
objectType: "rule",
|
|
154
|
+
objectId: rule.id,
|
|
155
|
+
versionId: rule.revisionId,
|
|
156
|
+
decision: "budget_exceeded",
|
|
157
|
+
reason: "Context budget reached",
|
|
158
|
+
content: rule.statement,
|
|
159
|
+
sourceLabel: "Your collaboration rule",
|
|
160
|
+
injectedChars: 0
|
|
161
|
+
});
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
usedChars += rule.statement.length;
|
|
165
|
+
selectedRules.push(rule);
|
|
166
|
+
traceItems.push({
|
|
167
|
+
objectType: "rule",
|
|
168
|
+
objectId: rule.id,
|
|
169
|
+
versionId: rule.revisionId,
|
|
170
|
+
decision: "selected",
|
|
171
|
+
reason: "Active collaboration rule",
|
|
172
|
+
content: rule.statement,
|
|
173
|
+
sourceLabel: "Your collaboration rule",
|
|
174
|
+
rank: index + 1,
|
|
175
|
+
score: 1,
|
|
176
|
+
injectedChars: rule.statement.length
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const ranked = listUnderstandings([
|
|
180
|
+
"active",
|
|
181
|
+
"candidate",
|
|
182
|
+
"needs_review",
|
|
183
|
+
"stale"
|
|
184
|
+
]).filter((item) => !excluded.has(item.id)).map((item) => ({
|
|
185
|
+
item,
|
|
186
|
+
score: relevance(query, item)
|
|
187
|
+
})).sort((left, right) => right.score - left.score).slice(0, Math.max(maxResults * 5, 50));
|
|
188
|
+
for (const { item, score } of ranked) {
|
|
189
|
+
if (items.length >= maxResults) {
|
|
190
|
+
rejected.push({
|
|
191
|
+
recordId: item.id,
|
|
192
|
+
reason: "budget"
|
|
193
|
+
});
|
|
194
|
+
traceItems.push({
|
|
195
|
+
objectType: "understanding",
|
|
196
|
+
objectId: item.id,
|
|
197
|
+
versionId: item.versionId,
|
|
198
|
+
decision: "budget_exceeded",
|
|
199
|
+
reason: "Maximum result count reached",
|
|
200
|
+
content: item.statement,
|
|
201
|
+
sourceLabel: sourceLabel(item),
|
|
202
|
+
score,
|
|
203
|
+
injectedChars: 0
|
|
204
|
+
});
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
let reason = rejectionReason(item, scopeInput, now);
|
|
208
|
+
if (!reason && score < .25) reason = "low_score";
|
|
209
|
+
if (!reason && item.disclosurePolicy === "ask_before_reference") {
|
|
210
|
+
const consentStatus = consumeContextConsent(item.id, params.sessionKey);
|
|
211
|
+
if (consentStatus !== "granted") {
|
|
212
|
+
reason = consentStatus === "denied" ? "disabled" : "requires_consent";
|
|
213
|
+
if (consentStatus === "missing") {
|
|
214
|
+
const consent = ensureContextConsent(item.id, params.sessionKey, query);
|
|
215
|
+
consentRequests.push({
|
|
216
|
+
id: consent.id,
|
|
217
|
+
recordId: item.id,
|
|
218
|
+
statement: item.statement,
|
|
219
|
+
purpose: consent.purpose
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (reason) {
|
|
225
|
+
rejected.push({
|
|
226
|
+
recordId: item.id,
|
|
227
|
+
reason
|
|
228
|
+
});
|
|
229
|
+
traceItems.push({
|
|
230
|
+
objectType: "understanding",
|
|
231
|
+
objectId: item.id,
|
|
232
|
+
versionId: item.versionId,
|
|
233
|
+
decision: reason === "budget" ? "budget_exceeded" : reason === "requires_consent" ? "needs_consent" : reason === "conflict" ? "conflicted" : reason === "expired" ? "expired" : reason === "sensitive" ? "sensitive" : reason === "scope_mismatch" ? "scope_mismatch" : reason === "disabled" ? "disabled" : "irrelevant",
|
|
234
|
+
reason,
|
|
235
|
+
content: item.statement,
|
|
236
|
+
sourceLabel: sourceLabel(item),
|
|
237
|
+
score,
|
|
238
|
+
injectedChars: 0
|
|
239
|
+
});
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (usedChars + item.statement.length > maxChars) {
|
|
243
|
+
rejected.push({
|
|
244
|
+
recordId: item.id,
|
|
245
|
+
reason: "budget"
|
|
246
|
+
});
|
|
247
|
+
traceItems.push({
|
|
248
|
+
objectType: "understanding",
|
|
249
|
+
objectId: item.id,
|
|
250
|
+
versionId: item.versionId,
|
|
251
|
+
decision: "budget_exceeded",
|
|
252
|
+
reason: "Context budget reached",
|
|
253
|
+
content: item.statement,
|
|
254
|
+
sourceLabel: sourceLabel(item),
|
|
255
|
+
score,
|
|
256
|
+
injectedChars: 0
|
|
257
|
+
});
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
usedChars += item.statement.length;
|
|
261
|
+
items.push({
|
|
262
|
+
recordId: item.id,
|
|
263
|
+
objectType: "understanding",
|
|
264
|
+
versionId: item.versionId,
|
|
265
|
+
content: item.statement,
|
|
266
|
+
score,
|
|
267
|
+
section: sectionFor(item),
|
|
268
|
+
citation: `user-context://${item.id}`,
|
|
269
|
+
origin: originFor(item),
|
|
270
|
+
stability: item.confidence
|
|
271
|
+
});
|
|
272
|
+
traceItems.push({
|
|
273
|
+
objectType: "understanding",
|
|
274
|
+
objectId: item.id,
|
|
275
|
+
versionId: item.versionId,
|
|
276
|
+
decision: "selected",
|
|
277
|
+
reason: "Relevant to this request",
|
|
278
|
+
content: item.statement,
|
|
279
|
+
sourceLabel: sourceLabel(item),
|
|
280
|
+
rank: items.length,
|
|
281
|
+
score,
|
|
282
|
+
injectedChars: item.statement.length
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
const block = [
|
|
286
|
+
profileLines.length ? `<user-profile>\n${profileLines.join("\n")}\n</user-profile>` : "",
|
|
287
|
+
activeFocusLines.length ? `<active-focuses>\n${activeFocusLines.join("\n")}\n</active-focuses>` : "",
|
|
288
|
+
selectedRules.length ? `<collaboration-contract>\n${selectedRules.map((rule) => `- ${rule.statement}`).join("\n")}\n</collaboration-contract>` : "",
|
|
289
|
+
items.length ? buildUserContextBlock(items.map((item) => `- ${item.content}\n Evidence: ${traceItems.find((trace) => trace.objectId === item.recordId)?.sourceLabel}`).join("\n")) : ""
|
|
290
|
+
].filter(Boolean).join("\n\n");
|
|
291
|
+
recordContextRun({
|
|
292
|
+
turnId: params.turnId,
|
|
293
|
+
sessionKey: params.sessionKey,
|
|
294
|
+
query,
|
|
295
|
+
budget: maxChars,
|
|
296
|
+
durationMs: Date.now() - started,
|
|
297
|
+
items: traceItems
|
|
298
|
+
});
|
|
299
|
+
return {
|
|
300
|
+
traceId,
|
|
301
|
+
modelMessage: prependAgentContext(params.userMessage, block),
|
|
302
|
+
items,
|
|
303
|
+
rejected,
|
|
304
|
+
consentRequests,
|
|
305
|
+
estimatedTokens: Math.ceil(block.length / 4),
|
|
306
|
+
allocation: params.allocation
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
//#endregion
|
|
311
|
+
export { UserContextPlanner, prependAgentContext };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const RELATIONSHIP_FOLLOW_UP_TAG = "relationship:follow-up";
|
|
1
|
+
import type { UserUnderstanding } from './domain.js';
|
|
3
2
|
export interface RelationshipFollowUpRequest {
|
|
4
3
|
subject: string;
|
|
5
|
-
|
|
4
|
+
validFrom?: number;
|
|
6
5
|
}
|
|
7
6
|
export declare function extractExplicitRelationshipFollowUp(message: string, nowMs?: number): RelationshipFollowUpRequest | null;
|
|
8
7
|
export declare function recordExplicitRelationshipFollowUp(input: {
|
|
9
8
|
sessionKey: string;
|
|
10
|
-
sourceAgentId: string;
|
|
11
9
|
message: string;
|
|
12
10
|
nowMs?: number;
|
|
13
|
-
}):
|
|
14
|
-
export declare function buildRelationshipContinuityPrompt(records: MemoryRecord[], nowMs?: number): string;
|
|
11
|
+
}): UserUnderstanding | null;
|
|
@@ -1,51 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createContextEvidence, createUnderstanding, linkUnderstandingEvidence, listUnderstandings } from "../storage/sqlite/user-context-repository.js";
|
|
2
2
|
import "../storage/sqlite/index.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
3
4
|
//#region src/user-context/relationship-continuity.ts
|
|
4
|
-
const
|
|
5
|
+
const CHINESE_FOLLOW_UP_PATTERN = /^(?:请|记得|麻烦|帮我)?\s*(?:明天|下周|之后|到时候)?\s*(?:提醒我|问问我|跟进一下|跟进)(?:关于)?[::,,\s]*(.+)$/;
|
|
6
|
+
const ENGLISH_FOLLOW_UP_PATTERN = /^(?:please\s+)?(?:remember to\s+)?(?:(?:tomorrow|next week|later)\s+)?(?:follow up with me|check in with me|ask me)(?: about)?[,\s:]+(.+)$/i;
|
|
7
|
+
function normalizeFollowUpSubject(value) {
|
|
8
|
+
const subject = value?.trim();
|
|
9
|
+
if (!subject || subject.length > 240) return null;
|
|
10
|
+
if (/^(?:的|地|得|以及|并且|和|与|、|,|。|;|:)/.test(subject)) return null;
|
|
11
|
+
return subject;
|
|
12
|
+
}
|
|
13
|
+
function hash(value) {
|
|
14
|
+
return createHash("sha256").update(value).digest("hex").slice(0, 20);
|
|
15
|
+
}
|
|
5
16
|
function extractExplicitRelationshipFollowUp(message, nowMs = Date.now()) {
|
|
6
17
|
const text = message.trim();
|
|
7
|
-
const subject = (text.match(
|
|
8
|
-
if (!subject
|
|
9
|
-
const delayMs = /明天|tomorrow/i.test(text) ?
|
|
18
|
+
const subject = normalizeFollowUpSubject((text.match(CHINESE_FOLLOW_UP_PATTERN) ?? text.match(ENGLISH_FOLLOW_UP_PATTERN))?.[1]);
|
|
19
|
+
if (!subject) return null;
|
|
20
|
+
const delayMs = /明天|tomorrow/i.test(text) ? 864e5 : /下周|next week/i.test(text) ? 7 * 864e5 : 0;
|
|
10
21
|
return {
|
|
11
22
|
subject,
|
|
12
|
-
...delayMs ? {
|
|
23
|
+
...delayMs ? { validFrom: nowMs + delayMs } : {}
|
|
13
24
|
};
|
|
14
25
|
}
|
|
15
26
|
function recordExplicitRelationshipFollowUp(input) {
|
|
16
27
|
const request = extractExplicitRelationshipFollowUp(input.message, input.nowMs);
|
|
17
28
|
if (!request) return null;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
status: "active",
|
|
21
|
-
limit: 200
|
|
22
|
-
}).find((record) => record.tags?.includes("relationship:follow-up") && record.content === request.subject);
|
|
29
|
+
const canonicalKey = `relationship-follow-up:${hash(request.subject.toLocaleLowerCase())}`;
|
|
30
|
+
const existing = listUnderstandings().find((item) => item.canonicalKey === canonicalKey && item.scope.type === "global" && item.status !== "rejected" && item.status !== "archived");
|
|
23
31
|
if (existing) return existing;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
sourceAgentId: input.sourceAgentId,
|
|
28
|
-
sessionKey: input.sessionKey,
|
|
29
|
-
content: request.subject,
|
|
30
|
-
source: { provider: "builtin" },
|
|
31
|
-
tags: [RELATIONSHIP_FOLLOW_UP_TAG],
|
|
32
|
+
const understanding = createUnderstanding({
|
|
33
|
+
kind: "relationship",
|
|
34
|
+
canonicalKey,
|
|
32
35
|
status: "active",
|
|
36
|
+
scope: { type: "global" },
|
|
33
37
|
explicitness: "explicit",
|
|
34
38
|
durability: "recurring",
|
|
35
|
-
|
|
39
|
+
sensitivity: "normal",
|
|
36
40
|
disclosurePolicy: "referenceable",
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
confidence: 1,
|
|
42
|
+
statement: request.subject,
|
|
43
|
+
...request.validFrom ? { validFrom: request.validFrom } : {},
|
|
44
|
+
createdBy: "user",
|
|
45
|
+
changeReason: "Explicit follow-up request"
|
|
39
46
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const evidence = createContextEvidence({
|
|
48
|
+
sourceType: "conversation",
|
|
49
|
+
sourceRef: `session:${input.sessionKey}:follow-up:${hash(input.message)}`,
|
|
50
|
+
redactedExcerpt: input.message.slice(0, 600),
|
|
51
|
+
trustLevel: "owner",
|
|
52
|
+
observedAt: input.nowMs ?? Date.now()
|
|
53
|
+
});
|
|
54
|
+
linkUnderstandingEvidence(understanding.versionId, evidence.id, "supports", 1);
|
|
55
|
+
return understanding;
|
|
49
56
|
}
|
|
50
57
|
//#endregion
|
|
51
|
-
export {
|
|
58
|
+
export { extractExplicitRelationshipFollowUp, recordExplicitRelationshipFollowUp };
|