@lenne.tech/nest-server 12.2.0 → 12.3.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.
Files changed (152) hide show
  1. package/.claude/rules/better-auth.md +31 -4
  2. package/.claude/rules/configurable-features.md +7 -6
  3. package/.claude/rules/package-management.md +13 -1
  4. package/.claude/rules/persistence.md +2 -2
  5. package/.claude/rules/testing.md +5 -5
  6. package/.claude/rules/versioning.md +13 -2
  7. package/CLAUDE.md +5 -0
  8. package/FRAMEWORK-API.md +4 -3
  9. package/README.md +2 -2
  10. package/dist/config.env.js +2 -2
  11. package/dist/config.env.js.map +1 -1
  12. package/dist/core/common/helpers/graphql-ws-connection.helper.d.ts +4 -0
  13. package/dist/core/common/helpers/graphql-ws-connection.helper.js +17 -3
  14. package/dist/core/common/helpers/graphql-ws-connection.helper.js.map +1 -1
  15. package/dist/core/common/interfaces/server-options.interface.d.ts +8 -0
  16. package/dist/core/modules/ai/core-ai-mcp.controller.d.ts +3 -0
  17. package/dist/core/modules/ai/core-ai-mcp.controller.js +29 -0
  18. package/dist/core/modules/ai/core-ai-mcp.controller.js.map +1 -1
  19. package/dist/core/modules/ai/core-ai.constants.d.ts +2 -0
  20. package/dist/core/modules/ai/core-ai.constants.js +2 -0
  21. package/dist/core/modules/ai/core-ai.constants.js.map +1 -1
  22. package/dist/core/modules/ai/core-ai.controller.d.ts +6 -0
  23. package/dist/core/modules/ai/core-ai.controller.js +31 -1
  24. package/dist/core/modules/ai/core-ai.controller.js.map +1 -1
  25. package/dist/core/modules/ai/core-ai.module.d.ts +2 -0
  26. package/dist/core/modules/ai/core-ai.module.js +8 -1
  27. package/dist/core/modules/ai/core-ai.module.js.map +1 -1
  28. package/dist/core/modules/ai/core-ai.resolver.d.ts +6 -0
  29. package/dist/core/modules/ai/core-ai.resolver.js +32 -0
  30. package/dist/core/modules/ai/core-ai.resolver.js.map +1 -1
  31. package/dist/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.d.ts +65 -1
  32. package/dist/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.js +6 -3
  33. package/dist/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.js.map +1 -1
  34. package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js +48 -1
  35. package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js.map +1 -1
  36. package/dist/core/modules/ai/helpers/ai-tool-authorization.helper.d.ts +9 -0
  37. package/dist/core/modules/ai/helpers/ai-tool-authorization.helper.js +54 -0
  38. package/dist/core/modules/ai/helpers/ai-tool-authorization.helper.js.map +1 -0
  39. package/dist/core/modules/ai/index.d.ts +7 -0
  40. package/dist/core/modules/ai/index.js +6 -0
  41. package/dist/core/modules/ai/index.js.map +1 -1
  42. package/dist/core/modules/ai/inputs/core-ai-settings.input.d.ts +3 -0
  43. package/dist/core/modules/ai/inputs/core-ai-settings.input.js +31 -0
  44. package/dist/core/modules/ai/inputs/core-ai-settings.input.js.map +1 -0
  45. package/dist/core/modules/ai/interfaces/ai-tool.interface.d.ts +2 -0
  46. package/dist/core/modules/ai/models/core-ai-settings.model.d.ts +4 -0
  47. package/dist/core/modules/ai/models/core-ai-settings.model.js +30 -0
  48. package/dist/core/modules/ai/models/core-ai-settings.model.js.map +1 -0
  49. package/dist/core/modules/ai/models/core-ai-user-setting.model.d.ts +8 -0
  50. package/dist/core/modules/ai/models/core-ai-user-setting.model.js +45 -0
  51. package/dist/core/modules/ai/models/core-ai-user-setting.model.js.map +1 -0
  52. package/dist/core/modules/ai/services/core-ai-conversation.service.d.ts +4 -1
  53. package/dist/core/modules/ai/services/core-ai-conversation.service.js +16 -4
  54. package/dist/core/modules/ai/services/core-ai-conversation.service.js.map +1 -1
  55. package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js +6 -6
  56. package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js.map +1 -1
  57. package/dist/core/modules/ai/services/core-ai-mcp.service.d.ts +27 -2
  58. package/dist/core/modules/ai/services/core-ai-mcp.service.js +118 -11
  59. package/dist/core/modules/ai/services/core-ai-mcp.service.js.map +1 -1
  60. package/dist/core/modules/ai/services/core-ai-prompt-builder.service.js +9 -6
  61. package/dist/core/modules/ai/services/core-ai-prompt-builder.service.js.map +1 -1
  62. package/dist/core/modules/ai/services/core-ai-user-setting.service.d.ts +17 -0
  63. package/dist/core/modules/ai/services/core-ai-user-setting.service.js +72 -0
  64. package/dist/core/modules/ai/services/core-ai-user-setting.service.js.map +1 -0
  65. package/dist/core/modules/ai/services/core-ai.service.d.ts +8 -3
  66. package/dist/core/modules/ai/services/core-ai.service.js +68 -29
  67. package/dist/core/modules/ai/services/core-ai.service.js.map +1 -1
  68. package/dist/core/modules/better-auth/better-auth.config.js +3 -1
  69. package/dist/core/modules/better-auth/better-auth.config.js.map +1 -1
  70. package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js +2 -2
  71. package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js.map +1 -1
  72. package/dist/core/modules/better-auth/core-better-auth-path-guard.middleware.d.ts +8 -0
  73. package/dist/core/modules/better-auth/core-better-auth-path-guard.middleware.js +64 -0
  74. package/dist/core/modules/better-auth/core-better-auth-path-guard.middleware.js.map +1 -0
  75. package/dist/core/modules/better-auth/core-better-auth-rate-limit.middleware.js +2 -1
  76. package/dist/core/modules/better-auth/core-better-auth-rate-limit.middleware.js.map +1 -1
  77. package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.d.ts +1 -1
  78. package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.js +5 -3
  79. package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.js.map +1 -1
  80. package/dist/core/modules/better-auth/core-better-auth.module.js +2 -0
  81. package/dist/core/modules/better-auth/core-better-auth.module.js.map +1 -1
  82. package/dist/core/modules/better-auth/index.d.ts +1 -0
  83. package/dist/core/modules/better-auth/index.js +1 -0
  84. package/dist/core/modules/better-auth/index.js.map +1 -1
  85. package/dist/core/modules/error-code/error-codes.d.ts +18 -0
  86. package/dist/core/modules/error-code/error-codes.js +16 -0
  87. package/dist/core/modules/error-code/error-codes.js.map +1 -1
  88. package/dist/core/modules/sync/core-sync.service.d.ts +1 -0
  89. package/dist/core/modules/sync/core-sync.service.js +31 -2
  90. package/dist/core/modules/sync/core-sync.service.js.map +1 -1
  91. package/dist/core/modules/tenant/core-tenant.guard.js +10 -0
  92. package/dist/core/modules/tenant/core-tenant.guard.js.map +1 -1
  93. package/dist/core/modules/tenant/core-tenant.service.d.ts +21 -1
  94. package/dist/core/modules/tenant/core-tenant.service.js +153 -1
  95. package/dist/core/modules/tenant/core-tenant.service.js.map +1 -1
  96. package/dist/server/modules/error-code/error-codes.d.ts +2 -0
  97. package/dist/test/test.helper.d.ts +1 -0
  98. package/dist/test/test.helper.js +9 -2
  99. package/dist/test/test.helper.js.map +1 -1
  100. package/docs/REQUEST-LIFECYCLE.md +3 -2
  101. package/docs/error-codes.md +14 -0
  102. package/docs/offline-sync-protocol.md +17 -8
  103. package/migration-guides/12.0.x-to-12.1.x.md +0 -1
  104. package/migration-guides/12.2.x-to-12.3.x.md +440 -0
  105. package/package.json +20 -20
  106. package/src/config.env.ts +6 -2
  107. package/src/core/common/helpers/graphql-ws-connection.helper.ts +32 -4
  108. package/src/core/common/interfaces/server-options.interface.ts +80 -8
  109. package/src/core/common/persistence/sync-model.ts +1 -1
  110. package/src/core/modules/ai/INTEGRATION-CHECKLIST.md +36 -15
  111. package/src/core/modules/ai/README.md +163 -25
  112. package/src/core/modules/ai/core-ai-mcp.controller.ts +48 -1
  113. package/src/core/modules/ai/core-ai.constants.ts +6 -0
  114. package/src/core/modules/ai/core-ai.controller.ts +36 -1
  115. package/src/core/modules/ai/core-ai.module.ts +12 -0
  116. package/src/core/modules/ai/core-ai.resolver.ts +36 -0
  117. package/src/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.ts +35 -4
  118. package/src/core/modules/ai/helpers/ai-mcp-oauth.helper.ts +68 -1
  119. package/src/core/modules/ai/helpers/ai-tool-authorization.helper.ts +99 -0
  120. package/src/core/modules/ai/index.ts +18 -0
  121. package/src/core/modules/ai/inputs/core-ai-settings.input.ts +24 -0
  122. package/src/core/modules/ai/interfaces/ai-hook.interface.ts +1 -1
  123. package/src/core/modules/ai/interfaces/ai-tool.interface.ts +38 -26
  124. package/src/core/modules/ai/models/core-ai-mode.model.ts +1 -1
  125. package/src/core/modules/ai/models/core-ai-settings.model.ts +23 -0
  126. package/src/core/modules/ai/models/core-ai-tool-policy.model.ts +1 -1
  127. package/src/core/modules/ai/models/core-ai-user-setting.model.ts +46 -0
  128. package/src/core/modules/ai/services/core-ai-conversation.service.ts +31 -6
  129. package/src/core/modules/ai/services/core-ai-mcp-oauth.service.ts +12 -9
  130. package/src/core/modules/ai/services/core-ai-mcp.service.ts +206 -13
  131. package/src/core/modules/ai/services/core-ai-prompt-builder.service.ts +13 -6
  132. package/src/core/modules/ai/services/core-ai-user-setting.service.ts +85 -0
  133. package/src/core/modules/ai/services/core-ai.service.ts +134 -35
  134. package/src/core/modules/api-token/README.md +4 -2
  135. package/src/core/modules/better-auth/CUSTOMIZATION.md +1 -1
  136. package/src/core/modules/better-auth/INTEGRATION-CHECKLIST.md +7 -0
  137. package/src/core/modules/better-auth/README.md +32 -1
  138. package/src/core/modules/better-auth/better-auth.config.ts +12 -1
  139. package/src/core/modules/better-auth/core-better-auth-email-verification.service.ts +5 -2
  140. package/src/core/modules/better-auth/core-better-auth-path-guard.middleware.ts +85 -0
  141. package/src/core/modules/better-auth/core-better-auth-rate-limit.middleware.ts +5 -2
  142. package/src/core/modules/better-auth/core-better-auth-rate-limiter.service.ts +14 -7
  143. package/src/core/modules/better-auth/core-better-auth.module.ts +12 -2
  144. package/src/core/modules/better-auth/index.ts +1 -0
  145. package/src/core/modules/error-code/error-codes.ts +18 -0
  146. package/src/core/modules/sync/README.md +11 -1
  147. package/src/core/modules/sync/core-sync.service.ts +48 -3
  148. package/src/core/modules/tenant/INTEGRATION-CHECKLIST.md +12 -1
  149. package/src/core/modules/tenant/README.md +49 -3
  150. package/src/core/modules/tenant/core-tenant.guard.ts +18 -2
  151. package/src/core/modules/tenant/core-tenant.service.ts +287 -2
  152. package/src/test/test.helper.ts +17 -3
