@nocobase/plugin-ai 2.1.0-beta.15 → 2.1.0-beta.17

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 (303) hide show
  1. package/dist/ai/ai-employees/atlas/index.d.ts +10 -0
  2. package/dist/{server/ai-employees/built-in/ai-coding/prompt.js → ai/ai-employees/atlas/index.js} +29 -20
  3. package/dist/ai/ai-employees/atlas/prompt.md +84 -0
  4. package/dist/ai/ai-employees/dara.d.ts +10 -0
  5. package/dist/{server/ai-employees/built-in/data-visualization/prompt.js → ai/ai-employees/dara.js} +21 -13
  6. package/dist/ai/ai-employees/dex.d.ts +10 -0
  7. package/dist/{server/ai-employees/built-in/data-organizer/prompt.js → ai/ai-employees/dex.js} +15 -7
  8. package/dist/ai/ai-employees/ellis.d.ts +10 -0
  9. package/dist/{server/ai-employees/built-in/email-assistant/prompt.js → ai/ai-employees/ellis.js} +19 -11
  10. package/dist/ai/ai-employees/lexi.d.ts +10 -0
  11. package/dist/{server/ai-employees/built-in/translator/prompt.js → ai/ai-employees/lexi.js} +15 -7
  12. package/dist/ai/ai-employees/vera.d.ts +10 -0
  13. package/dist/{server/ai-employees/built-in/research-analyst/prompt.js → ai/ai-employees/vera.js} +16 -8
  14. package/dist/ai/ai-employees/viz.d.ts +10 -0
  15. package/dist/{server/ai-employees/built-in/insights-analyst/prompt.js → ai/ai-employees/viz.js} +15 -7
  16. package/dist/ai/skills/business-analysis-report/SKILLS.md +88 -0
  17. package/dist/{server/ai-employees/built-in/ai-coding/prompt.d.ts → ai/skills/business-analysis-report/tools/businessReportGenerator.d.ts} +1 -3
  18. package/dist/ai/skills/business-analysis-report/tools/businessReportGenerator.js +98 -0
  19. package/dist/ai/skills/document-search/SKILLS.md +69 -0
  20. package/dist/ai/tools/chartGenerator.js +15 -3
  21. package/dist/ai/tools/formFiller.js +13 -2
  22. package/dist/{server/ai-employees/built-in/data-modeling/prompt.d.ts → ai/tools/getSkill.d.ts} +1 -3
  23. package/dist/{server/ai-employees/built-in/data-modeling/index.js → ai/tools/getSkill.js} +39 -32
  24. package/dist/{server/ai-employees/built-in/data-organizer/prompt.d.ts → ai/tools/knowledge-base-retrieve.d.ts} +1 -3
  25. package/dist/ai/tools/knowledge-base-retrieve.js +94 -0
  26. package/dist/{server/ai-employees/built-in/data-visualization/prompt.d.ts → ai/tools/sub-agents/dispatch-sub-agent-task.d.ts} +1 -3
  27. package/dist/ai/tools/sub-agents/dispatch-sub-agent-task.js +108 -0
  28. package/dist/ai/tools/sub-agents/get-ai-employee.d.ts +10 -0
  29. package/dist/{server/ai-employees/built-in/translator/profile.js → ai/tools/sub-agents/get-ai-employee.js} +28 -21
  30. package/dist/ai/tools/sub-agents/list-ai-employees.d.ts +10 -0
  31. package/dist/{server/ai-employees/built-in/email-assistant/profile.js → ai/tools/sub-agents/list-ai-employees.js} +25 -21
  32. package/dist/ai/tools/sub-agents/shared.d.ts +33 -0
  33. package/dist/ai/tools/sub-agents/shared.js +169 -0
  34. package/dist/ai/tools/suggestions.js +15 -4
  35. package/dist/client/170.d98eacdc00d9d527.js +10 -0
  36. package/dist/client/228.b18148eb1009d2fb.js +10 -0
  37. package/dist/client/280.029428b83d62155f.js +10 -0
  38. package/dist/client/290.0888139e33c9b7cb.js +10 -0
  39. package/dist/client/{524.954f96ec4fc2fd7a.js → 331.d547c95410476a69.js} +1 -1
  40. package/dist/client/343.83f7d96664e4e038.js +10 -0
  41. package/dist/client/406.15c09d98faa2ccf1.js +10 -0
  42. package/dist/client/428.e9f38da3b0d8b498.js +10 -0
  43. package/dist/client/486.afbed6b132b3c0dd.js +10 -0
  44. package/dist/client/502.2b4a51e0a8122e52.js +10 -0
  45. package/dist/client/525.33a9c8ec28be4ec4.js +10 -0
  46. package/dist/client/559.133d286a0a0a1d93.js +10 -0
  47. package/dist/client/{91.90e7098b7fbd5d00.js → 561.776886c5308e3c26.js} +1 -1
  48. package/dist/client/580.e75f97fb883ad042.js +10 -0
  49. package/dist/client/597.aa363881a325b5c0.js +10 -0
  50. package/dist/client/604.de96f3ec4d471afd.js +10 -0
  51. package/dist/client/614.aa766080f6b99aab.js +10 -0
  52. package/dist/client/646.51313bb0d85d6366.js +10 -0
  53. package/dist/client/687.224e569a99cae4bb.js +10 -0
  54. package/dist/client/699.57c0a1acb723202a.js +10 -0
  55. package/dist/client/711.266b8f1c520d467a.js +10 -0
  56. package/dist/client/758.a9741e81911e53c3.js +10 -0
  57. package/dist/client/768.973ce32e15099a48.js +10 -0
  58. package/dist/client/792.ae8ad1fcae9fd974.js +10 -0
  59. package/dist/client/820.6a26239ea96c075a.js +10 -0
  60. package/dist/client/832.0cf69e3f43c320b2.js +10 -0
  61. package/dist/client/927.ff5cd05b14901ae6.js +10 -0
  62. package/dist/client/ai-employees/admin/SkillSettings.d.ts +7 -5
  63. package/dist/client/ai-employees/admin/ToolsSettings.d.ts +17 -0
  64. package/dist/client/ai-employees/admin/mcp/MCPSettings.d.ts +10 -0
  65. package/dist/client/ai-employees/admin/mcp/MCPToolsList.d.ts +19 -0
  66. package/dist/client/ai-employees/admin/mcp/context.d.ts +15 -0
  67. package/dist/client/ai-employees/admin/mcp/schemas.d.ts +1286 -0
  68. package/dist/client/ai-employees/built-in/utils.d.ts +1 -0
  69. package/dist/client/ai-employees/business-report/tools/index.d.ts +10 -0
  70. package/dist/client/ai-employees/business-report/ui/BusinessReportCard.d.ts +12 -0
  71. package/dist/client/ai-employees/business-report/ui/BusinessReportModal.d.ts +17 -0
  72. package/dist/client/ai-employees/business-report/ui/report-utils.d.ts +38 -0
  73. package/dist/client/ai-employees/chatbox/AIEmployeeSwitch.d.ts +3 -2
  74. package/dist/client/ai-employees/chatbox/HintMessageHeader.d.ts +10 -0
  75. package/dist/client/ai-employees/chatbox/ModelSwitcher.d.ts +3 -1
  76. package/dist/client/ai-employees/chatbox/SearchSwitch.d.ts +3 -1
  77. package/dist/client/ai-employees/chatbox/Upload.d.ts +3 -1
  78. package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +27 -0
  79. package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +33 -0
  80. package/dist/client/ai-employees/chatbox/conversations/common.d.ts +43 -0
  81. package/dist/client/ai-employees/chatbox/conversations/index.d.ts +9 -0
  82. package/dist/client/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +5 -3
  83. package/dist/client/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +27 -0
  84. package/dist/client/ai-employees/chatbox/markdown/ECharts.d.ts +1 -2
  85. package/dist/client/ai-employees/chatbox/markdown/Markdown.d.ts +1 -1
  86. package/dist/client/ai-employees/chatbox/roles.d.ts +1 -0
  87. package/dist/client/ai-employees/chatbox/stores/chat-box.d.ts +8 -0
  88. package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +4 -0
  89. package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +8 -0
  90. package/dist/client/ai-employees/chatbox/stores/workflow-tasks.d.ts +45 -0
  91. package/dist/client/ai-employees/chatbox/utils.d.ts +17 -7
  92. package/dist/client/ai-employees/sub-agents/tools/index.d.ts +10 -0
  93. package/dist/client/ai-employees/sub-agents/ui/SubAgentDispatchCard.d.ts +21 -0
  94. package/dist/client/ai-employees/types.d.ts +24 -4
  95. package/dist/{server/ai-employees/built-in/ai-coding/document/example/js-filter → client/ai-employees/workflow-tasks/tools}/index.d.ts +2 -7
  96. package/dist/client/ai-employees/workflow-tasks/ui/WorkflowTaskOutputCard.d.ts +11 -0
  97. package/dist/client/components/ListCollapse.d.ts +28 -0
  98. package/dist/client/index.js +7 -7
  99. package/dist/client/manager/ai-manager.d.ts +4 -23
  100. package/dist/client/repositories/AIConfigRepository.d.ts +11 -3
  101. package/dist/client/workflow/nodes/employee/components/AIEmployeeSelect.d.ts +10 -0
  102. package/dist/client/workflow/nodes/employee/components/assigness.d.ts +11 -0
  103. package/dist/client/workflow/nodes/employee/components/file-inputs.d.ts +10 -0
  104. package/dist/client/workflow/nodes/employee/components/message-inputs.d.ts +12 -0
  105. package/dist/client/workflow/nodes/employee/components/model-options.d.ts +10 -0
  106. package/dist/client/workflow/nodes/employee/components/skill-settings.d.ts +10 -0
  107. package/dist/client/workflow/nodes/employee/components/structured-output.d.ts +10 -0
  108. package/dist/client/workflow/nodes/employee/components/users-select.d.ts +15 -0
  109. package/dist/client/workflow/nodes/employee/components/web-search-options.d.ts +10 -0
  110. package/dist/client/workflow/nodes/employee/configuration.d.ts +12 -0
  111. package/dist/client/workflow/nodes/employee/flow-models/feedback.d.ts +14 -0
  112. package/dist/client/workflow/nodes/employee/flow-models/task.d.ts +13 -0
  113. package/dist/client/workflow/nodes/employee/index.d.ts +7 -31
  114. package/dist/collections/ai-employees.js +2 -1
  115. package/dist/collections/ai-mcp-clients.d.ts +51 -0
  116. package/dist/collections/ai-mcp-clients.js +111 -0
  117. package/dist/externalVersion.js +17 -15
  118. package/dist/locale/en-US.json +141 -8
  119. package/dist/locale/zh-CN.json +142 -9
  120. package/dist/node_modules/fast-glob/out/index.js +8 -8
  121. package/dist/node_modules/fast-glob/package.json +1 -1
  122. package/dist/node_modules/flexsearch/dist/flexsearch.bundle.min.js +2 -2
  123. package/dist/node_modules/flexsearch/package.json +1 -1
  124. package/dist/node_modules/fs-extra/lib/index.js +1 -1
  125. package/dist/node_modules/fs-extra/package.json +1 -1
  126. package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.js +1 -1
  127. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  128. package/dist/node_modules/openai/index.js +1 -1
  129. package/dist/node_modules/openai/package.json +1 -1
  130. package/dist/node_modules/zod/index.cjs +1 -1
  131. package/dist/node_modules/zod/package.json +1 -1
  132. package/dist/server/ai-employees/ai-conversations.d.ts +70 -0
  133. package/dist/server/ai-employees/ai-conversations.js +325 -0
  134. package/dist/server/ai-employees/ai-employee.d.ts +100 -19
  135. package/dist/server/ai-employees/ai-employee.js +484 -261
  136. package/dist/server/ai-employees/ai-knowledge-base.d.ts +28 -0
  137. package/dist/server/ai-employees/ai-knowledge-base.js +167 -0
  138. package/dist/server/ai-employees/middleware/conversation.d.ts +2 -0
  139. package/dist/server/ai-employees/middleware/conversation.js +38 -5
  140. package/dist/server/ai-employees/middleware/index.d.ts +2 -0
  141. package/dist/server/ai-employees/middleware/index.js +5 -1
  142. package/dist/server/ai-employees/middleware/skill-tools.d.ts +12 -0
  143. package/dist/server/ai-employees/middleware/skill-tools.js +88 -0
  144. package/dist/server/ai-employees/middleware/tools.js +37 -10
  145. package/dist/server/ai-employees/middleware/workflow-history.d.ts +22 -0
  146. package/dist/server/ai-employees/middleware/workflow-history.js +173 -0
  147. package/dist/server/ai-employees/prompts.d.ts +16 -1
  148. package/dist/server/ai-employees/prompts.js +37 -1
  149. package/dist/server/ai-employees/sub-agents/dispatcher.d.ts +36 -0
  150. package/dist/server/ai-employees/sub-agents/dispatcher.js +225 -0
  151. package/dist/server/ai-employees/sub-agents/index.d.ts +9 -0
  152. package/dist/server/{migrations/20250923221107-setup-build-in.js → ai-employees/sub-agents/index.js} +9 -13
  153. package/dist/server/ai-employees/templates/form-assistant.d.ts +2 -2
  154. package/dist/server/ai-employees/templates/form-assistant.js +2 -2
  155. package/dist/server/ai-employees/utils.js +2 -2
  156. package/dist/server/collections/ai-conversations.js +18 -0
  157. package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_contacts_en.d.ts → collections/ai-mcp-clients.d.ts} +1 -4
  158. package/dist/server/{ai-employees/built-in/nocobase-assistant/index.js → collections/ai-mcp-clients.js} +12 -13
  159. package/dist/server/{ai-employees/built-in/ai-coding/document/basic/flow-resource.d.ts → collections/ai-skills.d.ts} +1 -4
  160. package/dist/server/{ai-employees/built-in/email-assistant/index.js → collections/ai-skills.js} +46 -23
  161. package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_opportunities_en.d.ts → collections/ai-workflow-tasks.d.ts} +1 -4
  162. package/dist/server/collections/ai-workflow-tasks.js +112 -0
  163. package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_accounts_en.d.ts → collections/users-ai-workflow-tasks.d.ts} +1 -4
  164. package/dist/server/collections/users-ai-workflow-tasks.js +44 -0
  165. package/dist/server/llm-providers/anthropic.d.ts +1 -0
  166. package/dist/server/llm-providers/anthropic.js +2 -1
  167. package/dist/server/llm-providers/dashscope.d.ts +1 -0
  168. package/dist/server/llm-providers/deepseek.d.ts +1 -0
  169. package/dist/server/llm-providers/google-genai.d.ts +1 -0
  170. package/dist/server/llm-providers/google-genai.js +2 -1
  171. package/dist/server/llm-providers/kimi/provider.d.ts +1 -0
  172. package/dist/server/llm-providers/openai/responses.d.ts +1 -0
  173. package/dist/server/llm-providers/openai/responses.js +2 -1
  174. package/dist/server/llm-providers/provider.d.ts +1 -10
  175. package/dist/server/llm-providers/provider.js +3 -34
  176. package/dist/server/manager/ai-coding-manager.d.ts +1 -2
  177. package/dist/server/manager/ai-coding-manager.js +0 -41
  178. package/dist/server/manager/ai-context-datasource-manager.js +30 -1
  179. package/dist/server/manager/built-in-manager.d.ts +2 -4
  180. package/dist/server/manager/built-in-manager.js +8 -117
  181. package/dist/server/migrations/20260306000001-migrate-skill-settings-tools.js +68 -0
  182. package/dist/server/migrations/20260319000000-add-ai-conversations-from.d.ts +14 -0
  183. package/dist/server/migrations/20260319000000-add-ai-conversations-from.js +63 -0
  184. package/dist/server/plugin.d.ts +6 -1
  185. package/dist/server/plugin.js +31 -8
  186. package/dist/server/resource/aiConversations.js +112 -188
  187. package/dist/server/resource/aiEmployees.js +5 -7
  188. package/dist/server/resource/aiMcpClients.d.ts +11 -0
  189. package/dist/server/resource/aiMcpClients.js +78 -0
  190. package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/index.d.ts → resource/aiSkills.d.ts} +3 -7
  191. package/dist/server/resource/aiSkills.js +71 -0
  192. package/dist/server/resource/aiTools.js +4 -6
  193. package/dist/server/resource/aiWorkflowTasks.d.ts +12 -0
  194. package/dist/server/resource/aiWorkflowTasks.js +290 -0
  195. package/dist/server/tools/docs.js +4 -3
  196. package/dist/server/tools/workflow-caller.js +1 -0
  197. package/dist/server/types/ai-chat-conversation.type.d.ts +8 -2
  198. package/dist/server/types/ai-message.type.d.ts +7 -0
  199. package/dist/server/utils.d.ts +3 -0
  200. package/dist/server/utils.js +28 -3
  201. package/dist/server/workflow/nodes/employee/files.d.ts +16 -0
  202. package/dist/server/workflow/nodes/employee/files.js +125 -0
  203. package/dist/server/workflow/nodes/employee/handler.d.ts +11 -0
  204. package/dist/server/workflow/nodes/employee/handler.js +107 -0
  205. package/dist/server/workflow/nodes/employee/index.d.ts +17 -0
  206. package/dist/server/workflow/nodes/employee/index.js +404 -0
  207. package/dist/server/workflow/nodes/employee/tools.d.ts +12 -0
  208. package/dist/server/workflow/nodes/employee/tools.js +133 -0
  209. package/dist/server/workflow/nodes/employee/types.d.ts +35 -0
  210. package/dist/server/workflow/nodes/employee/types.js +24 -0
  211. package/dist/server/workflow/utils.d.ts +14 -0
  212. package/dist/server/workflow/utils.js +111 -0
  213. package/package.json +4 -2
  214. package/dist/client/107.64d9efa24d6b9143.js +0 -10
  215. package/dist/client/124.768c8aa5d6e6b461.js +0 -10
  216. package/dist/client/159.d52107c7a34ce2da.js +0 -10
  217. package/dist/client/192.0419770b69678994.js +0 -10
  218. package/dist/client/204.91be8cfc54d91a59.js +0 -10
  219. package/dist/client/238.9f784a7cdb751999.js +0 -10
  220. package/dist/client/263.6e1dfb1cbb1964f5.js +0 -10
  221. package/dist/client/35.5ee7503d9c09daa8.js +0 -10
  222. package/dist/client/47.6bd245f2140efd24.js +0 -10
  223. package/dist/client/481.03b3d2306d409933.js +0 -10
  224. package/dist/client/586.6a1510cabaa84f23.js +0 -10
  225. package/dist/client/650.8871a07b31c307ea.js +0 -10
  226. package/dist/client/755.e295bbd2b2a1cc21.js +0 -10
  227. package/dist/client/772.d51f683c55e18dd4.js +0 -10
  228. package/dist/client/870.84187dcb8c89b4dc.js +0 -10
  229. package/dist/client/933.baab3aa75f30e020.js +0 -10
  230. package/dist/client/987.3aee964e7f406939.js +0 -10
  231. package/dist/server/ai-employees/built-in/ai-coding/document/basic/flow-resource.js +0 -256
  232. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/index.js +0 -48
  233. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_accounts_en.js +0 -452
  234. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_contacts_en.js +0 -363
  235. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_opportunities_en.js +0 -270
  236. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_quotations_en.d.ts +0 -13
  237. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_quotations_en.js +0 -219
  238. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_tickets_en.d.ts +0 -13
  239. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_tickets_en.js +0 -409
  240. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/accounts_filter_ant_style.d.ts +0 -13
  241. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/accounts_filter_ant_style.js +0 -324
  242. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/contacts_filter_ant_style.d.ts +0 -13
  243. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/contacts_filter_ant_style.js +0 -309
  244. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/index.js +0 -50
  245. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/leads_filter_ant_style.d.ts +0 -13
  246. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/leads_filter_ant_style.js +0 -345
  247. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/opportunities_filter_ant_style.d.ts +0 -13
  248. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/opportunities_filter_ant_style.js +0 -381
  249. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/product_categories_ant_style.d.ts +0 -13
  250. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/product_categories_ant_style.js +0 -545
  251. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/tickets_filter_ant_style.d.ts +0 -13
  252. package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/tickets_filter_ant_style.js +0 -346
  253. package/dist/server/ai-employees/built-in/ai-coding/document/js-action.d.ts +0 -13
  254. package/dist/server/ai-employees/built-in/ai-coding/document/js-action.js +0 -102
  255. package/dist/server/ai-employees/built-in/ai-coding/document/js-block.d.ts +0 -13
  256. package/dist/server/ai-employees/built-in/ai-coding/document/js-block.js +0 -314
  257. package/dist/server/ai-employees/built-in/ai-coding/document/js-column.d.ts +0 -13
  258. package/dist/server/ai-employees/built-in/ai-coding/document/js-column.js +0 -113
  259. package/dist/server/ai-employees/built-in/ai-coding/document/js-field.d.ts +0 -13
  260. package/dist/server/ai-employees/built-in/ai-coding/document/js-field.js +0 -498
  261. package/dist/server/ai-employees/built-in/ai-coding/document/js-item.d.ts +0 -13
  262. package/dist/server/ai-employees/built-in/ai-coding/document/js-item.js +0 -184
  263. package/dist/server/ai-employees/built-in/ai-coding/index.d.ts +0 -37
  264. package/dist/server/ai-employees/built-in/ai-coding/index.js +0 -99
  265. package/dist/server/ai-employees/built-in/ai-coding/profile.d.ts +0 -27
  266. package/dist/server/ai-employees/built-in/ai-coding/profile.js +0 -60
  267. package/dist/server/ai-employees/built-in/ai-coding/prompt_en.md +0 -110
  268. package/dist/server/ai-employees/built-in/data-modeling/index.d.ts +0 -37
  269. package/dist/server/ai-employees/built-in/data-modeling/profile.d.ts +0 -27
  270. package/dist/server/ai-employees/built-in/data-modeling/profile.js +0 -60
  271. package/dist/server/ai-employees/built-in/data-modeling/prompt.js +0 -283
  272. package/dist/server/ai-employees/built-in/data-organizer/index.d.ts +0 -37
  273. package/dist/server/ai-employees/built-in/data-organizer/index.js +0 -63
  274. package/dist/server/ai-employees/built-in/data-organizer/profile.d.ts +0 -27
  275. package/dist/server/ai-employees/built-in/data-organizer/profile.js +0 -60
  276. package/dist/server/ai-employees/built-in/data-visualization/index.d.ts +0 -37
  277. package/dist/server/ai-employees/built-in/data-visualization/index.js +0 -58
  278. package/dist/server/ai-employees/built-in/data-visualization/profile.d.ts +0 -27
  279. package/dist/server/ai-employees/built-in/data-visualization/profile.js +0 -60
  280. package/dist/server/ai-employees/built-in/email-assistant/index.d.ts +0 -34
  281. package/dist/server/ai-employees/built-in/email-assistant/profile.d.ts +0 -27
  282. package/dist/server/ai-employees/built-in/email-assistant/prompt.d.ts +0 -12
  283. package/dist/server/ai-employees/built-in/insights-analyst/index.d.ts +0 -37
  284. package/dist/server/ai-employees/built-in/insights-analyst/index.js +0 -63
  285. package/dist/server/ai-employees/built-in/insights-analyst/profile.d.ts +0 -27
  286. package/dist/server/ai-employees/built-in/insights-analyst/profile.js +0 -60
  287. package/dist/server/ai-employees/built-in/insights-analyst/prompt.d.ts +0 -12
  288. package/dist/server/ai-employees/built-in/nocobase-assistant/index.d.ts +0 -34
  289. package/dist/server/ai-employees/built-in/nocobase-assistant/profile.d.ts +0 -27
  290. package/dist/server/ai-employees/built-in/nocobase-assistant/profile.js +0 -60
  291. package/dist/server/ai-employees/built-in/nocobase-assistant/prompt.d.ts +0 -12
  292. package/dist/server/ai-employees/built-in/nocobase-assistant/prompt.js +0 -52
  293. package/dist/server/ai-employees/built-in/research-analyst/index.d.ts +0 -37
  294. package/dist/server/ai-employees/built-in/research-analyst/index.js +0 -63
  295. package/dist/server/ai-employees/built-in/research-analyst/profile.d.ts +0 -27
  296. package/dist/server/ai-employees/built-in/research-analyst/profile.js +0 -60
  297. package/dist/server/ai-employees/built-in/research-analyst/prompt.d.ts +0 -12
  298. package/dist/server/ai-employees/built-in/translator/index.d.ts +0 -37
  299. package/dist/server/ai-employees/built-in/translator/index.js +0 -67
  300. package/dist/server/ai-employees/built-in/translator/profile.d.ts +0 -27
  301. package/dist/server/ai-employees/built-in/translator/prompt.d.ts +0 -12
  302. /package/dist/client/ai-employees/chatbox/{Conversations.d.ts → conversations/Conversations.d.ts} +0 -0
  303. /package/dist/server/migrations/{20250923221107-setup-build-in.d.ts → 20260306000001-migrate-skill-settings-tools.d.ts} +0 -0
