@nocobase/plugin-ai 2.3.0-alpha.1 → 2.3.0-beta.10

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 (324) hide show
  1. package/dist/ai/docs/nocobase/ai-dev/watermark-plugin.md +2 -0
  2. package/dist/ai/docs/nocobase/ai-employees/block/ai-chat-box.md +133 -0
  3. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/documents.md +1 -1
  4. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/index.md +11 -7
  5. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/settings.md +12 -8
  6. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/rag.md +43 -13
  7. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-database.md +3 -3
  8. package/dist/ai/docs/nocobase/ai-employees/workflow/nodes/knowledge/create-document.md +1 -1
  9. package/dist/ai/docs/nocobase/api/app/env.md +2 -0
  10. package/dist/ai/docs/nocobase/api/cli/api/resource/create.md +4 -3
  11. package/dist/ai/docs/nocobase/building-tips/ai-fill-js-block-form.md +1092 -0
  12. package/dist/ai/docs/nocobase/data-sources/calendar/calendar-collection.md +100 -3
  13. package/dist/ai/docs/nocobase/data-sources/collection-comment/index.md +92 -39
  14. package/dist/ai/docs/nocobase/data-sources/collection-sql/index.md +150 -29
  15. package/dist/ai/docs/nocobase/data-sources/collection-tree/index.md +93 -5
  16. package/dist/ai/docs/nocobase/data-sources/collection-view/index.md +226 -4
  17. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/china-region.md +122 -5
  18. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/collection-select.md +105 -4
  19. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/json.md +102 -4
  20. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/nano-id.md +104 -4
  21. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/snowflake-id.md +108 -4
  22. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/sort.md +3 -19
  23. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/uuid.md +104 -4
  24. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/associations/index.md +44 -8
  25. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/color.md +102 -4
  26. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/email.md +104 -4
  27. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/icon.md +102 -4
  28. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/input.md +112 -8
  29. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/integer.md +103 -4
  30. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/number.md +103 -4
  31. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/password.md +102 -4
  32. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/percent.md +104 -5
  33. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/phone.md +104 -4
  34. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/textarea.md +99 -8
  35. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/url.md +103 -4
  36. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox-group.md +105 -3
  37. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox.md +102 -4
  38. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/china-region.md +108 -5
  39. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/multiple-select.md +103 -5
  40. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/radio-group.md +106 -4
  41. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/select.md +103 -5
  42. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/date.md +102 -4
  43. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime-without-tz.md +103 -5
  44. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime.md +103 -5
  45. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/index.md +53 -47
  46. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/time.md +102 -4
  47. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/unix-timestamp.md +103 -5
  48. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/circle.md +102 -4
  49. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/line.md +103 -5
  50. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/point.md +102 -4
  51. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/polygon.md +102 -4
  52. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/index.md +62 -16
  53. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/markdown.md +104 -4
  54. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/rich-text.md +105 -5
  55. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-at.md +105 -5
  56. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-by.md +103 -5
  57. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/space.md +100 -6
  58. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/table-oid.md +102 -4
  59. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-at.md +104 -5
  60. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-by.md +104 -6
  61. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/validation.md +68 -58
  62. package/dist/ai/docs/nocobase/data-sources/data-modeling/collection.md +32 -13
  63. package/dist/ai/docs/nocobase/data-sources/data-modeling/index.md +41 -33
  64. package/dist/ai/docs/nocobase/data-sources/data-source-external-mariadb/index.md +114 -6
  65. package/dist/ai/docs/nocobase/data-sources/data-source-external-mssql/index.md +117 -6
  66. package/dist/ai/docs/nocobase/data-sources/data-source-external-mysql/index.md +103 -6
  67. package/dist/ai/docs/nocobase/data-sources/data-source-external-nocobase/index.md +75 -73
  68. package/dist/ai/docs/nocobase/data-sources/data-source-external-oracle/index.md +129 -11
  69. package/dist/ai/docs/nocobase/data-sources/data-source-external-postgres/index.md +110 -6
  70. package/dist/ai/docs/nocobase/data-sources/data-source-kingbase/index.md +75 -49
  71. package/dist/ai/docs/nocobase/data-sources/data-source-main/general-collection.md +116 -15
  72. package/dist/ai/docs/nocobase/data-sources/data-source-main/index.md +92 -62
  73. package/dist/ai/docs/nocobase/data-sources/data-source-main/inheritance-collection.md +97 -10
  74. package/dist/ai/docs/nocobase/data-sources/data-source-manager/external-database.md +97 -58
  75. package/dist/ai/docs/nocobase/data-sources/data-source-manager/index.md +32 -24
  76. package/dist/ai/docs/nocobase/data-sources/data-source-rest-api/index.md +115 -153
  77. package/dist/ai/docs/nocobase/data-sources/external/clickhouse.md +124 -0
  78. package/dist/ai/docs/nocobase/data-sources/external/doris.md +130 -0
  79. package/dist/ai/docs/nocobase/data-sources/external/index.md +140 -0
  80. package/dist/ai/docs/nocobase/data-sources/external/kingbase.md +129 -0
  81. package/dist/ai/docs/nocobase/data-sources/external/mariadb.md +126 -0
  82. package/dist/ai/docs/nocobase/data-sources/external/mssql.md +129 -0
  83. package/dist/ai/docs/nocobase/data-sources/external/mysql.md +115 -0
  84. package/dist/ai/docs/nocobase/data-sources/external/nocobase.md +159 -0
  85. package/dist/ai/docs/nocobase/data-sources/external/oceanbase.md +126 -0
  86. package/dist/ai/docs/nocobase/data-sources/external/oracle.md +158 -0
  87. package/dist/ai/docs/nocobase/data-sources/external/postgresql.md +122 -0
  88. package/dist/ai/docs/nocobase/data-sources/external/rest-api.md +245 -0
  89. package/dist/ai/docs/nocobase/data-sources/field-attachment-url/index.md +100 -12
  90. package/dist/ai/docs/nocobase/data-sources/field-encryption/index.md +48 -47
  91. package/dist/ai/docs/nocobase/data-sources/field-formula/index.md +99 -5
  92. package/dist/ai/docs/nocobase/data-sources/field-markdown-vditor/index.md +105 -5
  93. package/dist/ai/docs/nocobase/data-sources/field-sequence/index.md +102 -5
  94. package/dist/ai/docs/nocobase/data-sources/field-signature/index.md +18 -16
  95. package/dist/ai/docs/nocobase/data-sources/field-sort/index.md +76 -73
  96. package/dist/ai/docs/nocobase/data-sources/file-manager/field-attachment.md +101 -7
  97. package/dist/ai/docs/nocobase/data-sources/file-manager/file-collection.md +101 -14
  98. package/dist/ai/docs/nocobase/data-sources/index.md +49 -33
  99. package/dist/ai/docs/nocobase/data-sources/main/index.md +130 -0
  100. package/dist/ai/docs/nocobase/data-sources/main/kingbase.md +147 -0
  101. package/dist/ai/docs/nocobase/data-sources/main/mariadb.md +59 -0
  102. package/dist/ai/docs/nocobase/data-sources/main/mysql.md +59 -0
  103. package/dist/ai/docs/nocobase/data-sources/main/oceanbase.md +62 -0
  104. package/dist/ai/docs/nocobase/data-sources/main/postgresql.md +61 -0
  105. package/dist/ai/docs/nocobase/file-manager/file-preview/index.md +44 -3
  106. package/dist/ai/docs/nocobase/file-manager/stable-url.md +1 -1
  107. package/dist/ai/docs/nocobase/file-manager/storage/aliyun-oss.md +100 -3
  108. package/dist/ai/docs/nocobase/file-manager/storage/index.md +76 -26
  109. package/dist/ai/docs/nocobase/file-manager/storage/local.md +4 -2
  110. package/dist/ai/docs/nocobase/file-manager/storage/s3-pro.md +58 -7
  111. package/dist/ai/docs/nocobase/get-started/installation/docker-nginx.mdx +4 -1
  112. package/dist/ai/docs/nocobase/get-started/installation/docker.mdx +2 -0
  113. package/dist/ai/docs/nocobase/get-started/installation/env.md +13 -1
  114. package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/caddy.md +28 -5
  115. package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/nginx.md +25 -0
  116. package/dist/ai/docs/nocobase/ops-management/migration-manager/built-in-tables.md +1 -2
  117. package/dist/ai/docs/nocobase/plugin-development/build.md +10 -4
  118. package/dist/ai/docs/nocobase/plugin-development/client/appendix/faq.md +1 -1
  119. package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-action.md +2 -0
  120. package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-block.md +2 -0
  121. package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-field.md +2 -0
  122. package/dist/ai/docs/nocobase/plugin-development/client/examples/fullstack-plugin.md +2 -0
  123. package/dist/ai/docs/nocobase/plugin-development/client/examples/settings-page.md +2 -0
  124. package/dist/ai/docs/nocobase/plugin-development/common/i18n.md +3 -3
  125. package/dist/ai/docs/nocobase/plugin-development/server/cache.md +1 -1
  126. package/dist/ai/docs/nocobase/plugin-development/server/collections.md +0 -6
  127. package/dist/ai/docs/nocobase/plugin-development/server/command.md +2 -2
  128. package/dist/ai/docs/nocobase/plugin-development/server/context.md +2 -2
  129. package/dist/ai/docs/nocobase/plugin-development/server/i18n.md +4 -4
  130. package/dist/ai/docs/nocobase/plugin-development/write-your-first-plugin.md +91 -43
  131. package/dist/ai/docs/nocobase/runjs/context/ai.md +194 -4
  132. package/dist/ai/docs/nocobase/security/guide.md +17 -2
  133. package/dist/ai/docs/nocobase/users-permissions/sync/index.md +8 -1
  134. package/dist/ai/docs/nocobase/users-permissions/sync/sources/dingtalk.md +138 -0
  135. package/dist/ai/docs/nocobase/users-permissions/sync/sources/ldap.md +87 -0
  136. package/dist/ai/docs/nocobase/workflow/nodes/javascript.md +21 -1
  137. package/dist/ai/tools/executeFrontendTool.d.ts +10 -0
  138. package/dist/ai/tools/executeFrontendTool.js +86 -0
  139. package/dist/ai/tools/getSkill.js +1 -1
  140. package/dist/ai/tools/knowledge-base-retrieve.js +3 -1
  141. package/dist/ai/tools/loadFrontendTool.d.ts +10 -0
  142. package/dist/ai/tools/loadFrontendTool.js +99 -0
  143. package/dist/client/244.aeb24ce76c510b34.js +10 -0
  144. package/dist/client/{525.203778500aca5d05.js → 525.94dd4136c1361477.js} +1 -1
  145. package/dist/client/681.6ffbc9329b9ac242.js +10 -0
  146. package/dist/client/705.1d735e63c25f66a8.js +10 -0
  147. package/dist/client/index.d.ts +1 -3
  148. package/dist/client/index.js +8 -8
  149. package/dist/client-v2/244.ee9ec45eac0eb99f.js +10 -0
  150. package/dist/client-v2/420.a5b929a5e7f330be.js +10 -0
  151. package/dist/client-v2/681.6890caa389564ff7.js +10 -0
  152. package/dist/client-v2/705.00c101bef403fb44.js +10 -0
  153. package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +2 -0
  154. package/dist/client-v2/ai-employees/AddContextButton.d.ts +2 -0
  155. package/dist/client-v2/ai-employees/chatbox/components/AIEmployeeSwitcher.d.ts +1 -0
  156. package/dist/client-v2/ai-employees/chatbox/components/ChatBoxUnreadBadge.d.ts +17 -0
  157. package/dist/client-v2/ai-employees/chatbox/components/Conversations.d.ts +9 -1
  158. package/dist/client-v2/ai-employees/chatbox/components/MessageRenderers.d.ts +1 -1
  159. package/dist/client-v2/ai-employees/chatbox/components/Messages.d.ts +5 -1
  160. package/dist/client-v2/ai-employees/chatbox/components/ModelSwitcher.d.ts +4 -0
  161. package/dist/client-v2/ai-employees/chatbox/components/Sender.d.ts +33 -1
  162. package/dist/client-v2/ai-employees/chatbox/components/index.d.ts +1 -0
  163. package/dist/client-v2/ai-employees/chatbox/hooks/reasoning-stream.d.ts +10 -0
  164. package/dist/client-v2/ai-employees/chatbox/hooks/useChat.d.ts +8 -5
  165. package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +3 -2
  166. package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxEffect.d.ts +2 -1
  167. package/dist/client-v2/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +3 -2
  168. package/dist/client-v2/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +4 -2
  169. package/dist/client-v2/ai-employees/chatbox/hooks/useToolCallActions.d.ts +3 -1
  170. package/dist/client-v2/ai-employees/chatbox/hooks/useUploadFiles.d.ts +13 -3
  171. package/dist/client-v2/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +3 -2
  172. package/dist/client-v2/ai-employees/chatbox/index.d.ts +17 -0
  173. package/dist/client-v2/ai-employees/chatbox/roles.d.ts +2 -153
  174. package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +46 -33
  175. package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +7 -7
  176. package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +23 -18
  177. package/dist/client-v2/ai-employees/chatbox/stores/chat-sender.d.ts +43 -0
  178. package/dist/client-v2/ai-employees/chatbox/stores/chat-tool-call.d.ts +6 -5
  179. package/dist/client-v2/ai-employees/chatbox/stores/chat-tools.d.ts +11 -5
  180. package/dist/client-v2/ai-employees/chatbox/stores/mounted-chat-boxes.d.ts +20 -0
  181. package/dist/client-v2/ai-employees/chatbox/stores/runtime.d.ts +43 -0
  182. package/dist/client-v2/ai-employees/chatbox/stores/workflow-tasks.d.ts +22 -10
  183. package/dist/client-v2/ai-employees/chatbox/upload.d.ts +19 -0
  184. package/dist/client-v2/ai-employees/chatbox/utils.d.ts +28 -4
  185. package/dist/client-v2/ai-employees/frontend-tools.d.ts +11 -0
  186. package/dist/client-v2/ai-employees/tools/SuggestionsOptionsCard.d.ts +1 -1
  187. package/dist/client-v2/ai-employees/tools/WorkflowTaskOutputCard.d.ts +1 -1
  188. package/dist/client-v2/ai-employees/types.d.ts +30 -0
  189. package/dist/client-v2/block/ai-chat-box/AIChatBoxBlockModel.d.ts +21 -0
  190. package/dist/client-v2/block/ai-chat-box/AIChatBoxCoreModel.d.ts +13 -0
  191. package/dist/client-v2/{ai-employees/chatbox/components/DebugPanel.d.ts → block/ai-chat-box/components/AIChatBoxCoreView.d.ts} +1 -1
  192. package/dist/client-v2/block/ai-chat-box/components/AIChatBoxView.d.ts +12 -0
  193. package/dist/client-v2/block/ai-chat-box/index.d.ts +14 -0
  194. package/dist/client-v2/block/ai-chat-box/settings.d.ts +12 -0
  195. package/dist/client-v2/block/ai-chat-box/sub-models.d.ts +26 -0
  196. package/dist/client-v2/block/ai-chat-box/types.d.ts +38 -0
  197. package/dist/client-v2/block/ai-chat-box/utils.d.ts +26 -0
  198. package/dist/client-v2/index.d.ts +3 -5
  199. package/dist/client-v2/index.js +3 -3
  200. package/dist/client-v2/llm-providers/forms.d.ts +2 -0
  201. package/dist/client-v2/llm-providers/index.d.ts +1 -0
  202. package/dist/client-v2/llm-services/model-select.d.ts +33 -0
  203. package/dist/client-v2/llm-services/utils.d.ts +1 -0
  204. package/dist/client-v2/manager/ai-manager.d.ts +10 -3
  205. package/dist/client-v2/manager/frontend-tool-registry.d.ts +30 -0
  206. package/dist/client-v2/models/ai-employees/AIEmployeeActionModel.d.ts +4 -1
  207. package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +8 -0
  208. package/dist/client-v2/pages/EmployeesPage.d.ts +12 -0
  209. package/dist/client-v2/pages/LLMServicesPage.d.ts +9 -4
  210. package/dist/client-v2/repositories/AIConfigRepository.d.ts +2 -0
  211. package/dist/client-v2/runjs/registerAIEmployeeRunJSFacade.d.ts +1 -0
  212. package/dist/client-v2/workflow/types.d.ts +1 -0
  213. package/dist/collections/ai-employees.d.ts +1 -0
  214. package/dist/collections/ai-employees.js +1 -0
  215. package/dist/common/ai-employee-validation.d.ts +17 -0
  216. package/dist/common/ai-employee-validation.js +67 -0
  217. package/dist/common/error-codes.d.ts +14 -0
  218. package/dist/common/error-codes.js +51 -0
  219. package/dist/common/frontend-tools.d.ts +26 -0
  220. package/dist/common/frontend-tools.js +57 -0
  221. package/dist/common/llm-service-models.d.ts +16 -0
  222. package/dist/common/llm-service-models.js +84 -0
  223. package/dist/externalVersion.js +19 -17
  224. package/dist/locale/de-DE.json +2 -1
  225. package/dist/locale/en-US.json +87 -5
  226. package/dist/locale/es-ES.json +2 -1
  227. package/dist/locale/fr-FR.json +2 -1
  228. package/dist/locale/hu-HU.json +2 -1
  229. package/dist/locale/id-ID.json +2 -1
  230. package/dist/locale/it-IT.json +2 -1
  231. package/dist/locale/ja-JP.json +2 -1
  232. package/dist/locale/ko-KR.json +2 -1
  233. package/dist/locale/nl-NL.json +2 -1
  234. package/dist/locale/pt-BR.json +2 -1
  235. package/dist/locale/ru-RU.json +2 -1
  236. package/dist/locale/tr-TR.json +2 -1
  237. package/dist/locale/uk-UA.json +2 -1
  238. package/dist/locale/vi-VN.json +2 -1
  239. package/dist/locale/zh-CN.json +87 -5
  240. package/dist/locale/zh-TW.json +2 -1
  241. package/dist/node_modules/@langchain/mistralai/package.json +1 -1
  242. package/dist/node_modules/@langchain/xai/package.json +1 -1
  243. package/dist/node_modules/fs-extra/package.json +1 -1
  244. package/dist/node_modules/jsonrepair/package.json +1 -1
  245. package/dist/node_modules/just-bash/package.json +1 -1
  246. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  247. package/dist/node_modules/openai/package.json +1 -1
  248. package/dist/node_modules/zod/package.json +1 -1
  249. package/dist/server/ai-employees/ai-conversations.d.ts +4 -1
  250. package/dist/server/ai-employees/ai-conversations.js +2 -0
  251. package/dist/server/ai-employees/ai-employee.d.ts +32 -2
  252. package/dist/server/ai-employees/ai-employee.js +367 -79
  253. package/dist/server/ai-employees/ai-knowledge-base.d.ts +21 -1
  254. package/dist/server/ai-employees/ai-knowledge-base.js +87 -12
  255. package/dist/server/ai-employees/middleware/conversation.js +28 -22
  256. package/dist/server/ai-employees/middleware/index.d.ts +1 -0
  257. package/dist/server/ai-employees/middleware/index.js +2 -0
  258. package/dist/server/ai-employees/middleware/tool-result-integrity.d.ts +22 -0
  259. package/dist/server/ai-employees/middleware/tool-result-integrity.js +211 -0
  260. package/dist/server/ai-employees/reasoning-stream-state.d.ts +23 -0
  261. package/dist/server/ai-employees/reasoning-stream-state.js +63 -0
  262. package/dist/server/collections/ai-conversations.js +5 -0
  263. package/dist/server/document-loader/constants.js +1 -1
  264. package/dist/server/features/knowledge-base.d.ts +2 -0
  265. package/dist/server/frontend-tools.d.ts +25 -0
  266. package/dist/server/frontend-tools.js +171 -0
  267. package/dist/server/llm-providers/common/reasoning.js +18 -10
  268. package/dist/server/llm-providers/deepseek/index.d.ts +10 -0
  269. package/dist/server/llm-providers/deepseek/index.js +32 -0
  270. package/dist/server/llm-providers/deepseek/provider.d.ts +57 -0
  271. package/dist/server/llm-providers/deepseek/provider.js +320 -0
  272. package/dist/server/llm-providers/deepseek/reasoning.d.ts +83 -0
  273. package/dist/server/llm-providers/deepseek/reasoning.js +285 -0
  274. package/dist/server/llm-providers/mistral.d.ts +1 -1
  275. package/dist/server/llm-providers/provider.d.ts +1 -0
  276. package/dist/server/llm-providers/provider.js +3 -0
  277. package/dist/server/llm-providers/shengsuanyun.d.ts +29 -0
  278. package/dist/server/llm-providers/shengsuanyun.js +114 -0
  279. package/dist/server/manager/ai-feature-manager.js +1 -1
  280. package/dist/server/manager/ai-manager.d.ts +3 -0
  281. package/dist/server/manager/ai-manager.js +7 -2
  282. package/dist/server/manager/work-context-handler.js +10 -3
  283. package/dist/server/migrations/20260501000000-ai-employee-knowledge-base-retrieval-strategy.d.ts +14 -0
  284. package/dist/server/migrations/20260501000000-ai-employee-knowledge-base-retrieval-strategy.js +49 -0
  285. package/dist/server/plugin.d.ts +1 -0
  286. package/dist/server/plugin.js +31 -0
  287. package/dist/server/resource/aiConversations.d.ts +2 -0
  288. package/dist/server/resource/aiConversations.js +33 -3
  289. package/dist/server/resource/aiEmployees.d.ts +2 -0
  290. package/dist/server/resource/aiEmployees.js +96 -0
  291. package/dist/server/resource/aiWorkflowTasks.js +9 -1
  292. package/dist/server/resource/llmServices.d.ts +11 -0
  293. package/dist/server/resource/llmServices.js +85 -0
  294. package/dist/server/types/ai-message.type.d.ts +4 -0
  295. package/dist/server/types/knowledge-base.type.d.ts +8 -3
  296. package/dist/server/workflow/nodes/employee/files.d.ts +1 -1
  297. package/dist/server/workflow/nodes/employee/files.js +48 -1
  298. package/dist/server/workflow/nodes/employee/index.js +7 -2
  299. package/dist/server/workflow/nodes/employee/types.d.ts +1 -0
  300. package/dist/swagger/common.d.ts +143 -0
  301. package/dist/swagger/common.js +144 -0
  302. package/dist/swagger/employees.d.ts +301 -0
  303. package/dist/swagger/employees.js +131 -0
  304. package/dist/swagger/index.d.ts +1617 -0
  305. package/dist/swagger/index.js +62 -0
  306. package/dist/swagger/llm.d.ts +563 -0
  307. package/dist/swagger/llm.js +255 -0
  308. package/dist/swagger/schemas.d.ts +757 -0
  309. package/dist/swagger/schemas.js +392 -0
  310. package/package.json +2 -2
  311. package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-store.md +0 -24
  312. package/dist/ai/docs/nocobase/data-sources/development/index.md +0 -6
  313. package/dist/client/372.40eb52905e3f3049.js +0 -10
  314. package/dist/client/681.399948c18d753667.js +0 -10
  315. package/dist/client/705.380279da896021fb.js +0 -10
  316. package/dist/client-v2/372.8cc3fde09c9bec77.js +0 -10
  317. package/dist/client-v2/406.341be51205c674e0.js +0 -10
  318. package/dist/client-v2/681.082f4f1c7b841983.js +0 -10
  319. package/dist/client-v2/705.1d10027ff8cfdf79.js +0 -10
  320. package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +0 -46
  321. package/dist/client-v2/ai-employees/chatbox/utils/normalizeTriggerTaskOptions.d.ts +0 -19
  322. package/dist/client-v2/debug-logger.d.ts +0 -52
  323. package/dist/server/llm-providers/deepseek.d.ts +0 -40
  324. package/dist/server/llm-providers/deepseek.js +0 -174
