@fastgpt-plugin/cli 0.1.0-beta.8 → 0.1.0-beta.9
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/index.js +16 -5
- package/package.json +1 -1
- package/templates/tool/index.tool.ts +11 -3
- package/templates/tool/index.toolset.ts +39 -10
package/dist/index.js
CHANGED
|
@@ -543,7 +543,7 @@ var CheckCommand = class extends BaseCommand {
|
|
|
543
543
|
//#endregion
|
|
544
544
|
//#region package.json
|
|
545
545
|
var name = "@fastgpt-plugin/cli";
|
|
546
|
-
var version = "0.1.0-beta.
|
|
546
|
+
var version = "0.1.0-beta.9";
|
|
547
547
|
|
|
548
548
|
//#endregion
|
|
549
549
|
//#region src/constants.ts
|
|
@@ -892,7 +892,10 @@ const InvokeUploadFileInputSchema = z.object({ ...FileCreateSchema.omit({
|
|
|
892
892
|
overwrite: true,
|
|
893
893
|
path: true
|
|
894
894
|
}).shape });
|
|
895
|
-
const InvokeUploadFileOutputSchema = z.object({
|
|
895
|
+
const InvokeUploadFileOutputSchema = z.object({
|
|
896
|
+
...FileMetaSchema.omit({ fileKey: true }).partial().shape,
|
|
897
|
+
accessURL: z.string()
|
|
898
|
+
});
|
|
896
899
|
const InvokeUserInfoOutputSchema = z.object({
|
|
897
900
|
username: z.string(),
|
|
898
901
|
contact: z.string().nullish(),
|
|
@@ -903,9 +906,17 @@ const InvokeUserInfoOutputSchema = z.object({
|
|
|
903
906
|
})),
|
|
904
907
|
groups: z.array(z.object({ name: z.string() }))
|
|
905
908
|
});
|
|
906
|
-
const InvokeMethodEnumSchema = z.enum([
|
|
909
|
+
const InvokeMethodEnumSchema = z.enum([
|
|
910
|
+
"uploadFile",
|
|
911
|
+
"userInfo",
|
|
912
|
+
"wecomCorpToken"
|
|
913
|
+
]);
|
|
907
914
|
const InvokeMethodEnum = InvokeMethodEnumSchema.enum;
|
|
908
915
|
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region ../../packages/domain/src/value-objects/result.vo.ts
|
|
918
|
+
const successResult = (data) => [data, null];
|
|
919
|
+
|
|
909
920
|
//#endregion
|
|
910
921
|
//#region ../../packages/domain/src/value-objects/stream.vo.ts
|
|
911
922
|
var StreamData = class StreamData {
|
|
@@ -1616,14 +1627,14 @@ function createVirtualHostHandler(uploadDir) {
|
|
|
1616
1627
|
const outputPath = path.join(saveDir, `${Date.now()}-${randomUUID().slice(0, 8)}-${fileName}`);
|
|
1617
1628
|
await fs.mkdir(saveDir, { recursive: true });
|
|
1618
1629
|
await fs.writeFile(outputPath, buffer);
|
|
1619
|
-
return {
|
|
1630
|
+
return successResult({
|
|
1620
1631
|
fileName,
|
|
1621
1632
|
contentType,
|
|
1622
1633
|
size: buffer.length,
|
|
1623
1634
|
etag: createHash("md5").update(buffer).digest("hex"),
|
|
1624
1635
|
createTime: /* @__PURE__ */ new Date(),
|
|
1625
1636
|
accessURL: pathToFileURL(outputPath).href
|
|
1626
|
-
};
|
|
1637
|
+
});
|
|
1627
1638
|
}
|
|
1628
1639
|
default: throw new Error(`本地虚拟环境暂不支持反向调用: ${String(method)}`);
|
|
1629
1640
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createToolHandler,
|
|
3
|
+
defineTool,
|
|
4
|
+
type InputSchemaMetaType,
|
|
5
|
+
type OutputSchemaMetaType
|
|
6
|
+
} from '@fastgpt-plugin/sdk-factory';
|
|
2
7
|
import z from 'zod';
|
|
3
8
|
|
|
4
9
|
const handler = createToolHandler({
|
|
5
10
|
inputSchema: z.object({
|
|
6
|
-
delay: z.number()
|
|
11
|
+
delay: z.number().meta({
|
|
12
|
+
title: 'Delay',
|
|
13
|
+
description: 'Delay duration in milliseconds'
|
|
14
|
+
} satisfies InputSchemaMetaType)
|
|
7
15
|
}),
|
|
8
|
-
outputSchema: z.object({}),
|
|
16
|
+
outputSchema: z.object({}).meta({} satisfies OutputSchemaMetaType),
|
|
9
17
|
handler: async (input, _ctx) => {
|
|
10
18
|
await new Promise((resolve) => setTimeout(resolve, input.delay));
|
|
11
19
|
return {};
|
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createToolHandler,
|
|
3
|
+
defineToolSet,
|
|
4
|
+
type InputSchemaMetaType,
|
|
5
|
+
type OutputSchemaMetaType,
|
|
6
|
+
type SecretSchemaMetaType
|
|
7
|
+
} from '@fastgpt-plugin/sdk-factory';
|
|
2
8
|
import z from 'zod';
|
|
3
9
|
|
|
4
10
|
const secretSchema = z.object({
|
|
5
|
-
host: z.string()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
host: z.string().meta({
|
|
12
|
+
title: 'Host',
|
|
13
|
+
isSecret: false
|
|
14
|
+
} satisfies SecretSchemaMetaType),
|
|
15
|
+
port: z.number().meta({
|
|
16
|
+
title: 'Port',
|
|
17
|
+
isSecret: false
|
|
18
|
+
} satisfies SecretSchemaMetaType),
|
|
19
|
+
username: z.string().meta({
|
|
20
|
+
title: 'Username',
|
|
21
|
+
isSecret: false
|
|
22
|
+
} satisfies SecretSchemaMetaType),
|
|
23
|
+
password: z.string().meta({
|
|
24
|
+
title: 'Password',
|
|
25
|
+
isSecret: true
|
|
26
|
+
} satisfies SecretSchemaMetaType),
|
|
27
|
+
database: z.string().meta({
|
|
28
|
+
title: 'Database',
|
|
29
|
+
isSecret: false
|
|
30
|
+
} satisfies SecretSchemaMetaType)
|
|
10
31
|
});
|
|
11
32
|
|
|
12
33
|
const mysqlHandler = createToolHandler({
|
|
13
34
|
inputSchema: z.object({
|
|
14
|
-
query: z.string()
|
|
35
|
+
query: z.string().meta({
|
|
36
|
+
title: 'SQL Query'
|
|
37
|
+
} satisfies InputSchemaMetaType)
|
|
15
38
|
}),
|
|
16
39
|
outputSchema: z.object({
|
|
17
|
-
results: z.array(z.record(z.string(), z.unknown()))
|
|
40
|
+
results: z.array(z.record(z.string(), z.unknown())).meta({
|
|
41
|
+
title: 'Query Results'
|
|
42
|
+
} satisfies OutputSchemaMetaType)
|
|
18
43
|
}),
|
|
19
44
|
secretSchema,
|
|
20
45
|
handler: async (input, ctx) => {
|
|
@@ -36,10 +61,14 @@ const mysqlHandler = createToolHandler({
|
|
|
36
61
|
|
|
37
62
|
const pgsqlHandler = createToolHandler({
|
|
38
63
|
inputSchema: z.object({
|
|
39
|
-
query: z.string()
|
|
64
|
+
query: z.string().meta({
|
|
65
|
+
title: 'SQL Query'
|
|
66
|
+
} satisfies InputSchemaMetaType)
|
|
40
67
|
}),
|
|
41
68
|
outputSchema: z.object({
|
|
42
|
-
results: z.array(z.record(z.string(), z.unknown()))
|
|
69
|
+
results: z.array(z.record(z.string(), z.unknown())).meta({
|
|
70
|
+
title: 'Query Results'
|
|
71
|
+
} satisfies OutputSchemaMetaType)
|
|
43
72
|
}),
|
|
44
73
|
secretSchema,
|
|
45
74
|
handler: async (input, ctx) => {
|