@nocobase/plugin-ai 2.1.31 → 2.2.0-alpha.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 (447) hide show
  1. package/client-v2.d.ts +1 -0
  2. package/dist/ai/docs/nocobase/api/app/env.md +1 -1
  3. package/dist/ai/docs/nocobase/api/cli/index.md +14 -2
  4. package/dist/ai/docs/nocobase/api/cli/portal/config.md +44 -0
  5. package/dist/ai/docs/nocobase/api/cli/portal/create.md +48 -0
  6. package/dist/ai/docs/nocobase/api/cli/portal/deploy.md +39 -0
  7. package/dist/ai/docs/nocobase/api/cli/portal/destroy.md +41 -0
  8. package/dist/ai/docs/nocobase/api/cli/portal/dev.md +39 -0
  9. package/dist/ai/docs/nocobase/api/cli/portal/index.md +136 -0
  10. package/dist/ai/docs/nocobase/api/cli/portal/info.md +41 -0
  11. package/dist/ai/docs/nocobase/api/cli/portal/list.md +40 -0
  12. package/dist/ai/docs/nocobase/api/cli/portal/pull.md +43 -0
  13. package/dist/ai/docs/nocobase/api/cli/portal/push.md +41 -0
  14. package/dist/ai/docs/nocobase/file-manager/stable-url.md +87 -0
  15. package/dist/ai/docs/nocobase/file-manager/storage/index.md +66 -26
  16. package/dist/ai/docs/nocobase/file-manager/storage/s3-pro.md +58 -7
  17. package/dist/ai/docs/nocobase/get-started/deployment/production.md +24 -2
  18. package/dist/ai/docs/nocobase/get-started/installation/docker-caddy.mdx +3 -0
  19. package/dist/ai/docs/nocobase/get-started/installation/docker-nginx.mdx +3 -0
  20. package/dist/ai/docs/nocobase/get-started/installation/docker.mdx +27 -3
  21. package/dist/ai/docs/nocobase/get-started/installation/env.md +34 -1
  22. package/dist/ai/docs/nocobase/interface-builder/blocks/data-blocks/comment.md +107 -0
  23. package/dist/ai/docs/nocobase/interface-builder/blocks/data-blocks/gantt.md +204 -0
  24. package/dist/ai/docs/nocobase/interface-builder/index.md +7 -6
  25. package/dist/ai/docs/nocobase/interface-builder/ui-layout/desktop.md +97 -0
  26. package/dist/ai/docs/nocobase/interface-builder/ui-layout/index.md +50 -0
  27. package/dist/ai/docs/nocobase/interface-builder/ui-layout/mobile.md +133 -0
  28. package/dist/ai/docs/nocobase/nocobase-cli/production/index.md +10 -0
  29. package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/caddy.md +15 -2
  30. package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/index.md +1 -1
  31. package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/nginx.md +16 -2
  32. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-block-comment/index.md +14 -0
  33. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-multi-portal/index.md +16 -0
  34. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-ui-layout/index.md +14 -0
  35. package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-workflow-transaction/index.md +16 -0
  36. package/dist/ai/docs/nocobase/runjs/context/ai.md +206 -0
  37. package/dist/ai/docs/nocobase/workflow/development/api.md +259 -77
  38. package/dist/ai/docs/nocobase/workflow/development/index.md +2 -1
  39. package/dist/ai/docs/nocobase/workflow/development/migration.md +319 -0
  40. package/dist/ai/docs/nocobase/workflow/development/node.md +84 -51
  41. package/dist/ai/docs/nocobase/workflow/development/trigger.md +122 -20
  42. package/dist/ai/docs/nocobase/workflow/nodes/index.md +2 -1
  43. package/dist/ai/docs/nocobase/workflow/nodes/transaction.md +81 -0
  44. package/dist/ai/tools/executeFrontendTool.d.ts +10 -0
  45. package/dist/ai/tools/executeFrontendTool.js +86 -0
  46. package/dist/ai/tools/formFiller.js +4 -3
  47. package/dist/ai/tools/loadFrontendTool.d.ts +10 -0
  48. package/dist/ai/tools/loadFrontendTool.js +99 -0
  49. package/dist/ai/tools/subAgentWebSearch.js +20 -15
  50. package/dist/client/23.65ea8c37cd4b884b.js +10 -0
  51. package/dist/client/264.cc98933ef65608b6.js +10 -0
  52. package/dist/client/336.7a8a8853196ad779.js +11 -0
  53. package/dist/client/372.49163fac65cef81c.js +10 -0
  54. package/dist/client/416.92b74ca47e4099c4.js +10 -0
  55. package/dist/client/446.d63c38d0309fe250.js +10 -0
  56. package/dist/client/525.94dd4136c1361477.js +10 -0
  57. package/dist/client/663.680bcf6272a8504d.js +10 -0
  58. package/dist/client/681.399948c18d753667.js +10 -0
  59. package/dist/client/705.19b642db34de438a.js +10 -0
  60. package/dist/client/ai-employees/1.x/selector/AIContextCollector.d.ts +1 -4
  61. package/dist/client/ai-employees/permissions/PermissionsTab.d.ts +21 -5
  62. package/dist/client/index.d.ts +15 -20
  63. package/dist/client/index.js +8 -8
  64. package/dist/client/workflow/nodes/employee/index.d.ts +2 -23
  65. package/dist/client/workflow/nodes/llm/index.d.ts +2 -52
  66. package/dist/client/workflow/triggers/ai-employee/index.d.ts +2 -83
  67. package/dist/client-v2/23.1bcb6986b40723d8.js +10 -0
  68. package/dist/client-v2/264.be92ff6a4d2612f1.js +10 -0
  69. package/dist/client-v2/336.e406470429e0670e.js +11 -0
  70. package/dist/client-v2/372.387161cdeb106987.js +10 -0
  71. package/dist/client-v2/406.341be51205c674e0.js +10 -0
  72. package/dist/client-v2/416.0e1c2d9cde43b83d.js +10 -0
  73. package/dist/client-v2/446.073d450882db29fd.js +10 -0
  74. package/dist/client-v2/457.d72febb89e88fc00.js +10 -0
  75. package/dist/client-v2/663.342341f0b2b412d8.js +10 -0
  76. package/dist/client-v2/681.082f4f1c7b841983.js +10 -0
  77. package/dist/client-v2/705.8dc34d43f02f322c.js +10 -0
  78. package/dist/{client/ai-employees/admin/AvatarSelect.d.ts → client-v2/ai-employees/AIEmployeeDropdown.d.ts} +8 -9
  79. package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +9 -2
  80. package/dist/{client → client-v2}/ai-employees/AddContextButton.d.ts +1 -1
  81. package/dist/{client → client-v2}/ai-employees/ai-coding/AICodingButton.d.ts +2 -1
  82. package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/Actions.d.ts +2 -4
  83. package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/AddLLMModal.d.ts +2 -4
  84. package/dist/client-v2/ai-employees/chatbox/components/Attachments.d.ts +27 -0
  85. package/dist/{client/ai-employees/permissions/Permissions.d.ts → client-v2/ai-employees/chatbox/components/ChatBox.d.ts} +2 -2
  86. package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/ChatBoxLayout.d.ts +1 -1
  87. package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/ContextItem.d.ts +1 -1
  88. package/dist/{client/ai-employees/admin/Employees.d.ts → client-v2/ai-employees/chatbox/components/DebugPanel.d.ts} +1 -1
  89. package/dist/{client/ai-employees/chatbox/markdown/Code.d.ts → client-v2/ai-employees/chatbox/components/Markdown.d.ts} +12 -5
  90. package/dist/{client/ai-employees/admin/ProfileSettings.d.ts → client-v2/ai-employees/chatbox/components/MessageContent.d.ts} +3 -2
  91. package/dist/client-v2/ai-employees/chatbox/components/MessageRenderers.d.ts +39 -0
  92. package/dist/{client/ai-employees/chatbox/generative-ui → client-v2/ai-employees/chatbox/components}/ToolCard.d.ts +7 -5
  93. package/dist/{client/ai-employees/admin/datasource/components/basic → client-v2/ai-employees/chatbox/components}/index.d.ts +5 -2
  94. package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useChat.d.ts +21 -22
  95. package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +3 -2
  96. package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +2 -2
  97. package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +8 -4
  98. package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useToolCallActions.d.ts +1 -1
  99. package/dist/client-v2/ai-employees/chatbox/hooks/useUploadFiles.d.ts +46 -0
  100. package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +1 -1
  101. package/dist/{client → client-v2}/ai-employees/chatbox/model.d.ts +9 -2
  102. package/dist/client-v2/ai-employees/chatbox/roles.d.ts +162 -0
  103. package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +1 -49
  104. package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +2 -19
  105. package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +1 -46
  106. package/dist/{client → client-v2}/ai-employees/chatbox/stores/chat-tool-call.d.ts +1 -15
  107. package/dist/client-v2/ai-employees/chatbox/stores/chat-tools.d.ts +30 -0
  108. package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +31 -3
  109. package/dist/{client/ai-employees/chatbox/conversations/common.d.ts → client-v2/ai-employees/chatbox/stores/workflow-tasks.d.ts} +21 -4
  110. package/dist/client-v2/ai-employees/chatbox/utils/normalizeTriggerTaskOptions.d.ts +19 -0
  111. package/dist/{client → client-v2}/ai-employees/chatbox/utils.d.ts +26 -7
  112. package/dist/{client/ai-employees/data-visualization/context.d.ts → client-v2/ai-employees/context/chart-config.d.ts} +1 -1
  113. package/dist/{client → client-v2}/ai-employees/context/code-editor.d.ts +1 -1
  114. package/dist/{client → client-v2}/ai-employees/context/datasource.d.ts +1 -1
  115. package/dist/{client → client-v2}/ai-employees/context/flow-models.d.ts +1 -1
  116. package/dist/{client/ai-employees/admin/datasource/components/DatasourceSettingDetail.d.ts → client-v2/ai-employees/data-modeling/setup.d.ts} +6 -5
  117. package/dist/{client → client-v2}/ai-employees/datasource/DatasourceSelector.d.ts +6 -2
  118. package/dist/{client/ai-employees/admin/datasource/flow-models/DatasourceSettingModel.d.ts → client-v2/ai-employees/flow/index.d.ts} +4 -6
  119. package/dist/{client → client-v2}/ai-employees/form-filler/tools/index.d.ts +1 -1
  120. package/dist/{client/ai-employees/ai-coding/tools/index.d.ts → client-v2/ai-employees/frontend-tools.d.ts} +3 -3
  121. package/dist/{client → client-v2}/ai-employees/stores/ai-selection.d.ts +4 -4
  122. package/dist/{client → client-v2}/ai-employees/stores/dialog-controller.d.ts +4 -4
  123. package/dist/{client/ai-employees/business-report/ui → client-v2/ai-employees/tools}/BusinessReportCard.d.ts +2 -2
  124. package/dist/{client/ai-employees/business-report/ui → client-v2/ai-employees/tools}/BusinessReportModal.d.ts +2 -2
  125. package/dist/{client/ai-employees/1.x/selector/withAISelectable.d.ts → client-v2/ai-employees/tools/ChartGeneratorCard.d.ts} +5 -4
  126. package/dist/{client/ai-employees/ai-coding/ui → client-v2/ai-employees/tools}/CodeToolCard.d.ts +1 -1
  127. package/dist/{client/ai-employees/data-modeling/ui → client-v2/ai-employees/tools}/DataModelingCard.d.ts +3 -5
  128. package/dist/{client/ai-employees/data-modeling/ui → client-v2/ai-employees/tools}/DataModelingModal.d.ts +4 -6
  129. package/dist/{client/ai-employees/sub-agents/ui → client-v2/ai-employees/tools}/SubAgentDispatchCard.d.ts +4 -9
  130. package/dist/{client/ai-employees/AISettingsProvider.d.ts → client-v2/ai-employees/tools/SuggestionsOptionsCard.d.ts} +6 -8
  131. package/dist/{client/ai-employees/workflow-tasks/ui → client-v2/ai-employees/tools}/WorkflowTaskOutputCard.d.ts +7 -2
  132. package/dist/{client/ai-employees/ai-coding/tools/context-tools.d.ts → client-v2/ai-employees/tools/ai-coding.d.ts} +3 -1
  133. package/dist/client-v2/ai-employees/tools/business-report-utils.d.ts +45 -0
  134. package/dist/{client/ai-employees/data-modeling/ui → client-v2/ai-employees/tools/data-modeling}/CollectionNode.d.ts +2 -3
  135. package/dist/{client/ai-employees/data-modeling/ui → client-v2/ai-employees/tools/data-modeling}/Diagram.d.ts +1 -1
  136. package/dist/{client/ai-employees/data-modeling/ui → client-v2/ai-employees/tools/data-modeling}/Table.d.ts +2 -2
  137. package/dist/client-v2/ai-employees/tools/data-modeling/legacy-template.d.ts +13 -0
  138. package/dist/client-v2/ai-employees/tools/data-modeling/runtime.d.ts +15 -0
  139. package/dist/{client/ai-employees → client-v2/ai-employees/tools}/data-modeling/types.d.ts +27 -4
  140. package/dist/client-v2/ai-employees/tools/data-modeling/useFieldInterfaceOptions.d.ts +151 -0
  141. package/dist/{client/ai-employees/data-visualization/tools/index.d.ts → client-v2/ai-employees/tools/data-visualization.d.ts} +1 -1
  142. package/dist/client-v2/ai-employees/tools/index.d.ts +32 -0
  143. package/dist/client-v2/ai-employees/types.d.ts +104 -7
  144. package/dist/client-v2/components/RemoteSelect.d.ts +43 -0
  145. package/dist/{client → client-v2}/debug-logger.d.ts +2 -2
  146. package/dist/client-v2/f0053e745af0ad03.svg +50 -0
  147. package/dist/client-v2/index.d.ts +9 -8
  148. package/dist/client-v2/index.js +37 -1
  149. package/dist/client-v2/llm-providers/forms.d.ts +44 -0
  150. package/dist/client-v2/llm-providers/index.d.ts +24 -0
  151. package/dist/{client/ai-employees/chart-generator/tools/index.d.ts → client-v2/llm-services/utils.d.ts} +5 -2
  152. package/dist/client-v2/locale.d.ts +14 -0
  153. package/dist/client-v2/manager/ai-manager.d.ts +57 -0
  154. package/dist/client-v2/manager/frontend-tool-registry.d.ts +30 -0
  155. package/dist/client-v2/models/ai-employees/AIEmployeeActionModel.d.ts +33 -0
  156. package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +44 -0
  157. package/dist/client-v2/pages/AdminSettingsPage.d.ts +24 -0
  158. package/dist/client-v2/pages/DatasourceSettingsPage.d.ts +62 -0
  159. package/dist/client-v2/pages/EmployeesPage.d.ts +63 -0
  160. package/dist/client-v2/pages/LLMServicesPage.d.ts +75 -0
  161. package/dist/client-v2/pages/MCPSettingsPage.d.ts +73 -0
  162. package/dist/client-v2/pages/drawerWidth.d.ts +10 -0
  163. package/dist/client-v2/pages/permissions/Permissions.d.ts +67 -0
  164. package/dist/client-v2/pages/permissions/PermissionsTab.d.ts +12 -0
  165. package/dist/client-v2/pages/useUnsavedChangesBeforeClose.d.ts +29 -0
  166. package/dist/client-v2/plugin.d.ts +33 -0
  167. package/dist/client-v2/repositories/AIConfigRepository.d.ts +3 -23
  168. package/dist/client-v2/runjs/registerAIEmployeeRunJSFacade.d.ts +20 -0
  169. package/dist/client-v2/workflow/components/FormValueRegistry.d.ts +12 -0
  170. package/dist/{client/components/ListCollapse.d.ts → client-v2/workflow/components/WorkflowListCollapse.d.ts} +4 -4
  171. package/dist/client-v2/workflow/constants.d.ts +26 -0
  172. package/dist/client-v2/workflow/nodes/employee/components/AIEmployeeFieldset.d.ts +11 -0
  173. package/dist/{client/ai-employees/common/CodeHighlight.d.ts → client-v2/workflow/nodes/employee/components/AIEmployeeSelect.d.ts} +5 -6
  174. package/dist/{client/ai-employees/ContextAwareTooltip.d.ts → client-v2/workflow/nodes/employee/components/Assignees.d.ts} +2 -1
  175. package/dist/client-v2/workflow/nodes/employee/components/FeedbackSettings.d.ts +17 -0
  176. package/dist/client-v2/workflow/nodes/employee/components/FileInputs.d.ts +11 -0
  177. package/dist/{client/ai-employees/AIEmployeesProvider.d.ts → client-v2/workflow/nodes/employee/components/MessageInputs.d.ts} +2 -3
  178. package/dist/client-v2/workflow/nodes/employee/components/ModelOptions.d.ts +17 -0
  179. package/dist/{client/ai-employees/admin/datasource/components/basic/CollectionCascader.d.ts → client-v2/workflow/nodes/employee/components/SkillSettings.d.ts} +6 -3
  180. package/dist/client-v2/workflow/nodes/employee/components/StructuredOutput.d.ts +11 -0
  181. package/dist/client-v2/workflow/nodes/employee/components/UserInput.d.ts +18 -0
  182. package/dist/client-v2/workflow/nodes/employee/components/WebSearchOptions.d.ts +16 -0
  183. package/dist/client-v2/workflow/nodes/employee/index.d.ts +23 -0
  184. package/dist/{client/ai-employees/AIEmployeeListItem.d.ts → client-v2/workflow/nodes/llm/components/LLMFieldset.d.ts} +3 -5
  185. package/dist/{client/admin-settings/AdminSettings.d.ts → client-v2/workflow/nodes/llm/components/Messages.d.ts} +2 -1
  186. package/dist/client-v2/workflow/nodes/llm/components/StructuredOutput.d.ts +11 -0
  187. package/dist/client-v2/workflow/nodes/llm/index.d.ts +30 -0
  188. package/dist/{client/ai-employees/1.x/selector/BlockSelector.d.ts → client-v2/workflow/register.d.ts} +2 -6
  189. package/dist/client-v2/workflow/triggers/ai-employee/AIEmployeeTriggerConfig.d.ts +11 -0
  190. package/dist/client-v2/workflow/triggers/ai-employee/Parameters.d.ts +11 -0
  191. package/dist/client-v2/workflow/triggers/ai-employee/index.d.ts +25 -0
  192. package/dist/client-v2/workflow/types.d.ts +128 -0
  193. package/dist/common/frontend-tools.d.ts +26 -0
  194. package/dist/common/frontend-tools.js +57 -0
  195. package/dist/externalVersion.js +20 -25
  196. package/dist/locale/en-US.json +48 -1
  197. package/dist/locale/zh-CN.json +48 -1
  198. package/dist/node_modules/@langchain/mistralai/package.json +1 -1
  199. package/dist/node_modules/@langchain/xai/package.json +1 -1
  200. package/dist/node_modules/fs-extra/package.json +1 -1
  201. package/dist/node_modules/jsonrepair/package.json +1 -1
  202. package/dist/node_modules/just-bash/package.json +1 -1
  203. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  204. package/dist/node_modules/openai/package.json +1 -1
  205. package/dist/node_modules/zod/package.json +1 -1
  206. package/dist/server/ai-employees/ai-conversations.d.ts +2 -0
  207. package/dist/server/ai-employees/ai-employee.d.ts +1 -1
  208. package/dist/server/ai-employees/ai-employee.js +27 -8
  209. package/dist/server/ai-employees/prompts.d.ts +2 -1
  210. package/dist/server/ai-employees/prompts.js +8 -2
  211. package/dist/server/ai-employees/tool-call-sanitizer.d.ts +1 -0
  212. package/dist/server/ai-employees/tool-call-sanitizer.js +2 -1
  213. package/dist/server/ai-employees/utils.js +11 -5
  214. package/dist/server/collections/ai-usage-events.d.ts +10 -0
  215. package/dist/server/collections/ai-usage-events.js +183 -0
  216. package/dist/server/document-loader/constants.js +1 -0
  217. package/dist/server/frontend-tools.d.ts +25 -0
  218. package/dist/server/frontend-tools.js +171 -0
  219. package/dist/server/llm-providers/dashscope.d.ts +2 -1
  220. package/dist/server/llm-providers/dashscope.js +16 -1
  221. package/dist/server/llm-providers/deepseek.d.ts +2 -1
  222. package/dist/server/llm-providers/deepseek.js +33 -2
  223. package/dist/server/llm-providers/kimi/provider.d.ts +2 -1
  224. package/dist/server/llm-providers/kimi/provider.js +22 -2
  225. package/dist/server/llm-providers/mistral.d.ts +36 -2
  226. package/dist/server/llm-providers/mistral.js +62 -2
  227. package/dist/server/llm-providers/openai/completions.d.ts +2 -1
  228. package/dist/server/llm-providers/openai/completions.js +17 -1
  229. package/dist/server/llm-providers/openai/responses.d.ts +2 -1
  230. package/dist/server/llm-providers/openai/responses.js +17 -1
  231. package/dist/server/llm-providers/provider.d.ts +7 -0
  232. package/dist/server/llm-providers/provider.js +7 -1
  233. package/dist/server/manager/ai-chat-conversation.js +2 -0
  234. package/dist/server/manager/ai-context-datasource-manager.js +34 -7
  235. package/dist/server/manager/ai-manager.d.ts +2 -1
  236. package/dist/server/manager/ai-manager.js +4 -1
  237. package/dist/server/manager/ai-usage-events.d.ts +49 -0
  238. package/dist/server/manager/ai-usage-events.js +195 -0
  239. package/dist/server/manager/work-context-handler.js +10 -3
  240. package/dist/server/resource/aiConversations.d.ts +2 -0
  241. package/dist/server/resource/aiConversations.js +27 -1
  242. package/package.json +5 -5
  243. package/dist/client/119.c6bf8c6433167d81.js +0 -10
  244. package/dist/client/170.d98eacdc00d9d527.js +0 -10
  245. package/dist/client/228.b4b709f93b86b6b9.js +0 -10
  246. package/dist/client/280.003b9e9788599244.js +0 -10
  247. package/dist/client/290.0f7f441d8a94f03c.js +0 -10
  248. package/dist/client/331.d547c95410476a69.js +0 -10
  249. package/dist/client/406.15c09d98faa2ccf1.js +0 -10
  250. package/dist/client/428.5eb4f53ddbb6a3b8.js +0 -10
  251. package/dist/client/462.d172d0fe91519e35.js +0 -10
  252. package/dist/client/486.dcac8f3fcec19c33.js +0 -10
  253. package/dist/client/502.2b4a51e0a8122e52.js +0 -10
  254. package/dist/client/525.33a9c8ec28be4ec4.js +0 -10
  255. package/dist/client/559.959c46d0056ccdc8.js +0 -10
  256. package/dist/client/561.7ec804ef39ec7dcd.js +0 -10
  257. package/dist/client/580.35ba54ff91b7fe6d.js +0 -10
  258. package/dist/client/597.b0d64948d74cf6cb.js +0 -10
  259. package/dist/client/604.89c674f35b52b4ef.js +0 -10
  260. package/dist/client/614.aa766080f6b99aab.js +0 -10
  261. package/dist/client/646.07bb23e72fb6eb15.js +0 -10
  262. package/dist/client/687.224e569a99cae4bb.js +0 -10
  263. package/dist/client/699.57c0a1acb723202a.js +0 -10
  264. package/dist/client/711.92cd94681fde7e05.js +0 -10
  265. package/dist/client/758.a9741e81911e53c3.js +0 -10
  266. package/dist/client/768.5177bff46ae71a5b.js +0 -10
  267. package/dist/client/792.abb57765453bcbcc.js +0 -10
  268. package/dist/client/820.f72ef2462b61d812.js +0 -10
  269. package/dist/client/832.0cf69e3f43c320b2.js +0 -10
  270. package/dist/client/927.d95c74ebb8fd51c9.js +0 -10
  271. package/dist/client/ai-employees/1.x/selector/AISelectorProvider.d.ts +0 -33
  272. package/dist/client/ai-employees/ProfileCard.d.ts +0 -15
  273. package/dist/client/ai-employees/admin/ChatSettings.d.ts +0 -10
  274. package/dist/client/ai-employees/admin/DataSourceSettings.d.ts +0 -10
  275. package/dist/client/ai-employees/admin/EnableSwitch.d.ts +0 -10
  276. package/dist/client/ai-employees/admin/InputsFormSettings.d.ts +0 -10
  277. package/dist/client/ai-employees/admin/KnowledgeBaseSettings.d.ts +0 -10
  278. package/dist/client/ai-employees/admin/ModelSettings.d.ts +0 -10
  279. package/dist/client/ai-employees/admin/SkillSettings.d.ts +0 -19
  280. package/dist/client/ai-employees/admin/SystemPrompt.d.ts +0 -10
  281. package/dist/client/ai-employees/admin/Templates.d.ts +0 -10
  282. package/dist/client/ai-employees/admin/ToolsSettings.d.ts +0 -17
  283. package/dist/client/ai-employees/admin/datasource/components/DatasourceSettingForm.d.ts +0 -10
  284. package/dist/client/ai-employees/admin/datasource/components/DatasourceSettingGrid.d.ts +0 -10
  285. package/dist/client/ai-employees/admin/datasource/components/basic/FieldsTransfer.d.ts +0 -17
  286. package/dist/client/ai-employees/admin/datasource/components/form-steps/CollectionSetting.d.ts +0 -17
  287. package/dist/client/ai-employees/admin/datasource/components/form-steps/FieldsSetting.d.ts +0 -15
  288. package/dist/client/ai-employees/admin/datasource/components/form-steps/FilterSetting.d.ts +0 -17
  289. package/dist/client/ai-employees/admin/datasource/components/form-steps/Preview.d.ts +0 -13
  290. package/dist/client/ai-employees/admin/datasource/components/form-steps/SortSetting.d.ts +0 -15
  291. package/dist/client/ai-employees/admin/datasource/components/form-steps/index.d.ts +0 -13
  292. package/dist/client/ai-employees/admin/datasource/components/index.d.ts +0 -9
  293. package/dist/client/ai-employees/admin/datasource/context.d.ts +0 -17
  294. package/dist/client/ai-employees/admin/datasource/flow-models/index.d.ts +0 -9
  295. package/dist/client/ai-employees/admin/datasource/index.d.ts +0 -10
  296. package/dist/client/ai-employees/admin/hooks.d.ts +0 -39
  297. package/dist/client/ai-employees/admin/mcp/MCPSettings.d.ts +0 -10
  298. package/dist/client/ai-employees/admin/mcp/MCPToolsList.d.ts +0 -19
  299. package/dist/client/ai-employees/admin/mcp/context.d.ts +0 -15
  300. package/dist/client/ai-employees/admin/mcp/schemas.d.ts +0 -1314
  301. package/dist/client/ai-employees/ai-coding/CodeHistory.d.ts +0 -10
  302. package/dist/client/ai-employees/ai-coding/markdown/Code.d.ts +0 -16
  303. package/dist/client/ai-employees/avatars.d.ts +0 -9
  304. package/dist/client/ai-employees/built-in/utils.d.ts +0 -15
  305. package/dist/client/ai-employees/business-report/tools/index.d.ts +0 -10
  306. package/dist/client/ai-employees/business-report/ui/report-utils.d.ts +0 -38
  307. package/dist/client/ai-employees/chart-generator/ui/ECharts.d.ts +0 -13
  308. package/dist/client/ai-employees/chatbox/AIThinking.d.ts +0 -12
  309. package/dist/client/ai-employees/chatbox/Attachment.d.ts +0 -14
  310. package/dist/client/ai-employees/chatbox/AttachmentsHeader.d.ts +0 -10
  311. package/dist/client/ai-employees/chatbox/ChatBox.d.ts +0 -12
  312. package/dist/client/ai-employees/chatbox/ContextItemsHeader.d.ts +0 -10
  313. package/dist/client/ai-employees/chatbox/DebugPanel.d.ts +0 -16
  314. package/dist/client/ai-employees/chatbox/EditMessageHeader.d.ts +0 -10
  315. package/dist/client/ai-employees/chatbox/HintMessageHeader.d.ts +0 -10
  316. package/dist/client/ai-employees/chatbox/MessageRenderer.d.ts +0 -33
  317. package/dist/client/ai-employees/chatbox/SenderFooter.d.ts +0 -13
  318. package/dist/client/ai-employees/chatbox/SenderHeader.d.ts +0 -10
  319. package/dist/client/ai-employees/chatbox/SenderPrefix.d.ts +0 -10
  320. package/dist/client/ai-employees/chatbox/Upload.d.ts +0 -12
  321. package/dist/client/ai-employees/chatbox/VirtualList.d.ts +0 -28
  322. package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +0 -13
  323. package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +0 -13
  324. package/dist/client/ai-employees/chatbox/conversations/index.d.ts +0 -9
  325. package/dist/client/ai-employees/chatbox/generative-ui/DefaultToolCard.d.ts +0 -16
  326. package/dist/client/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +0 -18
  327. package/dist/client/ai-employees/chatbox/hooks/useUploadFiles.d.ts +0 -12
  328. package/dist/client/ai-employees/chatbox/markdown/ECharts.d.ts +0 -10
  329. package/dist/client/ai-employees/chatbox/markdown/Form.d.ts +0 -10
  330. package/dist/client/ai-employees/chatbox/markdown/Generating.d.ts +0 -10
  331. package/dist/client/ai-employees/chatbox/markdown/Markdown.d.ts +0 -13
  332. package/dist/client/ai-employees/chatbox/roles.d.ts +0 -32
  333. package/dist/client/ai-employees/chatbox/stores/chat-box.d.ts +0 -9
  334. package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +0 -9
  335. package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +0 -9
  336. package/dist/client/ai-employees/chatbox/stores/chat-tools.d.ts +0 -51
  337. package/dist/client/ai-employees/chatbox/stores/create-selectors.d.ts +0 -18
  338. package/dist/client/ai-employees/chatbox/stores/workflow-tasks.d.ts +0 -45
  339. package/dist/client/ai-employees/context/classic-pages.d.ts +0 -10
  340. package/dist/client/ai-employees/data-modeling/Table.d.ts +0 -12
  341. package/dist/client/ai-employees/data-modeling/setup.d.ts +0 -10
  342. package/dist/client/ai-employees/data-modeling/tools/index.d.ts +0 -10
  343. package/dist/client/ai-employees/data-modeling/ui/useFieldInterfaceOptions.d.ts +0 -14
  344. package/dist/client/ai-employees/datasource/DatasourceList.d.ts +0 -17
  345. package/dist/client/ai-employees/datasource/index.d.ts +0 -9
  346. package/dist/client/ai-employees/flow/events/index.d.ts +0 -9
  347. package/dist/client/ai-employees/flow/index.d.ts +0 -36
  348. package/dist/client/ai-employees/flow/models/AIEmployeeActionModel.d.ts +0 -18
  349. package/dist/client/ai-employees/flow/models/AIEmployeeShortcutModel.d.ts +0 -30
  350. package/dist/client/ai-employees/shortcuts/ShortcutList.d.ts +0 -10
  351. package/dist/client/ai-employees/shortcuts/useShortcuts.d.ts +0 -13
  352. package/dist/client/ai-employees/stores/context-aware.d.ts +0 -19
  353. package/dist/client/ai-employees/sub-agents/tools/index.d.ts +0 -10
  354. package/dist/client/ai-employees/suggestions/tools/index.d.ts +0 -10
  355. package/dist/client/ai-employees/suggestions/ui/SuggestionsOptions.d.ts +0 -13
  356. package/dist/client/ai-employees/types.d.ts +0 -259
  357. package/dist/client/ai-employees/workflow-tasks/tools/index.d.ts +0 -10
  358. package/dist/client/chat-settings/Messages.d.ts +0 -11
  359. package/dist/client/chat-settings/StructuredOutput.d.ts +0 -11
  360. package/dist/client/components/skill-settings.d.ts +0 -22
  361. package/dist/client/features/components.d.ts +0 -9
  362. package/dist/client/features/feature-manager.d.ts +0 -9
  363. package/dist/client/features/index.d.ts +0 -9
  364. package/dist/client/features/vector-database-provider.d.ts +0 -9
  365. package/dist/client/features/vector-store-provider.d.ts +0 -9
  366. package/dist/client/llm-providers/anthropic/ModelSettings.d.ts +0 -10
  367. package/dist/client/llm-providers/anthropic/ProviderSettings.d.ts +0 -10
  368. package/dist/client/llm-providers/anthropic/index.d.ts +0 -10
  369. package/dist/client/llm-providers/components/Chat.d.ts +0 -10
  370. package/dist/client/llm-providers/components/ModelSelect.d.ts +0 -10
  371. package/dist/client/llm-providers/dashscope/ModelSettings.d.ts +0 -10
  372. package/dist/client/llm-providers/dashscope/ProviderSettings.d.ts +0 -10
  373. package/dist/client/llm-providers/dashscope/index.d.ts +0 -10
  374. package/dist/client/llm-providers/deepseek/ModelSettings.d.ts +0 -10
  375. package/dist/client/llm-providers/deepseek/index.d.ts +0 -10
  376. package/dist/client/llm-providers/google-genai/MessageRenderer.d.ts +0 -13
  377. package/dist/client/llm-providers/google-genai/ModelSettings.d.ts +0 -10
  378. package/dist/client/llm-providers/google-genai/ProviderSettings.d.ts +0 -10
  379. package/dist/client/llm-providers/google-genai/index.d.ts +0 -10
  380. package/dist/client/llm-providers/kimi/ModelSettings.d.ts +0 -10
  381. package/dist/client/llm-providers/kimi/index.d.ts +0 -10
  382. package/dist/client/llm-providers/mimo/ModelSettings.d.ts +0 -10
  383. package/dist/client/llm-providers/mimo/index.d.ts +0 -10
  384. package/dist/client/llm-providers/mistral/ModelSettings.d.ts +0 -10
  385. package/dist/client/llm-providers/mistral/index.d.ts +0 -10
  386. package/dist/client/llm-providers/ollama/ModelSettings.d.ts +0 -10
  387. package/dist/client/llm-providers/ollama/ProviderSettings.d.ts +0 -10
  388. package/dist/client/llm-providers/ollama/index.d.ts +0 -10
  389. package/dist/client/llm-providers/openai/completions/ModelSettings.d.ts +0 -10
  390. package/dist/client/llm-providers/openai/completions/index.d.ts +0 -10
  391. package/dist/client/llm-providers/openai/components/ProviderSettings.d.ts +0 -10
  392. package/dist/client/llm-providers/openai/responses/ModelSettings.d.ts +0 -10
  393. package/dist/client/llm-providers/openai/responses/index.d.ts +0 -10
  394. package/dist/client/llm-providers/orcarouter/ModelSettings.d.ts +0 -10
  395. package/dist/client/llm-providers/orcarouter/ProviderSettings.d.ts +0 -10
  396. package/dist/client/llm-providers/orcarouter/index.d.ts +0 -10
  397. package/dist/client/llm-providers/tongyi/ModelSettings.d.ts +0 -10
  398. package/dist/client/llm-providers/tongyi/ProviderSettings.d.ts +0 -10
  399. package/dist/client/llm-providers/tongyi/index.d.ts +0 -10
  400. package/dist/client/llm-providers/xai/ModelSettings.d.ts +0 -10
  401. package/dist/client/llm-providers/xai/index.d.ts +0 -10
  402. package/dist/client/llm-services/LLMServices.d.ts +0 -13
  403. package/dist/client/llm-services/component/DefaultModelSelect.d.ts +0 -10
  404. package/dist/client/llm-services/component/EnabledModelsSelect.d.ts +0 -23
  405. package/dist/client/llm-services/component/LLMTestFlight.d.ts +0 -10
  406. package/dist/client/llm-services/component/ModelOptionsSettings.d.ts +0 -10
  407. package/dist/client/llm-services/component/UnifiedModelSettings.d.ts +0 -10
  408. package/dist/client/llm-services/hooks/useLLMServiceCatalog.d.ts +0 -18
  409. package/dist/client/llm-services/llm-providers.d.ts +0 -27
  410. package/dist/client/llm-services/utils.d.ts +0 -35
  411. package/dist/client/manager/ai-feature-manager.d.ts +0 -9
  412. package/dist/client/manager/ai-manager.d.ts +0 -35
  413. package/dist/client/repositories/AIConfigRepository.d.ts +0 -60
  414. package/dist/client/repositories/hooks/useAIConfigRepository.d.ts +0 -10
  415. package/dist/client/schemas/llms.d.ts +0 -347
  416. package/dist/client/workflow/nodes/employee/components/AIEmployeeSelect.d.ts +0 -10
  417. package/dist/client/workflow/nodes/employee/components/assigness.d.ts +0 -11
  418. package/dist/client/workflow/nodes/employee/components/file-inputs.d.ts +0 -10
  419. package/dist/client/workflow/nodes/employee/components/message-inputs.d.ts +0 -12
  420. package/dist/client/workflow/nodes/employee/components/model-options.d.ts +0 -10
  421. package/dist/client/workflow/nodes/employee/components/structured-output.d.ts +0 -10
  422. package/dist/client/workflow/nodes/employee/components/users-select.d.ts +0 -13
  423. package/dist/client/workflow/nodes/employee/components/web-search-options.d.ts +0 -10
  424. package/dist/client/workflow/nodes/employee/configuration.d.ts +0 -12
  425. package/dist/client/workflow/nodes/employee/flow-models/feedback.d.ts +0 -14
  426. package/dist/client/workflow/nodes/employee/flow-models/task.d.ts +0 -13
  427. package/dist/client/workflow/nodes/llm/ModelSettings.d.ts +0 -11
  428. package/dist/client/workflow/triggers/ai-employee/Parameters.d.ts +0 -13
  429. /package/dist/{client → client-v2}/ai-employees/AISelection.d.ts +0 -0
  430. /package/dist/{client → client-v2}/ai-employees/AISelectionControl.d.ts +0 -0
  431. /package/dist/{client → client-v2}/ai-employees/ai-coding/prompts.d.ts +0 -0
  432. /package/dist/{client → client-v2}/ai-employees/ai-coding/setup.d.ts +0 -0
  433. /package/dist/{client/ai-employees/chatbox/AIEmployeeSwitch.d.ts → client-v2/ai-employees/chatbox/components/AIEmployeeSwitcher.d.ts} +0 -0
  434. /package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/ChatButton.d.ts +0 -0
  435. /package/dist/{client/ai-employees/chatbox/conversations → client-v2/ai-employees/chatbox/components}/Conversations.d.ts +0 -0
  436. /package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/Messages.d.ts +0 -0
  437. /package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/ModelSwitcher.d.ts +0 -0
  438. /package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/SearchSwitch.d.ts +0 -0
  439. /package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/Sender.d.ts +0 -0
  440. /package/dist/{client/ai-employees/chatbox/generative-ui → client-v2/ai-employees/chatbox/components}/ToolModal.d.ts +0 -0
  441. /package/dist/{client/ai-employees/chatbox → client-v2/ai-employees/chatbox/components}/UserPrompt.d.ts +0 -0
  442. /package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useChatBoxEffect.d.ts +0 -0
  443. /package/dist/{client → client-v2}/ai-employees/chatbox/hooks/useLoadMoreObserver.d.ts +0 -0
  444. /package/dist/client-v2/ai-employees/{chatbox/stores → stores}/global-store.d.ts +0 -0
  445. /package/dist/{client/ai-employees/flow/models → client-v2/models/ai-employees}/AIEmployeeShortcutListModel.d.ts +0 -0
  446. /package/dist/{client/ai-employees/flow/models → client-v2/models/ai-employees}/index.d.ts +0 -0
  447. /package/dist/{client/ai-employees/flow/events/ai-context-selection.d.ts → client-v2/workflow/components/index.d.ts} +0 -0
