@nocobase/plugin-ai 3.0.0-alpha.1 → 3.0.0-alpha.11

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 (261) hide show
  1. package/dist/ai/docs/nocobase/ai/ai-quick-start.md +1 -1
  2. package/dist/ai/docs/nocobase/ai/claude-code/index.md +1 -1
  3. package/dist/ai/docs/nocobase/ai/codex/index.md +1 -1
  4. package/dist/ai/docs/nocobase/ai/hermes-agent/index.md +1 -1
  5. package/dist/ai/docs/nocobase/ai/index.md +6 -25
  6. package/dist/ai/docs/nocobase/ai/install-nocobase-app.md +1 -1
  7. package/dist/ai/docs/nocobase/ai/openclaw/index.md +1 -1
  8. package/dist/ai/docs/nocobase/ai/opencode/index.md +1 -1
  9. package/dist/ai/docs/nocobase/ai/quick-start.mdx +9 -7
  10. package/dist/ai/docs/nocobase/ai/workbuddy/index.md +1 -1
  11. package/dist/ai/docs/nocobase/ai-builder/ai-portal/agent-workflow.md +153 -0
  12. package/dist/ai/docs/nocobase/ai-builder/ai-portal/components.md +134 -0
  13. package/dist/ai/docs/nocobase/ai-builder/ai-portal/deploy.md +164 -0
  14. package/dist/ai/docs/nocobase/ai-builder/ai-portal/index.md +144 -0
  15. package/dist/ai/docs/nocobase/ai-builder/ai-portal/model-selection.md +120 -0
  16. package/dist/ai/docs/nocobase/ai-builder/ai-portal/project-structure.md +128 -0
  17. package/dist/ai/docs/nocobase/ai-builder/index.md +73 -32
  18. package/dist/ai/docs/nocobase/ai-builder/ui-builder.md +2 -0
  19. package/dist/ai/docs/nocobase/ai-dev/index.md +2 -1
  20. package/dist/ai/docs/nocobase/ai-dev/watermark-plugin.md +2 -0
  21. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/complete-example.md +206 -0
  22. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/define-ai-employee.md +149 -0
  23. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/define-skill.md +138 -0
  24. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/define-tool.md +189 -0
  25. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/frontend-tool-ui.md +296 -0
  26. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/index.md +126 -0
  27. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/internationalization.md +88 -0
  28. package/dist/ai/docs/nocobase/ai-employees/dev/ai-employee/troubleshooting.md +86 -0
  29. package/dist/ai/docs/nocobase/ai-employees/{knowledge-base/dev → dev/knowledge-base}/external-knowledge-base.md +2 -2
  30. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/index.md +1 -1
  31. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/rag.md +43 -13
  32. package/dist/ai/docs/nocobase/api/cli/api/resource/create.md +4 -3
  33. package/dist/ai/docs/nocobase/api/cli/index.md +1 -1
  34. package/dist/ai/docs/nocobase/api/cli/portal/config.md +5 -3
  35. package/dist/ai/docs/nocobase/api/cli/portal/create.md +3 -6
  36. package/dist/ai/docs/nocobase/api/cli/portal/deploy.md +1 -1
  37. package/dist/ai/docs/nocobase/api/cli/portal/destroy.md +6 -4
  38. package/dist/ai/docs/nocobase/api/cli/portal/dev.md +21 -9
  39. package/dist/ai/docs/nocobase/api/cli/portal/index.md +19 -13
  40. package/dist/ai/docs/nocobase/api/cli/portal/info.md +3 -3
  41. package/dist/ai/docs/nocobase/api/cli/portal/list.md +5 -5
  42. package/dist/ai/docs/nocobase/api/cli/portal/pull.md +11 -1
  43. package/dist/ai/docs/nocobase/api/cli/portal/push.md +1 -1
  44. package/dist/ai/docs/nocobase/development/index.md +1 -1
  45. package/dist/ai/docs/nocobase/file-manager/file-preview/index.md +44 -3
  46. package/dist/ai/docs/nocobase/file-manager/storage/aliyun-oss.md +100 -3
  47. package/dist/ai/docs/nocobase/nocobase-cli/installation/cli.md +1 -1
  48. package/dist/ai/docs/nocobase/plugin-development/build.md +10 -4
  49. package/dist/ai/docs/nocobase/plugin-development/client/appendix/faq.md +1 -1
  50. package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-action.md +2 -0
  51. package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-block.md +2 -0
  52. package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-field.md +2 -0
  53. package/dist/ai/docs/nocobase/plugin-development/client/examples/fullstack-plugin.md +2 -0
  54. package/dist/ai/docs/nocobase/plugin-development/client/examples/settings-page.md +2 -0
  55. package/dist/ai/docs/nocobase/plugin-development/common/i18n.md +3 -3
  56. package/dist/ai/docs/nocobase/plugin-development/server/cache.md +1 -1
  57. package/dist/ai/docs/nocobase/plugin-development/server/collections.md +0 -6
  58. package/dist/ai/docs/nocobase/plugin-development/server/command.md +2 -2
  59. package/dist/ai/docs/nocobase/plugin-development/server/context.md +2 -2
  60. package/dist/ai/docs/nocobase/plugin-development/server/i18n.md +4 -4
  61. package/dist/ai/docs/nocobase/plugin-development/write-your-first-plugin.md +91 -43
  62. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-bulk-edit/index.md +1 -1
  63. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-bulk-update/index.md +1 -1
  64. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-custom-request/index.md +1 -1
  65. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-duplicate/index.md +1 -1
  66. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-export/index.md +1 -1
  67. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-import/index.md +1 -1
  68. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-action-print/index.md +1 -1
  69. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-ai/index.md +1 -1
  70. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-ai-gigachat/index.md +1 -1
  71. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-api-doc/index.md +1 -1
  72. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-api-keys/index.md +1 -1
  73. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-async-task-manager/index.md +1 -1
  74. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-audit-logs/index.md +1 -1
  75. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-auth/index.md +1 -1
  76. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-auth-sms/index.md +1 -1
  77. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-backup-restore/index.md +1 -1
  78. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-backups/index.md +1 -1
  79. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-comment/index.md +1 -1
  80. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-grid-card/index.md +1 -1
  81. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-iframe/index.md +1 -1
  82. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-list/index.md +1 -1
  83. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-markdown/index.md +1 -1
  84. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-multi-step-form/index.md +1 -1
  85. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-template/index.md +1 -1
  86. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-tree/index.md +1 -1
  87. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-workbench/index.md +1 -1
  88. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-calendar/index.md +1 -1
  89. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-charts/index.md +1 -1
  90. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-client/index.md +1 -1
  91. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-collection-fdw/index.md +1 -1
  92. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-collection-sql/index.md +1 -1
  93. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-collection-tree/index.md +1 -1
  94. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-comments/index.md +1 -1
  95. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-custom-variables/index.md +1 -1
  96. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-data-source-main/index.md +1 -1
  97. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-data-source-manager/index.md +1 -1
  98. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-data-visualization/index.md +1 -1
  99. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-data-visualization-echarts/index.md +1 -1
  100. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-departments/index.md +1 -1
  101. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-embed/index.md +1 -1
  102. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-environment-variables/index.md +1 -1
  103. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-error-handler/index.md +1 -1
  104. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-attachment-url/index.md +1 -1
  105. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-china-region/index.md +1 -1
  106. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-code/index.md +1 -1
  107. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-formula/index.md +1 -1
  108. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-m2m-array/index.md +1 -1
  109. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-markdown-vditor/index.md +1 -1
  110. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-sequence/index.md +1 -1
  111. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-field-sort/index.md +1 -1
  112. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-file-manager/index.md +1 -1
  113. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-file-previewer-office/index.md +1 -1
  114. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-flow-engine/index.md +1 -1
  115. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-form-drafts/index.md +1 -1
  116. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-gantt/index.md +1 -1
  117. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-graph-collection-manager/index.md +1 -1
  118. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-idp-oauth/index.md +1 -1
  119. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-kanban/index.md +1 -1
  120. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-license/index.md +1 -1
  121. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-locale-tester/index.md +1 -1
  122. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-localization/index.md +1 -1
  123. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-logger/index.md +1 -1
  124. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-map/index.md +1 -1
  125. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-mcp-server/index.md +1 -1
  126. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-mobile/index.md +1 -1
  127. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-mobile-client/index.md +1 -1
  128. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-multi-app-manager/index.md +1 -1
  129. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-multi-app-share-collection/index.md +1 -1
  130. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-multi-keyword-filter/index.md +1 -1
  131. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-notification-email/index.md +1 -1
  132. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-notification-in-app-message/index.md +1 -1
  133. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-notification-manager/index.md +1 -1
  134. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-public-forms/index.md +1 -1
  135. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-snapshot-field/index.md +1 -1
  136. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-system-settings/index.md +1 -1
  137. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-text-copy/index.md +1 -1
  138. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-theme-editor/index.md +1 -1
  139. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-ui-layout/index.md +1 -1
  140. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-ui-schema-storage/index.md +1 -1
  141. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-ui-templates/index.md +1 -1
  142. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-user-data-sync/index.md +1 -1
  143. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-users/index.md +1 -1
  144. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-verification/index.md +1 -1
  145. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow/index.md +1 -1
  146. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-action-trigger/index.md +1 -1
  147. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-aggregate/index.md +1 -1
  148. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-cc/index.md +1 -1
  149. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-custom-action-trigger/index.md +1 -1
  150. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-date-calculation/index.md +1 -1
  151. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-delay/index.md +1 -1
  152. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-dynamic-calculation/index.md +1 -1
  153. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-javascript/index.md +1 -1
  154. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-json-variable-mapping/index.md +1 -1
  155. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-loop/index.md +1 -1
  156. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-mailer/index.md +1 -1
  157. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-manual/index.md +1 -1
  158. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-notification/index.md +1 -1
  159. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-parallel/index.md +1 -1
  160. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-request/index.md +1 -1
  161. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-request-interceptor/index.md +1 -1
  162. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-response-message/index.md +1 -1
  163. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-sql/index.md +1 -1
  164. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-test/index.md +1 -1
  165. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-variable/index.md +1 -1
  166. package/dist/ai/docs/nocobase/users-permissions/sync/index.md +8 -1
  167. package/dist/ai/docs/nocobase/users-permissions/sync/sources/dingtalk.md +138 -0
  168. package/dist/ai/docs/nocobase/users-permissions/sync/sources/ldap.md +87 -0
  169. package/dist/ai/docs/nocobase/workflow/nodes/javascript.md +21 -1
  170. package/dist/ai/tools/knowledge-base-retrieve.js +3 -1
  171. package/dist/client/244.276308c9b2090ec2.js +10 -0
  172. package/dist/client/{264.cc98933ef65608b6.js → 264.6ca5f2eeb4173d86.js} +1 -1
  173. package/dist/client/{705.19b642db34de438a.js → 705.a4fe26945d175e8a.js} +1 -1
  174. package/dist/client/index.js +3 -3
  175. package/dist/client-v2/244.e85b8d4659ca66c0.js +10 -0
  176. package/dist/client-v2/{264.be92ff6a4d2612f1.js → 264.3c7d8e90aa7f46ee.js} +1 -1
  177. package/dist/client-v2/420.a5b929a5e7f330be.js +10 -0
  178. package/dist/client-v2/{705.8dc34d43f02f322c.js → 705.f2e1b26a3f000075.js} +1 -1
  179. package/dist/client-v2/ai-employees/chatbox/hooks/reasoning-stream.d.ts +10 -0
  180. package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +0 -2
  181. package/dist/client-v2/index.js +3 -3
  182. package/dist/client-v2/llm-providers/forms.d.ts +2 -0
  183. package/dist/client-v2/llm-providers/index.d.ts +1 -0
  184. package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +3 -0
  185. package/dist/client-v2/pages/EmployeesPage.d.ts +10 -0
  186. package/dist/client-v2/pages/LLMServicesPage.d.ts +9 -4
  187. package/dist/client-v2/repositories/AIConfigRepository.d.ts +2 -0
  188. package/dist/collections/ai-employees.d.ts +1 -0
  189. package/dist/collections/ai-employees.js +1 -0
  190. package/dist/externalVersion.js +18 -16
  191. package/dist/locale/de-DE.json +2 -1
  192. package/dist/locale/en-US.json +18 -5
  193. package/dist/locale/es-ES.json +2 -1
  194. package/dist/locale/fr-FR.json +2 -1
  195. package/dist/locale/hu-HU.json +2 -1
  196. package/dist/locale/id-ID.json +2 -1
  197. package/dist/locale/it-IT.json +2 -1
  198. package/dist/locale/ja-JP.json +2 -1
  199. package/dist/locale/ko-KR.json +2 -1
  200. package/dist/locale/nl-NL.json +2 -1
  201. package/dist/locale/pt-BR.json +2 -1
  202. package/dist/locale/ru-RU.json +2 -1
  203. package/dist/locale/tr-TR.json +2 -1
  204. package/dist/locale/uk-UA.json +2 -1
  205. package/dist/locale/vi-VN.json +2 -1
  206. package/dist/locale/zh-CN.json +18 -5
  207. package/dist/locale/zh-TW.json +2 -1
  208. package/dist/node_modules/@langchain/mistralai/package.json +1 -1
  209. package/dist/node_modules/@langchain/xai/package.json +1 -1
  210. package/dist/node_modules/fs-extra/package.json +1 -1
  211. package/dist/node_modules/jsonrepair/package.json +1 -1
  212. package/dist/node_modules/just-bash/package.json +1 -1
  213. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  214. package/dist/node_modules/openai/package.json +1 -1
  215. package/dist/node_modules/zod/package.json +1 -1
  216. package/dist/server/ai-employees/ai-conversations.d.ts +2 -1
  217. package/dist/server/ai-employees/ai-conversations.js +2 -0
  218. package/dist/server/ai-employees/ai-employee.d.ts +2 -0
  219. package/dist/server/ai-employees/ai-employee.js +86 -40
  220. package/dist/server/ai-employees/ai-knowledge-base.d.ts +21 -1
  221. package/dist/server/ai-employees/ai-knowledge-base.js +76 -8
  222. package/dist/server/ai-employees/reasoning-stream-state.d.ts +23 -0
  223. package/dist/server/ai-employees/reasoning-stream-state.js +63 -0
  224. package/dist/server/collections/ai-conversations.js +5 -0
  225. package/dist/server/features/knowledge-base.d.ts +2 -0
  226. package/dist/server/llm-providers/common/reasoning.js +18 -10
  227. package/dist/{client-v2/ai-employees/chatbox/components/DebugPanel.d.ts → server/llm-providers/deepseek/index.d.ts} +2 -2
  228. package/dist/server/llm-providers/deepseek/index.js +32 -0
  229. package/dist/server/llm-providers/deepseek/provider.d.ts +57 -0
  230. package/dist/server/llm-providers/deepseek/provider.js +320 -0
  231. package/dist/server/llm-providers/deepseek/reasoning.d.ts +83 -0
  232. package/dist/server/llm-providers/deepseek/reasoning.js +285 -0
  233. package/dist/server/llm-providers/mistral.d.ts +1 -1
  234. package/dist/server/llm-providers/provider.d.ts +1 -0
  235. package/dist/server/llm-providers/provider.js +3 -0
  236. package/dist/server/llm-providers/shengsuanyun.d.ts +29 -0
  237. package/dist/server/llm-providers/shengsuanyun.js +114 -0
  238. package/dist/server/manager/ai-feature-manager.js +1 -1
  239. package/dist/server/manager/ai-manager.d.ts +3 -0
  240. package/dist/server/manager/ai-manager.js +7 -2
  241. package/dist/server/migrations/20260501000000-ai-employee-knowledge-base-retrieval-strategy.d.ts +14 -0
  242. package/dist/server/migrations/20260501000000-ai-employee-knowledge-base-retrieval-strategy.js +49 -0
  243. package/dist/server/migrations/20260803185305-migrate-ai-conversations-portal-name.d.ts +14 -0
  244. package/dist/server/migrations/20260803185305-migrate-ai-conversations-portal-name.js +52 -0
  245. package/dist/server/plugin.js +6 -0
  246. package/dist/server/resource/aiConversations.js +14 -2
  247. package/dist/server/resource/aiEmployees.js +8 -0
  248. package/dist/server/types/ai-message.type.d.ts +4 -0
  249. package/dist/server/types/knowledge-base.type.d.ts +2 -1
  250. package/dist/swagger/index.d.ts +29 -0
  251. package/dist/swagger/llm.d.ts +8 -0
  252. package/dist/swagger/llm.js +8 -0
  253. package/dist/swagger/schemas.d.ts +21 -0
  254. package/dist/swagger/schemas.js +11 -0
  255. package/package.json +2 -2
  256. package/dist/client/244.8631eb5cf3f05e21.js +0 -10
  257. package/dist/client-v2/244.c428e645ecb94414.js +0 -10
  258. package/dist/client-v2/420.b2aedb1ff71fca0e.js +0 -10
  259. package/dist/client-v2/debug-logger.d.ts +0 -52
  260. package/dist/server/llm-providers/deepseek.d.ts +0 -40
  261. package/dist/server/llm-providers/deepseek.js +0 -174
