@nocobase/plugin-ai 2.1.0-beta.14 → 2.1.0-beta.16
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.
- package/dist/ai/ai-employees/atlas/index.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/ai-coding/prompt.js → ai/ai-employees/atlas/index.js} +29 -20
- package/dist/ai/ai-employees/atlas/prompt.md +84 -0
- package/dist/ai/ai-employees/dara.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/data-visualization/prompt.js → ai/ai-employees/dara.js} +21 -13
- package/dist/ai/ai-employees/dex.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/data-organizer/prompt.js → ai/ai-employees/dex.js} +15 -7
- package/dist/ai/ai-employees/ellis.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/email-assistant/prompt.js → ai/ai-employees/ellis.js} +19 -11
- package/dist/ai/ai-employees/lexi.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/translator/prompt.js → ai/ai-employees/lexi.js} +15 -7
- package/dist/ai/ai-employees/vera.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/research-analyst/prompt.js → ai/ai-employees/vera.js} +16 -8
- package/dist/ai/ai-employees/viz.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/insights-analyst/prompt.js → ai/ai-employees/viz.js} +15 -7
- package/dist/ai/skills/business-analysis-report/SKILLS.md +88 -0
- package/dist/{server/ai-employees/built-in/ai-coding/prompt.d.ts → ai/skills/business-analysis-report/tools/businessReportGenerator.d.ts} +1 -3
- package/dist/ai/skills/business-analysis-report/tools/businessReportGenerator.js +98 -0
- package/dist/ai/skills/document-search/SKILLS.md +69 -0
- package/dist/ai/tools/chartGenerator.js +15 -3
- package/dist/ai/tools/formFiller.js +13 -2
- package/dist/{server/ai-employees/built-in/data-modeling/prompt.d.ts → ai/tools/getSkill.d.ts} +1 -3
- package/dist/{server/ai-employees/built-in/data-modeling/index.js → ai/tools/getSkill.js} +39 -32
- package/dist/{server/ai-employees/built-in/data-organizer/prompt.d.ts → ai/tools/knowledge-base-retrieve.d.ts} +1 -3
- package/dist/ai/tools/knowledge-base-retrieve.js +94 -0
- package/dist/{server/ai-employees/built-in/data-visualization/prompt.d.ts → ai/tools/sub-agents/dispatch-sub-agent-task.d.ts} +1 -3
- package/dist/ai/tools/sub-agents/dispatch-sub-agent-task.js +108 -0
- package/dist/ai/tools/sub-agents/get-ai-employee.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/translator/profile.js → ai/tools/sub-agents/get-ai-employee.js} +28 -21
- package/dist/ai/tools/sub-agents/list-ai-employees.d.ts +10 -0
- package/dist/{server/ai-employees/built-in/email-assistant/profile.js → ai/tools/sub-agents/list-ai-employees.js} +25 -21
- package/dist/ai/tools/sub-agents/shared.d.ts +33 -0
- package/dist/ai/tools/sub-agents/shared.js +169 -0
- package/dist/ai/tools/suggestions.js +15 -4
- package/dist/client/170.d98eacdc00d9d527.js +10 -0
- package/dist/client/228.b18148eb1009d2fb.js +10 -0
- package/dist/client/280.029428b83d62155f.js +10 -0
- package/dist/client/290.0888139e33c9b7cb.js +10 -0
- package/dist/client/{524.954f96ec4fc2fd7a.js → 331.d547c95410476a69.js} +1 -1
- package/dist/client/343.83f7d96664e4e038.js +10 -0
- package/dist/client/406.15c09d98faa2ccf1.js +10 -0
- package/dist/client/428.e9f38da3b0d8b498.js +10 -0
- package/dist/client/486.77c26e2e7f8daf28.js +10 -0
- package/dist/client/502.2b4a51e0a8122e52.js +10 -0
- package/dist/client/525.33a9c8ec28be4ec4.js +10 -0
- package/dist/client/559.133d286a0a0a1d93.js +10 -0
- package/dist/client/{91.90e7098b7fbd5d00.js → 561.776886c5308e3c26.js} +1 -1
- package/dist/client/580.e75f97fb883ad042.js +10 -0
- package/dist/client/597.aa363881a325b5c0.js +10 -0
- package/dist/client/604.de96f3ec4d471afd.js +10 -0
- package/dist/client/614.aa766080f6b99aab.js +10 -0
- package/dist/client/646.ef9d7c2ea8641044.js +10 -0
- package/dist/client/687.224e569a99cae4bb.js +10 -0
- package/dist/client/699.57c0a1acb723202a.js +10 -0
- package/dist/client/711.266b8f1c520d467a.js +10 -0
- package/dist/client/758.a9741e81911e53c3.js +10 -0
- package/dist/client/768.973ce32e15099a48.js +10 -0
- package/dist/client/792.ae8ad1fcae9fd974.js +10 -0
- package/dist/client/820.6a26239ea96c075a.js +10 -0
- package/dist/client/832.0cf69e3f43c320b2.js +10 -0
- package/dist/client/927.ff5cd05b14901ae6.js +10 -0
- package/dist/client/ai-employees/admin/SkillSettings.d.ts +7 -5
- package/dist/client/ai-employees/admin/ToolsSettings.d.ts +17 -0
- package/dist/client/ai-employees/admin/mcp/MCPSettings.d.ts +10 -0
- package/dist/client/ai-employees/admin/mcp/MCPToolsList.d.ts +19 -0
- package/dist/client/ai-employees/admin/mcp/context.d.ts +15 -0
- package/dist/client/ai-employees/admin/mcp/schemas.d.ts +1286 -0
- package/dist/client/ai-employees/built-in/utils.d.ts +1 -0
- package/dist/client/ai-employees/business-report/tools/index.d.ts +10 -0
- package/dist/client/ai-employees/business-report/ui/BusinessReportCard.d.ts +12 -0
- package/dist/client/ai-employees/business-report/ui/BusinessReportModal.d.ts +17 -0
- package/dist/client/ai-employees/business-report/ui/report-utils.d.ts +38 -0
- package/dist/client/ai-employees/chatbox/AIEmployeeSwitch.d.ts +3 -2
- package/dist/client/ai-employees/chatbox/HintMessageHeader.d.ts +10 -0
- package/dist/client/ai-employees/chatbox/ModelSwitcher.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/SearchSwitch.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/Upload.d.ts +3 -1
- package/dist/client/ai-employees/chatbox/conversations/ConversationsList.d.ts +27 -0
- package/dist/client/ai-employees/chatbox/conversations/WorkflowTasksList.d.ts +31 -0
- package/dist/client/ai-employees/chatbox/conversations/common.d.ts +43 -0
- package/dist/{server/document-loader/loader.worker.d.ts → client/ai-employees/chatbox/conversations/index.d.ts} +1 -1
- package/dist/client/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +5 -3
- package/dist/client/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +24 -0
- package/dist/client/ai-employees/chatbox/markdown/ECharts.d.ts +1 -2
- package/dist/client/ai-employees/chatbox/markdown/Markdown.d.ts +1 -1
- package/dist/client/ai-employees/chatbox/roles.d.ts +1 -0
- package/dist/client/ai-employees/chatbox/stores/chat-box.d.ts +8 -0
- package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +4 -0
- package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +8 -0
- package/dist/client/ai-employees/chatbox/stores/workflow-tasks.d.ts +41 -0
- package/dist/client/ai-employees/chatbox/utils.d.ts +17 -7
- package/dist/client/ai-employees/sub-agents/tools/index.d.ts +10 -0
- package/dist/client/ai-employees/sub-agents/ui/SubAgentDispatchCard.d.ts +21 -0
- package/dist/client/ai-employees/types.d.ts +24 -4
- package/dist/{server/ai-employees/built-in/ai-coding/document/example/js-filter → client/ai-employees/workflow-tasks/tools}/index.d.ts +2 -7
- package/dist/client/ai-employees/workflow-tasks/ui/WorkflowTaskOutputCard.d.ts +11 -0
- package/dist/client/components/ListCollapse.d.ts +28 -0
- package/dist/client/index.js +7 -7
- package/dist/client/manager/ai-manager.d.ts +4 -23
- package/dist/client/repositories/AIConfigRepository.d.ts +11 -3
- package/dist/client/workflow/nodes/employee/components/AIEmployeeSelect.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/assigness.d.ts +11 -0
- package/dist/client/workflow/nodes/employee/components/file-inputs.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/message-inputs.d.ts +12 -0
- package/dist/client/workflow/nodes/employee/components/model-options.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/skill-settings.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/structured-output.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/components/users-select.d.ts +15 -0
- package/dist/client/workflow/nodes/employee/components/web-search-options.d.ts +10 -0
- package/dist/client/workflow/nodes/employee/configuration.d.ts +12 -0
- package/dist/client/workflow/nodes/employee/flow-models/feedback.d.ts +13 -0
- package/dist/client/workflow/nodes/employee/flow-models/task.d.ts +13 -0
- package/dist/client/workflow/nodes/employee/index.d.ts +7 -31
- package/dist/collections/ai-employees.js +2 -1
- package/dist/collections/ai-mcp-clients.d.ts +51 -0
- package/dist/collections/ai-mcp-clients.js +111 -0
- package/dist/externalVersion.js +17 -16
- package/dist/locale/en-US.json +136 -8
- package/dist/locale/zh-CN.json +138 -9
- package/dist/node_modules/fast-glob/out/index.js +8 -8
- package/dist/node_modules/fast-glob/package.json +1 -1
- package/dist/node_modules/flexsearch/dist/flexsearch.bundle.min.js +2 -2
- package/dist/node_modules/flexsearch/package.json +1 -1
- package/dist/node_modules/fs-extra/lib/index.js +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.js +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/index.js +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-conversations.d.ts +70 -0
- package/dist/server/ai-employees/ai-conversations.js +325 -0
- package/dist/server/ai-employees/ai-employee.d.ts +100 -19
- package/dist/server/ai-employees/ai-employee.js +484 -261
- package/dist/server/ai-employees/ai-knowledge-base.d.ts +28 -0
- package/dist/server/ai-employees/ai-knowledge-base.js +167 -0
- package/dist/server/ai-employees/middleware/conversation.d.ts +2 -0
- package/dist/server/ai-employees/middleware/conversation.js +38 -5
- package/dist/server/ai-employees/middleware/index.d.ts +2 -0
- package/dist/server/ai-employees/middleware/index.js +5 -1
- package/dist/server/ai-employees/middleware/skill-tools.d.ts +12 -0
- package/dist/server/ai-employees/middleware/skill-tools.js +88 -0
- package/dist/server/ai-employees/middleware/tools.js +37 -10
- package/dist/server/ai-employees/middleware/workflow-history.d.ts +22 -0
- package/dist/server/ai-employees/middleware/workflow-history.js +173 -0
- package/dist/server/ai-employees/prompts.d.ts +16 -1
- package/dist/server/ai-employees/prompts.js +37 -1
- package/dist/server/ai-employees/sub-agents/dispatcher.d.ts +36 -0
- package/dist/server/ai-employees/sub-agents/dispatcher.js +225 -0
- package/dist/server/ai-employees/sub-agents/index.d.ts +9 -0
- package/dist/server/{migrations/20250923221107-setup-build-in.js → ai-employees/sub-agents/index.js} +9 -13
- package/dist/server/ai-employees/templates/form-assistant.d.ts +2 -2
- package/dist/server/ai-employees/templates/form-assistant.js +2 -2
- package/dist/server/ai-employees/utils.js +2 -2
- package/dist/server/collections/ai-conversations.js +18 -0
- 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
- package/dist/server/{ai-employees/built-in/nocobase-assistant/index.js → collections/ai-mcp-clients.js} +12 -13
- package/dist/server/{ai-employees/built-in/ai-coding/document/basic/flow-resource.d.ts → collections/ai-skills.d.ts} +1 -4
- package/dist/server/collections/ai-skills.js +73 -0
- 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
- package/dist/server/collections/ai-workflow-tasks.js +112 -0
- 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
- package/dist/server/collections/users-ai-workflow-tasks.js +44 -0
- package/dist/server/document-loader/constants.d.ts +1 -2
- package/dist/server/document-loader/constants.js +6 -1
- package/dist/server/document-loader/loader.d.ts +0 -1
- package/dist/server/document-loader/loader.js +2 -55
- package/dist/server/document-loader/types.d.ts +0 -1
- package/dist/server/llm-providers/anthropic.d.ts +1 -0
- package/dist/server/llm-providers/anthropic.js +2 -1
- package/dist/server/llm-providers/dashscope.d.ts +1 -0
- package/dist/server/llm-providers/deepseek.d.ts +1 -0
- package/dist/server/llm-providers/google-genai.d.ts +1 -0
- package/dist/server/llm-providers/google-genai.js +2 -1
- package/dist/server/llm-providers/kimi/provider.d.ts +1 -0
- package/dist/server/llm-providers/openai/responses.d.ts +1 -0
- package/dist/server/llm-providers/openai/responses.js +2 -1
- package/dist/server/llm-providers/provider.d.ts +1 -10
- package/dist/server/llm-providers/provider.js +4 -35
- package/dist/server/manager/ai-coding-manager.d.ts +1 -2
- package/dist/server/manager/ai-coding-manager.js +0 -41
- package/dist/server/manager/ai-context-datasource-manager.js +30 -1
- package/dist/server/manager/built-in-manager.d.ts +2 -4
- package/dist/server/manager/built-in-manager.js +8 -118
- package/dist/server/migrations/20260306000001-migrate-skill-settings-tools.js +68 -0
- package/dist/server/migrations/20260319000000-add-ai-conversations-from.d.ts +14 -0
- package/dist/server/migrations/20260319000000-add-ai-conversations-from.js +63 -0
- package/dist/server/migrations/20260424000000-remove-cole-ai-employee.d.ts +14 -0
- package/dist/server/{ai-employees/built-in/email-assistant/index.js → migrations/20260424000000-remove-cole-ai-employee.js} +20 -22
- package/dist/server/plugin.d.ts +6 -1
- package/dist/server/plugin.js +31 -8
- package/dist/server/resource/aiConversations.js +112 -188
- package/dist/server/resource/aiEmployees.js +5 -7
- package/dist/server/resource/aiMcpClients.d.ts +11 -0
- package/dist/server/resource/aiMcpClients.js +78 -0
- package/dist/server/{ai-employees/built-in/ai-coding/document/example/js-column/index.d.ts → resource/aiSkills.d.ts} +3 -7
- package/dist/server/resource/aiSkills.js +71 -0
- package/dist/server/resource/aiTools.js +4 -6
- package/dist/server/resource/aiWorkflowTasks.d.ts +12 -0
- package/dist/server/resource/aiWorkflowTasks.js +290 -0
- package/dist/server/tools/docs.js +4 -3
- package/dist/server/tools/workflow-caller.js +1 -0
- package/dist/server/types/ai-chat-conversation.type.d.ts +8 -2
- package/dist/server/types/ai-message.type.d.ts +7 -0
- package/dist/server/utils.d.ts +3 -0
- package/dist/server/utils.js +28 -3
- package/dist/server/workflow/nodes/employee/files.d.ts +16 -0
- package/dist/server/workflow/nodes/employee/files.js +125 -0
- package/dist/server/workflow/nodes/employee/handler.d.ts +11 -0
- package/dist/server/workflow/nodes/employee/handler.js +107 -0
- package/dist/server/workflow/nodes/employee/index.d.ts +17 -0
- package/dist/server/workflow/nodes/employee/index.js +391 -0
- package/dist/server/workflow/nodes/employee/tools.d.ts +12 -0
- package/dist/server/workflow/nodes/employee/tools.js +133 -0
- package/dist/server/workflow/nodes/employee/types.d.ts +35 -0
- package/dist/server/workflow/nodes/employee/types.js +24 -0
- package/dist/server/workflow/utils.d.ts +14 -0
- package/dist/server/workflow/utils.js +111 -0
- package/package.json +4 -2
- package/dist/client/107.64d9efa24d6b9143.js +0 -10
- package/dist/client/124.768c8aa5d6e6b461.js +0 -10
- package/dist/client/159.d52107c7a34ce2da.js +0 -10
- package/dist/client/192.0419770b69678994.js +0 -10
- package/dist/client/204.91be8cfc54d91a59.js +0 -10
- package/dist/client/238.9f784a7cdb751999.js +0 -10
- package/dist/client/263.6e1dfb1cbb1964f5.js +0 -10
- package/dist/client/35.5ee7503d9c09daa8.js +0 -10
- package/dist/client/47.6bd245f2140efd24.js +0 -10
- package/dist/client/481.03b3d2306d409933.js +0 -10
- package/dist/client/586.6a1510cabaa84f23.js +0 -10
- package/dist/client/650.8871a07b31c307ea.js +0 -10
- package/dist/client/755.e295bbd2b2a1cc21.js +0 -10
- package/dist/client/772.d51f683c55e18dd4.js +0 -10
- package/dist/client/870.84187dcb8c89b4dc.js +0 -10
- package/dist/client/933.baab3aa75f30e020.js +0 -10
- package/dist/client/987.3aee964e7f406939.js +0 -10
- package/dist/server/ai-employees/built-in/ai-coding/document/basic/flow-resource.js +0 -256
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/index.js +0 -48
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_accounts_en.js +0 -452
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_contacts_en.js +0 -363
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_opportunities_en.js +0 -270
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_quotations_en.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_quotations_en.js +0 -219
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_tickets_en.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-column/js_columns_for_tickets_en.js +0 -409
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/accounts_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/accounts_filter_ant_style.js +0 -324
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/contacts_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/contacts_filter_ant_style.js +0 -309
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/index.js +0 -50
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/leads_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/leads_filter_ant_style.js +0 -345
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/opportunities_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/opportunities_filter_ant_style.js +0 -381
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/product_categories_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/product_categories_ant_style.js +0 -545
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/tickets_filter_ant_style.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/example/js-filter/tickets_filter_ant_style.js +0 -346
- package/dist/server/ai-employees/built-in/ai-coding/document/js-action.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-action.js +0 -102
- package/dist/server/ai-employees/built-in/ai-coding/document/js-block.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-block.js +0 -314
- package/dist/server/ai-employees/built-in/ai-coding/document/js-column.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-column.js +0 -113
- package/dist/server/ai-employees/built-in/ai-coding/document/js-field.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-field.js +0 -498
- package/dist/server/ai-employees/built-in/ai-coding/document/js-item.d.ts +0 -13
- package/dist/server/ai-employees/built-in/ai-coding/document/js-item.js +0 -184
- package/dist/server/ai-employees/built-in/ai-coding/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/ai-coding/index.js +0 -99
- package/dist/server/ai-employees/built-in/ai-coding/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/ai-coding/profile.js +0 -60
- package/dist/server/ai-employees/built-in/ai-coding/prompt_en.md +0 -110
- package/dist/server/ai-employees/built-in/data-modeling/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/data-modeling/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/data-modeling/profile.js +0 -60
- package/dist/server/ai-employees/built-in/data-modeling/prompt.js +0 -283
- package/dist/server/ai-employees/built-in/data-organizer/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/data-organizer/index.js +0 -63
- package/dist/server/ai-employees/built-in/data-organizer/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/data-organizer/profile.js +0 -60
- package/dist/server/ai-employees/built-in/data-visualization/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/data-visualization/index.js +0 -58
- package/dist/server/ai-employees/built-in/data-visualization/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/data-visualization/profile.js +0 -60
- package/dist/server/ai-employees/built-in/email-assistant/index.d.ts +0 -34
- package/dist/server/ai-employees/built-in/email-assistant/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/email-assistant/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/insights-analyst/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/insights-analyst/index.js +0 -63
- package/dist/server/ai-employees/built-in/insights-analyst/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/insights-analyst/profile.js +0 -60
- package/dist/server/ai-employees/built-in/insights-analyst/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/nocobase-assistant/index.d.ts +0 -34
- package/dist/server/ai-employees/built-in/nocobase-assistant/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/nocobase-assistant/profile.js +0 -60
- package/dist/server/ai-employees/built-in/nocobase-assistant/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/nocobase-assistant/prompt.js +0 -52
- package/dist/server/ai-employees/built-in/research-analyst/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/research-analyst/index.js +0 -63
- package/dist/server/ai-employees/built-in/research-analyst/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/research-analyst/profile.js +0 -60
- package/dist/server/ai-employees/built-in/research-analyst/prompt.d.ts +0 -12
- package/dist/server/ai-employees/built-in/translator/index.d.ts +0 -37
- package/dist/server/ai-employees/built-in/translator/index.js +0 -67
- package/dist/server/ai-employees/built-in/translator/profile.d.ts +0 -27
- package/dist/server/ai-employees/built-in/translator/prompt.d.ts +0 -12
- package/dist/server/document-loader/loader.worker.js +0 -68
- package/dist/server/document-loader/vendor/langchain/document_loaders/fs/text.d.ts +0 -20
- package/dist/server/document-loader/vendor/langchain/document_loaders/fs/text.js +0 -96
- /package/dist/client/ai-employees/chatbox/{Conversations.d.ts → conversations/Conversations.d.ts} +0 -0
- /package/dist/server/migrations/{20250923221107-setup-build-in.d.ts → 20260306000001-migrate-skill-settings-tools.d.ts} +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
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 workflow_history_exports = {};
|
|
38
|
+
__export(workflow_history_exports, {
|
|
39
|
+
WorkflowJobsLogHandler: () => WorkflowJobsLogHandler,
|
|
40
|
+
workflowHistoryMiddleware: () => workflowHistoryMiddleware
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(workflow_history_exports);
|
|
43
|
+
var import_langchain = require("langchain");
|
|
44
|
+
var import_zod = __toESM(require("zod"));
|
|
45
|
+
const WORKFLOW_JOB_LOG_MAX_LENGTH = 200;
|
|
46
|
+
const truncateWorkflowJobLogValue = (value) => value.length > WORKFLOW_JOB_LOG_MAX_LENGTH ? `${value.slice(0, WORKFLOW_JOB_LOG_MAX_LENGTH)}...` : value;
|
|
47
|
+
const normalizeToolMessageContent = (value) => {
|
|
48
|
+
if (typeof value === "string") {
|
|
49
|
+
return truncateWorkflowJobLogValue(value);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return truncateWorkflowJobLogValue(JSON.stringify(value));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return truncateWorkflowJobLogValue(String(value ?? ""));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const serializeToolCall = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
return truncateWorkflowJobLogValue(JSON.stringify(value));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return truncateWorkflowJobLogValue(String(value ?? ""));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const appendWorkflowJobLogText = (currentLog, nextLog) => {
|
|
65
|
+
const existingLog = typeof currentLog === "string" ? currentLog : String(currentLog ?? "");
|
|
66
|
+
if (!existingLog) {
|
|
67
|
+
return nextLog;
|
|
68
|
+
}
|
|
69
|
+
return existingLog.endsWith("\n") ? `${existingLog}${nextLog}` : `${existingLog}
|
|
70
|
+
${nextLog}`;
|
|
71
|
+
};
|
|
72
|
+
class WorkflowJobsLogHandler {
|
|
73
|
+
constructor(db, sessionId) {
|
|
74
|
+
this.db = db;
|
|
75
|
+
this.sessionId = sessionId;
|
|
76
|
+
}
|
|
77
|
+
async append(entries) {
|
|
78
|
+
if (!entries.length) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const conversation = await this.db.getRepository("aiConversations").findOne({
|
|
82
|
+
filter: {
|
|
83
|
+
sessionId: this.sessionId
|
|
84
|
+
},
|
|
85
|
+
fields: ["sessionId", "thread"]
|
|
86
|
+
});
|
|
87
|
+
const task = await this.db.getRepository("aiWorkflowTasks").findOne({
|
|
88
|
+
filter: {
|
|
89
|
+
sessionId: this.sessionId
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (!(task == null ? void 0 : task.jobId)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const job = await this.db.getModel("jobs").findByPk(task.jobId);
|
|
96
|
+
if (!job) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const thread = (conversation == null ? void 0 : conversation.thread) ?? 0;
|
|
100
|
+
const nextLog = entries.map(({ type, toolCallId, value }) => {
|
|
101
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
102
|
+
const payload = type === "toolCall" ? serializeToolCall(value) : normalizeToolMessageContent(value);
|
|
103
|
+
return `${createdAt} [${this.sessionId}:${thread}] [${toolCallId ?? ""}] ${payload}`;
|
|
104
|
+
}).join("\n");
|
|
105
|
+
const currentLog = typeof job.get === "function" ? job.get("log") : job.log;
|
|
106
|
+
job.set({
|
|
107
|
+
log: appendWorkflowJobLogText(currentLog, nextLog)
|
|
108
|
+
});
|
|
109
|
+
await job.save();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const workflowHistoryMiddleware = (aiEmployee, db) => {
|
|
113
|
+
const workflowJobsLogHandler = new WorkflowJobsLogHandler(db, aiEmployee.sessionId);
|
|
114
|
+
return (0, import_langchain.createMiddleware)({
|
|
115
|
+
name: "WorkflowHistoryMiddleware",
|
|
116
|
+
contextSchema: import_zod.default.object({
|
|
117
|
+
ctx: import_zod.default.any(),
|
|
118
|
+
appendMessage: import_zod.default.any()
|
|
119
|
+
}),
|
|
120
|
+
stateSchema: import_zod.default.object({
|
|
121
|
+
messageId: import_zod.default.coerce.string().optional(),
|
|
122
|
+
lastMessageIndex: import_zod.default.object({
|
|
123
|
+
lastHumanMessageIndex: import_zod.default.number().default(0),
|
|
124
|
+
lastAIMessageIndex: import_zod.default.number().default(0),
|
|
125
|
+
lastToolMessageIndex: import_zod.default.number().default(0),
|
|
126
|
+
lastMessageIndex: import_zod.default.number().default(0)
|
|
127
|
+
}).default({
|
|
128
|
+
lastHumanMessageIndex: 0,
|
|
129
|
+
lastAIMessageIndex: 0,
|
|
130
|
+
lastToolMessageIndex: 0,
|
|
131
|
+
lastMessageIndex: 0
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
beforeModel: async (state) => {
|
|
135
|
+
var _a;
|
|
136
|
+
const lastToolMessageIndex = ((_a = state.lastMessageIndex) == null ? void 0 : _a.lastToolMessageIndex) ?? 0;
|
|
137
|
+
const toolMessages = state.messages.filter((message) => message.type === "tool").slice(lastToolMessageIndex).map((message) => message);
|
|
138
|
+
if (!toolMessages.length) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await workflowJobsLogHandler.append(
|
|
142
|
+
toolMessages.map((toolMessage) => {
|
|
143
|
+
var _a2;
|
|
144
|
+
return {
|
|
145
|
+
type: "toolMessage",
|
|
146
|
+
toolCallId: toolMessage.tool_call_id ?? ((_a2 = toolMessage == null ? void 0 : toolMessage.artifact) == null ? void 0 : _a2.tool_call_id),
|
|
147
|
+
value: toolMessage.content
|
|
148
|
+
};
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
afterModel: async (state) => {
|
|
153
|
+
const lastMessage = state.messages.at(-1);
|
|
154
|
+
if ((lastMessage == null ? void 0 : lastMessage.type) === "ai") {
|
|
155
|
+
const toolCalls = lastMessage.tool_calls ?? [];
|
|
156
|
+
if (toolCalls.length) {
|
|
157
|
+
await workflowJobsLogHandler.append(
|
|
158
|
+
toolCalls.map((toolCall) => ({
|
|
159
|
+
type: "toolCall",
|
|
160
|
+
toolCallId: toolCall.id,
|
|
161
|
+
value: toolCall
|
|
162
|
+
}))
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
WorkflowJobsLogHandler,
|
|
172
|
+
workflowHistoryMiddleware
|
|
173
|
+
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export declare function getSystemPrompt({ aiEmployee, personal, task, environment, dataSources, knowledgeBase, }: {
|
|
9
|
+
export declare function getSystemPrompt({ aiEmployee, personal, task, environment, dataSources, knowledgeBase, availableSkills, availableAIEmployees, }: {
|
|
10
10
|
aiEmployee: {
|
|
11
11
|
nickname: string;
|
|
12
12
|
about: string;
|
|
@@ -19,7 +19,22 @@ export declare function getSystemPrompt({ aiEmployee, personal, task, environmen
|
|
|
19
19
|
environment: {
|
|
20
20
|
database: string;
|
|
21
21
|
locale: string;
|
|
22
|
+
currentDateTime?: string;
|
|
23
|
+
timezone?: string;
|
|
22
24
|
};
|
|
23
25
|
dataSources?: string;
|
|
24
26
|
knowledgeBase?: string;
|
|
27
|
+
availableSkills?: {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
content?: string;
|
|
31
|
+
}[];
|
|
32
|
+
availableAIEmployees?: {
|
|
33
|
+
username: string;
|
|
34
|
+
nickname: string;
|
|
35
|
+
position: string;
|
|
36
|
+
bio: string;
|
|
37
|
+
greeting: string;
|
|
38
|
+
skillSettings: any;
|
|
39
|
+
}[];
|
|
25
40
|
}): string;
|
|
@@ -35,7 +35,9 @@ function getSystemPrompt({
|
|
|
35
35
|
task,
|
|
36
36
|
environment,
|
|
37
37
|
dataSources,
|
|
38
|
-
knowledgeBase
|
|
38
|
+
knowledgeBase,
|
|
39
|
+
availableSkills,
|
|
40
|
+
availableAIEmployees
|
|
39
41
|
}) {
|
|
40
42
|
const getDatabaseQuotingRules = () => {
|
|
41
43
|
const quotingMap = {
|
|
@@ -74,6 +76,8 @@ This prompt uses a structured tag system to organize your operational framework:
|
|
|
74
76
|
- **\`<environment>\`** - System configuration parameters
|
|
75
77
|
- \`<main_database>\` - Main database engine type (affects SQL syntax and identifier quoting)
|
|
76
78
|
- \`<locale>\` - Communication language and regional formatting
|
|
79
|
+
- \`<current_datetime>\` - Current system date and time for this conversation
|
|
80
|
+
- \`<timezone>\` - User or request timezone when available
|
|
77
81
|
|
|
78
82
|
|
|
79
83
|
### Resources
|
|
@@ -104,6 +108,8 @@ This prompt uses a structured tag system to organize your operational framework:
|
|
|
104
108
|
|
|
105
109
|
4. **Communication Standards**
|
|
106
110
|
- Use language specified in \`<locale>\`: ${environment.locale}, unless the user requests otherwise
|
|
111
|
+
- When the task depends on "now", "today", reporting timestamps, or time ranges, use \`<current_datetime>\` and \`<timezone>\` as the authoritative time context instead of guessing
|
|
112
|
+
- Always follow the frontend date filter contract: valid date operators are only \`$dateOn\`, \`$dateNotOn\`, \`$dateBefore\`, \`$dateAfter\`, \`$dateNotBefore\`, \`$dateNotAfter\`, \`$dateBetween\`, \`$empty\`, and \`$notEmpty\`; valid relative \`type\` values are only \`today\`, \`yesterday\`, \`tomorrow\`, \`thisWeek\`, \`lastWeek\`, \`nextWeek\`, \`thisMonth\`, \`lastMonth\`, \`nextMonth\`, \`thisQuarter\`, \`lastQuarter\`, \`nextQuarter\`, \`thisYear\`, \`lastYear\`, \`nextYear\`, \`past\`, and \`next\`; do not default to UTC timestamp boundaries for calendar queries
|
|
107
113
|
- Be professional, concise, and helpful
|
|
108
114
|
|
|
109
115
|
5. **Tool Integration**
|
|
@@ -134,8 +140,38 @@ ${task.context}
|
|
|
134
140
|
<environment>
|
|
135
141
|
<main_database>${environment.database}</main_database>
|
|
136
142
|
<locale>${environment.locale}</locale>
|
|
143
|
+
${environment.currentDateTime ? `<current_datetime>${environment.currentDateTime}</current_datetime>` : ""}
|
|
144
|
+
${environment.timezone ? `<timezone>${environment.timezone}</timezone>` : ""}
|
|
137
145
|
</environment>
|
|
138
146
|
|
|
147
|
+
${(availableSkills == null ? void 0 : availableSkills.length) ? `<skills>
|
|
148
|
+
You have access to the following skills (tools groups). When a user's request matches a skill's description, use the **getSkill** tool to load that skill's detailed content and available tools
|
|
149
|
+
|
|
150
|
+
${availableSkills.map((skill) => `- **${skill.name}**: ${skill.description || "No description"}`).join("\n")}
|
|
151
|
+
</skills>
|
|
152
|
+
` : ""}
|
|
153
|
+
|
|
154
|
+
${(availableAIEmployees == null ? void 0 : availableAIEmployees.length) ? `<sub_agents>
|
|
155
|
+
The following ${availableAIEmployees.length} AI employees are currently available as sub agents.
|
|
156
|
+
Treat this list as the authoritative routing roster for this conversation.
|
|
157
|
+
Do not call discovery tools just to confirm the same list again.
|
|
158
|
+
Only use discovery when this section is missing, clearly insufficient for the routing decision, contradictory to the current conversation, or you have strong evidence the roster has changed.
|
|
159
|
+
If one listed employee is already an obvious fit, dispatch directly.
|
|
160
|
+
Use profile lookup only when you need deeper instructions before dispatching.
|
|
161
|
+
|
|
162
|
+
${availableAIEmployees.map(
|
|
163
|
+
(it) => {
|
|
164
|
+
var _a, _b, _c, _d, _e, _f;
|
|
165
|
+
return `- ${it.nickname}
|
|
166
|
+
- username: ${it.username}
|
|
167
|
+
- description: ${it.bio}
|
|
168
|
+
- position: ${it.position}
|
|
169
|
+
${((_b = (_a = it.skillSettings) == null ? void 0 : _a.skills) == null ? void 0 : _b.length) ? "- skills:" + ((_c = it.skillSettings) == null ? void 0 : _c.skills.join(",")) : ""}
|
|
170
|
+
${((_e = (_d = it.skillSettings) == null ? void 0 : _d.tools) == null ? void 0 : _e.length) ? "- tools:" + ((_f = it.skillSettings) == null ? void 0 : _f.tools.map((t) => t.name).join(",")) : ""}`;
|
|
171
|
+
}
|
|
172
|
+
)}
|
|
173
|
+
</sub_agents>` : ""}
|
|
174
|
+
|
|
139
175
|
${knowledgeBase ? `<knowledgeBase>${knowledgeBase}</knowledgeBase>` : ""}
|
|
140
176
|
`;
|
|
141
177
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Context } from '@nocobase/actions';
|
|
10
|
+
import { Model } from '@nocobase/database';
|
|
11
|
+
import { ModelRef } from '../ai-employee';
|
|
12
|
+
import type PluginAIServer from '../../plugin';
|
|
13
|
+
import type { UserDecision } from '../../types';
|
|
14
|
+
export type SubAgentTask = {
|
|
15
|
+
ctx: Context;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
employee: Model;
|
|
18
|
+
model: ModelRef;
|
|
19
|
+
question: string;
|
|
20
|
+
skillSettings?: Record<string, any>;
|
|
21
|
+
writer?: (chunk: any) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare class SubAgentsDispatcher {
|
|
24
|
+
protected plugin: PluginAIServer;
|
|
25
|
+
constructor(plugin: PluginAIServer);
|
|
26
|
+
private extractTextContent;
|
|
27
|
+
private extractLastMessageText;
|
|
28
|
+
private resolveSubAgentSessionId;
|
|
29
|
+
private resolveLastMessage;
|
|
30
|
+
run(task: SubAgentTask): Promise<string>;
|
|
31
|
+
isInterrupted(ctx: Context): Promise<boolean>;
|
|
32
|
+
reject(ctx: Context): Promise<{
|
|
33
|
+
interruptId?: string;
|
|
34
|
+
decisions: UserDecision[];
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
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 dispatcher_exports = {};
|
|
28
|
+
__export(dispatcher_exports, {
|
|
29
|
+
SubAgentsDispatcher: () => SubAgentsDispatcher
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(dispatcher_exports);
|
|
32
|
+
var import_ai_employee = require("../ai-employee");
|
|
33
|
+
class SubAgentsDispatcher {
|
|
34
|
+
constructor(plugin) {
|
|
35
|
+
this.plugin = plugin;
|
|
36
|
+
}
|
|
37
|
+
extractTextContent(content) {
|
|
38
|
+
if (typeof content === "string") {
|
|
39
|
+
return content;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(content)) {
|
|
42
|
+
return content.map((block) => {
|
|
43
|
+
if (typeof block === "string") {
|
|
44
|
+
return block;
|
|
45
|
+
}
|
|
46
|
+
if (block && typeof block === "object" && "type" in block && block.type === "text") {
|
|
47
|
+
return typeof block.text === "string" ? block.text : "";
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
}).join("");
|
|
51
|
+
}
|
|
52
|
+
if (content && typeof content === "object" && "content" in content) {
|
|
53
|
+
return this.extractTextContent(content.content);
|
|
54
|
+
}
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
extractLastMessageText(result) {
|
|
58
|
+
var _a;
|
|
59
|
+
const messages = result == null ? void 0 : result.messages;
|
|
60
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
63
|
+
return this.extractTextContent((_a = messages.at(-1)) == null ? void 0 : _a.content);
|
|
64
|
+
}
|
|
65
|
+
async resolveSubAgentSessionId(ctx) {
|
|
66
|
+
var _a, _b, _c, _d, _e;
|
|
67
|
+
const sessionId = (_c = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) == null ? void 0 : _c.sessionId;
|
|
68
|
+
if (!sessionId) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const aiToolMessage = await ctx.db.getRepository("aiToolMessages").findOne({
|
|
72
|
+
filter: {
|
|
73
|
+
sessionId,
|
|
74
|
+
toolName: "dispatch-sub-agent-task",
|
|
75
|
+
invokeStatus: {
|
|
76
|
+
$ne: "confirmed"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
sort: ["-id"]
|
|
80
|
+
});
|
|
81
|
+
if (!(aiToolMessage == null ? void 0 : aiToolMessage.messageId)) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const aiMessage = await ctx.db.getRepository("aiMessages").findOne({
|
|
85
|
+
filter: {
|
|
86
|
+
sessionId,
|
|
87
|
+
messageId: aiToolMessage.messageId
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const subAgentConversations = (_d = aiMessage == null ? void 0 : aiMessage.metadata) == null ? void 0 : _d.subAgentConversations;
|
|
91
|
+
if (!Array.isArray(subAgentConversations) || !subAgentConversations.length) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return ((_e = subAgentConversations.at(-1)) == null ? void 0 : _e.sessionId) ?? null;
|
|
95
|
+
}
|
|
96
|
+
async resolveLastMessage(ctx) {
|
|
97
|
+
const subSessionId = await this.resolveSubAgentSessionId(ctx);
|
|
98
|
+
if (!subSessionId) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return ctx.db.getRepository("aiMessages").findOne({
|
|
102
|
+
filter: {
|
|
103
|
+
sessionId: subSessionId
|
|
104
|
+
},
|
|
105
|
+
sort: ["-messageId"]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async run(task) {
|
|
109
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
110
|
+
const { ctx, sessionId, employee, model, question, skillSettings, writer } = task;
|
|
111
|
+
const { webSearch } = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? {};
|
|
112
|
+
const plugin = ctx.app.pm.get("ai");
|
|
113
|
+
const userId = (_d = (_c = ctx.auth) == null ? void 0 : _c.user) == null ? void 0 : _d.id;
|
|
114
|
+
if (!userId) {
|
|
115
|
+
throw new Error("User not authenticated");
|
|
116
|
+
}
|
|
117
|
+
if (!(model == null ? void 0 : model.llmService) || !(model == null ? void 0 : model.model)) {
|
|
118
|
+
throw new Error("LLM service not configured");
|
|
119
|
+
}
|
|
120
|
+
const aiEmployee = new import_ai_employee.AIEmployee({
|
|
121
|
+
ctx,
|
|
122
|
+
employee,
|
|
123
|
+
sessionId,
|
|
124
|
+
skillSettings,
|
|
125
|
+
webSearch,
|
|
126
|
+
model,
|
|
127
|
+
from: "sub-agent"
|
|
128
|
+
});
|
|
129
|
+
const lastMessage = await ctx.db.getRepository("aiMessages").findOne({
|
|
130
|
+
filter: {
|
|
131
|
+
sessionId
|
|
132
|
+
},
|
|
133
|
+
sort: ["-messageId"]
|
|
134
|
+
});
|
|
135
|
+
const decisions = lastMessage ? await plugin.aiConversationsManager.getUserDecisions(lastMessage.messageId) : null;
|
|
136
|
+
let context;
|
|
137
|
+
const { messages } = ((_f = (_e = ctx.action) == null ? void 0 : _e.params) == null ? void 0 : _f.values) ?? {};
|
|
138
|
+
if (messages && ((_g = decisions == null ? void 0 : decisions.decisions) == null ? void 0 : _g.some((it) => it.type === "reject"))) {
|
|
139
|
+
context = {
|
|
140
|
+
appendMessage: await aiEmployee.getFormatMessages(messages)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const result = await aiEmployee.invoke({
|
|
144
|
+
userDecisions: decisions,
|
|
145
|
+
userMessages: decisions ? void 0 : [
|
|
146
|
+
{
|
|
147
|
+
role: "user",
|
|
148
|
+
content: {
|
|
149
|
+
type: "text",
|
|
150
|
+
content: question
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
writer,
|
|
155
|
+
context
|
|
156
|
+
});
|
|
157
|
+
writer == null ? void 0 : writer({
|
|
158
|
+
action: "afterSubAgentInvoke",
|
|
159
|
+
body: {},
|
|
160
|
+
currentConversation: {
|
|
161
|
+
sessionId,
|
|
162
|
+
username: employee.username,
|
|
163
|
+
from: "sub-agent"
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return this.extractLastMessageText(result);
|
|
167
|
+
}
|
|
168
|
+
async isInterrupted(ctx) {
|
|
169
|
+
var _a, _b, _c;
|
|
170
|
+
const sessionId = (_c = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) == null ? void 0 : _c.sessionId;
|
|
171
|
+
if (!sessionId) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
const aiToolMessage = await ctx.db.getRepository("aiToolMessages").findOne({
|
|
175
|
+
filter: {
|
|
176
|
+
sessionId,
|
|
177
|
+
toolName: "dispatch-sub-agent-task",
|
|
178
|
+
invokeStatus: "pending"
|
|
179
|
+
},
|
|
180
|
+
sort: ["-id"]
|
|
181
|
+
});
|
|
182
|
+
return aiToolMessage ? true : false;
|
|
183
|
+
}
|
|
184
|
+
async reject(ctx) {
|
|
185
|
+
var _a, _b, _c;
|
|
186
|
+
const plugin = ctx.app.pm.get("ai");
|
|
187
|
+
const { sessionId } = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? {};
|
|
188
|
+
const conversation = await ctx.db.getRepository("aiConversations").findOne({
|
|
189
|
+
filter: {
|
|
190
|
+
sessionId,
|
|
191
|
+
userId: (_c = ctx.auth) == null ? void 0 : _c.user.id
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
if (!conversation) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const lastMessage = await this.resolveLastMessage(ctx);
|
|
198
|
+
if (!sessionId || !lastMessage) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const userDecision = {
|
|
202
|
+
type: "reject",
|
|
203
|
+
message: `The user ignored the tools usage and send new messages`
|
|
204
|
+
};
|
|
205
|
+
const [updated] = await ctx.db.getRepository("aiToolMessages").model.update(
|
|
206
|
+
{ userDecision, invokeStatus: "waiting" },
|
|
207
|
+
{
|
|
208
|
+
where: {
|
|
209
|
+
sessionId: lastMessage.get("sessionId"),
|
|
210
|
+
messageId: lastMessage.get("messageId"),
|
|
211
|
+
invokeStatus: "interrupted"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
if (updated > 0) {
|
|
216
|
+
return await plugin.aiConversationsManager.getUserDecisions(lastMessage.get("messageId"));
|
|
217
|
+
} else {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
223
|
+
0 && (module.exports = {
|
|
224
|
+
SubAgentsDispatcher
|
|
225
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { SubAgentsDispatcher } from './dispatcher';
|
package/dist/server/{migrations/20250923221107-setup-build-in.js → ai-employees/sub-agents/index.js}
RENAMED
|
@@ -24,17 +24,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var
|
|
28
|
-
__export(
|
|
29
|
-
|
|
27
|
+
var sub_agents_exports = {};
|
|
28
|
+
__export(sub_agents_exports, {
|
|
29
|
+
SubAgentsDispatcher: () => import_dispatcher.SubAgentsDispatcher
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(sub_agents_exports);
|
|
32
|
+
var import_dispatcher = require("./dispatcher");
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
SubAgentsDispatcher
|
|
30
36
|
});
|
|
31
|
-
module.exports = __toCommonJS(setup_build_in_exports);
|
|
32
|
-
var import_server = require("@nocobase/server");
|
|
33
|
-
class setup_build_in_default extends import_server.Migration {
|
|
34
|
-
on = "afterSync";
|
|
35
|
-
// 'beforeLoad' or 'afterLoad'
|
|
36
|
-
appVersion = "<2.1.0";
|
|
37
|
-
async up() {
|
|
38
|
-
await this.plugin.setupBuiltIn();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -16,7 +16,7 @@ declare const _default: {
|
|
|
16
16
|
greeting: string;
|
|
17
17
|
about: string;
|
|
18
18
|
skillSettings: {
|
|
19
|
-
|
|
19
|
+
tools: string[];
|
|
20
20
|
autoCall: boolean;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
@@ -29,7 +29,7 @@ declare const _default: {
|
|
|
29
29
|
greeting: string;
|
|
30
30
|
about: string;
|
|
31
31
|
skillSettings: {
|
|
32
|
-
|
|
32
|
+
tools: string[];
|
|
33
33
|
autoCall: boolean;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
@@ -45,7 +45,7 @@ var form_assistant_default = {
|
|
|
45
45
|
Unless an error occurs or the user asks for explanation, keep your response natural, focused, and execution-oriented.
|
|
46
46
|
`,
|
|
47
47
|
skillSettings: {
|
|
48
|
-
|
|
48
|
+
tools: ["formFiller"],
|
|
49
49
|
autoCall: true
|
|
50
50
|
}
|
|
51
51
|
},
|
|
@@ -64,7 +64,7 @@ Unless an error occurs or the user asks for explanation, keep your response natu
|
|
|
64
64
|
\u9664\u975E\u53D1\u751F\u9519\u8BEF\u6216\u7528\u6237\u8981\u6C42\u89E3\u91CA\uFF0C\u5426\u5219\u4E0D\u8F93\u51FA\u989D\u5916\u7684\u5206\u6790\u8FC7\u7A0B\u3002\u4FDD\u6301\u56DE\u7B54\u7B80\u6D01\u3001\u4E13\u4E1A\u3001\u805A\u7126\u3002
|
|
65
65
|
`,
|
|
66
66
|
skillSettings: {
|
|
67
|
-
|
|
67
|
+
tools: ["formFiller"],
|
|
68
68
|
autoCall: true
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -40,7 +40,7 @@ const convertAIMessage = ({
|
|
|
40
40
|
var _a;
|
|
41
41
|
const message = aiMessage.content;
|
|
42
42
|
const toolCalls = aiMessage.tool_calls;
|
|
43
|
-
const
|
|
43
|
+
const tools = (_a = aiEmployee.skillSettings) == null ? void 0 : _a.tools;
|
|
44
44
|
if (message == null && !(toolCalls == null ? void 0 : toolCalls.length)) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
@@ -78,7 +78,7 @@ const convertAIMessage = ({
|
|
|
78
78
|
if (toolCalls == null ? void 0 : toolCalls.length) {
|
|
79
79
|
values.toolCalls = toolCalls;
|
|
80
80
|
values.metadata.autoCallTools = toolCalls.filter((tool) => {
|
|
81
|
-
return
|
|
81
|
+
return tools == null ? void 0 : tools.some((s) => s.name === tool.name && s.autoCall);
|
|
82
82
|
}).map((tool) => tool.name);
|
|
83
83
|
}
|
|
84
84
|
if (aiMessage.usage_metadata) {
|
|
@@ -50,6 +50,12 @@ var ai_conversations_default = (0, import_database.defineCollection)({
|
|
|
50
50
|
name: "topicId",
|
|
51
51
|
type: "string"
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
name: "from",
|
|
55
|
+
type: "string",
|
|
56
|
+
defaultValue: "main-agent",
|
|
57
|
+
allowNull: false
|
|
58
|
+
},
|
|
53
59
|
{
|
|
54
60
|
name: "user",
|
|
55
61
|
type: "belongsTo",
|
|
@@ -79,6 +85,18 @@ var ai_conversations_default = (0, import_database.defineCollection)({
|
|
|
79
85
|
{
|
|
80
86
|
name: "options",
|
|
81
87
|
type: "jsonb"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "llmActiveState",
|
|
91
|
+
type: "string",
|
|
92
|
+
// idle,streaming,invoking,
|
|
93
|
+
defaultValue: "idle"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "category",
|
|
97
|
+
type: "string",
|
|
98
|
+
// chat, task
|
|
99
|
+
defaultValue: "chat"
|
|
82
100
|
}
|
|
83
101
|
]
|
|
84
102
|
});
|
|
@@ -6,8 +6,5 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
declare const _default:
|
|
10
|
-
name: string;
|
|
11
|
-
content: string;
|
|
12
|
-
};
|
|
9
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
13
10
|
export default _default;
|