@@ -1,4 +1,10 @@
1
- # Extend Trigger Types
1
+ ---
2
+ title: "Extending Trigger Types"
3
+ description: "Extending trigger types: custom trigger development, configuration interface, trigger logic, API reference."
4
+ keywords: "workflow,extending triggers,custom triggers,trigger development,NocoBase"
5
+ ---
6
+
7
+ # Extending Trigger Types
2
8
 
3
9
  Every workflow must be configured with a specific trigger, which serves as the entry point for starting the process execution.
4
10
 
@@ -62,39 +68,129 @@ After the server starts and loads, the `'interval'` type trigger can be added an
62
68
 
63
69
  The client-side part mainly provides a configuration interface based on the configuration items required by the trigger type. Each trigger type also needs to register its corresponding type configuration with the Workflow plugin.
64
70
 
65
- For example, for the scheduled execution trigger mentioned above, define the required interval time configuration item (`interval`) in the configuration interface form:
71
+ The trigger's configuration interface is defined through a Loader (lazy-loading function), which points to a plain React component that builds the form using antd's `Form.Item`.
72
+
73
+ ### The Simplest Trigger
74
+
75
+ For example, for the interval timer trigger described above, define the interval time configuration item (`interval`) needed in the configuration interface form:
66
76
 
67
77
  ```ts
68
- import { Trigger } from '@nocobase/workflow/client';
78
+ import { Trigger } from '@nocobase/plugin-workflow/client-v2';
69
79
 
70
80
  class MyTrigger extends Trigger {
71
81
  title = 'Interval timer trigger';
72
- // fields of trigger config
73
- fieldset = {
74
- interval: {
75
- type: 'number',
76
- title: 'Interval',
77
- name: 'config.interval',
78
- 'x-decorator': 'FormItem',
79
- 'x-component': 'InputNumber',
80
- default: 60000,
81
- },
82
- };
82
+
83
+ // Trigger config form (lazy-loaded component)
84
+ FieldsetLoader = () => import('./IntervalConfig');
85
+
86
+ // Config validation
87
+ validate(config) {
88
+ return Boolean(config?.interval);
89
+ }
90
+ }
91
+ ```
92
+
93
+ Here, `FieldsetLoader` is a function that returns `Promise<{ default: ComponentType }>`, implementing lazy loading via dynamic `import()`. The component it points to is a standard React function component:
94
+
95
+ ```tsx
96
+ // IntervalConfig.tsx
97
+ import { Form, InputNumber } from 'antd';
98
+
99
+ export default function IntervalConfig() {
100
+ return (
101
+ <Form.Item
102
+ name={['config', 'interval']}
103
+ label="Interval"
104
+ initialValue={60000}
105
+ rules={[{ required: true }]}
106
+ >
107
+ <InputNumber min={1000} />
108
+ </Form.Item>
109
+ );
83
110
  }
84
111
  ```
