@lenne.tech/nest-server 11.25.6 → 11.26.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/.claude/rules/configurable-features.md +2 -0
- package/CLAUDE.md +18 -0
- package/FRAMEWORK-API.md +48 -1
- package/dist/config.env.js +35 -1
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/helpers/config.helper.js +2 -2
- package/dist/core/common/helpers/config.helper.js.map +1 -1
- package/dist/core/common/interceptors/check-security.interceptor.js +9 -2
- package/dist/core/common/interceptors/check-security.interceptor.js.map +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +89 -0
- package/dist/core/modules/ai/core-ai-mcp.controller.d.ts +21 -0
- package/dist/core/modules/ai/core-ai-mcp.controller.js +191 -0
- package/dist/core/modules/ai/core-ai-mcp.controller.js.map +1 -0
- package/dist/core/modules/ai/core-ai.controller.d.ts +90 -0
- package/dist/core/modules/ai/core-ai.controller.js +576 -0
- package/dist/core/modules/ai/core-ai.controller.js.map +1 -0
- package/dist/core/modules/ai/core-ai.module.d.ts +43 -0
- package/dist/core/modules/ai/core-ai.module.js +164 -0
- package/dist/core/modules/ai/core-ai.module.js.map +1 -0
- package/dist/core/modules/ai/core-ai.resolver.d.ts +84 -0
- package/dist/core/modules/ai/core-ai.resolver.js +530 -0
- package/dist/core/modules/ai/core-ai.resolver.js.map +1 -0
- package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.d.ts +7 -0
- package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js +16 -0
- package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js.map +1 -0
- package/dist/core/modules/ai/hooks/ai-hook.base.d.ts +10 -0
- package/dist/core/modules/ai/hooks/ai-hook.base.js +30 -0
- package/dist/core/modules/ai/hooks/ai-hook.base.js.map +1 -0
- package/dist/core/modules/ai/hooks/ai-hook.registry.d.ts +22 -0
- package/dist/core/modules/ai/hooks/ai-hook.registry.js +98 -0
- package/dist/core/modules/ai/hooks/ai-hook.registry.js.map +1 -0
- package/dist/core/modules/ai/index.d.ts +69 -0
- package/dist/core/modules/ai/index.js +86 -0
- package/dist/core/modules/ai/index.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-budget-limit-create.input.d.ts +5 -0
- package/dist/core/modules/ai/inputs/core-ai-budget-limit-create.input.js +43 -0
- package/dist/core/modules/ai/inputs/core-ai-budget-limit-create.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-budget-limit.input.d.ts +7 -0
- package/dist/core/modules/ai/inputs/core-ai-budget-limit.input.js +74 -0
- package/dist/core/modules/ai/inputs/core-ai-budget-limit.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-connection-create.input.d.ts +6 -0
- package/dist/core/modules/ai/inputs/core-ai-connection-create.input.js +49 -0
- package/dist/core/modules/ai/inputs/core-ai-connection-create.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-connection-preference.input.d.ts +6 -0
- package/dist/core/modules/ai/inputs/core-ai-connection-preference.input.js +60 -0
- package/dist/core/modules/ai/inputs/core-ai-connection-preference.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-connection.input.d.ts +23 -0
- package/dist/core/modules/ai/inputs/core-ai-connection.input.js +229 -0
- package/dist/core/modules/ai/inputs/core-ai-connection.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-conversation-create.input.d.ts +3 -0
- package/dist/core/modules/ai/inputs/core-ai-conversation-create.input.js +21 -0
- package/dist/core/modules/ai/inputs/core-ai-conversation-create.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-conversation.input.d.ts +4 -0
- package/dist/core/modules/ai/inputs/core-ai-conversation.input.js +42 -0
- package/dist/core/modules/ai/inputs/core-ai-conversation.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-create.input.d.ts +10 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-create.input.js +74 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-create.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-hint-create.input.d.ts +5 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-hint-create.input.js +41 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-hint-create.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-hint.input.d.ts +6 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-hint.input.js +63 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-hint.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-update.input.d.ts +10 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-update.input.js +70 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt-update.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt.input.d.ts +18 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt.input.js +131 -0
- package/dist/core/modules/ai/inputs/core-ai-prompt.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-slot-create.input.d.ts +5 -0
- package/dist/core/modules/ai/inputs/core-ai-slot-create.input.js +41 -0
- package/dist/core/modules/ai/inputs/core-ai-slot-create.input.js.map +1 -0
- package/dist/core/modules/ai/inputs/core-ai-slot-update.input.d.ts +9 -0
- package/dist/core/modules/ai/inputs/core-ai-slot-update.input.js +91 -0
- package/dist/core/modules/ai/inputs/core-ai-slot-update.input.js.map +1 -0
- package/dist/core/modules/ai/interfaces/ai-hook.interface.d.ts +28 -0
- package/dist/core/modules/ai/interfaces/ai-hook.interface.js +3 -0
- package/dist/core/modules/ai/interfaces/ai-hook.interface.js.map +1 -0
- package/dist/core/modules/ai/interfaces/ai-placeholder.interface.d.ts +21 -0
- package/dist/core/modules/ai/interfaces/ai-placeholder.interface.js +3 -0
- package/dist/core/modules/ai/interfaces/ai-placeholder.interface.js.map +1 -0
- package/dist/core/modules/ai/interfaces/ai-tool.interface.d.ts +30 -0
- package/dist/core/modules/ai/interfaces/ai-tool.interface.js +3 -0
- package/dist/core/modules/ai/interfaces/ai-tool.interface.js.map +1 -0
- package/dist/core/modules/ai/interfaces/llm-provider.interface.d.ts +55 -0
- package/dist/core/modules/ai/interfaces/llm-provider.interface.js +3 -0
- package/dist/core/modules/ai/interfaces/llm-provider.interface.js.map +1 -0
- package/dist/core/modules/ai/interfaces/resolved-ai-connection.interface.d.ts +16 -0
- package/dist/core/modules/ai/interfaces/resolved-ai-connection.interface.js +3 -0
- package/dist/core/modules/ai/interfaces/resolved-ai-connection.interface.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-action.model.d.ts +6 -0
- package/dist/core/modules/ai/models/core-ai-action.model.js +44 -0
- package/dist/core/modules/ai/models/core-ai-action.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-available-connection.model.d.ts +8 -0
- package/dist/core/modules/ai/models/core-ai-available-connection.model.js +53 -0
- package/dist/core/modules/ai/models/core-ai-available-connection.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-budget-limit.model.d.ts +97 -0
- package/dist/core/modules/ai/models/core-ai-budget-limit.model.js +79 -0
- package/dist/core/modules/ai/models/core-ai-budget-limit.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-connection-preference.model.d.ts +91 -0
- package/dist/core/modules/ai/models/core-ai-connection-preference.model.js +67 -0
- package/dist/core/modules/ai/models/core-ai-connection-preference.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-connection.model.d.ts +200 -0
- package/dist/core/modules/ai/models/core-ai-connection.model.js +263 -0
- package/dist/core/modules/ai/models/core-ai-connection.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-conversation.model.d.ts +93 -0
- package/dist/core/modules/ai/models/core-ai-conversation.model.js +82 -0
- package/dist/core/modules/ai/models/core-ai-conversation.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-interaction.model.d.ts +133 -0
- package/dist/core/modules/ai/models/core-ai-interaction.model.js +137 -0
- package/dist/core/modules/ai/models/core-ai-interaction.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-message.model.d.ts +5 -0
- package/dist/core/modules/ai/models/core-ai-message.model.js +38 -0
- package/dist/core/modules/ai/models/core-ai-message.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-mode.model.d.ts +109 -0
- package/dist/core/modules/ai/models/core-ai-mode.model.js +100 -0
- package/dist/core/modules/ai/models/core-ai-mode.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-prompt-hint.model.d.ts +103 -0
- package/dist/core/modules/ai/models/core-ai-prompt-hint.model.js +89 -0
- package/dist/core/modules/ai/models/core-ai-prompt-hint.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-prompt.model.d.ts +122 -0
- package/dist/core/modules/ai/models/core-ai-prompt.model.js +117 -0
- package/dist/core/modules/ai/models/core-ai-prompt.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-response.model.d.ts +29 -0
- package/dist/core/modules/ai/models/core-ai-response.model.js +105 -0
- package/dist/core/modules/ai/models/core-ai-response.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-slot.model.d.ts +121 -0
- package/dist/core/modules/ai/models/core-ai-slot.model.js +119 -0
- package/dist/core/modules/ai/models/core-ai-slot.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-tool-grant.model.d.ts +103 -0
- package/dist/core/modules/ai/models/core-ai-tool-grant.model.js +88 -0
- package/dist/core/modules/ai/models/core-ai-tool-grant.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-tool-policy.model.d.ts +122 -0
- package/dist/core/modules/ai/models/core-ai-tool-policy.model.js +121 -0
- package/dist/core/modules/ai/models/core-ai-tool-policy.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-usage-info.model.d.ts +24 -0
- package/dist/core/modules/ai/models/core-ai-usage-info.model.js +127 -0
- package/dist/core/modules/ai/models/core-ai-usage-info.model.js.map +1 -0
- package/dist/core/modules/ai/models/core-ai-usage.model.d.ts +5 -0
- package/dist/core/modules/ai/models/core-ai-usage.model.js +38 -0
- package/dist/core/modules/ai/models/core-ai-usage.model.js.map +1 -0
- package/dist/core/modules/ai/providers/claude-cli.provider.d.ts +16 -0
- package/dist/core/modules/ai/providers/claude-cli.provider.js +151 -0
- package/dist/core/modules/ai/providers/claude-cli.provider.js.map +1 -0
- package/dist/core/modules/ai/providers/llm-provider.factory.d.ts +10 -0
- package/dist/core/modules/ai/providers/llm-provider.factory.js +45 -0
- package/dist/core/modules/ai/providers/llm-provider.factory.js.map +1 -0
- package/dist/core/modules/ai/providers/openai-compatible.provider.d.ts +32 -0
- package/dist/core/modules/ai/providers/openai-compatible.provider.js +236 -0
- package/dist/core/modules/ai/providers/openai-compatible.provider.js.map +1 -0
- package/dist/core/modules/ai/services/ai-crypto.service.d.ts +11 -0
- package/dist/core/modules/ai/services/ai-crypto.service.js +84 -0
- package/dist/core/modules/ai/services/ai-crypto.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-budget.service.d.ts +42 -0
- package/dist/core/modules/ai/services/core-ai-budget.service.js +211 -0
- package/dist/core/modules/ai/services/core-ai-budget.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-connection-preference.service.d.ts +18 -0
- package/dist/core/modules/ai/services/core-ai-connection-preference.service.js +53 -0
- package/dist/core/modules/ai/services/core-ai-connection-preference.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-connection-resolver.service.d.ts +55 -0
- package/dist/core/modules/ai/services/core-ai-connection-resolver.service.js +177 -0
- package/dist/core/modules/ai/services/core-ai-connection-resolver.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-connection.service.d.ts +43 -0
- package/dist/core/modules/ai/services/core-ai-connection.service.js +272 -0
- package/dist/core/modules/ai/services/core-ai-connection.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-conversation.service.d.ts +26 -0
- package/dist/core/modules/ai/services/core-ai-conversation.service.js +72 -0
- package/dist/core/modules/ai/services/core-ai-conversation.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-interaction.service.d.ts +13 -0
- package/dist/core/modules/ai/services/core-ai-interaction.service.js +52 -0
- package/dist/core/modules/ai/services/core-ai-interaction.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-mcp-client.service.d.ts +51 -0
- package/dist/core/modules/ai/services/core-ai-mcp-client.service.js +123 -0
- package/dist/core/modules/ai/services/core-ai-mcp-client.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.d.ts +68 -0
- package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js +279 -0
- package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-mcp.service.d.ts +22 -0
- package/dist/core/modules/ai/services/core-ai-mcp.service.js +59 -0
- package/dist/core/modules/ai/services/core-ai-mcp.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-mode.service.d.ts +14 -0
- package/dist/core/modules/ai/services/core-ai-mode.service.js +56 -0
- package/dist/core/modules/ai/services/core-ai-mode.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-placeholder.registry.d.ts +15 -0
- package/dist/core/modules/ai/services/core-ai-placeholder.registry.js +102 -0
- package/dist/core/modules/ai/services/core-ai-placeholder.registry.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-prompt-builder.service.d.ts +42 -0
- package/dist/core/modules/ai/services/core-ai-prompt-builder.service.js +136 -0
- package/dist/core/modules/ai/services/core-ai-prompt-builder.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-prompt-hint.service.d.ts +29 -0
- package/dist/core/modules/ai/services/core-ai-prompt-hint.service.js +98 -0
- package/dist/core/modules/ai/services/core-ai-prompt-hint.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-prompt.service.d.ts +21 -0
- package/dist/core/modules/ai/services/core-ai-prompt.service.js +143 -0
- package/dist/core/modules/ai/services/core-ai-prompt.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-slot.service.d.ts +51 -0
- package/dist/core/modules/ai/services/core-ai-slot.service.js +372 -0
- package/dist/core/modules/ai/services/core-ai-slot.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-tool-grant.service.d.ts +22 -0
- package/dist/core/modules/ai/services/core-ai-tool-grant.service.js +97 -0
- package/dist/core/modules/ai/services/core-ai-tool-grant.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai-tool-policy.service.d.ts +23 -0
- package/dist/core/modules/ai/services/core-ai-tool-policy.service.js +102 -0
- package/dist/core/modules/ai/services/core-ai-tool-policy.service.js.map +1 -0
- package/dist/core/modules/ai/services/core-ai.service.d.ts +144 -0
- package/dist/core/modules/ai/services/core-ai.service.js +991 -0
- package/dist/core/modules/ai/services/core-ai.service.js.map +1 -0
- package/dist/core/modules/ai/tools/ai-tool.base.d.ts +15 -0
- package/dist/core/modules/ai/tools/ai-tool.base.js +30 -0
- package/dist/core/modules/ai/tools/ai-tool.base.js.map +1 -0
- package/dist/core/modules/ai/tools/ai-tool.registry.d.ts +19 -0
- package/dist/core/modules/ai/tools/ai-tool.registry.js +71 -0
- package/dist/core/modules/ai/tools/ai-tool.registry.js.map +1 -0
- package/dist/core/modules/ai/tools/ask-user-question.tool.d.ts +38 -0
- package/dist/core/modules/ai/tools/ask-user-question.tool.js +65 -0
- package/dist/core/modules/ai/tools/ask-user-question.tool.js.map +1 -0
- package/dist/core/modules/ai/tools/search-tools.tool.d.ts +24 -0
- package/dist/core/modules/ai/tools/search-tools.tool.js +68 -0
- package/dist/core/modules/ai/tools/search-tools.tool.js.map +1 -0
- package/dist/core/modules/error-code/error-codes.d.ts +81 -0
- package/dist/core/modules/error-code/error-codes.js +72 -0
- package/dist/core/modules/error-code/error-codes.js.map +1 -1
- package/dist/core.module.js +8 -0
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/modules/ai/ai-tools.module.d.ts +5 -0
- package/dist/server/modules/ai/ai-tools.module.js +36 -0
- package/dist/server/modules/ai/ai-tools.module.js.map +1 -0
- package/dist/server/modules/ai/tools/delete-user.tool.d.ts +30 -0
- package/dist/server/modules/ai/tools/delete-user.tool.js +49 -0
- package/dist/server/modules/ai/tools/delete-user.tool.js.map +1 -0
- package/dist/server/modules/ai/tools/find-users.tool.d.ts +30 -0
- package/dist/server/modules/ai/tools/find-users.tool.js +52 -0
- package/dist/server/modules/ai/tools/find-users.tool.js.map +1 -0
- package/dist/server/modules/ai/tools/get-user.tool.d.ts +26 -0
- package/dist/server/modules/ai/tools/get-user.tool.js +48 -0
- package/dist/server/modules/ai/tools/get-user.tool.js.map +1 -0
- package/dist/server/modules/ai/tools/update-user-job-title.tool.d.ts +32 -0
- package/dist/server/modules/ai/tools/update-user-job-title.tool.js +54 -0
- package/dist/server/modules/ai/tools/update-user-job-title.tool.js.map +1 -0
- package/dist/server/modules/error-code/error-codes.d.ts +9 -0
- package/dist/server/server.module.js +2 -0
- package/dist/server/server.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/REQUEST-LIFECYCLE.md +10 -0
- package/migration-guides/11.25.x-to-11.26.0.md +278 -0
- package/package.json +2 -1
- package/src/config.env.ts +48 -1
- package/src/core/common/helpers/config.helper.ts +5 -2
- package/src/core/common/interceptors/check-security.interceptor.ts +13 -3
- package/src/core/common/interfaces/server-options.interface.ts +312 -0
- package/src/core/modules/ai/INTEGRATION-CHECKLIST.md +220 -0
- package/src/core/modules/ai/README.md +526 -0
- package/src/core/modules/ai/core-ai-mcp.controller.ts +223 -0
- package/src/core/modules/ai/core-ai.controller.ts +547 -0
- package/src/core/modules/ai/core-ai.module.ts +269 -0
- package/src/core/modules/ai/core-ai.resolver.ts +526 -0
- package/src/core/modules/ai/helpers/ai-mcp-oauth.helper.ts +35 -0
- package/src/core/modules/ai/hooks/ai-hook.base.ts +23 -0
- package/src/core/modules/ai/hooks/ai-hook.registry.ts +119 -0
- package/src/core/modules/ai/index.ts +70 -0
- package/src/core/modules/ai/inputs/core-ai-budget-limit-create.input.ts +27 -0
- package/src/core/modules/ai/inputs/core-ai-budget-limit.input.ts +52 -0
- package/src/core/modules/ai/inputs/core-ai-connection-create.input.ts +32 -0
- package/src/core/modules/ai/inputs/core-ai-connection-preference.input.ts +42 -0
- package/src/core/modules/ai/inputs/core-ai-connection.input.ts +235 -0
- package/src/core/modules/ai/inputs/core-ai-conversation-create.input.ts +13 -0
- package/src/core/modules/ai/inputs/core-ai-conversation.input.ts +33 -0
- package/src/core/modules/ai/inputs/core-ai-prompt-create.input.ts +50 -0
- package/src/core/modules/ai/inputs/core-ai-prompt-hint-create.input.ts +26 -0
- package/src/core/modules/ai/inputs/core-ai-prompt-hint.input.ts +43 -0
- package/src/core/modules/ai/inputs/core-ai-prompt-update.input.ts +42 -0
- package/src/core/modules/ai/inputs/core-ai-prompt.input.ts +144 -0
- package/src/core/modules/ai/inputs/core-ai-slot-create.input.ts +26 -0
- package/src/core/modules/ai/inputs/core-ai-slot-update.input.ts +65 -0
- package/src/core/modules/ai/interfaces/ai-hook.interface.ts +74 -0
- package/src/core/modules/ai/interfaces/ai-placeholder.interface.ts +49 -0
- package/src/core/modules/ai/interfaces/ai-tool.interface.ts +112 -0
- package/src/core/modules/ai/interfaces/llm-provider.interface.ts +187 -0
- package/src/core/modules/ai/interfaces/resolved-ai-connection.interface.ts +55 -0
- package/src/core/modules/ai/models/core-ai-action.model.ts +37 -0
- package/src/core/modules/ai/models/core-ai-available-connection.model.ts +42 -0
- package/src/core/modules/ai/models/core-ai-budget-limit.model.ts +82 -0
- package/src/core/modules/ai/models/core-ai-connection-preference.model.ts +72 -0
- package/src/core/modules/ai/models/core-ai-connection.model.ts +330 -0
- package/src/core/modules/ai/models/core-ai-conversation.model.ts +87 -0
- package/src/core/modules/ai/models/core-ai-interaction.model.ts +145 -0
- package/src/core/modules/ai/models/core-ai-message.model.ts +29 -0
- package/src/core/modules/ai/models/core-ai-mode.model.ts +93 -0
- package/src/core/modules/ai/models/core-ai-prompt-hint.model.ts +98 -0
- package/src/core/modules/ai/models/core-ai-prompt.model.ts +120 -0
- package/src/core/modules/ai/models/core-ai-response.model.ts +119 -0
- package/src/core/modules/ai/models/core-ai-slot.model.ts +146 -0
- package/src/core/modules/ai/models/core-ai-tool-grant.model.ts +87 -0
- package/src/core/modules/ai/models/core-ai-tool-policy.model.ts +115 -0
- package/src/core/modules/ai/models/core-ai-usage-info.model.ts +107 -0
- package/src/core/modules/ai/models/core-ai-usage.model.ts +29 -0
- package/src/core/modules/ai/providers/claude-cli.provider.ts +240 -0
- package/src/core/modules/ai/providers/llm-provider.factory.ts +63 -0
- package/src/core/modules/ai/providers/openai-compatible.provider.ts +329 -0
- package/src/core/modules/ai/services/ai-crypto.service.ts +120 -0
- package/src/core/modules/ai/services/core-ai-budget.service.ts +297 -0
- package/src/core/modules/ai/services/core-ai-connection-preference.service.ts +74 -0
- package/src/core/modules/ai/services/core-ai-connection-resolver.service.ts +308 -0
- package/src/core/modules/ai/services/core-ai-connection.service.ts +387 -0
- package/src/core/modules/ai/services/core-ai-conversation.service.ts +105 -0
- package/src/core/modules/ai/services/core-ai-interaction.service.ts +56 -0
- package/src/core/modules/ai/services/core-ai-mcp-client.service.ts +169 -0
- package/src/core/modules/ai/services/core-ai-mcp-oauth.service.ts +445 -0
- package/src/core/modules/ai/services/core-ai-mcp.service.ts +94 -0
- package/src/core/modules/ai/services/core-ai-mode.service.ts +43 -0
- package/src/core/modules/ai/services/core-ai-placeholder.registry.ts +123 -0
- package/src/core/modules/ai/services/core-ai-prompt-builder.service.ts +228 -0
- package/src/core/modules/ai/services/core-ai-prompt-hint.service.ts +133 -0
- package/src/core/modules/ai/services/core-ai-prompt.service.ts +164 -0
- package/src/core/modules/ai/services/core-ai-slot.service.ts +526 -0
- package/src/core/modules/ai/services/core-ai-tool-grant.service.ts +107 -0
- package/src/core/modules/ai/services/core-ai-tool-policy.service.ts +124 -0
- package/src/core/modules/ai/services/core-ai.service.ts +1396 -0
- package/src/core/modules/ai/tools/ai-tool.base.ts +46 -0
- package/src/core/modules/ai/tools/ai-tool.registry.ts +124 -0
- package/src/core/modules/ai/tools/ask-user-question.tool.ts +76 -0
- package/src/core/modules/ai/tools/search-tools.tool.ts +70 -0
- package/src/core/modules/error-code/error-codes.ts +86 -0
- package/src/core.module.ts +12 -0
- package/src/index.ts +6 -0
- package/src/server/modules/ai/ai-tools.module.ts +33 -0
- package/src/server/modules/ai/tools/delete-user.tool.ts +44 -0
- package/src/server/modules/ai/tools/find-users.tool.ts +49 -0
- package/src/server/modules/ai/tools/get-user.tool.ts +43 -0
- package/src/server/modules/ai/tools/update-user-job-title.tool.ts +62 -0
- package/src/server/server.module.ts +5 -0
|
@@ -164,6 +164,16 @@ JWT-based authentication for existing projects:
|
|
|
164
164
|
| **GridFS Migration** | Completed TUS uploads auto-migrate to GridFS |
|
|
165
165
|
| **CORS Support** | Automatic CORS headers for browser uploads |
|
|
166
166
|
|
|
167
|
+
### AI Assistant Module
|
|
168
|
+
|
|
169
|
+
| Feature | Description |
|
|
170
|
+
|---------|-------------|
|
|
171
|
+
| **AI Module** | Prompt orchestrator (auto + plan mode), DB-backed LLM connections, tool registry |
|
|
172
|
+
| **REST Endpoints** | `POST /ai/prompt`, `POST /ai/stream` (SSE); `GET/POST/PUT/DELETE /ai/connections*`, `/ai/connections/available`, `/ai/connections/select`, `/ai/connections/preferences*`, `/ai/conversations*`, `/ai/interactions*`, `/ai/budget-limits*`, `GET /ai/usage` |
|
|
173
|
+
| **GraphQL Endpoints** | `aiPrompt`, `aiAvailableConnections`, `aiSetUserConnection`, connection/preference/conversation/interaction/budget queries + mutations, `aiUsage` |
|
|
174
|
+
| **MCP Server** | Streamable HTTP at `POST/GET/DELETE /ai/mcp` (Bearer auth); optional OAuth 2.1 router mounted in `main.ts` via `mountAiMcpOAuth(app)` (`/.well-known/*`, `/authorize`, `/token`, `/register`) |
|
|
175
|
+
| **Permission Model** | `S_USER` for prompt/conversations/available/usage; `ADMIN` for connections/preferences/interactions/budgets; encrypted API keys never leave the server (`securityCheck` + `secretFields`) |
|
|
176
|
+
|
|
167
177
|
### Email & Templates
|
|
168
178
|
|
|
169
179
|
| Feature | Description |
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Migration Guide: 11.25.x → 11.26.0
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
| Category | Details |
|
|
6
|
+
|----------|---------|
|
|
7
|
+
| **Breaking Changes** | None for the framework core. AI module is opt-in (disabled unless an `ai` config block is present). If you experimented with pre-release AI builds: read the **AI naming overhaul** section below — `CoreAiPromptTemplate` → `CoreAiSlot`, `CoreAiPromptSnippet` → `CoreAiPrompt`, routes / collection names changed, `'global'` user-prompt scope removed. |
|
|
8
|
+
| **New Features** | AI Assistant module: DB-backed LLM connections (encrypted API keys), provider-agnostic orchestrator (auto + plan mode), role-filtered tool registry, multi-turn conversations, SSE streaming, audit, per-user/tenant token budgets, an MCP server (optional OAuth 2.1), a prioritized connection-resolution chain, self-optimizing prompts (tenant-scoped admin slots + governed learning loop), per-session context-window handling with auto-detection, runtime placeholder registry, user-facing prompt templates ("Vorlagen") with placeholder substitution. |
|
|
9
|
+
| **Bugfixes** | MCP OAuth refresh-token rotation is now bound to `client_id` (impersonation fix); confidential MCP OAuth clients now actually verify their `client_secret`; conversation list endpoint no longer over-fetches the full `messages` array (use the detail endpoint to load message history). See "Operational notes" for details. |
|
|
10
|
+
| **Migration Effort** | None to adopt the update (no action required if you don't use AI). ~30–60 min to enable and integrate the AI module |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Quick Migration (No Breaking Changes)
|
|
15
|
+
|
|
16
|
+
The AI module is **disabled by default**. If you do not add an `ai` config block, nothing changes — update and continue:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @lenne.tech/nest-server@11.26.0
|
|
20
|
+
npm run update # picks up the new (lazy) @modelcontextprotocol/sdk dependency if you enable MCP
|
|
21
|
+
npm run build
|
|
22
|
+
npm test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## What's New in 11.26.0
|
|
28
|
+
|
|
29
|
+
### AI Assistant Module
|
|
30
|
+
|
|
31
|
+
A reusable, fully overridable AI-assistant layer on top of the core. It is **provider-agnostic**: connections to any OpenAI-compatible endpoint (local runtimes such as Ollama, or hosted providers) are stored in the database and managed by admins at runtime. The orchestrator compensates for backends with limited capabilities (no native tool calling / no JSON responses) via emulated tool calling.
|
|
32
|
+
|
|
33
|
+
Full reference: `node_modules/@lenne.tech/nest-server/src/core/modules/ai/README.md`
|
|
34
|
+
Integration steps: `node_modules/@lenne.tech/nest-server/src/core/modules/ai/INTEGRATION-CHECKLIST.md`
|
|
35
|
+
|
|
36
|
+
#### 1. Enable the module (config)
|
|
37
|
+
|
|
38
|
+
Add an `ai` block to each relevant environment in `config.env.ts` (presence implies enabled; `enabled: false` keeps the config but disables it):
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
ai: {
|
|
42
|
+
maxIterations: 5,
|
|
43
|
+
rateLimit: { max: 20, windowSeconds: 60 },
|
|
44
|
+
// audit: true, // persist runs to aiInteractions (required for token budgets)
|
|
45
|
+
// budget: { period: 'day', user: { maxTokens: 1_000_000 } },
|
|
46
|
+
// mcp: true, // expose the tool registry as an MCP server at /ai/mcp
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### 2. Provide the secrets / env vars
|
|
51
|
+
|
|
52
|
+
API keys for connections are stored **AES-256-GCM encrypted at rest**. Provide an encryption secret. In dev/local/ci an insecure development default is used (with a warning); in **production/staging the app refuses to boot** when AI is enabled but no secret is set (same fail-loud guard as the email/cookie configs). The same applies to `NSC__AI__MCP__OAUTH_SECRET` when `ai.mcp.oauth` is enabled. Also note: if you change the encryption secret after keys were already stored, those keys can no longer be decrypted — the app logs the affected connections at boot and you must re-enter their API keys.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# .env (production)
|
|
56
|
+
NSC__AI__ENCRYPTION_SECRET=<32+ random chars> # required when AI is used in production
|
|
57
|
+
|
|
58
|
+
# Optional one-time seed of a default connection (only seeded when AI_BASE_URL is set):
|
|
59
|
+
AI_BASE_URL=https://llm.example.com/v1
|
|
60
|
+
AI_API_KEY=your-llm-api-key
|
|
61
|
+
AI_MODEL=gpt-oss-120b
|
|
62
|
+
AI_SUPPORTS_JSON=true
|
|
63
|
+
AI_SUPPORTS_NATIVE_TOOLS=true
|
|
64
|
+
|
|
65
|
+
# Only when ai.mcp.oauth is enabled:
|
|
66
|
+
NSC__AI__MCP__OAUTH_SECRET=<32+ random chars>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
See `.env.example` for the full list.
|
|
70
|
+
|
|
71
|
+
#### 3. Register tools (optional)
|
|
72
|
+
|
|
73
|
+
Tools self-register in the global `AiToolRegistry`. Implement `IAiTool` (or extend `AiTool`) and declare it as a provider in any module. Tools MUST route data access through `CrudService` with the caller's `serviceOptions` so `@Restricted`/`securityCheck` field filtering applies. See the reference tools in `src/server/modules/ai/tools/`.
|
|
74
|
+
|
|
75
|
+
#### 4. Enable the MCP server (optional)
|
|
76
|
+
|
|
77
|
+
If you set `ai: { mcp: true }` (or `ai: { mcp: { oauth: true, oauthSecret: '…' } }`), **install the MCP SDK** in your project:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm add @modelcontextprotocol/sdk
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The SDK is a peer-style optional dependency that the controller lazy-imports on the first MCP request — projects without MCP pay no install cost. When `ai.mcp` is set but the SDK is missing, `/ai/mcp` returns **503 Service Unavailable** with the install hint instead of a 500 trace.
|
|
84
|
+
|
|
85
|
+
For OAuth 2.1 (generic MCP clients with auto-discovery + dynamic registration), mount the OAuth router in `main.ts`:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { mountAiMcpOAuth } from '@lenne.tech/nest-server';
|
|
89
|
+
// after the app is created, before listen():
|
|
90
|
+
await mountAiMcpOAuth(app, { baseUrl: process.env.BASE_URL });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Override `CoreAiMcpOAuthService.authorizeConsent()` for your login/consent UI.
|
|
94
|
+
|
|
95
|
+
### Capability auto-detection
|
|
96
|
+
|
|
97
|
+
`supportsJsonResponse` / `supportsNativeTools` on a connection are now optional with
|
|
98
|
+
**auto-detection**: leave them undefined and the module probes the endpoint to detect
|
|
99
|
+
support (eagerly on create, lazily on first prompt, and on demand via
|
|
100
|
+
`detectAiConnectionCapabilities` / `POST /ai/connections/:id/detect-capabilities`).
|
|
101
|
+
An explicit `true`/`false` is always authoritative and never probed. The optional
|
|
102
|
+
seed env vars `AI_SUPPORTS_JSON` / `AI_SUPPORTS_NATIVE_TOOLS` are now only applied
|
|
103
|
+
when set — omit them to auto-detect. See the README "Capability auto-detection" section.
|
|
104
|
+
|
|
105
|
+
### Connection-resolution chain
|
|
106
|
+
|
|
107
|
+
When multiple connections exist, one is chosen per request via a prioritized, fully overridable chain (global default → tenant default → user default → client selection → tenant-enforced → admin-enforced global → admin-enforced per tenant → code override). No connections → AI is effectively disabled (a translated "unavailable" response). Per-tenant availability is restrictable via the connection's `tenantIds`. See the README "Connection selection" section.
|
|
108
|
+
|
|
109
|
+
### Self-optimizing prompts (editable slots + governed learning)
|
|
110
|
+
|
|
111
|
+
The system prompt is assembled from **keyed slots** (`getSystemDefaultSlots()` ships built-in defaults, so it works with zero rows) — there are no hard-coded, inaccessible prompt strings. Admins can override any slot via the **tenant-scoped** `aiSlots` store (admin CRUD, GraphQL `…AiSlot(s)` / REST `/ai/slots`). The collection auto-records `tenantId` on every row from the request context; overrides apply only to the admin's tenant. `create()` is idempotent on `(tenantId, key)` so repeated "Override anlegen" actions never produce duplicates.
|
|
112
|
+
|
|
113
|
+
The admin REST surface adds two admin-UI helpers:
|
|
114
|
+
- `GET /ai/slots/effective` — framework defaults + tenant overrides + custom rows, each tagged with `isSystem` / `isOverride` so the UI knows which action to render.
|
|
115
|
+
- `POST /ai/slots/:id/reset` — delete a tenant override → framework default applies again.
|
|
116
|
+
|
|
117
|
+
Soft-deleting a system default for a tenant is done by storing an override row with `enabled: false`.
|
|
118
|
+
|
|
119
|
+
### User prompts ("Vorlagen") and the placeholder registry
|
|
120
|
+
|
|
121
|
+
User-facing re-usable prompts are stored in `aiPrompts` (each user authors them for themselves — `scope: 'user'` private — or for the whole tenant — `scope: 'tenant'` public; owner-only mutations). They're inserted into the chat input by a picker; the `'global'` scope from the early AI builds was removed (admins use slots for tenant-wide system-prompt changes instead).
|
|
122
|
+
|
|
123
|
+
Placeholders for slots AND user prompts (`{{userId}}`, `{{roles}}`, `{{tools}}`, `{{toolCatalog}}`, `{{documentation}}`, `{{learnedHints}}`) are resolved by `CoreAiPlaceholderRegistry` at run time. The current list is exposed via `GET /ai/placeholders` (S_USER); UIs should fetch it dynamically (don't hard-code names). Add project-specific placeholders by calling `registry.register({ name, description, resolve })` from any provider — no eval, no DB-stored function bodies.
|
|
124
|
+
|
|
125
|
+
**User-prompt placeholders are resolved before the LLM sees them.** `CoreAiService.prompt()` runs an extra `resolvePromptPlaceholders()` pass on the incoming `input.prompt` text — a stored user-prompt template like *"Erkläre dem Nutzer mit ID `{{userId}}` …"* gets the real value substituted at run time. Unknown tokens are left as-is so plain text with curly braces survives. The streaming path (`promptStream`) inherits the substitution via the shared entry point.
|
|
126
|
+
|
|
127
|
+
A **governed learning loop** records `suggested` hints (`aiPromptHints`, admin CRUD / `/ai/prompt-hints`) when tools fail; hints only reach the prompt once an admin **approves** them — set `ai.promptLearning.autoApply: true` to auto-approve. Hints only ADD guidance and can never relax the permission model. No action required to adopt; the defaults are active automatically.
|
|
128
|
+
|
|
129
|
+
### AI naming overhaul (only if you experimented with pre-release AI builds)
|
|
130
|
+
|
|
131
|
+
If you tested an early build of the AI module BEFORE 11.26.0, the rename below is breaking:
|
|
132
|
+
|
|
133
|
+
| Old (pre-release) | New (11.26.0) |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `CoreAiPromptTemplate(Service)` | `CoreAiSlot(Service)` |
|
|
136
|
+
| `CoreAiPromptSnippet(Service)` | `CoreAiPrompt(Service)` |
|
|
137
|
+
| Collection `aiPromptTemplates` | `aiSlots` |
|
|
138
|
+
| Collection `aiPromptSnippets` | `aiPrompts` |
|
|
139
|
+
| REST `/ai/prompt-templates` | `/ai/slots` |
|
|
140
|
+
| REST `/ai/snippets` | `/ai/prompts` |
|
|
141
|
+
| GraphQL `…AiPromptTemplate(s)` | `…AiSlot(s)` |
|
|
142
|
+
| GraphQL `…AiPromptSnippet(s)` | `…AiPrompt(s)` |
|
|
143
|
+
| `promptTemplateService` override | `slotService` |
|
|
144
|
+
| `promptSnippetService` override | `promptService` |
|
|
145
|
+
| User-prompt `scope: 'global'` | Removed (admins use slots for tenant-wide changes) |
|
|
146
|
+
|
|
147
|
+
If you stored data in either pre-release collection, copy / re-create the rows in the new collections; the framework doesn't run a migration on its own. For production projects that never used the pre-release AI build there's nothing to do.
|
|
148
|
+
|
|
149
|
+
### Context window (per user/session, auto-detected)
|
|
150
|
+
|
|
151
|
+
Session histories are budgeted against the model's context window, which is **auto-detected per connection** (`ILlmProvider.detectContextWindow()` — Ollama `/api/show` probe, a known-model table, or the Claude alias) and persisted alongside the capability flags. Set `connection.contextWindow` to override, or `ai.contextWindow` (default `8192`) as the global fallback; overflowing sessions drop their oldest non-system turns and cap tool-results at `ai.maxToolResultChars` (default `12000`). No action required.
|
|
152
|
+
|
|
153
|
+
### Cumulative budget summary at every scope
|
|
154
|
+
|
|
155
|
+
`CoreAiBudgetService.buildSummary()` now always aggregates the user's running per-period token total via `getUsage({ userId }, period)` — including the soft `scope: 'llm'` fallback path where no hard limit is configured. Previously `usedTokens` was 0 for scope=`'llm'` and the UI fell back to per-request `promptTokens`. The new behaviour matches what user-facing token bars actually need (cumulative usage against whatever limit applies). Old client code that relied on `usedTokens === 0` under the `'llm'` scope keeps working but now sees a non-zero counter.
|
|
156
|
+
|
|
157
|
+
### Provider quota on the connection
|
|
158
|
+
|
|
159
|
+
Two new admin-only fields on `CoreAiConnection` let admins pin the provider's per-user soft quota once per connection (instead of every user / tenant override):
|
|
160
|
+
|
|
161
|
+
| Field | Type | Notes |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `defaultUserMaxTokens` | `number` | Soft user-token cap over `defaultUserMaxPeriod`. Surfaced as `scope: 'llm'` (no 429). |
|
|
164
|
+
| `defaultUserMaxPeriod` | `'day' \| 'month' \| 'none'` | Defaults to `ai.budget.period` (or `'day'`) when unset. |
|
|
165
|
+
|
|
166
|
+
The budget-summary resolution chain is now:
|
|
167
|
+
|
|
168
|
+
1. User override (`aiBudgetLimits`) — hard 429 on overflow
|
|
169
|
+
2. Tenant override — hard 429
|
|
170
|
+
3. Config defaults (`ai.budget.user.maxTokens` / `tenant.maxTokens`) — hard 429
|
|
171
|
+
4. Connection `defaultUserMaxTokens` (NEW) — soft fallback (`scope: 'llm'`)
|
|
172
|
+
5. LLM `contextWindow` — last-resort soft fallback
|
|
173
|
+
|
|
174
|
+
No migration required to adopt; the soft fallback only kicks in when nothing else is configured.
|
|
175
|
+
|
|
176
|
+
### Tools are opt-in (READ THIS BEFORE INTEGRATING)
|
|
177
|
+
|
|
178
|
+
The AI module has **no automatic access to your domain models**. The framework registers two meta-tools (`ask_user_question`, `search_tools`); everything domain-specific must be registered by the project. A consumer project without an `AiToolsModule` boots fine but the assistant correctly answers *"I don't have a tool to do that"* for every domain question — that's NOT a bug.
|
|
179
|
+
|
|
180
|
+
**Action for new integrators:** copy the four reference tools (`find-users.tool.ts`, `get-user.tool.ts`, `delete-user.tool.ts`, `update-user-job-title.tool.ts`) from `node_modules/@lenne.tech/nest-server/src/server/modules/ai/tools/` into `<api>/src/server/modules/ai/tools/`, rewrite the relative `'../../../../core/...'` imports to the npm specifier `'@lenne.tech/nest-server'`, group them in an `AiToolsModule` (copy from the framework reference) and add it to `ServerModule.imports`. Security contract: every tool MUST route through a `CrudService` with `context.serviceOptions` so `@Restricted`, `securityCheck()` and tenant context apply. See `INTEGRATION-CHECKLIST.md` §3 + §4 for the step-by-step.
|
|
181
|
+
|
|
182
|
+
### New error codes
|
|
183
|
+
|
|
184
|
+
The module adds the `LTNS_0600`–`LTNS_0608` error codes (AI errors), translated de/en via the error-code module. No action required.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Operational notes (no action required)
|
|
189
|
+
|
|
190
|
+
These are quality-of-life changes that don't require a migration but are worth knowing about:
|
|
191
|
+
|
|
192
|
+
### dotenv banner suppressed
|
|
193
|
+
|
|
194
|
+
The framework's `getEnvironmentConfig()` helper now calls `dotenv.config({ quiet: true })`, which silences dotenv's startup banner (`◇ injected env (N) from .env` + promotional `vestauth.com` tip). Genuine misconfiguration warnings still surface. Projects that call `dotenv.config()` directly are unaffected — if you want the same behaviour, add `{ quiet: true }` to your own call site.
|
|
195
|
+
|
|
196
|
+
### Vitest 4 + Vite 8 + unplugin-swc → set `oxc: false`
|
|
197
|
+
|
|
198
|
+
If your test stack uses Vitest 4 (which runs on Vite 8) together with `unplugin-swc`, you'll see this warning on every run:
|
|
199
|
+
|
|
200
|
+
> `esbuild` option is set to false, but `oxc` option was not set to false. `esbuild: false` does not have effect any more. […] please set `oxc: false` instead.
|
|
201
|
+
|
|
202
|
+
Vite 8 switched the default TS/JS transformer from esbuild to Oxc. `unplugin-swc` disables esbuild internally — without `oxc: false`, Oxc still runs in parallel to SWC. Fix in your `vitest.config.ts` (and `vitest-e2e.config.ts` if you have one):
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
export default defineConfig({
|
|
206
|
+
oxc: false,
|
|
207
|
+
plugins: [swc.vite()],
|
|
208
|
+
// …
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
This is a Vite-stack issue, not a nest-server change — but the framework's own configs were updated for it, so consumer projects on the same stack will hit it too.
|
|
213
|
+
|
|
214
|
+
### AI slot descriptions reworded
|
|
215
|
+
|
|
216
|
+
The GraphQL `description:` for AI Slot fields no longer uses `{{placeholders}}` notation (it now points to `GET /ai/placeholders` instead). This avoids spurious *"Unsupported interpolation"* warnings from spectaql / Handlebars-based doc generators. The behaviour of placeholder substitution is unchanged — the registry endpoint already documents the active token set.
|
|
217
|
+
|
|
218
|
+
### Conversation list excludes the `messages` array (PERF-1)
|
|
219
|
+
|
|
220
|
+
`findAiConversations` (GraphQL) and `GET /ai/conversations` (REST) now project the `messages` array OUT of the list result via `select: '-messages'`. Conversations carry up to 500 messages each — including them in every list call was unnecessary and grew the payload super-linearly for users with many long chats.
|
|
221
|
+
|
|
222
|
+
**If you were relying on the list endpoint to return `messages`**, switch to the per-id detail call:
|
|
223
|
+
- GraphQL: `getAiConversation(id) { id, messages { … } }`
|
|
224
|
+
- REST: `GET /ai/conversations/:id`
|
|
225
|
+
|
|
226
|
+
Both still return the full message history. The list endpoint is now meant for metadata only (id / title / createdAt / connectionId).
|
|
227
|
+
|
|
228
|
+
### MCP OAuth 2.1 security hardening (only relevant if `ai.mcp.oauth: true`)
|
|
229
|
+
|
|
230
|
+
Two security fixes landed for the OAuth layer between the initial 11.26.0 release and the patch:
|
|
231
|
+
|
|
232
|
+
- **Refresh tokens are now bound to the issuing client_id** (OAuth 2.1 §4.13.2 / §7.4). The previous `rotateRefreshToken(token)` accepted any caller — a stolen refresh token could be rotated by a different client and used to impersonate the original user. The signature is now `rotateRefreshToken(token, clientId)` and the SDK's `exchangeRefreshToken` is wired to forward the calling client's id.
|
|
233
|
+
- **`getClient()` now returns `client_secret`** so the MCP SDK's `clientAuth` middleware can verify it. Previously the secret was persisted on dynamic registration but dropped on read, silently downgrading confidential clients (`token_endpoint_auth_method !== 'none'`) to public clients (the SDK's secret-verify branch is gated by `if (client.client_secret) { … }`).
|
|
234
|
+
|
|
235
|
+
No action required for consumers that don't override `CoreAiMcpOAuthService`. If your project extends it, mirror the new `rotateRefreshToken(token, clientId)` signature and ensure `getClient()` does not strip `client_secret` from the returned shape.
|
|
236
|
+
|
|
237
|
+
### `ICoreModuleOverrides.ai` and `IAi.claudeCli` are now fully typed
|
|
238
|
+
|
|
239
|
+
These are additive type improvements — runtime behaviour is unchanged:
|
|
240
|
+
|
|
241
|
+
- `ICoreModuleOverrides.ai` now exposes `mcpClientService`, `modeService`, `placeholderRegistry`, `promptHintService`, `promptService`, `slotService`, `toolGrantService`, `toolPolicyService` (already accepted at runtime, TypeScript previously blocked them).
|
|
242
|
+
- `IAi.claudeCli?: { bin?, extraArgs?, maxBudgetUsd? }` is now typed — already consumed by `ClaudeCliProvider` but previously untyped.
|
|
243
|
+
|
|
244
|
+
If you cast to `as any` to pass these to `CoreModule.forRoot(...)`, you can drop the cast.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Compatibility Notes
|
|
249
|
+
|
|
250
|
+
| Pattern | Status | Notes |
|
|
251
|
+
|---------|--------|-------|
|
|
252
|
+
| Projects without an `ai` config block | ✅ Unaffected | The module is not registered |
|
|
253
|
+
| Custom `security.secretFields` | ✅ Improved | The list is now **merged** (union) with the framework defaults instead of replacing them, so `password`/`apiKeyEncrypted`/etc. can no longer be accidentally dropped. If you relied on replacement to expose a default secret field, this changes behaviour (you cannot remove a built-in secret field anymore) |
|
|
254
|
+
| Overriding AI collaborators | ✅ Supported | All collaborators are overridable via `CoreModule.forRoot(env, { ai: { service, resolver, connectionResolver, slotService, promptService, … } })`. The override interface now lists every customization point explicitly |
|
|
255
|
+
| Clients that read `messages` from the conversation list endpoint | ⚠️ Behaviour change | `findAiConversations` / `GET /ai/conversations` no longer return the `messages` array. Use `getAiConversation(id)` / `GET /ai/conversations/:id` to load the full history. See "Operational notes → Conversation list excludes the `messages` array" |
|
|
256
|
+
| Custom `CoreAiMcpOAuthService` subclasses | ⚠️ Signature change | `rotateRefreshToken(token)` is now `rotateRefreshToken(token, clientId)` and `getClient()` returns `client_secret` / `client_secret_expires_at` / `token_endpoint_auth_method`. Mirror these changes in overrides. Stock service users are unaffected |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Troubleshooting
|
|
261
|
+
|
|
262
|
+
| Issue | Solution |
|
|
263
|
+
|-------|----------|
|
|
264
|
+
| `aiPrompt` returns "No AI service is currently available" | No usable connection exists — create one (admin) or set `AI_BASE_URL` to seed a default |
|
|
265
|
+
| API keys encrypted with a dev default (warning logged) | Set `NSC__AI__ENCRYPTION_SECRET` (32+ chars) in production |
|
|
266
|
+
| Custom MCP controller endpoints return 404 | Ensure the MCP controller is enabled (`ai.mcp`) and OAuth is mounted in `main.ts` when using `ai.mcp.oauth` |
|
|
267
|
+
| `/ai/mcp` returns 503 "MCP server unavailable: the @modelcontextprotocol/sdk peer dependency is not installed" | Install the SDK in your project: `pnpm add @modelcontextprotocol/sdk` (it is a peer-style optional dep, lazy-imported only when MCP is used) |
|
|
268
|
+
| Token budgets not enforced | Budgets require `ai.audit: true` (usage is read from `aiInteractions`) |
|
|
269
|
+
| `aiPrompt` returns 500 "BSONError: input must be a 24 character hex string" | A client sent `conversationId: "null"` (literal string). The orchestrator now treats `"null"`/`"undefined"` strings as "no conversation" — upgrade to the latest 11.26.x patch if you still see this |
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Module Documentation
|
|
274
|
+
|
|
275
|
+
- AI module: `src/core/modules/ai/README.md`
|
|
276
|
+
- Integration: `src/core/modules/ai/INTEGRATION-CHECKLIST.md`
|
|
277
|
+
- Reference tools: `src/server/modules/ai/tools/`
|
|
278
|
+
- Configuration reference: `.claude/rules/configurable-features.md` (AI Assistant row + Module Override Pattern)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.26.0",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"@as-integrations/express5": "1.1.2",
|
|
79
79
|
"@better-auth/passkey": "1.6.11",
|
|
80
80
|
"@getbrevo/brevo": "3.0.1",
|
|
81
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
81
82
|
"@nestjs/apollo": "13.4.2",
|
|
82
83
|
"@nestjs/common": "11.1.23",
|
|
83
84
|
"@nestjs/core": "11.1.23",
|
package/src/config.env.ts
CHANGED
|
@@ -16,7 +16,10 @@ import { IServerOptions } from './core/common/interfaces/server-options.interfac
|
|
|
16
16
|
* @see IServerOptions for documentation of all options
|
|
17
17
|
* @see .env.example for all available environment variables
|
|
18
18
|
*/
|
|
19
|
-
dotenv
|
|
19
|
+
// `quiet: true` silences dotenv's startup banner ("◇ injected env (N) from .env // tip: …"),
|
|
20
|
+
// which is purely cosmetic and carries promotional content. Warnings (`⚠`) for genuine
|
|
21
|
+
// misconfiguration still surface.
|
|
22
|
+
dotenv.config({ quiet: true });
|
|
20
23
|
const config: { [env: string]: IServerOptions } = {
|
|
21
24
|
// ===========================================================================
|
|
22
25
|
// CI environment
|
|
@@ -25,6 +28,12 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
25
28
|
auth: {
|
|
26
29
|
legacyEndpoints: { enabled: true },
|
|
27
30
|
},
|
|
31
|
+
ai: {
|
|
32
|
+
// AI module enabled for tests; no defaultConnection seed (tests create their own).
|
|
33
|
+
audit: true,
|
|
34
|
+
maxIterations: 3,
|
|
35
|
+
mcp: true,
|
|
36
|
+
},
|
|
28
37
|
automaticObjectIdFiltering: true,
|
|
29
38
|
betterAuth: {
|
|
30
39
|
// Email verification disabled for test environment (no real mailbox available)
|
|
@@ -279,6 +288,12 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
279
288
|
auth: {
|
|
280
289
|
legacyEndpoints: { enabled: true },
|
|
281
290
|
},
|
|
291
|
+
ai: {
|
|
292
|
+
// AI module enabled for tests; no defaultConnection seed (tests create their own).
|
|
293
|
+
audit: true,
|
|
294
|
+
maxIterations: 3,
|
|
295
|
+
mcp: true,
|
|
296
|
+
},
|
|
282
297
|
automaticObjectIdFiltering: true,
|
|
283
298
|
betterAuth: {
|
|
284
299
|
// Email verification disabled for test environment (no real mailbox available)
|
|
@@ -415,6 +430,38 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
415
430
|
// Local environment (env: 'local' → auto URLs + Passkey)
|
|
416
431
|
// ===========================================================================
|
|
417
432
|
local: {
|
|
433
|
+
// AI assistant module (presence implies enabled). Vendor-agnostic: configure
|
|
434
|
+
// any OpenAI-compatible endpoint (local runtime or hosted) via env vars.
|
|
435
|
+
// Connections are managed at runtime (admin CRUD); the defaultConnection below
|
|
436
|
+
// is only a one-time seed and reads its key from an env var, so no secret is
|
|
437
|
+
// committed to the repository. Only seeded when AI_BASE_URL is set.
|
|
438
|
+
ai: {
|
|
439
|
+
...(process.env.AI_BASE_URL
|
|
440
|
+
? {
|
|
441
|
+
defaultConnection: {
|
|
442
|
+
apiKeyEnv: 'AI_API_KEY',
|
|
443
|
+
baseUrl: process.env.AI_BASE_URL,
|
|
444
|
+
defaultMaxTokens: 4096,
|
|
445
|
+
defaultTemperature: 0.1,
|
|
446
|
+
description: 'Default LLM connection',
|
|
447
|
+
model: process.env.AI_MODEL || 'default',
|
|
448
|
+
name: 'Default LLM',
|
|
449
|
+
providerType: 'openai-compatible',
|
|
450
|
+
// Capability flags — set explicitly only when the env var is provided;
|
|
451
|
+
// otherwise left undefined so the module auto-detects them by probing
|
|
452
|
+
// the endpoint (on create + lazily on first prompt).
|
|
453
|
+
...(process.env.AI_SUPPORTS_JSON === undefined
|
|
454
|
+
? {}
|
|
455
|
+
: { supportsJsonResponse: process.env.AI_SUPPORTS_JSON === 'true' }),
|
|
456
|
+
...(process.env.AI_SUPPORTS_NATIVE_TOOLS === undefined
|
|
457
|
+
? {}
|
|
458
|
+
: { supportsNativeTools: process.env.AI_SUPPORTS_NATIVE_TOOLS === 'true' }),
|
|
459
|
+
},
|
|
460
|
+
}
|
|
461
|
+
: {}),
|
|
462
|
+
maxIterations: 5,
|
|
463
|
+
rateLimit: { max: 20, windowSeconds: 60 },
|
|
464
|
+
},
|
|
418
465
|
auth: {
|
|
419
466
|
legacyEndpoints: { enabled: true },
|
|
420
467
|
},
|
|
@@ -46,10 +46,13 @@ export function getEnvironmentConfig(options: { config?: Record<string, any>; de
|
|
|
46
46
|
...options,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
// `quiet: true` silences dotenv's startup banner ("◇ injected env (N) from .env // tip: …"),
|
|
50
|
+
// which is purely cosmetic and carries promotional content. Warnings (`⚠`) for genuine
|
|
51
|
+
// misconfiguration still surface.
|
|
49
52
|
if (envPath) {
|
|
50
|
-
dotenv.config({ path: envPath });
|
|
53
|
+
dotenv.config({ path: envPath, quiet: true });
|
|
51
54
|
} else {
|
|
52
|
-
dotenv.config();
|
|
55
|
+
dotenv.config({ quiet: true });
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
const env = process.env['NODE_ENV'] || defaultEnv;
|
|
@@ -16,7 +16,14 @@ export class CheckSecurityInterceptor implements NestInterceptor {
|
|
|
16
16
|
debug: false,
|
|
17
17
|
noteCheckedObjects: true,
|
|
18
18
|
removeSecretFields: true,
|
|
19
|
-
secretFields: [
|
|
19
|
+
secretFields: [
|
|
20
|
+
'password',
|
|
21
|
+
'verificationToken',
|
|
22
|
+
'passwordResetToken',
|
|
23
|
+
'refreshTokens',
|
|
24
|
+
'tempTokens',
|
|
25
|
+
'apiKeyEncrypted',
|
|
26
|
+
],
|
|
20
27
|
};
|
|
21
28
|
|
|
22
29
|
constructor(private readonly configService: ConfigService) {
|
|
@@ -24,10 +31,13 @@ export class CheckSecurityInterceptor implements NestInterceptor {
|
|
|
24
31
|
if (typeof configuration === 'object') {
|
|
25
32
|
this.config = { ...this.config, ...configuration };
|
|
26
33
|
}
|
|
27
|
-
//
|
|
34
|
+
// Merge (union) project secretFields with the framework defaults instead of
|
|
35
|
+
// replacing them — a custom list must not be able to silently drop a
|
|
36
|
+
// security-critical default (e.g. `password`, `apiKeyEncrypted`). Projects can
|
|
37
|
+
// only ADD fields to strip, never remove the built-in ones.
|
|
28
38
|
const globalSecretFields = this.configService.getFastButReadOnly('security.secretFields');
|
|
29
39
|
if (Array.isArray(globalSecretFields)) {
|
|
30
|
-
this.config.secretFields = globalSecretFields;
|
|
40
|
+
this.config.secretFields = [...new Set([...this.config.secretFields, ...globalSecretFields])];
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
|