@@ -1 +1 @@
1
- {"version":3,"file":"core-ai-mcp.service.js","sourceRoot":"","sources":["../../../../../src/core/modules/ai/services/core-ai-mcp.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAc,MAAM,8BAA8B,CAAC;AAgCnE,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAGI;IAFZ,MAAM,GAAG,IAAI,MAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAE9D,YAA+B,YAA4B;QAA5B,iBAAY,GAAZ,YAAY,CAAgB;IAAG,CAAC;IAK/D,YAAY,CAAC,IAAmC;QAC9C,OAAO,IAAI,CAAC,YAAY;aACrB,OAAO,CAAC,IAAI,CAAC;aACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvG,CAAC;IAMD,KAAK,CAAC,WAAW,CACf,IAAmC,EACnC,IAAY,EACZ,IAAyB;QAEzB,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,kCAAkC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE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AC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,IAAI,sBAAuB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YACvG,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAMS,KAAK,CAAC,kBAAkB,CAAC,MAAW,EAAE,MAA6B,EAAE,SAAkB;QAC/F,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CACrC;YACE,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,eAAe,EAAE;gBACf,UAAU,EAAE;oBACV,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,MAAM,CAAC,IAAI,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;iBACxF;gBACD,QAAQ,EAAE,CAAC,SAAS,CAAC;gBACrB,IAAI,EAAE,QAAQ;aACf;SACF,EACD,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,CACrE,CAAC;QACF,OAAO,MAAM,EAAE,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzE,CAAC;IAGS,WAAW,CAAC,IAAY;QAChC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC9D,CAAC;CACF,CAAA;AAlNY,gBAAgB;IAD5B,UAAU,EAAE;IASR,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,QAAQ,EAAE,CAAA;qCAFsB,cAAc;QACK,wBAAwB;QACzB,uBAAuB;GATjE,gBAAgB,CAkN5B"}
@@ -103,12 +103,15 @@ let CoreAiPromptBuilderService = CoreAiPromptBuilderService_1 = class CoreAiProm
103
103
  : '\n\n[Schemas deferred. Call `search_tools` with the tool name to fetch its parameter schema BEFORE you call it.]';
104
104
  }
