@vectorx/agent-runtime 0.0.0-beta-20251112071515 → 0.0.0-beta-20251209102230
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/lib/agent.js +29 -6
- package/lib/schema/file.schema.d.ts +2 -2
- package/lib/schema/message.schema.d.ts +66 -31
- package/lib/schema/message.schema.js +21 -9
- package/package.json +3 -3
package/lib/agent.js
CHANGED
|
@@ -678,23 +678,46 @@ class AgentRuntime {
|
|
|
678
678
|
const path = yield Promise.resolve().then(() => __importStar(require("path")));
|
|
679
679
|
const os = yield Promise.resolve().then(() => __importStar(require("os")));
|
|
680
680
|
let tempFilePath = null;
|
|
681
|
-
console.log("==== input ====", input);
|
|
682
681
|
try {
|
|
683
682
|
const fileData = input.file;
|
|
684
|
-
const
|
|
683
|
+
const rawFilename = fileData.newFilename || fileData.name || fileData.originalFilename || "unknown";
|
|
684
|
+
const baseName = (yield Promise.resolve().then(() => __importStar(require("path")))).basename(String(rawFilename));
|
|
685
|
+
const safeFilename = baseName.replace(/[\/\\:*?"<>|]/g, "_");
|
|
686
|
+
const filename = safeFilename;
|
|
685
687
|
const purpose = input.purpose || "file-extract";
|
|
686
688
|
const mimeType = fileData.type || fileData.mimetype || "application/octet-stream";
|
|
687
|
-
console.log("==== filename ====", filename);
|
|
688
|
-
console.log("==== purpose ====", purpose);
|
|
689
|
-
console.log("==== mimeType ====", mimeType);
|
|
690
689
|
const fileBuffer = fileData.buffer || fileData;
|
|
691
690
|
if (!Buffer.isBuffer(fileBuffer)) {
|
|
692
691
|
throw new Error("无法从上传的文件对象中提取文件内容:buffer 不存在或格式错误");
|
|
693
692
|
}
|
|
693
|
+
this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
|
|
694
|
+
type: AgentEventType.FRAMEWORK_EVENT,
|
|
695
|
+
scene: "AI_SDK_UPLOAD_FILE_PARSE",
|
|
696
|
+
message: "Parsed upload file metadata",
|
|
697
|
+
eventId: this.context.eventID,
|
|
698
|
+
timestamp: new Date().toISOString(),
|
|
699
|
+
data: {
|
|
700
|
+
filename,
|
|
701
|
+
rawFilename,
|
|
702
|
+
mimeType,
|
|
703
|
+
purpose,
|
|
704
|
+
size: typeof (fileData === null || fileData === void 0 ? void 0 : fileData.size) === "number" ? fileData.size : fileBuffer.length,
|
|
705
|
+
hasBuffer: true,
|
|
706
|
+
source: {
|
|
707
|
+
name: fileData === null || fileData === void 0 ? void 0 : fileData.name,
|
|
708
|
+
newFilename: fileData === null || fileData === void 0 ? void 0 : fileData.newFilename,
|
|
709
|
+
originalFilename: fileData === null || fileData === void 0 ? void 0 : fileData.originalFilename,
|
|
710
|
+
mimetype: fileData === null || fileData === void 0 ? void 0 : fileData.mimetype,
|
|
711
|
+
type: fileData === null || fileData === void 0 ? void 0 : fileData.type,
|
|
712
|
+
filepath: fileData === null || fileData === void 0 ? void 0 : fileData.filepath,
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
}));
|
|
694
716
|
const tempDir = os.tmpdir();
|
|
695
717
|
const timestamp = Date.now();
|
|
696
718
|
const randomStr = Math.random().toString(36).substring(2, 15);
|
|
697
|
-
|
|
719
|
+
const ext = path.extname(filename) || "";
|
|
720
|
+
tempFilePath = path.join(tempDir, `upload_${timestamp}_${randomStr}${ext}`);
|
|
698
721
|
fs.writeFileSync(tempFilePath, fileBuffer);
|
|
699
722
|
this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
|
|
700
723
|
type: AgentEventType.FRAMEWORK_EVENT,
|
|
@@ -7,12 +7,12 @@ export declare const uploadFileInputSchema: z.ZodObject<{
|
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
8
|
filename?: string;
|
|
9
9
|
purpose?: string;
|
|
10
|
-
fileContent?: string;
|
|
11
10
|
mimeType?: string;
|
|
11
|
+
fileContent?: string;
|
|
12
12
|
}, {
|
|
13
13
|
filename?: string;
|
|
14
14
|
purpose?: string;
|
|
15
|
-
fileContent?: string;
|
|
16
15
|
mimeType?: string;
|
|
16
|
+
fileContent?: string;
|
|
17
17
|
}>;
|
|
18
18
|
export type UploadFileInputSchema = z.infer<typeof uploadFileInputSchema>;
|
|
@@ -918,25 +918,46 @@ export declare const sendMessageInputSchema: z.ZodObject<{
|
|
|
918
918
|
content?: string | any[] | Record<string, any>;
|
|
919
919
|
name?: string;
|
|
920
920
|
}>]>, "many">;
|
|
921
|
-
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
922
|
-
id: z.ZodString
|
|
923
|
-
filename: z.ZodString
|
|
924
|
-
purpose: z.ZodString
|
|
925
|
-
bytes: z.ZodNumber
|
|
926
|
-
created_at: z.ZodNumber
|
|
921
|
+
files: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
922
|
+
id: z.ZodOptional<z.ZodString>;
|
|
923
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
924
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
925
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
926
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
927
927
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
928
|
-
id: z.ZodString
|
|
929
|
-
filename: z.ZodString
|
|
930
|
-
purpose: z.ZodString
|
|
931
|
-
bytes: z.ZodNumber
|
|
932
|
-
created_at: z.ZodNumber
|
|
928
|
+
id: z.ZodOptional<z.ZodString>;
|
|
929
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
930
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
931
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
932
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
933
933
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
934
|
-
id: z.ZodString
|
|
935
|
-
filename: z.ZodString
|
|
936
|
-
purpose: z.ZodString
|
|
937
|
-
bytes: z.ZodNumber
|
|
938
|
-
created_at: z.ZodNumber
|
|
939
|
-
}, z.ZodTypeAny, "passthrough">>,
|
|
934
|
+
id: z.ZodOptional<z.ZodString>;
|
|
935
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
936
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
937
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
938
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
939
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
940
|
+
url: z.ZodOptional<z.ZodString>;
|
|
941
|
+
type: z.ZodOptional<z.ZodString>;
|
|
942
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
943
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
944
|
+
fileSource: z.ZodOptional<z.ZodString>;
|
|
945
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
946
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
947
|
+
url: z.ZodOptional<z.ZodString>;
|
|
948
|
+
type: z.ZodOptional<z.ZodString>;
|
|
949
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
950
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
951
|
+
fileSource: z.ZodOptional<z.ZodString>;
|
|
952
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
953
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
954
|
+
url: z.ZodOptional<z.ZodString>;
|
|
955
|
+
type: z.ZodOptional<z.ZodString>;
|
|
956
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
957
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
958
|
+
fileSource: z.ZodOptional<z.ZodString>;
|
|
959
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
960
|
+
}, z.ZodTypeAny, "passthrough">>]>, "many">>;
|
|
940
961
|
}, "strip", z.ZodTypeAny, {
|
|
941
962
|
msg?: string;
|
|
942
963
|
history?: ({
|
|
@@ -978,13 +999,20 @@ export declare const sendMessageInputSchema: z.ZodObject<{
|
|
|
978
999
|
content?: string | any[] | Record<string, any>;
|
|
979
1000
|
name?: string;
|
|
980
1001
|
})[];
|
|
981
|
-
files?: z.objectOutputType<{
|
|
982
|
-
id: z.ZodString
|
|
983
|
-
filename: z.ZodString
|
|
984
|
-
purpose: z.ZodString
|
|
985
|
-
bytes: z.ZodNumber
|
|
986
|
-
created_at: z.ZodNumber
|
|
987
|
-
}, z.ZodTypeAny, "passthrough">
|
|
1002
|
+
files?: (z.objectOutputType<{
|
|
1003
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1004
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
1005
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
1006
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
1007
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
1008
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
1009
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1010
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1011
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
1012
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
1013
|
+
fileSource: z.ZodOptional<z.ZodString>;
|
|
1014
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
1015
|
+
}, z.ZodTypeAny, "passthrough">)[];
|
|
988
1016
|
}, {
|
|
989
1017
|
msg?: string;
|
|
990
1018
|
history?: ({
|
|
@@ -1026,13 +1054,20 @@ export declare const sendMessageInputSchema: z.ZodObject<{
|
|
|
1026
1054
|
content?: string | any[] | Record<string, any>;
|
|
1027
1055
|
name?: string;
|
|
1028
1056
|
})[];
|
|
1029
|
-
files?: z.objectInputType<{
|
|
1030
|
-
id: z.ZodString
|
|
1031
|
-
filename: z.ZodString
|
|
1032
|
-
purpose: z.ZodString
|
|
1033
|
-
bytes: z.ZodNumber
|
|
1034
|
-
created_at: z.ZodNumber
|
|
1035
|
-
}, z.ZodTypeAny, "passthrough">
|
|
1057
|
+
files?: (z.objectInputType<{
|
|
1058
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1059
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
1060
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
1061
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
1062
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
1063
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
1064
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1065
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1066
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
1067
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
1068
|
+
fileSource: z.ZodOptional<z.ZodString>;
|
|
1069
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
1070
|
+
}, z.ZodTypeAny, "passthrough">)[];
|
|
1036
1071
|
}>;
|
|
1037
1072
|
export type TextContent = z.infer<typeof textContentSchema>;
|
|
1038
1073
|
export type ImageContent = z.infer<typeof imageContentSchema>;
|
|
@@ -66,14 +66,26 @@ exports.sendMessageInputSchema = zod_1.z.object({
|
|
|
66
66
|
msg: zod_1.z.string(),
|
|
67
67
|
history: exports.messageHistorySchema,
|
|
68
68
|
files: zod_1.z
|
|
69
|
-
.array(zod_1.z
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
.array(zod_1.z.union([
|
|
70
|
+
zod_1.z
|
|
71
|
+
.object({
|
|
72
|
+
id: zod_1.z.string().optional(),
|
|
73
|
+
filename: zod_1.z.string().optional(),
|
|
74
|
+
purpose: zod_1.z.string().optional(),
|
|
75
|
+
bytes: zod_1.z.number().optional(),
|
|
76
|
+
created_at: zod_1.z.number().optional(),
|
|
77
|
+
})
|
|
78
|
+
.passthrough(),
|
|
79
|
+
zod_1.z
|
|
80
|
+
.object({
|
|
81
|
+
url: zod_1.z.string().optional(),
|
|
82
|
+
type: zod_1.z.string().optional(),
|
|
83
|
+
size: zod_1.z.number().optional(),
|
|
84
|
+
mimeType: zod_1.z.string().optional(),
|
|
85
|
+
fileSource: zod_1.z.string().optional(),
|
|
86
|
+
filename: zod_1.z.string().optional(),
|
|
87
|
+
})
|
|
88
|
+
.passthrough(),
|
|
89
|
+
]))
|
|
78
90
|
.optional(),
|
|
79
91
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorx/agent-runtime",
|
|
3
|
-
"version": "0.0.0-beta-
|
|
3
|
+
"version": "0.0.0-beta-20251209102230",
|
|
4
4
|
"description": "Cloud AI agent runtime",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"node": ">=18.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@vectorx/ai-sdk": "0.0.0-beta-
|
|
24
|
-
"@vectorx/functions-framework": "0.0.0-beta-
|
|
23
|
+
"@vectorx/ai-sdk": "0.0.0-beta-20251209102230",
|
|
24
|
+
"@vectorx/functions-framework": "0.0.0-beta-20251209102230",
|
|
25
25
|
"form-data": "^4.0.0",
|
|
26
26
|
"langfuse": "^3.38.4",
|
|
27
27
|
"query-string": "^6.14.1",
|