diff --git a/docSite/content/zh-cn/docs/development/openapi/chat.md b/docSite/content/zh-cn/docs/development/openapi/chat.md index b5f1c276d7b4..25f2c835d0ae 100644 --- a/docSite/content/zh-cn/docs/development/openapi/chat.md +++ b/docSite/content/zh-cn/docs/development/openapi/chat.md @@ -866,6 +866,8 @@ curl --location --request DELETE 'http://localhost:3000/api/core/chat/delHistory ### 清空所有历史记录 +仅会情况通过 API Key 创建的对话历史记录,不会清空在线使用、分享链接等其他来源的对话历史记录。 + {{< tabs tabTotal="3" >}} {{< tab tabName="请求示例" >}} {{< markdownify >}} diff --git a/docSite/content/zh-cn/docs/development/upgrading/4816.md b/docSite/content/zh-cn/docs/development/upgrading/4816.md index 12260fb5e5c9..27f9ae10c0f9 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4816.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4816.md @@ -13,9 +13,11 @@ weight: 808 1. 2. 新增 - 商业版支持 API 知识库和链接集合定时同步。 3. 新增 - 猜你想问支持选择模型和自定义提示词。 -4. 优化 - 工作流/简易模式变量初始化代码,去除监听初始化,避免因渲染顺序不一致导致的失败。 -5. 修复 - 无法自动切换默认语言。增加分享链接,强制执行一次切换默认语言。 -6. 修复 - 数组选择器自动兼容 4.8.13 以前的数据。 -7. 修复 - 站点同步知识库,链接同步时未使用选择器。 -8. 修复 - 简易模式转工作流,没有把系统配置项转化。 -9. 修复 - 插件独立运行,变量初始值未赋上。 \ No newline at end of file +4. 新增 - 钉钉和企微机器人 webhook 插件。 +5. 新增 - sandbox 新增 createHmac 加密全局方法。 +6. 优化 - 工作流/简易模式变量初始化代码,去除监听初始化,避免因渲染顺序不一致导致的失败。 +7. 修复 - 无法自动切换默认语言。增加分享链接,强制执行一次切换默认语言。 +8. 修复 - 数组选择器自动兼容 4.8.13 以前的数据。 +9. 修复 - 站点同步知识库,链接同步时未使用选择器。 +10. 修复 - 简易模式转工作流,没有把系统配置项转化。 +11. 修复 - 插件独立运行,变量初始值未赋上。 \ No newline at end of file diff --git a/docSite/content/zh-cn/docs/guide/workbench/workflow/sandbox.md b/docSite/content/zh-cn/docs/guide/workbench/workflow/sandbox.md index 4a6a7aad70e2..61b5eb3ea3ff 100644 --- a/docSite/content/zh-cn/docs/guide/workbench/workflow/sandbox.md +++ b/docSite/content/zh-cn/docs/guide/workbench/workflow/sandbox.md @@ -84,4 +84,18 @@ function main({input}){ } ``` -![alt text](/imgs/image-2.png) \ No newline at end of file +![alt text](/imgs/image-2.png) + +### createHmac 加密 + +与 node 中 crypto 的 createHmac 方法一致。 + +```js +function main({secret}){ + const {sign,timestamp} = createHmac('sha256',secret) + + return { + sign,timestamp + } +} +``` \ No newline at end of file diff --git a/packages/plugins/register.ts b/packages/plugins/register.ts index 3940ff1a1f71..1085a7548687 100644 --- a/packages/plugins/register.ts +++ b/packages/plugins/register.ts @@ -5,7 +5,15 @@ import { cloneDeep } from 'lodash'; import { WorkerNameEnum, runWorker } from '@fastgpt/service/worker/utils'; // Run in main thread -const staticPluginList = ['getTime', 'fetchUrl', 'feishu', 'google', 'bing']; +const staticPluginList = [ + 'getTime', + 'fetchUrl', + 'feishu', + 'DingTalkWebhook', + 'WeWorkWebhook', + 'google', + 'bing' +]; // Run in worker thread (Have npm packages) const packagePluginList = [ 'mathExprVal', diff --git a/packages/plugins/src/DingTalk/template.json b/packages/plugins/src/DingTalkWebhook/template.json similarity index 60% rename from packages/plugins/src/DingTalk/template.json rename to packages/plugins/src/DingTalkWebhook/template.json index f1fc625e0f5f..5195cc9abc1e 100644 --- a/packages/plugins/src/DingTalk/template.json +++ b/packages/plugins/src/DingTalkWebhook/template.json @@ -1,8 +1,8 @@ { "author": "", "version": "4816", - "name": "钉钉机器人 webhook", - "avatar": "/appMarketTemplates/plugin-dingtalk/avatar.svg", + "name": "钉钉 webhook", + "avatar": "plugins/dingding", "intro": "向钉钉机器人发起 webhook 请求。", "courseUrl": "https://open.dingtalk.com/document/robots/custom-robot-access", "showStatus": false, @@ -19,8 +19,8 @@ "flowNodeType": "pluginInput", "showStatus": false, "position": { - "x": 535.7465806305546, - "y": -201.26482361861054 + "x": 557.4542421888484, + "y": -131.2827008898969 }, "version": "481", "inputs": [ @@ -43,25 +43,49 @@ "renderTypeList": ["input"], "required": true, "canEdit": true, - "value": "" + "value": "", + "list": [] }, { - "key": "发送的消息", + "renderTypeList": ["input", "reference"], + "selectedTypeIndex": 0, + "valueType": "string", + "canEdit": true, + "key": "加签值", + "label": "加签值", + "description": "钉钉机器人加签值", + "defaultValue": "", + "list": [ + { + "label": "", + "value": "" + } + ], + "maxFiles": 5, + "canSelectFile": true, + "canSelectImg": true, + "required": true + }, + { + "renderTypeList": ["input", "reference"], + "selectedTypeIndex": 0, "valueType": "string", + "canEdit": true, + "key": "发送的消息", "label": "发送的消息", - "renderTypeList": ["reference"], + "description": "发送的消息", + "defaultValue": "", + "list": [ + { + "label": "", + "value": "" + } + ], + "maxFiles": 5, + "canSelectFile": true, + "canSelectImg": true, "required": true, - "description": "", - "canEdit": true, - "value": "", - "editField": { - "key": true - }, - "dynamicParamDefaultValue": { - "inputType": "reference", - "valueType": "string", - "required": true - } + "toolDescription": "发送的消息" } ], "outputs": [ @@ -73,11 +97,18 @@ "type": "static" }, { - "id": "p0m68Dv5KaIp", - "key": "发送的消息", + "id": "srcret", + "valueType": "string", + "key": "加签值", + "label": "加签值", + "type": "hidden" + }, + { + "id": "发送的消息", "valueType": "string", + "key": "发送的消息", "label": "发送的消息", - "type": "static" + "type": "hidden" } ] }, @@ -89,8 +120,8 @@ "flowNodeType": "pluginOutput", "showStatus": false, "position": { - "x": 1776.027569211593, - "y": -58.264823618610535 + "x": 2420.0305926489386, + "y": -106.28270088989689 }, "version": "481", "inputs": [], @@ -104,8 +135,8 @@ "flowNodeType": "httpRequest468", "showStatus": true, "position": { - "x": 1069.7228495148624, - "y": -392.26482361861054 + "x": 1645.779103978597, + "y": -431.7827008898969 }, "version": "481", "inputs": [ @@ -170,7 +201,7 @@ "description": "common:core.module.input.description.Http Request Url", "placeholder": "https://api.ai.com/getInventory", "required": false, - "value": "{{url}}", + "value": "{{$a5qdMS7ECNYE.qLUQfhG0ILRX$}}", "debugLabel": "", "toolDescription": "" }, @@ -200,7 +231,7 @@ "key": "system_httpJsonBody", "renderTypeList": ["hidden"], "valueType": "any", - "value": "{\r\n \"msgtype\": \"text\",\r\n \"text\": {\r\n \"content\": \"{{text}}\"\r\n }\r\n}", + "value": "{\r\n \"msgtype\": \"text\",\r\n \"text\": {\r\n \"content\": \"{{$pluginInput.发送的消息$}}\"\r\n }\r\n}", "label": "", "required": false, "debugLabel": "", @@ -225,19 +256,73 @@ "required": false, "debugLabel": "", "toolDescription": "" + } + ], + "outputs": [ + { + "id": "error", + "key": "error", + "label": "workflow:request_error", + "description": "HTTP请求错误信息,成功时返回空", + "valueType": "object", + "type": "static" }, { - "key": "text", - "valueType": "string", - "label": "text", - "renderTypeList": ["reference"], - "description": "", - "canEdit": true, + "id": "httpRawResponse", + "key": "httpRawResponse", + "required": true, + "label": "workflow:raw_response", + "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。", + "valueType": "any", + "type": "static" + }, + { + "id": "system_addOutputParam", + "key": "system_addOutputParam", + "type": "dynamic", + "valueType": "dynamic", + "label": "", "editField": { "key": true, "valueType": true - }, - "value": ["pluginInput", "p0m68Dv5KaIp"], + } + } + ] + }, + { + "nodeId": "q3ccNXiZIHoS", + "name": "系统配置", + "intro": "", + "avatar": "core/workflow/template/systemConfig", + "flowNodeType": "pluginConfig", + "position": { + "x": 99.73879703925843, + "y": -201.26482361861054 + }, + "version": "4811", + "inputs": [], + "outputs": [] + }, + { + "nodeId": "a5qdMS7ECNYE", + "name": "代码运行", + "intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。", + "avatar": "core/workflow/template/codeRun", + "flowNodeType": "code", + "showStatus": true, + "position": { + "x": 1106.1011901190363, + "y": -407.7827008898969 + }, + "version": "482", + "inputs": [ + { + "key": "system_addInputParam", + "renderTypeList": ["addInputParam"], + "valueType": "dynamic", + "label": "", + "required": false, + "description": "workflow:these_variables_will_be_input_parameters_for_code_execution", "customInputConfig": { "selectValueTypeList": [ "string", @@ -258,20 +343,67 @@ ], "showDescription": false, "showDefaultValue": true - } + }, + "valueDesc": "", + "debugLabel": "", + "toolDescription": "" }, { - "key": "url", + "key": "codeType", + "renderTypeList": ["hidden"], + "label": "", + "value": "js", + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "key": "code", + "renderTypeList": ["custom"], + "label": "", + "value": "function main({url, secret}){\n const {sign,timestamp} = createHmac('sha256',secret)\n\n return {\n result: `${url}×tamp=${timestamp}&sign=${sign}`\n }\n}", + "valueDesc": "", + "description": "", + "debugLabel": "", + "toolDescription": "" + }, + { + "renderTypeList": ["reference"], "valueType": "string", + "canEdit": true, + "key": "url", "label": "url", + "customInputConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "arrayAny", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": true + }, + "required": true, + "value": ["pluginInput", "mv52BrPVE6bm"] + }, + { "renderTypeList": ["reference"], - "description": "", + "valueType": "string", "canEdit": true, - "editField": { - "key": true, - "valueType": true - }, - "value": ["pluginInput", "mv52BrPVE6bm"], + "key": "secret", + "label": "secret", "customInputConfig": { "selectValueTypeList": [ "string", @@ -292,25 +424,26 @@ ], "showDescription": false, "showDefaultValue": true - } + }, + "required": true, + "value": ["pluginInput", "srcret"] } ], "outputs": [ { - "id": "error", - "key": "error", - "label": "workflow:request_error", - "description": "HTTP请求错误信息,成功时返回空", + "id": "system_rawResponse", + "key": "system_rawResponse", + "label": "workflow:full_response_data", "valueType": "object", - "type": "static" + "type": "static", + "description": "" }, { - "id": "httpRawResponse", - "key": "httpRawResponse", - "required": true, - "label": "workflow:raw_response", - "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。", - "valueType": "any", + "id": "error", + "key": "error", + "label": "workflow:execution_error", + "description": "代码运行错误信息,成功时返回空", + "valueType": "object", "type": "static" }, { @@ -319,41 +452,85 @@ "type": "dynamic", "valueType": "dynamic", "label": "", - "editField": { - "key": true, - "valueType": true - } + "customFieldConfig": { + "selectValueTypeList": [ + "string", + "number", + "boolean", + "object", + "arrayString", + "arrayNumber", + "arrayBoolean", + "arrayObject", + "arrayAny", + "any", + "chatHistory", + "datasetQuote", + "dynamic", + "selectApp", + "selectDataset" + ], + "showDescription": false, + "showDefaultValue": false + }, + "description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key", + "valueDesc": "" + }, + { + "id": "qLUQfhG0ILRX", + "type": "dynamic", + "key": "result", + "valueType": "string", + "label": "result", + "valueDesc": "", + "description": "" } ] - }, - { - "nodeId": "q3ccNXiZIHoS", - "name": "系统配置", - "intro": "", - "avatar": "core/workflow/template/systemConfig", - "flowNodeType": "pluginConfig", - "position": { - "x": 99.73879703925843, - "y": -201.26482361861054 - }, - "version": "4811", - "inputs": [], - "outputs": [] } ], "edges": [ - { - "source": "pluginInput", - "target": "rKBYGQuYefae", - "sourceHandle": "pluginInput-source-right", - "targetHandle": "rKBYGQuYefae-target-left" - }, { "source": "rKBYGQuYefae", "target": "pluginOutput", "sourceHandle": "rKBYGQuYefae-source-right", "targetHandle": "pluginOutput-target-left" + }, + { + "source": "pluginInput", + "target": "a5qdMS7ECNYE", + "sourceHandle": "pluginInput-source-right", + "targetHandle": "a5qdMS7ECNYE-target-left" + }, + { + "source": "a5qdMS7ECNYE", + "target": "rKBYGQuYefae", + "sourceHandle": "a5qdMS7ECNYE-source-right", + "targetHandle": "rKBYGQuYefae-target-left" } - ] + ], + "chatConfig": { + "welcomeText": "", + "variables": [], + "questionGuide": false, + "ttsConfig": { + "type": "web" + }, + "whisperConfig": { + "open": false, + "autoSend": false, + "autoTTSResponse": false + }, + "chatInputGuide": { + "open": false, + "textList": [], + "customUrl": "" + }, + "instruction": "", + "autoExecute": { + "open": false, + "defaultPrompt": "" + }, + "_id": "6710a5619c45325525326719" + } } } diff --git a/packages/plugins/src/WeWork/template.json b/packages/plugins/src/WeWorkWebhook/template.json similarity index 91% rename from packages/plugins/src/WeWork/template.json rename to packages/plugins/src/WeWorkWebhook/template.json index 88bbae6a5392..1e5f7c2ada11 100644 --- a/packages/plugins/src/WeWork/template.json +++ b/packages/plugins/src/WeWorkWebhook/template.json @@ -1,9 +1,9 @@ { "author": "", "version": "4816", - "name": "企业微信机器人 webhook", - "avatar": "/appMarketTemplates/plugin-wework/avatar.svg", - "intro": "向企业微信机器人发起 webhook 请求。", + "name": "企业微信 webhook", + "avatar": "plugins/qiwei", + "intro": "向企业微信机器人发起 webhook 请求。只能内部群使用。", "courseUrl": "https://developer.work.weixin.qq.com/document/path/91770", "showStatus": false, "weight": 10, @@ -19,7 +19,7 @@ "flowNodeType": "pluginInput", "showStatus": false, "position": { - "x": 535.7465806305546, + "x": 537.6357458754286, "y": -201.26482361861054 }, "version": "481", @@ -49,9 +49,9 @@ "key": "发送的消息", "valueType": "string", "label": "发送的消息", - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "required": true, - "description": "", + "description": "发送的消息", "canEdit": true, "value": "", "editField": { @@ -61,7 +61,10 @@ "inputType": "reference", "valueType": "string", "required": true - } + }, + "list": [], + "defaultValue": "", + "toolDescription": "发送的消息" } ], "outputs": [ @@ -354,6 +357,30 @@ "sourceHandle": "rKBYGQuYefae-source-right", "targetHandle": "pluginOutput-target-left" } - ] + ], + "chatConfig": { + "welcomeText": "", + "variables": [], + "questionGuide": false, + "ttsConfig": { + "type": "web" + }, + "whisperConfig": { + "open": false, + "autoSend": false, + "autoTTSResponse": false + }, + "chatInputGuide": { + "open": false, + "textList": [], + "customUrl": "" + }, + "instruction": "", + "autoExecute": { + "open": false, + "defaultPrompt": "" + }, + "_id": "6710a5619c45325525326719" + } } } diff --git a/packages/plugins/src/feishu/template.json b/packages/plugins/src/feishu/template.json index 947eb4793efa..53dc38edcd8a 100644 --- a/packages/plugins/src/feishu/template.json +++ b/packages/plugins/src/feishu/template.json @@ -1,7 +1,7 @@ { "author": "", "version": "488", - "name": "飞书机器人 webhook", + "name": "飞书 webhook", "avatar": "/appMarketTemplates/plugin-feishu/avatar.svg", "intro": "向飞书机器人发起 webhook 请求。", "courseUrl": "https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#f62e72d5", @@ -27,7 +27,7 @@ "version": "481", "inputs": [ { - "renderTypeList": ["reference"], + "renderTypeList": ["input", "reference"], "selectedTypeIndex": 0, "valueType": "string", "canEdit": true, @@ -35,7 +35,9 @@ "label": "content", "description": "需要发送的消息", "required": true, - "toolDescription": "需要发送的消息" + "toolDescription": "需要发送的消息", + "list": [], + "defaultValue": "" }, { "renderTypeList": ["input"], @@ -46,7 +48,8 @@ "label": "hook_url", "description": "飞书机器人地址", "required": true, - "defaultValue": "" + "defaultValue": "", + "list": [] } ], "outputs": [ @@ -508,6 +511,30 @@ "sourceHandle": "qcJpBBVtXsGd-source-right", "targetHandle": "vzreK6vHrPvZ-target-left" } - ] + ], + "chatConfig": { + "welcomeText": "", + "variables": [], + "questionGuide": false, + "ttsConfig": { + "type": "web" + }, + "whisperConfig": { + "open": false, + "autoSend": false, + "autoTTSResponse": false + }, + "chatInputGuide": { + "open": false, + "textList": [], + "customUrl": "" + }, + "instruction": "", + "autoExecute": { + "open": false, + "defaultPrompt": "" + }, + "_id": "6710a5619c45325525326719" + } } } diff --git a/packages/web/components/common/Icon/constants.ts b/packages/web/components/common/Icon/constants.ts index 512fc584e240..6fd523576977 100644 --- a/packages/web/components/common/Icon/constants.ts +++ b/packages/web/components/common/Icon/constants.ts @@ -341,7 +341,9 @@ export const iconPaths = { 'phoneTabbar/me': () => import('./icons/phoneTabbar/me.svg'), 'phoneTabbar/tool': () => import('./icons/phoneTabbar/tool.svg'), 'phoneTabbar/toolFill': () => import('./icons/phoneTabbar/toolFill.svg'), + 'plugins/dingding': () => import('./icons/plugins/dingding.svg'), 'plugins/doc2x': () => import('./icons/plugins/doc2x.svg'), + 'plugins/qiwei': () => import('./icons/plugins/qiwei.svg'), 'plugins/textEditor': () => import('./icons/plugins/textEditor.svg'), point: () => import('./icons/point.svg'), preview: () => import('./icons/preview.svg'), diff --git a/packages/web/components/common/Icon/icons/plugins/dingding.svg b/packages/web/components/common/Icon/icons/plugins/dingding.svg new file mode 100644 index 000000000000..53d772393354 --- /dev/null +++ b/packages/web/components/common/Icon/icons/plugins/dingding.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/plugins/qiwei.svg b/packages/web/components/common/Icon/icons/plugins/qiwei.svg new file mode 100644 index 000000000000..be307bfa49b7 --- /dev/null +++ b/packages/web/components/common/Icon/icons/plugins/qiwei.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 25297d3a1161..aae58ee05a8d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,7 +22,7 @@ importers: version: 13.3.0 next-i18next: specifier: 15.3.0 - version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) + version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) prettier: specifier: 3.2.4 version: 3.2.4 @@ -61,7 +61,7 @@ importers: version: 4.0.2 next: specifier: 14.2.5 - version: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) + version: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) openai: specifier: 4.61.0 version: 4.61.0(encoding@0.1.13) @@ -201,7 +201,7 @@ importers: version: 1.4.5-lts.1 next: specifier: 14.2.5 - version: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) + version: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) nextjs-cors: specifier: ^2.2.0 version: 2.2.0(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)) @@ -277,7 +277,7 @@ importers: version: 2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1) '@chakra-ui/next-js': specifier: 2.1.5 - version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1) + version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1) '@chakra-ui/react': specifier: 2.8.1 version: 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -340,7 +340,7 @@ importers: version: 4.17.21 next-i18next: specifier: 15.3.0 - version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) + version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) papaparse: specifier: ^5.4.1 version: 5.4.1 @@ -563,7 +563,7 @@ importers: version: 1.77.8 ts-jest: specifier: ^29.1.0 - version: 29.2.2(@babel/core@7.24.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.9))(jest@29.7.0(@types/node@20.14.11)(babel-plugin-macros@3.1.0))(typescript@5.5.3) + version: 29.2.2(@babel/core@7.24.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.9))(jest@29.7.0(@types/node@20.14.11)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)))(typescript@5.5.3) use-context-selector: specifier: ^1.4.4 version: 1.4.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(scheduler@0.23.2) @@ -643,6 +643,9 @@ importers: '@nestjs/swagger': specifier: ^7.3.1 version: 7.4.0(@fastify/static@7.0.4)(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.3.10(@nestjs/common@10.3.10(reflect-metadata@0.2.2)(rxjs@7.8.1))(encoding@0.1.13)(reflect-metadata@0.2.2)(rxjs@7.8.1))(reflect-metadata@0.2.2) + crypto: + specifier: ^1.0.1 + version: 1.0.1 dayjs: specifier: ^1.11.7 version: 1.11.11 @@ -3180,8 +3183,8 @@ packages: '@tanstack/react-query@4.36.1': resolution: {integrity: sha512-y7ySVHFyyQblPl3J3eQBWpXZkliroki3ARnBKsdJchlgt7yJLRDUcf4B8soufgiYt3pEQIkBWBx1N9/ZPIeUWw==} peerDependencies: - react: 18.3.1 - react-dom: 18.3.1 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 react-native: '*' peerDependenciesMeta: react-dom: @@ -4499,6 +4502,10 @@ packages: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} + crypto@1.0.1: + resolution: {integrity: sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==} + deprecated: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in. + css-box-model@1.2.1: resolution: {integrity: sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw==} @@ -10477,14 +10484,6 @@ snapshots: next: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) react: 18.3.1 - '@chakra-ui/next-js@2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)': - dependencies: - '@chakra-ui/react': 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - '@emotion/cache': 11.11.0 - '@emotion/react': 11.11.1(@types/react@18.3.1)(react@18.3.1) - next: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) - react: 18.3.1 - '@chakra-ui/number-input@2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)': dependencies: '@chakra-ui/counter': 2.1.0(react@18.3.1) @@ -13228,7 +13227,7 @@ snapshots: axios@1.7.7: dependencies: - follow-redirects: 1.15.9 + follow-redirects: 1.15.9(debug@4.3.7) form-data: 4.0.1 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -13813,6 +13812,8 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 + crypto@1.0.1: {} + css-box-model@1.2.1: dependencies: tiny-invariant: 1.3.3 @@ -15009,8 +15010,6 @@ snapshots: follow-redirects@1.15.6: {} - follow-redirects@1.15.9: {} - follow-redirects@1.15.9(debug@4.3.4): optionalDependencies: debug: 4.3.4 @@ -17358,18 +17357,6 @@ snapshots: react: 18.3.1 react-i18next: 14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - next-i18next@15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1): - dependencies: - '@babel/runtime': 7.24.8 - '@types/hoist-non-react-statics': 3.3.5 - core-js: 3.37.1 - hoist-non-react-statics: 3.3.2 - i18next: 23.11.5 - i18next-fs-backend: 2.3.1 - next: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) - react: 18.3.1 - react-i18next: 14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8): dependencies: '@next/env': 14.2.5 @@ -17396,36 +17383,10 @@ snapshots: - '@babel/core' - babel-plugin-macros - next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8): - dependencies: - '@next/env': 14.2.5 - '@swc/helpers': 0.5.5 - busboy: 1.6.0 - caniuse-lite: 1.0.30001669 - graceful-fs: 4.2.11 - postcss: 8.4.31 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - styled-jsx: 5.1.1(react@18.3.1) - optionalDependencies: - '@next/swc-darwin-arm64': 14.2.5 - '@next/swc-darwin-x64': 14.2.5 - '@next/swc-linux-arm64-gnu': 14.2.5 - '@next/swc-linux-arm64-musl': 14.2.5 - '@next/swc-linux-x64-gnu': 14.2.5 - '@next/swc-linux-x64-musl': 14.2.5 - '@next/swc-win32-arm64-msvc': 14.2.5 - '@next/swc-win32-ia32-msvc': 14.2.5 - '@next/swc-win32-x64-msvc': 14.2.5 - sass: 1.77.8 - transitivePeerDependencies: - - '@babel/core' - - babel-plugin-macros - nextjs-cors@2.2.0(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)): dependencies: cors: 2.8.5 - next: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) + next: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) nextjs-node-loader@1.1.5(webpack@5.92.1): dependencies: @@ -18828,11 +18789,6 @@ snapshots: '@babel/core': 7.24.9 babel-plugin-macros: 3.1.0 - styled-jsx@5.1.1(react@18.3.1): - dependencies: - client-only: 0.0.1 - react: 18.3.1 - stylis@4.2.0: {} stylis@4.3.2: {} @@ -19053,25 +19009,6 @@ snapshots: '@jest/types': 29.6.3 babel-jest: 29.7.0(@babel/core@7.24.9) - ts-jest@29.2.2(@babel/core@7.24.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.9))(jest@29.7.0(@types/node@20.14.11)(babel-plugin-macros@3.1.0))(typescript@5.5.3): - dependencies: - bs-logger: 0.2.6 - ejs: 3.1.10 - fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.14.11)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - jest-util: 29.7.0 - json5: 2.2.3 - lodash.memoize: 4.1.2 - make-error: 1.3.6 - semver: 7.6.3 - typescript: 5.5.3 - yargs-parser: 21.1.1 - optionalDependencies: - '@babel/core': 7.24.9 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.24.9) - ts-loader@9.5.1(typescript@5.5.3)(webpack@5.92.1): dependencies: chalk: 4.1.2 diff --git a/projects/app/src/pages/api/core/chat/clearHistories.ts b/projects/app/src/pages/api/core/chat/clearHistories.ts index 9b5d5d591b04..a6c7b7492a78 100644 --- a/projects/app/src/pages/api/core/chat/clearHistories.ts +++ b/projects/app/src/pages/api/core/chat/clearHistories.ts @@ -48,6 +48,13 @@ async function handler(req: ApiRequestProps<{}, ClearHistoriesProps>, res: NextA source: ChatSourceEnum.online }; } + if (authType === 'apikey') { + return { + teamId: chatTeamId, + appId, + source: ChatSourceEnum.api + }; + } return Promise.reject('Param are error'); })(); diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/context/workflowStatusContext.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/context/workflowStatusContext.tsx index 9780d6f402a2..d7392e44a4c1 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/context/workflowStatusContext.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/context/workflowStatusContext.tsx @@ -73,7 +73,7 @@ const WorkflowStatusContextProvider = ({ children }: { children: ReactNode }) => if (isSaved || !leaveSaveSign.current) return; console.log('Leave auto save'); const data = flowData2StoreData(); - if (!data) return; + if (!data || data.nodes.length === 0) return; await onSaveApp({ ...data, isPublish: false, diff --git a/projects/sandbox/package.json b/projects/sandbox/package.json index 70d5de089868..86830537a032 100644 --- a/projects/sandbox/package.json +++ b/projects/sandbox/package.json @@ -24,13 +24,14 @@ "@nestjs/core": "^10.0.0", "@nestjs/platform-fastify": "^10.3.8", "@nestjs/swagger": "^7.3.1", - "fastify": "^4.27.0", + "crypto": "^1.0.1", "dayjs": "^1.11.7", + "fastify": "^4.27.0", "isolated-vm": "^4.7.2", - "tiktoken": "1.0.17", "node-gyp": "^10.1.0", "reflect-metadata": "^0.2.0", - "rxjs": "^7.8.1" + "rxjs": "^7.8.1", + "tiktoken": "1.0.17" }, "devDependencies": { "@nestjs/cli": "^10.0.0", diff --git a/projects/sandbox/src/sandbox/jsFn/crypto.ts b/projects/sandbox/src/sandbox/jsFn/crypto.ts new file mode 100644 index 000000000000..09474ad0bfc7 --- /dev/null +++ b/projects/sandbox/src/sandbox/jsFn/crypto.ts @@ -0,0 +1,19 @@ +import * as crypto from 'crypto'; +import * as querystring from 'querystring'; + +export const createHmac = (algorithm: string, secret: string) => { + const timestamp = Date.now().toString(); + const stringToSign = `${timestamp}\n${secret}`; + + // 创建 HMAC + const hmac = crypto.createHmac(algorithm, secret); + hmac.update(stringToSign, 'utf8'); + const signData = hmac.digest(); + + const sign = querystring.escape(Buffer.from(signData).toString('base64')); + + return { + timestamp, + sign + }; +}; diff --git a/projects/sandbox/src/sandbox/utils.ts b/projects/sandbox/src/sandbox/utils.ts index cc7b3870824b..e1e506e865df 100644 --- a/projects/sandbox/src/sandbox/utils.ts +++ b/projects/sandbox/src/sandbox/utils.ts @@ -1,8 +1,10 @@ import { RunCodeDto, RunCodeResponse } from 'src/sandbox/dto/create-sandbox.dto'; import IsolatedVM, { ExternalCopy, Isolate, Reference } from 'isolated-vm'; + import { countToken } from './jsFn/tiktoken'; import { timeDelay } from './jsFn/delay'; import { strToBase64 } from './jsFn/str2Base64'; +import { createHmac } from './jsFn/crypto'; const CustomLogStr = 'CUSTOM_LOG'; @@ -42,7 +44,8 @@ function registerSystemFn(jail: IsolatedVM.Reference