@fastgpt-plugin/helpers 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/common/fn.d.ts +18 -0
  2. package/dist/common/fn.js +48 -0
  3. package/dist/common/fs.d.ts +12 -0
  4. package/dist/common/fs.js +24 -0
  5. package/dist/common/schemas/i18n.d.ts +17 -0
  6. package/dist/common/schemas/i18n.js +3 -0
  7. package/dist/common/schemas/s3.d.ts +2 -0
  8. package/dist/common/schemas/s3.js +14 -0
  9. package/dist/common/zip.d.ts +15 -0
  10. package/dist/common/zip.js +4 -0
  11. package/dist/events/index.d.ts +3 -0
  12. package/dist/events/index.js +1 -0
  13. package/dist/events/schemas.d.ts +3 -0
  14. package/dist/events/schemas.js +50 -0
  15. package/dist/events/type.d.ts +3 -0
  16. package/dist/events/type.js +1 -0
  17. package/dist/fastgpt-ATrPZt7b.js +122 -0
  18. package/dist/i18n-CEMsaKK_.js +16 -0
  19. package/dist/index.d.ts +13 -0
  20. package/dist/index.js +13 -0
  21. package/dist/models/schemas.d.ts +234 -0
  22. package/dist/models/schemas.js +74 -0
  23. package/dist/req-Cgf43aEm.js +55 -0
  24. package/dist/s3-CkZHJIa9.d.ts +14 -0
  25. package/dist/schemas-CMeQg8vV.d.ts +137 -0
  26. package/dist/tools/constants.d.ts +75 -0
  27. package/dist/tools/constants.js +72 -0
  28. package/dist/tools/helper.d.ts +260 -0
  29. package/dist/tools/helper.js +55 -0
  30. package/dist/tools/schemas/fastgpt.d.ts +203 -0
  31. package/dist/tools/schemas/fastgpt.js +3 -0
  32. package/dist/tools/schemas/req.d.ts +3 -0
  33. package/dist/tools/schemas/req.js +3 -0
  34. package/dist/tools/schemas/tool.d.ts +2157 -0
  35. package/dist/tools/schemas/tool.js +132 -0
  36. package/dist/workflows/schemas.d.ts +45 -0
  37. package/dist/workflows/schemas.js +26 -0
  38. package/dist/zip-DjBhByRt.js +8857 -0
  39. package/package.json +36 -0