@@ -0,0 +1,49 @@
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 ai_employee_knowledge_base_retrieval_strategy_exports = {};
28
+ __export(ai_employee_knowledge_base_retrieval_strategy_exports, {
29
+ default: () => ai_employee_knowledge_base_retrieval_strategy_default
30
+ });
31
+ module.exports = __toCommonJS(ai_employee_knowledge_base_retrieval_strategy_exports);
32
+ var import_server = require("@nocobase/server");
33
+ var import_ai_knowledge_base = require("../ai-employees/ai-knowledge-base");
34
+ const getKnowledgeBaseSettings = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? { ...value } : {};
35
+ class ai_employee_knowledge_base_retrieval_strategy_default extends import_server.Migration {
36
+ on = "afterSync";
37
+ appVersion = "<3.0.0";
38
+ async up() {
39
+ const repository = this.db.getRepository("aiEmployees");
40
+ const employees = await repository.find();
41
+ for (const employee of employees) {
42
+ const knowledgeBase = getKnowledgeBaseSettings(employee.get("knowledgeBase"));
43
+ if ((0, import_ai_knowledge_base.isKnowledgeBaseRetrievalStrategy)(knowledgeBase.retrievalStrategy)) {
44
+ continue;
45
+ }
46
+ await employee.update({ knowledgeBase: { ...knowledgeBase, retrievalStrategy: "always" } });
47
+ }
48
+ }
49
+ }
@@ -62,6 +62,7 @@ export declare class PluginAIServer extends Plugin {
62
62
  get repositories(): {
63
63
  aiContextDatasources: import("@nocobase/database").Repository<any, any>;
64
64
  };
65
+ private registerAIFileAccessAuthorizer;
65
66
  get fileManager(): PluginFileManagerServer;
66
67
  private repository;
67
68
  }