@@ -0,0 +1,71 @@
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 aiSkills_exports = {};
28
+ __export(aiSkills_exports, {
29
+ aiSkills: () => aiSkills,
30
+ default: () => aiSkills_default
31
+ });
32
+ module.exports = __toCommonJS(aiSkills_exports);
33
+ const aiSkills = {
34
+ name: "aiSkills",
35
+ actions: {
36
+ list: async (ctx, next) => {
37
+ const { skillsManager } = ctx.app.aiManager;
38
+ const { filter } = ctx.action.params;
39
+ const skills = await skillsManager.listSkills(filter || {});
40
+ ctx.body = skills.map(({ content, ...rest }) => rest);
41
+ await next();
42
+ },
43
+ listBinding: async (ctx, next) => {
44
+ var _a, _b;
45
+ const { username } = ctx.action.params;
46
+ const aiEmployee = await ctx.app.db.getRepository("aiEmployees").findOne({
47
+ filter: {
48
+ username
49
+ }
50
+ });
51
+ if (!aiEmployee) {
52
+ return [];
53
+ }
54
+ const bindingSkillNames = ((_b = (_a = aiEmployee.skillSettings) == null ? void 0 : _a.skills) == null ? void 0 : _b.map((tool) => tool.name)) ?? [];
55
+ const plugin = ctx.app.pm.get("ai");
56
+ const skills = await plugin.ai.skillsManager.listSkills();
57
+ const result = skills.filter((tool) => tool.scope === "GENERAL" || bindingSkillNames.includes(tool.name));
58
+ ctx.body = result.map(({ introduction, name, description }) => ({
59
+ title: (introduction == null ? void 0 : introduction.title) ?? name,
60
+ name,
61
+ description: (introduction == null ? void 0 : introduction.about) ?? description
62
+ }));
63
+ await next();
64
+ }
65
+ }
66
+ };
67
+ var aiSkills_default = aiSkills;
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ aiSkills
71
+ });
@@ -59,18 +59,16 @@ const aiTools = {
59
59
  if (!aiEmployee) {
60
60
  return [];
61
61
  }
62
- if (!((_b = (_a = aiEmployee.skillSettings) == null ? void 0 : _a.skills) == null ? void 0 : _b.length)) {
63
- return [];
64
- }
65
- const bindingSkillNames = aiEmployee.skillSettings.skills.map((skill) => skill.name);
62
+ const bindingToolNames = ((_b = (_a = aiEmployee.skillSettings) == null ? void 0 : _a.tools) == null ? void 0 : _b.map((tool) => tool.name)) ?? [];
66
63
  const plugin = ctx.app.pm.get("ai");
67
64
  const tools = await plugin.ai.toolsManager.listTools();
68
65
  const result = tools.filter(
69
- (tool) => tool.scope === "GENERAL" || bindingSkillNames.includes(tool.definition.name)
66
+ (tool) => tool.scope === "GENERAL" && tool.from === "loader" || bindingToolNames.includes(tool.definition.name)
70
67
  );
71
68
  ctx.body = result.map(({ introduction, definition }) => ({
72
69
  title: (introduction == null ? void 0 : introduction.title) ?? definition.name,
73
- name: definition.name
70
+ name: definition.name,
71
+ description: (introduction == null ? void 0 : introduction.about) ?? definition.description
74
72
  }));
75
73
  await next();
76
74
  }
