@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
//#region src/user-context/sources/catalog.ts
|
|
2
|
+
const COMMON = [
|
|
3
|
+
{
|
|
4
|
+
id: "local-work-folders",
|
|
5
|
+
category: "files",
|
|
6
|
+
platform: "all",
|
|
7
|
+
displayName: "Work folders",
|
|
8
|
+
description: "Discover likely work folders and analyze only folders you approve.",
|
|
9
|
+
availability: "available",
|
|
10
|
+
permission: "not_requested",
|
|
11
|
+
defaultAccessMode: "continuous",
|
|
12
|
+
supportedAccessModes: ["once", "continuous"],
|
|
13
|
+
recommended: true,
|
|
14
|
+
sensitive: false
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "connector-github",
|
|
18
|
+
category: "code_activity",
|
|
19
|
+
platform: "all",
|
|
20
|
+
displayName: "GitHub",
|
|
21
|
+
description: "Repositories, pull requests, issues, and recent code activity from an account you connect.",
|
|
22
|
+
availability: "available",
|
|
23
|
+
permission: "not_requested",
|
|
24
|
+
defaultAccessMode: "continuous",
|
|
25
|
+
supportedAccessModes: ["once", "continuous"],
|
|
26
|
+
recommended: true,
|
|
27
|
+
sensitive: false
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "connector-calendar",
|
|
31
|
+
category: "calendar",
|
|
32
|
+
platform: "all",
|
|
33
|
+
displayName: "Connected calendar",
|
|
34
|
+
description: "Calendar commitments and recurring work rhythms from a connected account.",
|
|
35
|
+
availability: "available",
|
|
36
|
+
permission: "not_requested",
|
|
37
|
+
defaultAccessMode: "continuous",
|
|
38
|
+
supportedAccessModes: ["once", "continuous"],
|
|
39
|
+
recommended: true,
|
|
40
|
+
sensitive: true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "connector-drive",
|
|
44
|
+
category: "files",
|
|
45
|
+
platform: "all",
|
|
46
|
+
displayName: "Cloud documents",
|
|
47
|
+
description: "Selected cloud documents and metadata from a connected workspace.",
|
|
48
|
+
availability: "available",
|
|
49
|
+
permission: "not_requested",
|
|
50
|
+
defaultAccessMode: "continuous",
|
|
51
|
+
supportedAccessModes: ["once", "continuous"],
|
|
52
|
+
recommended: false,
|
|
53
|
+
sensitive: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "connector-mail",
|
|
57
|
+
category: "mail",
|
|
58
|
+
platform: "all",
|
|
59
|
+
displayName: "Mail",
|
|
60
|
+
description: "Work themes and commitments from explicitly connected mail.",
|
|
61
|
+
availability: "available",
|
|
62
|
+
permission: "not_requested",
|
|
63
|
+
defaultAccessMode: "continuous",
|
|
64
|
+
supportedAccessModes: ["once", "continuous"],
|
|
65
|
+
recommended: false,
|
|
66
|
+
sensitive: true
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "connector-messages",
|
|
70
|
+
category: "messages",
|
|
71
|
+
platform: "all",
|
|
72
|
+
displayName: "Messages",
|
|
73
|
+
description: "Work themes from explicitly connected collaboration messages.",
|
|
74
|
+
availability: "available",
|
|
75
|
+
permission: "not_requested",
|
|
76
|
+
defaultAccessMode: "continuous",
|
|
77
|
+
supportedAccessModes: ["once", "continuous"],
|
|
78
|
+
recommended: false,
|
|
79
|
+
sensitive: true
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
const PLATFORM = {
|
|
83
|
+
darwin: [
|
|
84
|
+
[
|
|
85
|
+
"apple-notes",
|
|
86
|
+
"notes",
|
|
87
|
+
"Apple Notes",
|
|
88
|
+
"Recent unlocked notes selected through macOS Automation",
|
|
89
|
+
true
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
"apple-calendar",
|
|
93
|
+
"calendar",
|
|
94
|
+
"Apple Calendar",
|
|
95
|
+
"Recent and upcoming calendar events",
|
|
96
|
+
true
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"apple-reminders",
|
|
100
|
+
"tasks",
|
|
101
|
+
"Apple Reminders",
|
|
102
|
+
"Open and recently completed reminders",
|
|
103
|
+
true
|
|
104
|
+
]
|
|
105
|
+
].map(([id, category, displayName, description, sensitive]) => ({
|
|
106
|
+
id: String(id),
|
|
107
|
+
category,
|
|
108
|
+
platform: "darwin",
|
|
109
|
+
displayName: String(displayName),
|
|
110
|
+
description: String(description),
|
|
111
|
+
availability: "available",
|
|
112
|
+
permission: "not_requested",
|
|
113
|
+
defaultAccessMode: "once",
|
|
114
|
+
supportedAccessModes: ["once"],
|
|
115
|
+
recommended: category !== "notes",
|
|
116
|
+
sensitive: Boolean(sensitive)
|
|
117
|
+
})),
|
|
118
|
+
win32: [{
|
|
119
|
+
id: "windows-recent-documents",
|
|
120
|
+
category: "recent_documents",
|
|
121
|
+
platform: "win32",
|
|
122
|
+
displayName: "Recent documents",
|
|
123
|
+
description: "Metadata for files in Windows Recent Items",
|
|
124
|
+
availability: "available",
|
|
125
|
+
permission: "granted",
|
|
126
|
+
defaultAccessMode: "once",
|
|
127
|
+
supportedAccessModes: ["once"],
|
|
128
|
+
recommended: true,
|
|
129
|
+
sensitive: false
|
|
130
|
+
}],
|
|
131
|
+
linux: [{
|
|
132
|
+
id: "linux-recent-documents",
|
|
133
|
+
category: "recent_documents",
|
|
134
|
+
platform: "linux",
|
|
135
|
+
displayName: "Recent documents",
|
|
136
|
+
description: "Metadata from the freedesktop recent-files list",
|
|
137
|
+
availability: "available",
|
|
138
|
+
permission: "granted",
|
|
139
|
+
defaultAccessMode: "once",
|
|
140
|
+
supportedAccessModes: ["once"],
|
|
141
|
+
recommended: true,
|
|
142
|
+
sensitive: false
|
|
143
|
+
}]
|
|
144
|
+
};
|
|
145
|
+
function listUnderstandingSourceDefinitions(platform = process.platform) {
|
|
146
|
+
return [...COMMON, ...PLATFORM[platform] ?? []];
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { listUnderstandingSourceDefinitions };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus } from "./repository.js";
|
|
2
|
+
import { listUnderstandingSourceDefinitions } from "./catalog.js";
|
|
3
|
+
export { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceDefinitions, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { UnderstandingSourceGrant, UnderstandingSourceRun, UserFocus } from './types.js';
|
|
2
|
+
export declare function listUnderstandingSourceGrants(options?: {
|
|
3
|
+
includeRevoked?: boolean;
|
|
4
|
+
}): UnderstandingSourceGrant[];
|
|
5
|
+
export declare function getUnderstandingSourceGrant(id: string): UnderstandingSourceGrant | null;
|
|
6
|
+
export declare function upsertUnderstandingSourceGrant(input: Omit<UnderstandingSourceGrant, 'id' | 'status' | 'checkpoint' | 'lastCollectedAt' | 'createdAt' | 'updatedAt'> & {
|
|
7
|
+
checkpoint?: Record<string, unknown>;
|
|
8
|
+
lastCollectedAt?: number;
|
|
9
|
+
nowMs?: number;
|
|
10
|
+
}): UnderstandingSourceGrant;
|
|
11
|
+
export declare function updateUnderstandingSourceGrantCheckpoint(id: string, input: {
|
|
12
|
+
checkpoint?: Record<string, unknown>;
|
|
13
|
+
lastCollectedAt?: number;
|
|
14
|
+
nowMs?: number;
|
|
15
|
+
}): UnderstandingSourceGrant | null;
|
|
16
|
+
export declare function revokeUnderstandingSourceGrant(id: string, nowMs?: number): UnderstandingSourceGrant | null;
|
|
17
|
+
export declare function createUnderstandingSourceRun(input: {
|
|
18
|
+
grantId: string;
|
|
19
|
+
kind: UnderstandingSourceRun['kind'];
|
|
20
|
+
status?: UnderstandingSourceRun['status'];
|
|
21
|
+
cursorBefore?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
nowMs?: number;
|
|
24
|
+
}): UnderstandingSourceRun;
|
|
25
|
+
export declare function getUnderstandingSourceRun(id: string): UnderstandingSourceRun | null;
|
|
26
|
+
export declare function listUnderstandingSourceRuns(grantId: string, limit?: number): UnderstandingSourceRun[];
|
|
27
|
+
export declare function updateUnderstandingSourceRun(id: string, patch: {
|
|
28
|
+
status?: UnderstandingSourceRun['status'];
|
|
29
|
+
cursorAfter?: string;
|
|
30
|
+
itemsSeen?: number;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
errorMessage?: string;
|
|
33
|
+
completed?: boolean;
|
|
34
|
+
nowMs?: number;
|
|
35
|
+
}): UnderstandingSourceRun | null;
|
|
36
|
+
export declare function upsertUserFocus(input: Omit<UserFocus, 'id' | 'createdAt' | 'updatedAt'> & {
|
|
37
|
+
nowMs?: number;
|
|
38
|
+
}): UserFocus;
|
|
39
|
+
export declare function listUserFocuses(statuses?: UserFocus['status'][]): UserFocus[];
|
|
40
|
+
export declare function setUserFocusStatus(id: string, status: UserFocus['status'], nowMs?: number): UserFocus | null;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
//#region src/user-context/sources/repository.ts
|
|
4
|
+
function record(value) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(value);
|
|
7
|
+
} catch {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function strings(value) {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(value);
|
|
14
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
15
|
+
} catch {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function grantFromRow(row) {
|
|
20
|
+
return {
|
|
21
|
+
id: row.grant_id,
|
|
22
|
+
sourceKey: row.source_key,
|
|
23
|
+
adapterId: row.adapter_id,
|
|
24
|
+
category: row.category,
|
|
25
|
+
platform: row.platform,
|
|
26
|
+
displayName: row.display_name,
|
|
27
|
+
status: row.status,
|
|
28
|
+
accessMode: row.access_mode,
|
|
29
|
+
retentionPolicy: row.retention_policy,
|
|
30
|
+
processingPolicy: row.processing_policy,
|
|
31
|
+
config: record(row.config_json),
|
|
32
|
+
checkpoint: record(row.checkpoint_json),
|
|
33
|
+
...row.last_collected_at == null ? {} : { lastCollectedAt: row.last_collected_at },
|
|
34
|
+
createdAt: row.created_at,
|
|
35
|
+
updatedAt: row.updated_at
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function runFromRow(row) {
|
|
39
|
+
return {
|
|
40
|
+
id: row.run_id,
|
|
41
|
+
grantId: row.grant_id,
|
|
42
|
+
kind: row.kind,
|
|
43
|
+
status: row.status,
|
|
44
|
+
...row.cursor_before ? { cursorBefore: row.cursor_before } : {},
|
|
45
|
+
...row.cursor_after ? { cursorAfter: row.cursor_after } : {},
|
|
46
|
+
itemsSeen: row.items_seen,
|
|
47
|
+
metadata: record(row.metadata_json),
|
|
48
|
+
...row.error_message ? { errorMessage: row.error_message } : {},
|
|
49
|
+
startedAt: row.started_at,
|
|
50
|
+
...row.completed_at == null ? {} : { completedAt: row.completed_at }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function focusFromRow(row) {
|
|
54
|
+
return {
|
|
55
|
+
id: row.focus_id,
|
|
56
|
+
canonicalKey: row.canonical_key,
|
|
57
|
+
title: row.title,
|
|
58
|
+
summary: row.summary,
|
|
59
|
+
horizon: row.horizon,
|
|
60
|
+
status: row.status,
|
|
61
|
+
confidence: row.confidence,
|
|
62
|
+
...row.project_id ? { projectId: row.project_id } : {},
|
|
63
|
+
evidenceRefs: strings(row.evidence_refs_json),
|
|
64
|
+
...row.source_run_id ? { sourceRunId: row.source_run_id } : {},
|
|
65
|
+
createdAt: row.created_at,
|
|
66
|
+
updatedAt: row.updated_at
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function listUnderstandingSourceGrants(options = {}) {
|
|
70
|
+
return getSqliteDatabase().prepare(`SELECT * FROM understanding_source_grants ${options.includeRevoked ? "" : "WHERE status = 'active'"} ORDER BY updated_at DESC`).all().map(grantFromRow);
|
|
71
|
+
}
|
|
72
|
+
function getUnderstandingSourceGrant(id) {
|
|
73
|
+
const row = getSqliteDatabase().prepare("SELECT * FROM understanding_source_grants WHERE grant_id = ?").get(id);
|
|
74
|
+
return row ? grantFromRow(row) : null;
|
|
75
|
+
}
|
|
76
|
+
function upsertUnderstandingSourceGrant(input) {
|
|
77
|
+
const id = randomUUID();
|
|
78
|
+
const now = input.nowMs ?? Date.now();
|
|
79
|
+
const existingRow = getSqliteDatabase().prepare("SELECT * FROM understanding_source_grants WHERE source_key = ?").get(input.sourceKey);
|
|
80
|
+
const existing = existingRow ? grantFromRow(existingRow) : void 0;
|
|
81
|
+
runSqliteWriteTransaction((db) => db.prepare(`
|
|
82
|
+
INSERT INTO understanding_source_grants (
|
|
83
|
+
grant_id, source_key, adapter_id, category, platform, display_name, status, access_mode,
|
|
84
|
+
retention_policy, processing_policy, config_json, checkpoint_json, last_collected_at, created_at, updated_at
|
|
85
|
+
) VALUES (?, ?, ?, ?, ?, ?, 'active', ?, ?, ?, ?, ?, ?, ?, ?)
|
|
86
|
+
ON CONFLICT(source_key) DO UPDATE SET
|
|
87
|
+
adapter_id = excluded.adapter_id, category = excluded.category, platform = excluded.platform,
|
|
88
|
+
display_name = excluded.display_name, status = 'active', access_mode = excluded.access_mode,
|
|
89
|
+
retention_policy = excluded.retention_policy, processing_policy = excluded.processing_policy,
|
|
90
|
+
config_json = excluded.config_json, checkpoint_json = excluded.checkpoint_json,
|
|
91
|
+
last_collected_at = COALESCE(excluded.last_collected_at, understanding_source_grants.last_collected_at),
|
|
92
|
+
updated_at = excluded.updated_at
|
|
93
|
+
`).run(id, input.sourceKey, input.adapterId, input.category, input.platform, input.displayName, input.accessMode, input.retentionPolicy, input.processingPolicy, JSON.stringify(input.config), JSON.stringify(input.checkpoint ?? existing?.checkpoint ?? {}), input.lastCollectedAt ?? null, now, now));
|
|
94
|
+
return grantFromRow(getSqliteDatabase().prepare("SELECT * FROM understanding_source_grants WHERE source_key = ?").get(input.sourceKey));
|
|
95
|
+
}
|
|
96
|
+
function updateUnderstandingSourceGrantCheckpoint(id, input) {
|
|
97
|
+
const current = getUnderstandingSourceGrant(id);
|
|
98
|
+
if (!current) return null;
|
|
99
|
+
const now = input.nowMs ?? Date.now();
|
|
100
|
+
runSqliteWriteTransaction((db) => db.prepare(`
|
|
101
|
+
UPDATE understanding_source_grants
|
|
102
|
+
SET checkpoint_json = ?, last_collected_at = ?, updated_at = ?
|
|
103
|
+
WHERE grant_id = ?
|
|
104
|
+
`).run(JSON.stringify(input.checkpoint ?? current.checkpoint), input.lastCollectedAt ?? current.lastCollectedAt ?? null, now, id));
|
|
105
|
+
return getUnderstandingSourceGrant(id);
|
|
106
|
+
}
|
|
107
|
+
function revokeUnderstandingSourceGrant(id, nowMs = Date.now()) {
|
|
108
|
+
runSqliteWriteTransaction((db) => db.prepare("UPDATE understanding_source_grants SET status = 'revoked', updated_at = ? WHERE grant_id = ?").run(nowMs, id));
|
|
109
|
+
return getUnderstandingSourceGrant(id);
|
|
110
|
+
}
|
|
111
|
+
function createUnderstandingSourceRun(input) {
|
|
112
|
+
const id = randomUUID();
|
|
113
|
+
const now = input.nowMs ?? Date.now();
|
|
114
|
+
runSqliteWriteTransaction((db) => db.prepare(`
|
|
115
|
+
INSERT INTO understanding_source_runs (
|
|
116
|
+
run_id, grant_id, kind, status, cursor_before, metadata_json, started_at
|
|
117
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
118
|
+
`).run(id, input.grantId, input.kind, input.status ?? "running", input.cursorBefore ?? null, JSON.stringify(input.metadata ?? {}), now));
|
|
119
|
+
return getUnderstandingSourceRun(id);
|
|
120
|
+
}
|
|
121
|
+
function getUnderstandingSourceRun(id) {
|
|
122
|
+
const row = getSqliteDatabase().prepare("SELECT * FROM understanding_source_runs WHERE run_id = ?").get(id);
|
|
123
|
+
return row ? runFromRow(row) : null;
|
|
124
|
+
}
|
|
125
|
+
function listUnderstandingSourceRuns(grantId, limit = 20) {
|
|
126
|
+
return getSqliteDatabase().prepare("SELECT * FROM understanding_source_runs WHERE grant_id = ? ORDER BY started_at DESC LIMIT ?").all(grantId, Math.max(1, Math.min(100, limit))).map(runFromRow);
|
|
127
|
+
}
|
|
128
|
+
function updateUnderstandingSourceRun(id, patch) {
|
|
129
|
+
const current = getUnderstandingSourceRun(id);
|
|
130
|
+
if (!current) return null;
|
|
131
|
+
const completedAt = patch.completed ? patch.nowMs ?? Date.now() : current.completedAt ?? null;
|
|
132
|
+
runSqliteWriteTransaction((db) => db.prepare(`
|
|
133
|
+
UPDATE understanding_source_runs SET status = ?, cursor_after = ?, items_seen = ?, metadata_json = ?,
|
|
134
|
+
error_message = ?, completed_at = ? WHERE run_id = ?
|
|
135
|
+
`).run(patch.status ?? current.status, patch.cursorAfter ?? current.cursorAfter ?? null, patch.itemsSeen ?? current.itemsSeen, JSON.stringify(patch.metadata ?? current.metadata), patch.errorMessage ?? current.errorMessage ?? null, completedAt, id));
|
|
136
|
+
return getUnderstandingSourceRun(id);
|
|
137
|
+
}
|
|
138
|
+
function upsertUserFocus(input) {
|
|
139
|
+
const id = randomUUID();
|
|
140
|
+
const now = input.nowMs ?? Date.now();
|
|
141
|
+
runSqliteWriteTransaction((db) => db.prepare(`
|
|
142
|
+
INSERT INTO user_focuses (
|
|
143
|
+
focus_id, canonical_key, title, summary, horizon, status, confidence, project_id,
|
|
144
|
+
evidence_refs_json, source_run_id, created_at, updated_at
|
|
145
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
146
|
+
ON CONFLICT(canonical_key) DO UPDATE SET title = excluded.title, summary = excluded.summary,
|
|
147
|
+
horizon = excluded.horizon, status = excluded.status, confidence = excluded.confidence,
|
|
148
|
+
project_id = excluded.project_id, evidence_refs_json = excluded.evidence_refs_json,
|
|
149
|
+
source_run_id = excluded.source_run_id, updated_at = excluded.updated_at
|
|
150
|
+
`).run(id, input.canonicalKey, input.title, input.summary, input.horizon, input.status, input.confidence, input.projectId ?? null, JSON.stringify(input.evidenceRefs), input.sourceRunId ?? null, now, now));
|
|
151
|
+
return focusFromRow(getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE canonical_key = ?").get(input.canonicalKey));
|
|
152
|
+
}
|
|
153
|
+
function listUserFocuses(statuses) {
|
|
154
|
+
if (!statuses?.length) return getSqliteDatabase().prepare("SELECT * FROM user_focuses ORDER BY updated_at DESC").all().map(focusFromRow);
|
|
155
|
+
const placeholders = statuses.map(() => "?").join(", ");
|
|
156
|
+
return getSqliteDatabase().prepare(`SELECT * FROM user_focuses WHERE status IN (${placeholders}) ORDER BY updated_at DESC`).all(...statuses).map(focusFromRow);
|
|
157
|
+
}
|
|
158
|
+
function setUserFocusStatus(id, status, nowMs = Date.now()) {
|
|
159
|
+
runSqliteWriteTransaction((db) => db.prepare("UPDATE user_focuses SET status = ?, updated_at = ? WHERE focus_id = ?").run(status, nowMs, id));
|
|
160
|
+
const row = getSqliteDatabase().prepare("SELECT * FROM user_focuses WHERE focus_id = ?").get(id);
|
|
161
|
+
return row ? focusFromRow(row) : null;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, listUnderstandingSourceGrants, listUnderstandingSourceRuns, listUserFocuses, revokeUnderstandingSourceGrant, setUserFocusStatus, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant, upsertUserFocus };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type UnderstandingSourcePlatform = 'darwin' | 'win32' | 'linux' | 'all';
|
|
2
|
+
export type UnderstandingSourceCategory = 'files' | 'recent_documents' | 'calendar' | 'tasks' | 'notes' | 'mail' | 'messages' | 'code_activity';
|
|
3
|
+
export type UnderstandingSourceAccessMode = 'once' | 'continuous';
|
|
4
|
+
export type UnderstandingSourceRetentionPolicy = 'metadata_only' | 'derived_only' | 'bounded_raw';
|
|
5
|
+
export type UnderstandingSourceProcessingPolicy = 'local_only' | 'remote_allowed';
|
|
6
|
+
export interface UnderstandingSourceDefinition {
|
|
7
|
+
id: string;
|
|
8
|
+
category: UnderstandingSourceCategory;
|
|
9
|
+
platform: UnderstandingSourcePlatform;
|
|
10
|
+
displayName: string;
|
|
11
|
+
description: string;
|
|
12
|
+
availability: 'available' | 'unavailable';
|
|
13
|
+
permission: 'not_requested' | 'granted' | 'denied' | 'unavailable';
|
|
14
|
+
defaultAccessMode: UnderstandingSourceAccessMode;
|
|
15
|
+
supportedAccessModes: UnderstandingSourceAccessMode[];
|
|
16
|
+
recommended: boolean;
|
|
17
|
+
sensitive: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface UnderstandingSourceGrant {
|
|
20
|
+
id: string;
|
|
21
|
+
sourceKey: string;
|
|
22
|
+
adapterId: string;
|
|
23
|
+
category: UnderstandingSourceCategory;
|
|
24
|
+
platform: UnderstandingSourcePlatform;
|
|
25
|
+
displayName: string;
|
|
26
|
+
status: 'active' | 'revoked';
|
|
27
|
+
accessMode: UnderstandingSourceAccessMode;
|
|
28
|
+
retentionPolicy: UnderstandingSourceRetentionPolicy;
|
|
29
|
+
processingPolicy: UnderstandingSourceProcessingPolicy;
|
|
30
|
+
config: Record<string, unknown>;
|
|
31
|
+
checkpoint: Record<string, unknown>;
|
|
32
|
+
lastCollectedAt?: number;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
updatedAt: number;
|
|
35
|
+
}
|
|
36
|
+
export interface UnderstandingSourceItem {
|
|
37
|
+
id: string;
|
|
38
|
+
sourceId: string;
|
|
39
|
+
type: 'document' | 'calendar_event' | 'task' | 'note' | 'mail' | 'message' | 'code_activity';
|
|
40
|
+
title: string;
|
|
41
|
+
text?: string;
|
|
42
|
+
group?: string;
|
|
43
|
+
occurredAt?: number;
|
|
44
|
+
modifiedAt?: number;
|
|
45
|
+
startsAt?: number;
|
|
46
|
+
endsAt?: number;
|
|
47
|
+
ownerAttribution: 'user' | 'other' | 'shared' | 'unknown';
|
|
48
|
+
sensitivity: 'normal' | 'personal' | 'secret' | 'regulated';
|
|
49
|
+
evidenceRef: string;
|
|
50
|
+
}
|
|
51
|
+
export interface UnderstandingSourceCollectionResult {
|
|
52
|
+
sourceId: string;
|
|
53
|
+
status: 'completed' | 'denied' | 'failed';
|
|
54
|
+
items: UnderstandingSourceItem[];
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface UnderstandingSourceRun {
|
|
58
|
+
id: string;
|
|
59
|
+
grantId: string;
|
|
60
|
+
kind: 'preview' | 'bootstrap' | 'incremental' | 'fingerprint';
|
|
61
|
+
status: 'queued' | 'running' | 'completed' | 'partial' | 'failed' | 'canceled';
|
|
62
|
+
cursorBefore?: string;
|
|
63
|
+
cursorAfter?: string;
|
|
64
|
+
itemsSeen: number;
|
|
65
|
+
metadata: Record<string, unknown>;
|
|
66
|
+
errorMessage?: string;
|
|
67
|
+
startedAt: number;
|
|
68
|
+
completedAt?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface UserFocus {
|
|
71
|
+
id: string;
|
|
72
|
+
canonicalKey: string;
|
|
73
|
+
title: string;
|
|
74
|
+
summary: string;
|
|
75
|
+
horizon: 'current' | 'ongoing' | 'long_term';
|
|
76
|
+
status: 'candidate' | 'active' | 'paused' | 'completed' | 'rejected';
|
|
77
|
+
confidence: number;
|
|
78
|
+
projectId?: string;
|
|
79
|
+
evidenceRefs: string[];
|
|
80
|
+
sourceRunId?: string;
|
|
81
|
+
createdAt: number;
|
|
82
|
+
updatedAt: number;
|
|
83
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MemoryKind } from '../agent/memory/types.js';
|
|
2
|
+
export declare function isStandaloneUnderstandingContent(content: string): boolean;
|
|
3
|
+
export declare function isActionableUnderstandingContent(content: string): boolean;
|
|
4
|
+
export declare function isDurableUnderstandingCandidate(kind: MemoryKind, content: string): boolean;
|
|
5
|
+
export declare function isNearDuplicateUnderstanding(left: string, right: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/user-context/understandingQuality.ts
|
|
2
|
+
const INCOMPLETE_PREFIX = /^(?:and\b|also\b|then\b|plus\b|as\s+well\s+as\b|which\b|that\b|并且|并将|以及|然后|同时|另外|还有|而且|或者|的事项|事项[,,、::]?)/i;
|
|
3
|
+
const DEFERRED_OR_NEGATED_ACTION = /(?:not\s+now|no\s+need\s+to|do\s+not\s+(?:start|proceed)|don't\s+(?:start|proceed)|later\s+maybe|暂时不用|暂时不(?:用|要|开始)?|先不用|无需|不用开始|不要推进|不需要推进)/i;
|
|
4
|
+
const ONE_OFF_ACTION_PREFIX = /^(?:please\s+|update\b|investigate\b|summari[sz]e\b|fix\b|write\b|add\b|record\b|track\b)|^(?:请|帮我|更新|调查|汇总|整理|修复|写入|加入|记录|跟进)/i;
|
|
5
|
+
function meaningfulLength(content) {
|
|
6
|
+
return content.normalize("NFKC").replace(/[\p{P}\p{S}\s]/gu, "").length;
|
|
7
|
+
}
|
|
8
|
+
function isStandaloneUnderstandingContent(content) {
|
|
9
|
+
const normalized = content.normalize("NFKC").trim();
|
|
10
|
+
return meaningfulLength(normalized) >= 4 && !INCOMPLETE_PREFIX.test(normalized) && !DEFERRED_OR_NEGATED_ACTION.test(normalized);
|
|
11
|
+
}
|
|
12
|
+
function isActionableUnderstandingContent(content) {
|
|
13
|
+
return meaningfulLength(content) >= 8 && isStandaloneUnderstandingContent(content);
|
|
14
|
+
}
|
|
15
|
+
function isDurableUnderstandingCandidate(kind, content) {
|
|
16
|
+
if (!isStandaloneUnderstandingContent(content)) return false;
|
|
17
|
+
if ((kind === "commitment" || kind === "long_term_goal") && ONE_OFF_ACTION_PREFIX.test(content.trim())) return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function comparableText(content) {
|
|
21
|
+
return content.normalize("NFKC").toLocaleLowerCase().replace(/[\p{P}\p{S}\s]/gu, "");
|
|
22
|
+
}
|
|
23
|
+
function bigrams(content) {
|
|
24
|
+
const result = /* @__PURE__ */ new Set();
|
|
25
|
+
for (let index = 0; index < content.length - 1; index += 1) result.add(content.slice(index, index + 2));
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function isNearDuplicateUnderstanding(left, right) {
|
|
29
|
+
const a = comparableText(left);
|
|
30
|
+
const b = comparableText(right);
|
|
31
|
+
if (!a || !b) return false;
|
|
32
|
+
if (a === b) return true;
|
|
33
|
+
const shorter = a.length <= b.length ? a : b;
|
|
34
|
+
const longer = a.length > b.length ? a : b;
|
|
35
|
+
if (shorter.length >= 8 && longer.includes(shorter) && shorter.length / longer.length >= .55) return true;
|
|
36
|
+
if (shorter.length < 4) return false;
|
|
37
|
+
const aPairs = bigrams(a);
|
|
38
|
+
const bPairs = bigrams(b);
|
|
39
|
+
let overlap = 0;
|
|
40
|
+
for (const pair of aPairs) if (bPairs.has(pair)) overlap += 1;
|
|
41
|
+
return 2 * overlap / (aPairs.size + bPairs.size) >= .78;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { isActionableUnderstandingContent, isDurableUnderstandingCandidate, isNearDuplicateUnderstanding, isStandaloneUnderstandingContent };
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Log Streaming Module - SSE real-time log delivery
|
|
3
|
-
*/
|
|
1
|
+
/** In-process live log fan-out. */
|
|
4
2
|
import type { LogLevel, LogEntry } from './types.js';
|
|
5
3
|
export type { LogLevel, LogEntry };
|
|
4
|
+
type LogSubscriber = (entry: LogEntry) => void;
|
|
5
|
+
export declare function subscribeToLogs(subscriber: LogSubscriber): () => void;
|
|
6
6
|
export declare function hasSubscribers(): boolean;
|
|
7
7
|
/** @internal Called from Pino live emit stream */
|
|
8
8
|
export declare function emitLogEntry(entry: LogEntry): void;
|
|
9
|
-
/** Hono handler for `GET /api/logs/stream`. */
|
|
10
|
-
export declare function createLogSSEHandler(): (c: {
|
|
11
|
-
req: {
|
|
12
|
-
raw: Request;
|
|
13
|
-
url: string;
|
|
14
|
-
};
|
|
15
|
-
}) => Promise<Response>;
|
|
@@ -4,9 +4,6 @@ function subscribeToLogs(subscriber) {
|
|
|
4
4
|
subscribers.add(subscriber);
|
|
5
5
|
return () => subscribers.delete(subscriber);
|
|
6
6
|
}
|
|
7
|
-
function getSubscriberCount() {
|
|
8
|
-
return subscribers.size;
|
|
9
|
-
}
|
|
10
7
|
function hasSubscribers() {
|
|
11
8
|
return subscribers.size > 0;
|
|
12
9
|
}
|
|
@@ -17,78 +14,10 @@ function emitLogEntry(entry) {
|
|
|
17
14
|
subscriber(entry);
|
|
18
15
|
} catch {}
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
if (!levelsParam) return [
|
|
22
|
-
"info",
|
|
23
|
-
"warn",
|
|
24
|
-
"error",
|
|
25
|
-
"fatal"
|
|
26
|
-
];
|
|
27
|
-
return levelsParam.split(",").filter((l) => VALID_LEVELS.includes(l));
|
|
28
|
-
}
|
|
29
|
-
function createLogSseResponse(req, allowedLevels, moduleFilter) {
|
|
30
|
-
const stream = new ReadableStream({ start(controller) {
|
|
31
|
-
const encoder = new TextEncoder();
|
|
32
|
-
const sendEvent = (data) => {
|
|
33
|
-
const message = `data: ${JSON.stringify(data)}\n\n`;
|
|
34
|
-
controller.enqueue(encoder.encode(message));
|
|
35
|
-
};
|
|
36
|
-
sendEvent({
|
|
37
|
-
type: "connected",
|
|
38
|
-
message: "Log stream started"
|
|
39
|
-
});
|
|
40
|
-
const unsubscribe = subscribeToLogs((entry) => {
|
|
41
|
-
if (!allowedLevels.includes(entry.level)) return;
|
|
42
|
-
if (moduleFilter && entry.module !== moduleFilter) return;
|
|
43
|
-
sendEvent(entry);
|
|
44
|
-
});
|
|
45
|
-
const heartbeat = setInterval(() => {
|
|
46
|
-
try {
|
|
47
|
-
sendEvent({
|
|
48
|
-
type: "heartbeat",
|
|
49
|
-
subscribers: getSubscriberCount()
|
|
50
|
-
});
|
|
51
|
-
} catch {
|
|
52
|
-
clearInterval(heartbeat);
|
|
53
|
-
}
|
|
54
|
-
}, 3e4);
|
|
55
|
-
req.signal.addEventListener("abort", () => {
|
|
56
|
-
unsubscribe();
|
|
57
|
-
clearInterval(heartbeat);
|
|
58
|
-
try {
|
|
59
|
-
controller.close();
|
|
60
|
-
} catch {}
|
|
61
|
-
});
|
|
62
|
-
} });
|
|
63
|
-
return new Response(stream, { headers: {
|
|
64
|
-
"Content-Type": "text/event-stream",
|
|
65
|
-
"Cache-Control": "no-cache",
|
|
66
|
-
Connection: "keep-alive",
|
|
67
|
-
"X-Accel-Buffering": "no"
|
|
68
|
-
} });
|
|
69
|
-
}
|
|
70
|
-
/** Hono handler for `GET /api/logs/stream`. */
|
|
71
|
-
function createLogSSEHandler() {
|
|
72
|
-
return async (c) => {
|
|
73
|
-
const url = new URL(c.req.url);
|
|
74
|
-
const allowedLevels = parseAllowedLevels(url.searchParams.get("levels"));
|
|
75
|
-
const moduleFilter = url.searchParams.get("module");
|
|
76
|
-
return createLogSseResponse(c.req.raw, allowedLevels, moduleFilter);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
var subscribers, VALID_LEVELS;
|
|
17
|
+
var subscribers;
|
|
80
18
|
var init_log_stream = __esmMin((() => {
|
|
81
19
|
subscribers = /* @__PURE__ */ new Set();
|
|
82
|
-
VALID_LEVELS = [
|
|
83
|
-
"trace",
|
|
84
|
-
"debug",
|
|
85
|
-
"info",
|
|
86
|
-
"warn",
|
|
87
|
-
"error",
|
|
88
|
-
"fatal",
|
|
89
|
-
"silent"
|
|
90
|
-
];
|
|
91
20
|
}));
|
|
92
21
|
//#endregion
|
|
93
22
|
init_log_stream();
|
|
94
|
-
export {
|
|
23
|
+
export { emitLogEntry, hasSubscribers, init_log_stream, subscribeToLogs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared Pino JSON record → LogEntry conversion for file query and live
|
|
2
|
+
* Shared Pino JSON record → LogEntry conversion for file query and live realtime delivery.
|
|
3
3
|
*/
|
|
4
4
|
import type { LogEntry } from './types.js';
|
|
5
5
|
/** Convert a parsed Pino JSON object into a normalized LogEntry. */
|
|
@@ -32,7 +32,7 @@ function createLogStream(filePath) {
|
|
|
32
32
|
encoding: "utf-8"
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
/** Push parsed Pino lines to live
|
|
35
|
+
/** Push parsed Pino lines to live realtime subscribers when any are connected. */
|
|
36
36
|
function createLiveEmitStream() {
|
|
37
37
|
return new Writable({ write(chunk, _encoding, callback) {
|
|
38
38
|
if (hasSubscribers()) try {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Config } from '../config/schema.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnderstandingSourceItem } from '../user-context/sources/types.js';
|
|
3
|
+
import type { WorkContextSnapshot, WorkDiscoveryCandidate, WorkDiscoveryProfileCandidate, WorkDiscoveryResult, WorkUnderstandingThreadCandidate } from './types.js';
|
|
3
4
|
export declare function analyzeWorkContext(input: {
|
|
4
5
|
config: Config;
|
|
5
6
|
snapshot: WorkContextSnapshot;
|
|
@@ -9,9 +10,9 @@ export declare function analyzeWorkContext(input: {
|
|
|
9
10
|
modelRef: string;
|
|
10
11
|
result: WorkDiscoveryResult;
|
|
11
12
|
}>;
|
|
12
|
-
export declare function
|
|
13
|
+
export declare function analyzeUnderstandingSources(input: {
|
|
13
14
|
config: Config;
|
|
14
|
-
items:
|
|
15
|
+
items: UnderstandingSourceItem[];
|
|
15
16
|
workContext?: Pick<WorkDiscoveryResult, 'projectSummary' | 'currentState' | 'uncertainties' | 'workThreads'>;
|
|
16
17
|
signal?: AbortSignal;
|
|
17
18
|
}): Promise<{
|