@xopcai/xopc 0.0.189 → 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 +0 -3
- 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-DTFKTPs8.js → activity-store-DstnJCS5.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DqO25Qe5.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-DWeXfwVU.js → api-BTL9kayv.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BRpV8PXG.js → app-management-settings-panel-DkFeIdBf.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-3ntKM9nQ.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-Df7Ycj_7.js → archive-plugin-Ch2RmLCC.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-UHgfZYtj.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-BJah99wE.js → binary-plugins-D6CqlymH.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DNlY5KqF.js → block-editor-ClL6HEg9.js} +48 -48
- package/dist/gateway/static/root/assets/browser-settings-page-DW99iDmD.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-vyUfdzAd.js → browser-workflow-inputs-BYy48VhN.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-C1cKZjx-.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-BGG2kpJB.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-BUuBEJuP.js → desktop-pet-Cv8rGhYW.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BGfVIJM3.js → desktop-pet-settings-CIeJdwfV.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DrQFfHH_.js → directory-picker-path-field-D8jXEiAY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CEnIFOX-.js → extension-debug-page-CCZ9u6TZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CCqHbexs.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-CgUE2Ii1.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-DxhKNiCF.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-DCFdc-HD.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-Bf2VLtXW.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-Ca1RuI13.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-B3Eop1zn.js → management-settings--V_fovKD.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-BGOYjgnM.js → markdown-split-Dt9-in6W.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CT0txyM4.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-DfKgAe78.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-DNrbCgmC.js → page-tabs-C5ge434C.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BTqViDOR.js → preview-open-alternatives-BFa9DgSV.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-C_2L4_Iu.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-BFLfkDGG.js → schema-form-B84DckWe.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-C9a-EbTZ.js → settings-loading-skeleton-CCtlhoy7.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DI9qDH5x.js → settings-page-DQmMKf8r.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-D-LWQdI5.js → settings-page-layout-EQIOJa_L.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CJwmPvgs.js → setup-status-panel-Cwi-SPja.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BKSMG9r5.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-zsz2HIlZ.js → skills-page.utils-Jhm24i4h.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-IWNDBI1O.js → system-settings-panel-Dpx2ags2.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-CgtK02kP.js → task-detail-page-DLAdxI6e.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BkJe7UDo.js → theme-store-DnBOcGXi.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-C07LGthO.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-Boue1D46.js → voice-api-key-field-BISTPfq_.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-bbmvCmc8.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-DlHv-GZC.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 +7 -7
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tool-activity.js +0 -36
- package/dist/packages/realtime-client/src/index.js +105 -48
- package/dist/packages/realtime-protocol/src/index.js +6 -1
- package/dist/src/agent/agent-manager.d.ts +0 -1
- package/dist/src/agent/agent-manager.js +6 -13
- package/dist/src/agent/background-review/coordinator.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +5 -7
- 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/context/workspace-templates/SOUL.md +1 -1
- 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/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/direct-turn-helpers.js +1 -1
- package/dist/src/agent/service.d.ts +1 -2
- package/dist/src/agent/service.js +4 -17
- package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js +1 -1
- 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 +0 -3
- package/dist/src/agent/tools/factory.js +1 -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/validation.d.ts +28 -28
- package/dist/src/automations/draft/automation-draft-validator.d.ts +3 -3
- package/dist/src/chat-commands/builtins/understanding.js +2 -5
- package/dist/src/cli/commands/doctor/checks/database-schema.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/schema.d.ts +24 -117
- package/dist/src/config/schema.js +9 -39
- package/dist/src/connectors/learning-coordinator.js +75 -3
- 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/dreaming-automation-reconciler.d.ts +3 -3
- package/dist/src/gateway/dreaming-automation-reconciler.js +48 -88
- package/dist/src/gateway/hono/lib/config-payload.d.ts +19 -7
- package/dist/src/gateway/hono/lib/config-payload.js +3 -1
- 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/agents.js +1 -33
- 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/index.js +2 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -5
- 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/you.d.ts +0 -22
- package/dist/src/gateway/hono/routes/you.js +234 -1118
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +2 -4
- 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/proactive/execution/context.js +8 -13
- package/dist/src/realtime/broker.d.ts +1 -0
- package/dist/src/realtime/broker.js +19 -2
- package/dist/src/realtime/runtime.js +6 -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/fts.d.ts +2 -0
- package/dist/src/storage/sqlite/fts.js +29 -1
- package/dist/src/storage/sqlite/index.d.ts +4 -6
- package/dist/src/storage/sqlite/index.js +5 -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/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/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/tui/tool-summary.js +1 -7
- package/dist/src/tui/tui-startup-resources.js +1 -2
- 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 -54
- 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/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 +3 -8
- package/dist/gateway/static/root/assets/agents-BvdqdER9.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-nKLsfy6C.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Dh5bdZiN.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CRJ_nAuh.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DeQR5BZt.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-api-D7tkhDMv.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-D7uK3q1p.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-Bw6Dniyq.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-BrUTz4uU.js +0 -1
- package/dist/gateway/static/root/assets/connector-logo-8YU53RUT.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-k9tMiOL5.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-B3B1eqnr.js +0 -2
- package/dist/gateway/static/root/assets/extension-settings-page-DEZw_7zN.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Dg8qCiIp.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-27tRzDEo.js +0 -1
- package/dist/gateway/static/root/assets/home-page-VA511kMr.js +0 -3
- package/dist/gateway/static/root/assets/index-BvR-i-m6.js +0 -216
- package/dist/gateway/static/root/assets/index-zybP34zk.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CaJq4-wV.js +0 -2
- package/dist/gateway/static/root/assets/locale-store-DUW5YE3R.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-BLTCg69e.js +0 -2
- package/dist/gateway/static/root/assets/messages-CMjnbdbn.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-Bp1w9UM1.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CZmbPDQN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D5pzqfm5.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CC-XhVGI.js +0 -1
- package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-B2eTLVDV.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CRuZ_bl0.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-C4GXGeA4.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-YzSDS4G_.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CwOo8zZk.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-xd1cgSGN.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-CstQ___Y.js +0 -1
- package/dist/gateway/static/root/assets/use-save-bar-registration-CQYE0l6z.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BnQAWS_B.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CAszL1y8.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DxGzo3-x.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/gateway/hono/routes/memory.d.ts +0 -3
- package/dist/src/gateway/hono/routes/memory.js +0 -460
- 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/user-context/actionableInsights.d.ts +0 -14
- package/dist/src/user-context/actionableInsights.js +0 -34
- 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,280 +0,0 @@
|
|
|
1
|
-
import { resolveStateDir } from "../../config/paths-state.js";
|
|
2
|
-
import { createLogger } from "../../utils/logger/index.js";
|
|
3
|
-
import { init_logger } from "../../utils/logger.js";
|
|
4
|
-
import { init_paths } from "../../config/paths.js";
|
|
5
|
-
import { XopcStdioClientTransport } from "../mcp/mcp-stdio-transport.js";
|
|
6
|
-
import { ensureCodebaseMemoryBinary } from "./binary.js";
|
|
7
|
-
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
|
-
import { mkdirSync } from "node:fs";
|
|
9
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
10
|
-
//#region src/agent/code-intelligence/runtime.ts
|
|
11
|
-
init_paths();
|
|
12
|
-
init_logger();
|
|
13
|
-
const log = createLogger("CodeIntelligence");
|
|
14
|
-
function deriveProjectName(workspace) {
|
|
15
|
-
return workspace.replace(/^[\\/]+/, "").replace(/[\\/:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
16
|
-
}
|
|
17
|
-
function timeout(promise, timeoutMs, operation) {
|
|
18
|
-
return new Promise((resolvePromise, reject) => {
|
|
19
|
-
const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`${operation} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
20
|
-
promise.then((value) => {
|
|
21
|
-
clearTimeout(timer);
|
|
22
|
-
resolvePromise(value);
|
|
23
|
-
}, (error) => {
|
|
24
|
-
clearTimeout(timer);
|
|
25
|
-
reject(error);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function resultText(result) {
|
|
30
|
-
const parts = [];
|
|
31
|
-
for (const item of result.content ?? []) if (item.type === "text" && typeof item.text === "string") parts.push(item.text);
|
|
32
|
-
return parts.join("\n").trim();
|
|
33
|
-
}
|
|
34
|
-
function parseJsonRecord(text) {
|
|
35
|
-
try {
|
|
36
|
-
const parsed = JSON.parse(text);
|
|
37
|
-
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
|
|
38
|
-
} catch {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function abortError() {
|
|
43
|
-
return new DOMException("Code intelligence operation aborted", "AbortError");
|
|
44
|
-
}
|
|
45
|
-
var CodeIntelligenceRuntime = class {
|
|
46
|
-
workspace;
|
|
47
|
-
project;
|
|
48
|
-
getConfig;
|
|
49
|
-
state = "idle";
|
|
50
|
-
coverage = "unknown";
|
|
51
|
-
indexedAt;
|
|
52
|
-
errorMessage;
|
|
53
|
-
dirtyPaths = /* @__PURE__ */ new Set();
|
|
54
|
-
dirtyVersion = 0;
|
|
55
|
-
refreshTimer;
|
|
56
|
-
connectionPromise;
|
|
57
|
-
indexPromise;
|
|
58
|
-
client;
|
|
59
|
-
transport;
|
|
60
|
-
availableTools = /* @__PURE__ */ new Set();
|
|
61
|
-
disposed = false;
|
|
62
|
-
constructor(options) {
|
|
63
|
-
this.workspace = resolve(options.workspace);
|
|
64
|
-
this.project = deriveProjectName(this.workspace);
|
|
65
|
-
this.getConfig = options.getConfig;
|
|
66
|
-
}
|
|
67
|
-
getStatus() {
|
|
68
|
-
return {
|
|
69
|
-
state: this.state,
|
|
70
|
-
workspace: this.workspace,
|
|
71
|
-
project: this.project,
|
|
72
|
-
indexedAt: this.indexedAt,
|
|
73
|
-
dirtyPaths: [...this.dirtyPaths].toSorted(),
|
|
74
|
-
coverage: this.coverage,
|
|
75
|
-
errorMessage: this.errorMessage
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
supportsTool(name) {
|
|
79
|
-
return this.availableTools.has(name);
|
|
80
|
-
}
|
|
81
|
-
async prime() {
|
|
82
|
-
const config = this.getConfig().codeIntelligence;
|
|
83
|
-
if (!config.enabled || !config.autoIndex || this.disposed) return;
|
|
84
|
-
if (this.indexPromise) return this.indexPromise;
|
|
85
|
-
if (this.indexedAt && this.dirtyPaths.size === 0) return;
|
|
86
|
-
await this.refreshIndex();
|
|
87
|
-
}
|
|
88
|
-
markDirty(paths) {
|
|
89
|
-
const config = this.getConfig().codeIntelligence;
|
|
90
|
-
if (!config.enabled || !config.autoRefresh || this.disposed) return;
|
|
91
|
-
let changed = false;
|
|
92
|
-
for (const input of paths) {
|
|
93
|
-
if (!input?.trim()) continue;
|
|
94
|
-
const absolute = isAbsolute(input) ? resolve(input) : resolve(this.workspace, input);
|
|
95
|
-
const rel = relative(this.workspace, absolute);
|
|
96
|
-
if (!rel || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) continue;
|
|
97
|
-
this.dirtyPaths.add(rel.split(sep).join("/"));
|
|
98
|
-
changed = true;
|
|
99
|
-
}
|
|
100
|
-
if (!changed) return;
|
|
101
|
-
this.dirtyVersion += 1;
|
|
102
|
-
if (this.state === "ready" || this.state === "degraded") this.state = "dirty";
|
|
103
|
-
if (this.refreshTimer) clearTimeout(this.refreshTimer);
|
|
104
|
-
this.refreshTimer = setTimeout(() => {
|
|
105
|
-
this.refreshTimer = void 0;
|
|
106
|
-
this.refreshIndex().catch(() => {});
|
|
107
|
-
}, config.refreshDebounceMs);
|
|
108
|
-
this.refreshTimer.unref?.();
|
|
109
|
-
}
|
|
110
|
-
async callTool(toolNames, input, signal) {
|
|
111
|
-
if (signal?.aborted) throw abortError();
|
|
112
|
-
const config = this.getConfig().codeIntelligence;
|
|
113
|
-
if (!config.enabled) throw new Error("Code intelligence is disabled");
|
|
114
|
-
if (config.autoIndex && (this.indexedAt === void 0 || this.state === "idle" || this.dirtyPaths.size > 0)) await this.refreshIndex();
|
|
115
|
-
else await this.ensureConnected();
|
|
116
|
-
if (signal?.aborted) throw abortError();
|
|
117
|
-
const names = typeof toolNames === "string" ? [toolNames] : [...toolNames];
|
|
118
|
-
const toolName = names.find((name) => this.availableTools.has(name));
|
|
119
|
-
if (!toolName) throw new Error(`CBM does not expose a supported tool: ${names.join(" or ")}`);
|
|
120
|
-
const result = await this.callRaw(toolName, input, config.queryTimeoutMs);
|
|
121
|
-
const text = resultText(result);
|
|
122
|
-
if (result.isError) throw new Error(text || `CBM ${toolName} failed`);
|
|
123
|
-
return {
|
|
124
|
-
text,
|
|
125
|
-
status: this.getStatus()
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
async ensureConnected() {
|
|
129
|
-
if (this.disposed) throw new Error("Code intelligence runtime is disposed");
|
|
130
|
-
if (this.client && this.transport) return;
|
|
131
|
-
if (this.connectionPromise) return this.connectionPromise;
|
|
132
|
-
this.connectionPromise = (async () => {
|
|
133
|
-
this.state = "connecting";
|
|
134
|
-
const config = this.getConfig().codeIntelligence;
|
|
135
|
-
const binary = await ensureCodebaseMemoryBinary(config.binaryPath);
|
|
136
|
-
const cacheDir = join(resolveStateDir(), "code-intelligence", "cbm");
|
|
137
|
-
mkdirSync(cacheDir, { recursive: true });
|
|
138
|
-
const transport = new XopcStdioClientTransport({
|
|
139
|
-
command: binary,
|
|
140
|
-
cwd: this.workspace,
|
|
141
|
-
env: {
|
|
142
|
-
CBM_ALLOWED_ROOT: this.workspace,
|
|
143
|
-
CBM_CACHE_DIR: cacheDir,
|
|
144
|
-
CBM_LOG_LEVEL: process.env.XOPC_LOG_LEVEL === "debug" ? "debug" : "warn"
|
|
145
|
-
},
|
|
146
|
-
stderr: "pipe"
|
|
147
|
-
});
|
|
148
|
-
const client = new Client({
|
|
149
|
-
name: "xopc-code-intelligence",
|
|
150
|
-
version: "1.0.0"
|
|
151
|
-
});
|
|
152
|
-
transport.stderr?.on("data", (chunk) => {
|
|
153
|
-
for (const line of String(chunk).split(/\r?\n/)) if (line.trim()) log.debug({ workspace: this.workspace }, `CBM: ${line.trim()}`);
|
|
154
|
-
});
|
|
155
|
-
try {
|
|
156
|
-
await timeout(client.connect(transport), 3e4, "CBM connection");
|
|
157
|
-
const toolNames = /* @__PURE__ */ new Set();
|
|
158
|
-
let cursor;
|
|
159
|
-
do {
|
|
160
|
-
const page = await timeout(client.listTools(cursor ? { cursor } : void 0), 2e4, "CBM tool discovery");
|
|
161
|
-
for (const tool of page.tools) toolNames.add(tool.name);
|
|
162
|
-
cursor = page.nextCursor;
|
|
163
|
-
} while (cursor);
|
|
164
|
-
this.client = client;
|
|
165
|
-
this.transport = transport;
|
|
166
|
-
this.availableTools = toolNames;
|
|
167
|
-
this.state = this.dirtyPaths.size > 0 ? "dirty" : "idle";
|
|
168
|
-
this.errorMessage = void 0;
|
|
169
|
-
log.info({
|
|
170
|
-
workspace: this.workspace,
|
|
171
|
-
project: this.project,
|
|
172
|
-
toolCount: this.availableTools.size
|
|
173
|
-
}, "Code intelligence runtime connected");
|
|
174
|
-
} catch (error) {
|
|
175
|
-
await transport.close().catch(() => {});
|
|
176
|
-
await client.close().catch(() => {});
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
})();
|
|
180
|
-
try {
|
|
181
|
-
await this.connectionPromise;
|
|
182
|
-
} catch (error) {
|
|
183
|
-
this.state = "unavailable";
|
|
184
|
-
this.errorMessage = error instanceof Error ? error.message : String(error);
|
|
185
|
-
log.warn({
|
|
186
|
-
err: error,
|
|
187
|
-
workspace: this.workspace,
|
|
188
|
-
project: this.project
|
|
189
|
-
}, `Code intelligence unavailable: ${this.errorMessage}`);
|
|
190
|
-
throw error;
|
|
191
|
-
} finally {
|
|
192
|
-
this.connectionPromise = void 0;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async refreshIndex() {
|
|
196
|
-
if (this.disposed) throw new Error("Code intelligence runtime is disposed");
|
|
197
|
-
if (this.indexPromise) return this.indexPromise;
|
|
198
|
-
const versionAtStart = this.dirtyVersion;
|
|
199
|
-
this.indexPromise = (async () => {
|
|
200
|
-
await this.ensureConnected();
|
|
201
|
-
const config = this.getConfig().codeIntelligence;
|
|
202
|
-
this.state = "indexing";
|
|
203
|
-
const result = await this.callRaw("index_repository", {
|
|
204
|
-
repo_path: this.workspace,
|
|
205
|
-
name: this.project,
|
|
206
|
-
mode: config.indexMode,
|
|
207
|
-
persistence: false
|
|
208
|
-
}, config.indexTimeoutMs);
|
|
209
|
-
const text = resultText(result);
|
|
210
|
-
const parsed = parseJsonRecord(text);
|
|
211
|
-
const resultStatus = typeof parsed?.status === "string" ? parsed.status : "indexed";
|
|
212
|
-
if (result.isError || resultStatus === "error") throw new Error(text || "CBM indexing failed");
|
|
213
|
-
this.indexedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
214
|
-
this.coverage = resultStatus === "degraded" ? "partial" : "unknown";
|
|
215
|
-
this.errorMessage = void 0;
|
|
216
|
-
if (versionAtStart === this.dirtyVersion) {
|
|
217
|
-
this.dirtyPaths.clear();
|
|
218
|
-
this.state = resultStatus === "degraded" ? "degraded" : "ready";
|
|
219
|
-
} else this.state = "dirty";
|
|
220
|
-
log.info({
|
|
221
|
-
workspace: this.workspace,
|
|
222
|
-
project: this.project,
|
|
223
|
-
indexMode: config.indexMode,
|
|
224
|
-
status: resultStatus,
|
|
225
|
-
dirtyPaths: this.dirtyPaths.size
|
|
226
|
-
}, "Code intelligence index refreshed");
|
|
227
|
-
})();
|
|
228
|
-
try {
|
|
229
|
-
await this.indexPromise;
|
|
230
|
-
} catch (error) {
|
|
231
|
-
this.state = "degraded";
|
|
232
|
-
this.coverage = "unknown";
|
|
233
|
-
this.errorMessage = error instanceof Error ? error.message : String(error);
|
|
234
|
-
log.warn({
|
|
235
|
-
err: error,
|
|
236
|
-
workspace: this.workspace,
|
|
237
|
-
project: this.project
|
|
238
|
-
}, `Code intelligence indexing failed: ${this.errorMessage}`);
|
|
239
|
-
throw error;
|
|
240
|
-
} finally {
|
|
241
|
-
this.indexPromise = void 0;
|
|
242
|
-
if (!this.disposed && this.dirtyPaths.size > 0 && versionAtStart !== this.dirtyVersion) queueMicrotask(() => void this.refreshIndex().catch(() => {}));
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async callRaw(toolName, input, timeoutMs) {
|
|
246
|
-
await this.ensureConnected();
|
|
247
|
-
if (!this.client) throw new Error("CBM client is not connected");
|
|
248
|
-
if (!this.availableTools.has(toolName)) throw new Error(`CBM tool is unavailable: ${toolName}`);
|
|
249
|
-
try {
|
|
250
|
-
return await timeout(this.client.callTool({
|
|
251
|
-
name: toolName,
|
|
252
|
-
arguments: input
|
|
253
|
-
}), timeoutMs, `CBM ${toolName}`);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
this.state = "unavailable";
|
|
256
|
-
this.errorMessage = error instanceof Error ? error.message : String(error);
|
|
257
|
-
await this.resetConnection();
|
|
258
|
-
throw error;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
async resetConnection() {
|
|
262
|
-
const transport = this.transport;
|
|
263
|
-
const client = this.client;
|
|
264
|
-
this.transport = void 0;
|
|
265
|
-
this.client = void 0;
|
|
266
|
-
this.availableTools.clear();
|
|
267
|
-
await client?.close().catch(() => {});
|
|
268
|
-
await transport?.close().catch(() => {});
|
|
269
|
-
}
|
|
270
|
-
async dispose() {
|
|
271
|
-
if (this.disposed) return;
|
|
272
|
-
this.disposed = true;
|
|
273
|
-
this.state = "disposed";
|
|
274
|
-
if (this.refreshTimer) clearTimeout(this.refreshTimer);
|
|
275
|
-
this.refreshTimer = void 0;
|
|
276
|
-
await this.resetConnection();
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
//#endregion
|
|
280
|
-
export { CodeIntelligenceRuntime };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/agent/code-intelligence/tool-gating.ts
|
|
2
|
-
function isCodeIntelligenceEnabledForAgent(config, agentId) {
|
|
3
|
-
return config?.enabled === true && agentId !== void 0 && config.agentIds?.includes(agentId) === true;
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { isCodeIntelligenceEnabledForAgent };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from '@earendil-works/pi-agent-core';
|
|
2
|
-
import type { CodeIntelligenceRuntimeLike } from './types.js';
|
|
3
|
-
export interface CodeIntelligenceToolDeps {
|
|
4
|
-
getRuntime: () => CodeIntelligenceRuntimeLike;
|
|
5
|
-
}
|
|
6
|
-
export declare function createCodeIntelligenceTools(deps: CodeIntelligenceToolDeps): AgentTool[];
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { promisify } from "node:util";
|
|
4
|
-
//#region src/agent/code-intelligence/tools.ts
|
|
5
|
-
const execFileAsync = promisify(execFile);
|
|
6
|
-
function statusHeader(status) {
|
|
7
|
-
const fields = [
|
|
8
|
-
`project=${status.project}`,
|
|
9
|
-
`freshness=${status.state}`,
|
|
10
|
-
`coverage=${status.coverage}`
|
|
11
|
-
];
|
|
12
|
-
if (status.indexedAt) fields.push(`indexedAt=${status.indexedAt}`);
|
|
13
|
-
if (status.dirtyPaths.length > 0) fields.push(`dirtyPaths=${status.dirtyPaths.length}`);
|
|
14
|
-
return `[Code intelligence: ${fields.join(", ")}]`;
|
|
15
|
-
}
|
|
16
|
-
function success(result) {
|
|
17
|
-
return {
|
|
18
|
-
content: [{
|
|
19
|
-
type: "text",
|
|
20
|
-
text: `${statusHeader(result.status)}\n${result.text}`.trim()
|
|
21
|
-
}],
|
|
22
|
-
details: { codeIntelligence: result.status }
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function failure(error, runtime) {
|
|
26
|
-
const status = runtime.getStatus();
|
|
27
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
28
|
-
return {
|
|
29
|
-
content: [{
|
|
30
|
-
type: "text",
|
|
31
|
-
text: `${statusHeader(status)}\nCode intelligence failed: ${message}\nUse grep/find/read_file for direct source inspection and do not infer absence from the graph.`
|
|
32
|
-
}],
|
|
33
|
-
details: { codeIntelligence: status }
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function searchWasEmpty(text) {
|
|
37
|
-
try {
|
|
38
|
-
return JSON.parse(text).total === 0;
|
|
39
|
-
} catch {
|
|
40
|
-
return /(?:^|\n)total:\s*0(?:\n|$)/.test(text);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function escapeCypherString(value) {
|
|
44
|
-
return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
45
|
-
}
|
|
46
|
-
function normalizeDetectChangesResult(result, limit) {
|
|
47
|
-
try {
|
|
48
|
-
const parsed = JSON.parse(result.text);
|
|
49
|
-
if (!Array.isArray(parsed.changed_files)) return result;
|
|
50
|
-
const changedFiles = [...new Set(parsed.changed_files.filter((file) => typeof file === "string"))];
|
|
51
|
-
const impactedSymbols = Array.isArray(parsed.impacted_symbols) ? parsed.impacted_symbols : [];
|
|
52
|
-
const impactedSymbolCount = impactedSymbols.length;
|
|
53
|
-
return {
|
|
54
|
-
...result,
|
|
55
|
-
text: JSON.stringify({
|
|
56
|
-
...parsed,
|
|
57
|
-
changed_files: changedFiles,
|
|
58
|
-
changed_count: changedFiles.length,
|
|
59
|
-
impacted_symbols: impactedSymbols.slice(0, limit),
|
|
60
|
-
impacted_symbol_count: impactedSymbolCount,
|
|
61
|
-
impacted_symbols_truncated: impactedSymbolCount > limit
|
|
62
|
-
})
|
|
63
|
-
};
|
|
64
|
-
} catch {
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async function changedFilesForImpact(params) {
|
|
69
|
-
const args = ["diff", "--name-only"];
|
|
70
|
-
if (params.baseBranch) args.push(`${params.baseBranch}...HEAD`);
|
|
71
|
-
else args.push(params.since ?? "HEAD");
|
|
72
|
-
args.push("--");
|
|
73
|
-
if (params.scope) args.push(params.scope);
|
|
74
|
-
const untrackedArgs = [
|
|
75
|
-
"ls-files",
|
|
76
|
-
"--others",
|
|
77
|
-
"--exclude-standard",
|
|
78
|
-
"--"
|
|
79
|
-
];
|
|
80
|
-
if (params.scope) untrackedArgs.push(params.scope);
|
|
81
|
-
const [diff, untracked] = await Promise.all([execFileAsync("git", args, {
|
|
82
|
-
cwd: params.workspace,
|
|
83
|
-
timeout: 2e4,
|
|
84
|
-
maxBuffer: 1024 * 1024
|
|
85
|
-
}), execFileAsync("git", untrackedArgs, {
|
|
86
|
-
cwd: params.workspace,
|
|
87
|
-
timeout: 2e4,
|
|
88
|
-
maxBuffer: 1024 * 1024
|
|
89
|
-
})]);
|
|
90
|
-
return [...new Set(`${diff.stdout}\n${untracked.stdout}`.split(/\r?\n/).map((line) => line.trim()).filter(Boolean))].slice(0, 100);
|
|
91
|
-
}
|
|
92
|
-
async function queryImpactCompatibility(runtime, params, signal) {
|
|
93
|
-
const status = runtime.getStatus();
|
|
94
|
-
const files = await changedFilesForImpact({
|
|
95
|
-
workspace: status.workspace,
|
|
96
|
-
since: params.since,
|
|
97
|
-
baseBranch: params.baseBranch,
|
|
98
|
-
scope: params.scope
|
|
99
|
-
});
|
|
100
|
-
if (files.length === 0) return {
|
|
101
|
-
text: "No changed files found for the requested Git comparison.",
|
|
102
|
-
status
|
|
103
|
-
};
|
|
104
|
-
const predicate = files.map((file) => `changed.file_path = '${escapeCypherString(file)}'`).join(" OR ");
|
|
105
|
-
const depth = Math.max(1, Math.min(5, Math.floor(params.depth ?? 3)));
|
|
106
|
-
const limit = Math.max(1, Math.min(500, Math.floor(params.limit ?? 100)));
|
|
107
|
-
const query = [
|
|
108
|
-
"MATCH (changed)",
|
|
109
|
-
`WHERE ${predicate}`,
|
|
110
|
-
`OPTIONAL MATCH (caller)-[:CALLS*1..${depth}]->(changed)`,
|
|
111
|
-
"RETURN DISTINCT changed.qualified_name AS changed_symbol, changed.file_path AS changed_file,",
|
|
112
|
-
"caller.qualified_name AS affected_caller, caller.file_path AS affected_file",
|
|
113
|
-
`LIMIT ${limit}`
|
|
114
|
-
].join(" ");
|
|
115
|
-
const result = await runtime.callTool("query_graph", {
|
|
116
|
-
project: status.project,
|
|
117
|
-
query,
|
|
118
|
-
max_rows: limit
|
|
119
|
-
}, signal);
|
|
120
|
-
return {
|
|
121
|
-
...result,
|
|
122
|
-
text: `Changed files (${files.length}):\n${files.join("\n")}\n\nGraph impact:\n${result.text}`
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function buildTool(options) {
|
|
126
|
-
return {
|
|
127
|
-
name: options.name,
|
|
128
|
-
label: options.name,
|
|
129
|
-
description: options.description,
|
|
130
|
-
parameters: options.parameters,
|
|
131
|
-
supportsParallel: true,
|
|
132
|
-
idempotent: true,
|
|
133
|
-
async execute(_toolCallId, params, signal) {
|
|
134
|
-
const runtime = options.deps.getRuntime();
|
|
135
|
-
try {
|
|
136
|
-
return success(await options.run(runtime, params, signal));
|
|
137
|
-
} catch (error) {
|
|
138
|
-
return failure(error, runtime);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
const SearchSchema = Type.Object({
|
|
144
|
-
query: Type.String({ description: "Natural-language intent or symbol keywords" }),
|
|
145
|
-
label: Type.Optional(Type.String({ description: "Optional graph label such as Function, Method, Class, Interface, or Route" })),
|
|
146
|
-
filePattern: Type.Optional(Type.String({ description: "Optional file/path pattern to narrow the search" })),
|
|
147
|
-
semanticKeywords: Type.Optional(Type.Array(Type.String(), { description: "Optional semantic concepts; use 2-4 concise terms" })),
|
|
148
|
-
limit: Type.Optional(Type.Number({ description: "Maximum results, default 20" }))
|
|
149
|
-
});
|
|
150
|
-
const ReadSymbolSchema = Type.Object({
|
|
151
|
-
qualifiedName: Type.String({ description: "Exact qualified_name returned by code_search" }),
|
|
152
|
-
includeNeighbors: Type.Optional(Type.Boolean({ description: "Include nearby source context" }))
|
|
153
|
-
});
|
|
154
|
-
const TraceSchema = Type.Object({
|
|
155
|
-
functionName: Type.String({ description: "Exact or unambiguous function/method name" }),
|
|
156
|
-
direction: Type.Optional(Type.Union([
|
|
157
|
-
Type.Literal("inbound"),
|
|
158
|
-
Type.Literal("outbound"),
|
|
159
|
-
Type.Literal("both")
|
|
160
|
-
])),
|
|
161
|
-
depth: Type.Optional(Type.Number({ description: "Traversal depth, default 3" })),
|
|
162
|
-
mode: Type.Optional(Type.Union([
|
|
163
|
-
Type.Literal("calls"),
|
|
164
|
-
Type.Literal("data_flow"),
|
|
165
|
-
Type.Literal("cross_service")
|
|
166
|
-
])),
|
|
167
|
-
parameterName: Type.Optional(Type.String({ description: "Parameter to follow in data_flow mode" })),
|
|
168
|
-
includeTests: Type.Optional(Type.Boolean()),
|
|
169
|
-
riskLabels: Type.Optional(Type.Boolean())
|
|
170
|
-
});
|
|
171
|
-
const ImpactSchema = Type.Object({
|
|
172
|
-
since: Type.Optional(Type.String({ description: "Git ref or date, for example HEAD~1 or a tag" })),
|
|
173
|
-
baseBranch: Type.Optional(Type.String({ description: "Base branch for comparison" })),
|
|
174
|
-
scope: Type.Optional(Type.String({ description: "Optional file or directory scope" })),
|
|
175
|
-
depth: Type.Optional(Type.Number({ description: "Impact traversal depth, default 3" })),
|
|
176
|
-
limit: Type.Optional(Type.Number({ description: "Maximum impacted symbols, default 100, maximum 500" }))
|
|
177
|
-
});
|
|
178
|
-
const ArchitectureSchema = Type.Object({ aspects: Type.Optional(Type.Array(Type.String(), { description: "Optional aspects such as packages, boundaries, layers, entry_points, hotspots, or clusters" })) });
|
|
179
|
-
function createCodeIntelligenceTools(deps) {
|
|
180
|
-
return [
|
|
181
|
-
buildTool({
|
|
182
|
-
name: "code_search",
|
|
183
|
-
description: "Search the repository knowledge graph for definitions, implementations, routes, types, and structurally important symbols. Prefer this over grep for code discovery.",
|
|
184
|
-
parameters: SearchSchema,
|
|
185
|
-
deps,
|
|
186
|
-
run: async (runtime, params, signal) => {
|
|
187
|
-
const graphResult = await runtime.callTool("search_graph", {
|
|
188
|
-
project: runtime.getStatus().project,
|
|
189
|
-
query: params.query,
|
|
190
|
-
...params.label ? { label: params.label } : {},
|
|
191
|
-
...params.filePattern ? { file_pattern: params.filePattern } : {},
|
|
192
|
-
...params.semanticKeywords?.length ? { semantic_query: params.semanticKeywords } : {},
|
|
193
|
-
limit: params.limit ?? 20
|
|
194
|
-
}, signal);
|
|
195
|
-
if (!searchWasEmpty(graphResult.text)) return graphResult;
|
|
196
|
-
const textResult = await runtime.callTool("search_code", {
|
|
197
|
-
project: runtime.getStatus().project,
|
|
198
|
-
pattern: params.query,
|
|
199
|
-
...params.filePattern ? { path_filter: params.filePattern } : {},
|
|
200
|
-
mode: "compact",
|
|
201
|
-
limit: params.limit ?? 20
|
|
202
|
-
}, signal);
|
|
203
|
-
return {
|
|
204
|
-
...textResult,
|
|
205
|
-
text: `No graph symbol matched; graph-augmented text fallback:\n${textResult.text}`
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}),
|
|
209
|
-
buildTool({
|
|
210
|
-
name: "code_read_symbol",
|
|
211
|
-
description: "Read the exact source for a symbol returned by code_search. Use this to ground graph results in current source before editing.",
|
|
212
|
-
parameters: ReadSymbolSchema,
|
|
213
|
-
deps,
|
|
214
|
-
run: (runtime, params, signal) => runtime.callTool("get_code_snippet", {
|
|
215
|
-
project: runtime.getStatus().project,
|
|
216
|
-
qualified_name: params.qualifiedName,
|
|
217
|
-
include_neighbors: params.includeNeighbors ?? false
|
|
218
|
-
}, signal)
|
|
219
|
-
}),
|
|
220
|
-
buildTool({
|
|
221
|
-
name: "code_trace",
|
|
222
|
-
description: "Trace callers, callees, data flow, or cross-service paths for a function or method.",
|
|
223
|
-
parameters: TraceSchema,
|
|
224
|
-
deps,
|
|
225
|
-
run: (runtime, params, signal) => runtime.callTool(["trace_path", "trace_call_path"], {
|
|
226
|
-
project: runtime.getStatus().project,
|
|
227
|
-
function_name: params.functionName,
|
|
228
|
-
direction: params.direction ?? "both",
|
|
229
|
-
depth: params.depth ?? 3,
|
|
230
|
-
mode: params.mode ?? "calls",
|
|
231
|
-
...params.parameterName ? { parameter_name: params.parameterName } : {},
|
|
232
|
-
include_tests: params.includeTests ?? false,
|
|
233
|
-
risk_labels: params.riskLabels ?? false
|
|
234
|
-
}, signal)
|
|
235
|
-
}),
|
|
236
|
-
buildTool({
|
|
237
|
-
name: "code_impact",
|
|
238
|
-
description: "Map the current git diff or a git range to changed symbols, callers, and blast radius before or after edits.",
|
|
239
|
-
parameters: ImpactSchema,
|
|
240
|
-
deps,
|
|
241
|
-
run: async (runtime, params, signal) => {
|
|
242
|
-
const limit = Math.max(1, Math.min(500, Math.floor(params.limit ?? 100)));
|
|
243
|
-
if (runtime.supportsTool("detect_changes")) return normalizeDetectChangesResult(await runtime.callTool("detect_changes", {
|
|
244
|
-
project: runtime.getStatus().project,
|
|
245
|
-
...params.since || !params.baseBranch ? { since: params.since ?? "HEAD" } : {},
|
|
246
|
-
...params.baseBranch ? { base_branch: params.baseBranch } : {},
|
|
247
|
-
...params.scope ? { scope: params.scope } : {},
|
|
248
|
-
depth: params.depth ?? 3
|
|
249
|
-
}, signal), limit);
|
|
250
|
-
return queryImpactCompatibility(runtime, params, signal);
|
|
251
|
-
}
|
|
252
|
-
}),
|
|
253
|
-
buildTool({
|
|
254
|
-
name: "code_architecture",
|
|
255
|
-
description: "Get a compact repository architecture map including packages, boundaries, layers, entry points, hotspots, and graph-derived clusters.",
|
|
256
|
-
parameters: ArchitectureSchema,
|
|
257
|
-
deps,
|
|
258
|
-
run: (runtime, params, signal) => runtime.callTool("get_architecture", {
|
|
259
|
-
project: runtime.getStatus().project,
|
|
260
|
-
...params.aspects?.length ? { aspects: params.aspects } : {}
|
|
261
|
-
}, signal)
|
|
262
|
-
})
|
|
263
|
-
];
|
|
264
|
-
}
|
|
265
|
-
//#endregion
|
|
266
|
-
export { createCodeIntelligenceTools };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type CodeIntelligenceState = 'idle' | 'connecting' | 'indexing' | 'ready' | 'dirty' | 'degraded' | 'unavailable' | 'disposed';
|
|
2
|
-
export interface CodeIntelligenceStatus {
|
|
3
|
-
state: CodeIntelligenceState;
|
|
4
|
-
workspace: string;
|
|
5
|
-
project: string;
|
|
6
|
-
indexedAt?: string;
|
|
7
|
-
dirtyPaths: string[];
|
|
8
|
-
coverage: 'complete' | 'partial' | 'unknown';
|
|
9
|
-
errorMessage?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface CodeIntelligenceToolResult {
|
|
12
|
-
text: string;
|
|
13
|
-
status: CodeIntelligenceStatus;
|
|
14
|
-
}
|
|
15
|
-
export interface CodeIntelligenceRuntimeLike {
|
|
16
|
-
prime(): Promise<void>;
|
|
17
|
-
markDirty(paths: readonly string[]): void;
|
|
18
|
-
supportsTool(name: string): boolean;
|
|
19
|
-
callTool(toolNames: string | readonly string[], input: Record<string, unknown>, signal?: AbortSignal): Promise<CodeIntelligenceToolResult>;
|
|
20
|
-
getStatus(): CodeIntelligenceStatus;
|
|
21
|
-
dispose(): Promise<void>;
|
|
22
|
-
}
|