85
112
 
86
- Then, register this trigger type with the workflow plugin instance within the extended plugin:
113
+ Note that the form field's `name` uses the nested array format `['config', 'fieldName']`, which is the standard antd Form convention.
114
+
115
+ ### Multiple Configuration Interfaces
116
+
117
+ A trigger can provide multiple configuration interfaces for different scenarios:
118
+
119
+ - `PresetFieldsetLoader` — Preset form when creating a workflow (usually contains only required fields)
120
+ ![PresetFieldsetLoader](https://static-docs.nocobase.com/20260701152711.png)
121
+
122
+ - `FieldsetLoader` — Full trigger configuration form (displayed in the configuration drawer)
123
+ ![FieldsetLoader](https://static-docs.nocobase.com/20260701152822.png)
124
+
125
+ - `TriggerFieldsetLoader` — Input form for manual execution
126
+ ![FieldsetLoader](https://static-docs.nocobase.com/20260701152846.png)
127
+
128
+ When a Loader needs to point to a named export (rather than the default export) in a file, use `.then()` to remap:
87
129
 
88
130
  ```ts
89
- import { Plugin } from '@nocobase/client';
90
- import WorkflowPlugin from '@nocobase/plugin-workflow/client';
131
+ class MyTrigger extends Trigger {
132
+ title = 'My trigger';
91
133
 
134
+ PresetFieldsetLoader = () =>
135
+ import('./MyTriggerConfig').then((m) => ({ default: m.MyPresetConfig }));
136
+ FieldsetLoader = () => import('./MyTriggerConfig');
137
+ TriggerFieldsetLoader = () => import('./TriggerMyConfig');
138
+
139
+ validate(config) {
140
+ return Boolean(config?.collection && config?.mode);
141
+ }
142
+
143
+ createDefaultConfig() {
144
+ return { mode: 1 };
145
+ }
146
+ }
147
+ ```
148
+
149
+ ```tsx
150
+ // MyTriggerConfig.tsx
151
+ import { Form, Select } from 'antd';
152
+ import { CollectionCascader } from '@nocobase/plugin-workflow/client-v2';
153
+
154
+ // Preset form for creation (named export)
155
+ export function MyPresetConfig() {
156
+ return (
157
+ <Form.Item name={['config', 'collection']} label="Collection" rules={[{ required: true }]}>
158
+ <CollectionCascader />
159
+ </Form.Item>
160
+ );
161
+ }
162
+
163
+ // Full config form (default export)
164
+ export default function MyTriggerConfig() {
165
+ return (
166
+ <>
167
+ <Form.Item name={['config', 'collection']} label="Collection">
168
+ <CollectionCascader disabled />
169
+ </Form.Item>
170
+ <Form.Item name={['config', 'mode']} label="Mode">
171
+ <Select
172
+ options={[
173
+ { label: 'Created', value: 1 },
174
+ { label: 'Updated', value: 2 },
175
+ ]}
176
+ />
177
+ </Form.Item>
178
+ </>
179
+ );
180
+ }
181
+ ```
182
+
183
+ ### Register the Trigger
184
+
185
+ Register the trigger type with the workflow plugin instance within the extended plugin:
186
+
187
+ ```ts
188
+ import { Plugin } from '@nocobase/client-v2';
92
189
  import MyTrigger from './MyTrigger';
93
190
 
94
191
  export default class extends Plugin {
95
- // You can get and modify the app instance here
96
192
  async load() {
97
- const workflow = this.app.pm.get(WorkflowPlugin) as WorkflowPlugin;
193
+ const workflow = this.app.pm.get('workflow');
98
194
  workflow.registerTrigger('interval', MyTrigger);
99
195
  }
100
196
  }
@@ -106,4 +202,10 @@ After that, the new trigger type will be visible in the workflow configuration i
106
202
  The identifier of the trigger type registered on the client-side must be consistent with the one on the server-side, otherwise it will cause errors.
107
203
  :::
108
204
 
109
- For other details on defining trigger types, please refer to the [Workflow API Reference](./api#pluginregisterTrigger) section.
205
+ For a complete real-world example, refer to: [CollectionTrigger source code](https://github.com/nocobase/nocobase/blob/develop/packages/plugins/%40nocobase/plugin-workflow/src/client-v2/triggers/collection/index.tsx)
206
+
207
+ For other details on defining trigger types, please refer to the [Workflow API Reference](./api) section.
208
+
209
+ :::info{title=Note}
210
+ If you were previously using the legacy (v1) client-side code and want to migrate to the new v2 version, refer to the [v1 to v2 Migration Guide](./migration).
211
+ :::
@@ -6,7 +6,7 @@ A workflow is typically composed of several connected operational steps. Each no
6
6
  A workflow's trigger is not a node. It is only displayed as an entry point in the flowchart, but it is a different concept from a node. For details, please refer to the [Triggers](../triggers/index.md) content.
7
7
  :::
8
8
 
9
- From a functional perspective, the currently implemented nodes can be divided into several major categories (28 types of nodes in total):
9
+ From a functional perspective, the currently implemented nodes can be divided into several major categories (30 types of nodes in total):
10
10
 
11
11
  - Artificial Intelligence
12
12
  - [Large Language Model](../../ai-employees/workflow/nodes/llm/chat.md) (provided by @nocobase/plugin-workflow-llm plugin)
@@ -32,6 +32,7 @@ From a functional perspective, the currently implemented nodes can be divided in
32
32
  - [Query Data](./query.md)
33
33
  - [Aggregate Query](./aggregate.md) (provided by @nocobase/plugin-workflow-aggregate plugin)
34
34
  - [SQL Action](./sql.md) (provided by @nocobase/plugin-workflow-sql plugin)
35
+ - [Database Transaction](./transaction.md) (provided by @nocobase/plugin-workflow-transaction plugin)
35
36
  - Manual Handling
36
37
  - [Manual Handling](./manual.md) (provided by @nocobase/plugin-workflow-manual plugin)
37
38
  - [Approval](./approval.md) (provided by @nocobase/plugin-workflow-approval plugin)
@@ -0,0 +1,81 @@
1
+ ---
2
+ pkg: '@nocobase/plugin-workflow-transaction'
3
+ title: "Workflow node - Database transaction"
4
+ description: "Database transaction node: run data operations from the same data source in one transaction, commit on success, and roll back on failure."
5
+ keywords: "workflow,database transaction,Transaction,rollback,commit,data operation,NocoBase"
6
+ ---
7
+
8
+ # Database Transaction
9
+
10
+ ## Introduction
11
+
12
+ The database transaction node runs a group of database operations in the same transaction. It is suitable for scenarios where multiple data steps must either all succeed or all roll back, such as creating an order, deducting inventory, writing order details, and updating status.
13
+
14
+ The transaction node currently supports database data sources only. Data operations from the same data source inside the node are automatically included in the transaction; other data sources do not use this transaction.
15
+
16
+ This node has been supported since 2.2.0.
17
+
18
+ ## Create Node
19
+
20
+ In the workflow configuration interface, click the plus ("+") button in the flow to add a "Database transaction" node.
21
+
22
+ ![20260610205146](https://static-docs.nocobase.com/20260610205146.png)
23
+
24
+ After creation, two branches are generated:
25
+
26
+ - **Run**: The main branch executed inside the transaction. If all nodes in this branch succeed, the transaction is committed automatically. If any node fails or throws an error, the transaction is rolled back automatically.
27
+ - **After rollback**: The branch executed after rollback. This branch runs outside the transaction and can be used to record logs, send notifications, or perform compensation handling.
28
+
29
+ ![20260610205303](https://static-docs.nocobase.com/20260610205303.png)
30
+
31
+ ## Node Configuration
32
+
33
+ ![20260610205505](https://static-docs.nocobase.com/20260610205505.png)
34
+
35
+ ### Data Source
36
+
37
+ Select the database data source controlled by this transaction. Only data operation nodes from the same data source are automatically included in the transaction.
38
+
39
+ ### Isolation Level
40
+
41
+ Set the transaction isolation level. The default value is `READ UNCOMMITTED`. If your business requires stricter data consistency, choose another isolation level based on database capabilities and concurrency requirements.
42
+
43
+ ### Continue Workflow After Rollback
44
+
45
+ When enabled, the workflow continues to the nodes after the transaction node after the `After rollback` branch finishes.
46
+
47
+ When disabled, the workflow stops at the transaction node after the `After rollback` branch finishes, and subsequent nodes are not executed.
48
+
49
+ ## Usage
50
+
51
+ ### Constraints
52
+
53
+ The `Run` branch does not support asynchronous nodes that suspend the workflow, such as manual handling and delay nodes. The transaction must be committed or rolled back during the current execution. If the `Run` branch enters a waiting state, the system rolls back the transaction and marks the workflow as failed.
54
+
55
+ The `After rollback` branch runs outside the transaction, so it is not subject to the above restriction. You can use asynchronous nodes in this branch as needed, such as sending requests, waiting for manual confirmation, or delaying processing.
56
+
57
+ :::warning Note
58
+ Transactions occupy database connections until they are committed or rolled back. Avoid long-running operations in the `Run` branch and keep only the necessary data reads, writes, and checks there.
59
+ :::
60
+
61
+ ### Nested Transactions
62
+
63
+ Transaction nodes can be nested, but you need to pay attention to the data source scope:
64
+
65
+ - If the inner and outer transactions use the same data source, the inner transaction is created within the outer transaction scope and is handled according to the database and Sequelize capabilities.
66
+ - If the inner transaction uses a different data source, it does not reuse the outer transaction and creates an independent transaction for that data source.
67
+ - If the workflow is triggered by a synchronous collection event, the trigger itself may already provide a top-level transaction for the same data source. The transaction node preferentially reuses the outer transaction of the same data source and does not reuse transactions from different data sources.
68
+
69
+ Nested transactions increase the cost of understanding and troubleshooting. In general, use nested transactions only when you really need a local rollback boundary. Otherwise, prefer wrapping the complete data processing flow in a single transaction node.
70
+
71
+ ### Common Scenario
72
+
73
+ A typical flow is as follows:
74
+
75
+ 1. Query or create related data in the `Run` branch.
76
+ 2. Continue updating inventory, status, details, and other data from the same data source in the `Run` branch.
77
+ 3. If all steps succeed, the transaction is committed automatically.
78
+ 4. If any node fails or throws an error, the transaction is rolled back automatically and the workflow enters the `After rollback` branch.
79
+ 5. Record the failure reason, send notifications, or perform compensation logic in the `After rollback` branch.
80
+
81
+ If the workflow needs to continue after rollback, enable "Continue workflow after rollback".
@@ -0,0 +1,10 @@
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
+ declare const _default: import("@nocobase/ai").ToolsOptions;
10
+ export default _default;
@@ -0,0 +1,86 @@
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 executeFrontendTool_exports = {};
38
+ __export(executeFrontendTool_exports, {
39
+ default: () => executeFrontendTool_default
40
+ });
41
+ module.exports = __toCommonJS(executeFrontendTool_exports);
42
+ var import_ai = require("@nocobase/ai");
43
+ var import_zod = require("zod");
44
+ var import_frontend_tools = require("../../common/frontend-tools");
45
+ var import_frontend_tools2 = require("../../server/frontend-tools");
46
+ var import_package = __toESM(require("../../../package.json"));
47
+ var executeFrontendTool_default = (0, import_ai.defineTools)({
48
+ scope: "GENERAL",
49
+ execution: "frontend",
50
+ defaultPermission: "ALLOW",
51
+ introduction: {
52
+ title: `{{t("Execute frontend tool", { ns: "${import_package.default.name}" })}}`,
53
+ about: `{{t("Execute a frontend tool provided by the selected block.", { ns: "${import_package.default.name}" })}}`
54
+ },
55
+ definition: {
56
+ name: import_frontend_tools.EXECUTE_FRONTEND_TOOL_NAME,
57
+ description: "Execute a frontend tool from the current frontendToolCatalog. Use loadFrontendTool first when you need its input schema. Never use a tool id that is not present in the current catalog.",
58
+ schema: import_zod.z.object({
59
+ toolId: import_zod.z.string().describe("The exact tool id from the current frontendToolCatalog."),
60
+ args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).default({}).describe("Arguments that match the loaded frontend tool schema.")
61
+ })
62
+ },
63
+ invoke: async (ctx, args, runtime) => {
64
+ const tool = await (0, import_frontend_tools2.findCurrentFrontendTool)(ctx, args.toolId);
65
+ if (!tool) {
66
+ return {
67
+ status: "error",
68
+ content: "Frontend tool is unavailable in the current conversation."
69
+ };
70
+ }
71
+ const result = await (0, import_frontend_tools2.readFrontendToolResult)(ctx, runtime.toolCallId);
72
+ if (!(result == null ? void 0 : result.provided)) {
73
+ return {
74
+ status: "error",
75
+ content: "Frontend tool did not return a result."
76
+ };
77
+ }
78
+ if ((0, import_frontend_tools.isFrontendToolInvokeResult)(result.value)) {
79
+ return result.value;
80
+ }
81
+ return {
82
+ status: "success",
83
+ content: result.value
84
+ };
85
+ }
86
+ });
@@ -48,16 +48,17 @@ var formFiller_default = (0, import_ai.defineTools)({
48
48
  execution: "frontend",
49
49
  introduction: {
50
50
  title: `{{t("Form filler", { ns: "${import_package.default.name}" })}}`,
51
- about: `{{t("Fill the form with the given content", { ns: "${import_package.default.name}" })}}`
51
+ about: `{{t("Fill form fields with the given content. This tool only writes values into the form UI; it does not submit or save the form.", { ns: "${import_package.default.name}" })}}`
52
52
  },
53
53
  definition: {
54
54
  name: "formFiller",
55
- description: "Fill the form with the given content",
55
+ description: "Fill form fields with the given content. This tool only writes values into the form UI; it does not submit, save, create, or update records. After using it, tell the user to review the filled values and manually submit the form.",
56
56
  schema: import_zod.z.object({
57
57
  form: import_zod.z.string().describe("The UI Schema ID of the target form to be filled."),
58
58
  data: import_zod.z.object({}).catchall(import_zod.z.any()).describe(
59
59
  `Structured key-value pairs matching the form's JSON Schema,
60
60
  to be assigned to form.values.
61
+ This only populates fields in the form UI and does not submit, save, create, or update records.
61
62
  Example: { "username": "alice", "email": "alice@example.com", "age": 30 }`
62
63
  )
63
64
  })
@@ -65,7 +66,7 @@ var formFiller_default = (0, import_ai.defineTools)({
65
66
  invoke: async () => {
66
67
  return {
67
68
  status: "success",
68
- content: "I have filled the form with the provided data."
69
+ content: "I have filled the form with the provided data. Please review the values and manually submit the form to save the data."
69
70
  };
70
71
  }
71
72
  });
@@ -0,0 +1,10 @@
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
+ declare const _default: import("@nocobase/ai").ToolsOptions;
10
+ export default _default;
@@ -0,0 +1,99 @@
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 loadFrontendTool_exports = {};
38
+ __export(loadFrontendTool_exports, {
39
+ default: () => loadFrontendTool_default
40
+ });
41
+ module.exports = __toCommonJS(loadFrontendTool_exports);
42
+ var import_ai = require("@nocobase/ai");
43
+ var import_zod = require("zod");
44
+ var import_frontend_tools = require("../../common/frontend-tools");
45
+ var import_frontend_tools2 = require("../../server/frontend-tools");
46
+ var import_package = __toESM(require("../../../package.json"));
47
+ var loadFrontendTool_default = (0, import_ai.defineTools)({
48
+ scope: "GENERAL",
49
+ execution: "frontend",
50
+ defaultPermission: "ALLOW",
51
+ introduction: {
52
+ title: `{{t("Load frontend tool", { ns: "${import_package.default.name}" })}}`,
53
+ about: `{{t("Load the input schema of a frontend tool provided by the selected block.", { ns: "${import_package.default.name}" })}}`
54
+ },
55
+ definition: {
56
+ name: import_frontend_tools.LOAD_FRONTEND_TOOL_NAME,
57
+ description: 'Load the complete input schema for one frontend tool. This is not a tool discovery API: only call it with an exact tool id copied from the current frontendToolCatalog, and never invent an id such as "current-workspace". After loading a suitable tool, call executeFrontendTool with arguments that match the returned schema.',
58
+ schema: import_zod.z.object({
59
+ toolId: import_zod.z.string().describe("The exact tool id from the current frontendToolCatalog.")
60
+ })
61
+ },
62
+ invoke: async (ctx, args, runtime) => {
63
+ const tool = await (0, import_frontend_tools2.findCurrentFrontendTool)(ctx, args.toolId);
64
+ if (!tool) {
65
+ return {
66
+ status: "error",
67
+ content: {
68
+ message: "Frontend tool is unavailable in the current conversation."
69
+ }
70
+ };
71
+ }
72
+ const result = await (0, import_frontend_tools2.readFrontendToolResult)(ctx, runtime.toolCallId);
73
+ if (!(result == null ? void 0 : result.provided)) {
74
+ return {
75
+ status: "error",
76
+ content: "Frontend tool manifest was not returned."
77
+ };
78
+ }
79
+ if ((0, import_frontend_tools.isFrontendToolInvokeResult)(result.value)) {
80
+ return result.value;
81
+ }
82
+ if (!(0, import_frontend_tools.isFrontendToolManifest)(result.value) || result.value.id !== args.toolId) {
83
+ return {
84
+ status: "error",
85
+ content: "Frontend tool returned an invalid manifest."
86
+ };
87
+ }
88
+ return {
89
+ status: "success",
90
+ content: {
91
+ id: result.value.id,
92
+ name: result.value.name,
93
+ title: result.value.title,
94
+ description: result.value.description,
95
+ inputSchema: result.value.inputSchema
96
+ }
97
+ };
98
+ }
99
+ });
@@ -40,9 +40,12 @@ var subAgentWebSearch_default = (0, import_ai.defineTools)({
40
40
  },
41
41
  definition: {
42
42
  name: "subAgentWebSearch",
43
- description: "Use the query to search the web and return concise, relevant findings with source links.",
43
+ description: "Search the web for current information. Put all independent search queries needed for this turn into one call so they can run in parallel. Do not call this tool repeatedly with similar queries unless the previous results are clearly insufficient for a critical missing fact.",
44
44
  schema: import_zod.z.object({
45
- query: import_zod.z.array(import_zod.z.string(), "A clear and specific web search query describing the information to retrieve.")
45
+ query: import_zod.z.array(
46
+ import_zod.z.string(),
47
+ "A list of clear, specific, non-overlapping web search queries. Include all independent queries needed for this answer in a single tool call so they can run in parallel."
48
+ )
46
49
  })
47
50
  },
48
51
  invoke: async (ctx, args, id) => {
@@ -51,7 +54,8 @@ var subAgentWebSearch_default = (0, import_ai.defineTools)({
51
54
  const { model } = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? {};
52
55
  const { provider } = await pluginAI.aiManager.getLLMService({
53
56
  ...model,
54
- webSearch: true
57
+ webSearch: true,
58
+ reasoning: { mode: "off" }
55
59
  });
56
60
  if (!((_c = args.query) == null ? void 0 : _c.length)) {
57
61
  return {
@@ -85,19 +89,20 @@ var subAgentWebSearch_default = (0, import_ai.defineTools)({
85
89
  };
86
90
  }
87
91
  });
88
- const WEB_SEARCH_SYSTEM_PROMPT = `You are a web search assistant.
92
+ const WEB_SEARCH_SYSTEM_PROMPT = `You are a web search retrieval assistant.
89
93
 
90
- Your primary task is to retrieve up-to-date information from the internet based on the user's input query.
94
+ Your output is for another AI model, not the final user-facing answer.
91
95
 
92
96
  Requirements:
93
- 1. Actively attempt web retrieval first. Use internet search to find relevant and recent information.
94
- 2. Summarize and synthesize findings clearly and concisely.
95
- 3. Explicitly cite sources for key points whenever possible (for example: website/publication name, article title, and URL if available).
96
- 4. Distinguish confirmed facts from uncertain or incomplete information.
97
- 5. Do not fabricate search results, sources, or real-time data.
98
- 6. If you cannot access reliable real-time information from the internet, clearly and honestly state that real-time retrieval was not possible, then provide the best available general information with that limitation noted.
97
+ 1. Retrieve current, relevant information for the query.
98
+ 2. Return concise findings only. Do not write a polished final answer.
99
+ 3. Include source title, publisher/site, URL, and publication or update date when available.
100
+ 4. Prefer authoritative and recent sources.
101
+ 5. Distinguish confirmed facts from uncertain or incomplete information.
102
+ 6. Do not fabricate results, sources, dates, or URLs.
103
+ 7. If results are weak, say exactly what is missing instead of broadening the search yourself.
99
104
 
100
- Output style:
101
- - Start with a brief direct answer.
102
- - Then provide a structured summary of findings.
103
- - End with a "Sources" section listing the origin of the information used.`;
105
+ Output format:
106
+ - Findings: 3-6 concise bullet points.
107
+ - Sources: numbered list with title, site, URL, and date when available.
108
+ - Gaps: one short sentence if important information could not be verified.`;
@@ -0,0 +1,10 @@
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
+ "use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["23"],{8178:function(e,t,r){r.r(t),r.d(t,{BusinessReportModal:function(){return j},BusinessReportModalFooter:function(){return P}});var n=r(9155),o=r.n(n),a=r(2059),i=r(7375),l=r(3485),u=r(9488),c=r(9305),s=r(1020);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t,r,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){r(e);return}l.done?t(u):Promise.resolve(u).then(n,o)}function f(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){p(a,n,o,i,l,"next",e)}function l(e){p(a,n,o,i,l,"throw",e)}i(void 0)})}}function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){m(e,t,r[t])})}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(k=function(){return!!e})()}function O(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:u(0)}),l(i,"throw",{value:u(1)}),l(i,"return",{value:u(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function u(l){return function(u){var c=[l,u];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var E=function(e){var t,r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=v(t),m(e=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,k()?Reflect.construct(t,r||[],v(this).constructor):t.apply(this,r)),"state",{error:null,resetKey:e.props.resetKey}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&h(n,e),t=[{key:"render",value:function(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}],r=[{key:"getDerivedStateFromError",value:function(e){return{error:e}}},{key:"getDerivedStateFromProps",value:function(e,t){return e.resetKey!==t.resetKey?{error:null,resetKey:e.resetKey}:null}}],t&&y(n.prototype,t),r&&y(n,r),n}(o().Component),S=function(e){var t,r,d,p,y,m,v,h,k,E,S,P,j,M,T,B,R,x,A=e.tool,_=(0,u.kj)(),C=a.theme.useToken().token,L=(t=(0,u.kj)(),r=(0,l.useApp)().apiClient.auth.getLocale(),d=(0,n.useMemo)(function(){return(0,s.cZ)(g(b({},null==A?void 0:A.args),{generatedAt:null==A?void 0:A.invokeEndTime}))},[null==A?void 0:A.args,null==A?void 0:A.invokeEndTime]),p=!["done","confirmed"].includes(A.invokeStatus),y=!!((null==d?void 0:d.title)||(null==d?void 0:d.summary)||(null==d?void 0:d.markdown)),v=(m=w((0,n.useState)(null),2))[0],h=m[1],E=(k=w((0,n.useState)(null),2))[0],S=k[1],P=(0,n.useMemo)(function(){return JSON.stringify({title:(null==d?void 0:d.title)||"",summary:(null==d?void 0:d.summary)||"",markdown:(null==d?void 0:d.markdown)||"",charts:(null==d?void 0:d.charts)||[],generatedAt:(null==d?void 0:d.generatedAt)||null})},[d]),(0,n.useEffect)(function(){h(null),S(null)},[A.id]),(0,n.useEffect)(function(){"success"===A.status&&"done"===A.invokeStatus&&y&&P!==E&&(h(d),S(P))},[y,d,P,E,A.invokeStatus,A.status]),M=(null==(j=v||d)?void 0:j.title)||t("Business analysis report"),T=(0,n.useMemo)(function(){return(0,s.wP)(j,{locale:"string"==typeof r?r:void 0,t:t})},[j,r,t]),B=(0,n.useMemo)(function(){return(0,s.e4)(j)},[j]),R=(0,n.useMemo)(function(){return p?g(b({},j),{charts:[]}):j},[j,p]),x=(0,n.useMemo)(function(){return{content:(null==R?void 0:R.markdown)?(0,s.wP)(R,{locale:"string"==typeof r?r:void 0,t:t}):"# ".concat(M,"\n\n").concat((null==j?void 0:j.summary)||t("Generating business analysis report...")),type:"text",messageId:A.id}},[null==j?void 0:j.summary,r,R,t,M,A.id]),!y&&p?{displayReport:j,isGenerating:p,markdown:T,fileName:B,previewMessage:x,title:M,locale:"string"==typeof r?r:void 0,invalid:!1,loading:!0}:{displayReport:j,isGenerating:p,markdown:T,fileName:B,previewMessage:x,title:M,locale:"string"==typeof r?r:void 0,invalid:!(null==j?void 0:j.title)&&!(null==j?void 0:j.markdown)&&!p,loading:!1}),G=L.previewMessage,F=L.displayReport,D=L.isGenerating,I=L.title,K=L.invalid,N=L.loading,H=L.markdown,X="calc(100vh - ".concat(C.controlHeightLG+6*C.marginXXL,"px)"),J=w((0,n.useState)(""),2),U=J[0],W=J[1],z=(0,n.useMemo)(function(){return JSON.stringify({title:(null==F?void 0:F.title)||"",summary:(null==F?void 0:F.summary)||"",markdown:(null==F?void 0:F.markdown)||"",charts:(null==F?void 0:F.charts)||[],generatedAt:(null==F?void 0:F.generatedAt)||null})},[F]);return((0,n.useEffect)(function(){var e=!1;return f(function(){var t,r;return O(this,function(n){switch(n.label){case 0:if(!(null==F?void 0:F.markdown)||D)return W(""),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,(0,s.UV)(F,{locale:L.locale,t:_})];case 2:if(t=n.sent(),e)return[2];return W(function(e){return e===t?e:t}),[3,4];case 3:return r=n.sent(),e||(console.error("Failed to build business report HTML:",r),W("")),[3,4];case 4:return[2]}})})(),function(){e=!0}},[F,z,D,L.locale,_]),N)?o().createElement(a.Result,{icon:o().createElement(i.LoadingOutlined,{spin:!0}),title:_("Generating business analysis report..."),subTitle:_("The report modal will update in real time as new content arrives.")}):K?o().createElement(a.Alert,{type:"error",showIcon:!0,message:_("Invalid report definition")}):o().createElement("div",null,o().createElement("div",null,o().createElement("div",{style:{paddingRight:C.paddingSM}},o().createElement(a.Typography.Title,{level:4,style:{marginBottom:C.marginXXS}},I,D?o().createElement(a.Spin,{indicator:o().createElement(i.LoadingOutlined,{spin:!0}),size:"small",style:{marginLeft:C.marginSM}}):null),F.summary?o().createElement(a.Typography.Paragraph,{type:"secondary",style:{marginBottom:0}},F.summary):D?o().createElement(a.Typography.Paragraph,{type:"secondary",style:{marginBottom:0}},_("The report modal will update in real time as new content arrives.")):null)),o().createElement(a.Tabs,{style:{height:X},tabBarStyle:{marginBottom:C.marginSM},items:[{key:"preview",label:_("Preview"),children:o().createElement("div",{style:{height:X,overflow:"auto",padding:C.padding,border:"".concat(C.lineWidth,"px ").concat(C.lineType," ").concat(C.colorBorderSecondary),borderRadius:C.borderRadiusLG,background:C.colorBgContainer,color:C.colorText,boxShadow:"inset 0 ".concat(C.lineWidth,"px 0 ").concat(C.colorFillQuaternary)}},o().createElement(c.oz,{message:G},G.content))},{key:"markdown",label:_("Markdown"),children:o().createElement("pre",{style:{height:X,overflow:"auto",padding:C.padding,borderRadius:C.borderRadiusLG,background:C.colorText,color:C.colorBgContainer,whiteSpace:"pre-wrap",wordBreak:"break-word"}},H||_("Generating business analysis report..."))},{key:"html",label:_("HTML"),children:U?o().createElement("iframe",{title:I,srcDoc:U,style:{width:"100%",height:X,border:"".concat(C.lineWidth,"px ").concat(C.lineType," ").concat(C.colorBorderSecondary),borderRadius:C.borderRadiusLG,background:C.colorBgContainer}}):o().createElement(a.Result,{icon:o().createElement(i.LoadingOutlined,{spin:!0}),title:_("Generating business analysis report...")})}]}))},P=function(e){var t=e.tool,r=(0,u.kj)(),c=(0,l.useApp)(),d=a.App.useApp().message,p=c.apiClient.auth.getLocale(),y=(0,n.useMemo)(function(){return(0,s.cZ)(g(b({},null==t?void 0:t.args),{generatedAt:null==t?void 0:t.invokeEndTime}))},[null==t?void 0:t.args,null==t?void 0:t.invokeEndTime]),m=!["done","confirmed"].includes(t.invokeStatus),v=(0,n.useMemo)(function(){return(0,s.wP)(y,{locale:"string"==typeof p?p:void 0,t:r})},[p,y,r]),h=(0,n.useMemo)(function(){return(0,s.e4)(y)},[y]),k=w((0,n.useState)(!1),2),E=k[0],S=k[1],P=!!(null==y?void 0:y.markdown);return o().createElement(a.Space,{wrap:!0,style:{justifyContent:"flex-end",width:"100%"}},o().createElement(a.Button,{icon:o().createElement(i.FileMarkdownOutlined,null),disabled:m||!P,onClick:function(){return(0,s.MT)("".concat(h,".md"),v,"text/markdown;charset=utf-8")}},r("Download Markdown")),o().createElement(a.Button,{icon:o().createElement(i.FileTextOutlined,null),disabled:m||!P||E,onClick:function(){return f(function(){var e;return O(this,function(t){switch(t.label){case 0:S(!0),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,(0,s.UV)(y,{printMode:!0,locale:"string"==typeof p?p:void 0,t:r})];case 2:return e=t.sent(),(0,s.MT)("".concat(h,".html"),e,"text/html;charset=utf-8"),[3,4];case 3:return S(!1),[7];case 4:return[2]}})})()}},r("Download HTML")),o().createElement(a.Button,{type:"primary",icon:o().createElement(i.FilePdfOutlined,null),loading:E,disabled:m||!P||E,onClick:function(){return f(function(){return O(this,function(e){switch(e.label){case 0:S(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,(0,s.Y_)(y,{locale:"string"==typeof p?p:void 0,t:r})];case 2:return e.sent()||d.error(r("Popup blocked. Please allow popups and try again.")),[3,5];case 3:return console.error("Failed to print business report:",e.sent()),d.error(r("Popup blocked. Please allow popups and try again.")),[3,5];case 4:return S(!1),[7];case 5:return[2]}})})()}},r("Print PDF")))},j=function(e){var t=e.tool,r=(0,u.kj)(),n="".concat(t.id,":").concat(t.invokeStatus,":").concat(JSON.stringify(t.args));return o().createElement(E,{resetKey:n,fallback:function(e){return o().createElement(a.Alert,{type:"error",showIcon:!0,message:r("Invalid report definition"),description:e.message})}},o().createElement(S,{tool:t}))};j.displayName="BusinessReportModal",P.displayName="BusinessReportModalFooter"}}]);