@@ -1 +1 @@
1
- {"name":"openai","version":"6.39.1","description":"The official TypeScript library for the OpenAI API","author":"OpenAI <support@openai.com>","types":"./index.d.ts","main":"./index.js","type":"commonjs","repository":"github:openai/openai-node","license":"Apache-2.0","packageManager":"yarn@1.22.22","files":["**/*"],"private":false,"publishConfig":{"access":"public"},"scripts":{"test":"./scripts/test","build":"./scripts/build","format":"./scripts/format","tsn":"ts-node -r tsconfig-paths/register","lint":"./scripts/lint","fix":"./scripts/format"},"dependencies":{},"bin":{"openai":"bin/cli"},"overrides":{"minimatch":"^9.0.5"},"pnpm":{"overrides":{"minimatch":"^9.0.5"}},"resolutions":{"minimatch":"^9.0.5"},"exports":{".":{"require":{"types":"./index.d.ts","default":"./index.js"},"types":"./index.d.mts","default":"./index.mjs"},"./_vendor/*.mjs":{"default":"./_vendor/*.mjs"},"./_vendor/*.js":{"default":"./_vendor/*.js"},"./_vendor/*":{"import":"./_vendor/*.mjs","require":"./_vendor/*.js"},"./api-promise":{"import":"./api-promise.mjs","require":"./api-promise.js"},"./api-promise.js":{"default":"./api-promise.js"},"./api-promise.mjs":{"default":"./api-promise.mjs"},"./auth/*.mjs":{"default":"./auth/*.mjs"},"./auth/*.js":{"default":"./auth/*.js"},"./auth/*":{"import":"./auth/*.mjs","require":"./auth/*.js"},"./azure":{"import":"./azure.mjs","require":"./azure.js"},"./azure.js":{"default":"./azure.js"},"./azure.mjs":{"default":"./azure.mjs"},"./beta/*.mjs":{"default":"./beta/*.mjs"},"./beta/*.js":{"default":"./beta/*.js"},"./beta/*":{"import":"./beta/*.mjs","require":"./beta/*.js"},"./client":{"import":"./client.mjs","require":"./client.js"},"./client.js":{"default":"./client.js"},"./client.mjs":{"default":"./client.mjs"},"./core/*.mjs":{"default":"./core/*.mjs"},"./core/*.js":{"default":"./core/*.js"},"./core/*":{"import":"./core/*.mjs","require":"./core/*.js"},"./error":{"import":"./error.mjs","require":"./error.js"},"./error.js":{"default":"./error.js"},"./error.mjs":{"default":"./error.mjs"},"./helpers/*.mjs":{"default":"./helpers/*.mjs"},"./helpers/*.js":{"default":"./helpers/*.js"},"./helpers/*":{"import":"./helpers/*.mjs","require":"./helpers/*.js"},"./index":{"import":"./index.mjs","require":"./index.js"},"./index.js":{"default":"./index.js"},"./index.mjs":{"default":"./index.mjs"},"./lib/*.mjs":{"default":"./lib/*.mjs"},"./lib/*.js":{"default":"./lib/*.js"},"./lib/*":{"import":"./lib/*.mjs","require":"./lib/*.js"},"./pagination":{"import":"./pagination.mjs","require":"./pagination.js"},"./pagination.js":{"default":"./pagination.js"},"./pagination.mjs":{"default":"./pagination.mjs"},"./realtime/*.mjs":{"default":"./realtime/*.mjs"},"./realtime/*.js":{"default":"./realtime/*.js"},"./realtime/*":{"import":"./realtime/*.mjs","require":"./realtime/*.js"},"./resource":{"import":"./resource.mjs","require":"./resource.js"},"./resource.js":{"default":"./resource.js"},"./resource.mjs":{"default":"./resource.mjs"},"./resources/*.mjs":{"default":"./resources/*.mjs"},"./resources/*.js":{"default":"./resources/*.js"},"./resources/*":{"import":"./resources/*.mjs","require":"./resources/*.js"},"./resources":{"import":"./resources.mjs","require":"./resources.js"},"./resources.js":{"default":"./resources.js"},"./resources.mjs":{"default":"./resources.mjs"},"./streaming":{"import":"./streaming.mjs","require":"./streaming.js"},"./streaming.js":{"default":"./streaming.js"},"./streaming.mjs":{"default":"./streaming.mjs"},"./uploads":{"import":"./uploads.mjs","require":"./uploads.js"},"./uploads.js":{"default":"./uploads.js"},"./uploads.mjs":{"default":"./uploads.mjs"},"./version":{"import":"./version.mjs","require":"./version.js"},"./version.js":{"default":"./version.js"},"./version.mjs":{"default":"./version.mjs"}},"peerDependencies":{"ws":"^8.18.0","zod":"^3.25 || ^4.0"},"peerDependenciesMeta":{"ws":{"optional":true},"zod":{"optional":true}},"_lastModified":"2026-07-30T03:56:49.545Z"}
1
+ {"name":"openai","version":"6.39.1","description":"The official TypeScript library for the OpenAI API","author":"OpenAI <support@openai.com>","types":"./index.d.ts","main":"./index.js","type":"commonjs","repository":"github:openai/openai-node","license":"Apache-2.0","packageManager":"yarn@1.22.22","files":["**/*"],"private":false,"publishConfig":{"access":"public"},"scripts":{"test":"./scripts/test","build":"./scripts/build","format":"./scripts/format","tsn":"ts-node -r tsconfig-paths/register","lint":"./scripts/lint","fix":"./scripts/format"},"dependencies":{},"bin":{"openai":"bin/cli"},"overrides":{"minimatch":"^9.0.5"},"pnpm":{"overrides":{"minimatch":"^9.0.5"}},"resolutions":{"minimatch":"^9.0.5"},"exports":{".":{"require":{"types":"./index.d.ts","default":"./index.js"},"types":"./index.d.mts","default":"./index.mjs"},"./_vendor/*.mjs":{"default":"./_vendor/*.mjs"},"./_vendor/*.js":{"default":"./_vendor/*.js"},"./_vendor/*":{"import":"./_vendor/*.mjs","require":"./_vendor/*.js"},"./api-promise":{"import":"./api-promise.mjs","require":"./api-promise.js"},"./api-promise.js":{"default":"./api-promise.js"},"./api-promise.mjs":{"default":"./api-promise.mjs"},"./auth/*.mjs":{"default":"./auth/*.mjs"},"./auth/*.js":{"default":"./auth/*.js"},"./auth/*":{"import":"./auth/*.mjs","require":"./auth/*.js"},"./azure":{"import":"./azure.mjs","require":"./azure.js"},"./azure.js":{"default":"./azure.js"},"./azure.mjs":{"default":"./azure.mjs"},"./beta/*.mjs":{"default":"./beta/*.mjs"},"./beta/*.js":{"default":"./beta/*.js"},"./beta/*":{"import":"./beta/*.mjs","require":"./beta/*.js"},"./client":{"import":"./client.mjs","require":"./client.js"},"./client.js":{"default":"./client.js"},"./client.mjs":{"default":"./client.mjs"},"./core/*.mjs":{"default":"./core/*.mjs"},"./core/*.js":{"default":"./core/*.js"},"./core/*":{"import":"./core/*.mjs","require":"./core/*.js"},"./error":{"import":"./error.mjs","require":"./error.js"},"./error.js":{"default":"./error.js"},"./error.mjs":{"default":"./error.mjs"},"./helpers/*.mjs":{"default":"./helpers/*.mjs"},"./helpers/*.js":{"default":"./helpers/*.js"},"./helpers/*":{"import":"./helpers/*.mjs","require":"./helpers/*.js"},"./index":{"import":"./index.mjs","require":"./index.js"},"./index.js":{"default":"./index.js"},"./index.mjs":{"default":"./index.mjs"},"./lib/*.mjs":{"default":"./lib/*.mjs"},"./lib/*.js":{"default":"./lib/*.js"},"./lib/*":{"import":"./lib/*.mjs","require":"./lib/*.js"},"./pagination":{"import":"./pagination.mjs","require":"./pagination.js"},"./pagination.js":{"default":"./pagination.js"},"./pagination.mjs":{"default":"./pagination.mjs"},"./realtime/*.mjs":{"default":"./realtime/*.mjs"},"./realtime/*.js":{"default":"./realtime/*.js"},"./realtime/*":{"import":"./realtime/*.mjs","require":"./realtime/*.js"},"./resource":{"import":"./resource.mjs","require":"./resource.js"},"./resource.js":{"default":"./resource.js"},"./resource.mjs":{"default":"./resource.mjs"},"./resources/*.mjs":{"default":"./resources/*.mjs"},"./resources/*.js":{"default":"./resources/*.js"},"./resources/*":{"import":"./resources/*.mjs","require":"./resources/*.js"},"./resources":{"import":"./resources.mjs","require":"./resources.js"},"./resources.js":{"default":"./resources.js"},"./resources.mjs":{"default":"./resources.mjs"},"./streaming":{"import":"./streaming.mjs","require":"./streaming.js"},"./streaming.js":{"default":"./streaming.js"},"./streaming.mjs":{"default":"./streaming.mjs"},"./uploads":{"import":"./uploads.mjs","require":"./uploads.js"},"./uploads.js":{"default":"./uploads.js"},"./uploads.mjs":{"default":"./uploads.mjs"},"./version":{"import":"./version.mjs","require":"./version.js"},"./version.js":{"default":"./version.js"},"./version.mjs":{"default":"./version.mjs"}},"peerDependencies":{"ws":"^8.18.0","zod":"^3.25 || ^4.0"},"peerDependenciesMeta":{"ws":{"optional":true},"zod":{"optional":true}},"_lastModified":"2026-08-23T06:24:39.118Z"}
@@ -1 +1 @@
1
- {"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-07-30T03:56:47.975Z"}
1
+ {"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-08-23T06:24:21.035Z"}
@@ -31,6 +31,7 @@ export type CreateAIConversationParams = {
31
31
  title?: string;
32
32
  options?: AIConversationsOptions;
33
33
  from?: 'main-agent' | 'sub-agent';
34
+ portalName?: string;
34
35
  scope?: string;
35
36
  transaction?: Transaction;
36
37
  category?: 'chat' | 'task';
@@ -58,7 +59,7 @@ export declare const registerAIConversationReadNotification: (plugin: PluginAISe
58
59
  export declare class AIConversationsManager {
59
60
  protected plugin: PluginAIServer;
60
61
  constructor(plugin: PluginAIServer);
61
- create({ userId, aiEmployee, title, options, from, scope, transaction, category, }: CreateAIConversationParams): Promise<any>;
62
+ create({ userId, aiEmployee, title, options, from, portalName, scope, transaction, category, }: CreateAIConversationParams): Promise<any>;
62
63
  update({ userId, sessionId, title, options: inputOptions }: UpdateAIConversationParams): Promise<any>;
63
64
  getConversation({ sessionId, userId }: {
64
65
  sessionId: string;
@@ -66,6 +66,7 @@ class AIConversationsManager {
66
66
  title,
67
67
  options = {},
68
68
  from = "main-agent",
69
+ portalName,
69
70
  scope,
70
71
  transaction,
71
72
  category = "chat"
@@ -78,6 +79,7 @@ class AIConversationsManager {
78
79
  options,
79
80
  thread: 1,
80
81
  from,
82
+ ...portalName !== void 0 ? { portalName } : {},
81
83
  ...scope !== void 0 ? { scope } : {},
82
84
  category
83
85
  },
@@ -53,6 +53,7 @@ export declare class AIEmployee {
53
53
  private get systemPromptMode();
54
54
  private areSkillsEnabled;
55
55
  private areToolsEnabled;
56
+ private getAIEmployeeRecord;
56
57
  getFormatMessages(userMessages: AIMessageInput[]): Promise<{
57
58
  role: "system" | "user" | "assistant" | "tool";
58
59
  content: any;
@@ -148,6 +149,7 @@ export declare class AIEmployee {
148
149
  private formatMessages;
149
150
  private getToolCallMap;
150
151
  private toInterruptActions;
152
+ private getKnowledgeBaseRetrieveTool;
151
153
  private getAIEmployeeTools;
152
154
  private getAvailableSkills;
153
155
  private getAgentTools;
@@ -45,6 +45,7 @@ var import_utils = require("../utils");
45
45
  var import_prompts = require("./prompts");
46
46
  var import_lodash = __toESM(require("lodash"));
47
47
  var import_ai_chat_conversation = require("../manager/ai-chat-conversation");
48
+ var import_ai_knowledge_base = require("./ai-knowledge-base");
48
49
  var import_middleware = require("./middleware");
49
50
  var import_ai = require("@nocobase/ai");
50
51
  var import_checkpoints = require("./checkpoints");
@@ -58,6 +59,7 @@ var import_tool_call_sanitizer = require("./tool-call-sanitizer");
58
59
  var import_attachments = require("../attachments");
59
60
  var import_frontend_tools = require("../../common/frontend-tools");
60
61
  var import_frontend_tools2 = require("../frontend-tools");
62
+ var import_reasoning_stream_state = require("./reasoning-stream-state");
61
63
  class AIEmployee {
62
64
  sessionId;
63
65
  from = "main-agent";
@@ -125,6 +127,9 @@ class AIEmployee {
125
127
  areToolsEnabled() {
126
128
  return this.chatSettings.enableTools !== false;
127
129
  }
130
+ getAIEmployeeRecord() {
131
+ return this.employee.toJSON();
132
+ }
128
133
  async getFormatMessages(userMessages) {
129
134
  const { provider } = await this.plugin.aiManager.getLLMService({
130
135
  ...this.model
@@ -415,10 +420,21 @@ class AIEmployee {
415
420
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
416
421
  const aiMessageIdMap = /* @__PURE__ */ new Map();
417
422
  const { signal, providerName, llmService, model, provider, responseMetadata, allowEmpty = false } = options;
418
- let isReasoning = false;
423
+ const reasoningState = new import_reasoning_stream_state.ReasoningStreamState();
424
+ const stopReasoning = async (conversation) => {
425
+ if (reasoningState.stop(conversation)) {
426
+ await this.protocol.with(conversation).stopReasoning();
427
+ }
428
+ };
429
+ const stopAllReasoning = async () => {
430
+ for (const conversation of reasoningState.drain()) {
431
+ await this.protocol.with(conversation).stopReasoning();
432
+ }
433
+ };
419
434
  let gathered;
420
435
  signal.addEventListener("abort", async () => {
421
436
  try {
437
+ await stopAllReasoning();
422
438
  if ((gathered == null ? void 0 : gathered.type) === "ai") {
423
439
  const values = (0, import_utils2.convertAIMessage)({
424
440
  aiEmployee: this,
@@ -460,27 +476,27 @@ class AIEmployee {
460
476
  const { currentConversation } = metadata;
461
477
  if (chunk.type === "ai") {
462
478
  gathered = gathered !== void 0 ? (0, import_stream.concat)(gathered, chunk) : chunk;
463
- if (chunk.content) {
464
- if (isReasoning) {
465
- isReasoning = false;
466
- await this.protocol.with(currentConversation).stopReasoning();
467
- }
468
- const parsedContent = provider.parseResponseChunk(chunk.content);
469
- if (parsedContent) {
470
- await this.protocol.with(currentConversation).content(parsedContent);
471
- }
479
+ const reasoningContent = provider.parseReasoningContent(chunk);
480
+ if (reasoningContent) {
481
+ reasoningState.start(currentConversation);
482
+ await this.protocol.with(currentConversation).reasoning(reasoningContent);
483
+ }
484
+ const parsedContent = chunk.content ? provider.parseResponseChunk(chunk.content) : null;
485
+ if (parsedContent) {
486
+ await stopReasoning(currentConversation);
487
+ await this.protocol.with(currentConversation).content(parsedContent);
472
488
  }
473
489
  if ((_a = chunk.tool_call_chunks) == null ? void 0 : _a.length) {
490
+ await stopReasoning(currentConversation);
474
491
  await this.protocol.with(currentConversation).toolCallChunks(chunk.tool_call_chunks);
475
492
  }
476
493
  const webSearch = provider.parseWebSearchAction(chunk);
477
494
  if (webSearch == null ? void 0 : webSearch.length) {
495
+ await stopReasoning(currentConversation);
478
496
  await this.protocol.with(currentConversation).webSearch(webSearch);
479
497
  }
480
- const reasoningContent = provider.parseReasoningContent(chunk);
481
- if (reasoningContent) {
482
- isReasoning = true;
483
- await this.protocol.with(currentConversation).reasoning(reasoningContent);
498
+ if ((0, import_reasoning_stream_state.isReasoningFinishChunk)(chunk)) {
499
+ await stopReasoning(currentConversation);
484
500
  }
485
501
  }
486
502
  } else if (mode === "updates") {
@@ -536,6 +552,7 @@ class AIEmployee {
536
552
  }
537
553
  }
538
554
  } else if (chunks.action === "initToolCalls") {
555
+ await stopReasoning(currentConversation);
539
556
  await this.protocol.with(currentConversation).toolCalls(chunks.body);
540
557
  } else if (chunks.action === "beforeToolCall") {
541
558
  const toolsMap = await this.getToolsMap();
@@ -597,12 +614,14 @@ class AIEmployee {
597
614
  }
598
615
  }
599
616
  }
617
+ await stopAllReasoning();
600
618
  if (this.protocol.statistics.sent === 0 && !signal.aborted && !allowEmpty) {
601
619
  this.sendErrorResponse("Empty message");
602
620
  return;
603
621
  }
604
622
  await this.protocol.with(aiEmployeeConversation).endStream();
605
623
  } catch (err) {
624
+ await stopAllReasoning();
606
625
  this.ctx.log.error(err);
607
626
  if (err.name === "GraphRecursionError") {
608
627
  this.sendSpecificError({ name: err.name, message: err.message });
@@ -691,7 +710,7 @@ Field: ${field.name}, Title: ${(_a = field.options.uiSchema) == null ? void 0 :
691
710
  return message;
692
711
  }
693
712
  async getSystemPrompt(userMessages) {
694
- var _a, _b, _c, _d, _e, _f, _g;
713
+ var _a, _b, _c, _d, _e, _f, _g, _h;
695
714
  if (this.systemPromptMode === "none") {
696
715
  return "";
697
716
  }
@@ -699,9 +718,16 @@ Field: ${field.name}, Title: ${(_a = field.options.uiSchema) == null ? void 0 :
699
718
  if (this.systemPromptMode === "raw") {
700
719
  return about;
701
720
  }
721
+ const employee = this.getAIEmployeeRecord();
722
+ const knowledgeBaseManager = this.plugin.knowledgeBaseManager;
723
+ const knowledgeBaseEnabled = await knowledgeBaseManager.isEnabledKnowledgeBase(employee);
724
+ const roleNames = (0, import_ai_knowledge_base.getCurrentRoleNames)(this.ctx.state);
725
+ const hasAccessibleKnowledgeBase = knowledgeBaseEnabled ? await knowledgeBaseManager.hasAccessibleKnowledgeBase({ employee, roleNames }) : false;
726
+ const knowledgeBaseAccessDenied = knowledgeBaseEnabled && !hasAccessibleKnowledgeBase;
727
+ const knowledgeBaseOnDemand = knowledgeBaseEnabled && hasAccessibleKnowledgeBase && (0, import_ai_knowledge_base.normalizeKnowledgeBaseRetrievalStrategy)((_a = employee.knowledgeBase) == null ? void 0 : _a.retrievalStrategy) === "onDemand";
702
728
  const userConfig = await this.db.getRepository("usersAiEmployees").findOne({
703
729
  filter: {
704
- userId: ((_a = this.ctx.auth) == null ? void 0 : _a.user.id) ?? 0,
730
+ userId: ((_b = this.ctx.auth) == null ? void 0 : _b.user.id) ?? 0,
705
731
  aiEmployee: this.employee.username
706
732
  }
707
733
  });
@@ -726,17 +752,25 @@ ${workContextBackground.join("\n")}`;
726
752
  ${addSystemPrompt.map((it) => it.content).join("\n")}`;
727
753
  }
728
754
  let knowledgeBase;
729
- const { knowledgeBaseManager } = this.plugin;
730
- const employee = this.employee.toJSON();
731
- if (await knowledgeBaseManager.isEnabledKnowledgeBase(employee) && employee.knowledgeBasePrompt && (userMessages == null ? void 0 : userMessages.length)) {
755
+ if (knowledgeBaseEnabled && hasAccessibleKnowledgeBase && !knowledgeBaseOnDemand && (userMessages == null ? void 0 : userMessages.length)) {
732
756
  const lastUserMessage = userMessages.filter((x) => x.role === "user").at(-1);
733
757
  if (lastUserMessage) {
734
758
  knowledgeBase = await knowledgeBaseManager.retrievePrompt({
735
759
  employee,
736
- query: lastUserMessage.content.content
760
+ query: lastUserMessage.content.content,
761
+ roleNames
737
762
  });
738
763
  }
739
764
  }
765
+ const knowledgeBaseBackgroundPrompt = (0, import_ai_knowledge_base.getKnowledgeBaseBackgroundPrompt)({
766
+ accessDenied: knowledgeBaseAccessDenied,
767
+ onDemand: knowledgeBaseOnDemand,
768
+ preRetrieved: Boolean(knowledgeBase)
769
+ });
770
+ if (knowledgeBaseBackgroundPrompt) {
771
+ background = `${background}
772
+ ${knowledgeBaseBackgroundPrompt}`;
773
+ }
740
774
  const availableSkills = await this.getAvailableSkills();
741
775
  const availableAIEmployees = await this.getAvailableAIEmployees();
742
776
  const systemPrompt = (0, import_prompts.getSystemPrompt)({
@@ -750,8 +784,8 @@ ${addSystemPrompt.map((it) => it.content).join("\n")}`;
750
784
  personal: userConfig == null ? void 0 : userConfig.prompt,
751
785
  environment: {
752
786
  database: this.db.sequelize.getDialect(),
753
- locale: ((_c = (_b = this.ctx).getCurrentLocale) == null ? void 0 : _c.call(_b)) || "en-US",
754
- currentDateTime: getCurrentDateTimeForPrompt((_e = (_d = this.ctx).getCurrentLocale) == null ? void 0 : _e.call(_d), getCurrentTimezone(this.ctx)),
787
+ locale: ((_d = (_c = this.ctx).getCurrentLocale) == null ? void 0 : _d.call(_c)) || "en-US",
788
+ currentDateTime: getCurrentDateTimeForPrompt((_f = (_e = this.ctx).getCurrentLocale) == null ? void 0 : _f.call(_e), getCurrentTimezone(this.ctx)),
755
789
  timezone: getCurrentTimezone(this.ctx)
756
790
  },
757
791
  knowledgeBase,
@@ -759,7 +793,7 @@ ${addSystemPrompt.map((it) => it.content).join("\n")}`;
759
793
  availableAIEmployees,
760
794
  webSearch: this.webSearch
761
795
  });
762
- const { important } = ((_g = (_f = this.ctx.action) == null ? void 0 : _f.params) == null ? void 0 : _g.values) || {};
796
+ const { important } = ((_h = (_g = this.ctx.action) == null ? void 0 : _g.params) == null ? void 0 : _h.values) || {};
763
797
  if (important === "GraphRecursionError") {
764
798
  const importantPrompt = `<Important>You have already called tools multiple times and gathered sufficient information.
765
799
  First, provide a summary based on the existing information. Do not call additional tools.
@@ -1132,20 +1166,21 @@ If information is missing, clearly state it in the summary.</Important>`;
1132
1166
  });
1133
1167
  continue;
1134
1168
  }
1169
+ const additionalKwargs = (0, import_tool_call_sanitizer.sanitizeAdditionalKwargsForToolCalls)((_b = msg.metadata) == null ? void 0 : _b.additional_kwargs, msg.toolCalls, {
1170
+ onDiscard: (info) => {
1171
+ var _a2;
1172
+ this.logger.warn("Discard malformed raw tool calls from AI message", {
1173
+ phase: "formatMessages",
1174
+ messageId: (_a2 = msg.metadata) == null ? void 0 : _a2.id,
1175
+ ...info
1176
+ });
1177
+ }
1178
+ }).additionalKwargs;
1135
1179
  formattedMessages.push({
1136
1180
  role: "assistant",
1137
1181
  content,
1138
1182
  tool_calls: msg.toolCalls,
1139
- additional_kwargs: (0, import_tool_call_sanitizer.sanitizeAdditionalKwargsForToolCalls)((_b = msg.metadata) == null ? void 0 : _b.additional_kwargs, msg.toolCalls, {
1140
- onDiscard: (info) => {
1141
- var _a2;
1142
- this.logger.warn("Discard malformed raw tool calls from AI message", {
1143
- phase: "formatMessages",
1144
- messageId: (_a2 = msg.metadata) == null ? void 0 : _a2.id,
1145
- ...info
1146
- });
1147
- }
1148
- }).additionalKwargs
1183
+ additional_kwargs: provider.prepareStoredAssistantAdditionalKwargs(additionalKwargs)
1149
1184
  });
1150
1185
  }
1151
1186
  return formattedMessages;
@@ -1190,6 +1225,21 @@ If information is missing, clearly state it in the summary.</Important>`;
1190
1225
  }
1191
1226
  return result;
1192
1227
  }
1228
+ async getKnowledgeBaseRetrieveTool() {
1229
+ const employee = this.getAIEmployeeRecord();
1230
+ const knowledgeBaseManager = this.plugin.knowledgeBaseManager;
1231
+ if (!await knowledgeBaseManager.isEnabledKnowledgeBase(employee)) {
1232
+ return void 0;
1233
+ }
1234
+ const hasAccessibleKnowledgeBase = await knowledgeBaseManager.hasAccessibleKnowledgeBase({
1235
+ employee,
1236
+ roleNames: (0, import_ai_knowledge_base.getCurrentRoleNames)(this.ctx.state)
1237
+ });
1238
+ if (!hasAccessibleKnowledgeBase) {
1239
+ return void 0;
1240
+ }
1241
+ return await this.toolsManager.getTools(import_ai.SYSTEM_TOOLS.KNOWLEDGE_BASE, { ctx: this.ctx });
1242
+ }
1193
1243
  async getAIEmployeeTools() {
1194
1244
  var _a;
1195
1245
  if (!this.areToolsEnabled()) {
@@ -1209,13 +1259,9 @@ If information is missing, clearly state it in the summary.</Important>`;
1209
1259
  const toolMap = await this.getToolsMap();
1210
1260
  const settingsTools = ((_a = this.employee.skillSettings) == null ? void 0 : _a.tools) ?? [];
1211
1261
  const employeeTools = [...settingsTools, ...this.tools];
1212
- if (await this.plugin.knowledgeBaseManager.isEnabledKnowledgeBase(this.employee.toJSON())) {
1213
- const knowledgeBaseRetrieveTool = await this.toolsManager.getTools(import_ai.SYSTEM_TOOLS.KNOWLEDGE_BASE, {
1214
- ctx: this.ctx
1215
- });
1216
- if (knowledgeBaseRetrieveTool) {
1217
- employeeTools.push({ name: import_ai.SYSTEM_TOOLS.KNOWLEDGE_BASE });
1218
- }
1262
+ const knowledgeBaseRetrieveTool = await this.getKnowledgeBaseRetrieveTool();
1263
+ if (knowledgeBaseRetrieveTool) {
1264
+ employeeTools.push({ name: import_ai.SYSTEM_TOOLS.KNOWLEDGE_BASE });
1219
1265
  }
1220
1266
  for (const toolSetting of employeeTools) {
1221
1267
  if (generalToolsNameSet.has(toolSetting.name)) {
@@ -8,15 +8,35 @@
8
8
  */
9
9
  import { AIEmployee } from '../../collections/ai-employees';
10
10
  import type PluginAIServer from '../plugin';
11
+ export declare const KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES: readonly ["always", "onDemand"];
12
+ export type KnowledgeBaseRetrievalStrategy = (typeof KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES)[number];
13
+ export declare const isKnowledgeBaseRetrievalStrategy: (value: unknown) => value is "always" | "onDemand";
14
+ export declare const normalizeKnowledgeBaseRetrievalStrategy: (value: unknown) => KnowledgeBaseRetrievalStrategy;
15
+ export declare const withDefaultKnowledgeBaseRetrievalStrategy: (knowledgeBase: unknown) => Record<string, unknown>;
16
+ export declare const getCurrentRoleNames: (state: unknown) => string[];
17
+ export declare const KNOWLEDGE_BASE_ON_DEMAND_PROMPT: string;
18
+ export declare const KNOWLEDGE_BASE_PRE_RETRIEVED_PROMPT: string;
19
+ export declare const KNOWLEDGE_BASE_NO_ACCESS_PROMPT: string;
20
+ export declare const getKnowledgeBaseBackgroundPrompt: ({ accessDenied, onDemand, preRetrieved, }: {
21
+ accessDenied: boolean;
22
+ onDemand: boolean;
23
+ preRetrieved: boolean;
24
+ }) => string | undefined;
11
25
  export type KnowledgeBaseRetrieveOptions = {
12
26
  username?: string;
13
27
  employee?: AIEmployee;
14
28
  query: string;
29
+ roleNames?: string[];
30
+ };
31
+ export type KnowledgeBaseAccessOptions = {
32
+ employee: AIEmployee;
33
+ roleNames: string[];
15
34
  };
16
35
  export declare class KnowledgeBaseManager {
17
36
  private readonly plugin;
18
37
  constructor(plugin: PluginAIServer);
19
- retrievePrompt({ username, employee, query }: KnowledgeBaseRetrieveOptions): Promise<string>;
38
+ retrievePrompt({ username, employee, query, roleNames }: KnowledgeBaseRetrieveOptions): Promise<string>;
39
+ hasAccessibleKnowledgeBase({ employee, roleNames }: KnowledgeBaseAccessOptions): Promise<boolean>;
20
40
  isEnabledKnowledgeBase(username: string): Promise<boolean>;
21
41
  isEnabledKnowledgeBase(employee: AIEmployee): Promise<boolean>;
22
42
  private getEmployee;
@@ -36,12 +36,64 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var ai_knowledge_base_exports = {};
38
38
  __export(ai_knowledge_base_exports, {
39
- KnowledgeBaseManager: () => KnowledgeBaseManager
39
+ KNOWLEDGE_BASE_NO_ACCESS_PROMPT: () => KNOWLEDGE_BASE_NO_ACCESS_PROMPT,
40
+ KNOWLEDGE_BASE_ON_DEMAND_PROMPT: () => KNOWLEDGE_BASE_ON_DEMAND_PROMPT,
41
+ KNOWLEDGE_BASE_PRE_RETRIEVED_PROMPT: () => KNOWLEDGE_BASE_PRE_RETRIEVED_PROMPT,
42
+ KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES: () => KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES,
43
+ KnowledgeBaseManager: () => KnowledgeBaseManager,
44
+ getCurrentRoleNames: () => getCurrentRoleNames,
45
+ getKnowledgeBaseBackgroundPrompt: () => getKnowledgeBaseBackgroundPrompt,
46
+ isKnowledgeBaseRetrievalStrategy: () => isKnowledgeBaseRetrievalStrategy,
47
+ normalizeKnowledgeBaseRetrievalStrategy: () => normalizeKnowledgeBaseRetrievalStrategy,
48
+ withDefaultKnowledgeBaseRetrievalStrategy: () => withDefaultKnowledgeBaseRetrievalStrategy
40
49
  });
41
50
  module.exports = __toCommonJS(ai_knowledge_base_exports);
42
51
  var import_prompts = require("@langchain/core/prompts");
43
52
  var import_ai_feature_manager = require("../manager/ai-feature-manager");
44
53
  var import_lodash = __toESM(require("lodash"));
54
+ const KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES = ["always", "onDemand"];
55
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
56
+ const getRoleNames = (roles) => Array.isArray(roles) ? Array.from(
57
+ new Set(
58
+ roles.map((role) => isRecord(role) ? role.name : role).filter((role) => typeof role === "string" && role.length > 0)
59
+ )
60
+ ) : [];
61
+ const isKnowledgeBaseRetrievalStrategy = (value) => typeof value === "string" && KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES.includes(value);
62
+ const normalizeKnowledgeBaseRetrievalStrategy = (value) => isKnowledgeBaseRetrievalStrategy(value) ? value : "always";
63
+ const withDefaultKnowledgeBaseRetrievalStrategy = (knowledgeBase) => {
64
+ const settings = isRecord(knowledgeBase) ? { ...knowledgeBase } : {};
65
+ if (!isKnowledgeBaseRetrievalStrategy(settings.retrievalStrategy)) {
66
+ settings.retrievalStrategy = "onDemand";
67
+ }
68
+ return settings;
69
+ };
70
+ const getCurrentRoleNames = (state) => {
71
+ const { currentRole, currentRoles, currentUser } = isRecord(state) ? state : {};
72
+ const currentUserRoleNames = getRoleNames(isRecord(currentUser) ? currentUser.roles : void 0);
73
+ if (currentUserRoleNames.length) {
74
+ return currentUserRoleNames;
75
+ }
76
+ if (Array.isArray(currentRoles)) {
77
+ return getRoleNames(currentRoles);
78
+ }
79
+ return typeof currentRole === "string" && currentRole.length > 0 ? [currentRole] : [];
80
+ };
81
+ const KNOWLEDGE_BASE_ON_DEMAND_PROMPT = "Use the knowledge base retrieval tool only when the request needs internal knowledge, uploaded documents, or knowledge-base facts. Do not call it for requests that clearly do not need those sources.";
82
+ const KNOWLEDGE_BASE_PRE_RETRIEVED_PROMPT = "The <knowledgeBase> content was retrieved in advance for the current user request. Use it directly when it is sufficient to answer; do not call the knowledge base retrieval tool again unless additional or different knowledge-base information is genuinely needed.";
83
+ const KNOWLEDGE_BASE_NO_ACCESS_PROMPT = "The current user does not have permission to access any knowledge base in this AI employee's configured scope. First answer the user's question as helpfully as possible using only information available without knowledge-base content; do not replace or interrupt the answer with a permission notice, and do not fabricate unavailable facts. Only after completing the answer, append a brief notice in the user's language stating that this response did not use knowledge-base content because the current user does not have permission to access these knowledge bases. Format this notice as a visually prominent Markdown reminder, using a blockquote with a bold warning or reminder heading so that it is easy to notice. If knowledge-base access is needed, advise the user to contact an administrator. Do not claim to have searched or used knowledge-base content.";
84
+ const getKnowledgeBaseBackgroundPrompt = ({
85
+ accessDenied,
86
+ onDemand,
87
+ preRetrieved
88
+ }) => {
89
+ if (accessDenied) {
90
+ return KNOWLEDGE_BASE_NO_ACCESS_PROMPT;
91
+ }
92
+ if (onDemand) {
93
+ return KNOWLEDGE_BASE_ON_DEMAND_PROMPT;
94
+ }
95
+ return preRetrieved ? KNOWLEDGE_BASE_PRE_RETRIEVED_PROMPT : void 0;
96
+ };
45
97
  const normalizeMatchedQuestions = (value) => {
46
98
  if (!Array.isArray(value)) {
47
99
  return [];
@@ -62,17 +114,14 @@ class KnowledgeBaseManager {
62
114
  constructor(plugin) {
63
115
  this.plugin = plugin;
64
116
  }
65
- async retrievePrompt({ username, employee, query }) {
117
+ async retrievePrompt({ username, employee, query, roleNames }) {
66
118
  employee = employee ?? (username ? await this.getEmployee(username) : null);
67
119
  if (!employee) {
68
120
  return "Specified knowledge base not existed";
69
121
  }
70
- const { knowledgeBaseKeys, topK, score } = employee.knowledgeBase ?? {};
71
- if (!knowledgeBaseKeys || import_lodash.default.isEmpty(knowledgeBaseKeys)) {
72
- return "Specified knowledge base not existed";
73
- }
122
+ const { knowledgeBaseKeys = [], topK, score } = employee.knowledgeBase ?? {};
74
123
  const promptTemplate = import_prompts.ChatPromptTemplate.fromTemplate(employee.knowledgeBasePrompt ?? "{knowledgeBaseData}");
75
- const docs = await this.plugin.features.knowledgeBase.search({ knowledgeBaseKeys, query, topK, score });
124
+ const docs = await this.plugin.features.knowledgeBase.search({ knowledgeBaseKeys, query, topK, score, roleNames });
76
125
  if (!(docs == null ? void 0 : docs.length)) {
77
126
  return "No document match in knowledge base";
78
127
  }
@@ -81,6 +130,16 @@ class KnowledgeBaseManager {
81
130
  knowledgeBaseData
82
131
  });
83
132
  }
133
+ async hasAccessibleKnowledgeBase({ employee, roleNames }) {
134
+ var _a;
135
+ const knowledgeBaseKeys = ((_a = employee.knowledgeBase) == null ? void 0 : _a.knowledgeBaseKeys) ?? [];
136
+ const knowledgeBaseFeature = this.plugin.features.knowledgeBase;
137
+ if (!knowledgeBaseFeature.getAccessibleKnowledgeBaseKeys) {
138
+ return true;
139
+ }
140
+ const accessibleKeys = await knowledgeBaseFeature.getAccessibleKnowledgeBaseKeys({ knowledgeBaseKeys, roleNames });
141
+ return accessibleKeys.length > 0;
142
+ }
84
143
  async isEnabledKnowledgeBase(usernameOrEmployee) {
85
144
  const featureEnabled = this.plugin.features.isFeaturesEnabled(Object.values(import_ai_feature_manager.EEFeatures));
86
145
  const employee = typeof usernameOrEmployee === "string" ? await this.getEmployee(usernameOrEmployee) : usernameOrEmployee;
@@ -96,5 +155,14 @@ class KnowledgeBaseManager {
96
155
  }
97
156
  // Annotate the CommonJS export names for ESM import in node:
98
157
  0 && (module.exports = {
99
- KnowledgeBaseManager
158
+ KNOWLEDGE_BASE_NO_ACCESS_PROMPT,
159
+ KNOWLEDGE_BASE_ON_DEMAND_PROMPT,
160
+ KNOWLEDGE_BASE_PRE_RETRIEVED_PROMPT,
161
+ KNOWLEDGE_BASE_RETRIEVAL_STRATEGIES,
162
+ KnowledgeBaseManager,
163
+ getCurrentRoleNames,
164
+ getKnowledgeBaseBackgroundPrompt,
165
+ isKnowledgeBaseRetrievalStrategy,
166
+ normalizeKnowledgeBaseRetrievalStrategy,
167
+ withDefaultKnowledgeBaseRetrievalStrategy
100
168
  });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export type StreamConversation = {
10
+ sessionId: string;
11
+ from: string;
12
+ username: string;
13
+ };
14
+ export declare class ReasoningStreamState {
15
+ private readonly active;
16
+ start(conversation: StreamConversation): void;
17
+ stop(conversation: StreamConversation): boolean;
18
+ drain(): StreamConversation[];
19
+ }
20
+ export declare const isReasoningFinishChunk: (chunk: {
21
+ response_metadata?: Record<string, unknown>;
22
+ usage_metadata?: Record<string, unknown>;
23
+ }) => boolean;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var reasoning_stream_state_exports = {};
28
+ __export(reasoning_stream_state_exports, {
29
+ ReasoningStreamState: () => ReasoningStreamState,
30
+ isReasoningFinishChunk: () => isReasoningFinishChunk
31
+ });
32
+ module.exports = __toCommonJS(reasoning_stream_state_exports);
33
+ const getConversationKey = (conversation) => `${conversation.from}:${conversation.sessionId}:${conversation.username}`;
34
+ class ReasoningStreamState {
35
+ active = /* @__PURE__ */ new Map();
36
+ start(conversation) {
37
+ this.active.set(getConversationKey(conversation), conversation);
38
+ }
39
+ stop(conversation) {
40
+ return this.active.delete(getConversationKey(conversation));
41
+ }
42
+ drain() {
43
+ const conversations = Array.from(this.active.values());
44
+ this.active.clear();
45
+ return conversations;
46
+ }
47
+ }
48
+ const isReasoningFinishChunk = (chunk) => {
49
+ const metadata = chunk.response_metadata;
50
+ if (!metadata) {
51
+ return false;
52
+ }
53
+ const finishReason = metadata.finish_reason ?? metadata.finishReason;
54
+ if (typeof finishReason === "string" && finishReason.length > 0) {
55
+ return true;
56
+ }
57
+ return metadata.status === "completed" || metadata.status === "incomplete" || metadata.status === "failed";
58
+ };
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ ReasoningStreamState,
62
+ isReasoningFinishChunk
63
+ });
@@ -57,6 +57,11 @@ var ai_conversations_default = (0, import_database.defineCollection)({
57
57
  defaultValue: "main-agent",
58
58
  allowNull: false
59
59
  },
60
+ {
61
+ name: "portalName",
62
+ type: "string",
63
+ allowNull: true
64
+ },
60
65
  {
61
66
  name: "scope",
62
67
  type: "string",
@@ -7,8 +7,10 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { DocumentSegmentedWithScore, KnowledgeBase, KnowledgeBaseGroup, SearchOptions } from '../types';
10
+ export type KnowledgeBaseAccessOptions = Pick<SearchOptions, 'knowledgeBaseKeys' | 'roleNames'>;
10
11
  export interface KnowledgeBaseFeature {
11
12
  getKnowledgeBase(knowledgeBaseKeys: string[]): Promise<KnowledgeBase[]>;
12
13
  getKnowledgeBaseGroup(knowledgeBaseKeys: string[]): Promise<KnowledgeBaseGroup[]>;
14
+ getAccessibleKnowledgeBaseKeys(options: KnowledgeBaseAccessOptions): Promise<string[]>;
13
15
  search(options: SearchOptions): Promise<DocumentSegmentedWithScore[]>;
14
16
  }