@@ -56,6 +56,7 @@ var import_ai_employees_manager = require("./ai-employees/ai-employees-manager")
56
56
  var import_ai_conversations = require("./ai-employees/ai-conversations");
57
57
  var import_snowflake = __toESM(require("./snowflake"));
58
58
  var aiEmployeeActions = __toESM(require("./resource/aiEmployees"));
59
+ var llmServiceActions = __toESM(require("./resource/llmServices"));
59
60
  var import_google_genai = require("./llm-providers/google-genai");
60
61
  var import_ai_employee = require("./workflow/triggers/ai-employee");
61
62
  var import_tools = require("./tools");
@@ -76,11 +77,13 @@ var import_checkpoints = require("./ai-employees/checkpoints");
76
77
  var import_mimo = require("./llm-providers/mimo");
77
78
  var import_mistral = require("./llm-providers/mistral");
78
79
  var import_orcarouter = require("./llm-providers/orcarouter");
80
+ var import_shengsuanyun = require("./llm-providers/shengsuanyun");
79
81
  var import_sub_agents = require("./ai-employees/sub-agents");
80
82
  var import_employee = require("./workflow/nodes/employee");
81
83
  var import_ai_knowledge_base = require("./ai-employees/ai-knowledge-base");
82
84
  var import_llm_stream_manager = require("./manager/llm-stream-manager");