@@ -0,0 +1,12 @@
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 { ResourceOptions } from '@nocobase/resourcer';
10
+ export declare const parseAiWorkflowTaskListRecord: (record: any, userId: string | number, jobStatusMap: Map<string, number>) => any;
11
+ export declare const aiWorkflowTasks: ResourceOptions;
12
+ export default aiWorkflowTasks;
@@ -0,0 +1,290 @@
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 aiWorkflowTasks_exports = {};
38
+ __export(aiWorkflowTasks_exports, {
39
+ aiWorkflowTasks: () => aiWorkflowTasks,
40
+ default: () => aiWorkflowTasks_default,
41
+ parseAiWorkflowTaskListRecord: () => parseAiWorkflowTaskListRecord
42
+ });
43
+ module.exports = __toCommonJS(aiWorkflowTasks_exports);
44
+ var import_actions = __toESM(require("@nocobase/actions"));
45
+ var import_plugin_workflow = require("@nocobase/plugin-workflow");
46
+ const parseAiWorkflowTaskListRecord = (record, userId, jobStatusMap) => {
47
+ var _a, _b;
48
+ const users = (record == null ? void 0 : record.users) || [];
49
+ const currentUser = users.find(
50
+ (user) => String(user == null ? void 0 : user.id) === String(userId)
51
+ );
52
+ return {
53
+ ...(record == null ? void 0 : record.toJSON()) ?? {},
54
+ read: ((_a = currentUser == null ? void 0 : currentUser.usersAiWorkflowTasks) == null ? void 0 : _a.read) ?? false,
55
+ jobStatus: jobStatusMap.get(String((record == null ? void 0 : record.jobId) ?? ((_b = record == null ? void 0 : record.get) == null ? void 0 : _b.call(record, "jobId")))) ?? import_plugin_workflow.JOB_STATUS.PENDING
56
+ };
57
+ };
58
+ const aiWorkflowTasks = {
59
+ name: "aiWorkflowTasks",
60
+ actions: {
61
+ list: async (ctx, next) => {
62
+ var _a;
63
+ const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
64
+ if (!userId) {
65
+ return ctx.throw(403);
66
+ }
67
+ const filter = ctx.action.params.filter || {};
68
+ const appends = Array.isArray(ctx.action.params.appends) ? ctx.action.params.appends : ctx.action.params.appends ? [ctx.action.params.appends] : [];
69
+ if (!appends.includes("users")) {
70
+ appends.push("users");
71
+ }
72
+ ctx.action.mergeParams({
73
+ filter: {
74
+ $and: [
75
+ filter,
76
+ {
77
+ "users.id": userId
78
+ }
79
+ ]
80
+ },
81
+ appends
82
+ });
83
+ await import_actions.default.list(ctx, async () => {
84
+ });
85
+ const jobIds = Array.from(
86
+ new Set(
87
+ (ctx.body.rows || []).map((record) => {
88
+ var _a2;
89
+ return (record == null ? void 0 : record.jobId) ?? ((_a2 = record == null ? void 0 : record.get) == null ? void 0 : _a2.call(record, "jobId"));
90
+ }).filter((jobId) => jobId != null)
91
+ )
92
+ );
93
+ const jobs = jobIds.length ? await ctx.db.getRepository("jobs").find({
94
+ filter: {
95
+ id: {
96
+ $in: jobIds
97
+ }
98
+ },
99
+ fields: ["id", "status"]
100
+ }) : [];
101
+ const jobStatusMap = new Map(
102
+ jobs.map((job) => {
103
+ var _a2, _b;
104
+ return [
105
+ String((job == null ? void 0 : job.id) ?? ((_a2 = job == null ? void 0 : job.get) == null ? void 0 : _a2.call(job, "id"))),
106
+ (job == null ? void 0 : job.status) ?? ((_b = job == null ? void 0 : job.get) == null ? void 0 : _b.call(job, "status")) ?? import_plugin_workflow.JOB_STATUS.PENDING
107
+ ];
108
+ })
109
+ );
110
+ ctx.body.rows = ctx.body.rows.map((record) => parseAiWorkflowTaskListRecord(record, userId, jobStatusMap));
111
+ await next();
112
+ },
113
+ unreadCount: async (ctx, next) => {
114
+ var _a;
115
+ const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
116
+ if (!userId) {
117
+ return ctx.throw(403);
118
+ }
119
+ const usersAiWorkflowTasksModel = ctx.db.getModel("usersAiWorkflowTasks");
120
+ const count = await usersAiWorkflowTasksModel.count({
121
+ where: {
122
+ userId,
123
+ read: false
124
+ }
125
+ });
126
+ ctx.body = {
127
+ count
128
+ };
129
+ await next();
130
+ },
131
+ getBySession: async (ctx, next) => {
132
+ var _a, _b, _c, _d, _e;
133
+ const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
134
+ if (!userId) {
135
+ return ctx.throw(403);
136
+ }
137
+ const sessionId = (_b = ctx.action.params.values) == null ? void 0 : _b.sessionId;
138
+ if (!sessionId) {
139
+ return ctx.throw(400, "sessionId is required");
140
+ }
141
+ const task = await ctx.db.getRepository("aiWorkflowTasks").findOne({
142
+ filter: {
143
+ sessionId,
144
+ "users.id": userId
145
+ }
146
+ });
147
+ if (!task) {
148
+ return ctx.throw(404, "workflow task not found");
149
+ }
150
+ const usersAiWorkflowTasks = await ctx.db.getModel("usersAiWorkflowTasks").findOne({
151
+ where: {
152
+ aiWorkflowTaskId: task.id,
153
+ userId
154
+ }
155
+ });
156
+ const node = await ctx.db.getRepository("flow_nodes").findOne({
157
+ filter: {
158
+ id: task.nodeId
159
+ }
160
+ });
161
+ const readonly = task.status !== "pending_approval" || task.acceptedUserId !== userId;
162
+ ctx.body = {
163
+ ...((_c = task == null ? void 0 : task.toJSON) == null ? void 0 : _c.call(task)) ?? task,
164
+ read: (usersAiWorkflowTasks == null ? void 0 : usersAiWorkflowTasks.read) ?? true,
165
+ config: (node == null ? void 0 : node.config) ?? null,
166
+ structuredOutputSchema: ((_e = (_d = node == null ? void 0 : node.config) == null ? void 0 : _d.structuredOutput) == null ? void 0 : _e.schema) ?? null,
167
+ readonly
168
+ };
169
+ await next();
170
+ },
171
+ accept: async (ctx, next) => {
172
+ var _a, _b;
173
+ const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
174
+ if (!userId) {
175
+ return ctx.throw(403);
176
+ }
177
+ const sessionId = (_b = ctx.action.params.values) == null ? void 0 : _b.sessionId;
178
+ if (!sessionId) {
179
+ return ctx.throw(400, "sessionId is required");
180
+ }
181
+ const task = await ctx.db.getRepository("aiWorkflowTasks").findOne({
182
+ filter: {
183
+ sessionId,
184
+ "users.id": userId
185
+ }
186
+ });
187
+ if (!task) {
188
+ return ctx.throw(404, "workflow task not found");
189
+ }
190
+ const aiWorkflowTasksModel = ctx.db.getModel("aiWorkflowTasks");
191
+ const [acceptedCount] = await aiWorkflowTasksModel.update(
192
+ {
193
+ acceptedUserId: userId,
194
+ status: "pending_approval"
195
+ },
196
+ {
197
+ where: {
198
+ id: task.id,
199
+ acceptedUserId: null,
200
+ status: "pending_acceptance"
201
+ }
202
+ }
203
+ );
204
+ const usersAiWorkflowTasksModel = ctx.db.getModel("usersAiWorkflowTasks");
205
+ const [readCount] = await usersAiWorkflowTasksModel.update(
206
+ {
207
+ read: true
208
+ },
209
+ {
210
+ where: {
211
+ aiWorkflowTaskId: task.id,
212
+ userId
213
+ }
214
+ }
215
+ );
216
+ const latestTask = await ctx.db.getRepository("aiWorkflowTasks").findOne({
217
+ filter: {
218
+ id: task.id
219
+ }
220
+ });
221
+ ctx.body = {
222
+ accepted: acceptedCount > 0,
223
+ readUpdated: readCount > 0,
224
+ acceptedUserId: (latestTask == null ? void 0 : latestTask.acceptedUserId) ?? null
225
+ };
226
+ await next();
227
+ },
228
+ reject: async (ctx, next) => {
229
+ var _a, _b, _c;
230
+ const userId = (_a = ctx.auth) == null ? void 0 : _a.user.id;
231
+ if (!userId) {
232
+ return ctx.throw(403);
233
+ }
234
+ const id = (_b = ctx.action.params.values) == null ? void 0 : _b.id;
235
+ const result = (_c = ctx.action.params.values) == null ? void 0 : _c.result;
236
+ if (!id) {
237
+ return ctx.throw(400, "id is required");
238
+ }
239
+ if (!result) {
240
+ return ctx.throw(400, "result is required");
241
+ }
242
+ const task = await ctx.db.getRepository("aiWorkflowTasks").findOne({
243
+ filter: {
244
+ id,
245
+ "users.id": userId
246
+ }
247
+ });
248
+ if (!task) {
249
+ return ctx.throw(404, "workflow task not found");
250
+ }
251
+ if (task.status !== "pending_approval" || String(task.acceptedUserId) !== String(userId)) {
252
+ return ctx.throw(403);
253
+ }
254
+ const job = await ctx.db.getRepository("jobs").findOne({
255
+ filter: {
256
+ id: task.jobId
257
+ }
258
+ });
259
+ if (!job) {
260
+ return ctx.throw(404, "job not found");
261
+ }
262
+ await ctx.db.getRepository("aiWorkflowTasks").update({
263
+ values: {
264
+ status: "rejected"
265
+ },
266
+ filter: {
267
+ id: task.id,
268
+ acceptedUserId: userId,
269
+ status: "pending_approval"
270
+ }
271
+ });
272
+ await job.update({
273
+ status: import_plugin_workflow.JOB_STATUS.REJECTED,
274
+ result
275
+ });
276
+ const workflowPlugin = ctx.app.pm.get("workflow");
277
+ await workflowPlugin.resume(job);
278
+ ctx.body = {
279
+ status: "success"
280
+ };
281
+ await next();
282
+ }
283
+ }
284
+ };
285
+ var aiWorkflowTasks_default = aiWorkflowTasks;
286
+ // Annotate the CommonJS export names for ESM import in node:
287
+ 0 && (module.exports = {
288
+ aiWorkflowTasks,
289
+ parseAiWorkflowTaskListRecord
290
+ });
@@ -47,10 +47,11 @@ __export(docs_exports, {
47
47
  module.exports = __toCommonJS(docs_exports);
48
48
  var import_zod = require("zod");
49
49
  var import_path = __toESM(require("path"));
50
+ var import_utils = require("@nocobase/utils");
50
51
  var import_fs_extra = __toESM(require("fs-extra"));
51
52
  var import_fast_glob = __toESM(require("fast-glob"));
52
53
  var import_flexsearch = require("flexsearch");
53
- const DEFAULT_DOCS_DIR = import_path.default.resolve(process.cwd(), "storage/ai/docs");
54
+ const DEFAULT_DOCS_DIR = (0, import_utils.storagePathJoin)("ai", "docs");
54
55
  const docsModules = /* @__PURE__ */ new Map();
55
56
  let docsBaseDir = DEFAULT_DOCS_DIR;
56
57
  let docsMeta = {};
@@ -217,7 +218,7 @@ async function readDocEntry(docPath) {
217
218
  function createDocsSearchTool() {
218
219
  const docsModulesDescription = describeDocModules("Docs modules unavailable. Run ai:create-docs-index first.");
219
220
  return {
220
- scope: "GENERAL",
221
+ scope: "SPECIFIED",
221
222
  defaultPermission: "ALLOW",
222
223
  introduction: {
223
224
  title: '{{t("Search documentation")}}',
@@ -279,7 +280,7 @@ Return matching document paths only. ${docsModulesDescription}`,
279
280
  }
280
281
  function createReadDocEntryTool() {
281
282
  return {
282
- scope: "GENERAL",
283
+ scope: "SPECIFIED",
283
284
  defaultPermission: "ALLOW",
284
285
  introduction: {
285
286
  title: '{{t("Read documentation file")}}',
@@ -114,6 +114,7 @@ const getWorkflowCallers = (plugin, prefix) => async (register) => {
114
114
  const config = workflow.config;
115
115
  register.registerTools({
116
116
  scope: "CUSTOM",
117
+ from: "workflow",
117
118
  introduction: {
118
119
  title: workflow.title,
119
120
  about: workflow.description
@@ -29,7 +29,10 @@ export type AIChatContext = {
29
29
  tool_call_id?: string;
30
30
  tool_calls?: AIToolCall[];
31
31
  }[];
32
- decisions?: UserDecision[];
32
+ decisions?: {
33
+ interruptId?: string;
34
+ decisions: UserDecision[];
35
+ };
33
36
  tools?: any[];
34
37
  middleware?: any[];
35
38
  structuredOutput?: {
@@ -48,7 +51,10 @@ export type AIMessageRemoveOptions = {
48
51
  };
49
52
  export type AIChatContextOptions = {
50
53
  userMessages?: AIMessageInput[];
51
- userDecisions?: UserDecision[];
54
+ userDecisions?: {
55
+ interruptId?: string;
56
+ decisions: UserDecision[];
57
+ };
52
58
  tools?: any[];
53
59
  middleware?: any[];
54
60
  getSystemPrompt?: (userMessages: AIMessageInput[]) => Promise<string>;
@@ -10,6 +10,7 @@ export type AIMessage = {
10
10
  messageId: string;
11
11
  sessionId: string;
12
12
  role: string;
13
+ createdAt?: string | Date;
13
14
  content: AIMessageContent;
14
15
  toolCalls?: AIToolCall[];
15
16
  attachments?: unknown[];
@@ -44,8 +45,14 @@ export type AIMessageMetadata = {
44
45
  autoCallTools?: string[];
45
46
  autoCall?: boolean;
46
47
  interrupted?: boolean;
48
+ subAgentConversations?: SubAgentConversationMetadata[];
47
49
  [key: string]: unknown;
48
50
  };
51
+ export type SubAgentConversationMetadata = {
52
+ sessionId: string;
53
+ toolCallId: string;
54
+ status: 'pending' | 'completed';
55
+ };
49
56
  export type AIToolMessage = {
50
57
  id: string;
51
58
  sessionId: string;
@@ -8,13 +8,16 @@
8
8
  */
9
9
  import { Model } from '@nocobase/database';
10
10
  import { Context } from '@nocobase/actions';
11
+ import { ToolsEntry } from '@nocobase/ai';
11
12
  export declare function sendSSEError(ctx: Context, error: Error | string, errorName?: string): void;
12
13
  export declare function stripToolCallTags(content: string): string | null;
13
14
  export declare function parseResponseMessage(row: Model): {
14
15
  key: any;
16
+ createdAt: any;
15
17
  content: any;
16
18
  role: any;
17
19
  };
18
20
  export declare function encodeLocalFile(url: string): Promise<string>;
19
21
  export declare function encodeFile(ctx: Context, url: string): Promise<string>;
20
22
  export declare function parseVariables(ctx: Context, value: string): Promise<any>;
23
+ export declare const buildTool: (toolsEntry: ToolsEntry) => import("@langchain/core/dist/tools").DynamicTool<any>;
@@ -36,6 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var utils_exports = {};
38
38
  __export(utils_exports, {
39
+ buildTool: () => buildTool,
39
40
  encodeFile: () => encodeFile,
40
41
  encodeLocalFile: () => encodeLocalFile,
41
42
  parseResponseMessage: () => parseResponseMessage,
@@ -47,6 +48,7 @@ module.exports = __toCommonJS(utils_exports);
47
48
  var import_path = __toESM(require("path"));
48
49
  var import_fs = __toESM(require("fs"));
49
50
  var import_utils = require("@nocobase/utils");
51
+ var import_langchain = require("langchain");
50
52
  function sendSSEError(ctx, error, errorName) {
51
53
  const body = typeof error === "string" ? error : error.message || "Unknown error";
52
54
  if (!ctx.res.headersSent) {
@@ -69,7 +71,7 @@ function stripToolCallTags(content) {
69
71
  return content.replace(/<[||]tool▁(?:calls▁begin|calls▁end|call▁begin|call▁end|sep)[||]>/g, "");
70
72
  }
71
73
  function parseResponseMessage(row) {
72
- const { content: rawContent, messageId, metadata, role, toolCalls, attachments, workContext } = row;
74
+ const { content: rawContent, messageId, metadata, role, toolCalls, attachments, workContext, createdAt } = row;
73
75
  const content = {
74
76
  ...rawContent ?? {},
75
77
  content: stripToolCallTags(rawContent == null ? void 0 : rawContent.content),
@@ -83,6 +85,7 @@ function parseResponseMessage(row) {
83
85
  }
84
86
  return {
85
87
  key: messageId,
88
+ createdAt,
86
89
  content,
87
90
  role
88
91
  };
@@ -128,6 +131,7 @@ async function getUser(ctx, fields) {
128
131
  return user;
129
132
  }
130
133
  async function parseVariables(ctx, value) {
134
+ var _a, _b;
131
135
  const re = /\{\{\$user\.([^}]+)\}\}/g;
132
136
  const userFieldsSet = /* @__PURE__ */ new Set();
133
137
  const matches = value.matchAll(re);
@@ -141,7 +145,7 @@ async function parseVariables(ctx, value) {
141
145
  for (const [key, value2] of Object.entries(dateVariables)) {
142
146
  if (typeof value2 === "function") {
143
147
  $nDate[key] = value2({
144
- timezone: ctx.get("x-timezone"),
148
+ timezone: (_a = ctx.get) == null ? void 0 : _a.call(ctx, "x-timezone"),
145
149
  now: (/* @__PURE__ */ new Date()).toISOString()
146
150
  });
147
151
  } else {
@@ -151,12 +155,33 @@ async function parseVariables(ctx, value) {
151
155
  return (0, import_utils.parse)(value)({
152
156
  $user,
153
157
  $nRole: ctx.state.currentRole === "__union__" ? ctx.state.currentRoles : ctx.state.currentRole,
154
- $nLang: ctx.getCurrentLocale(),
158
+ $nLang: (_b = ctx.getCurrentLocale) == null ? void 0 : _b.call(ctx),
155
159
  $nDate
156
160
  });
157
161
  }
162
+ const noWriter = (chunk) => console.warn(`No writer in tools runtime, chunk:[${chunk}]`);
163
+ const buildTool = (toolsEntry) => {
164
+ const {
165
+ invoke,
166
+ definition: { name, description, schema }
167
+ } = toolsEntry;
168
+ return (0, import_langchain.tool)(
169
+ (input, config) => {
170
+ const { context, toolCall } = config;
171
+ const writer = config["writer"] ?? noWriter;
172
+ return invoke(context.ctx, input, { toolCallId: toolCall.id, writer });
173
+ },
174
+ {
175
+ name,
176
+ description,
177
+ schema,
178
+ returnDirect: false
179
+ }
180
+ );
181
+ };
158
182
  // Annotate the CommonJS export names for ESM import in node:
159
183
  0 && (module.exports = {
184
+ buildTool,
160
185
  encodeFile,
161
186
  encodeLocalFile,
162
187
  parseResponseMessage,
@@ -0,0 +1,16 @@
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 { AIEmployeeInstructionFiles } from './types';
10
+ import { Plugin } from '@nocobase/server';
11
+ export declare abstract class Files {
12
+ static resolvers(plugin: Plugin, attachmentPart: Record<string, any>): {
13
+ resolveAttachments: (files: AIEmployeeInstructionFiles[]) => Promise<void>;
14
+ resolveUrls: (files: AIEmployeeInstructionFiles[]) => Promise<void>;
15
+ };
16
+ }