kontexta 5.2.0 → 6.1.0
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/bundle/standalone/CHANGELOG.md +52 -0
- package/bundle/standalone/apps/web/.next/BUILD_ID +1 -1
- package/bundle/standalone/apps/web/.next/app-build-manifest.json +42 -42
- package/bundle/standalone/apps/web/.next/app-path-routes-manifest.json +10 -10
- package/bundle/standalone/apps/web/.next/build-manifest.json +2 -2
- package/bundle/standalone/apps/web/.next/prerender-manifest.json +16 -16
- package/bundle/standalone/apps/web/.next/required-server-files.json +1 -0
- package/bundle/standalone/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found.html +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found.rsc +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/about/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/about/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/clip/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/clip/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/health/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/profile/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/profile/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/refresh/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/refresh/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reindex/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reindex/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/search/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/tags/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/version-check/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/version-check/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/welcome/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/welcome/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/apple-icon.png/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/icon.png/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/page.js +4 -4
- package/bundle/standalone/apps/web/.next/server/app/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs.html +2 -2
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs.rsc +1 -1
- package/bundle/standalone/apps/web/.next/server/app-paths-manifest.json +10 -10
- package/bundle/standalone/apps/web/.next/server/pages/404.html +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/500.html +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/_app.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/_document.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/_error.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/page-86e385abedf10ccd.js +1 -0
- package/bundle/standalone/apps/web/package.json +6 -5
- package/bundle/standalone/apps/web/server.js +1 -1
- package/bundle/standalone/apps/web/src/lib/mcp-tools.json +103 -95
- package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-block.md +28 -185
- package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-reference.md +207 -0
- package/bundle/standalone/node_modules/kontexta-mcp/dist/calendar-tools.js +12 -12
- package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/formatter.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/schema-doc.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js +196 -68
- package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js.map +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-capture.js +3 -3
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-commit-upgrades-tool.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-housekeep-tool.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-tools.js +2 -2
- package/bundle/standalone/node_modules/kontexta-mcp/dist/repo-write-guard.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/package.json +4 -2
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.d.ts +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js +84 -25
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-block.md +28 -185
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-reference.md +207 -0
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.d.ts +25 -1
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.js +159 -32
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.d.ts +71 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.js +192 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.d.ts +9 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.js +10 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.d.ts +20 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.js +124 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.d.ts +20 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.js +28 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.d.ts +30 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.js +57 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.d.ts +42 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.js +7 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.d.ts +3 -1
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.js +10 -1
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/hooks/alerts.js +2 -2
- package/bundle/standalone/node_modules/kxta-core/dist/index.d.ts +4 -1
- package/bundle/standalone/node_modules/kxta-core/dist/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/index.js +4 -1
- package/bundle/standalone/node_modules/kxta-core/dist/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.d.ts +3 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.js +27 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.d.ts +41 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.js +140 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.d.ts +7 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.js +39 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.d.ts +16 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.js +17 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.d.ts +132 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.js +312 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.d.ts +55 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.js +6 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.d.ts +6 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.js +50 -7
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.d.ts +12 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.js +190 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/high-water.d.ts +2 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/high-water.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/high-water.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.d.ts +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.js +3 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.d.ts +10 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.js +22 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js +2 -2
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.js +30 -5
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.d.ts +21 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.js +90 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.d.ts +2 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.js +17 -5
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/strict-mode.js +2 -2
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.d.ts +17 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.js +77 -9
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/types.d.ts +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/types.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/tools.generated.js +58 -58
- package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.js +10 -1
- package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/project-map/index.js +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.d.ts +29 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.js +68 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.d.ts +57 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.js +199 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.d.ts +7 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.js +8 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.d.ts +50 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.js +2 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/types.d.ts +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/types.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/util/paths.js +1 -1
- package/bundle/standalone/node_modules/kxta-core/package.json +4 -2
- package/bundle/standalone/node_modules/kxta-publish/package.json +3 -3
- package/bundle/standalone/package.json +3 -2
- package/package.json +5 -3
- package/bundle/standalone/apps/web/.next/static/chunks/app/page-df34c386b7c150bb.js +0 -1
- /package/bundle/standalone/apps/web/.next/static/{yyj-uK2RH8Rffeq9wVzjU → 0ZL7PJwYf_7ZTTXE_AM0S}/_buildManifest.js +0 -0
- /package/bundle/standalone/apps/web/.next/static/{yyj-uK2RH8Rffeq9wVzjU → 0ZL7PJwYf_7ZTTXE_AM0S}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// packages/core/src/decision/engine.ts
|
|
2
|
+
/**
|
|
3
|
+
* Decision engine for classification, verdict evaluation, and scoring.
|
|
4
|
+
*
|
|
5
|
+
* Uses the inference runtime to load decision models on demand.
|
|
6
|
+
* All methods return deterministic fallback values on failure.
|
|
7
|
+
*/
|
|
8
|
+
import { inferenceRuntime } from "../inference/runtime.js";
|
|
9
|
+
/** Default timeout for decision operations (ms). */
|
|
10
|
+
const DEFAULT_DECISION_TIMEOUT_MS = 500;
|
|
11
|
+
/**
|
|
12
|
+
* Decision model configuration.
|
|
13
|
+
*/
|
|
14
|
+
const DECISION_MODEL_CONFIG = {
|
|
15
|
+
modelId: "Xenova/distilbert-base-uncased-finetuned-sst-2-english",
|
|
16
|
+
device: "auto",
|
|
17
|
+
timeoutMs: DEFAULT_DECISION_TIMEOUT_MS,
|
|
18
|
+
};
|
|
19
|
+
class DecisionEngine {
|
|
20
|
+
/**
|
|
21
|
+
* Check if a decision model is available and ready for inference.
|
|
22
|
+
*/
|
|
23
|
+
async isAvailable() {
|
|
24
|
+
try {
|
|
25
|
+
// The decision-model inference backends are not implemented yet, so we
|
|
26
|
+
// can never actually score anything. Short-circuit BEFORE touching the
|
|
27
|
+
// model session: getModelSession would otherwise attempt a (potentially
|
|
28
|
+
// remote) model download on every call, from the intent router,
|
|
29
|
+
// event triage, and topic pivot detector alike.
|
|
30
|
+
if (!this.hasInferenceImplementation())
|
|
31
|
+
return false;
|
|
32
|
+
const session = await inferenceRuntime.getModelSession(DECISION_MODEL_CONFIG);
|
|
33
|
+
return session.instance !== null;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
hasInferenceImplementation() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Cheap, I/O-free readiness check: true only when a concrete inference
|
|
44
|
+
* implementation exists. Callers use this to avoid triggering model
|
|
45
|
+
* downloads when there is nothing to run them against.
|
|
46
|
+
*/
|
|
47
|
+
isReady() {
|
|
48
|
+
return this.hasInferenceImplementation();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Lazily obtain the decision model session (loads on first use).
|
|
52
|
+
*/
|
|
53
|
+
session() {
|
|
54
|
+
return inferenceRuntime.getModelSession(DECISION_MODEL_CONFIG);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Classify context among multiple options.
|
|
58
|
+
*
|
|
59
|
+
* Constructs a prompt asking the model to choose the best option
|
|
60
|
+
* given the context, then returns the selected option with confidence
|
|
61
|
+
* and distribution.
|
|
62
|
+
*
|
|
63
|
+
* @param context - The context to classify
|
|
64
|
+
* @param options - Available options to choose from
|
|
65
|
+
* @returns ChoiceDecision with selected option, confidence, and distribution
|
|
66
|
+
*/
|
|
67
|
+
async classifyChoice(context, options) {
|
|
68
|
+
try {
|
|
69
|
+
// Check if model is loaded
|
|
70
|
+
const session = this.isReady() ? await this.session() : null;
|
|
71
|
+
// Fallback if model is not available
|
|
72
|
+
if (!session?.instance) {
|
|
73
|
+
return {
|
|
74
|
+
selected: options[0] ?? "unknown",
|
|
75
|
+
confidence: 0.5,
|
|
76
|
+
distribution: Object.fromEntries(options.map((o) => [o, 1 / options.length])),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Construct prompt for classification
|
|
80
|
+
const prompt = `Given the following context, which option best describes it?\n\nContext: ${context}\n\nOptions: ${options.join(", ")}`;
|
|
81
|
+
// Attempt inference (structure depends on loaded model)
|
|
82
|
+
const result = await this.withTimeout(this.runClassification(session.instance, prompt), DEFAULT_DECISION_TIMEOUT_MS);
|
|
83
|
+
if (result) {
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
// Model ran but returned nothing — fallback
|
|
87
|
+
return {
|
|
88
|
+
selected: options[0] ?? "unknown",
|
|
89
|
+
confidence: 0.5,
|
|
90
|
+
distribution: Object.fromEntries(options.map((o) => [o, 1 / options.length])),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Never throw — return deterministic fallback
|
|
95
|
+
return {
|
|
96
|
+
selected: options[0] ?? "unknown",
|
|
97
|
+
confidence: 0.5,
|
|
98
|
+
distribution: Object.fromEntries(options.map((o) => [o, 1 / options.length])),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Evaluate a binary verdict on whether context satisfies a question.
|
|
104
|
+
*
|
|
105
|
+
* @param context - The context to evaluate
|
|
106
|
+
* @param question - The question to answer (yes/no)
|
|
107
|
+
* @returns BinaryVerdict with verdict, confidence, and raw logit
|
|
108
|
+
*/
|
|
109
|
+
async evaluateVerdict(context, question) {
|
|
110
|
+
try {
|
|
111
|
+
const session = this.isReady() ? await this.session() : null;
|
|
112
|
+
if (!session?.instance) {
|
|
113
|
+
return { verdict: true, confidence: 0.5, logit: 0 };
|
|
114
|
+
}
|
|
115
|
+
const prompt = `Given the following context, answer the question with yes or no.\n\nContext: ${context}\n\nQuestion: ${question}`;
|
|
116
|
+
const result = await this.withTimeout(this.runVerdict(session.instance, prompt), DEFAULT_DECISION_TIMEOUT_MS);
|
|
117
|
+
if (result) {
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
return { verdict: true, confidence: 0.5, logit: 0 };
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return { verdict: true, confidence: 0.5, logit: 0 };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Rate context against criteria on a 0–4 scale.
|
|
128
|
+
*
|
|
129
|
+
* @param context - The context to rate
|
|
130
|
+
* @param criteria - The criteria to rate against
|
|
131
|
+
* @returns ScoreRating with discrete score and continuous calibrated value
|
|
132
|
+
*/
|
|
133
|
+
async rateScore(context, criteria) {
|
|
134
|
+
try {
|
|
135
|
+
const session = this.isReady() ? await this.session() : null;
|
|
136
|
+
if (!session?.instance) {
|
|
137
|
+
return { score: 2, calibrated: 2.0 };
|
|
138
|
+
}
|
|
139
|
+
const prompt = `Rate the following context on a scale of 0-4 based on these criteria.\n\nContext: ${context}\n\nCriteria: ${criteria}`;
|
|
140
|
+
const result = await this.withTimeout(this.runRating(session.instance, prompt), DEFAULT_DECISION_TIMEOUT_MS);
|
|
141
|
+
if (result) {
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
return { score: 2, calibrated: 2.0 };
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return { score: 2, calibrated: 2.0 };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Run classification inference.
|
|
152
|
+
*/
|
|
153
|
+
async runClassification(_instance, _prompt) {
|
|
154
|
+
// TODO: Implement actual model inference when a decision model is available.
|
|
155
|
+
// This placeholder returns undefined to trigger fallback.
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Run binary verdict inference.
|
|
160
|
+
*/
|
|
161
|
+
async runVerdict(_instance, _prompt) {
|
|
162
|
+
// TODO: Implement actual model inference when a decision model is available.
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Run rating inference.
|
|
167
|
+
*/
|
|
168
|
+
async runRating(_instance, _prompt) {
|
|
169
|
+
// TODO: Implement actual model inference when a decision model is available.
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Wrap a promise with a hard timeout.
|
|
174
|
+
*/
|
|
175
|
+
async withTimeout(promise, timeoutMs) {
|
|
176
|
+
let timer;
|
|
177
|
+
try {
|
|
178
|
+
return await Promise.race([
|
|
179
|
+
promise,
|
|
180
|
+
new Promise((_resolve, reject) => {
|
|
181
|
+
timer = setTimeout(() => reject(new Error("Decision timeout")), timeoutMs);
|
|
182
|
+
}),
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
clearTimeout(timer);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Export singleton instance
|
|
191
|
+
export const decisionEngine = new DecisionEngine();
|
|
192
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/decision/engine.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQ3D,oDAAoD;AACpD,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAExC;;GAEG;AACH,MAAM,qBAAqB,GAAuB;IAChD,OAAO,EAAE,wDAAwD;IACjE,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,2BAA2B;CACvC,CAAC;AAEF,MAAM,cAAc;IAClB;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,uEAAuE;YACvE,uEAAuE;YACvE,wEAAwE;YACxE,gEAAgE;YAChE,gDAAgD;YAChD,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE;gBAAE,OAAO,KAAK,CAAC;YAErD,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC;YAC9E,OAAO,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,C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OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,SAAS,CACrB,SAAkB,EAClB,OAAe;QAEf,6EAA6E;QAC7E,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,OAAmB,EACnB,SAAiB;QAEjB,IAAI,KAAgD,CAAC;QACrD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACxB,OAAO;gBACP,IAAI,OAAO,CAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;oBAC1C,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;gBAC7E,CAAC,CAAC;aACH,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export all decision modules for convenient imports.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./engine.js";
|
|
6
|
+
export * from "./intent-router.js";
|
|
7
|
+
export * from "./sufficiency.js";
|
|
8
|
+
export { pruneLowRelevanceCandidates } from "./pruning.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decision/index.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// packages/core/src/decision/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Re-export all decision modules for convenient imports.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./types.js";
|
|
6
|
+
export * from "./engine.js";
|
|
7
|
+
export * from "./intent-router.js";
|
|
8
|
+
export * from "./sufficiency.js";
|
|
9
|
+
export { pruneLowRelevanceCandidates } from "./pruning.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decision/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent router for query classification.
|
|
3
|
+
*
|
|
4
|
+
* Classifies user queries into intent categories and returns the
|
|
5
|
+
* appropriate dictionary_boost for content-class arbitration.
|
|
6
|
+
*
|
|
7
|
+
* Falls back to regex heuristics when the model is unavailable.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Route a query to its most likely intent and return the appropriate
|
|
11
|
+
* dictionary_boost for content-class arbitration.
|
|
12
|
+
*
|
|
13
|
+
* @param query - The user's search query
|
|
14
|
+
* @returns { intent, dictionary_boost }
|
|
15
|
+
*/
|
|
16
|
+
export declare function routeQueryIntent(query: string): Promise<{
|
|
17
|
+
intent: string;
|
|
18
|
+
dictionary_boost: number;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=intent-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent-router.d.ts","sourceRoot":"","sources":["../../src/decision/intent-router.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAqDH;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC,CAOvD"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// packages/core/src/decision/intent-router.ts
|
|
2
|
+
/**
|
|
3
|
+
* Intent router for query classification.
|
|
4
|
+
*
|
|
5
|
+
* Classifies user queries into intent categories and returns the
|
|
6
|
+
* appropriate dictionary_boost for content-class arbitration.
|
|
7
|
+
*
|
|
8
|
+
* Falls back to regex heuristics when the model is unavailable.
|
|
9
|
+
*/
|
|
10
|
+
import { decisionEngine } from "./engine.js";
|
|
11
|
+
/**
|
|
12
|
+
* Predefined intent categories with heuristic detection rules.
|
|
13
|
+
*
|
|
14
|
+
* - spec_authoritative (+0.15): queries about specifications, architectures,
|
|
15
|
+
* definitions — authoritative knowledge is highly relevant
|
|
16
|
+
* - troubleshooting_incident (-0.05): error reports, bug fixes — journal
|
|
17
|
+
* entries and notes may contain more actionable info than dictionary
|
|
18
|
+
* - code_symbol (+0.08): code references with camelCase, snake_case, etc.
|
|
19
|
+
* — project files and code notes are most relevant
|
|
20
|
+
* - general_exploration (+0.08): default fallback — balanced across sources
|
|
21
|
+
*/
|
|
22
|
+
const INTENT_CATEGORIES = [
|
|
23
|
+
{
|
|
24
|
+
intent: "spec_authoritative",
|
|
25
|
+
dictionary_boost: 0.15,
|
|
26
|
+
keywords: [
|
|
27
|
+
"spec", "schema", "architecture", "definition", "how it works",
|
|
28
|
+
"design document", "specification", "standard", "protocol",
|
|
29
|
+
"interface contract", "api contract",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
intent: "troubleshooting_incident",
|
|
34
|
+
dictionary_boost: -0.05,
|
|
35
|
+
keywords: [
|
|
36
|
+
"error", "bug", "fix", "issue", "timeout", "fail", "crash",
|
|
37
|
+
"exception", "stack trace", "debug", "trace", "log",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
intent: "code_symbol",
|
|
42
|
+
dictionary_boost: 0.0,
|
|
43
|
+
// camelCase, PascalCase, snake_case identifiers
|
|
44
|
+
patterns: [
|
|
45
|
+
/[a-z]+[A-Z][a-zA-Z]+/, // camelCase
|
|
46
|
+
/[A-Z][a-z]+[A-Z]/, // PascalCase
|
|
47
|
+
/[a-z]+_[a-z]+/, // snake_case
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Route a query to its most likely intent and return the appropriate
|
|
53
|
+
* dictionary_boost for content-class arbitration.
|
|
54
|
+
*
|
|
55
|
+
* @param query - The user's search query
|
|
56
|
+
* @returns { intent, dictionary_boost }
|
|
57
|
+
*/
|
|
58
|
+
export async function routeQueryIntent(query) {
|
|
59
|
+
// Try model-based classification first
|
|
60
|
+
const modelResult = await tryModelClassification(query);
|
|
61
|
+
if (modelResult)
|
|
62
|
+
return modelResult;
|
|
63
|
+
// Fall back to regex heuristics (preserves case for pattern matching)
|
|
64
|
+
return heuristicClassification(query);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Attempt to classify using the decision engine model.
|
|
68
|
+
* Returns null if model is unavailable.
|
|
69
|
+
*/
|
|
70
|
+
async function tryModelClassification(query) {
|
|
71
|
+
if (!(await decisionEngine.isAvailable())) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const intents = INTENT_CATEGORIES.map((c) => c.intent);
|
|
76
|
+
const result = await decisionEngine.classifyChoice(query, intents);
|
|
77
|
+
// Use the model's selected intent
|
|
78
|
+
const mapping = INTENT_CATEGORIES.find((c) => c.intent === result.selected);
|
|
79
|
+
if (mapping) {
|
|
80
|
+
return {
|
|
81
|
+
intent: result.selected,
|
|
82
|
+
dictionary_boost: mapping.dictionary_boost,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Model unavailable, fall through to heuristics
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Classify query using regex heuristics.
|
|
93
|
+
* Used as fallback when model is unavailable.
|
|
94
|
+
*/
|
|
95
|
+
function heuristicClassification(query) {
|
|
96
|
+
const trimmed = query.trim();
|
|
97
|
+
const lower = trimmed.toLowerCase();
|
|
98
|
+
// Check for code symbols first (most specific pattern, requires original casing)
|
|
99
|
+
for (const cat of INTENT_CATEGORIES) {
|
|
100
|
+
if (cat.patterns) {
|
|
101
|
+
for (const pattern of cat.patterns) {
|
|
102
|
+
if (pattern.test(trimmed)) {
|
|
103
|
+
return { intent: cat.intent, dictionary_boost: cat.dictionary_boost };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Check for keyword matches against lowercased query
|
|
109
|
+
for (const cat of INTENT_CATEGORIES) {
|
|
110
|
+
if (cat.keywords) {
|
|
111
|
+
for (const keyword of cat.keywords) {
|
|
112
|
+
if (lower.includes(keyword.toLowerCase())) {
|
|
113
|
+
return { intent: cat.intent, dictionary_boost: cat.dictionary_boost };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Default: general exploration
|
|
119
|
+
return {
|
|
120
|
+
intent: "general_exploration",
|
|
121
|
+
dictionary_boost: 0.08,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=intent-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent-router.js","sourceRoot":"","sources":["../../src/decision/intent-router.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAU7C;;;;;;;;;;GAUG;AACH,MA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E,CAAC;oBAC1C,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAC;gBACxE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,OAAO;QACL,MAAM,EAAE,qBAAqB;QAC7B,gBAAgB,EAAE,IAAI;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relevance pruning for candidate filtering.
|
|
3
|
+
*
|
|
4
|
+
* Removes candidates below a minimum relevance threshold
|
|
5
|
+
* before they are passed to the bundle packing stage.
|
|
6
|
+
*/
|
|
7
|
+
import type { ScoredCandidate } from "../rerank/types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Filter out low-relevance candidates below the floor threshold.
|
|
10
|
+
*
|
|
11
|
+
* This is called from bundleSearch to reduce the candidate pool
|
|
12
|
+
* before greedy token packing, preventing noise from consuming
|
|
13
|
+
* the token budget.
|
|
14
|
+
*
|
|
15
|
+
* @param candidates - Reranked and arbitrated candidates
|
|
16
|
+
* @param floorScore - Minimum final_score threshold (default: 0.15)
|
|
17
|
+
* @returns Candidates where final_score >= floorScore, sorted by final_score descending
|
|
18
|
+
*/
|
|
19
|
+
export declare function pruneLowRelevanceCandidates(candidates: ScoredCandidate[], floorScore?: number): ScoredCandidate[];
|
|
20
|
+
//# sourceMappingURL=pruning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pruning.d.ts","sourceRoot":"","sources":["../../src/decision/pruning.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAK1D;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,eAAe,EAAE,EAC7B,UAAU,CAAC,EAAE,MAAM,GAClB,eAAe,EAAE,CAOnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// packages/core/src/decision/pruning.ts
|
|
2
|
+
/**
|
|
3
|
+
* Relevance pruning for candidate filtering.
|
|
4
|
+
*
|
|
5
|
+
* Removes candidates below a minimum relevance threshold
|
|
6
|
+
* before they are passed to the bundle packing stage.
|
|
7
|
+
*/
|
|
8
|
+
/** Default minimum final_score threshold (logit < -4.0 maps to sigmoid ≈ 0.018). */
|
|
9
|
+
const DEFAULT_FLOOR_SCORE = 0.15;
|
|
10
|
+
/**
|
|
11
|
+
* Filter out low-relevance candidates below the floor threshold.
|
|
12
|
+
*
|
|
13
|
+
* This is called from bundleSearch to reduce the candidate pool
|
|
14
|
+
* before greedy token packing, preventing noise from consuming
|
|
15
|
+
* the token budget.
|
|
16
|
+
*
|
|
17
|
+
* @param candidates - Reranked and arbitrated candidates
|
|
18
|
+
* @param floorScore - Minimum final_score threshold (default: 0.15)
|
|
19
|
+
* @returns Candidates where final_score >= floorScore, sorted by final_score descending
|
|
20
|
+
*/
|
|
21
|
+
export function pruneLowRelevanceCandidates(candidates, floorScore) {
|
|
22
|
+
const threshold = floorScore ?? DEFAULT_FLOOR_SCORE;
|
|
23
|
+
// If threshold is zero or negative, keep all candidates (sorted by score descending)
|
|
24
|
+
if (threshold <= 0)
|
|
25
|
+
return [...candidates].sort((a, b) => b.final_score - a.final_score);
|
|
26
|
+
return candidates.filter((c) => c.final_score >= threshold).sort((a, b) => b.final_score - a.final_score);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=pruning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pruning.js","sourceRoot":"","sources":["../../src/decision/pruning.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC;;;;;GAKG;AAIH,oFAAoF;AACpF,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CACzC,UAA6B,EAC7B,UAAmB;IAEnB,MAAM,SAAS,GAAG,UAAU,IAAI,mBAAmB,CAAC;IAEpD,qFAAqF;IACrF,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;IAEzF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;AAC5G,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relevance sufficiency evaluation.
|
|
3
|
+
*
|
|
4
|
+
* Determines whether the retrieved candidate excerpts provide
|
|
5
|
+
* sufficient context to answer the query, helping the system
|
|
6
|
+
* decide whether to fetch more data or proceed with the current set.
|
|
7
|
+
*/
|
|
8
|
+
import type { ScoredCandidate } from "../rerank/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Evaluate whether the retrieved context adequately addresses the query.
|
|
11
|
+
*
|
|
12
|
+
* Concatenates the query with up to `MAX_EXCERPTS` top candidate excerpts
|
|
13
|
+
* and queries the decision engine to determine if the context is sufficient.
|
|
14
|
+
*
|
|
15
|
+
* @param query - The user's query
|
|
16
|
+
* @param candidateExcerpts - Array of candidate excerpts (already scored/ranked)
|
|
17
|
+
* @returns { satisfied, confidence } indicating whether context is adequate
|
|
18
|
+
*/
|
|
19
|
+
export declare function evaluateSufficiency(query: string, candidateExcerpts: string[]): Promise<{
|
|
20
|
+
satisfied: boolean;
|
|
21
|
+
confidence: number;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Convenience overload: accepts ScoredCandidate[] and extracts excerpts automatically.
|
|
25
|
+
*/
|
|
26
|
+
export declare function evaluateCandidatesSufficiency(query: string, candidates: ScoredCandidate[]): Promise<{
|
|
27
|
+
satisfied: boolean;
|
|
28
|
+
confidence: number;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=sufficiency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sufficiency.d.ts","sourceRoot":"","sources":["../../src/decision/sufficiency.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAK1D;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAuBrD;AAED;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,eAAe,EAAE,GAC5B,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAWrD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// packages/core/src/decision/sufficiency.ts
|
|
2
|
+
/**
|
|
3
|
+
* Relevance sufficiency evaluation.
|
|
4
|
+
*
|
|
5
|
+
* Determines whether the retrieved candidate excerpts provide
|
|
6
|
+
* sufficient context to answer the query, helping the system
|
|
7
|
+
* decide whether to fetch more data or proceed with the current set.
|
|
8
|
+
*/
|
|
9
|
+
import { decisionEngine } from "./engine.js";
|
|
10
|
+
/** Maximum number of excerpts to include in the sufficiency check. */
|
|
11
|
+
const MAX_EXCERPTS = 3;
|
|
12
|
+
/**
|
|
13
|
+
* Evaluate whether the retrieved context adequately addresses the query.
|
|
14
|
+
*
|
|
15
|
+
* Concatenates the query with up to `MAX_EXCERPTS` top candidate excerpts
|
|
16
|
+
* and queries the decision engine to determine if the context is sufficient.
|
|
17
|
+
*
|
|
18
|
+
* @param query - The user's query
|
|
19
|
+
* @param candidateExcerpts - Array of candidate excerpts (already scored/ranked)
|
|
20
|
+
* @returns { satisfied, confidence } indicating whether context is adequate
|
|
21
|
+
*/
|
|
22
|
+
export async function evaluateSufficiency(query, candidateExcerpts) {
|
|
23
|
+
try {
|
|
24
|
+
// Take top excerpts (up to MAX_EXCERPTS)
|
|
25
|
+
const topExcerpts = candidateExcerpts.slice(0, MAX_EXCERPTS);
|
|
26
|
+
if (topExcerpts.length === 0) {
|
|
27
|
+
return { satisfied: false, confidence: 0.9 };
|
|
28
|
+
}
|
|
29
|
+
// Concatenate query with excerpts
|
|
30
|
+
const concatenatedExcerpts = topExcerpts.join("\n\n---\n\n");
|
|
31
|
+
// Use decision engine to evaluate
|
|
32
|
+
const verdict = await decisionEngine.evaluateVerdict(concatenatedExcerpts, `Does this retrieved context adequately address the query? ${query}`);
|
|
33
|
+
return {
|
|
34
|
+
satisfied: verdict.verdict,
|
|
35
|
+
confidence: verdict.confidence,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Fallback: assume sufficient to avoid blocking the pipeline
|
|
40
|
+
return { satisfied: true, confidence: 0.5 };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convenience overload: accepts ScoredCandidate[] and extracts excerpts automatically.
|
|
45
|
+
*/
|
|
46
|
+
export async function evaluateCandidatesSufficiency(query, candidates) {
|
|
47
|
+
// Extract top candidate excerpts
|
|
48
|
+
const excerpts = candidates
|
|
49
|
+
.slice(0, MAX_EXCERPTS)
|
|
50
|
+
.map((c) => {
|
|
51
|
+
const title = c.title.trim();
|
|
52
|
+
const content = c.content.trim().slice(0, 500);
|
|
53
|
+
return title && content ? `${title}\n${content}` : title || content || " ";
|
|
54
|
+
});
|
|
55
|
+
return evaluateSufficiency(query, excerpts);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=s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E;QACT,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/C,OAAO,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,IAAI,GAAG,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEL,OAAO,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the decision engine.
|
|
3
|
+
* Supports choice classification, binary verdicts, and relevance scoring.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Result of a multi-option classification decision.
|
|
7
|
+
* `selected` is the chosen option, `confidence` is the model's confidence
|
|
8
|
+
* in the choice (0–1), and `distribution` contains normalized scores
|
|
9
|
+
* for each option to enable downstream arbitration.
|
|
10
|
+
*/
|
|
11
|
+
export interface ChoiceDecision<T extends string = string> {
|
|
12
|
+
/** The chosen option */
|
|
13
|
+
selected: T;
|
|
14
|
+
/** Confidence in the choice, 0–1 */
|
|
15
|
+
confidence: number;
|
|
16
|
+
/** Normalized scores for all options, enabling tie-breaking or exploration */
|
|
17
|
+
distribution: Record<T, number>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Result of a binary yes/no evaluation.
|
|
21
|
+
* `verdict` is the decision, `confidence` is certainty (0–1),
|
|
22
|
+
* and `logit` is the raw model output before sigmoid.
|
|
23
|
+
*/
|
|
24
|
+
export interface BinaryVerdict {
|
|
25
|
+
/** The binary decision */
|
|
26
|
+
verdict: boolean;
|
|
27
|
+
/** Confidence in the decision, 0–1 */
|
|
28
|
+
confidence: number;
|
|
29
|
+
/** Raw logit output from the model (before sigmoid) */
|
|
30
|
+
logit: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Result of a relevance / quality rating on a 0–4 scale.
|
|
34
|
+
* `score` is a discrete 0–4 rating, `calibrated` is a continuous 0.0–4.0 value.
|
|
35
|
+
*/
|
|
36
|
+
export interface ScoreRating {
|
|
37
|
+
/** Discrete rating on a 0–4 scale */
|
|
38
|
+
score: number;
|
|
39
|
+
/** Continuous calibrated score, 0.0–4.0 */
|
|
40
|
+
calibrated: number;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/decision/types.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACvD,wBAAwB;IACxB,QAAQ,EAAE,CAAC,CAAC;IACZ,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/decision/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;GAGG"}
|
|
@@ -70,7 +70,9 @@ export declare function createFolder(projectPath: string, folderName: string, op
|
|
|
70
70
|
/**
|
|
71
71
|
* Delete a folder (recursive)
|
|
72
72
|
*/
|
|
73
|
-
export declare function deleteFolder(projectPath: string, folderName: string
|
|
73
|
+
export declare function deleteFolder(projectPath: string, folderName: string, opts?: {
|
|
74
|
+
dataDir?: string;
|
|
75
|
+
}): void;
|
|
74
76
|
/**
|
|
75
77
|
* List files with optional filters
|
|
76
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAgChE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CA4CzE;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,MAAM,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IAC/B,kKAAkK;IAClK,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;GAE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,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAUzG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAYvG;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,UAAU,EAAE,CA0F9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CA0GlF"}
|
|
@@ -465,8 +465,17 @@ export function createFolder(projectPath, folderName, opts) {
|
|
|
465
465
|
/**
|
|
466
466
|
* Delete a folder (recursive)
|
|
467
467
|
*/
|
|
468
|
-
export function deleteFolder(projectPath, folderName) {
|
|
468
|
+
export function deleteFolder(projectPath, folderName, opts) {
|
|
469
469
|
const fullPath = assertPathInside(projectPath, folderName);
|
|
470
|
+
if (opts?.dataDir) {
|
|
471
|
+
const knowledgeDir = resolve(opts.dataDir, "knowledge");
|
|
472
|
+
if (resolve(projectPath) === knowledgeDir) {
|
|
473
|
+
const segments = folderName.split(/[/\\]/).filter(Boolean);
|
|
474
|
+
if (segments.length <= 1) {
|
|
475
|
+
throw new Error(`Cannot delete root knowledge folder '${folderName}'.`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
470
479
|
rmSync(fullPath, { recursive: true, force: true });
|
|
471
480
|
}
|
|
472
481
|
/**
|