@@ -0,0 +1,55 @@
1
+ import "../i18n-CEMsaKK_.js";
2
+ import "../req-Cgf43aEm.js";
3
+ import { n as FlowNodeOutputTypeEnum } from "../fastgpt-ATrPZt7b.js";
4
+ import { ToolConfigSchema, ToolSetConfigSchema } from "./schemas/tool.js";
5
+ import z, { ZodError, ZodType } from "zod";
6
+
7
+ //#region src/tools/helper.ts
8
+ function defineTool(tool) {
9
+ const versionList = tool.versionList.map((version) => {
10
+ return {
11
+ ...version,
12
+ outputs: version.outputs.map((output) => {
13
+ return {
14
+ ...output,
15
+ type: output.type ?? FlowNodeOutputTypeEnum.enum.static,
16
+ id: output.id ?? output.key
17
+ };
18
+ })
19
+ };
20
+ });
21
+ return ToolConfigSchema.parse({
22
+ ...tool,
23
+ versionList
24
+ });
25
+ }
26
+ function defineToolSet(toolset) {
27
+ return ToolSetConfigSchema.parse(toolset);
28
+ }
29
+ const exportTool = ({ toolCb, InputType, OutputType, config }) => {
30
+ const cb = async (props, e) => {
31
+ try {
32
+ const output = await toolCb(InputType.parse(props), e);
33
+ return { output: OutputType.parse(output) };
34
+ } catch (error) {
35
+ if (error instanceof ZodError) {
36
+ const issues = error.issues;
37
+ if (issues.length === 0) throw new Error("Unknown Zod error");
38
+ const paths = [];
39
+ for (const issue of issues) if (issue.path) paths.push(...issue.path.flat());
40
+ return { error: `Invalid parameters. Please check: ${Array.from(new Set(paths)).filter(Boolean).join(", ")}` };
41
+ }
42
+ return { error };
43
+ }
44
+ };
45
+ return {
46
+ ...config,
47
+ cb
48
+ };
49
+ };
50
+ const exportToolSet = ({ config }) => {
51
+ return { ...config };
52
+ };
53
+
54
+ //#endregion
55
+ export { defineTool, defineToolSet, exportTool, exportToolSet };
@@ -0,0 +1,203 @@
1
+ import z from "zod";
2
+
3
+ //#region src/tools/schemas/fastgpt.d.ts
4
+ declare const FlowNodeInputTypeEnum: z.ZodEnum<{
5
+ reference: "reference";
6
+ input: "input";
7
+ textarea: "textarea";
8
+ numberInput: "numberInput";
9
+ switch: "switch";
10
+ select: "select";
11
+ multipleSelect: "multipleSelect";
12
+ JSONEditor: "JSONEditor";
13
+ addInputParam: "addInputParam";
14
+ selectApp: "selectApp";
15
+ customVariable: "customVariable";
16
+ selectLLMModel: "selectLLMModel";
17
+ settingLLMModel: "settingLLMModel";
18
+ selectDataset: "selectDataset";
19
+ selectDatasetParamsModal: "selectDatasetParamsModal";
20
+ settingDatasetQuotePrompt: "settingDatasetQuotePrompt";
21
+ hidden: "hidden";
22
+ custom: "custom";
23
+ fileSelect: "fileSelect";
24
+ }>;
25
+ declare const WorkflowIOValueTypeEnum: z.ZodEnum<{
26
+ string: "string";
27
+ number: "number";
28
+ boolean: "boolean";
29
+ object: "object";
30
+ selectApp: "selectApp";
31
+ selectDataset: "selectDataset";
32
+ arrayString: "arrayString";
33
+ arrayNumber: "arrayNumber";
34
+ arrayBoolean: "arrayBoolean";
35
+ arrayObject: "arrayObject";
36
+ arrayAny: "arrayAny";
37
+ any: "any";
38
+ chatHistory: "chatHistory";
39
+ datasetQuote: "datasetQuote";
40
+ dynamic: "dynamic";
41
+ }>;
42
+ declare const LLMModelTypeEnum: z.ZodEnum<{
43
+ all: "all";
44
+ classify: "classify";
45
+ extractFields: "extractFields";
46
+ toolCall: "toolCall";
47
+ }>;
48
+ declare const FlowNodeOutputTypeEnum: z.ZodEnum<{
49
+ hidden: "hidden";
50
+ dynamic: "dynamic";
51
+ source: "source";
52
+ static: "static";
53
+ error: "error";
54
+ }>;
55
+ declare const SecretInputItemSchema: z.ZodObject<{
56
+ key: z.ZodString;
57
+ label: z.ZodString;
58
+ description: z.ZodOptional<z.ZodString>;
59
+ required: z.ZodOptional<z.ZodBoolean>;
60
+ inputType: z.ZodEnum<{
61
+ input: "input";
62
+ numberInput: "numberInput";
63
+ switch: "switch";
64
+ select: "select";
65
+ secret: "secret";
66
+ }>;
67
+ defaultValue: z.ZodOptional<z.ZodAny>;
68
+ list: z.ZodOptional<z.ZodArray<z.ZodObject<{
69
+ label: z.ZodString;
70
+ value: z.ZodString;
71
+ }, z.core.$strip>>>;
72
+ }, z.core.$strip>;
73
+ type SecretInputItemType = z.infer<typeof SecretInputItemSchema>;
74
+ declare const InputSchema: z.ZodObject<{
75
+ key: z.ZodString;
76
+ label: z.ZodString;
77
+ referencePlaceholder: z.ZodOptional<z.ZodString>;
78
+ placeholder: z.ZodOptional<z.ZodString>;
79
+ defaultValue: z.ZodOptional<z.ZodAny>;
80
+ selectedTypeIndex: z.ZodOptional<z.ZodNumber>;
81
+ renderTypeList: z.ZodArray<z.ZodEnum<{
82
+ reference: "reference";
83
+ input: "input";
84
+ textarea: "textarea";
85
+ numberInput: "numberInput";
86
+ switch: "switch";
87
+ select: "select";
88
+ multipleSelect: "multipleSelect";
89
+ JSONEditor: "JSONEditor";
90
+ addInputParam: "addInputParam";
91
+ selectApp: "selectApp";
92
+ customVariable: "customVariable";
93
+ selectLLMModel: "selectLLMModel";
94
+ settingLLMModel: "settingLLMModel";
95
+ selectDataset: "selectDataset";
96
+ selectDatasetParamsModal: "selectDatasetParamsModal";
97
+ settingDatasetQuotePrompt: "settingDatasetQuotePrompt";
98
+ hidden: "hidden";
99
+ custom: "custom";
100
+ fileSelect: "fileSelect";
101
+ }>>;
102
+ valueType: z.ZodEnum<{
103
+ string: "string";
104
+ number: "number";
105
+ boolean: "boolean";
106
+ object: "object";
107
+ selectApp: "selectApp";
108
+ selectDataset: "selectDataset";
109
+ arrayString: "arrayString";
110
+ arrayNumber: "arrayNumber";
111
+ arrayBoolean: "arrayBoolean";
112
+ arrayObject: "arrayObject";
113
+ arrayAny: "arrayAny";
114
+ any: "any";
115
+ chatHistory: "chatHistory";
116
+ datasetQuote: "datasetQuote";
117
+ dynamic: "dynamic";
118
+ }>;
119
+ valueDesc: z.ZodOptional<z.ZodString>;
120
+ value: z.ZodOptional<z.ZodUnknown>;
121
+ description: z.ZodOptional<z.ZodString>;
122
+ required: z.ZodOptional<z.ZodBoolean>;
123
+ toolDescription: z.ZodOptional<z.ZodString>;
124
+ canEdit: z.ZodOptional<z.ZodBoolean>;
125
+ isPro: z.ZodOptional<z.ZodBoolean>;
126
+ maxLength: z.ZodOptional<z.ZodNumber>;
127
+ canSelectFile: z.ZodOptional<z.ZodBoolean>;
128
+ canSelectImg: z.ZodOptional<z.ZodBoolean>;
129
+ maxFiles: z.ZodOptional<z.ZodNumber>;
130
+ inputList: z.ZodOptional<z.ZodArray<z.ZodObject<{
131
+ key: z.ZodString;
132
+ label: z.ZodString;
133
+ description: z.ZodOptional<z.ZodString>;
134
+ required: z.ZodOptional<z.ZodBoolean>;
135
+ inputType: z.ZodEnum<{
136
+ input: "input";
137
+ numberInput: "numberInput";
138
+ switch: "switch";
139
+ select: "select";
140
+ secret: "secret";
141
+ }>;
142
+ defaultValue: z.ZodOptional<z.ZodAny>;
143
+ list: z.ZodOptional<z.ZodArray<z.ZodObject<{
144
+ label: z.ZodString;
145
+ value: z.ZodString;
146
+ }, z.core.$strip>>>;
147
+ }, z.core.$strip>>>;
148
+ llmModelType: z.ZodOptional<z.ZodEnum<{
149
+ all: "all";
150
+ classify: "classify";
151
+ extractFields: "extractFields";
152
+ toolCall: "toolCall";
153
+ }>>;
154
+ list: z.ZodOptional<z.ZodArray<z.ZodObject<{
155
+ label: z.ZodString;
156
+ value: z.ZodString;
157
+ }, z.core.$strip>>>;
158
+ markList: z.ZodOptional<z.ZodArray<z.ZodObject<{
159
+ label: z.ZodString;
160
+ value: z.ZodNumber;
161
+ }, z.core.$strip>>>;
162
+ step: z.ZodOptional<z.ZodNumber>;
163
+ max: z.ZodOptional<z.ZodNumber>;
164
+ min: z.ZodOptional<z.ZodNumber>;
165
+ precision: z.ZodOptional<z.ZodNumber>;
166
+ }, z.core.$strip>;
167
+ declare const OutputSchema: z.ZodObject<{
168
+ id: z.ZodOptional<z.ZodString>;
169
+ type: z.ZodOptional<z.ZodEnum<{
170
+ hidden: "hidden";
171
+ dynamic: "dynamic";
172
+ source: "source";
173
+ static: "static";
174
+ error: "error";
175
+ }>>;
176
+ key: z.ZodString;
177
+ valueType: z.ZodEnum<{
178
+ string: "string";
179
+ number: "number";
180
+ boolean: "boolean";
181
+ object: "object";
182
+ selectApp: "selectApp";
183
+ selectDataset: "selectDataset";
184
+ arrayString: "arrayString";
185
+ arrayNumber: "arrayNumber";
186
+ arrayBoolean: "arrayBoolean";
187
+ arrayObject: "arrayObject";
188
+ arrayAny: "arrayAny";
189
+ any: "any";
190
+ chatHistory: "chatHistory";
191
+ datasetQuote: "datasetQuote";
192
+ dynamic: "dynamic";
193
+ }>;
194
+ valueDesc: z.ZodOptional<z.ZodString>;
195
+ value: z.ZodOptional<z.ZodUnknown>;
196
+ label: z.ZodOptional<z.ZodString>;
197
+ description: z.ZodOptional<z.ZodString>;
198
+ defaultValue: z.ZodOptional<z.ZodAny>;
199
+ required: z.ZodOptional<z.ZodBoolean>;
200
+ }, z.core.$strip>;
201
+ type OutputType = z.infer<typeof OutputSchema>;
202
+ //#endregion
203
+ export { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, InputSchema, LLMModelTypeEnum, OutputSchema, OutputType, SecretInputItemSchema, SecretInputItemType, WorkflowIOValueTypeEnum };
@@ -0,0 +1,3 @@
1
+ import { a as OutputSchema, i as LLMModelTypeEnum, n as FlowNodeOutputTypeEnum, o as SecretInputItemSchema, r as InputSchema, s as WorkflowIOValueTypeEnum, t as FlowNodeInputTypeEnum } from "../../fastgpt-ATrPZt7b.js";
2
+
3
+ export { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, InputSchema, LLMModelTypeEnum, OutputSchema, SecretInputItemSchema, WorkflowIOValueTypeEnum };
@@ -0,0 +1,3 @@
1
+ import "../../s3-CkZHJIa9.js";
2
+ import { C as ToolHandlerReturnType, S as ToolHandlerReturnSchema, _ as StreamMessageTypeEnum, b as ToolContextType, f as StreamDataAnswerTypeEnum, g as StreamMessageType, h as StreamMessageSchema, m as StreamDataType, p as StreamDataSchema, v as SystemVarSchema, x as ToolHandlerFunctionType, y as SystemVarType } from "../../schemas-CMeQg8vV.js";
3
+ export { StreamDataAnswerTypeEnum, StreamDataSchema, StreamDataType, StreamMessageSchema, StreamMessageType, StreamMessageTypeEnum, SystemVarSchema, SystemVarType, ToolContextType, ToolHandlerFunctionType, ToolHandlerReturnSchema, ToolHandlerReturnType };
@@ -0,0 +1,3 @@
1
+ import { a as SystemVarSchema, i as StreamMessageTypeEnum, n as StreamDataSchema, o as ToolHandlerReturnSchema, r as StreamMessageSchema, t as StreamDataAnswerTypeEnum } from "../../req-Cgf43aEm.js";
2
+
3
+ export { StreamDataAnswerTypeEnum, StreamDataSchema, StreamMessageSchema, StreamMessageTypeEnum, SystemVarSchema, ToolHandlerReturnSchema };