105
105
  }
106
- const toolCatalog = defer
107
- ? (tools.map((t) => `- ${t.name}: ${this.summarizeToolDescription(t.description, summaryChars)}`).join('\n') ||
108
- '(none)') + deferNote
109
- : tools
110
- .map((t) => `- ${t.name}: ${t.description}\n parameters (JSON schema): ${JSON.stringify(t.parameters)}`)
111
- .join('\n') || '(none)';
106
+ const namesOnly = supportsNativeTools && !planMode && ConfigService.get('ai.nativeToolCatalog') !== 'full';
107
+ const toolCatalog = namesOnly
108
+ ? tools.map((t) => `- ${t.name}`).join('\n') || '(none)'
109
+ : defer
110
+ ? (tools.map((t) => `- ${t.name}: ${this.summarizeToolDescription(t.description, summaryChars)}`).join('\n') ||
111
+ '(none)') + deferNote
112
+ : tools
113
+ .map((t) => `- ${t.name}: ${t.description}\n parameters (JSON schema): ${JSON.stringify(t.parameters)}`)
114
+ .join('\n') || '(none)';
112
115
  if (this.placeholderRegistry) {
113
116
  return this.placeholderRegistry.resolveAll({ toolCatalog, tools, user });
114
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"core-ai-prompt-builder.service.js","sourceRoot":"","sources":["../../../../../src/core/modules/ai/services/core-ai-prompt-builder.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAG3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAA0B,MAAM,2BAA2B,CAAC;AAuBtG,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAmBJ;IACA;IACA;IApBd,MAAM,GAAG,IAAI,MAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;IAGrD,YAAY,GAAG,CAAC,i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AAC;IAC/F,CAAC;CACF,CAAA;AA1UY,0BAA0B;IADtC,UAAU,EAAE;IAoBR,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,QAAQ,EAAE,CAAA;qCAFsC,iBAAiB;QACrB,uBAAuB;QACf,yBAAyB;GArBrE,0BAA0B,CA0UtC"}
1
+ {"version":3,"file":"core-ai-prompt-builder.service.js","sourceRoot":"","sources":["../../../../../src/core/modules/ai/services/core-ai-prompt-builder.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAG3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAA0B,MAAM,2BAA2B,CAAC;AAuBtG,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAmBJ;IACA;IACA;IApBd,MAAM,GAAG,IAAI,MAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;IAGrD,YAAY,GAAG,CAAC,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,CAAC,CAAC;IAG9F,mBAAmB,GACpC,sEAAsE;QACtE,uFAAuF;QACvF,uFAAuF,CAAC;IAGvE,QAAQ,GAAG,CAAC,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,CAAC,CAAC;IAGrG,yBAAyB,GAAG,KAAK,CAAC;IAE1C,YACiC,eAAmC,EACnC,WAAqC,EACrC,mBAA+C;QAF/C,oBAAe,GAAf,eAAe,CAAoB;QACnC,gBAAW,GAAX,WAAW,CAA0B;QACrC,wBAAmB,GAAnB,mBAAmB,CAA4B;IAC7E,CAAC;IAOJ,KAAK,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ACV,WAAA,QAAQ,EAAE,CAAA;qCAFsC,iBAAiB;QACrB,uBAAuB;QACf,yBAAyB;GArBrE,0BAA0B,CAiVtC"}
@@ -0,0 +1,17 @@
1
+ import { Logger } from '@nestjs/common';
2
+ import type { Model } from 'mongoose';
3
+ import { CrudService } from '../../../common/services/crud.service.js';
4
+ import type { CoreModelConstructor } from '../../../common/types/core-model-constructor.type.js';
5
+ import type { CoreAiSettingsInput } from '../inputs/core-ai-settings.input.js';
6
+ import { CoreAiSettings } from '../models/core-ai-settings.model.js';
7
+ import { AiUserSettingDocument, CoreAiUserSetting } from '../models/core-ai-user-setting.model.js';
8
+ export declare class CoreAiUserSettingService extends CrudService<CoreAiUserSetting, CoreAiUserSetting, CoreAiUserSetting> {
9
+ protected readonly mainDbModel: Model<AiUserSettingDocument>;
10
+ protected readonly mainModelConstructor: CoreModelConstructor<CoreAiUserSetting>;
11
+ protected readonly logger: Logger;
12
+ constructor(mainDbModel: Model<AiUserSettingDocument>, mainModelConstructor: CoreModelConstructor<CoreAiUserSetting>);
13
+ getSettings(userId: string | undefined): Promise<CoreAiSettings>;
14
+ updateSettings(userId: string, input: CoreAiSettingsInput): Promise<CoreAiSettings>;
15
+ mcpConfirmationFor(userId: string | undefined): Promise<boolean>;
16
+ protected findForUser(userId: string): Promise<CoreAiUserSetting | undefined>;
17
+ }
@@ -0,0 +1,72 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ var CoreAiUserSettingService_1;
14
+ import { ForbiddenException, Inject, Injectable, Logger } from '@nestjs/common';
15
+ import { InjectModel } from '../../../common/persistence/mongo/mongoose-compat.js';
16
+ import { upsertRecord } from '../../../common/persistence/store-upsert.js';
17
+ import { CrudService } from '../../../common/services/crud.service.js';
18
+ import { ErrorCode } from '../../error-code/index.js';
19
+ import { effectiveMcpConfirmation, mcpConfirmationPolicy } from '../helpers/ai-tool-authorization.helper.js';
20
+ import { CoreAiSettings } from '../models/core-ai-settings.model.js';
21
+ import { AI_USER_SETTING_CLASS, AI_USER_SETTING_MODEL } from '../core-ai.constants.js';
22
+ let CoreAiUserSettingService = CoreAiUserSettingService_1 = class CoreAiUserSettingService extends CrudService {
23
+ mainDbModel;
24
+ mainModelConstructor;
25
+ logger = new Logger(CoreAiUserSettingService_1.name);
26
+ constructor(mainDbModel, mainModelConstructor) {
27
+ super();
28
+ this.mainDbModel = mainDbModel;
29
+ this.mainModelConstructor = mainModelConstructor;
30
+ }
31
+ async getSettings(userId) {
32
+ const policy = mcpConfirmationPolicy();
33
+ const stored = userId ? await this.findForUser(userId) : undefined;
34
+ const settings = new CoreAiSettings();
35
+ settings.mcpConfirmation = effectiveMcpConfirmation(policy, stored?.mcpConfirmation);
36
+ settings.mcpConfirmationEnforced = policy.enforced;
37
+ return settings;
38
+ }
39
+ async updateSettings(userId, input) {
40
+ if (typeof input?.mcpConfirmation === 'boolean') {
41
+ if (mcpConfirmationPolicy().enforced) {
42
+ throw new ForbiddenException(ErrorCode.AI_SETTING_ENFORCED);
43
+ }
44
+ await upsertRecord(this.dataStore, { userId }, { mcpConfirmation: input.mcpConfirmation });
45
+ }
46
+ return this.getSettings(userId);
47
+ }
48
+ async mcpConfirmationFor(userId) {
49
+ const policy = mcpConfirmationPolicy();
50
+ if (policy.enforced || !userId) {
51
+ return policy.default;
52
+ }
53
+ try {
54
+ return effectiveMcpConfirmation(policy, (await this.findForUser(userId))?.mcpConfirmation);
55
+ }
56
+ catch (err) {
57
+ this.logger.warn(`AI settings of user ${userId} could not be read, MCP asks: ${err.message}`);
58
+ return true;
59
+ }
60
+ }
61
+ async findForUser(userId) {
62
+ return (await this.dataStore.findOne({ userId })) ?? undefined;
63
+ }
64
+ };
65
+ CoreAiUserSettingService = CoreAiUserSettingService_1 = __decorate([
66
+ Injectable(),
67
+ __param(0, InjectModel(AI_USER_SETTING_MODEL)),
68
+ __param(1, Inject(AI_USER_SETTING_CLASS)),
69
+ __metadata("design:paramtypes", [Function, Object])
70
+ ], CoreAiUserSettingService);
71
+ export { CoreAiUserSettingService };
72
+ //# sourceMappingURL=core-ai-user-setting.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-ai-user-setting.service.js","sourceRoot":"","sources":["../../../../../src/core/modules/ai/services/core-ai-user-setting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAE7G,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAGrE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAahF,IAAM,wBAAwB,gCAA9B,MAAM,wBAAyB,SAAQ,WAAoE;IAI9C;IAEpC;IALX,MAAM,GAAG,IAA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,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,wBAAwB,CAAC,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;QAC7F,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,MAAM,iCAAkC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YACzG,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAGS,KAAK,CAAC,WAAW,CAAC,MAAc;QACxC,OAAQ,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAA8B,IAAI,SAAS,CAAC;IAC/F,CAAC;CACF,CAAA;AA1DY,wBAAwB;IADpC,UAAU,EAAE;IAKR,WAAA,WAAW,CAAC,qBAAqB,CAAC,CAAA;IAClC,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GALrB,wBAAwB,CA0DpC"}
@@ -68,11 +68,13 @@ export declare class CoreAiService {
68
68
  protected readonly placeholderRegistry?: CoreAiPlaceholderRegistry;
69
69
  protected readonly coreRedisService?: CoreRedisService;
70
70
  protected readonly logger: Logger;
71
+ protected crowdedContextWarned?: Set<string>;
71
72
  protected rateLimitStore?: RateLimitStore;
72
73
  constructor(connectionService: CoreAiConnectionService, providerFactory: LlmProviderFactory, toolRegistry: AiToolRegistry, promptBuilder: CoreAiPromptBuilderService, interactionService?: CoreAiInteractionService, conversationService?: CoreAiConversationService, budgetService?: CoreAiBudgetService, connectionResolver?: CoreAiConnectionResolverService, hintService?: CoreAiPromptHintService, toolGrantService?: CoreAiToolGrantService, hookRegistry?: AiHookRegistry, toolPolicyService?: CoreAiToolPolicyService, modeService?: CoreAiModeService, placeholderRegistry?: CoreAiPlaceholderRegistry, coreRedisService?: CoreRedisService);
73
74
  prompt(input: CoreAiPromptInput, serviceOptions: ServiceOptions, hooks?: {
74
75
  onAction?: (action: CoreAiAction) => void;
75
76
  }): Promise<CoreAiResponse>;
77
+ protected scopeConversation(input: CoreAiPromptInput, serviceOptions: ServiceOptions): Promise<CoreAiPromptInput>;
76
78
  protected resolvePromptPlaceholders(input: CoreAiPromptInput, serviceOptions: ServiceOptions): Promise<CoreAiPromptInput>;
77
79
  protected unavailableResponse(input: CoreAiPromptInput, language?: string): CoreAiResponse;
78
80
  protected readonly detectionBackoff: Map<string, number>;
@@ -102,7 +104,7 @@ export declare class CoreAiService {
102
104
  }, completion: LlmResponse): void;
103
105
  protected toAction(call: LlmToolCall): CoreAiAction;
104
106
  protected baseResponse(connectionId: string, input: CoreAiPromptInput): CoreAiResponse;
105
- protected persistTurn(input: CoreAiPromptInput, response: CoreAiResponse): Promise<void>;
107
+ protected persistTurn(input: CoreAiPromptInput, response: CoreAiResponse, run: AiRunContext): Promise<void>;
106
108
  protected auditRecord(input: CoreAiPromptInput, run: AiRunContext, response: CoreAiResponse, usage: {
107
109
  completionTokens: number;
108
110
  promptTokens: number;
@@ -122,8 +124,11 @@ export declare class CoreAiService {
122
124
  protected firstBalancedJson(text: string, from: number): null | string;
123
125
  protected estimateTokens(text: string): number;
124
126
  protected contextBudget(connection: ResolvedAiConnection): number;
125
- protected compactMessages(messages: LlmMessage[], connection: ResolvedAiConnection): Promise<number>;
126
- protected fitMessagesToContext(messages: LlmMessage[], connection: ResolvedAiConnection): void;
127
+ protected messageBudget(connection: ResolvedAiConnection, reservedTokens?: number): number;
128
+ protected crowdedContextShare(): number;
129
+ protected warnOnCrowdedContext(connection: ResolvedAiConnection, fixedTokens: number): void;
130
+ protected compactMessages(messages: LlmMessage[], connection: ResolvedAiConnection, reservedTokens?: number): Promise<number>;
131
+ protected fitMessagesToContext(messages: LlmMessage[], connection: ResolvedAiConnection, reservedTokens?: number): void;
127
132
  protected capToolResults(serialized: string): string;
128
133
  protected evaluateToolPolicies(toolCalls: LlmToolCall[], tools: IAiTool[], run: AiRunContext): Promise<{
129
134
  asked: LlmToolCall[];
@@ -17,6 +17,7 @@ import { CoreRedisService } from '../../../common/services/core-redis.service.js
17
17
  import { InMemoryRateLimitStore, RedisRateLimitStore, } from '../../../common/services/rate-limit-store.js';
18
18
  import { RequestContext } from '../../../common/services/request-context.service.js';
19
19
  import { ErrorCode } from '../../error-code/index.js';
20
+ import { authorizeToolCall, toolRequiresConfirmation } from '../helpers/ai-tool-authorization.helper.js';
20
21
  import { CoreAiAction } from '../models/core-ai-action.model.js';
21
22
  import { CoreAiResponse } from '../models/core-ai-response.model.js';
22
23
  import { CoreAiUsage } from '../models/core-ai-usage.model.js';
@@ -52,6 +53,7 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
52
53
  placeholderRegistry;
53
54
  coreRedisService;
54
55
  logger = new Logger(CoreAiService_1.name);
56
+ crowdedContextWarned;
55
57
  rateLimitStore;
56
58
  constructor(connectionService, providerFactory, toolRegistry, promptBuilder, interactionService, conversationService, budgetService, connectionResolver, hintService, toolGrantService, hookRegistry, toolPolicyService, modeService, placeholderRegistry, coreRedisService) {
57
59
  this.connectionService = connectionService;
@@ -72,7 +74,7 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
72
74
  }
73
75
  async prompt(input, serviceOptions, hooks) {
74
76
  const mode = input.mode || ConfigService.get('ai.defaultMode') || 'auto';
75
- const resolvedInput = await this.resolvePromptPlaceholders(input, serviceOptions);
77
+ const resolvedInput = await this.scopeConversation(await this.resolvePromptPlaceholders(input, serviceOptions), serviceOptions);
76
78
  const run = await this.prepareRun(resolvedInput, serviceOptions);
77
79
  if (!run) {
78
80
  return this.unavailableResponse(resolvedInput, serviceOptions?.language);
@@ -84,6 +86,13 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
84
86
  await this.attachBudgetSummary(response, run);
85
87
  return response;
86
88
  }
89
+ async scopeConversation(input, serviceOptions) {
90
+ if (!input?.conversationId) {
91
+ return input;
92
+ }
93
+ const owned = await this.conversationService?.isOwnedBy(input.conversationId, serviceOptions?.currentUser?.id);
94
+ return owned ? input : { ...input, conversationId: undefined };
95
+ }
87
96
  async resolvePromptPlaceholders(input, serviceOptions) {
88
97
  if (!this.placeholderRegistry || !input?.prompt || !input.prompt.includes('{{')) {
89
98
  return input;
@@ -219,6 +228,8 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
219
228
  language,
220
229
  });
221
230
  const toolSchemas = this.promptBuilder.buildToolSchemas(tools);
231
+ const toolTokens = provider.capabilities.nativeTools ? this.estimateTokens(JSON.stringify(toolSchemas)) : 0;
232
+ this.warnOnCrowdedContext(connection, this.estimateTokens(systemPrompt) + toolTokens);
222
233
  const jsonMode = provider.capabilities.nativeTools ? { jsonResponse: false } : {};
223
234
  const messages = [{ content: systemPrompt, role: 'system' }];
224
235
  for (const turn of history) {
@@ -251,8 +262,8 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
251
262
  break;
252
263
  }
253
264
  iterations++;
254
- await this.compactMessages(messages, connection);
255
- this.fitMessagesToContext(messages, connection);
265
+ await this.compactMessages(messages, connection, toolTokens);
266
+ this.fitMessagesToContext(messages, connection, toolTokens);
256
267
  const completion = await provider.chat(messages, toolSchemas, {
257
268
  ...jsonMode,
258
269
  maxTokens: connection.defaultMaxTokens,
@@ -377,8 +388,9 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
377
388
  response.pendingQuestion = pendingQuestion;
378
389
  }
379
390
  if (input.conversationId && this.conversationService && !requiresConfirmation && !pendingQuestion) {
380
- await this.conversationService.appendMessage(input.conversationId, { content: input.prompt, role: 'user' });
381
- await this.conversationService.appendMessage(input.conversationId, { content: finalText, role: 'assistant' });
391
+ const owner = currentUser?.id;
392
+ await this.conversationService.appendMessage(input.conversationId, { content: input.prompt, role: 'user' }, owner);
393
+ await this.conversationService.appendMessage(input.conversationId, { content: finalText, role: 'assistant' }, owner);
382
394
  }
383
395
  await this.audit({
384
396
  actions: actions.map((a) => ({ name: a.name, success: a.success })),
@@ -400,6 +412,7 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
400
412
  const usage = { completionTokens: 0, promptTokens: 0, totalTokens: 0 };
401
413
  const chatOptions = { maxTokens: connection.defaultMaxTokens, temperature: connection.defaultTemperature };
402
414
  const planSystemPrompt = await this.promptBuilder.buildPlanSystemPrompt(tools, currentUser, { language });
415
+ this.warnOnCrowdedContext(connection, this.estimateTokens(planSystemPrompt));
403
416
  const messages = [{ content: planSystemPrompt, role: 'system' }];
404
417
  for (const turn of history) {
405
418
  messages.push({ content: turn.content, role: turn.role === 'assistant' ? 'assistant' : 'user' });
@@ -482,7 +495,7 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
482
495
  response.plan = planActions;
483
496
  response.text = finalText;
484
497
  response.usage = Object.assign(new CoreAiUsage(), usage);
485
- await this.persistTurn(input, response);
498
+ await this.persistTurn(input, response, run);
486
499
  await this.audit(this.auditRecord(input, run, response, usage));
487
500
  return response;
488
501
  }
@@ -547,23 +560,10 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
547
560
  if (!tool) {
548
561
  return { allowed: false, reason: `Unknown or not permitted tool: ${call.name}` };
549
562
  }
550
- if (!tool.authorize) {
551
- return { allowed: true };
552
- }
553
- const result = await tool.authorize(call.arguments ?? {}, context);
554
- return typeof result === 'boolean' ? { allowed: result } : result;
563
+ return authorizeToolCall(tool, call.arguments ?? {}, context);
555
564
  }
556
565
  confirmationRequiredFor(tool, input) {
557
- if (tool.destructive) {
558
- return true;
559
- }
560
- if (!tool.mutating) {
561
- return false;
562
- }
563
- const cfg = ConfigService.get('ai.confirmation.mutating');
564
- const enforced = cfg?.enforced === true;
565
- const adminDefault = cfg?.default === true;
566
- return enforced ? true : (input.requireConfirmation ?? adminDefault);
566
+ return toolRequiresConfirmation(tool, input.requireConfirmation);
567
567
  }
568
568
  translate(key, language, params = {}) {
569
569
  const lang = (language || 'en').slice(0, 2).toLowerCase();
@@ -633,10 +633,11 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
633
633
  response.conversationId = input.conversationId;
634
634
  return response;
635
635
  }
636
- async persistTurn(input, response) {
636
+ async persistTurn(input, response, run) {
637
637
  if (input.conversationId && this.conversationService && !response.requiresConfirmation && !response.denied) {
638
- await this.conversationService.appendMessage(input.conversationId, { content: input.prompt, role: 'user' });
639
- await this.conversationService.appendMessage(input.conversationId, { content: response.text, role: 'assistant' });
638
+ const owner = run?.currentUser?.id;
639
+ await this.conversationService.appendMessage(input.conversationId, { content: input.prompt, role: 'user' }, owner);
640
+ await this.conversationService.appendMessage(input.conversationId, { content: response.text, role: 'assistant' }, owner);
640
641
  }
641
642
  }
642
643
  auditRecord(input, run, response, usage) {
@@ -726,8 +727,21 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
726
727
  action.arguments = decision.args;
727
728
  }
728
729
  }
730
+ const authorization = await this.authorizeCall(call, availableTools, context);
731
+ if (!authorization.allowed) {
732
+ action.success = false;
733
+ action.result = {
734
+ error: {
735
+ code: 'TOOL_NOT_AVAILABLE',
736
+ hint: 'The user may not run this tool with these arguments. Do not retry it; explain this to the user.',
737
+ message: authorization.reason || `Not permitted: ${call.name}`,
738
+ },
739
+ };
740
+ return action;
741
+ }
742
+ const toolContext = tool.authorize ? { ...context, authorization } : context;
729
743
  try {
730
- const raw = await tool.execute(call.arguments ?? {}, context);
744
+ const raw = await tool.execute(call.arguments ?? {}, toolContext);
731
745
  let success = true;
732
746
  let payload = raw;
733
747
  let message;
@@ -898,14 +912,39 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
898
912
  const margin = 256;
899
913
  return Math.max(512, window - reserve - margin);
900
914
  }
901
- async compactMessages(messages, connection) {
915
+ messageBudget(connection, reservedTokens = 0) {
916
+ return Math.max(512, this.contextBudget(connection) - Math.max(0, reservedTokens));
917
+ }
918
+ crowdedContextShare() {
919
+ return 0.5;
920
+ }
921
+ warnOnCrowdedContext(connection, fixedTokens) {
922
+ const budget = this.contextBudget(connection);
923
+ const key = connection.id ?? connection.name ?? '';
924
+ const warned = (this.crowdedContextWarned ??= new Set());
925
+ if (fixedTokens <= budget * this.crowdedContextShare() || warned.has(key)) {
926
+ return;
927
+ }
928
+ if (warned.size >= 1000) {
929
+ warned.clear();
930
+ }
931
+ warned.add(key);
932
+ const window = connection.contextWindow
933
+ ? `its context window of ${connection.contextWindow}`
934
+ : `the ai.contextWindow fallback of ${ConfigService.get('ai.contextWindow') ?? 8192} (the connection has no context window of its own)`;
935
+ this.logger.warn(`AI connection "${connection.name ?? key}": the system prompt and tool definitions take ~${fixedTokens} of ` +
936
+ `${budget} input tokens (${window}). Little room is left for the conversation: older turns are dropped ` +
937
+ `early and a long message is cut. Set the connection's contextWindow, or shrink the tool catalog ` +
938
+ `(ai.deferToolSchemas, fewer tools per role).`);
939
+ }
940
+ async compactMessages(messages, connection, reservedTokens = 0) {
902
941
  if (ConfigService.get('ai.compaction') === false) {
903
942
  return 0;
904
943
  }
905
944
  if (messages.length <= 3) {
906
945
  return 0;
907
946
  }
908
- const budget = this.contextBudget(connection);
947
+ const budget = this.messageBudget(connection, reservedTokens);
909
948
  const total = () => messages.reduce((sum, m) => sum + this.estimateTokens(m.content) + 4, 0);
910
949
  if (total() <= budget) {
911
950
  return 0;
@@ -943,11 +982,11 @@ let CoreAiService = CoreAiService_1 = class CoreAiService {
943
982
  return 0;
944
983
  }
945
984
  }
946
- fitMessagesToContext(messages, connection) {
985
+ fitMessagesToContext(messages, connection, reservedTokens = 0) {
947
986
  if (messages.length === 0) {
948
987
  return;
949
988
  }
950
- const budget = this.contextBudget(connection);
989
+ const budget = this.messageBudget(connection, reservedTokens);
951
990
  const total = () => messages.reduce((sum, m) => sum + this.estimateTokens(m.content) + 4, 0);
952
991
  let dropped = 0;
953
992
  while (total() > budget && messages.length > 2) {