83
85
  var import_attachments = require("./attachments");
86
+ var import_ai_knowledge_base2 = require("./ai-employees/ai-knowledge-base");
84
87
  class PluginAIServer extends import_server.Plugin {
85
88
  features = new import_ai_feature_manager.AIPluginFeatureManagerImpl();
86
89
  aiManager = new import_ai_manager.AIManager(this);
@@ -134,6 +137,9 @@ class PluginAIServer extends import_server.Plugin {
134
137
  this.app.on("afterUpgrade", async () => {
135
138
  await this.resetConversationThreadsWhenCheckpointsEmpty();
136
139
  });
140
+ this.db.on("aiEmployees.beforeCreate", (employee) => {
141
+ employee.set("knowledgeBase", (0, import_ai_knowledge_base2.withDefaultKnowledgeBaseRetrievalStrategy)(employee.get("knowledgeBase")));
142
+ });
137
143
  }
138
144
  async resetConversationThreadsWhenCheckpointsEmpty() {
139
145
  const [checkpointCount, checkpointWriteCount, checkpointBlobCount, conversationsWithThreadCount] = await Promise.all([
@@ -169,6 +175,7 @@ class PluginAIServer extends import_server.Plugin {
169
175
  this.defineResources();
170
176
  this.registerMcpClientEvents();
171
177
  this.setPermissions();
178
+ this.registerAIFileAccessAuthorizer();
172
179
  this.registerWorkflow();
173
180
  this.registerWorkContextResolveStrategy();
174
181
  (0, import_employee.registerAIEmployeeTaskNotification)(this);
@@ -189,6 +196,7 @@ class PluginAIServer extends import_server.Plugin {
189
196
  this.aiManager.registerLLMProvider("kimi", import_kimi.kimiProviderOptions);
190
197
  this.aiManager.registerLLMProvider("xai", import_xai.xaiProviderOptions);
191
198
  this.aiManager.registerLLMProvider("orcarouter", import_orcarouter.orcarouterProviderOptions);
199
+ this.aiManager.registerLLMProvider("shengsuanyun", import_shengsuanyun.shengsuanyunProviderOptions);
192
200
  }
193
201
  registerTools() {
194
202
  const toolsManager = this.ai.toolsManager;
@@ -235,6 +243,9 @@ class PluginAIServer extends import_server.Plugin {
235
243
  Object.entries(aiEmployeeActions).forEach(([name, action]) => {
236
244
  this.app.resourceManager.registerActionHandler(`aiEmployees:${name}`, action);
237
245
  });
246
+ Object.entries(llmServiceActions).forEach(([name, action]) => {
247
+ this.app.resourceManager.registerActionHandler(`llmServices:${name}`, action);
248
+ });
238
249
  }
239
250
  registerMcpClientEvents() {
240
251
  this.db.on("aiMcpClients.afterCreate", (model, { transaction } = {}) => {
@@ -370,6 +381,26 @@ class PluginAIServer extends import_server.Plugin {
370
381
  aiContextDatasources: this.repository("aiContextDatasources")
371
382
  };
372
383
  }
384
+ registerAIFileAccessAuthorizer() {
385
+ this.fileManager.registerFileAccessAuthorizer({
386
+ name: "ai-files",
387
+ authorize: async (ctx, params) => {
388
+ var _a;
389
+ const currentUserId = (_a = ctx.state.currentUser) == null ? void 0 : _a.id;
390
+ if (params.dataSourceKey !== "main" || params.collectionName !== "aiFiles" || !currentUserId) {
391
+ return false;
392
+ }
393
+ const file = await ctx.db.getRepository("aiFiles").findOne({
394
+ filter: {
395
+ id: params.id,
396
+ createdById: currentUserId
397
+ },
398
+ fields: ["id"]
399
+ });
400
+ return Boolean(file);
401
+ }
402
+ });
403
+ }
373
404
  get fileManager() {
374
405
  return this.app.pm.get("file-manager");
375
406
  }
@@ -7,6 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Context, Next } from '@nocobase/actions';
10
+ import { Model } from '@nocobase/database';
11
+ export declare function isAIEmployeeEnabled(employee: Model | null | undefined): boolean;
10
12
  declare function loginInCheck(ctx: Context, next: Next): Promise<never>;
11
13
  declare const _default: {
12
14
  name: string;
@@ -36,7 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var aiConversations_exports = {};
38
38
  __export(aiConversations_exports, {
39
- default: () => aiConversations_default
39
+ default: () => aiConversations_default,
40
+ isAIEmployeeEnabled: () => isAIEmployeeEnabled
40
41
  });
41
42
  module.exports = __toCommonJS(aiConversations_exports);
42
43
  var import_actions = __toESM(require("@nocobase/actions"));
@@ -44,6 +45,8 @@ var import_database = require("@nocobase/database");
44
45
  var import_utils = require("../utils");
45
46
  var import_ai_employee = require("../ai-employees/ai-employee");
46
47
  var import_ai_chat_conversation = require("../manager/ai-chat-conversation");
48
+ var import_frontend_tools = require("../../common/frontend-tools");
49
+ var import_frontend_tools2 = require("../frontend-tools");
47
50
  async function getAIEmployee(ctx, username) {
48
51
  var _a;
49
52
  const filter = {
@@ -57,6 +60,10 @@ async function getAIEmployee(ctx, username) {
57
60
  });
58
61
  return employee;
59
62
  }
63
+ function isAIEmployeeEnabled(employee) {
64
+ var _a;
65
+ return ((_a = employee == null ? void 0 : employee.get) == null ? void 0 : _a.call(employee, "enabled")) !== false;
66
+ }
60
67
  function setupSSEHeaders(ctx) {
61
68
  ctx.set({
62
69
  "Content-Type": "text/event-stream",
@@ -142,12 +149,14 @@ var aiConversations_default = {
142
149
  var _a;
143
150
  const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
144
151
  const filter = ctx.action.params.filter || {};
152
+ const scope = ctx.action.params.scope;
145
153
  ctx.action.mergeParams({
146
154
  filter: {
147
155
  ...filter,
148
156
  userId,
149
157
  from: filter.from ?? "main-agent",
150
- category: "chat"
158
+ category: "chat",
159
+ ...typeof scope === "string" && scope ? { scope } : {}
151
160
  }
152
161
  });
153
162
  return import_actions.default.list(ctx, next);
@@ -197,15 +206,20 @@ var aiConversations_default = {
197
206
  var _a;
198
207
  const plugin = ctx.app.pm.get("ai");
199
208
  const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
200
- const { aiEmployee, systemMessage, skillSettings, conversationSettings, modelSettings } = ctx.action.params.values || {};
209
+ const { aiEmployee, systemMessage, skillSettings, conversationSettings, modelSettings, scope } = ctx.action.params.values || {};
210
+ const normalizedScope = typeof scope === "string" ? scope : void 0;
201
211
  const employee = await getAIEmployee(ctx, aiEmployee.username);
202
212
  if (!employee) {
203
213
  ctx.throw(400, "AI employee not found");
204
214
  }
215
+ if (!isAIEmployeeEnabled(employee)) {
216
+ ctx.throw(400, "AI employee is disabled");
217
+ }
205
218
  try {
206
219
  ctx.body = await plugin.aiConversationsManager.create({
207
220
  userId,
208
221
  aiEmployee,
222
+ scope: normalizedScope,
209
223
  options: {
210
224
  systemMessage,
211
225
  skillSettings,
@@ -672,6 +686,17 @@ var aiConversations_default = {
672
686
  if (!(toolCalls == null ? void 0 : toolCalls.length)) {
673
687
  ctx.throw(400);
674
688
  }
689
+ const selectedToolCall = toolCalls.find((toolCall2) => toolCall2.id === toolCallId);
690
+ if (!selectedToolCall) {
691
+ ctx.throw(400);
692
+ }
693
+ if (selectedToolCall.name === import_frontend_tools.EXECUTE_FRONTEND_TOOL_NAME) {
694
+ const toolId = isRecord(selectedToolCall.args) ? selectedToolCall.args.toolId : void 0;
695
+ const frontendTool = typeof toolId === "string" ? await (0, import_frontend_tools2.findCurrentFrontendTool)(ctx, toolId, message.sessionId) : void 0;
696
+ if (!frontendTool) {
697
+ ctx.throw(400, ctx.t("Frontend tool is unavailable"));
698
+ }
699
+ }
675
700
  const aiToolMessagesModel = ctx.db.getModel("aiToolMessages");
676
701
  const toolCall = await aiToolMessagesModel.findOne({
677
702
  where: { sessionId: message.sessionId, messageId: message.messageId, toolCallId }
@@ -715,6 +740,7 @@ var aiConversations_default = {
715
740
  toolCall2.auto = toolMessage == null ? void 0 : toolMessage.auto;
716
741
  toolCall2.status = toolMessage == null ? void 0 : toolMessage.status;
717
742
  toolCall2.content = toolMessage == null ? void 0 : toolMessage.content;
743
+ toolCall2.userDecision = toolMessage == null ? void 0 : toolMessage.userDecision;
718
744
  toolCall2.execution = tools == null ? void 0 : tools.execution;
719
745
  toolCall2.willInterrupt = (tools == null ? void 0 : tools.execution) === "frontend" || (toolMessage == null ? void 0 : toolMessage.auto) === false;
720
746
  toolCall2.defaultPermission = tools == null ? void 0 : tools.defaultPermission;
@@ -801,3 +827,7 @@ var aiConversations_default = {
801
827
  }
802
828
  }
803
829
  };
830
+ // Annotate the CommonJS export names for ESM import in node:
831
+ 0 && (module.exports = {
832
+ isAIEmployeeEnabled
833
+ });
@@ -7,6 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Context, Next } from '@nocobase/actions';
10
+ export declare const create: (ctx: Context, next: Next) => Promise<void>;
11
+ export declare const update: (ctx: Context, next: Next) => Promise<void>;
10
12
  export declare const list: (ctx: Context, next: Next) => Promise<void>;
11
13
  export declare const listByUser: (ctx: Context, next: Next) => Promise<any>;
12
14
  export declare const updateUserPrompt: (ctx: Context, next: Next) => Promise<any>;
@@ -36,16 +36,110 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var aiEmployees_exports = {};
38
38
  __export(aiEmployees_exports, {
39
+ create: () => create,
39
40
  getTemplates: () => getTemplates,
40
41
  list: () => list,
41
42
  listByUser: () => listByUser,
43
+ update: () => update,
42
44
  updateUserPrompt: () => updateUserPrompt
43
45
  });
44
46
  module.exports = __toCommonJS(aiEmployees_exports);
45
47
  var import_actions = __toESM(require("@nocobase/actions"));
48
+ var import_database = require("@nocobase/database");
46
49
  var templates = __toESM(require("../ai-employees/templates"));
47
50
  var import_lodash = __toESM(require("lodash"));
48
51
  var import_ai_feature_manager = require("../manager/ai-feature-manager");
52
+ var import_error_codes = require("../../common/error-codes");
53
+ var import_ai_employee_validation = require("../../common/ai-employee-validation");
54
+ var import_ai_knowledge_base = require("../ai-employees/ai-knowledge-base");
55
+ const isUniqueConstraintError = (error) => error instanceof import_database.UniqueConstraintError || typeof error === "object" && error !== null && "name" in error && error.name === "SequelizeUniqueConstraintError";
56
+ const throwUsernameConflict = (ctx) => ctx.throw(409, {
57
+ code: import_error_codes.AI_EMPLOYEE_USERNAME_CONFLICT,
58
+ message: ctx.t("Username already exists")
59
+ });
60
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
61
+ const validateAndNormalizeProfileValues = (ctx) => {
62
+ const values = ctx.action.params.values;
63
+ if (!isRecord(values)) {
64
+ return;
65
+ }
66
+ if ("username" in values) {
67
+ if (typeof values.username !== "string" || !(0, import_ai_employee_validation.isValidAIEmployeeUsername)(values.username)) {
68
+ ctx.throw(400, {
69
+ code: import_error_codes.AI_EMPLOYEE_USERNAME_INVALID,
70
+ message: ctx.t("Use 1-64 letters, numbers, underscores, or hyphens.")
71
+ });
72
+ }
73
+ values.username = (0, import_ai_employee_validation.normalizeAIEmployeeName)(values.username);
74
+ }
75
+ if ("nickname" in values) {
76
+ if (typeof values.nickname !== "string" || !(0, import_ai_employee_validation.isValidAIEmployeeNickname)(values.nickname)) {
77
+ ctx.throw(400, {
78
+ code: import_error_codes.AI_EMPLOYEE_NICKNAME_INVALID,
79
+ message: ctx.t("Use 1-64 letters, numbers, spaces, or . _ - ' ( ) & \xB7.")
80
+ });
81
+ }
82
+ values.nickname = (0, import_ai_employee_validation.normalizeAIEmployeeName)(values.nickname);
83
+ }
84
+ };
85
+ const setDefaultKnowledgeBaseRetrievalStrategy = (ctx) => {
86
+ const values = ctx.action.params.values;
87
+ if (isRecord(values)) {
88
+ values.knowledgeBase = (0, import_ai_knowledge_base.withDefaultKnowledgeBaseRetrievalStrategy)(values.knowledgeBase);
89
+ }
90
+ };
91
+ const readEmployeeValue = (employee, key) => typeof (employee == null ? void 0 : employee.get) === "function" ? employee.get(key) : employee == null ? void 0 : employee[key];
92
+ const validateKnowledgeBasePrompt = (ctx, employee) => {
93
+ const values = ctx.action.params.values;
94
+ if (!isRecord(values)) {
95
+ return;
96
+ }
97
+ const enableKnowledgeBase = typeof values.enableKnowledgeBase === "boolean" ? values.enableKnowledgeBase : readEmployeeValue(employee, "enableKnowledgeBase") === true;
98
+ const knowledgeBasePrompt = "knowledgeBasePrompt" in values ? values.knowledgeBasePrompt : readEmployeeValue(employee, "knowledgeBasePrompt");
99
+ if (enableKnowledgeBase && !(0, import_ai_employee_validation.hasKnowledgeBaseDataPlaceholder)(knowledgeBasePrompt)) {
100
+ ctx.throw(400, {
101
+ code: import_error_codes.AI_EMPLOYEE_KNOWLEDGE_BASE_PROMPT_INVALID,
102
+ message: ctx.t("The Knowledge Base Prompt must include {knowledgeBaseData} before you can save it."),
103
+ data: { field: "knowledgeBasePrompt" }
104
+ });
105
+ }
106
+ };
107
+ const hasKnowledgeBaseConfigurationChanges = (values) => isRecord(values) && ["enableKnowledgeBase", "knowledgeBase", "knowledgeBasePrompt"].some(
108
+ (key) => Object.prototype.hasOwnProperty.call(values, key)
109
+ );
110
+ const create = async (ctx, next) => {
111
+ var _a;
112
+ validateAndNormalizeProfileValues(ctx);
113
+ setDefaultKnowledgeBaseRetrievalStrategy(ctx);
114
+ validateKnowledgeBasePrompt(ctx);
115
+ const username = (_a = ctx.action.params.values) == null ? void 0 : _a.username;
116
+ if (typeof username === "string") {
117
+ const existingEmployee = await ctx.db.getRepository("aiEmployees").findOne({
118
+ filter: { username }
119
+ });
120
+ if (existingEmployee) {
121
+ throwUsernameConflict(ctx);
122
+ }
123
+ }
124
+ try {
125
+ await import_actions.default.create(ctx, next);
126
+ } catch (error) {
127
+ if (isUniqueConstraintError(error)) {
128
+ throwUsernameConflict(ctx);
129
+ }
130
+ throw error;
131
+ }
132
+ };
133
+ const update = async (ctx, next) => {
134
+ validateAndNormalizeProfileValues(ctx);
135
+ if (hasKnowledgeBaseConfigurationChanges(ctx.action.params.values)) {
136
+ const employee = await ctx.db.getRepository("aiEmployees").findOne({
137
+ filterByTk: ctx.action.params.filterByTk
138
+ });
139
+ validateKnowledgeBasePrompt(ctx, employee);
140
+ }
141
+ await import_actions.default.update(ctx, next);
142
+ };
49
143
  const list = async (ctx, next) => {
50
144
  var _a, _b;
51
145
  const { paginate } = ctx.action.params || {};
@@ -227,8 +321,10 @@ const getTemplates = async (ctx, next) => {
227
321
  };
228
322
  // Annotate the CommonJS export names for ESM import in node:
229
323
  0 && (module.exports = {
324
+ create,
230
325
  getTemplates,
231
326
  list,
232
327
  listByUser,
328
+ update,
233
329
  updateUserPrompt
234
330
  });
@@ -129,7 +129,7 @@ const aiWorkflowTasks = {
129
129
  await next();
130
130
  },
131
131
  getBySession: async (ctx, next) => {
132
- var _a, _b, _c, _d, _e;
132
+ var _a, _b, _c, _d, _e, _f;
133
133
  const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
134
134
  if (!userId) {
135
135
  return ctx.throw(403);
@@ -158,12 +158,20 @@ const aiWorkflowTasks = {
158
158
  id: task.nodeId
159
159
  }
160
160
  });
161
+ const conversation = await ctx.db.getRepository("aiConversations").findOne({
162
+ filter: {
163
+ sessionId
164
+ },
165
+ appends: ["aiEmployee"]
166
+ });
167
+ const aiEmployee = conversation == null ? void 0 : conversation.aiEmployee;
161
168
  const readonly = task.status !== "pending_approval" || task.acceptedUserId !== userId;
162
169
  ctx.body = {
163
170
  ...((_c = task == null ? void 0 : task.toJSON) == null ? void 0 : _c.call(task)) ?? task,
164
171
  read: (usersAiWorkflowTasks == null ? void 0 : usersAiWorkflowTasks.read) ?? true,
165
172
  config: (node == null ? void 0 : node.config) ?? null,
166
173
  structuredOutputSchema: ((_e = (_d = node == null ? void 0 : node.config) == null ? void 0 : _d.structuredOutput) == null ? void 0 : _e.schema) ?? null,
174
+ aiEmployee: ((_f = aiEmployee == null ? void 0 : aiEmployee.toJSON) == null ? void 0 : _f.call(aiEmployee)) ?? aiEmployee ?? null,
167
175
  readonly
168
176
  };
169
177
  await next();
@@ -0,0 +1,11 @@
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
+ import { Context, Next } from '@nocobase/actions';
10
+ export declare const create: (ctx: Context, next: Next) => Promise<void>;
11
+ export declare const update: (ctx: Context, next: Next) => Promise<void>;
@@ -0,0 +1,85 @@
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 __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var llmServices_exports = {};
38
+ __export(llmServices_exports, {
39
+ create: () => create,
40
+ update: () => update
41
+ });
42
+ module.exports = __toCommonJS(llmServices_exports);
43
+ var import_actions = __toESM(require("@nocobase/actions"));
44
+ var import_package = require("../../../package.json");
45
+ var import_error_codes = require("../../common/error-codes");
46
+ var import_llm_service_models = require("../../common/llm-service-models");
47
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
48
+ const validateAndNormalizeEnabledModels = (ctx) => {
49
+ const values = ctx.action.params.values;
50
+ if (!isRecord(values) || !("enabledModels" in values)) {
51
+ return;
52
+ }
53
+ const enabledModels = (0, import_llm_service_models.normalizeCustomModelIds)(values.enabledModels);
54
+ const issue = (0, import_llm_service_models.getCustomModelIdIssues)(enabledModels)[0];
55
+ if (issue) {
56
+ const required = issue.type === "required";
57
+ ctx.throw(400, {
58
+ code: required ? import_error_codes.LLM_SERVICE_MODEL_ID_REQUIRED : import_error_codes.LLM_SERVICE_MODEL_ID_DUPLICATE,
59
+ message: ctx.t(required ? "Model ID is required" : "Model ID already exists", { ns: import_package.name }),
60
+ data: { index: issue.index }
61
+ });
62
+ }
63
+ ctx.action.mergeParams(
64
+ {
65
+ values: {
66
+ ...values,
67
+ enabledModels
68
+ }
69
+ },
70
+ { values: "overwrite" }
71
+ );
72
+ };
73
+ const create = async (ctx, next) => {
74
+ validateAndNormalizeEnabledModels(ctx);
75
+ await import_actions.default.create(ctx, next);
76
+ };
77
+ const update = async (ctx, next) => {
78
+ validateAndNormalizeEnabledModels(ctx);
79
+ await import_actions.default.update(ctx, next);
80
+ };
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ create,
84
+ update
85
+ });
@@ -27,6 +27,10 @@ export type WorkContext = {
27
27
  export type AIMessageContent = {
28
28
  type: string;
29
29
  content: unknown;
30
+ reference?: {
31
+ title: string;
32
+ url: string;
33
+ }[];
30
34
  };
31
35
  export type AIToolCall = {
32
36
  id: string;
@@ -19,13 +19,17 @@ export type KnowledgeBase = {
19
19
  name: string;
20
20
  description: string;
21
21
  vectorStoreProvider: string;
22
- vectorStoreConfigKey?: string;
22
+ vectorDatabaseKey?: string;
23
+ llmService?: string;
24
+ embeddingModel?: string;
23
25
  vectorStoreProps?: VectorStoreProp[];
24
26
  enabled: boolean;
25
27
  };
26
28
  export type VectorStoreConfig = {
27
29
  vectorStoreProvider: string;
28
- vectorStoreConfigKey?: string;
30
+ vectorDatabaseKey?: string;
31
+ llmService?: string;
32
+ embeddingModel?: string;
29
33
  };
30
34
  export type KnowledgeBaseGroup = {
31
35
  vectorStoreConfig: VectorStoreConfig;
@@ -41,8 +45,9 @@ export type DocumentSegmentedWithScore = DocumentSegmented & {
41
45
  score: number;
42
46
  };
43
47
  export type SearchOptions = {
44
- knowledgeBaseKeys: string[];
48
+ knowledgeBaseKeys?: string[];
45
49
  query: string;
46
50
  topK?: number;
47
51
  score?: string;
52
+ roleNames?: string[];
48
53
  };
@@ -11,7 +11,7 @@ import { Plugin } from '@nocobase/server';
11
11
  export declare abstract class Files {
12
12
  static resolvers(plugin: Plugin, attachmentPart: {
13
13
  attachments?: unknown[];
14
- }): {
14
+ }, fileUrlOrigin?: string): {
15
15
  resolveAttachments: (files: AIEmployeeInstructionFiles[]) => Promise<void>;
16
16
  resolveFileIds: (files: AIEmployeeInstructionFiles[]) => Promise<void>;
17
17
  resolveUrls: (files: AIEmployeeInstructionFiles[]) => Promise<void>;
@@ -44,6 +44,7 @@ var import_node_os = __toESM(require("node:os"));
44
44
  var import_node_path = __toESM(require("node:path"));
45
45
  var import_lodash = __toESM(require("lodash"));
46
46
  var import_axios = __toESM(require("axios"));
47
+ var import_plugin_file_manager = require("@nocobase/plugin-file-manager");
47
48
  var import_utils = require("../../utils");
48
49
  var import_attachments = require("../../../attachments");
49
50
  function appendSource(record, source) {
@@ -55,8 +56,45 @@ function appendSource(record, source) {
55
56
  source
56
57
  };
57
58
  }
59
+ function toFilePlainObject(record) {
60
+ const value = typeof record.toJSON === "function" ? record.toJSON() : record;
61
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
62
+ throw new Error("Invalid file record");
63
+ }
64
+ return value;
65
+ }
66
+ async function resolveInternalFileURL(plugin, url, origin) {
67
+ var _a;
68
+ const reference = (0, import_plugin_file_manager.parsePermanentFileReference)(url, origin);
69
+ if (!reference) {
70
+ return null;
71
+ }
72
+ if (reference.appName !== (plugin.app.name || "main")) {
73
+ throw new Error("File not found");
74
+ }
75
+ const dataSource = plugin.app.dataSourceManager.get(reference.dataSourceKey);
76
+ const collection = dataSource == null ? void 0 : dataSource.collectionManager.getCollection(reference.collectionName);
77
+ if (!dataSource || !collection || collection.name !== "attachments" && ((_a = collection.options) == null ? void 0 : _a.template) !== "file") {
78
+ throw new Error("File not found");
79
+ }
80
+ const record = await dataSource.collectionManager.getRepository(collection.name).findOne({
81
+ filter: { id: reference.id }
82
+ });
83
+ if (!record) {
84
+ throw new Error("File not found");
85
+ }
86
+ const file = toFilePlainObject(record);
87
+ if (file.storageId == null || reference.extname && reference.extname !== file.extname) {
88
+ throw new Error("File not found");
89
+ }
90
+ return appendSource(file, {
91
+ dataSourceKey: reference.dataSourceKey,
92
+ collectionName: collection.name,
93
+ trustworthy: true
94
+ });
95
+ }
58
96
  class Files {
59
- static resolvers(plugin, attachmentPart) {
97
+ static resolvers(plugin, attachmentPart, fileUrlOrigin) {
60
98
  const resolveAttachments = async (files) => {
61
99
  const attachments = files.filter((it) => it.type === "attachments").flatMap((it) => import_lodash.default.isArray(it.value) ? it.value : [it.value]).map(
62
100
  (attachment) => appendSource(attachment, {
@@ -114,6 +152,15 @@ class Files {
114
152
  const storageName = (_a = settings == null ? void 0 : settings.options) == null ? void 0 : _a.storage;
115
153
  const attachments = await Promise.all(
116
154
  urls.map(async (url) => {
155
+ const internalFile = await resolveInternalFileURL(plugin, url, fileUrlOrigin);
156
+ if (internalFile) {
157
+ return internalFile;
158
+ }
159
+ try {
160
+ new URL(url);
161
+ } catch (error) {
162
+ throw new Error(`File URL must be an absolute URL or a NocoBase permanent file URL: ${url}`);
163
+ }
117
164
  const response = await import_axios.default.get(url, {
118
165
  responseType: "arraybuffer"
119
166
  });
@@ -59,7 +59,8 @@ class AIEmployeeInstruction extends import_plugin_workflow.Instruction {
59
59
  model,
60
60
  requiresApproval = import_constants.REQUIRES_APPROVAL.NO_REQUIRED,
61
61
  userId,
62
- files
62
+ files,
63
+ fileUrlOrigin
63
64
  } = processor.getParsedValue(node.config, node.id);
64
65
  const toolName = import_ai.SYSTEM_TOOLS.WORK_FLOW_TASK_OUTPUT;
65
66
  const workflowSystemPrompt = `
@@ -153,7 +154,11 @@ ${typeof message.system === "object" ? JSON.stringify(message.system) : message.
153
154
  });
154
155
  const attachmentPart = {};
155
156
  if (files == null ? void 0 : files.length) {
156
- const { resolveAttachments, resolveFileIds, resolveUrls } = import_files.Files.resolvers(this.workflow, attachmentPart);
157
+ const { resolveAttachments, resolveFileIds, resolveUrls } = import_files.Files.resolvers(
158
+ this.workflow,
159
+ attachmentPart,
160
+ fileUrlOrigin
161
+ );
157
162
  await resolveAttachments(files);
158
163
  await resolveFileIds(files);
159
164
  await resolveUrls(files);
@@ -29,6 +29,7 @@ export type AIEmployeeInstructionConfig = {
29
29
  assignees?: string[];
30
30
  userId: string;
31
31
  files: AIEmployeeInstructionFiles[];
32
+ fileUrlOrigin?: string;
32
33
  };
33
34
  export type AIEmployeeInstructionFiles = {
34
35
  type: 'attachments' | 'file_id' | 'file_url';