@nocobase/plugin-ai 2.2.0-beta.15 → 2.2.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/docs/nocobase/ai-employees/block/ai-chat-box.md +133 -0
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/documents.md +1 -1
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/index.md +11 -7
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/settings.md +12 -8
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-database.md +3 -3
- package/dist/ai/docs/nocobase/ai-employees/workflow/nodes/knowledge/create-document.md +1 -1
- package/dist/ai/docs/nocobase/api/app/env.md +2 -0
- package/dist/ai/docs/nocobase/building-tips/ai-fill-js-block-form.md +1092 -0
- package/dist/ai/docs/nocobase/data-sources/calendar/calendar-collection.md +100 -3
- package/dist/ai/docs/nocobase/data-sources/collection-comment/index.md +92 -39
- package/dist/ai/docs/nocobase/data-sources/collection-sql/index.md +150 -29
- package/dist/ai/docs/nocobase/data-sources/collection-tree/index.md +93 -5
- package/dist/ai/docs/nocobase/data-sources/collection-view/index.md +226 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/china-region.md +122 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/collection-select.md +105 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/json.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/nano-id.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/snowflake-id.md +108 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/sort.md +3 -19
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/uuid.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/associations/index.md +44 -8
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/color.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/email.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/icon.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/input.md +112 -8
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/integer.md +103 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/number.md +103 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/password.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/percent.md +104 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/phone.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/textarea.md +99 -8
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/url.md +103 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox-group.md +105 -3
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/china-region.md +108 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/multiple-select.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/radio-group.md +106 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/select.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/date.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime-without-tz.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/index.md +53 -47
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/time.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/unix-timestamp.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/circle.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/line.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/point.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/polygon.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/index.md +62 -16
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/markdown.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/rich-text.md +105 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-at.md +105 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-by.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/space.md +100 -6
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/table-oid.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-at.md +104 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-by.md +104 -6
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/validation.md +68 -58
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection.md +32 -13
- package/dist/ai/docs/nocobase/data-sources/data-modeling/index.md +41 -33
- package/dist/ai/docs/nocobase/data-sources/data-source-external-mariadb/index.md +114 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-external-mssql/index.md +117 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-external-mysql/index.md +103 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-external-nocobase/index.md +75 -73
- package/dist/ai/docs/nocobase/data-sources/data-source-external-oracle/index.md +129 -11
- package/dist/ai/docs/nocobase/data-sources/data-source-external-postgres/index.md +110 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-kingbase/index.md +75 -49
- package/dist/ai/docs/nocobase/data-sources/data-source-main/general-collection.md +116 -15
- package/dist/ai/docs/nocobase/data-sources/data-source-main/index.md +92 -62
- package/dist/ai/docs/nocobase/data-sources/data-source-main/inheritance-collection.md +97 -10
- package/dist/ai/docs/nocobase/data-sources/data-source-manager/external-database.md +97 -58
- package/dist/ai/docs/nocobase/data-sources/data-source-manager/index.md +32 -24
- package/dist/ai/docs/nocobase/data-sources/data-source-rest-api/index.md +115 -153
- package/dist/ai/docs/nocobase/data-sources/external/clickhouse.md +124 -0
- package/dist/ai/docs/nocobase/data-sources/external/doris.md +130 -0
- package/dist/ai/docs/nocobase/data-sources/external/index.md +140 -0
- package/dist/ai/docs/nocobase/data-sources/external/kingbase.md +129 -0
- package/dist/ai/docs/nocobase/data-sources/external/mariadb.md +126 -0
- package/dist/ai/docs/nocobase/data-sources/external/mssql.md +129 -0
- package/dist/ai/docs/nocobase/data-sources/external/mysql.md +115 -0
- package/dist/ai/docs/nocobase/data-sources/external/nocobase.md +159 -0
- package/dist/ai/docs/nocobase/data-sources/external/oceanbase.md +126 -0
- package/dist/ai/docs/nocobase/data-sources/external/oracle.md +158 -0
- package/dist/ai/docs/nocobase/data-sources/external/postgresql.md +122 -0
- package/dist/ai/docs/nocobase/data-sources/external/rest-api.md +245 -0
- package/dist/ai/docs/nocobase/data-sources/field-attachment-url/index.md +100 -12
- package/dist/ai/docs/nocobase/data-sources/field-encryption/index.md +48 -47
- package/dist/ai/docs/nocobase/data-sources/field-formula/index.md +99 -5
- package/dist/ai/docs/nocobase/data-sources/field-markdown-vditor/index.md +105 -5
- package/dist/ai/docs/nocobase/data-sources/field-sequence/index.md +102 -5
- package/dist/ai/docs/nocobase/data-sources/field-signature/index.md +18 -16
- package/dist/ai/docs/nocobase/data-sources/field-sort/index.md +76 -73
- package/dist/ai/docs/nocobase/data-sources/file-manager/field-attachment.md +101 -7
- package/dist/ai/docs/nocobase/data-sources/file-manager/file-collection.md +101 -14
- package/dist/ai/docs/nocobase/data-sources/index.md +49 -33
- package/dist/ai/docs/nocobase/data-sources/main/index.md +130 -0
- package/dist/ai/docs/nocobase/data-sources/main/kingbase.md +147 -0
- package/dist/ai/docs/nocobase/data-sources/main/mariadb.md +59 -0
- package/dist/ai/docs/nocobase/data-sources/main/mysql.md +59 -0
- package/dist/ai/docs/nocobase/data-sources/main/oceanbase.md +62 -0
- package/dist/ai/docs/nocobase/data-sources/main/postgresql.md +61 -0
- package/dist/ai/docs/nocobase/file-manager/file-preview/index.md +44 -3
- package/dist/ai/docs/nocobase/file-manager/storage/aliyun-oss.md +100 -3
- package/dist/ai/docs/nocobase/file-manager/storage/index.md +66 -26
- package/dist/ai/docs/nocobase/file-manager/storage/s3-pro.md +58 -7
- package/dist/ai/docs/nocobase/get-started/installation/env.md +1 -1
- package/dist/ai/docs/nocobase/ops-management/migration-manager/built-in-tables.md +1 -2
- package/dist/ai/docs/nocobase/runjs/context/ai.md +194 -4
- package/dist/ai/docs/nocobase/workflow/nodes/javascript.md +21 -1
- package/dist/ai/tools/executeFrontendTool.d.ts +10 -0
- package/dist/ai/tools/executeFrontendTool.js +86 -0
- package/dist/ai/tools/getSkill.js +1 -1
- package/dist/ai/tools/loadFrontendTool.d.ts +10 -0
- package/dist/ai/tools/loadFrontendTool.js +99 -0
- package/dist/client/244.1086967ad8fdedf4.js +10 -0
- package/dist/client/{525.203778500aca5d05.js → 525.94dd4136c1361477.js} +1 -1
- package/dist/client/681.6ffbc9329b9ac242.js +10 -0
- package/dist/{client-v2/705.1d10027ff8cfdf79.js → client/705.19b642db34de438a.js} +1 -1
- package/dist/client/index.d.ts +1 -3
- package/dist/client/index.js +8 -8
- package/dist/client-v2/244.678c34d698985c60.js +10 -0
- package/dist/client-v2/420.b2aedb1ff71fca0e.js +10 -0
- package/dist/client-v2/681.6890caa389564ff7.js +10 -0
- package/dist/client-v2/705.8dc34d43f02f322c.js +10 -0
- package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +2 -0
- package/dist/client-v2/ai-employees/AddContextButton.d.ts +2 -0
- package/dist/client-v2/ai-employees/chatbox/components/AIEmployeeSwitcher.d.ts +1 -0
- package/dist/client-v2/ai-employees/chatbox/components/ChatBoxUnreadBadge.d.ts +17 -0
- package/dist/client-v2/ai-employees/chatbox/components/Conversations.d.ts +9 -1
- package/dist/client-v2/ai-employees/chatbox/components/MessageRenderers.d.ts +1 -1
- package/dist/client-v2/ai-employees/chatbox/components/Messages.d.ts +5 -1
- package/dist/client-v2/ai-employees/chatbox/components/ModelSwitcher.d.ts +4 -0
- package/dist/client-v2/ai-employees/chatbox/components/Sender.d.ts +33 -1
- package/dist/client-v2/ai-employees/chatbox/components/index.d.ts +1 -0
- package/dist/client-v2/ai-employees/chatbox/hooks/useChat.d.ts +8 -5
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +3 -2
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxEffect.d.ts +2 -1
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +3 -2
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +4 -2
- package/dist/client-v2/ai-employees/chatbox/hooks/useToolCallActions.d.ts +3 -1
- package/dist/client-v2/ai-employees/chatbox/hooks/useUploadFiles.d.ts +13 -3
- package/dist/client-v2/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +3 -2
- package/dist/client-v2/ai-employees/chatbox/index.d.ts +17 -0
- package/dist/client-v2/ai-employees/chatbox/roles.d.ts +2 -153
- package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +46 -31
- package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +7 -7
- package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +23 -18
- package/dist/client-v2/ai-employees/chatbox/stores/chat-sender.d.ts +43 -0
- package/dist/client-v2/ai-employees/chatbox/stores/chat-tool-call.d.ts +6 -5
- package/dist/client-v2/ai-employees/chatbox/stores/chat-tools.d.ts +11 -5
- package/dist/client-v2/ai-employees/chatbox/stores/mounted-chat-boxes.d.ts +20 -0
- package/dist/client-v2/ai-employees/chatbox/stores/runtime.d.ts +43 -0
- package/dist/client-v2/ai-employees/chatbox/stores/workflow-tasks.d.ts +22 -10
- package/dist/client-v2/ai-employees/chatbox/upload.d.ts +19 -0
- package/dist/client-v2/ai-employees/chatbox/utils.d.ts +28 -4
- package/dist/client-v2/ai-employees/frontend-tools.d.ts +11 -0
- package/dist/client-v2/ai-employees/tools/SuggestionsOptionsCard.d.ts +1 -1
- package/dist/client-v2/ai-employees/tools/WorkflowTaskOutputCard.d.ts +1 -1
- package/dist/client-v2/ai-employees/types.d.ts +30 -0
- package/dist/client-v2/block/ai-chat-box/AIChatBoxBlockModel.d.ts +21 -0
- package/dist/client-v2/block/ai-chat-box/AIChatBoxCoreModel.d.ts +13 -0
- package/dist/client-v2/block/ai-chat-box/components/AIChatBoxCoreView.d.ts +10 -0
- package/dist/client-v2/block/ai-chat-box/components/AIChatBoxView.d.ts +12 -0
- package/dist/client-v2/block/ai-chat-box/index.d.ts +14 -0
- package/dist/client-v2/block/ai-chat-box/settings.d.ts +12 -0
- package/dist/client-v2/block/ai-chat-box/sub-models.d.ts +26 -0
- package/dist/client-v2/block/ai-chat-box/types.d.ts +38 -0
- package/dist/client-v2/block/ai-chat-box/utils.d.ts +26 -0
- package/dist/client-v2/index.d.ts +3 -5
- package/dist/client-v2/index.js +3 -3
- package/dist/client-v2/llm-services/model-select.d.ts +33 -0
- package/dist/client-v2/llm-services/utils.d.ts +1 -0
- package/dist/client-v2/manager/ai-manager.d.ts +10 -3
- package/dist/client-v2/manager/frontend-tool-registry.d.ts +30 -0
- package/dist/client-v2/models/ai-employees/AIEmployeeActionModel.d.ts +4 -1
- package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +7 -0
- package/dist/client-v2/pages/EmployeesPage.d.ts +5 -0
- package/dist/client-v2/pages/LLMServicesPage.d.ts +9 -4
- package/dist/client-v2/runjs/registerAIEmployeeRunJSFacade.d.ts +1 -0
- package/dist/common/ai-employee-validation.d.ts +15 -0
- package/dist/common/ai-employee-validation.js +61 -0
- package/dist/common/error-codes.d.ts +13 -0
- package/dist/common/error-codes.js +48 -0
- package/dist/common/frontend-tools.d.ts +26 -0
- package/dist/common/frontend-tools.js +57 -0
- package/dist/common/llm-service-models.d.ts +16 -0
- package/dist/common/llm-service-models.js +84 -0
- package/dist/externalVersion.js +16 -16
- package/dist/locale/de-DE.json +2 -1
- package/dist/locale/en-US.json +73 -1
- package/dist/locale/es-ES.json +2 -1
- package/dist/locale/fr-FR.json +2 -1
- package/dist/locale/hu-HU.json +2 -1
- package/dist/locale/id-ID.json +2 -1
- package/dist/locale/it-IT.json +2 -1
- package/dist/locale/ja-JP.json +2 -1
- package/dist/locale/ko-KR.json +2 -1
- package/dist/locale/nl-NL.json +2 -1
- package/dist/locale/pt-BR.json +2 -1
- package/dist/locale/ru-RU.json +2 -1
- package/dist/locale/tr-TR.json +2 -1
- package/dist/locale/uk-UA.json +2 -1
- package/dist/locale/vi-VN.json +2 -1
- package/dist/locale/zh-CN.json +73 -1
- package/dist/locale/zh-TW.json +2 -1
- package/dist/node_modules/@langchain/mistralai/package.json +1 -1
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-conversations.d.ts +4 -1
- package/dist/server/ai-employees/ai-conversations.js +2 -0
- package/dist/server/ai-employees/ai-employee.d.ts +2 -1
- package/dist/server/ai-employees/ai-employee.js +26 -7
- package/dist/server/ai-employees/middleware/conversation.js +9 -2
- package/dist/server/collections/ai-conversations.js +5 -0
- package/dist/server/document-loader/constants.js +1 -1
- package/dist/server/frontend-tools.d.ts +25 -0
- package/dist/server/frontend-tools.js +171 -0
- package/dist/server/manager/work-context-handler.js +10 -3
- package/dist/server/plugin.d.ts +1 -0
- package/dist/server/plugin.js +25 -0
- package/dist/server/resource/aiConversations.d.ts +2 -0
- package/dist/server/resource/aiConversations.js +33 -3
- package/dist/server/resource/aiEmployees.d.ts +2 -0
- package/dist/server/resource/aiEmployees.js +62 -0
- package/dist/server/resource/aiWorkflowTasks.js +9 -1
- package/dist/server/resource/llmServices.d.ts +11 -0
- package/dist/server/resource/llmServices.js +85 -0
- package/dist/server/types/knowledge-base.type.d.ts +6 -2
- package/dist/swagger/common.d.ts +143 -0
- package/dist/swagger/common.js +144 -0
- package/dist/swagger/employees.d.ts +301 -0
- package/dist/swagger/employees.js +131 -0
- package/dist/swagger/index.d.ts +1596 -0
- package/dist/swagger/index.js +62 -0
- package/dist/swagger/llm.d.ts +563 -0
- package/dist/swagger/llm.js +255 -0
- package/dist/swagger/schemas.d.ts +736 -0
- package/dist/swagger/schemas.js +381 -0
- package/package.json +2 -2
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-store.md +0 -24
- package/dist/ai/docs/nocobase/data-sources/development/index.md +0 -6
- package/dist/client/372.40eb52905e3f3049.js +0 -10
- package/dist/client/681.399948c18d753667.js +0 -10
- package/dist/client/705.380279da896021fb.js +0 -10
- package/dist/client-v2/372.8cc3fde09c9bec77.js +0 -10
- package/dist/client-v2/406.341be51205c674e0.js +0 -10
- package/dist/client-v2/681.082f4f1c7b841983.js +0 -10
- package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +0 -46
- package/dist/client-v2/ai-employees/chatbox/utils/normalizeTriggerTaskOptions.d.ts +0 -19
|
@@ -392,7 +392,7 @@ SERVER_REQUEST_WHITELIST=api.example.com,*.trusted.com,10.0.0.0/8,127.0.0.1
|
|
|
392
392
|
|
|
393
393
|
**When not set**: All `http` / `https` outbound requests are allowed to keep existing behavior. However, if the target is a loopback, private, link-local, or metadata address, or if a domain resolves to one of these addresses, the server logs a warning.
|
|
394
394
|
|
|
395
|
-
**When set**:
|
|
395
|
+
**When set**: The initial request and every redirect destination must match a whitelist entry; non-matching requests will raise an error before the next request is sent. Future versions may gradually tighten the default behavior. If your deployment needs to access internal services, configure an explicit whitelist in advance.
|
|
396
396
|
|
|
397
397
|
Supported formats:
|
|
398
398
|
|
|
@@ -336,9 +336,8 @@ The “Data type” column comes from built-in classification. System base data
|
|
|
336
336
|
| Table | Description | Data type | Default migration strategy | Version control | Backup/restore |
|
|
337
337
|
| --- | --- | --- | --- | --- | --- |
|
|
338
338
|
| `aiKnowledgeBaseDocs` | Document chunks and index metadata stored in knowledge bases | Business runtime data | Schema-only | Not included | Backed up |
|
|
339
|
-
| `aiKnowledgeBase` | Knowledge-base type, external ID, and base information | Business runtime data | Schema-only | Not included | Backed up |
|
|
339
|
+
| `aiKnowledgeBase` | Knowledge-base type, external ID, vector database, LLM service, embedding model, and base information | Business runtime data | Schema-only | Not included | Backed up |
|
|
340
340
|
| `aiVectorDatabases` | Vector database service and connection configuration | Business runtime data | Schema-only | Not included | Backed up |
|
|
341
|
-
| `aiVectorStoreConfig` | Relationship between vector database connections and embedding models | Business runtime data | Schema-only | Not included | Backed up |
|
|
342
341
|
|
|
343
342
|
### Environment variables
|
|
344
343
|
|
|
@@ -1,23 +1,51 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "ctx.ai"
|
|
3
|
-
description: "Use ctx.ai in RunJS to trigger AI employee tasks, either with inline task content or with tasks configured on an AI employee action."
|
|
4
|
-
keywords: "ctx.ai,AI employee,triggerTask,triggerModelTask,RunJS,NocoBase"
|
|
3
|
+
description: "Use ctx.ai in RunJS to trigger AI employee tasks in the global conversation or a specified AI Chat Box, either with inline task content or with tasks configured on an AI employee action."
|
|
4
|
+
keywords: "ctx.ai,AI employee,uploadFile,attachments,triggerTask,triggerModelTask,onResponseLoadingChange,chatBoxUid,AI Chat Box,RunJS,NocoBase"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# ctx.ai
|
|
8
8
|
|
|
9
9
|
Use `ctx.ai` in RunJS to trigger **AI employee tasks**. It works well in JSBlock, JSAction, and other interactions where a button, form, or business flow needs to hand work to a specific AI employee.
|
|
10
10
|
|
|
11
|
-
`ctx.ai`
|
|
11
|
+
`ctx.ai` uploads AI task attachments and triggers tasks. File uploads can be awaited, but task triggering does not return the execution result of the AI employee task. After the call, the task enters the AI employee conversation flow, and the result is handled by the AI employee session.
|
|
12
12
|
|
|
13
13
|
:::warning Note
|
|
14
14
|
|
|
15
|
-
`ctx.ai` is provided by the AI plugin. If the AI plugin is not enabled, or the current RunJS environment has not loaded the corresponding client capability, `ctx.ai` may not exist. You can check `ctx.ai?.triggerTask
|
|
15
|
+
`ctx.ai` is provided by the AI plugin. If the AI plugin is not enabled, or the current RunJS environment has not loaded the corresponding client capability, `ctx.ai` may not exist. You can check `ctx.ai?.uploadFile`, `ctx.ai?.triggerTask`, or `ctx.ai?.triggerModelTask` before calling it.
|
|
16
16
|
|
|
17
17
|
:::
|
|
18
18
|
|
|
19
19
|
## Methods
|
|
20
20
|
|
|
21
|
+
### ctx.ai.uploadFile()
|
|
22
|
+
|
|
23
|
+
Upload one file and return an attachment object that can be passed directly to an AI employee task.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const attachment = await ctx.ai.uploadFile(file, options);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Parameter | Type | Description |
|
|
30
|
+
|------|------|------|
|
|
31
|
+
| `file` | `File` | Browser file object to upload. |
|
|
32
|
+
| `options.onProgress` | `(percent: number) => void` | Upload progress callback. `percent` ranges from `0` to `100`. |
|
|
33
|
+
| `options.signal` | `AbortSignal` | Signal used to cancel the upload. |
|
|
34
|
+
|
|
35
|
+
The upload uses the file storage configured by the AI plugin and creates a record in `aiFiles`. The returned object includes fields such as `id`, `filename`, `url`, and `source`:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const attachment = await ctx.ai.uploadFile(file, {
|
|
39
|
+
onProgress(percent) {
|
|
40
|
+
console.log('upload progress', percent);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// attachment can be placed directly in message.attachments
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The Promise is rejected when the upload fails. Removing an attachment from the local UI does not delete the record already created in `aiFiles`, matching the behavior of the default AI chat window.
|
|
48
|
+
|
|
21
49
|
### ctx.ai.triggerTask()
|
|
22
50
|
|
|
23
51
|
Trigger an AI employee task directly.
|
|
@@ -30,8 +58,10 @@ ctx.ai.triggerTask(options: TriggerTaskOptions): void
|
|
|
30
58
|
|------|------|------|
|
|
31
59
|
| `aiEmployee` | `string \| AIEmployee` | AI employee. When a string is passed, NocoBase matches `AIEmployee.username` exactly, and the AI employee must be accessible to the current user. |
|
|
32
60
|
| `tasks` | `Task[]` | Tasks to trigger. |
|
|
61
|
+
| `chatBoxUid` | `string` | FlowModel uid of the AI Chat Box block that should receive the task. |
|
|
33
62
|
| `open` | `boolean` | Whether to open the AI employee conversation panel. |
|
|
34
63
|
| `auto` | `boolean` | Whether to use the auto-trigger semantics of an AI employee action. |
|
|
64
|
+
| `onResponseLoadingChange` | `(loading: boolean) => void` | Model response loading callback. It only runs when this task is sent automatically. |
|
|
35
65
|
|
|
36
66
|
Common `Task` fields:
|
|
37
67
|
|
|
@@ -40,12 +70,160 @@ Common `Task` fields:
|
|
|
40
70
|
| `title` | `string` | Task title. |
|
|
41
71
|
| `message.system` | `string` | System message, used to constrain the AI employee's role and output requirements. |
|
|
42
72
|
| `message.user` | `string` | User message, which is the main instruction for this task. |
|
|
73
|
+
| `message.attachments` | `Attachment[]` | Attachments used by the task, usually returned by `ctx.ai.uploadFile()`. |
|
|
43
74
|
| `message.workContext` | `ContextItem[]` | Page block context used by the task. |
|
|
44
75
|
| `autoSend` | `boolean` | Whether to send the task message automatically. |
|
|
45
76
|
| `webSearch` | `boolean` | Whether Web search is allowed for this task. |
|
|
46
77
|
| `model` | `{ llmService: string; model: string } \| null` | Model used by this task. |
|
|
47
78
|
| `skillSettings` | `SkillSettings` | Skills and tools available to this task. |
|
|
48
79
|
|
|
80
|
+
### Track the Response Loading State
|
|
81
|
+
|
|
82
|
+
Pass `onResponseLoadingChange` in the top-level options to track the model response loading state for this task. The callback receives `true` when NocoBase starts waiting for the model response, and `false` when the response completes, is canceled, or fails. If the React component has declared `setResponseLoading` with `useState`, you can write:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
ctx.ai.triggerTask({
|
|
86
|
+
aiEmployee: 'nathan',
|
|
87
|
+
open: true,
|
|
88
|
+
tasks: [
|
|
89
|
+
{
|
|
90
|
+
title: ctx.t('Review current page'),
|
|
91
|
+
message: {
|
|
92
|
+
user: 'Review the current page and summarize the main risks.',
|
|
93
|
+
},
|
|
94
|
+
autoSend: true,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
onResponseLoadingChange(loading) {
|
|
98
|
+
setResponseLoading(loading);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`onResponseLoadingChange` only tracks the model response started directly by this `triggerTask()` call. With `autoSend: false`, the task is placed in the chat draft and the callback does not run. If the user sends the draft later, that manual send does not reuse this callback.
|
|
104
|
+
|
|
105
|
+
In a React component inside a JS block, this state update rerenders the component while it remains mounted.
|
|
106
|
+
|
|
107
|
+
### Target an AI Chat Box
|
|
108
|
+
|
|
109
|
+
Set `chatBoxUid` on the top-level `triggerTask()` options to trigger the task in a mounted AI Chat Box block instead of the global AI employee dialog.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
ctx.ai.triggerTask({
|
|
113
|
+
aiEmployee: 'nathan',
|
|
114
|
+
chatBoxUid: 'AI_CHAT_BOX_BLOCK_UID',
|
|
115
|
+
open: true,
|
|
116
|
+
tasks: [
|
|
117
|
+
{
|
|
118
|
+
title: ctx.t('Review current page'),
|
|
119
|
+
message: {
|
|
120
|
+
user: 'Review the current page and summarize the main risks.',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The uid must belong to the outer AI Chat Box block currently mounted on the page. Do not put this routing value inside `tasks`. If the target block cannot be found, NocoBase reports an error and does not fall back to the global dialog. When `chatBoxUid` is omitted, the task uses the global AI employee dialog.
|
|
128
|
+
|
|
129
|
+
### Upload and Send Attachments in JSBlock
|
|
130
|
+
|
|
131
|
+
The following example renders file upload, task instructions, and a send button in JSBlock. Uploaded files are passed to the AI employee through `message.attachments`:
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
if (!ctx.ai?.uploadFile || !ctx.ai?.triggerTask) {
|
|
135
|
+
ctx.message.error(ctx.t('AI employee task API is not available.'));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const { React } = ctx.libs;
|
|
140
|
+
const { useState } = React;
|
|
141
|
+
const { Button, Card, Input, Space, Upload } = ctx.libs.antd;
|
|
142
|
+
const { InboxOutlined, SendOutlined } = ctx.libs.antdIcons;
|
|
143
|
+
|
|
144
|
+
const AttachmentTask = () => {
|
|
145
|
+
const [prompt, setPrompt] = useState('');
|
|
146
|
+
const [fileList, setFileList] = useState([]);
|
|
147
|
+
|
|
148
|
+
const uploadAttachment = async ({ file, onError, onProgress, onSuccess }) => {
|
|
149
|
+
try {
|
|
150
|
+
const attachment = await ctx.ai.uploadFile(file, {
|
|
151
|
+
onProgress(percent) {
|
|
152
|
+
onProgress?.({ percent });
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
onSuccess?.(attachment);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
onError?.(error instanceof Error ? error : new Error(ctx.t('File upload failed')));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const sendTask = () => {
|
|
162
|
+
const attachments = fileList
|
|
163
|
+
.filter((file) => file.status === 'done' && file.response)
|
|
164
|
+
.map((file) => file.response);
|
|
165
|
+
|
|
166
|
+
if (!prompt.trim()) {
|
|
167
|
+
ctx.message.warning(ctx.t('Enter task instructions'));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
ctx.ai.triggerTask({
|
|
172
|
+
aiEmployee: 'viz',
|
|
173
|
+
open: true,
|
|
174
|
+
tasks: [
|
|
175
|
+
{
|
|
176
|
+
title: ctx.t('Analyze uploaded files'),
|
|
177
|
+
message: {
|
|
178
|
+
user: prompt.trim(),
|
|
179
|
+
attachments,
|
|
180
|
+
},
|
|
181
|
+
autoSend: true,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
});
|
|
185
|
+
setPrompt('');
|
|
186
|
+
setFileList([]);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const uploading = fileList.some((file) => file.status === 'uploading');
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<Card title={ctx.t('AI file analysis')}>
|
|
193
|
+
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
|
194
|
+
<Upload.Dragger
|
|
195
|
+
multiple
|
|
196
|
+
fileList={fileList}
|
|
197
|
+
customRequest={uploadAttachment}
|
|
198
|
+
onChange={({ fileList: nextFileList }) => setFileList(nextFileList)}
|
|
199
|
+
>
|
|
200
|
+
<p className="ant-upload-drag-icon"><InboxOutlined /></p>
|
|
201
|
+
<p>{ctx.t('Click or drag files here to upload')}</p>
|
|
202
|
+
</Upload.Dragger>
|
|
203
|
+
<Input.TextArea
|
|
204
|
+
value={prompt}
|
|
205
|
+
onChange={(event) => setPrompt(event.target.value)}
|
|
206
|
+
placeholder={ctx.t('Describe the task for the AI employee')}
|
|
207
|
+
autoSize={{ minRows: 3, maxRows: 8 }}
|
|
208
|
+
/>
|
|
209
|
+
<Button
|
|
210
|
+
type="primary"
|
|
211
|
+
icon={<SendOutlined />}
|
|
212
|
+
disabled={uploading || !prompt.trim()}
|
|
213
|
+
onClick={sendTask}
|
|
214
|
+
>
|
|
215
|
+
{ctx.t('Send to AI')}
|
|
216
|
+
</Button>
|
|
217
|
+
</Space>
|
|
218
|
+
</Card>
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
ctx.render(<AttachmentTask />);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
With `autoSend: false`, the attachments and task instructions are placed in the AI chat draft instead of being sent immediately.
|
|
226
|
+
|
|
49
227
|
### Add Page Block Context
|
|
50
228
|
|
|
51
229
|
`message.workContext` currently passes page blocks. Put the FlowModel uid of the target page block into it:
|
|
@@ -163,9 +341,15 @@ ctx.ai.triggerModelTask(uid: string, taskIndex: number, options?: TriggerModelTa
|
|
|
163
341
|
| `taskIndex` | `number` | Task index, starting from `0`. |
|
|
164
342
|
| `options.open` | `boolean` | Whether to open the AI employee conversation panel. |
|
|
165
343
|
| `options.auto` | `boolean` | Whether to use the auto-trigger semantics of an AI employee action. |
|
|
344
|
+
| `options.attachments` | `Attachment[]` | Attachments dynamically appended to the configured task. |
|
|
345
|
+
| `options.onResponseLoadingChange` | `(loading: boolean) => void` | Model response loading callback. It only runs when the configured task is sent automatically. |
|
|
166
346
|
|
|
167
347
|
This method reads the AI employee and task configuration from the target model. It is useful when the task has already been configured on an AI employee action on the page, and RunJS only needs to trigger it.
|
|
168
348
|
|
|
349
|
+
The public `triggerModelTask()` options do not accept `chatBoxUid`. To target an AI Chat Box, configure `chatBoxUid` on the preset task of the AI employee action. `triggerModelTask()` continues to reuse that preset value.
|
|
350
|
+
|
|
351
|
+
`options.onResponseLoadingChange` behaves the same as the option on `triggerTask()`. Whether it runs depends on the configured task's `autoSend` value. It does not run when that task uses `autoSend: false`.
|
|
352
|
+
|
|
169
353
|
```ts
|
|
170
354
|
if (!ctx.ai?.triggerModelTask) {
|
|
171
355
|
ctx.message.error(ctx.t('AI employee task API is not available.'));
|
|
@@ -176,6 +360,7 @@ const weeklyReviewActionUid = 'AI_EMPLOYEE_ACTION_MODEL_UID';
|
|
|
176
360
|
|
|
177
361
|
ctx.ai.triggerModelTask(weeklyReviewActionUid, 0, {
|
|
178
362
|
open: true,
|
|
363
|
+
attachments,
|
|
179
364
|
});
|
|
180
365
|
|
|
181
366
|
ctx.message.success(ctx.t('Configured AI employee task triggered.'));
|
|
@@ -195,9 +380,14 @@ If the target model does not exist, has no AI employee configured, or the specif
|
|
|
195
380
|
## Notes
|
|
196
381
|
|
|
197
382
|
- `triggerTask()` and `triggerModelTask()` are fire-and-forget. They do not return the execution result of the AI employee task.
|
|
383
|
+
- `uploadFile()` returns a Promise. Wait for the upload to finish before triggering a task that uses the attachment.
|
|
198
384
|
- `aiEmployee` strings only match `AIEmployee.username` exactly. They do not match nicknames, job titles, or translated names.
|
|
199
385
|
- `triggerModelTask()` uses a `0`-based `taskIndex`.
|
|
200
386
|
- `triggerModelTask()` reads task configuration from the target AI employee action model. If the task needs work context, configure `message.workContext` on that task.
|
|
387
|
+
- Top-level `triggerTask().chatBoxUid` must reference an AI Chat Box block currently mounted on the page.
|
|
388
|
+
- `triggerModelTask()` keeps using `chatBoxUid` configured on its preset task.
|
|
389
|
+
- Dynamic `triggerModelTask()` attachments are appended to the preset task's existing `message.attachments` without changing the saved task configuration.
|
|
390
|
+
- `onResponseLoadingChange` only tracks a model response automatically sent by the current call. It does not track a message the user sends manually later.
|
|
201
391
|
|
|
202
392
|
## Related
|
|
203
393
|
|
|
@@ -44,6 +44,26 @@ If checked, subsequent nodes will still be executed even if the script encounter
|
|
|
44
44
|
If the script errors out, it will have no return value, and the node's result will be populated with the error message. If subsequent nodes use the result variable from the script node, it should be handled with caution.
|
|
45
45
|
:::
|
|
46
46
|
|
|
47
|
+
## Worker concurrency control
|
|
48
|
+
|
|
49
|
+
JavaScript script nodes place pending scripts in a task queue and execute them in separate Worker threads. By default, NocoBase does not limit JavaScript script Worker concurrency. If multiple tasks are waiting in the queue, they can create Workers and run concurrently.
|
|
50
|
+
|
|
51
|
+
If scripts consume a significant amount of memory while running, multiple Workers can quickly increase the memory usage of an application instance. In this case, use the `WORKFLOW_SCRIPT_WORKER_CONCURRENCY` environment variable to set a concurrency limit. The same applies to CPU-intensive scripts: excessive concurrency increases CPU contention and may affect other requests and workflows in NocoBase. You should also configure this variable if a large number of script tasks may be created within a short period:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
WORKFLOW_SCRIPT_WORKER_CONCURRENCY=4
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The configuration rules are as follows:
|
|
58
|
+
|
|
59
|
+
- If the variable is unset or its value is invalid, concurrency is unlimited
|
|
60
|
+
- A positive integer sets the maximum number of Worker threads that can run concurrently
|
|
61
|
+
- A value of `0` removes the concurrency limit, allowing all queued tasks to run concurrently
|
|
62
|
+
|
|
63
|
+
When the concurrency limit is reached, new tasks remain in the queue until a Worker becomes available. You can keep the default configuration if scripts run infrequently and each execution uses few resources. If you need a concurrency limit, start with a small value and adjust it gradually based on the application instance's memory and CPU usage and task queueing time.
|
|
64
|
+
|
|
65
|
+
If an application runs on multiple server instances, this setting applies separately to each instance. The overall concurrency capacity also depends on the number of instances that can consume tasks. Restart the NocoBase service after changing the environment variable for the new value to take effect.
|
|
66
|
+
|
|
47
67
|
## Execution Engine
|
|
48
68
|
|
|
49
69
|
The JavaScript script node supports two execution engines, automatically selected based on whether the `WORKFLOW_SCRIPT_MODULES` environment variable is configured:
|
|
@@ -164,4 +184,4 @@ async function sleep(time) {
|
|
|
164
184
|
await sleep(1000);
|
|
165
185
|
|
|
166
186
|
return 123;
|
|
167
|
-
```
|
|
187
|
+
```
|
|
@@ -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
|
+
});
|
|
@@ -43,7 +43,7 @@ var import_ai = require("@nocobase/ai");
|
|
|
43
43
|
var import_zod = require("zod");
|
|
44
44
|
var import_package = __toESM(require("../../../package.json"));
|
|
45
45
|
var getSkill_default = (0, import_ai.defineTools)({
|
|
46
|
-
scope: "
|
|
46
|
+
scope: "SPECIFIED",
|
|
47
47
|
defaultPermission: "ALLOW",
|
|
48
48
|
introduction: {
|
|
49
49
|
title: `{{t("Load specific SKILLS", { ns: "${import_package.default.name}" })}}`,
|
|
@@ -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
|
+
});
|